OpenArena Message Boards

OpenArena Contributions => Models => Topic started by: fromhell on October 04, 2014, 03:40:38 PM

Title: [OA3] how to EYES
Post by: fromhell on October 04, 2014, 03:40:38 PM

Currently OA3 is not released, but the code is out there!

- OA3 eyes are not sphere meshes that rotate and turn.  They are polygons with UVmaps calculated dynamically.
- Q3 mods can't use this since the method currently uses cgame to give the eye source target vectors to the engine.

You'll need:

- Compiled OpenArena/Engine ( binary
- Compiled OpenArena/leixperimental ( QVMs
- Some creative experience with a [insert 3d modeling suite that can export MDR/MD3 here] because i'm not going to hold your hand on making a complete character

1.  Create your eye polys

Your eyes should be done in a new 'special' head mesh that should be exported with a different name, like headhi.md3 (NOTE: loading headhi.* is not implemented in cgame yet, but would be to retain compatibility with mods that don't support eyes)

You don't have to alter the uvmaps of your eyes, but just keep each eye with their own material/surface  so the special eye shaders can work.

2. Creating the eye texture

If your character needs to have a unique eyeball texture you can create an eye texture.  OA3's eye textures are stored in


where they'll be isolated from the player models into a common place where eyes can go.

The iris and pupil must be located in the center of the image, and the rest of the texture should be the sclera.
Suggested resolution is 128x128
Unlike Source engine, you can use one eye texture for both eyes and it will work.

3. Write the config
OA3 reads eyes.cfg from your models/players/modelname directory.  This is an eyes configuration file
// Eyes positions, loaded separately to not muck with animations on mods that don't recognize this key.
eyes 2.10298 1.45542 3.39689

The values following the word 'eyes' are X, Y, Z coordinates for the right eye. X is flipped for the other eye and uses the same Y and Z coordinates automatically.
You can make these coordinates easily by making a sphere, then moving the sphere in Object Mode into your model's eye socket, and fitting that sphere in place.
You can then use the origin values from its transformed position for your eyes config.
(This method can also apply to Source Engine btw)

4. Write the eyes shaders

Make one shader for each eye, but the difference in the two are the tcGens they use

tcGen eyeleft

tcGen eyeright

For best results you should use clampmap for the texture so there will be no repeating eyes of horror (unless you want that)

5. TESTING ingame

You should use cg_cameramode 1 and cg_thirdPerson 1 to orbit around your character without turning the model.  If things are done right, the eyes should now be looking to where you're actually aiming.

Title: Re: [OA3] how to EYES
Post by: andrewj on October 04, 2014, 08:02:20 PM
This is a pretty cool extension for the ol' idtech3 engine.

Did you consider using MD3 tags for the eye positions?

Title: Re: [OA3] how to EYES
Post by: fromhell on October 04, 2014, 08:20:55 PM
Yes, though I prototyped using hard values in cgame first since it was so easy to adjust numbers there.  Having tag eyes would help the compatibility issue and they could have a default looking forward if they don't have an eyelookat vector at all or somehow take the client's angle regardless of head's angle in client rather than cgame. somehow

There's also an annoying bug with where the eyes look during death sequences.  I would have to do a tag on the torso to fix that so it overrides eyelookat in certain animation sequences, like death and taunt (so sarcastic rolling of eyes is supported).

Title: Re: [OA3] how to EYES
Post by: revanic on October 04, 2014, 08:58:38 PM
Pretty awesome! however, someone may want to have lopsided eyes. Perhaps add a left eye override that is only used when specified?