player_model_export_guide

This is an old revision of the document!


For this tutorial I'll be using f0rqu3's Python export scripts for Blender, found [url=http://tremx.googlecode.com/files/2009_02_14_blendermd320080828_TEST.zip]here[/url] or [url=http://www.moddb.com/games/quake-iii-arena/downloads/blender-md3-import-export-tool]here[/url].

I'll assume that you have a basic working knowledge of modeling, animation, armatures, object manipulation, materials, UV-mapping, and the Blender interface. If you have any issues with these, I recommend checking the official Blender homepage for help: http://www.blender.org/education-help/

There are many people around the world sharing their knowledge and experience in using this great 3D tool, so apart from the Blender homepage, there are lots of other pages to find very useful and interesting information, such as: http://blenderart.org/issues/ Just ask me if you have any questions, or if some parts of this article aren't very clear. Let me know and I'll do my best to fix it.

Briefing on Segmentation of Models

Quake 3's (idTech3) player models are segmented. So what does that mean? It basically means they're not one object, but consist of several pieces that can be animated separately, and that each segment can be rotated as needed. While not all games based on the idTech3 engine use segmented models, OpenArena for instance has few non-segmented models, the majority do.

What does that mean for a regular player?

  • The model can do two actions at the time (e.g. run and shoot, or jump and gesture)
  • Parts of the model can rotate separately from each other (e.g. model raises his head when the player looks up)

Usually humanoid models are divided into 3 segments:

  • Legs (also referred as 'lower')
  • Torso
  • Head

The downside of these divisions are:

  • Unless connections between body parts are covered with geometry, seams are very visible
  • Under some angles, some animations can cause body parts to overlay on each other (e.g. elbows go through knees when model is in a crouching position, and gesturing while looking down)
  • They can be difficult to export
  • More on this later]You have to use an animation.cfg file

Each model doesn't have to be one object; it might be set of objects (exported as surfaces) where each object can be drawn with a different shader and/or texture. An example of this is the human trooper from Tremulous, who has 'Light armor' as part of its torso model, but it's skinned with different textures and also uses a shader that turns it invisible if the human doesn't have armor on (at least that's how the helmet head shader works). This way, many models can use the same images as texture sources, while using different shaders.

You'll need to rig with armature objects. You may have already noticed (by importing MD3 models) that each model has separate animations (the only animations that are synced are death animations). My idea was to make separate armatures for each part of the body, but still connect them using 'empty' objects. In fact, that's how segments of model are connected - by empty objects called 'tags', that can carry information about rotation and location. This way, I could animate both upper and lower body animations and animations of both at once (like for the death animations).

Also, I could see the how the animations would look in-game. So how did I put these parts together?

<image missing>

Example locations for some of the empties

<image missing>

Here I've set leg armatures to fit the leg's shape. I made the hip bone the 'oldest' bone or ultimate parent (below selected bone) and I also added a 'magic bone' (the selected bone) which is a child of the hip bone, and set it to be a 'hinge'.

<image missing>

This makes the magic bone always keep its original rotation (always pointing up, unless otherwise needed). I added an empty object, and then while in Pose Mode, I first selected the empty and then the 'magic' bone and parented it to the empty object. This created a point for the upper body armature to be fixed to.

The next step was to add an upper body armature in place of where the empty object was. So, I selected the empty and snapped cursor to it, and added an armature. In Object Mode, (making sure that the center of the armature aligned with the empty) I made the armature a child of the empty.

<image missing>

Then using Edit Mode, I made the armature fit the model and added a special bone for the head and parented the empty (another one) to that bone for fixing the head. After doing so, I parented the empty object (the one I've just set to be a child of the head bone) to head (the one with a real mesh).

<image missing>

(The pink box on the screenshot is also an empty) And here I've also done the whole parenting thing for an empty used for a weapon (a child of the hand bone).

What do we have now?

The Lower armature is parented to the Torso's empty, and that is parented to upper body's armature and has two children:

  • The Head empty which is parent for the Head object
  • Weapon empty that is parent for the weapon (but that's not necessary, it's just there for animation previews)

Now, parent each armature to the right part of the body (lower to legs, upper to torso) and start weight painting, moving bones around while checking how it distorts topology of the mesh, then fixing it up, and remodeling as needed.

When you feel that you are alright with what you have, take a look into the animation.cfg file to see what animations are needed and then make your own. Here is the animation.cfg file for Tremulous' basic human model

animation config file sex m footsteps custom first frame, num frames, looping frames, frames per second 0 30 0 25 BOTH_DEATH1 29 1 0 25 BOTH_DEAD1 30 30 0 25 BOTH_DEATH2 59 1 0 25 BOTH_DEAD2 60 30 0 25 BOTH_DEATH3 89 1 0 25 BOTH_DEAD3 90 40 0 20 TORSO_GESTURE 130 6 0 15 TORSO_ATTACK (MUST NOT CHANGE – hand animation is synced to this) 136 6 0 15 TORSO_ATTACK2 (MUST NOT CHANGE – hand animation is synced to this) 142 5 0 20 TORSO_DROP (MUST NOT CHANGE – hand animation is synced to this) 147 4 0 20 TORSO_RAISE (MUST NOT CHANGE – hand animation is synced to this) 151 1 0 15 TORSO_STAND 152 1 0 15 TORSO_STAND2 153 8 8 16 LEGS_WALKCR 161 12 12 20 LEGS_WALK 173 9 9 15 LEGS_RUN 182 10 10 20 LEGS_BACK 192 10 10 15 LEGS_SWIM 202 8 0 15 LEGS_JUMP 210 1 0 15 LEGS_LAND 202 8 0 15 LEGS_JUMPB 210 1 0 15 LEGS_LANDB 220 10 10 15 LEGS_IDLE 230 10 10 15 LEGS_IDLECR 240 7 7 15 LEGS_TURN [/tt] <image missing> Each of these animations must be done… or at least some of them. Tips on Animating * A good way of doing animations is to make actions for every animation (see above) which is extremely useful when putting animations together * The animations for MD3's start at frame 0, but in Blender they start from frame 1 (note:, so if the BOTH_DEATH1 animation starts at frame 0 and ends at 29 (30 frames), in Blender it would start at frame 1 and end at frame 30. * For the Torso, the animation.cfg shows the correct frames for animation, but for the legs, after the 'BOTH_DEATH's, they don't show the real frames from the .blend. This is because the starting frames for the 'legs only' animation are added on top of the ending frames of the last 'torso only' animations. So in our example, the 'torso only' animations start at frame 90 and end at 153, for a total of 63 frames. In the real MD3 file, the 'legs only' animations start at frame 90, but in the animation.cfg file, we see that it adds 63 frames of 'torso only' animation frames (63 of them) so we start from 153 instead. We end the 'legs only' animations in the MD3 at frame 184, but in the animation.cfg, it adds an extra 63 frames so that the legs animations end at frame 247, which is correct. Don't rely on these values, they are only here to make you understand the rules. The last tip is not important until we get to the stage where we put our animations in order using the NLA editor. If you are replacing a default player model with one of your own, then you might want to do it the same way I did. All of this is a good general work-flow for making a model that would be okay to exported to MD3. Setting the Model and Exporting It Before you export, check that your model is the right size, rotation and location. Just import another MD3 player model for comparison. Now if when you're done, you might say &quot;Oh noes! It's out of scale and wrong rotation!&quot;. Don't worry.. it can be fixed. Add an empty and parent it to our lower armature (Remember that its the ultimate parent of whole model, and everything else is somewhat it's child). First rotate it around the Z-axis so instead of facing towards you in 'Front' view, it would face you in the 'Right' view. Do this by pressing [R] then [Z] and typing '90', and then press [Enter]. The whole mesh should follow. <image missing> You can see the empty in the picture above - its this big cross. Don't freak out, it's still a good old empty, just viewed in a different way and resized. Check the picture below: <image missing> Now scale up the empty, until you are happy with it. This scaling isn't final, so write down the amount that you've scaled it up (you'll need it in a minute). Exporting the Model 1. Save the .blend file. 2. Delete the upper armature, torso and head (and all of the empties except the torso's empty). 3. Save as a new .blend file (give it a new name). 4. Open up your .blend file saved in step 1, and delete the lower armature, legs, and head (and weapon if you had one). 5. Make sure that the torso's empty is in the middle of space, then rotate it 90 degrees along the Z-axis, and scale it up by the same amount that you scaled it up using empty (the amount you wrote down). 6. Save what you've done as a totally new .blend file. 7. Once again, open the file from step 8. This time, delete all but the head's empty and the head parented to it. 9. Repeat step 5 for the head's empty. Setting Up Animations <image missing> 1. Open the .blend file that contains only the legs. 2. Import the legs from the basic human model in to another layer. 3. Split the main 3D window into 3, and press the lock button on the middle one to be able to view 2 layers at once. 4. Open the NLA editor in a window and start putting animations into the right order, checking against the imported mesh. 5. In your model, add a new empty and name it as tag_torso . But first, in the imported model, add a character to the end of its empty (like tag_torso_ , because Blender won't let you give two different objects the same name. 6. Snap it to the torso's empty which we made earlier. 7. Parent the torso's empty to tag_torso (the newly created one, not the old one). 8. Move the torso's empty, our empty for rotating and resizing, and lower armature to another layer (This is for easier selection of things we want to export). 9. Set the model to its final animation frame: This is the one where the basic human model freaks out and doesn't change its pose anymore (it's frame ~170 something or so, just a frame with no more animations). 10. Now select every model you want exported and also the newly named tag_torso and export it. Also, while you're exporting the upper body, remember that you'll need to repeat the process of copying the empties and naming them as tags for the different 3 tags: tag_head, tag_weapon, and of course tag_torso. (check the names from the imported model). Finally, the little text window that pops up when exporting is the location where the game engine will look for the texture/shader named as the material that we added to our model in Blender (I'll write more about this later, that and about .skin files). Eg: models/player/priestess/priestessbody Cheers! Article by Krzysztof 'RedSky' Kozlowski, edited by Cameron 'cron' Fraser

  • player_model_export_guide.1511398044.txt.gz
  • Last modified: 2017/11/22 16:47
  • by romdos