Conitec 3d gamestudio a4 programmer 매뉴얼
A4 Programmer’s Manual © Conitec 2000 10
The MDL model format
A wireframe mesh, made of triangles, gives the general shape of a model. 3D vertices define the
position of triangles. For each triangle in the wireframe, there will be a corresponding triangle cut
from the skin picture. Or, in other words, for each 3D vertex of a triangle that describes a XYZ
position, there will be a corresponding 2D vertex positioned that describes a UV position on the
skin picture.
It is not necessary that the triangle in 3D space and the triangle on the skin have the same shape (in
fact, it is not possible for all triangles), but they should have shapes roughly similar, to limit
distortion and aliasing. Several animation frames of a model are just several sets of 3D vertex
positions. The 2D vertex positions always remain the same.
A MDL file contains:
- A list of skin textures in 8-bit palettized or 16-bit 5-6-5 format.
- A list of skin vertices, that are just the UV position of vertices on the skin texture.
- A list of triangles, which describe the general shape of the model.
- A list of animation frames. Each frame holds a list of 3D vertices.
- A list of bone vertices, which are used for creating the animation frames.
MDL file header
Once the file header is read, all the other model parts can be found just by calculating their position
in the file. Here is the format of the .MDL file header:
typedef float vec3[3];
typedef struct {
char version[4]; // "MDL3" or "MDL4"
long final; // not used yet
vec3 scale; // 3D position scale factors.
vec3 offset; // 3D position offset.
float pad; // not used yet.
vec3 eye; // not used yet.
long numskins ; // number of skin textures
long skinwidth; // width of skin texture; must be a multiple of 2
long skinheight; // height of skin texture
long numverts; // number of 3d wireframe vertices
long numtris; // number of triangles surfaces
long numframes; // number of frames
long numskinverts; // number of 2D skin vertice
long flags; // 0 = normal, 1 = terrain model
long numbones; // number of bone vertices (MDL4 only, otherwise 0)
} mdl_header;
typedef struct {
char version[4]; // "MDL3" or "MDL4"
long final; // not used yet
vec3 scale; // 3D position scale factors.
vec3 offset; // 3D position offset.
float pad; // not used yet.
vec3 eye; // not used yet.
long numskins ; // number of skin textures
long skinwidth; // width of skin texture; must be a multiple of 2
long skinheight; // height of skin texture
long numverts; // number of 3d wireframe vertices
long numtris; // number of triangles surfaces
long numframes; // number of frames
long numskinverts; // number of 2D skin vertice
long flags; // 0 = normal, 1 = terrain model
long numbones; // number of bone vertices (MDL4 only, otherwise 0)
} mdl_header;
The size of this header is 0x54 bytes (84).
The "MDL3" format is used by the A4 engine, while the "MDL4" format is used by the A5 engine.
After the file header follow the skins, the skin vertices, the triangles, the frames, and finally the
bones (future expansion).