MODELDEF

From ZDoom Wiki
Jump to: navigation, search
Center Warning: This feature does not work in ZDoom but in its OpenGL children ports.

MODELDEF is the lump which defines models used in hardware-accelerated ports.

Model Definition Overview

Models with named frames

MD2s normally have actual frame names so you can reference them by name.

Model <ActorName>
{
   Path <"path">
   Model <model index> <"model file">
   Skin <model index> <"skin file">
   Scale <X scale> <Y scale> <Z scale>

   Frame <XXXX> <X> <model index> <"frame name">
}

For models with unnamed frames

MD3s do not contain any useful names that you can use. You would use frame indexes instead of frame names. More information below.

Model <ActorName>
{
   Path <"path">
   Model <model index> <"model file">
   Skin <model index> <"skin file">
   Scale <X scale> <Y scale> <Z scale>

   FrameIndex <XXXX> <X> <model index> <frame number>
}

More detailed information

In the two above examples, <ActorName> is the name of the actor (as used in DECORATE, etc), <XXXX> is the sprite lump (example POSS), and <X> is the sprite frame (example A). The rest can be found in the Properties section.

Flags and Properties

Flags

There are a number of flags that you can use in MODELDEF.

  • PITCHFROMMOMENTUM
Adjusts the model's pitch to match the momentum of the actor; useful for rocket projectiles.
  • IGNORETRANSLATION
Ignores the actor's translation.
  • INHERITACTORPITCH
Model's pitch adjusts to match actor's pitch.
  • INHERITACTORROLL
Model's roll, adjusts to match actor's roll. However, due to the absence proper functions to adjust an actor's roll, this has currently no use.
  • INTERPOLATEDOUBLEDFRAMES
Workaround to smooth the model interpolation of actors that use the same frame twice in a row. Most of the standard Doom monsters do this in their see state.
  • ROTATING
Makes the model rotate, useful for pickup models a la Quake 3.
  • NOINTERPOLATION
Forces uninterpolated animation.

Properties

  • AngleOffset angle
Changes model yaw angle by the given floating point value in degrees.
  • Model model-index model-file
Defines model to use. You can define multiple models to use with different indexes.
  • Path path
Path to model file in the ZIP/PK3
  • PitchOffset angle
Changes model pitch angle by the given floating point value in degrees.
  • Offset xoffset yoffset zoffset
Sets actor x/y/z offsets.
  • RollOffset angle
Changes model roll angle by the given floating point value in degrees.
  • Rotation-Center float float float
Specify the x, y and z coordinate of the center of the rotation
  • Rotation-Speed float
Specify the speed of the rotation. Without the ROTATING keyword, this and the other rotation properties do nothing
  • Rotation-Vector float float float
Specify the x, y and z component of the vector of the rotation
  • Skin model-index skin-file
Defines skin to use for the model of the same index. The skin-file can be of any format that ZDoom supports.
  • Scale float float float
Defines the x, y, and z scaling of the model.
  • ZOffset float
Adjusts the model's height, useful if you don't have access to a model editor.

Examples

Simple one-frame example:

Model SteelCrate
{
   Path "Models/Crate"
   Model 0 "Steelc.md2"
   Skin 0 "Steelc.png"

   Frame COL1 A 0 "frame01"
}

An example of a walking animation for an MD2 model (uses frame names instead of frame numbers):

Model BloodHound              // Name of actor in DECORATE
{
   Path "models/bloodhound"   // Path to model in PK3
   Model 0 "bloodhound.md2"   // Model index, model file
   Skin 0 "bloodhound.pcx"    // Model index, texture (can be in any format supported by GZDoom)
   Scale 1.0 1.0 1.0          // Scale values

   Frame BHND A 0 "walk01"    // The sprite lump, sprite frame, model index, name of frame
   Frame BHND B 0 "walk02"
   Frame BHND C 0 "walk03"
   Frame BHND D 0 "walk04"
}

An example of a walking animation for an MD3 model (uses frame numbers instead of frame names):

Model InsaneCancer               // Name of actor in DECORATE
{
   Path "models/insanecancer"    // Path to model in PK3
   Model 0 "insanecancer.md3"    // Model index, model file
   Skin 0 "insanecancer.png"     // Model index, texture (can be in any format supported by GZDoom)
   Scale 1.0 1.0 1.0             // Scale values

   FrameIndex ICNC A 0 0         // The sprite lump, sprite frame, model index, frame number
   FrameIndex ICNC B 0 1
   FrameIndex ICNC C 0 2
   FrameIndex ICNC D 0 3
}

Multiple model example:

Model MultiModel
{
   Path "Models/MyModel"
   Model 0 MyModel_Piece_1.md3
   Skin 0 MyModel_Piece_1.jpg
   Model 1 MyModel_Piece_2.md3
   Skin 1 MyModel_Piece_2.jpg
   Model 2 MyModel_Piece_3.md3
   Skin 2 MyModel_Piece_3.jpg
   Model 3 MyModel_Piece_4.md3
   Skin 3 MyModel_Piece_4.jpg

   Scale 1.0 1.0 1.0

   Frame FRAM A 0 0 // All four models are drawn when you call frame "FRAM A"
   Frame FRAM A 1 0
   Frame FRAM A 2 0
   Frame FRAM A 3 0
}

Animation through multiple skins example using two model parts:

Model "PDA Model"
{
   Path "models\PDA"
   Model 0 "PDA.md3"
   Skin 0 "pda.png"
   Model 1 "pdascreen.md3"
   Path "textures\models\PDA" //this redirects the path for the next file
   Skin 1 "pdas1.png" // Each redefinition includes the next frame of skin animation for this piece
   Scale 3.0 3.0 3.0
   
   FrameIndex PDA1 A 0 0 // Both the frame and screen are pieced together
   FrameIndex PDA1 A 1 0
}
Model "PDA Model" //re-defining the same actor for the next frame
{
   Path "models\PDA"
   Model 0 "PDA.md3"
   Skin 0 "pda.png"
   Model 1 "pdascreen.md3"
   Path "textures\models\PDA"
   Skin 1 "pdas2.png"  
   Scale 3.0 3.0 3.0
   
   FrameIndex PDA1 B 0 0 // the next frame is defined
   FrameIndex PDA1 B 1 0
}
Model "PDA Model"
{
   Path "models\PDA"
   Model 0 "PDA.md3"
   Skin 0 "pda.png"
   Model 1 "pdascreen.md3"
   Path "textures\models\PDA"
   Skin 1 "pdas3.png"
   Scale 3.0 3.0 3.0
   
   FrameIndex PDA1 C 0 0
   FrameIndex PDA1 C 1 0
}
Model "PDA Model"
{
   Path "models\PDA"
   Model 0 "PDA.md3"
   Skin 0 "pda.png"
   Model 1 "pdascreen.md3"
   Path "textures\models\PDA"
   Skin 1 "pdas4.png"
   Scale 3.0 3.0 3.0
   
   FrameIndex PDA1 D 0 0
   FrameIndex PDA1 D 1 0
}

Brightmapped Example:

Model BrightmapModel
{
   Path "Models/MyModel"
   Model 0 "MyModel.md3"
   Path "Textures/Models/MyModel/Skin" //this redirects the path for the next file
   Skin 0 "MyModel_Skin.png" //this must be defined as a brightmap in GLDEFS

   Scale 1.0 1.0 1.0

   FrameIndex FRAM A 0 0
}

Notes

While you are limited to using 4 model 'pieces' in each definition, you can re-define the same actor again to add more. This way, you are not limited to any given skin animation length, or by the number of model parts.

Model skins can be brightmapped by placing all related skins in the TEXTURES folder of your pk3, and redefining the skin path appropriately. Brightmaps must then be declared within GLDEFS as normal.

If you don't know how the frames in your model file are named, simply use FrameIndex instead of Frame. By using FrameIndex, all you have to do is supply the frame NUMBERS, without having to worry about typing out the frame names correctly.