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.
This file format needs more research There's a lot of unknown data.
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.
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).
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.
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.
Format (1 means unsigned short; 2 means unsigned long)
0x4
End of index buffer
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.
Offset
Size
Description
0x0
4
Unknown; always 4?
0x4
4
GPU section offset
0x8
4
GPU chunk count (CC)
0xC
8 × CC
GPU chunk definitions
-
4
Compressed vertex buffer count (VC)
-
0x10 × VC
Vertex buffer definitions
-
4
Compressed index buffer count (IC)
-
0x10 × IC
Index buffer definitions
End of pak metadata
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.
Offset
Size
Description
0x0
4
Size
0x4
4
Offset
0x8
End of GPU chunk definition
Compressed Buffer
The format for compressed buffer definitions is the same regardless of buffer type (vertex/index).
Offset
Size
Description
0x0
4
GPU chunk index
0x4
4
Start offset (relative to the start of the chosen GPU chunk)