Making DOOM 3 Mods : Models

A model decl defines an animated model in the game. Static models don't need decls, they can be specified by the actual file name. Anything that animates does need a decl.

All a model decl does is tie a mesh to an set of animations. Therefore if a model doesn't have animations, it doesn't need a model decl.

The number of commands that can be in a model definition is quite small, here's a full list:

CommandDescription
inherit <model>Copies everything from another model definition
skin <skin>Specify the skin to use
mesh <file>Specify the mesh file to use (.md5mesh)
remove <anim>Remove an animation from the definition. Used to get rid of unwanted animations that were inherited with the 'inherit' command.
anim <name> <file> [ { ... } ]An animation definiton (described below)
offset <x, y, z>Offset the model from the origin
channel <name> ( <joints> )Set up an animation channel.

The channel command allows animations to play only on certain joints. For example, you can have a walking animation playing on the legs, a yo-yo animation playing on the torso, and a chewing bubble gum animation playing on the head.

Let's take a look at a shortened version of our good friend, the cyberdemon:

model monster_boss_cyberdemon
{
    mesh          models/md5/monsters/cyberdemon/cyberdemon.md5mesh
    channel torso ( *Waist )
    channel legs  ( *Hips Body origin ROT -*Waist)

    anim af_pose  models/md5/monsters/cyberdemon/af_pose.md5anim
    anim ik_pose  models/md5/monsters/cyberdemon/ik_pose.md5anim

    anim stand    models/md5/monsters/cyberdemon/idle.md5anim
    anim idle     models/md5/monsters/cyberdemon/idle.md5anim
    anim sight1   models/md5/monsters/cyberdemon/sight.md5anim {
        frame 16.5  sound_voice    snd_sight1
    }
    anim walk     models/md5/monsters/cyberdemon/walk3.md5anim {
        frame 17    sound_body snd_footstep
        frame 17    triggerSmokeParticle cyber_rfoot_dust
        frame 37    sound_body snd_footstep
        frame 37    triggerSmokeParticle cyber_lfoot_dust
    }
    anim pain     models/md5/monsters/cyberdemon/pain_big1.md5anim {
        frame 1    call overrideLegs
        frame 1    sound_voice snd_pain
        frame 16   sound_body  snd_footstep
        frame 49   sound_body  snd_footstep
    }
}

You'll notice the mesh and the animations are defined in seperate files and glued together with this decl. That means you can use the same animation file with multiple meshes (really handy). You can also reference the same animation file multiple times in the same model (for example, notice the 'idle' animation and the 'stand' animation both use 'cyberdemon/idle.md5anim').

Apart from tying animations to meshes, this decl type allows us to specify events that happen on certain frames. This makes it trivial to sync sounds and special effects to things like footsteps, weapons fire, etc.

In this example, the 'snd_sight1' sound is played on the voice channel at frame 16.5 of the 'sight1' animation. snd_footstep is played on the body channel at frames 16 and 49 of the 'pain' animation.

Here's a chart that lists all the available frame commands:

CommandDescription
call <function>Calls the specified script function
object_call <function>Calls the specified script function on the entity
event <event> [args...]Sends the specified event to the entity
sound <snd>Plays the specified sound on any available channel
sound_voice <snd> Plays the specified sound on the specified channel. If a sound is being played on the body channel, and another sound is requested to play, then the first sound is halted. Since the footstep sounds are all defined to be on the body channel, there will never be 2 footstop sounds played twice on the same entity at the same time.
sound_voice2 <snd>
sound_body <snd>
sound_body2 <snd>
sound_body3 <snd>
sound_weapon <snd>
sound_global <snd>
sound_item <snd>
sound_chatter <snd>
skin <skin>Changes the model's skin to <skin>
fx <fx>Triggers an effect defined by the decl <fx>
trigger <name>Triggers the level trigger named <name>
recordDemo <name>Starts recording a demo named <name> or stops recording if blank
aviGame <name>Starts an aviGame named <name> Useful for making animations to be used on video screens (such as all the talking head videos in Doom 3)

There are some frame commands that are just shortcuts to various built in events:

CommandShortcut for
triggerSmokeParticle ...event triggerParticles ...
melee ...event attackMelee ...
direct_damage ...event directDamage ...
attack_begin ...event attackBegin ...
attack_endevent attackEnd
muzzle_flash ...event muzzleFlash ...
create_missile ...event createMissile ...
launch_missile ...event launchMissile ...
fire_missile_at_target ...event fireMissileAtTarget ...
footstepevent footstep
leftfootevent leftfoot
rightfootevent rightfoot
CommandShortcut for
jumpevent jump
enableEyeFocusevent enableEyeFocus
disableEyeFocusevent disableEyeFocus
disableGravityevent disableGravity
enableGravityevent enableGravity
enableClipevent enableClip
disableClipevent disableClip
enableWalkIKevent enableWalkIK
disableWalkIKevent disableWalkIK
enableLegIKevent enableLegIK
disableLegIKevent disableLegIK

Copyright © 2004 id software