BMD and BDL (File Format)

From Custom Mario Kart
Jump to navigation Jump to search
Under Construction
This article is not finished. Help improve it by adding accurate information or correcting grammar and spelling.
This article is about the file format used in GameCube and Wii games. For other uses of the same name, see BMD.

BMD and BDL are two file formats used by a wide variety of Nintendo games between the GameCube and Wii.

File Header

The file begins with the header of 0x10 bytes. BDL Includes an extra section (MDL3) that BMD does not. The structure is the same as for BCK & JPA files (All lengths are in hexadecimal):

Offset Size Description
0x00 8 File identifier: 'J3D2bmd3' for BMD and 'J3D2bdl4' for BDL in ASCII.
0x08 4 Length of file in bytes.
0x0c 4 Number of sections in the file (08 in BMD & 09 in BDL)
0x10 4 'SVR3' in ASCII.
0x14 0C Consists only of FF (Padding?)
End of header

Sections

BMD and BDL contain mostly the same sections, with the exception of the MDL3 section that appears only within BDL files.

INF1

The INF1 section contains Model Information.

Offset Size Description
0x00 4 Section name: 'INF1' in ASCII.
0x04 4 Length of section in bytes.
0x08 2 Unknown model setting (very similar to MDL0), 01 for BMD & 00 for BDL.
0x0A 2 Padding. Always FF FF.
0x0C 4 Number of packets across all batches in the file.
0x10 4 Number of coordinates in VTX1 section.
0x14 4 Offset location relative to beginning of section (After the length of section, typically location 0x18).
0x18 (O = The offset) 2 Unknown setting (Always 00 10).

The next part of the INF1 section describes the scene graph of the file, it controls what references what. It starts immediately after 0x18 in the INF1 section. There can be many of these and they go in order:

Offset Size Description
0x00 + O 2 Node type. 0x00 to end the scene graph. 0x01 for an open child node. 0x02 for a closed child node. 0x10 for a joint. 0x11 for a material. 0x12 for a shape.
0x02 + O (O2 = This Offset) 2 Unknown.

The end of this section:

Offset Size Description
0x00 + O2 O2 - Start of VTX1 Section Attempts to spell '......This is padding data to align' until the beginning of the VTX1 section in ASCII.
End of INF1 Section

VTX1

The VTX1 sections stores the vertex arrays for positions, colors, normals and texture coordinates. Additionally, it stores the data format in which these arrays are stored.

Offset Size Description
0x00 4 Section name: 'VTX1' in ASCII.
0x04 4 Size of section in bytes.
0x08 4 Offset location of the array data.
0x0C 4 Offset of position data, relative to the start of the 'VTX1' section (always 0A if VTX1 section begins 0xFF).
0x10 4 Offset of normal data, relative to the start of the 'VTX1' section.
0x14 4 Offset of ??? data, relative to the start of the 'VTX1' section.
0x18 4 Offset of color0 data, relative to the start of the 'VTX1' section.
0x1C 4 Offset of ??? data, relative to the start of the 'VTX1' section.
0x20 4 Offset of tex0 data, relative to the start of the 'VTX1' section.
0x24 4 Offset of tex1 data, relative to the start of the 'VTX1' section.
0x28 4 Offset of tex2 data, relative to the start of the 'VTX1' section.
0x2C 4 Offset of tex3 data, relative to the start of the 'VTX1' section.
0x30 4 Offset of ??? data, relative to the start of the 'VTX1' section.
0x34 4 Offset of ??? data, relative to the start of the 'VTX1' section.
0x38 4 Offset of ??? data, relative to the start of the 'VTX1' section.
0x3C 4 Offset of ??? data, relative to the start of the 'VTX1' section.
End of section header, beginning of array format

The next section of the VTX1 section describes the array format, this section can be used many times.

Offset Size Description
0x00 4 ArrayType. (See VTX1 Array Types, the last array always seems to have 0x000000ff here)
0x04 4 ComponentCount. Effects DataType, 00 = Component Type 1, 01 = Component Type 2
0x08 4 DataType. (See VTX1 Component Types)
0x0C 1 Position of decimal point, has only been seen to be 00, 07, 08, 0b & 0e.
0x0D 3 Padding. Always FF FF FF.
End of array format

If there are five arrays or less, this will appear directly after the last array, but if it exceeds five, then it will not:

Size Description
0A Spells 'This is padding ' in ASCII

From here the VTX1 sections stores vertex data, until the beginning of the next section.

EVP1

This section is what contains the weight data for vertex skinning.

Offset Size Description
0x00 4 Section name: 'EVP1' in ASCII.
0x04 4 Size of section in bytes.
0x08 2 What it should count (See EVP1 Count Index
0x0A 2 Padding (FF)

JNT1

The JNT1 section contains joint information.

Offset Size Description
0x00 4 Section name: 'JNT1' in ASCII.
0x04 4 Size of section in bytes.
0x06 2 Number of joints.
0x08 2 Padding (FF)
0x0C 4 Offset to joint data.
0x10 4 Offset to joint remap data.
0x14 4 Offset to the string table.

Joint Data

Offset Size Description
0x00 2 Unknown.
0x02 1 If 1, this joint does not inherit its parent joint's scale. If 0, it does.
0x03 1 Padding (FF)
0x04 4 Scale X.
0x08 4 Scale Y.
0x0C 4 Scale Z.
0x10 2 Rotation X.
0x12 2 Rotation Y.
0x16 2 Rotation Z.
0x18 2 Padding. Always FF FF.
0x1C 4 Scale X.
0x20 4 Scale Y.
0x24 4 Scale Z.
0X28 4 Bounding sphere diameter.
0X2C 4 Bounding box min X.
0X30 4 Bounding box min Y.
0X34 4 Bounding box min Z.
0X38 4 Bounding box max X.
0X3C 4 Bounding box max Y.
0X40 4 Bounding box max Z.

Remap Data

Offset Size Description
0x00 2 Unknown.

String Table

Offset Size Description
0x00 2 Number of strings in the table.
0x02 2 Padding. Always FF FF.

Data for each string.

Offset Size Description
0x00 2 String hash.
0x02 2 String offset.

The data is followed by the strings, separated by 00.

Format Values

Here are specific values and their meanings are listed for various sections.

VTX1

Known values for VTX1.

ArrayType

Value Reference Description
0x00 'POSITION_MATRIX_INDEX'
0x01 'TEX0_MATRIX_INDEX'
0x02 'TEX1_MATRIX_INDEX'
0x03 'TEX2_MATRIX_INDEX'
0x04 'TEX3_MATRIX_INDEX'
0x05 'TEX4_MATRIX_INDEX'
0x06 'TEX5_MATRIX_INDEX'
0x07 'TEX6_MATRIX_INDEX'
0x08 'TEX7_MATRIX_INDEX'
0x09 'POSITION' Texture position
0x0a 'NORMAL' This effects the direction of the normals
0x0b 'COLOR0' Vertex Color Channel 1
0x0c 'COLOR1' Vertex Color Channel 2
0x0d 'TEX0'
0x0e 'TEX1'
0x0f 'TEX2'
0x10 'TEX3'
0x11 'TEX4'
0x12 'TEX5'
0x13 'TEX6'
0x14 'TEX7'
0x15 'POSITION_MATRIX_ARRAY'
0x16 'NORMAL_MATRIX_ARRAY'
0x17 'TEXTURE_MATRIX_ARRAY'
0x18 'LIT_MATRIX_ARRAY'
0x19 'NORMAL_BINORMAL_TANGENT'
0x1a 'MAX_ATTR'
0xff 'NULL_ATTR'

CompType

Type 1

This may be used in DataType if ComponentType is set to 00:

Value Reference Description
0x00 'U8'
0x01 'S8'
0x02 'U16'
0x03 'S16'
0x04 'F32'
Type 2

This may be used in DataType if ComponentType is set to 01:

Value Reference Description
0x00 'RGB565'
0x01 'RGB8'
0x02 'RGBX8'
0x03 'RGBA4'
0x04 'RGBA6'
0x05 'RGBA8'

EVP1

Known values for EVP1.

Count

Value Description
0x00 Counts each bone
0x01
0x02
0x01

Tools

The following tools can handle BMD and BDL files: