CMB (File Format)
From Wexos's Wiki
Under Construction
This article is not finished. Help improve it by adding accurate information or correcting grammar and spelling.
CMB (Citra Model Binary) is a file format used in Nintendo 3DS games such as The Legend of Zelda: Ocarina of Time 3D and The Legend of Zelda: Majora's Mask 3D, and they contain 3D model and texture information.
File Format
The file byte order is always little endian.
Header
The file starts with a header that is 0x20 bytes long.
Offset | Type | Description |
---|---|---|
0x00 | Char[4] | File magic. Always cmb in ASCII. |
0x04 | UInt32 | File size in bytes. |
0x08 | Int32 | Probably a version number. 0x6 for OoT3D and 0xA for MM3D. |
0x0C | Int32 | Unknown. Always 0. |
0x10 | String | Null-terminated string of the model name and padding. |
Section Data
Offset | Type | Description |
---|---|---|
0x00 | Int32 | Number of indices. |
0x04 | UInt32 | skl offset. |
If version = 0xA | ||
0x08 | UInt32 | qtrs offset. |
P = current position | ||
P | UInt32 | mats offset. |
P + 0x04 | UInt32 | tex offset. |
P + 0x08 | UInt32 | sklm offset. |
P + 0x0C | UInt32 | luts offset. |
P + 0x10 | UInt32 | vatr offset. |
P + 0x14 | UInt32 | Index Buffer offset. |
P + 0x18 | UInt32 | Texture Data offset. |
If version = 0xA | ||
P + 0x1C | UInt32 | Unknown. Always 0. Maybe padding? |
skl
The skl section contains skeleton information.
Header
Offset | Type | Description |
---|---|---|
0x00 | Char[4] | Section magic. Always skl in ASCII. |
0x04 | UInt32 | Section size in bytes. |
0x08 | Int32 | Number of bones. |
0x0C | Int32 | Unknown. |
Bone
Offset | Type | Description |
---|---|---|
0x00 | Int16 | Bone index. |
0x02 | Int16 | Parent bone index. -1 if none. |
0x04 | Float[3] | Bone scale. |
0x10 | Float[3] | Bone rotation. |
0x1C | Float[3] | Bone translation. |
If version = 0xA | ||
0x28 | UInt32 | Unknown. |
qtrs
The qtrs section contains quadtree information. It's only used on version 0xA.
Header
Offset | Type | Description |
---|---|---|
0x00 | Char[4] | Section magic. Always qtrs in ASCII. |
0x04 | UInt32 | Section size in bytes. |
0x08 | Int32 | Number of Bounding Boxes. |
0x0C | Int32 | Unknown. Always 0? |
0x10 | Int32 | Unknown. Always 0? |
Bounding Box
Offset | Type | Description |
---|---|---|
0x00 | Float[3] | Minimum box position. |
0x0C | Float[3] | Maximum box position. |
0x18 | Int32 | Unknown. Usually -1. |
0x1C | Int32 | Unknown. Usually -1. |
0x20 | UInt32 | Unknown. Always 0. Maybe padding? |
mats
The mats section contains material information.
Header
Offset | Type | Description |
---|---|---|
0x00 | Char[4] | Section magic. Always mats in ASCII. |
0x04 | UInt32 | Unknown. Seems to be a size value, but it does not match with the section's size. |
0x08 | Int32 | Number of Materials. |
Material
Each material has a header, 3 Texture Sampler sections, .
Header
Offset | Type | Description |
---|---|---|
0x00 | Byte[8] | Unknown flags. |
0x08 | Int32 | Unknown. |
0x0C | Int32 | Unknown. |
Texture Sampler
Offset | Type | Description |
---|---|---|
0x10 | Int16 | Texture ID. -1 if none. |
0x12 | Int16 | Unknown. |
0x14 | UInt16 | Texture MinFilter:
|
0x16 | UInt16 | Texture MagFilter:
|
0x18 | UInt16[2] | Texture Wrap Mode:
|
0x1C | Byte[12] | Unknown. |
Texture Combiner
Tools
The following tools can handle CMB files:
- N3DSCmbViewer, by xdanieldzd.