Getting Characters and their Anims into Doom

From The DarkMod Wiki
Jump to navigationJump to search

Originally written by oDDity on http://forums.thedarkmod.com/topic/1485

(Severely edited by Domarius)

This tutorial only covers getting the character into Doom 3, importing the animations, and cycling through them in Doom 3. It does not cover the script writing necessary to create behaviour for the characters.

Preparation

First, make sure Doom 3 is updated to version 1.3 by downloading and installing the patch from here.

Then you need to extract a MayaImportx86.dll from MayaImportx86_versions and put it in your Doom 3 folder.

Save you character in Maya as a .mb file. It has been boned and weighted obviously, and the rig has to have a bone called origin at the 0,0,0 world origin, and the skeleton has this as the parent bone.

Write the definition file

This is just a simple text file that you will save as Doom3\base\def\mycharacter.def (or Doom3\darkmod\def\mycharacter.def if you want it to show up in the DarkMod)

The first section of the definition file deals with this exporting. sourcedir is the source directory where you saved your .mb files, and destdir is where you want the exported files to go.

export hammer
{
  options -sourcedir models/mymodels/hammer -destdir models/md5/mycharacter/hammer

  mesh hammer.mb
  anim idle.mb -dest stand
  anim stepback.mb -dest sight1
  anim walkF.mb -dest walk1
  anim attack1.mb -dest swing1
  anim attack2.mb -dest swing2
  anim attack1.mb  -dest swing3
  anim attack2.mb  -dest swing4
  anim attack1.mb -dest swing5
  anim stepback.mb  -dest head_pain1
  anim stepback.mb  -dest head_pain2
  anim stepback.mb  -dest head_pain3
  anim stepback.mb -dest chest_pain1
  anim stepback.mb  -dest chest_pain2
  anim stepback.mb  -dest leftarm_pain1
  anim stepback.mb  -dest leftarm_pain2
  anim stepback.mb  -dest rightarm_pain1
  anim stepback.mb  -dest rightarm_pain2
  anim attack1.mb   -dest spit_attack1
  anim RunF.mb -dest fastwalk
}

The "mesh" line is your base mesh in the stance pose, and all the diffent animations you did are in the following lines. the '-dest' after them is used to export it as a different file name, so on the bottom line the .mb file 'runf' animation is saved as 'fastwalk.md5anim'

That's all you need in the definintion file to get it in the game. I'd call this definiton file 'hammer.def'

Export the model and its animations

Run Doom or DoomEdit, go to the console (CTRL+ALT+~ in Doom) and type

exportModels hammer

and this should convert all the maya files to md5 files.

You will know if the export process works because it will spit out a lot of info to the console, and appear to lock up at times.

IMPORTANT: Take note of which files have been exported (check the time stamp on the file, or the SVN icon). exportModels will only export new animation or mesh files for source .mb files that have been changed since the last run of exportModels. If it re-exports the mesh or some anims when you don't think they have been changed, you need to check the source .mb for changes that you might have missed. Though if the -source and -dest folders in the .def file have changed, this will cause it to export everything again.

Troubleshooting exportModels

If you get an error like "Exporter Error: Maya Not Installed In Registry", you need to do the following; Find the 'my computer' icon on your desktop or in your start menu, right click on it and choose 'properties' which takes you to the system tab, then click the advanced tab, and click the environment variables button. In the bottom pane, scroll through the list till you see an item called "Path", click on it, and click "Edit". Make sure there is a ; on the end of whatever is there, and then add the path that you installed Maya, with \bin on the end, eg.

D:\Programs\Maya7\bin

But if nothing at all happens and you get taken straight back to the prompt with no error messages, there are plenty of things that could be wrong. Doom is not helpful in this regard. (When I first tried this, there was a typo in the origin path in my def file, but I got no error message --Springheel)

Fortunately, you can work it out with Process Monitor. Create a filter that only shows Doom3.exe activities and watch where the problem occours. It may be a failed registry access or a failed file access, something like that. See if you can rectify it by babying Doom 3.

For example, in one instance, Doom 3 was looking for a file called foundation.dll in D:\Games\bin - this file is actually found in the Maya\bin folder, so all that was needed was to make a D:\Games\bin folder and copy foundation.dll over into it.

Note that this paragraph doesn't apply anymore for TDM, but it might be of interest for other mods, so I'll leave it --greebo In another instance, Doom 3 was trying to access a registry entry called HKLM\SOFTWARE\Alias|WaveFront\Maya, so I looked in the registry and found the real entry was HKLM\SOFTWARE\Alias|WaveFront\Archives\Maya, and I figured it just wanted the INSTALLDIR item out of it, so I made another HKLM\SOFTWARE\Alias|WaveFront\Maya path for it and put an INSTALLDIR there - then when I ran exportModels it then got a bit further, and asked me to specify the maya folder (bringing up a dialogue box) so I did (same folder as was in the key...) and away it went.

If the "Cannot determine the Maya environment" message keeps popping up, add a MAYA_LOCATION environment variable pointing to your Maya7 folder, like C:\Program Files\Alias\Maya7 or wherever you installed it to.

One user (amita12) reported that the exporter didn't work for him unless the Maya program was installed to a different location (it was installed in "Program Files" before). It maybe that the spaces in the path prevented the exporter from working.

Testing the model

If and when the export process completes without any errors, then load any map in Doom 3 by typing

map mapname

in the console, leaving off the .map extention

(For a list of available maps, look in your Doom3\base\maps or Doom3\darkmod\maps folder)

Then in the console, type

testModel hammer

replace hammer with whatever your def file is called, but don't put .def on the end of it. Your model will appear a few feet in front of you, so don't face a wall. Then just type

nextanim

repeatedly to cycle through the animations in sequence.

Note: the head for this testmodel is defined by the CVAR g_testModelHead, which defaults to the citywatch's head head_citywatch.

More information

This tutorial is a work in progress, and may have errors and is certainly not very complete. Please refer to the following resources for more information.

Exporting models into Doom 3 (PDF)

Various pages on exporting characters to Doom 3 from all the major modelling applications.

See also