Model (DED)

From Doomsday Wiki
Jump to: navigation, search

Cleanup Note: This article should be cleaned up to be more readable and/or to more closely follow the Wiki article guidelines.

Model
Attributes: Copy
Type ReferenceDED Syntax

A single Model is represented by a collection of one to eight "sub-models". Each Sub{}-model may be assigned it's own 3d model file. Sub-model indices are specified according to their position in the definition, sequentially (starting from zero). The engine treats sub-models separately. (Allowing independent animation interpolation).

Theory

Flag usage

  • Stated at definition "root" level flags affect all sub-models:
Model {
  Flags = flag;
}
  • Stated at Sub{} level scopes them to only that sub-model:
Model {
  Sub {
    Flags = flag;
  };
}

A XOR operation of Model{ Sub{ Flags }} with Model{ Flags } will reverse them, meaning the sub-model flags can be used to turn off or on flags that affect all sub-models.

Usage Example

Model
{
    Flags = shadow1;
    Sub { Flags = shadow1; }; # Not shadowed at all.
    Sub { Flags = fullbright; }; # Shadowed and fullbright.
    Sub { }; # Just shadowed.
}

Animation

Inter and Interpolate can be used together. You can for example assign two model frames to span across three states:

:    (Frame 1)    :    (Frame 2)    :
:                 :                 :
+-----------+-----------+-----------+ Time-->
| (State 1) | (State 2) | (State 3) |
|0         1|0   0.5   1|0         1| Inter (0..1)
D1----------D2----D3----D4----------+
:           :     :     :
:           :     :     4th defn: S3, Inter=0, Interpolate {0.333 1}
:           :     :
:           :     3rd defn: S2, Inter=0.5, Interpolate {-0.333 0.333}
:           :
:           2nd defn: S2, Inter=0, Interpolate {0.666 1.333}
:
1st definition: S1, Inter=0, Interpolate {0 0.666}

Note the 2nd definition's Interpolate end marker (1.333) and 3rd definition's Interpolate start marker (-0.333). This is needed because the 2nd definition only extends from Inter=0 to Inter=0.5, but we want that at Inter=0.5 the interpolation visually reaches its end (frame 1 ends and frame 2 begins): point 0.5 in the range {0.666 1.333} is one. The 3rd definition's case is similar, but this time the definition begins really from Inter=0.5 and visually from the beginning (i.e. zero). When 0.5 is scaled to the range {-0.333 0.333} we get the zero we wanted.

Syntax

<Copy> Model
{
   ID = "";
   State = "";
   Off = 0;
   Group = "";
   Selector = 0;
   Inter = 0.0;
   Interpolate { 0.0 1.0 };
   Flags = flaga | flagb | flagc;
   Skin tics = 0;
   Scale = 1.0;
   Scale XYZ { 1.0 1.0 1.0 };
   Resize = 0;
   Offset = 0.0;
   Offset XYZ { 0.0 0.0 0.0 };
   Sprite = "";
   Sprite frame = 0;
   Shadow radius = 0;

   Sub # A sub-model begins. 'Md2' can be used instead.
   {
       # There must be at least one sub-model per definition
       # (up to eight are supported).
       File = "";
       Frame = "";
       Frame range = 0;
       Flags = "";
       Blending mode = normal;
       Shiny reaction = 1.0;
       Skin = 0;
       Skin range = 0;
       Skin file = "";
       Offset XYZ { 0.0 0.0 0.0 };
       Transparent = 0.0;
       Shiny skin = "";
       Shiny = 0.0;
       Shiny color { 1.0 1.0 1.0 };
       Selskin mask = 0;
       Selskin shift = 0;
       Selskins { 0 0 0 0 0 0 0 0 };
       Parm = 0.0;
   };
}

If the Copy attribute is used, all the data of the previous definition is copied to this one. For the first definition in a file Copy has no effect.

A model definition must define at least one sub-model (up to a maximum of eight).

You can set flags in both the main Model definition and the Sub-model definitions.

ID

The identifier of this definition. You can only set either the ID key or the State key, not both. Models with an ID can't be assigned to Thing States.

State

The State this model will be used with. You can only set either the ID key or the State key, not both.

Off

Offset to state index. Use carefully! If State indices change you'll be in a lot of trouble.

Group

One or more group IDs (mg_*). Optional.

Selector

A custom value which can be used by the Game for various purposes, like alternative models for some objects.

Inter

Possible values: 0-1. Determines the point during the interpolation between states when this definition becomes valid. Can be used to assign several different model frames to a single State.

Note: Sub-models are sorted by definition order when drawing so Sub{}-model definitions must be given in an ascending order; the definition with the lowest Inter value is drawn last.

Interpolate

Range of interpolation. Specifies the range of the visual interpolation of the model during the State. Can be used to extend the interpolation of one model frame onto multiple States (by defining a sub-0..1 range). Always define full ranges that begin from zero and end to one.

When the worldtime flag is used, this statement has a different meaning:

Interpolate { <range-length> <interpos-offset> }
  • <range-length>: number of seconds one animation cycle takes to run from start to finish (Inter 0...1).
  • <interpos-offset>: offset factor added to Inter, a point calculated from world time and <range-length> (offset should be between 0 and 1). If -1 a random offset is chosen for each object.

Flags

Flags for the whole model, including all the submodels.

Name Purpose
alignpitch Aligns pitch rotation of the model with the camera.
alignyaw Aligns yaw rotation of the model with the camera.
autoscale The model is automatically scaled to match the dimensions of the original sprite.
brightshadow The model is rendered with additive blending and 80% translucency.
brightshadow2 The model is rendered with additive blending (equivalent to #Blendmode = add).
darkshadow The model is rendered with inverse-additive blending (equivalent to #Blendmode = dark).
fullbright The model is rendered with the maximum light level (corresponds sector light level 255) regardless of the sector it's currently in.
idangle The model gets a unique yaw angle offset calculated from the ID number of the object.
idframe An offset derived from the ID number of the object is added to the current frame index of the object. #Frame range must also be set.
idskin Assigns a unique skin selection based on the ID of the model's object.
litshiny Lighting should be applied to the model's shiny texture (if defined).
movpitch Enables model's pitch rotation in accordance with the object's velocity.
movyaw Enables model's yaw rotation in accordance with the object's velocity.
nointerpol Disable model vertex interpolation.
nomaxz Model is used at all distances regardless of the model visibility settings.
noptc Disables emission of particles for particle generators associated with the model.
notexcomp Disable texture compression of all the skins of the model associated with this definition.
noz The model is rendered with Z-buffer writes disabled.
ptoffsub1 The center of submodel #1 is the spawn origin for particle generators.
selskin Enable skin selection with #Selskin Mask, #Selskin Shift, and #Selskins keys.
shadow1 The model is rendered with 33% translucency. When using this flag the value of the #Transparent is ignored.
shadow2 The model is rendered with 66% translucency. When using this flag the value of the #Transparent is ignored.
skintrans Skin selection is determined by the color translation of the original sprite.
specular Enable specular highlighting when rendering the model.
spin Enable model spinning. Useful for showcasing items etc.
twosided The model is rendered with both sides of each face drawn. Useful for simple models with texturized planes in which both both sides must be visible.
worldtime Model's animation becomes a function of world time. Changes the meaning of #Interpolate. This is intended to make it easier to animate objects with just one state.

Skin tics

Skin cycle: this many tics for each skin.

Scale

Scaling factor for the whole model (all submodels affected). Uniformly sets *all* components of Scale XYZ to the specified scaling factor.

Scale XYZ

Scaling factors for the whole model (all submodels affected).

Resize

Automatic resizing to the given height. The whole model will be scaled (only along the Y axis).

Offset

Offset to model Y coordinate, applied when rendering. Affects all submodels. Modifies the Y component of Offset XYZ.

Offset XYZ

Offset to model X, Y and Z coordinates, applied when rendering. Affects all submodels.

Sprite

Sprite frame

For auto-scaling: specifies the sprite and frame to scale things by. If not given, auto-scaling is done based on the sprite and frame associated with the State of this model.

Shadow radius

With the default value of zero the shadow radius is automatically calculated based on the visual bounds of the object/model.

Sub (or Md2)

There can be eight Sub blocks in a Model definition. Each block defines one sub-model.

File

Model file, e.g. "Monst\Trooper.md2". The given file name is searched from all the directories specified in the model search path. The skin of the model should reside in the same directory with the model (not required, though: it's enough that the skin is on the model path as well).

Frame

Name of the animation frame within the model file to use.

Frame range

Used with the df_idframe flag. Defines how many consecutive frames make up the range for the frame index offset, which is calculated from the object's ID.

Flags

Flags (with the prefix df_*) that affect this sub-model only. A XOR operation is done with the model flags (which affect the whole model).

Blending mode

Blending mode for this submodel. One of the bm_* flags. Note that blending modes set by the flags override this setting.

Shiny reaction

A factor that modifies how shiny coordinates are calculated for the submodel. Values below 1.0 will reduce the effect rotation of the model has on the shiny coordinates.

Skin

The index number of the skin to use.

Skin range

Size of the skin cycling range. The first skin in the range is the one specified by Skin, and the last one is (Skin) + (Skin range) - 1.

Skin file

File name of the skin. This can be any image file on the model path. If a skin file is specified, the skin number is ignored. If skins are defined in the model file then it is not necessary to use this parameter (though it may be used to override).

Offset XYZ

Offset to submodel X, Y and Z coordinates, within the model.

Transparent

Translucency of the sub-model: 0=opaque, 1=transparent. The level of translucency defined here is not used with df_shadow1/2 or df_brightshadow. However, with df_brightshadow2, this is applied to the sub-model.

Shiny skin

Shiny

Shiny color

Selskin mask

df_selskin chooses the skin to use by looking at the high byte of the selector integer. The selskin mask specifies which bits of the selector special byte should be considered.

Selskin shift

After doing an AND operation with the selskin mask, the resulting value is shifted to the right this many bits. Negative values shift to the left.

Selskins

At most 8 skin numbers for use with #selskin. After the special byte is AND'd with the selskin mask and shifted, the result is an index to this list. If the df_selskin flag is set for the model, the skins in this list are used.

Parm

Custom parameter. (presently unused)