From CloudModding TWW Wiki

DZB is used as the collision format in The Legend of Zelda: The Wind Waker. It was first introduced in The Legend of Zelda: The Wind Waker, and was mostly replaced by The Legend of Zelda: Twilight Princess, where it was only used for object collision, rather than scene collision.

The format contains no specific MAGIC, so its extension, ".dzb," is used to refer to it instead. DZB utilizes an embedded octree to accelerate collision detection by the engine and increase collision resolution.

File Header

The header of the DZB format lays out the offset of each section and the number of entries each of them has.

Size: 0x34 bytes.

Offset Size Name Description
0x00
4
Vertices Count
0x04
4
Vertices Offset
0x08
4
Triangles Count
0x0C
4
Triangles Offset
0x10
4
Blocks Count
0x14
4
Blocks Offset
0x18
4
Tree Nodes Count
0x1C
4
Tree Nodes Offset
0x20
4
Groups Count
0x24
4
Groups Offset
0x28
4
Properties Count
0x2C
4
Properties Offset
0x30
4
Padding Always 0.

Vertices

Vertices are stored as regular floating point singles.

Size: 0xC bytes.

Offset Size Name Description
0x00
4
X Pos Floating point X position.
0x04
4
Y Pos Floating point Y position.
0x08
4
Z Pos Floating point Z position.

Triangles

Triangles are made up of 3 indexes into the vertex section, in addition to indexes for the group they belong to and the property they use.

Size: 0xA bytes.

Offset Size Name Description
0x00
2
Vertex 1 Index
0x02
2
Vertex 2 Index
0x04
2
Vertex 3 Index
0x06
2
Property Index
0x08
2
Group Index

Octree

In order to speed up collision detection, DZB uses an octree to partition parts of the mesh into separate spaces. It is split between two sections: the node tree, and blocks.

Node Tree

The node tree is made up of branch and leaf nodes. Each group in the file that actually has collision assigned to it contains the index of the group's root node.

Nodes have two forms, which are differentiated by the Flags field. Branch nodes have 8 sub-children. There is no required spatial ordering to the children blocks, as best I can tell. The code checks the children in a strange order (2 3 6 7 0 1 4 5), implying this is not just an array of children, but the checks for each of the children are the exact same.

Leaf nodes contain an index into the Blocks section.

Size: 0x14 bytes.

Offset Size Name Description
0x00
2
Flags Low bit is set if a leaf node, otherwise it is a branch node. All other fields are ignored.
0x02
2
Parent Node Index
0x04
2
Octant 1 Branch Index If this is a leaf node, this field instead contains an index into the Blocks section. All other fields after this would be filled with 0xFF.
0x06
2
Octant 2 Branch Index
0x08
2
Octant 3 Branch Index
0x0A
2
Octant 4 Branch Index
0x0C
2
Octant 5 Branch Index
0x0E
2
Octant 6 Branch Index
0x10
2
Octant 7 Branch Index
0x12
2
Octant 8 Branch Index

Blocks

A block defines a series of triangles. The first triangle in the block is specified by the corresponding index, and contains every triangle up until the next block (or the end of the triangles array if there is no next block).

The original game's code categorizes triangles into one of three separate categories: "roof", "wall", and "ground" depending on the normal of the plane, building three separate linked lists for a block, speeding up acceleration even further.

Size: 2 bytes.

Offset Size Name Description
0x00
2
Starting Triangle Index

Groups

Groups form a hierarchy that appears derived from the original structure of the model in Maya. Only the lowest groups in the hierarchy have geometry data attached to them.

In addition to the hierarchy, groups have the ability to transform, scale, and rotate their geometry, though these are rarely used in practice. Confoundingly, groups contain the only indicator of whether geometry is solid, water, or lava.

Size: 0x34 bytes.

Offset Size Name Description
0x00
4
Name Offset
0x04
4
X Scale Floating point X scale.
0x08
4
Y Scale Floating point Y scale.
0x0C
4
Z Scale Floating point Z scale.
0x10
2
X Rotation
0x12
2
Y Rotation
0x14
2
Z Rotation
0x16
2
Unknown 1 Usually 0xFFFF, but sometimes 0xDCDC.
0x18
4
X Translation Floating point X translation.
0x1C
4
Y Translation Floating point Y translation.
0x20
4
Z Translation Floating point Z translation.
0x24
2
Parent Group Index
0x26
2
Next Sibling Group Index
0x28
2
First Child Group Index
0x2A
2
Room Index Index of the room this group belongs to.
0x2C
2
First Vertex Index The lowest vertex index that belongs to this group. For groups with no faces, this is 0 instead. This field does not seem to be read or have any effect.
0x2E
2
Octree Root Node Index
0x30
4
Bitfield See below

Bitfield

Mask Field Name Description
0x000000FF RTBL Index The room table index to use when the player is above a triangle in this group. This property allows a single room to load different rooms depending on where the player is physically located in it. For instance, room 0 of the sea uses this to load the correct island room for each sector, and the hub room in DRC uses this to determine if you're in the upper level of the hub or the lower level.
0x00000100 Is Water
0x00000200 Is Lava
0x00000400 Unused 1
0x0007F800 Sea Floor Audio Info Officially called "Sound ID", this value is used by the audio system to determine what music to play and what sound banks to load for each sector on the sea. It is 0 for groups that are not part of the sea floor. For groups that are part of the sea floor, bits & 0x3F are the room number this sea floor belongs to. If bit & 0x40 is set, it is the "Inner Sea" part of the sector's sea floor (the center, not near the edge of a sector). If bit & 0x80 is set, it is the "Outer Edge" part of the sector's sea floor (the outermost border of the sector). If neither bit & 0x40 nor bit & 0x80 are set, it is the "Inner Edge" part of the sector's sea floor (the thin border in between the "Inner Sea" and "Outer Edge" parts). Note that collision belonging to room 0 of the sea is slightly different - it is always considered to be part of the sea floor (specifically known as the "Outer Sea"), even if this value is 0.
0xFFF80000 Unused 2

Properties

These give the faces that reference them their attributes, such as whether they trigger an exit, what sound they make when items collide with them, and how Link will interact with them. Most of the data is compressed into 3 bit fields, but there is one int tacked onto the end.

Size: 0x10 bytes.

Offset Size Name Description
0x00
4
Bitfield 1 See below
0x04
4
Bitfield 2 See below
0x08
4
Bitfield 3 See below
0x0C
4
Bitfield 4 See below

Bitfield 1

Mask Field Name Description
0x000000FF Cam ID  ?
0x00001F00 Sound ID Sets the sound that plays when Link interacts with the face.
0x0007E000 Exit ID If this is not 0x3F, then the face triggers the exit with this index. Otherwise, the face does nothing.
0x07F80000 PolyColor  ?
0x08000000 Disable Shadows Prevents actor shadows from being drawn on this surface. (Only real shadows, does not disable drop shadows.)


Bitfield 2

Mask Field Name Description
0x000000FF LinkNo  ?
0x00000F00 Wall Code Sets the wall type, such as climable like a ladder or grabable like a block.
0x0000F000 Special Code  ?
0x001F0000 Attribute Code Direct  ?
0x03E00000 Ground Code Sets the terrain type, such as sloped or slippery.

Bitfield 3

Mask Field Name Description
0x000000FF Cam Move BG  ?
0x0000FF00 Room Cam ID  ?
0x00FF0000 Room Path ID  ?
0xFF000000 Room Path Pnt No  ?

Bitfield 4

Mask Field Name Description
0x00000001 Pass 1 Camera Allows the camera to pass through this surface.
0x00000002 Pass 0 Normal Allows most objects to pass through this surface.
0x00000004 Pass 2 Link Allows Link to pass through this surface.
0x00000008 Pass 3 Arrows and Light Allows arrows and reflected rays of light to pass through this surface. Also prevents actor shadows from being drawn on this surface. (Only real shadows, does not disable drop shadows.)
0x00000010 Hookshottable Allows the hookshot to stick to this surface so the player can pull themself to it.
0x00000020 Pass 4 Bombs Allows bombs to pass through this surface.
0x00000040 Pass 5 Boomerang Allows the boomerang to pass through this surface.
0x00000080 Pass 6 Hookshot Allows the hookshot to pass through this surface.\n(Maybe also allows other things, such as Link's line-of-sight, to pass through...?)