CMB (File Format)

From Wexos's Wiki
Jump to navigationJump to search
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:
  • 0x2600 = GL_NEAREST
  • 0x2601 = GL_LINEAR
  • 0x2700 = GL_NEAREST_MIPMAP_NEAREST
  • 0x2701 = GL_LINEAR_MIPMAP_NEAREST
  • 0x2702 = GL_NEAREST_MIPMAP_LINEAR
  • 0x2703 = GL_LINEAR_MIPMAP_LINEAR
  • 0x8146 = GL_FILTER4_SGIS
  • 0x8170 = GL_LINEAR_CLIPMAP_LINEAR_SGIX
  • 0x8184 = GL_PIXEL_TEX_GEN_Q_CEILING_SGIX
  • 0x8185 = GL_PIXEL_TEX_GEN_Q_ROUND_SGIX
  • 0x8186 = GL_PIXEL_TEX_GEN_Q_FLOOR_SGIX
  • 0x848D = GL_NEAREST_CLIPMAP_NEAREST_SGIX
  • 0x844E = GL_NEAREST_CLIPMAP_LINEAR_SGIX
  • 0x844F = GL_LINEAR_CLIPMAP_NEAREST_SGIX
0x16 UInt16 Texture MagFilter:
  • 0x2600 = GL_NEAREST
  • 0x2601 = GL_LINEAR
  • 0x8097 = GL_LINEAR_DETAIL_SGIS
  • 0x8098 = GL_LINEAR_DETAIL_ALPHA_SGIS
  • 0x8099 = GL_LINEAR_DETAIL_COLOR_SGIS
  • 0x80AD = GL_LINEAR_SHARPEN_SGIS
  • 0x80AE = GL_LINEAR_SHARPEN_ALPHA_SGIS
  • 0x80AF = GL_LINEAR_SHARPEN_COLOR_SGIS
  • 0x8146 = GL_FILTER4_SGIS
  • 0x8184 = GL_PIXEL_TEX_GEN_Q_CEILING_SGIX
  • 0x8185 = GL_PIXEL_TEX_GEN_Q_ROUND_SGIX
  • 0x8186 = GL_PIXEL_TEX_GEN_Q_FLOOR_SGIX
0x18 UInt16[2] Texture Wrap Mode:
  • 0x2900 = GL_CLAMP
  • 0x2901 = GL_REPEAT
  • 0x812D = GL_CLAMP_TO_BORDER
  • 0x812F = GL_CLAMP_TO_EDGE
  • 0x8370 = GL_MIRRORED_REPEAT
0x1C Byte[12] Unknown.

Texture Combiner

Tools

The following tools can handle CMB files: