BCO (File Format)

From Wexos's Wiki
Revision as of 17:01, 1 May 2024 by Wexos (talk | contribs) (Imported from avsys wiki)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigationJump to search

BCO is a collision file format used in Mario Kart Double Dash!!.

File Format

Header

The format begins with the following header:

Offset Type Description
0x00 Char[4] File identifier. Always 0003 in ASCII.
0x04 UInt16[2] Number of root quadtree nodes.
0x08 Int32[2] Quadtree origin.
0x10 Int32[2] Quadtree node size.
0x18 UInt16 Number of collision attributes.
0x1A UInt16 Unknown. Only seen as 0.
0x1C UInt32 Triangle index array offset.
0x20 UInt32 Triangle array offset.
0x24 UInt32 Position array offset. Stores the positions of the triangles. Each position consists of three floats.
0x28 UInt32 Collision attribute array offset.

Quadtree

The quadtree is stored directly after the header. Triangles are organized in a quadtree. Each node in the quadtree is either a leaf or an internal nodes. A leaf points to triangles and internal nodes points to 4 sub nodes.

The game's collision works in 2D, which is why a quadtree is used and not an octree. The order which the triangles are sort is important, because the first triangles a kart hits is the one which is collided. Therefore the highest triangle center should be stored first.

Each quadtree node has the following structure:

Offset Type Description
0x00 Byte Number of triangles.
0x01 Byte Unknown. Only seen as 0.
0x02 UInt16 Index of first child node.
0x04 UInt32 Triangle array index.

Triangle

Each triangle has the following structure:

Offset Type Description
0x00 Int32[3] Position indices. Links to the three positions of the triangle.
0x0C Float Negative dot product between triangle center and triangle normal. Unknown usage.
0x10 Int16[3] Triangle normal. Base 10 fixed-point number with scale 10 000.
0x16 UInt16 Collision attribute. Stores the collision type.
0x18 Byte Min max look up.
0x19 Byte Unknown.
0x1A UInt16[3] Triangle neighbor indices. Stores triangle indices for neighbors for edge AB, BC respectively CA. 0xFFFF means no neighbor triangle.
0x20 UInt16 Unknown.
0x22 Byte Splash object index. Unknown if there are more usages for it.
0x23 Byte Enables splash. Unknown if there are more usages for it.
Collision attributes

A collision attribute is a 16-bit number which specifies how entities interact when colliding. The number consists of two bytes. The high byte represents the basic type, and the low byte represent the variant. The basic types are shown below:

Attribute Name Description
0x00 DIRT Off-road.
0x01 ROAD Road.
0x02 WALL Wall.
0x03 GRASS ?
0x04 ICE ?
0x05 RESQ ?
0x06 SLIP ?
0x07 DASHJ ?
0x08 DASHB ?
0x09 CANNON ?
0x0A VALLEY Fall boundary.
0x0B ? ?
0x0C ? ?
0x0D ? ?
0x0E RESQD ?
0x0F RESQS Lava/Water
0x10 ? ?
0x11 BEACH ?
0x12 OUTF ?
0x13 ? Heavy off-road.
0xFF NONE ?

Collision Attribute

The collision attribute structure stores more information about each collision attribute used in triangles. Each entry has the following structure:

Offset Type Description
0x00 UInt16 Collision attribute.
0x02 UInt16 Unknown.
0x04 UInt32 Unknown.
0x08 UInt32 Unknown.

Tools

The following tools can handle BCO files: