CMDL (Tropical Freeze)

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

Tropical Freeze features a new model format (necessitated by the hardware jump from Wii to Wii U) that bears little-to-no resemblance to the CMDL format of past games. There are three extensions used for models:


 * CMDL: Generic models
 * SMDL: Skinned models (ie. animated characters)
 * WMDL: World models (ie. level geometry)

All three share the same basic format, with SMDL and WMDL each containing an extra data chunk at the start of the file.

Format
File layout:

Render Octree
This seems to be an updated version of the AROT format seen in previous Retro games.

Material Data
The MTRL section has a 32-bit material count, then lays out its materials one after the other. Materials are composed of basically a MTRL asset ID which contains the shader the material is rendered with, then per-instance material parameters (textures, scalar/color parameters, etc).

Material Parameter
Each parameter has a fourCC parameter ID as well as a parameter type enum. There are five possible parameter types that each have a different layout in the file.

Render Meshes
The MESH section defines render meshes.

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

Index Buffers
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 (as there's only two possible index buffer configurations).

GPU Data
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.

Read Buffer Info
For large models, the GPU section may be split into multiple read buffers. All offsets into the GPU section will be relative to the beginning of the chosen buffer.

Buffer Info
This structure is used for both vertex and index buffers.