MDX (file format)
.MDX files are 3D model files engineered and used by Blizzard Entertainment in their games. Several variations exists but this document focuses on the format used in Warcraft 3 and Frozen Throne. The format actually comes in two flavors, .MDX and .MDL. .MDX is a binary format. It's harder to edit but has GeneRally smaller filesizes. .MDL is a text format which allows you to edit the models with just a text editor. The text formatting increases the filesize drastically though. Several converters exists to quickly convert between these formats.
Converters
This is a list of known converters to convert to and from the MDX format.
- MDLX Converter - Converts between MDL, MDX
- War3ModelEditor - Converts between MDL, MDX, converts from MD2, MS3D
- Yobguls File Converter - Converts between MDL, MDX
Editors
This is a list of known editors for manipulating the MDX files.
- Warcraft III Art Tools - Requires 3DSMax4 or 3DSMax5
- War3ModelEditor
- Oinkerwinkles Tools
Code syntax
All code samples below will be given in a C/C++ like pseudo-code. To simplify syntax and readability some have been split into substructures. The following notations are used to describe this.
- X - A structure X that must be present and in the given order
- {X} - A structure X that may or may not be present. They may also be in a different order.
A few special fields exists which has specific meanings.
- ChunkSize - The size of the chunk (see General structure below)
- InclusiveSize - The size of the structure including the size of this variable
- ExclusiveSize - The size of the structure NOT including the size of this variable
Other notations.
- #X - A flag value. Multiple flags can be combined in a single variable.
Datatypes
In the code below various datatypes are used. This is a table describing these datatypes.
- UINT8 - An 8-bit unsigned integer, little endian
- UINT16 - A 16-bit unsigned integer, little endian
- UINT32 - A 32-bit unsigned integer, little endian
- FLOAT - A 32-bit floating point number, IEEE single precision
- FLOAT[N] - A sequence of N 32-bit floating point numbers forming a vector
- STRING[N] - A sequence of N 8-bit characters forming a string
General structure
All models have a tree hiearchy of components, or chunks. Many components lie directly under the root while others are subcomponents. The contents vary from type to type though most of them have the same kind of header as shown below.
struct Chunk
{
UINT32 Tag;
UINT32 ChunkSize;
...
};
Each chunk begins with two 32-bit unsigned integers. The first is a tag describing the type. It's usually (always) constructed as a sequence of four 8-bit characters giving them a descriptive id if viewed in a hex editor (or even Notepad). The second integer tells the size of the chunk. This size does NOT include the tag and size itself, only the following contents. The ChunkSize is useful for determining the number of subcomponents, but if you're writing a non-complete MDX loader it's very useful for skipping whole chunks. Just read the tag and size then skip that many bytes to start reading the next chunk.
Some structures have ID's to reference other objects. These are 0-based indexes referencing the object in the order they appear in the file. The special value 0xFFFFFFFF (or -1 in signed format) represents "No ID", or in some cases "Many IDs". In the latter case the reference has to be made some other way, usually from the other object.