Call of Duty 4: ViewModels
Exporting a Viewmodel Gun
- Open m16.VMGun.mb in a valid copy of Maya. This is the weapon model. The root bone is
J_gun
. The viewmodel gun and its joint setup will be in this file. Make sure the model is skinned using smooth bind. - Goto COD Tools → Model Exporter.
- Note: If you have anything selected before opening the COD Tools, everything will be deselected.
- Set the file path to
model_export\viewmodels\viewmodel_m16.XMODEL_EXPORT
. (You do not have to add.XMODEL_EXPORT
at the end of the name. The exporter will add it automatically) - Select every joint (
J_gun
and it’s siblings), and select all geometry. - Click the Set Exports button. This tells what joints and geometry should be in the file you have specified.
- Click the Export All Entries button.
- Click Yes or No on the Save Changes prompt.
Viewmodel_m16.XMODEL_EXPORT is now exported. If you open this file in a text editor you can find out a lot of valuable information. On the top it will tell you what source file the asset came from. It will list the time it was exported as well. It will tell you the number of bones in the file and individually list all of them. Most of the file tells you the location of each vertex. If you scroll down to the bottom of the file you will find a list of each piece of geometry in the file and a material list. If you’re trying to troubleshoot a problem, I highly recommend opening your XMODEL_EXPORT or XANIM_EXPORT files in a text editor in order to make sure you included everything you need in the file. If your material isn’t showing up in game, make sure the material in your XMODEL_EXPORT file is the correct one. Also, check your shader in Maya and make sure it is referencing the correct file.
Create new gunsleeves
- First off, you must have the .VMGun.mb file open that you want to create the gunsleeves for. A gunsleeve is the 'animation model' that is used for each specific gun's animations.
- To create gunsleeves for a particular VMGun.mb gun, have the gun open and go to the Call of Duty 4 drop down menu. Under ViewModel Tools, select 'Create new gunsleeve Maya file’. After pressing this, a Maya file will automatically be created and so will an XMODEL_EXPORT for this gun setup. This XMODEL_EXPORT will be added to this guns animations in its GDT settings.
Create new viewmodel animation rig
- To create a new viewmodel animation rig for your VMGun.mb, you do not need any file open. If you have a file open, a prompt will ask you to save the current file.
- Go to the Call of Duty 4 drop down menu and select ‘Create new ViewModel Rig File’
- A window will open asking you to select the VMGun.mb file that you want to make the animation rig for. Choose the VMGun.mb that you would like.
- After this is complete, save the created file in the same directory as the VMGun.mb file you selected. We name these files with the ‘_animation’ suffix. Rig is now ready for animation.
Setting animation exports
There are two types of exports sets that are used for Viewmodel animation. ADS animations and non-ADS animations.
ADS Animation Exports
- Open viewmodelanimation_m16.mb.
- Go to COD Tools → Animation Exporter.
- Select
tag_view
andtag_ads
.- These may have a prefix in front of them. You are selecting these to set to the two main aiming-down-sight (ADS) animations.
tag_view
will never move; it is also the location of the camera. Animatingtag_ads
will move the entire viewmodel. If you have a new weapon model, you will need to create an animation of the viewmodel going up to ADS from the hip position, and an animation of it going from ADS down to the hip position. When you line up the reticle for the ADS position, you want to make sure it is exactly in the middle of the screen. Take your camera that is at 0,0 withtag_view
and change the focal length to zoom in. You want to still have your gun reticle in the middle of the screen at a very very high zoom. If your reticle is off, then people will be aiming somewhere that the gun isn’t shooting.
- These may have a prefix in front of them. You are selecting these to set to the two main aiming-down-sight (ADS) animations.
- Set Exports on the ADS_down and ADS_up animations
Non-ADS Animation Exports
For any other animation export, you need to select almost every ‘deforming joint’ in the Viewmodel skeleton Hierarchy EXCEPT ‘rig:DefMesh:tag_view’
- Select
tag_ads
and all of it’s siblings. - Select
j_gun
and all of it’s siblings (AllVM_Gun:*
joints). - Set Exports on all of the remaining animations. All of the animation paths should already be set. You can change them if necessary.
- Click Export All Entries.
- Run converter.exe.
Using Asset Manager for Viewmodels
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 gun each AI uses. Asset Manager is in cod3-pc\cod3-modtools\public\bin
.
- Open xanim_viewmodel.gdt in the
cod3-pc\cod3-modtools\public\xanim_export
directory with AssMan. - Scroll down to
viewmodel_m16_xxxxx
.- There are already animations setup in AssMan. Click on one of the m16 animation files. You’re only going to be changing the filename field for each animation you setup. There are no animations that should be set to ‘looping’ (except the
*sprint_loop
animation). Type should be ‘relative’. If you want to add another animation it is easiest to click on Copy Entry and then just change the filename.
- There are already animations setup in AssMan. Click on one of the m16 animation files. You’re only going to be changing the filename field for each animation you setup. There are no animations that should be set to ‘looping’ (except the
- In the ‘filename’ field add your XANIM_EXPORT that corresponds to the xanim asset you are creating.
- In the ‘model’ field add the name of the XMODEL_EXPORT that corresponds to the asset you are creating. (This is the model that is exported when you created the ‘gunsleeves’ file. This model is not the visual representation of the gun and sleeves, but is the JOINT info of the sleeves and gun, enabling your animation to play.)
- Open viewmodels.gdt in
cod3-pc\cod3-modtools\public\model_export
. - Scroll down to
viewmodel_m16
.- This GDT contains the model of the gun you exported from the VMGun.mb file. In this case this is the ‘viewmodel_m16.XMODEL_EXPORT’. Just make sure the type is set to ‘animated’ and the filename corresponds to the asset you are creating. Now your viewmodel is set.
- Open weaponsettings.gdt from
cod3-pc\cod3-modtools\public\source_data
. - Select the m1m16 in the
bulletweapon
category.- There are three main categories in
weaponsettings
.bulletweapon
will have all your regular guns,grenadeweapon
will have grenades, andprojectileweapon
will have bazookas or anything rocket propelled like RPGs.
- There are three main categories in
- In the ‘View Gun’ field in the XModels category type in ‘viewmodel_m16’
- These all are most likely already set, but this is what you’d do if the field wasn’t already there.
viewmodel_m16
is the name of the asset you created in viewmodels.gdt.
- These all are most likely already set, but this is what you’d do if the field wasn’t already there.
- Set ‘Default view Hand’ to ‘viewmodel_base_viewhands’
viewmodel_base_viewhands
is the name of the basic sleeves mesh that you will be using. This will usually always be the same model.
- Set all the animation fields to the appropriate animations.
Consult the AssMan Settings section of this document to find out what each animation field means.
Asset Manager Settings
XModels
- gunModel
- This is where you would have
weapon_bar
. It’s the weapon file for the viewmodel. Keep in mind that the world models for weapons are completely separate from viewmodels.
- worldModel
- This is where you select the worldmodel for the weapon that is dropped when you kill a player, or just the model that is dropped in general when you drop a weapon for any reason.
XAnims
- idleAnim
- The viewmodel animation that is being played when the player is not doing anything. In Call of Duty this is always just a single pose, although you may want to put a whole animation in here (there’s no guarantee it’ll play properly though). Make sure that the frame you export is exactly like the pose that is at the beginning and end of every other viewmodel animation for that weapon, or you’ll get pops.
- emptyIdleAnim
- This is the animation that is played when you’re out of ammunition for your weapon. In most cases it will be the same as idleAnim, but for grenades you need an animation where the grenade is completely out of the view since you have no grenades to hold.
- fireAnim
- Animation played when you fire the weapon.
- lastShotAnim
- This is the animation played on the last bullet in the clip. On most weapons when you finish off a clip, the bolt stays back. So instead of the regular fire animation that has the bolt go backwards and then forwards quickly, or from the back position, forwards, and then back again, you would have an animation of the bolt staying where it is.
- rechamberAnim
- This is the animation that will be played on bolt-action rifles after every shot except the last shot.
- meleeAnim
- The close range Melee animation goes here. (In COD4 this is the knife swipe animation
*knife_1
.)
- meleechargeAnim
- The charge Melee animation goes here. (In COD4 this is the knife stab animation
*knife_2
.)
- reloadAnim
- This is the reload animation that is played when you still have bullets in your clip or magazine. For single-fed bullets, this animation is looped after reloadStartAnim.
- reloadEmptyAnim
- This is the reload animation that is played when the clip or magazine is empty. The reload process for many weapons is different depending on whether or not you finished off the clip/magazine or not.
- reloadStartAnim
- On bolt-action weapons like the Springfield where you insert single bullets, this is the beginning of the animation. The animation usually consists of pulling the bolt back and inserting the first bullet. In this viewmodel mode, after this animation is played, reloadAnim is looped. So in the case of the Springfield, reloadStartAnim is the bolt being pulled back and a bullet inserted, followed by the reloadAnim loop for each additional bullet. If you need three bullets to fill up your weapon, the loop would play twice. (Remember you already inserted one bullet on the reloadStartAnim.)
- reloadEndAnim
- To finish off the single bullet insert animation, you need to push the bolt forwards. This is where you would have an animation of pushing the bolt into position.
- raiseAnim
- Drawing the weapon.
- dropAnim
- Putting the weapon away.
- altRaiseAnim and altDropAnim
- Put the firing mode switch animations in both of these fields. To have a weapon with an alternate fire, you will actually have two viewmodels setup in AssMan. They will be very similar, but of course will have different rates of fire. You need to set the altDropTime value to the length of the firing mode switch animation, and set altRaiseTime to 0. Do that for both viewmodels for that weapon. The BAR viewmodel, for example, switches between fast and slow fire rates.
- adsFireAnim
- This is an alternate field for the ADS fire animation because sometimes the regular firing animation doesn’t work correctly while in ADS. The most common problem is the amount of recoil looks too crazy when aiming down the site. You usually have to tone down the recoil in the firing animation, and export it for an ADS fire animation. Keep in mind, even though this is called an adsFireAnim you export this just like the other animations and not like the ADS up and down animations.
- adsLastShotAnim
- Same thing as adsFireAnim except for the last shot.
- adsRechamberAnim
- Same thing as adsFireAnim except for rechamber.
- adsUpAnim
- This is the animation of
tag_ads
going from the "at the hip" position to ADS. Look under important objects on how to export this.
- adsDownAnim
- This is
tag_ads
going from the ADS position to the hip position. Look under important objects on how to export this.
State Timers
- reloadStartAdd
- This is how many bullets are inserted when the reloadStartAnim is played. The Enfield would be five, and the Springfield one.
- reloadAmmoAdd
- This is only applicable to bolt-action rifles. This is the amount of ammo added each time the the reload loop is played. For instance the Enfield uses stripper clips, so it would be five. It would be one for the Springfield.
- reloadTime
- Length of the reload animation when clip or magazine isn’t emptied.
- reloadEmptyTime
- Length of animation when clip or magazine is emptied.
- reloadAddTime
- This is how far into the reload animation the ammo is actually added. You would see how long into the animation it takes before the new clip is inserted into the weapon.
- fireTime
- Length of the fire animation.
- meleeTime
- Length of melee animation.
- rechamberTime
- Length of rechamber animation.
- rechamberBoltTime
- This is the time in the rechamber animation that the bolt is actually pulled out. It tells the shells when to eject from
tag_brass
.
- dropTime
- Length of the weapon stowage animation.
- raiseTime
- Length of the weapon drawing animation.
There are many other values in the weaponsettings.gdt file, which control the behavior of the weapon. There are settings for the recoil strength and direction, the amount of bullet damage and the speed at which a player can run while carrying the weapon and the animation set used by player models when players carry this weapon. There are also settings for the hud icons, the sounds and effects played by the weapon.
Important Joints
- tag_view
- This is basically the camera tag. This is where your modeling camera should be attached at all times, because this is where the eyebone—or game camera—is in the game. This tag is never animated.
- tag_ads
- This is the bone that controls ADS (aiming down the sight). When exporting ADS up and down animations, you only need to export
tag_view
andtag_ads
. Thetag_ads
position will be applied to whatever full viewmodel animations are playing. When creating the ADS up and down animation, you need to make sure thattag_weapon
is always in the exact some place relative totag_ads
.
- tag_weapon
- This is what the majority of the animating is done on, except the hands. The weapon you're using is parented to that, and the right and left hands are usually IKed to it. Be really careful to make sure that all your animations start and end on a particular
tag_weapon
position so you don't get any pops before or at the end of your animations. You shouldn’t be animatingtag_weapon
directly, but rather through a controller in your modeller. Either way will work, but you don’t want animation on both the controller and tag_weapon or it will get confusing.
- tag_flash
- This is at the end of the weapon, and tells the game where the muzzle flash should go.
- tag_brass
- This tag is where shells eject. Point the X axis the direction you want them to come out.