This is a comprehensive (and long overdue) tutorial on adding custom, animated weapons to CoD. The only two prerequisites to this tutorial are that you have Maya 8.5 with IW's xAnim/xModel Export Plugin or Maya 2012-2014 with Aidan's xAnim/xModel Export Plugin as well as an already completed weapon mesh to work with.

Setting up your VMGun

Importing

First, open your completed weapon mesh into maya. To ensure that your weapon is interpreted correctly by the engine, make sure your model has correct topology before continuing(details can be found about this via google).

Rotate your weapon so the muzzle is pointing in the X+ direction and the top of the weapon is pointing in the Z+ direction. Now with your weapon mesh selected go to "Modify>Freeze Transformations".

(OPTIONAL) Import a weapon created by IW or Treyarch into your scene to compare scale. Once your weapon scale is matched proportionally to the example weapon you can delete the example from the scene. If you are having trouble obtaining an example weapon, one can be found at "root/bin/maya/model_src/modern_weapons/m16/weapon_m16.mb" within the COD4 mod tools.

Make sure the polygon menu set is selected and select all your weapon meshes. Now click the "Color" menu button and hit the square outline beside the "Apply Color" button. A dialog box should appear. Under the "Color Value" section ensure the "Color" slider is positioned all the way to the right, resulting in the color preview being blank white. With your meshes still selected hit "Apply Color" on the dialog box and within shaded mode you will see all your meshes become blank white. This is required for your textures to appear within game, otherwise they would appear pitch black.

Materials

Open the hypershade by going to "Window>Rendering Editors>Hypershade". Once open select the "materials" tab.

Ensure that all surfaces have a material applied to them and no surfaces have the initial shading group applied.

The material names here will match the names of the materials we will be creating in asset manager. Make sure that all materials have appropriate names. For example, if I had a material that colored the main piece of the weapon, I would call it "mtl_*WEAPONNAMEmain". Or if I had a material that was applied to a scope on the weapon I would call it "mtlWEAPONNAME_scope".

Rigging

(OPTIONAL) Switch to the side orthographic viewport for easier joint placement.

Select the animation shelf above the main viewport and click the "Joint" tool. You can now click anywhere in the viewport to place a joint. Place a new joint in the lower receiver of the weapon just above the grip. Open the outliner by going to "Window>Outliner" and rename the joint you just created to "J_Gun".

Repeat the last step except you will now want to name your joint "tag_clip". Once your second joint has been named middle mouse click and drag the second joint onto the "J_Gun" joint. This will make "J_Gun" a parent of "tag_clip". With the tag clip joint selected use the "Move" tool to move the joint into the center of your clip mesh.

You will now want to create 3 duplicates of "tag_clip" as well as one for each attachment you have on the weapon by selecting "tag_clip" and pressing Ctrl + D. Name the new joints "tag_flash", "tag_brass" and "j_bolt". Any attachment joints you create should have the naming convention of "tag_*ATTACHMENT". Ex: "tag_holographic".

"tag_flash" is where the muzzle flash FX will spawn in game. Place it at the end of the barrel half way into the muzzle. "tag_brass" is where the shell ejection FX will spawn in game. Place this joint flush with the ejection port on the weapon. "j_bolt" is the joint that will control movement of the bolt on the weapon. Place this joint inside the bolt handle for easy selection. If the weapon you are animating is a pistol "j_bolt" will control the pistol's slide.

First select "tag_clip", then your clip mesh. With the "Animation" menu set selected go to "Skin>Bind Skin>Smooth Bind". With your joint selected and wireframe mode on the clip mesh will now appear pink. This means that the selected joint is bound to the highlighted mesh.

Select "j_bolt", then the bolt mesh and repeat the above step. Once j_bolt is bound to the bolt mesh select "J_Gun" and then select any meshes which aren't already bound to one of the previous joints. Now once again repeat the step above. With "J_Gun" selected in wireframe mode all meshes should now appear pink.

Select "J_Gun", then go to "Edit>Select Hierarchy". Now go to "Create>Sets>Set". In the outliner you will see a newly created set, likely called "set1". Inside will be your weapon's joints. Rename the set to "GunExport".

Exporting

Animation

Preparation

Open /bin/maya/model_src/modern_weapons/m16/weapon_m16.mb with Maya. Open Outliner and expand the J_Gun tree. Hold Shift and select m16_high, then select the last join in the J_Gun tree. Go to Modify -> Freeze Transformations, then Edit -> Delete All by Type -> History. Now, in the top left corner of Maya on the tool bar, click the dropdown box and select Animation. Now select Skin -> Detach. Now select and delete all 3 m16 poly groups.

Importing

Go to File -> Import and find your gun. It will be imported into the scene. Now you must bind the joints to the skin.

Binding

In order for the viewhands to know what to grab, and for the game to know what part of the mesh to move, you must bind joins to their corresponding meshes.

To this you must first

Save + Export

You have now finished the rig for this weapon. Save the scene in /Call of Duty World at War/model_export/ as weapon_gunname.mb. Go to the CoDWaW Plugin Menu and choose Model Exporter. If you don't see an Entry, click add new entry. Otherwise, continue.

Tick the box on the left next to 'Entry 1' and click the '...' next to the textbox. Locate weapon_gunname.mb and click OK. Now go to Window -> Hypergraph:Hierarchy and click+drag over everything in the black window. Zoom in and, while holding shift, click the first 3 items (cameras) so that they are not selected anymore (not yellow highlighted). Then click 'Set Exports' and tick the 'Force export joints' box on the Model Exporter window. Now click 'Export Selected Entities' and wait for the progress window to disappear. You can find the exported file in the same directory as the .mb.

Animating

Viewmodel

Next you must create the viewmodel for your gun. This is the model that the user of the gun will see.

Open /bin/maya/animation_src/viewmodel/m16/m16.VMGun.mb in Maya. Now we are going to do the same thing we did for the rigging: Open Outliner again and expand the 'm16' and 'J_Gun' trees. Hold shift and select all items within these two trees and go to Skin -> Detach. Now delete the 'm16' tree and go to File -> Import. Locate your original, unrigged, unjointed model again and import it. Do the same thing you did before: bind the joints to mesh and create any new joints if necessary. Save the scene as gunname.VMGun.mb. Now open the Model Exporter again and go to Window -> Hypergraph:Hierarchy. Select everything as you did before, then in the Model Export window check the Entry 1 box, locate your gunname.VMGun.mb, click yes to the popup window, then press Set Exports and tick the 'Force Export Selected Joints' box. Press Export Selected Entities. You will find the exported file in the same directory as the .mb scene.

gunsleeve

Now that you have your weapon rig (weapon_gunname.mb), it's time to do what will probably be the most simple step of this tutorial: making a gunsleeve. It is crucial to do this step correctly or your anim will never work.

The gunsleeve file is essentially an 'index' of all the joints and meshes involved in the animation. If the game cannot correctly identify all things in use, the anim will not play or the arms will be disfigured in-game.

To create the gunsleeve, first open your gunname.VMGun.mb (it should still be open if you are following this tutorial step-by-step). Now choose CoDWaW -> Viewmodel Tools -> Create new gunsleeve Maya file. If it prompts you to locate Viewmodel_DefMesh.mb, you can find it in /bin/maya/rigs/viewmodel/. Now, save the newly created scene as gunname_gunsleeves.mb. Open Model Exporter and tick the Entry 1 box. Choose your gunname_gunsleeves.mb file and then open Window -> Hypergraph:Hierarchy. Select everything and then press Set Exports in the Exporter window. Then Export Selected Entities. You can find the exported file in the same location as the .mb scene.

Animating the Model

Animation process to be added here.

Save your animation scene as gunname_animation.mb. To export your anims, open the Animation Exporter from the CoD Menu. Open the Hypergraph and select everything as usual. Now in the exporter window, first 'Add new Entry' if there isnt one already, then tick the Entry 1 box. Now select gunname_animations.mb and enter the frame numbers of your animation in the boxes on the right. Now press 'Set Export Nodes'. It should recognize 'rig:' as the prefix. Now press Export Selected Entities. You will find a new file, .XANIM_EXPORT in the same directory. You MUST copy this file to /Call of Duty World at War/xanim_export/ (create this directory as it most likely does not exist yet). All .XMODEL_EXPORTS must be in /model_export/.

Asset Manager

Now that you have all of your exported files, it's time to make them available to the game. Open Launcher, and from there click the Asset Manager button.

Adding Materials

The first step in importing to AssMan is to set up your model's materials. Open your model in Maya and open Window -> Rendering -> Hypershade. Here you can see all of your shader names. You must create a mirror copy of each of them in Asset Manager. The material name must match the shader name. GO THOUGH PROCESS OF MATERIAL ADDING HERE.

Adding the xmodel

After adding materials, you can safely add your weapon model. Scroll down to 'xmodel' and press New Entry. Give the model a name such as viewmodel_gunname (although it can be whatever you want - keep it lowercase). For type, choose animated. In the first Filename box, locate your weapon_gunname.xmodel_export and press OK. Now go to PC Convert -> Current Asset Only. It should convert successfully.

Adding the anims

Now scroll to 'xanim' and press New Entry. Give it a name representative to what it is an animation of, for example, viewmodel_gunname_reload_empty.

For Anim File, navigate to and select your .XANIM_EXPORT file.

For Model File, navigate to your gunsleeve .xmodel_export. Leave notetrack blank unless you know what you are doing. Uncheck Looping and Uncheck Use Bones. Change type to relative. Now select PC Convert -> Current Asset Only.

Weapon File

Now you must create a weapon file for your gun. You can use UGX WeaponsEditor++ if you wish, or copy/paste a treyarch weapon file and edit it to your needs. What is important is that you change the value for key 'gunModel' to your xmodel, and the value for the key of your desired anim to your anim name. Add the weapon file to mods/mapname/weapons/sp.

CSVs & IWD

In order for your xmodel and xanim to show in-game, you must include them in fastfiles. Open Launcher and go to the Mod tab. Select your mod from the list and then add these lines to the ff box:

xanim,nameofxanim
xmodel,nameofxmodel

Note: Edit the names to match what you are adding.

Add the same files you included in your FF to your /mods/mapname folders.