CMDL (Tropical Freeze)

See CMDL (File Format) for the other revisions of this format.

The CMDL, SMDL, and WMDL format are Tropical Freeze's three model formats; CMDL is a generic model format, SMDL is for skinned models, and WMDL is for world (terrain) models. All three are the same basic format, with SMDL and WMDL each containing an extra data section at the start of the file. With the Wii U's graphics system being updated from GX to GX2, the Retro model format has been dramatically overhauled, bearing little to no resemblance to the previous CMDL format found in DKCR and the Prime series.

Format
After the RFRM Header, the first section of the file is SKHD in SMDL, and WDHD in WMDL. Following those extra sections, all three formats start with a header.

HEAD
If the ending flag is 1, then a large chunk of extra data follows before the next section begins; otherwise, the HEAD section ends.

MTRL
Materials. To do.

MESH
The MESH section does what the name suggests: it defines submeshes. The MESH section header is as follows:

Each submesh definition is structured as follows:

VBUF
The VBUF section defines vertex buffers; each buffer can have different vertex types, with different strides and attributes.

IBUF
Just like how the VBUF section defines vertex buffers, the IBUF section defines index buffers. Each index buffer only has one value associated with it, so it's fairly simple, and you generally will only see one or two index buffers per file.

GPU
The GPU section contains raw buffer data that's fed to the GPU. It's essentially just a giant blob with all the vertex and index buffers laid out next to each other. The tricky part is, all the buffer data is LZSS-compressed, and the metadata needed to decompress it is stored in the pak rather than in the files themselves; not only that, but that metadata is also the only way to distinguish the different buffers from each other.

As such, this section can't be read correctly if the model file is unpacked and completely left as-is; it needs to be either read directly from the pak, or the metadata needs to be added to the file in some way. A good unpacker should append the metadata to the end of the file; a pre-decompressed file needs the buffer sizes or offsets inserted into the file data somewhere.

PAK Metadata
The pak metadata for the model formats contains mainly information related to the size and layout of the GPU section, and the metadata required to locate and decompress specific buffers within it.

GPU Chunk
For large models, the GPU section might be split up into multiple chunks, rather than read as one data buffer; all offsets into the GPU section will be relative to the start of the chosen chunk.

Compressed Buffer
The format for compressed buffer definitions is the same regardless of buffer type (vertex/index).