From 3DGE Wiki
Jump to: navigation, search

The MD2 model file format was introduced by id Software when releasing Quake 2 in November 1997. It's a file format quite simple to use and understand. MD2 models' characteristics are these:

  • Model's geometric data (triangles);
  • Frame-by-frame animations;
  • Structured data for drawing the model using GL_TRIANGLE_FAN and GL_TRIANGLE_STRIP primitives (called “OpenGL commands”).
  • Model's texture is in a separate file. One MD2 model can have only one texture at the same time.

MD2 model file's extension is “md2”. A MD2 file is a binary file divided in two part: the header dans the data. The header contains all information needed to use and manipulate the data.


Here are some constant values defining maximal dimensions, so do not exceed these amounts, or 3DGE will fail to render the model:

  • Maximum number of triangles: 4096
  • Maximum number of vertices: 2048
  • Maximum number of texture coordinates: 2048
  • Maximum number of frames: 512
  • Maximum number of skins: 32
  • Number of precalculated normal vectors: 162

Use in 3DGE

Both ports can utilize MD2, but there are a few key additions that become helpful, as the engine supports higher-resolution/color textures,


EDGE, and by extension, 3DGE, can load MD2s from either a LUMP in the wadfile, or externally as a plain file. While Quake 2 imposes harsh limits on the format, 3DGE enhances it beyond what was normally capable:

  • Ability to use PNG, JPG, and TGA file formats for skins (original PCX is not supported)
  • Able to define up to 9 skins-per-model and switch them out on-the-fly through DDF
  • Able to use animations as either frame number or reference name, or both if desired
  • Can control the bias, aspect, scale, and placement of the model, both for environment and HUD (weapons)


While those features are handy, there are currently limitations of the format:

  • No linear interpolation implementation, so the "jelly-like" vertex animation carries over from Quake 2



Any state frame can specify a model by using the special '@123' or '@framename' syntax for the frame (instead of a letter). The number is the absolute frame number in the MD2 model, beginning at 1, or you can use the frame name.


STATES(IDLE)=TROO:@5:7:NORMAL:NOTHING; // the 5th frame

STATES(IDLE)=TROO:@run3:7:NORMAL:NOTHING; // frame called "run3"

The model itself must be stored in a wad, and the lump name is the sprite base ("TROO") plus "MD2" on the end --> "TROOMD2".


The skin of the model is the sprite base ("TROO") plus "SKN1" on the end --> "TROOSKN1". There should be a definition for it in IMAGES.DDF using the sprite namespace --> [spr:TROOSKN1].

Normal and specular maps can be applied to skins. The normal/spec map name id the sprite base ("TROO") plus "NRM" or "SPC" respectively on the end --> "TROONRM1" / "TROOSPC1".

Other skins can be used. The command "MODEL_SKIN=3" in a thing or weapon definition will use the third skin --> "TROOSKN3". Up to nine skins can currently be used (1 to 9). The skin can also be changed dynamically by using the SET_SKIN(##) action in the state frames.


Below describes the commands needed to manipulate and use the models in the game engine via DDF:


MODEL_SCALE Draw the model bigger, for example: MODEL_SCALE=1.5;
MODEL_ASPECT make the model fatter/skinnier: MODEL_ASPECT=0.7;
MODEL_BIAS add this to every z coordinate: MODEL_BIAS=24.0; Useful if you don't want to position from Quake 2's original 24 units in an external editor.


MODEL_ASPECT make the weapon fatter/skinnier
MODEL_BIAS add this to every z coordinate
MODEL_FORWARD move the weapon forward/backward: MODEL_FORWARD=2.2;
MODEL_SIDE move the weapon right/left: MODEL_SIDE=-3.5;
Note: there is no MODEL_SCALE command for WEAPONS.DDF (scaling has no effect because the model is drawn at the camera point). Changing MODEL_FORWARD, MODEL_SIDE and/or MODEL_BIAS can have a huge impact on the apparent size of the weapon.

Also see MD3 and MD5.