Call of Duty 4: Maya

From COD Modding & Mapping Wiki
Jump to navigation Jump to search

Models and Animations in the CoD4 Engine

 The documentation below originate from Call of Duty 2 and as such all might not be relevant to Call of Duty 4.

Maya 8 plugin setup

  • To start off, you need to set up the usersetup.mel and maya.env files so Maya can find our tools. The files included have already been set up to work with our pipeline. The maya.env file creates the environment variables to point to the locations of plugins and scripts located in the tree, and should be put in 'My Documents\maya\6.0'. Example paths are 'MAYA_SCRIPT_PATH = C:/Program Files/Activision/Call of Duty 4 - Modern Warfare/bin/maya' & 'MAYA_PLUG_IN_PATH = C:/Program Files/Activision/Call of Duty 4 - Modern Warfare/bin/maya'. These will tell Maya to look here for our plugins and scripts.


  • The usersetup.mel file will tell Maya what to add on startup of Maya. This invokes the startup of our 'COD Tools' menu.

Setting up, skinning and exporting a character model

  • The first stage of getting a character into the game is to bind the character’s body to the DefMesh skeleton. The DefMesh skeleton is the basic rig that will be ultimately exported into the game, and is included within the Josh_DefMesh character. The Josh character is a good example of how one should bind the model to the skeleton.




IW Dev conventions

  • IW Dev's character models are usually rigged on the DefMesh skeleton in 3 different parts: the body, head, and helmet. This is done so that characters parts may be interchangeable. This usually means that you want to rig the character or characters bodies LOD's into one Maya file, and the heads into a separate Maya file. You can also export the model as one full mesh if you’d like, but you will not be able to make unique characters out of any part of your model that was exported as one full mesh.


  • IW Dev generally make 4 levels of detail for each character, at 8,000, 4,000, 1,000 and 300 triangles. We name the parts for each LoD, _8k, _4k, _1k and _300.


  • In all the Maya scenes, Z is up.



Rigging

  • You may decide to position the joints to fit the character’s mouth, eyes, and other areas. If you decide to move the joints in the face, or any other part of the body, you must animate with the provided Josh_DefMesh characters skeleton positions. The reason being is that the provided base_character.XMODEL uses the Josh character.


  • After positioning the joints into the correct places, bind all of the facial joints, J_Head, J_Neck, and J_Spine4 joints to the facial geometry.


  • Skinning the body uses pretty much the same procedures as the head, except there are no adjustments to joint positions per character on the body. Therefore, you are able to put multiple unique bodies and their LOD's into the same Maya file, which can work well for editing and copying weights.


  • To export the model, go to 'COD Tools->Model Exporter' in the menu. Click 'Add New Entry' to create a new list to add to for each LOD. Here is where you can designate where the .xmodel_export files will be exported to. You should export all of your models to subdirectories in 'C:/Program Files/Activision/Call of Duty 4 - Modern Warfare/xmodel_export/*. Force Export Selected Joints must be checked if you are exporting animatable models (like a character’s head). You also must set the meshes and joints that will be exported. To do this, you can either manually select the joints that are used in the skinClusters of the head or full charater, or you can use a script called 'selectBound' that is included. To use the script, first select all of the pieces of the highest LOD, and type selectBound in the command line. This will remove any unused influences from the skinClusters, and will then return and select all of the joints that are used within the selected objects. The script will also add extra joints like TAG_ joints where needed. After you have the highest LOD's bones selected, Shift select the highest LOD's top group and then set exports. After that, you can deselect the 8k group, and shift select the 4k group and set exports. Do this for the rest of the LOD's. In our engine, even if the lowest LOD is only using 4 joints (which we do when skinning to save in calculation), you must still include all of the joints of the highest LOD in the Exports.




Materials

  • By default, the game engine uses the material name you use in Maya. It does not use the actual image file you use in Maya, just the name of the material. Give your material a good name - we use the prefix ‘mtl_’, followed by the model name for almost all materials on our models, which makes our lives much easier. Once you’ve exported your model, you’ll need to create a material with that name in Asset Manager (covered later).




Creating a Rig

  • To start off, our main character that we do all animation exports from is the Josh_DefMesh_Rig. The reason we must use Josh_DefMesh_Rig to export all animations is because the 'base_character' that we assign for almost all animations is using his character as a reference. Often though, we create other animatable _Rig characters that can be used to animate with until export time.


  • To create a new Rig character for animating with, start by creating a new Maya file. Next, create a reference using namespaces and set the type to ‘this string:’. Make a new prefix name (i.e. “rig”) and reference in the Josh_DefMesh character. From here you can build animation controls onto the character to animated with. You may also decide to just build the animation controls onto the Josh_DefMesh.mb file, but you still MUST create a new reference file before you are to export any animations.




Working with and exporting animations

  • Depending on the animation, you may need to add a 'Notetrack' to specify when certain actions occur that have to be noted for scripting purposes. Notetracks associate a word or phrase with a frame of the animation, and can be detected by the game script at run time. An example of this would be to specify when the sound file for dialog should be played. To do this, you can create a notetrack using the tool located under 'COD Tools->Notetrack Window'. You would then 'Create Note Track node' on the frame at the beginning of the dialog.


  • Once all of your animation is complete and you are ready to export your animation, go to 'COD Tools->Animation Exporter' in the menu. Here is where you can designate where the .xanim_export file will be exported to. You should export all of your animations to subdirectories of 'C:/Program Files/Activision/Call of Duty 4 - Modern Warfare/xanim_export/*', or where the game has been installed.


  • You need to set the start and end frames of the animation, and the joints that are used in the animation. If you click on the 'Export Nodes' button, you will notice it will bring up a window that will ask you which character (designated by its prefix) you would like to set for exports. This button will then set the full set of joints for exporting for the particular character. Sometimes you may want to only select the head joints or the upper torso joints for export. In this case, you must select them manually and set those for export.


  • If your animation uses a note track, you’ll need to tell the exporter. Click on the ‘notetrack’ button in the animation exporter window, and a dialog will pop up asking you which notetrack the animation uses.




Asset Manager

  • Asset Manager (AssMan for short) is a little program that helps us edit all our game data files (.gdt’s). GDT’s control how Maya models become game models, how materials and animations associate with models and how normal maps are associated with color maps. They also control a whole host of other, less-art-specific things, like how weapons behave and what guns each AI uses.



Models

  • Click on “xmodel” and click on the “New Entry” button and specify a unique name for your model that is less than 40 characters. You’ll now see a list that appears on the right hand side. For static models, you set the type to ‘rigid’. For animated models, you use ‘animated’. In the filename box below is where you specify the xmodel_export filename for the highest LOD of your model. In the highLodDist selection box, specify the distance that the game should use for the highest LOD. From here, specify the mediumLod, lowLod, and lowestLod xmodel_exports and their corresponding LOD distances.


  • On character models, you’ll want to specify the hitBoxModel, which is included in the bin/maya directory.


  • In AssMan, you have the ability to make a group of models to be randomly selected within the game by giving that group a name of it’s own. Groups of model types to be interchanged between characters. For instance, you could create an xmodelalias for a handful of head models. To do this, you would create a unique name for the xmodelalias, and then assign head models you made as xmodels and put their names in these fields.



Materials

  • Click on “material” and click on the “New Entry” button and specify a unique name for your model that is less than 40 characters. You can see they are all the materials associated with the models in the GDT. The main ones to edit here are first the materialType and surfaceType, where you set these to the corresponding types. The other ones to be concerned with is the Color Map, Normal

Map, Specular color map, and Cosine power map fields. Here you put the path of where these files are located, which should be 'C:\Program Files\Activision\Call of Duty 4 - Modern Warfare\xmodel_export\*’ for materials associated with a model, and in ‘C:\Program Files\Activision\Call of Duty 4 - Modern Warfare\texture_source\*’ for world textures. The rest of the entries can usually be left as default, but can aid in the look of how the materials are displayed.



Animations

  • Click on “xanim” and click on the “New Entry” button and specify a unique name for your model that is less than 40 characters. Animation GDT’s should be saved in 'C:\Program Files\Activision\Call of Duty 4 - Modern Warfare\xanim_export\*’.


  • The first option in the right is “filename”, which is the xanim_export file for the animation.


  • The second option is “model”, which can be confusing at first. We associate every animation with a model, which establishes the base pose and proportions that the animation is diverging from. We also get all hierarchy information from the model. Also, any joints that are in the animation but not in the model will be stripped from the animation. We made a special model file called “Base_character” for our full-body character animations. It’s basically just a copy of our Josh model, but we called it base_character to make it easy to find.


  • The third option is “looping” – whether or not the animation is looping. When you set this, the last frame of the animation is assumed to be the same as the first, and is deleted by converter.


  • “Type” is generally set to “delta” for full-body character animations. Delta uses the root joint of the model to determine how far the model moves each frame. In “delta” animations, it’s essential that the root bone always remain upright (the Z axis of the bone faces along Maya’s Z axis, or the Z axis of the “node” if a node is specified in the next point). Type “relative” treats the root joint of the model (or the joint in the animation that is highest in the model’s hierarchy) as the origin, and animates the other joints relative to that. Type “absolute” treats the origin of your Maya scene as the origin and moves all the joints relative to that. The “mp_” types are used only for MP animations.


  • “Node” is only used with “type”=”delta” animations. The node is a very powerful feature that enables us to line up scripted animations perfectly. Export a joint or object with your animation from Maya, and enter its name here. When the designer plays your animation in script, he or she can specify a node for the animation to be based off, and the engine will move the animation so that the node in your Maya file lines up with the node in the game. Thus you could create a complex animation of several people interacting, based around some point on the floor, and you don’t have to worry about compounding errors making your characters drift apart or through each other.


  • “angleError” and “translationError” are the maximum errors allowed when compressing the animation. Larger numbers make smaller files, smaller numbers make perfect animation. The defaults (0.05 and 0.025) result in no noticeable compression artifacts that we’ve noticed.


  • “boneStabilizers” is old, and something to do with multiplayer. I doubt you’ll need it.



Converting models and animations

  • After exporting your models or animations and adding them to AssMan, you need to convert the text files into files the game engine reads. To do this, execute converter, located at ‘C:\Program Files\Activision\Call of Duty 4 - Modern Warfare\bin\converter.exe’. This will convert all files that have been changed. Converter endeavors to find every possible error in your models, materials and animations so that we don’t have any surprises in the game, so you may have to go back and fix problems in Maya or AssMan in order to get converter to finish with no errors.