Introduction
MD2 is the model format of Quake II, released by id Software in 1997. Like the Quake MDL before it, it animates a model by storing every vertex position for every frame, and the engine blends between frames. Skins became separate image files, and the vertices are packed into single bytes per coordinate to keep files small.
The Quake II source code was released under the GPL in 2001. MD2 was popular with modders and in later engines and tutorials, and was followed by MD3 in Quake III Arena.
Structure
An MD2 file is binary and little-endian. The 68-byte header starts with
IDP2 and version 8, then gives the skin size, the size of one frame, the
counts of skins, vertices, texture coordinates, triangles, OpenGL commands and frames,
and the offset of each list.
Skins are 64-character paths to image files. Texture coordinates are pairs of 16-bit
integers in pixels. Each triangle names three vertices and three texture coordinates.
Each frame has a scale and a translation, a 16-character name such as
run1, and then every vertex as three bytes, which the scale and
translation turn back into positions, plus one byte choosing a normal from a fixed
table of 162 directions. The OpenGL commands list triangle strips and fans for fast
drawing.
0HeaderIDP2, version 8, sizes, counts, offsets68 bytes…Skins image paths64 bytes each…Texture coordinates s and t4 bytes each…Triangles vertex and texture coordinate indices12 bytes each…Frames scale, translation, name, packed verticesframe size each…OpenGL commands strips and fansvaries
Links
Software
- Yamagi Quake II (Windows, macOS, Linux)
Developers
- Quake II source code, id Software’s C engine code under the GPL, including the MD2 loader
- Assimp, C++ library that imports dozens of 3D formats, MD2 among them