Call of duty 4: Import models

From COD Modding & Mapping Wiki
Jump to navigation Jump to search
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.
This tutorial assumes that you already know how to create, compile & create GSCs,CSVs & FastFiles for your maps

By NovemberDobby

This tutorial will show you the basics of importing a new weapon model into Cod4. Below is my example, which you will hopefully be able to use.

You will be needing:

  • Maya 7.0 or 8.5 (not the Personal Learning Edition)
  • Maya 8.0 requires a little hack (see below)
  • The Cod4\bin\maya folder from the mod tools
  • Texture(s) for your model: The dimensions have to be a power of two. (256*256, 512*512, etc), and the file must be a .jpg, .tga, or .dds. TGA and DDS textures can both have alpha channels, and can both be natively edited using Paint.net. (www.getpaint.net)
  • My example weapon model, from HERE
  • In this tutorial, I will assume you know Maya's basic controls. Firstly, I recommend you follow this tutorial, written by mdS HERE
  • It shows you how to export a rigid model from Maya, and get it into the game using Asset Manager. It also shows you the first two steps needed to set up Maya to use the plugins. As these two steps are necessary, I'll explain them here, courtesy of Infinity Ward's Wiki.


Maya 8.0 Fix

You can use the Maya 8.5 plugins (xmodel, xanim) which come with the CoD4 Mod Tools, in Maya 8.0. Just open the two MLL files with a hex-editor, do a text search for '850' and replace it with '800'.

Change  850 (hex 38 35 30 )
To -->  800 (hex 38 30 30 )

Offsets:
XAnimExport.mll  - 0x2B10B
XModelExport.mll - 0x350EC

850 is the version number v8.50, the Maya version the plugins are designed for. Maya v8.00 won't accept them, but if you change the version requirement like described above it will load the plugins. The Maya scripting engines probably didn't change a lot, thus you shouldn't experience any problems with the hacked plugins.


MAYA Setup

Create a Maya.env file in: C:\Documents and Settings\My Documents\maya\ and add the two lines below into it.

MAYA_SCRIPT_PATH = C:\Program Files\Activision\Call of Duty 4 - Modern Warfare\bin\maya\tools
MAYA_PLUG_IN_PATH = C:\Program Files\Activision\Call of Duty 4 - Modern Warfare\bin\maya\tools

This folder location will be different if you have the Steam version, or have installed Cod4 somewhere else. You also need to make a file called usersetup.mel in C:\Documents and Settings\\My Documents\maya\\scripts\ and add the following three lines to it:

source CODToolsMenu;
CODStartup;
CODToolsMenu;

Lastly, you need to extract the corret plugins for your version of Maya. Go to Cod4\bin\maya\tools, and open up either Maya7_plugins.zip or Maya8_plugins.zip. Extract the two files from that zip into the Cod4\bin\maya\tools folder.


In MAYA

  • Ok, start up Maya, and you should see a Call Of Duty 4 menu at the top. Open my example weapon, and then save it as a Maya file in a folder called Cod5\model_export\maya_ex. Maya_ex is the name of your model for now, it can be anything as long as there are no spaces in the name. You can save the actual Maya file under any filename. Also, copy the textures out of my example file into the same folder you saved this into.
  • To view and edit the texturing in this model, you need to use Hypershade. In Maya, go to Window > Rendering Editors > Hypershade. You will be presented with a dialog box which shows you the textures in use along with some other stuff. In the top dark section, you should see four textures. The one called 'demo_wep_skin' is the one we're interested in, the other three are there by default and you cannot remove them. You may have to re-locate the actual .tga texture which is being used, so double click on the demo_wep_skin, and you should see the main right hand side panel change in Maya. There should be a 'file1' tab there now, click on it. About halfway down this new page, you should see 'Image name'. Click on the folder icon to browse to the skin image, demo_weapon_skin.tga, and open it.
  • There is one step that you need to do for each model that you export, otherwise they will appear totally black in Radiant and the game. Go to Edit > Select All, and then to Color > Apply color, but don't click on the menu button; click the small box to the right of it. In the 'Color Value' frame, click on the coloured box, and select a full white colour from the colour selector that comes up. Click 'Apply color', and you should see your model become marginally brighter in the 3D window. You need to do this for every new model, or again if you add geometry to an existing model.
  • This model has already been rigged with the correct joints needed to work as a weapon in Cod4, so, navigate to the Call Of Duty 4 menu, and click on Model Exporter. When the dialog box comes up, click on the 'Add new Entry' button. Tick the checkbox called 'Entry1', and then choose where you will export your model. This should be in the same folder as your Maya model, and should have a similar (if not the same) name.
  • Next, in Maya's menus, go to Edit>Select All. Back in the Cod4 dialog, click on Set Exports in Entry1. This has set the polygons and joints that you want to export to the Cod4 model, and it's very rare that you won't want to export everything.


MAYA: Convert

You're now ready to convert the model to a useable format. In the Cod5 Model Export Window, click 'Select Exports', and 'Export Selected Entries'. If all goes well, a progress bar should pop up and reach 100%. It won't work unless you have clicked 'Select Exports' (or selected everything in Maya).

You sould now have a .xmodel_export file in your model's folder in Cod5\model_export. If you do, continue to the steps below.


Asset Manager

  • Close Maya, and open up Cod4\bin\asset_manager.exe. You will see several buttons in the top left corner, along with a list. Scroll down to 'xmodel', and click 'New Entry'. You now need to enter the name of the model that you will use to access it ingame, and in Radiant. It can't have any spaces, and try not to make it too generic, pick something which will definitely be unique, e.g. db_laser_cannon. You will see a list of options for your model appear on the right hand side now, select 'animated' from the first drop-down menu. In the 'filename' field, click the browse (three dots) button to the right. Use this to locate and open your xmodel_export file that you made before.
  • Save your Asset Manager file in Cod4\model_export. Anywhere else and it won't convert, but it won't have any errors.

To convert the xmodel_export, you need to edit the export file. Go to Cod4\model_export\modelfolder\, and open up the .xmodel_export in a text editor like notepd. You will see 'VERSION 8', this needs changing to 'VERSION 6'. Save and close it.

  • Go back to Asset Manager, and click on your entry in xmodel. Go to PC Convert>Current Asset Only, and if it works, you should see 'Conversion done, hit key to continue'.

In the left hand scroll list, go to 'material', and click new entry. This entry must be the same name as the weapon texture you used in Hypershade, in this example, 'demo_wep_skin'. Change these properties of the material:

Materialtype = world phong
surfacetype = none
sort = default*
usage = not in editor
  • Click the three dots symbol next to the 'Color map' box, and navigate to your .tga skin. If you want the skins to have a specular map aswell, you have to create a texture for that and browse for it, using 'Specular color map'. Do not use a Normal Map on your texture, because it'll stop the specular from working properly, on scopes and reflections.
  • Re-save the Asset Manager file, it will only convert entries that are in the saved version.
  • Select your material from the list on the left, and go to PC Convert>Current Asset Only. If all goes well, a black box should appear, and it'll eventually read 'Conversion done, hit key to continue'. You've now converted the texture for use with your model.
  • If both your texture and your model have converted properly, you can now package them in your mod. I'm assuming you can use .csv files and know how to make a basic mod.ff. All of the textures must go in the mod's IWD, and if it doesn't have one, it needs one. The file structure is: IWD\images\, and the converted iwi images can be found in Cod4\raw\images.


Creating the weapon's file

For this example, we'll mod a stock weaponfile. (rpg_mp)

WEAPONFILE \weaponType\projectile\weaponClass\rocketlauncher\impactType\rocket_explode\guidedMissileType\None\inventoryType\item\maxSteeringAccel\3000\displayName\Laser thingy\AIOverlayDescription\\modeName\\playerAnimType\rocketlauncher\gunModel\db_laser_cannon\gunModel2\\gunModel3\\gunModel4\\gunModel5\\gunModel6\\gunModel7\\gunModel8\\gunModel9\\gunModel10\\gunModel11\\gunModel12\\gunModel13\\gunModel14\\gunModel15\\gunModel16\\handModel\viewmodel_base_viewhands\isHandModelOverridable\0\idleAnim\viewmodel_rpg_idle\emptyIdleAnim\viewmodel_rpg_idle_empty\fireAnim\viewmodel_rpg_fire\lastShotAnim\viewmodel_rpg_fire\meleeAnim\viewmodel_M4m203_knife_melee_1\meleeChargeAnim\viewmodel_M4m203_knife_melee_2\reloadAnim\viewmodel_rpg_reload\raiseAnim\viewmodel_rpg_pullout\dropAnim\viewmodel_rpg_putaway\firstRaiseAnim\viewmodel_rpg_pullout\altRaiseAnim\viewmodel_rpg_pullout\altDropAnim\viewmodel_rpg_putaway\quickRaiseAnim\viewmodel_rpg_pullout\quickDropAnim\viewmodel_rpg_putaway\emptyRaiseAnim\viewmodel_rpg_pullout\emptyDropAnim\viewmodel_rpg_putaway\sprintInAnim\viewmodel_rpg_sprint_in\sprintLoopAnim\viewmodel_rpg_sprint_loop\sprintOutAnim\viewmodel_rpg_sprint_out\nightVisionWearAnim\\nightVisionRemoveAnim\\adsFireAnim\viewmodel_rpg_fire\adsLastShotAnim\viewmodel_rpg_fire\adsUpAnim\viewmodel_rpg_ads_up\adsDownAnim\viewmodel_rpg_ads_down\moveSpeedScale\1\adsMoveSpeedScale\1\sprintDurationScale\1\lowAmmoWarningThreshold\0.33\damage\1000\meleeDamage\135\fireDelay\0\meleeDelay\0.13\meleeChargeDelay\0.16\fireTime\0.33\meleeTime\0.8\meleeChargeTime\1.16\reloadTime\3.292\reloadShowRocketTime\0.1\reloadAddTime\1.17\dropTime\0.467\raiseTime\0.73\altDropTime\0.467\altRaiseTime\0.733\quickDropTime\0.25\quickRaiseTime\0.75\firstRaiseTime\0.73\emptyDropTime\0.467\emptyRaiseTime\0.73\sprintInTime\0.3\sprintLoopTime\1\sprintOutTime\0.3\nightVisionWearTime\0\nightVisionWearTimeFadeOutEnd\0\nightVisionWearTimePowerUp\0\nightVisionRemoveTime\0\nightVisionRemoveTimePowerDown\0\nightVisionRemoveTimeFadeInStart\0\clipOnly\0\adsTransInTime\0.5\adsTransOutTime\0.5\adsZoomFov\55\adsZoomGunFov\40\adsZoomInFrac\0.5\adsZoomOutFrac\0.1\adsOverlayShader\\adsOverlayReticle\none\adsOverlayInterface\none\adsOverlayWidth\240\adsOverlayHeight\240\adsBobFactor\1\adsViewBobMult\0\hipSpreadStandMin\5\hipSpreadDuckedMin\3.5\hipSpreadProneMin\2\hipSpreadMax\6\hipSpreadDuckedMax\6\hipSpreadProneMax\6\hipSpreadDecayRate\2.5\hipSpreadFireAdd\0.4\hipSpreadTurnAdd\0\hipSpreadMoveAdd\2.3\hipSpreadDuckedDecay\1.375\hipSpreadProneDecay\1.6\hipReticleSidePos\0\adsSpread\1.7\adsIdleAmount\25\hipIdleAmount\80\hipIdleSpeed\1\adsIdleSpeed\1\idleCrouchFactor\0.5\idleProneFactor\0.15\gunMaxPitch\30\gunMaxYaw\30\adsAimPitch\0\adsCrosshairInFrac\1\adsCrosshairOutFrac\0.2\adsReloadTransTime\0.6\adsGunKickPitchMin\-30\adsGunKickPitchMax\-20\adsGunKickYawMin\-17\adsGunKickYawMax\17\adsGunKickAccel\250\adsGunKickSpeedMax\1000\adsGunKickSpeedDecay\10\adsGunKickStaticDecay\1\adsViewKickPitchMin\20\adsViewKickPitchMax\95\adsViewKickYawMin\-10\adsViewKickYawMax\30\adsViewKickCenterSpeed\2500\hipGunKickPitchMin\-5\hipGunKickPitchMax\-3\hipGunKickYawMin\-15\hipGunKickYawMax\15\hipGunKickAccel\250\hipGunKickSpeedMax\500\hipGunKickSpeedDecay\15\hipGunKickStaticDecay\1\hipViewKickPitchMin\100\hipViewKickPitchMax\150\hipViewKickYawMin\-50\hipViewKickYawMax\-80\hipViewKickCenterSpeed\1500\swayMaxAngle\30\swayLerpSpeed\6\swayPitchScale\0.1\swayYawScale\0.1\swayHorizScale\0.1\swayVertScale\0.1\swayShellShockScale\5\adsSwayMaxAngle\30\adsSwayLerpSpeed\6\adsSwayPitchScale\0.1\adsSwayYawScale\0.1\adsSwayHorizScale\0.1\adsSwayVertScale\0.1\hudIcon\hud_icon_rpg\killIcon\hud_icon_rpg\dpadIcon\hud_icon_rpg_dpad\ammoCounterIcon\hud_icon_rpg\hudIconRatio\4:1\killIconRatio\4:1\dpadIconRatio\1:1\ammoCounterIconRatio\4:1\ammoCounterClip\Rocket\flipKillIcon\1\worldModel\weapon_rpg7\worldModel2\\worldModel3\\worldModel4\\worldModel5\\worldModel6\\worldModel7\\worldModel8\\worldModel9\\worldModel10\\worldModel11\\worldModel12\\worldModel13\\worldModel14\\worldModel15\\worldModel16\\worldClipModel\\rocketModel\viewmodel_rpg7_rocket\knifeModel\viewmodel_knife\worldKnifeModel\weapon_parabolic_knife\ammoName\rpg\maxAmmo\2\startAmmo\2\clipName\rpg_mp\clipSize\1\dropAmmoMin\1\dropAmmoMax\2\viewFlashEffect\muzzleflashes/at4_flash\worldFlashEffect\muzzleflashes/at4_flash\shellEjectEffect\\lastShotEjectEffect\\worldClipDropEffect\\pickupSound\weap_pickup\pickupSoundPlayer\weap_pickup\ammoPickupSound\\ammoPickupSoundPlayer\\projectileSound\weap_rpg_loop\fireSound\weap_rpg_fire_npc\fireSoundPlayer\weap_rpg_fire_plr\lastShotSound\\lastShotSoundPlayer\\emptyFireSound\weap_dryfire_rifle_npc\emptyFireSoundPlayer\weap_dryfire_rifle_plr\meleeSwipeSound\melee_swing_ps_large\meleeSwipeSoundPlayer\melee_rpg_swing_plr\rechamberSound\\rechamberSoundPlayer\\reloadSound\\reloadSoundPlayer\\reloadEmptySound\\reloadEmptySoundPlayer\\reloadStartSound\\reloadStartSoundPlayer\\reloadEndSound\\reloadEndSoundPlayer\\altSwitchSound\\altSwitchSoundPlayer\\raiseSound\weap_rpg_raise_npc\raiseSoundPlayer\weap_rpg_raise_plr\firstRaiseSound\\firstRaiseSoundPlayer\\putawaySound\weap_rpg_drop_npc\putawaySoundPlayer\weap_rpg_drop_plr\bounceSound\\nightVisionWearSound\\nightVisionWearSoundPlayer\\nightVisionRemoveSound\\nightVisionRemoveSoundPlayer\\reticleCenter\reticle_flechette\reticleSide\\reticleCenterSize\32\reticleSideSize\24\reticleMinOfs\17\enemyCrosshairRange\1000\crosshairColorChange\1\altWeapon\\boltAction\0\aimDownSight\1\rechamberWhileAds\1\adsViewErrorMin\0\adsViewErrorMax\0\adsFire\1\noAdsWhenMagEmpty\0\avoidDropCleanup\0\cancelAutoHolsterWhenEmpty\0\suppressAmmoReserveDisplay\0\blocksProne\0\noPartialReload\0\reloadAmmoAdd\1\autoAimRange\0\aimAssistRange\1000\aimAssistRangeAds\1000\fightDist\720\maxDist\1400\aiVsAiAccuracyGraph\\aiVsPlayerAccuracyGraph\\standMoveF\0\standMoveR\0\standMoveU\-1.7\standRotP\0\standRotY\0\standRotR\0\duckedOfsF\-2\duckedOfsR\0.8\duckedOfsU\-0.2\duckedMoveF\-1\duckedMoveR\0\duckedMoveU\-1.7\duckedRotP\0\duckedRotY\0\duckedRotR\0\proneOfsF\-2\proneOfsR\1\proneOfsU\-1\proneMoveF\-160\proneMoveR\3\proneMoveU\-120\proneRotP\0\proneRotY\300\proneRotR\-300\posMoveRate\6\posProneMoveRate\25\standMoveMinSpeed\110\duckedMoveMinSpeed\60\proneMoveMinSpeed\0\posRotRate\6\posProneRotRate\30\standRotMinSpeed\110\duckedRotMinSpeed\60\proneRotMinSpeed\0\explosionRadius\300\explosionInnerDamage\160\explosionOuterDamage\30\damageConeAngle\180\projectileSpeed\1500\projectileSpeedUp\500\projectileActivateDist\0\projectileLifetime\5\projectileModel\projectile_rpg7\projExplosionType\rocket\projExplosionEffect\\projExplosionEffectForceNormalUp\0\projExplosionSound\\projDudEffect\\projDudSound\\projImpactExplode\1\projTrailEffect\smoke/smoke_geotrail_rpg\projectileDLight\200\projectileRed\0.75\projectileGreen\0.3\projectileBlue\1\projIgnitionDelay\0\projIgnitionEffect\\projIgnitionSound\\destabilizationRateTime\0.4\destabilizationCurvatureMax\10\destabilizeDistance\300\parallelDefaultBounce\0.5\parallelBarkBounce\0.5\parallelBrickBounce\0.5\parallelCarpetBounce\0.5\parallelClothBounce\0.5\parallelConcreteBounce\0.5\parallelDirtBounce\0.5\parallelFleshBounce\0.5\parallelFoliageBounce\0.5\parallelGlassBounce\0.5\parallelGrassBounce\0.5\parallelGravelBounce\0.5\parallelIceBounce\0.5\parallelMetalBounce\0.5\parallelMudBounce\0.5\parallelPaperBounce\0.5\parallelPlasterBounce\0.5\parallelRockBounce\0.5\parallelSandBounce\0.5\parallelSnowBounce\0.5\parallelWaterBounce\0.5\parallelWoodBounce\0.5\parallelAsphaltBounce\0.5\parallelCeramicBounce\0.5\parallelPlasticBounce\0.5\parallelRubberBounce\0.5\parallelCushionBounce\0.5\parallelFruitBounce\0.5\parallelPaintedMetalBounce\0.5\perpendicularDefaultBounce\0.5\perpendicularBarkBounce\0.5\perpendicularBrickBounce\0.5\perpendicularCarpetBounce\0.5\perpendicularClothBounce\0.5\perpendicularConcreteBounce\0.5\perpendicularDirtBounce\0.5\perpendicularFleshBounce\0.5\perpendicularFoliageBounce\0.5\perpendicularGlassBounce\0.5\perpendicularGrassBounce\0.5\perpendicularGravelBounce\0.5\perpendicularIceBounce\0.5\perpendicularMetalBounce\0.5\perpendicularMudBounce\0.5\perpendicularPaperBounce\0.5\perpendicularPlasterBounce\0.5\perpendicularRockBounce\0.5\perpendicularSandBounce\0.5\perpendicularSnowBounce\0.5\perpendicularWaterBounce\0.5\perpendicularWoodBounce\0.5\perpendicularAsphaltBounce\0.5\perpendicularCeramicBounce\0.5\perpendicularPlasticBounce\0.5\perpendicularRubberBounce\0.5\perpendicularCushionBounce\0.5\perpendicularFruitBounce\0.5\perpendicularPaintedMetalBounce\0.5\fireRumble\\meleeImpactRumble\\adsDofStart\0\adsDofEnd\0\requireLockonToFire\0\notetrackSoundMap\weap_rpg_raise_plr weap_rpg_raise_plr weap_rpg_drop_plr weap_rpg_drop_plr melee_knife_stab melee_knife_stab weap_rpg_lift_plr weap_rpg_lift_plr weap_rpg_insert_plr weap_rpg_insert_plr weap_rpg_twist_plr weap_rpg_twist_plr
  • I have changed the display name of the weapon, and it's viewmodel. It will look like your model in first person view, but will still be an rpg in other people's hands and thirdperson. For more info on modding weaponfiles, Shadowlance194 wrote a tutorial here: http://www.modsonline.com/Tutorials-read-466.html
  • This weaponfile needs to go in the mod IWD\weapons\mp folder, and also needs to be referenced in the mod csv:
weapon,mp/rpg_mp

Outline of updating model process:

  • Save model in Maya
  • Open Cod4 export plugin, tick 'entry1' & Select Exports, Set Exports if the geometry has changed
  • Edit version number in .xmodel_export
  • Convert model & materials in Asset Manager
  • Put textures in IWD, re-build fastfile


NOTES AND WARNINGS:
  • This is quite complicated, with a lot of things that can go wrong.
  • There is no way to reverse the conversion; you can't get an xmodel_export from an xmodel file. You also can't re-import the xmodel_export into Maya, like in old versions of Cod, so don't lose the source!
  • You will find that the weapon model looks very small in thirdperson view, or if you are looking at someone else who has it. You need to create a separate worldmodel for it, because for some reason they are on different scales. On estimate, the worldmodel needs to be around twice as large.
  • There are three joints on this model. The one at the front, tag_flash, defines where the muzzleflash effect will be.
  • The actual position of the weapon in your hand is the position of the weapon model relative to 0,0,0 in Maya, none of the joints control it.
  • If you only edit a stock weaponfile, you don't need to worry about precaching it. However, if it's not stock, you need to add a line in your mod scripts: PrecacheItem("weaponfile_name");