MD5 Export Process

From Mod Wiki

Exporting animated models into the game is relatively pain free process but is easy to get wrong if not making sure it is done right. So, lets go through right from the start the most common eventualities you'll come across...

Where To Start?

Model Prepping in Maya

Start by taking the freshly made model into Maya. Once there, usually the best place to start is to 'separate' it into all the parts you think should be their own piece (eg. wheels, detachable components) or if you just think it will be easier to skin as a separate piece of mesh. Next you will want to assign your materials to the relevant pieces. The material is linked with a diffuse texture of the same name in the same path as the material name, for example the material for the GPMG is models/weapons/gdf_gpmg/gpmg_roler, in Maya you would link the diffuse texture to a file in your ETQW folder, eg. /base/models/weapons/gdf_gpmg/gpmg_roler.tga. This file doesn't have to be referenced in the game.

Begin the Rigging Process

Now you are ready to begin the rigging process. Add joints to all parts of the mesh you think will needed to deform the mesh nicely and also that you think might be needed to make the model functional in game, and that might be needed for scripting purposes. These might include:

  • An origin joint
  • Exit points for vehicles
  • Muzzle flash points for weapons

It is a good idea to name your joints (as with anything) at this point, so you or anyone else who has to deal with the model later knows what they are all for.

Joint Considerations

The main orientation you want for joints is the same as Maya. X = forwards, Z = right, Y = up This is important for joints that will be controlled by the gamecode, ie not just keyframe animated.

Also, for large models, make sure that any joint is never any more than 256 units away from its parent joint, as this can cause problems (If you have unknowingly done so you will get a warning anyway telling you which joint/s need fixing).

Bind Meshes to Joints

When you have your rig and the joints are all parented the way you want, you should now be ready to bind the mesh/es to the joints (use 'smooth bind' option). Once you have all the meshes weighted to your liking you are ready save the file and move on. Note: If any of the meshes or the groups they are in have any history (translations, mesh tweaks etc) make sure to freeze them then delete history.

Setting Up a Reference File

You won't want to animate in this file, it will be used as a reference file. Create a new Maya file and select File > Create Reference (click the options box for this menu). Under the section name 'Name Clash Options' make sure Use Namespaces is unchecked, and resolve 'all nodes' with 'this string' and in the box type a name that will be a prefix for everything in the reference file. For this example I would type GPMG and then click the reference box at bottom left of this window. This will bring up a file selection window where you select the reference file you made a moment ago. If this has worked, your reference file should be loaded into your new file, but now you will notice everything has the name you just set prefixing everything. Save this as a separate file (think of it as a child of the parent file). You can now animate in this and any subsequent files made from it safe in the knowledge you are not changing anything in your master reference file.

Also, should you need to make any core changes to the master file, such as adding new joints, reskinning or applying different materials for example, these changes will all be present in you child files. So, at this point, you should be ready to start animating the model. Well, go on then... :)


Animate the model as usual in Maya. For those who are new to animation, The Animator’s Survival Kit by Richard Williams is a good place to start. There are also scores of tutorials on the Internet for Maya-specific animation techniques (eg.

It is good practice, however, not to spend too long perfecting animations until you know they are working in game, so let's look at the export process that you should now be ready for and get the model into the game!

The Export File

Here's a quick example taken from the GPMG first person weapon export file (found in base/def/weapons/gpmg.def):

export hauser {
       options -prefix GPMG_ -sourcedir models/weapons/gdf_gpmg/dev_sd 
       -destdir models/weapons/gdf_gpmg/ 
       -keep joint1 joint2  -keepmesh gpmg ammo_cover_lock gpmg_charge_handle

       mesh	gpmg_base_file.mb	-dest view.md5mesh
       anim	gpmg_idle.mb		-dest idle.md5anim -xyzprecision 0.001
       anim	gpmg_raise.mb	        -dest raise.md5anim
       anim	gpmg_lower.mb		-dest lower.md5anim
       anim	gpmg_fire.mb		-dest fire.md5anim
       anim	gpmg_reload.mb		-dest reload.md5anim
       anim	gpmg_idle_zoom.mb	-dest idle_zoom.md5anim
       anim	gpmg_fire_zoom.mb	-dest fire_zoom.md5anim
       anim	gpmg_zoom_out.mb	-dest zoom_out.md5anim
       anim	gpmg_zoom_in.mb		-dest zoom_in.md5anim
       anim 	gpmg_start_sprint.mb	-dest start_sprint.md5anim
       anim 	gpmg_leave_sprint.mb	-dest leave_sprint.md5anim

The above example contains options most frequently used when exporting .md5’s:

  • -prefix - When referencing the master file, Maya will ask for a prefix that will be added to the joint names. Specify that prefix here.
  • -scale - You can tweak the scale of the model on export. This can be very handy if a designer decides they want something bigger but it has already been rigged and animated. It is of course better to rescale/rig/animate it in Maya if it is not much work, as it can end up being confusing otherwise.
  • -align - This will align the specified Maya node and all of its children to face the proper direction.
  • -keep - The engine will prune joints that have little or no skin weights attached to them. If such joints are necessary to keep in the .MD5, they must be specified here.
  • -dest - Destination filename. Usage: -dest [filename]

Some additional commands that may be useful:

  • -rename - Renames joints. Usage: -rename [joint name] [new name]
  • -parent - Re-parents a joint. Usage: -parent [joint name] [new parent]
  • -range - Sets a frame range. Usage: -range [start frame] [end frame]
  • -cycleStart - Usage: -cycleStart [first frame of cycle]
  • -rotate - Usage: -rotate [yaw]
  • -nomesh
  • -clearorigin
  • -clearoriginaxis
  • -ignorescale
  • -xyzprecision - Usage: -xyzprecision [precision]
  • -quatprecision - Usage: -quatprecision [precision]
  • -jointthreshold - Usage: -jointthreshold [minimum joint weight]
  • -skipmesh - Usage: -skipmesh [name of mesh to skip]
  • -keepmesh - Usage: -keepmesh [name of mesh to keep]
  • -keepmeshprefix - Usage: -keepmeshprefix [prefix of mesh(es) to keep]
  • -jointgroup - Usage: -jointgroup [group name] [joint1] [joint2]...[joint n]

Time To Export

Now you have your Maya files and .def file ready you can open up the game. For this example you would type the following into the console: exportmodels weapons/gpmg.def

  • exportmodels can be used alone if you wish to export every single .def.
  • reexportmodels can be used to force a full export.

If everything has been set up properly you should see the engine run through executing all the export lines. If it shows up with any warnings you will need to assess whether it is something to do with the Maya files or the export file.

If you do get warnings or errors, the most common mistakes/things to check are:

  • Spelling mistakes in the .def file.
  • Too many, missing or inappropriate double braces.
  • Wrong path indicated for where the files are.
  • The Maya files' time stamps are checked against the the MD5 files. Maybe your date is incorrectly set, or you have only changed the reference file so the game doesn't check it and realize anything is worth exporting (in this case you should use reexportmodels).
  • Export name masks can be used, in this case we have set it to 'export hauser' as shown at the top of the export section above. In game if the g_exportmask is set to anything other than "hauser" or "" (no mask exports all .defs)then the export won't work.

Viewing The Model In ETQW

The game can't read an MD5mesh file without a matching MD5anim file. The only way for the game to know which MD5anims go with the MD5mesh is for us to define them in the .def file. Lets take a look at the GPMG model definition section.

model viewmodel_gpmg {
	mesh 					models/weapons/gdf_gpmg/view.md5mesh

	anim idle 				models/weapons/gdf_gpmg/idle.md5anim {

	anim fire				models/weapons/gdf_gpmg/fire.md5anim {

	anim reload				models/weapons/gdf_gpmg/reload.md5anim {
		frame 1					sound_channel snd_weapon_reload snd_reload
	anim raise				models/weapons/gdf_gpmg/raise.md5anim {
		frame 1					sound_channel snd_weapon_raise snd_raise

	anim putaway				models/weapons/gdf_gpmg/lower.md5anim {
  • model <modelname> - the model name of the combined md5mesh and md5anims. This can be tested in the game using the testmodel console command, or can be referenced from other .def files.
  • mesh <md5mesh path> - the path of the md5mesh you want to use (most likely you have just exported it).
  • anim <animation name> <md5anim path> - once the model has been loaded, the animations can be played using the testanim console command.
    • After each anim name definition there is a section for frame commands. In this example the reload and raise animations will play sound effects.


The MD5 files are in plain text, so if anything is going wrong you can open them in a text editor to try and see what's happening more clearly.

Example of a camera export def;

export frankie{
	camera models/newcams/democam.mb -dest models/newcams/demovalley