MDB Format - KCreator/Earth-Defence-Force-Documentation GitHub Wiki
All offsets are relative to the beginning of their table entries.
Since the header is always at the beginning of the file, the offsets there are also absolute file offsets.
File format largely derived from EDF5, and EDF6. EDF4.1 might have unknown differences.
Header: 48 (0x30) bytes
Offset | Size | Description |
---|---|---|
0x00 | 4 | Always 'MDB0' |
0x04 | 4 | version 0x14 for EDF5, 0x20 for EDF6 |
0x08 | 4 | Name table count |
0x0C | 4 | Name table offset (Always 0x30) |
0x10 | 4 | Bone count |
0x14 | 4 | Bone offset |
0x18 | 4 | Object count |
0x1C | 4 | Object offset |
0x20 | 4 | Material count |
0x24 | 4 | Material offset |
0x28 | 4 | Texture count |
0x2C | 4 | Texture offset |
Name table:
Offset | Size | Description |
---|---|---|
0x00 | 4 | String offset (Offset, UTF-16) |
Bone table: 192 (0xC0) bytes
Offset | Size | Description |
---|---|---|
0x00 | 4 | Bone index |
0x04 | 4 | Bone parent (-1 for no parent) |
0x08 | 4 | Bone Next Sibling (-1 for none) |
0x0C | 4 | Bone First Child (-1 for none) |
0x10 | 4 | Bone name (Name table index) |
0x14 | 4 | Child Bone Count |
0x18 | 1 | Unknown Byte, possibly control groups (0=None, 1=??? 2=EmptyBones 3=SkinnedBones)? |
0x19 | 1 | Unknown Byte, Values below 10, and 250-255 (2=Camera aim?, 4=Aim point?)? |
0x1A | 1 | Has Bounding Box (value == 1). True when 0xA0 and 0xB0 contain bounding box data. |
0x1B | 5 | Always zero (Alignment padding to 8 bytes) |
0x20 | 64 (0x40) | Local transformation matrix 4x4. Position, Rotation, and Scale for bones in parent context |
0x60 | 64 (0x40) | Inverse Bind Pose Matrix. Used for GPU calculations regarding this bone |
Note: Matrices are Y-UP for default world orientation | ||
0xA0 | 16 (0x10) | float4, Mesh Bounding Box Size (W is always 1) |
0xB0 | 16 (0x10) | float4, Mesh Bounding Box Offset (W is always 1) |
Note: Box is "child" of this bone. It inherits rotation/position! Bounds are determined by weight painted meshes vertices on normal models. However on UI elements there are objects with bounding box, but no weight paint. Current assumption is that if there is a Mesh with the same name as the Bone, it will create a bounding box for that entire mesh. |
Texture table: 16 (0x10) bytes
Offset | Size | Description |
---|---|---|
0x0 | 4 | Texture index |
0x4 | 4 | Texture name (Offset, UTF-16) |
0x8 | 4 | Texture filename (Offset, UTF-16) |
0xC | 4 | Always zero |
Material table: 32 (0x20) bytes
Offset | Size | Description |
---|---|---|
0x00 | 2 | Index |
0x02 | 1 | Render Priority (Usually 0, often higher on transparent objects) |
0x03 | 1 | Render Layer (Normally 0, 1 on Loading screen and tank_catapi, 2 on transparent materials and UI) |
0x04 | 4 | Material name (Name table index) |
0x08 | 4 | Shader (Offset, UTF-16) |
0x0C | 4 | Material Parameters offset |
0x10 | 4 | Material Parameters count |
0x14 | 4 | Material Textures offset |
0x18 | 4 | Material Textures count |
0x1C | 4 | Render Type? (Normally 3, 2 was seen for UI elements and Barrier objects, 2 implies updating texture cont?) |
Material Parameters: 32 (0x20) bytes
Offset | Size | Description |
---|---|---|
0x00 | 4 | Value 1 |
0x04 | 4 | Value 2 |
0x08 | 4 | Value 3 |
0x0C | 4 | Value 4 |
0x10 | 4 | Value 5 (Unused) |
0x14 | 4 | Value 6 (Unused) |
Note: Some values above are sometimes defined (non 0), but unused due to Type. | ||
0x18 | 4 | String (Offset, ASCII) |
0x1C | 1 | Type (0=Float, 1=Vector2, 2=RGB, 3=RGBA) |
0x1D | 1 | Size (Amount of Values used) |
0x1E | 2 | Padding 0's |
Material Textures: 28 (0x1C) bytes
Offset | Size | Description |
---|---|---|
0x00 | 4 | Texture (Texture index) |
0x04 | 4 | Type (Offset, ASCII) |
0x08 | 4 | Unknown (Always 0, 4 on only Regular Hornet) |
0x0C | 4 | Always zero (Unused) |
0x10 | 4 | Always zero (Unused) |
0x14 | 4 | Always zero (Unused) |
0x18 | 4 | Unknown (Always 0.0 or -1.0 on only Regular Hornet) |
Object table: 16 (0x10) bytes
Offset | Size | Description |
---|---|---|
0x00 | 4 | Object index |
0x04 | 4 | Name (Name table index) |
0x08 | 4 | Mesh count |
0x0C | 4 | Mesh info (Offset) |
Mesh info: 40 (0x28) bytes
Offset | Size | Description |
---|---|---|
0x00 | 1 | Unknown bool (value != 0, always zero) |
0x01 | 1 | Boolean, is skinned mesh (value == 1) |
0x02 | 1 | Number of bones per vertex, from 0 to 4 |
0x03 | 1 | Always zero (Unused, alignment) |
0x04 | 4 | Material Index (-1 for None?) |
0x08 | 4 | Always zero |
0x0C | 4 | Vertex layout info (Offset) |
0x10 | 2 | Total Layout Size (bytes for 1 vertex's data block) |
0x12 | 2 | Layout count |
0x14 | 4 | Number of vertices |
0x18 | 4 | Mesh index |
0x1C | 4 | Vertex data (Offset) |
0x20 | 4 | Number of indices |
0x24 | 4 | Indice data (Offset) |
Vertex layout info: 16 (0x10) bytes
Offset | Size | Description |
---|---|---|
0x00 | 4 | Type |
0x04 | 4 | Offset in vertex data |
0x08 | 4 | Channel (Indicates texcoord0 vs texcoord1) |
0x0C | 4 | Name (Offset, ASCII) |
Vertex types:
Type | Description |
---|---|
1 | float4 (16 bytes) |
4 | float3 (12 bytes) |
7 | half4 (8 bytes) |
12 | float2 (8 bytes) |
21 | ubyte4 (4 bytes) |
Indice data: 2 bytes
Offset | Size | Description |
---|---|---|
0x00 | 2 | Vertex index, it is an unsigned value |
Vertex data: Variable length
Offset | Size | Description |
---|---|---|
0x00 | Mesh - Total Layout Size | Format and size of data depends on layout info |
- | - | Data is stored per vertex, data format and order is in order of Layout Info. |
Strings: Variable length
Offset | Size | Description |
---|---|---|
0x00 | ? | Variable length ASCII strings followed by UTF-16 strings |