Area Collision (File Format): Difference between revisions
Jump to navigation
Jump to search
>Aruki (Created page with "The format for '''area collision''' stores the collision geometry for levels, and can be found in the MREA format. Most of it is shared with the DCLN...") |
>Aruki (→Format) |
||
(2 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
The format for '''area collision''' stores the collision geometry for levels, and can be found in the [[MREA (File Format)|MREA]] format. Most of it is shared with the [[DCLN ( | The format for '''area collision''' stores the collision geometry for levels, and can be found in the [[MREA (File Format)|MREA]] format. Most of it is shared with the [[DCLN (Metroid Prime)|DCLN]] format, but there are a few parts that are exclusive to MREA. | ||
__TOC__ | __TOC__ | ||
Line 16: | Line 16: | ||
| 1 | | 1 | ||
| {{unknown|Unknown}} | | {{unknown|Unknown}} | ||
| Always 0x01000000 | | Always <code>0x01000000</code> | ||
|- | |- | ||
| 0x4 | | 0x4 | ||
Line 45: | Line 45: | ||
| Bounding box of the collision mesh. This is also the bounding box of the root node of the octree. | | Bounding box of the collision mesh. This is also the bounding box of the root node of the octree. | ||
|- | |- | ||
| | | 0x28 | ||
| u32 | | u32 | ||
| 1 | | 1 | ||
Line 51: | Line 51: | ||
| Node type for the root node. This is almost always 1 (Branch) but there ARE some areas that use other values for this. | | Node type for the root node. This is almost always 1 (Branch) but there ARE some areas that use other values for this. | ||
|- | |- | ||
| | | 0x2C | ||
| u32 | | u32 | ||
| 1 | | 1 | ||
Line 57: | Line 57: | ||
| Size of the collision octree. | | Size of the collision octree. | ||
|- | |- | ||
| | | 0x30 | ||
| [[#Collision Octree|Collision Octree]] | | [[#Collision Octree|Collision Octree]] | ||
| 1 | | 1 | ||
Line 67: | Line 67: | ||
| 1 | | 1 | ||
| '''Collision Index Data''' | | '''Collision Index Data''' | ||
| Index data for the collision mesh. This data section is what actually defines the collision mesh itself. This part of the format is shared with [[DCLN ( | | Index data for the collision mesh. This data section is what actually defines the collision mesh itself. This part of the format is shared with [[DCLN (Metroid Prime)|DCLN]]. | ||
|- | |- | ||
| colspan=5 {{unknown|End of MREA Collision Section}} | | colspan=5 {{unknown|End of MREA Collision Section}} |
Latest revision as of 20:03, 30 December 2016
The format for area collision stores the collision geometry for levels, and can be found in the MREA format. Most of it is shared with the DCLN format, but there are a few parts that are exclusive to MREA.
Format
Offset | Type | Count | Name | Notes |
---|---|---|---|---|
0x0 | u32 | 1 | Unknown | Always 0x01000000
|
0x4 | u32 | 1 | Collision Section Size | Size of the collision section (not including these first two values). |
0x8 | u32 | 1 | Magic | Always 0xDEAFBABE
|
0xC | u32 | 1 | Version | Possible values:
|
0x10 | AABox | 1 | Collision Bounding Box | Bounding box of the collision mesh. This is also the bounding box of the root node of the octree. |
0x28 | u32 | 1 | Octree Root Node Type | Node type for the root node. This is almost always 1 (Branch) but there ARE some areas that use other values for this. |
0x2C | u32 | 1 | Octree Size | Size of the collision octree. |
0x30 | Collision Octree | 1 | Collision Octree | Octree for the collision mesh. This is used to quickly locate triangles that an actor could potentially be colliding with. |
Collision Index Data | 1 | Collision Index Data | Index data for the collision mesh. This data section is what actually defines the collision mesh itself. This part of the format is shared with DCLN. | |
End of MREA Collision Section |
Collision Octree
To do: In DKCR the octree format was modified to partition in 2D instead of 3D. Need to document changes. |
The collision octree is a node tree that allows an actor to quickly locate any triangles it might be colliding with without needing to check every triangle in the mesh. The type of the root node of the tree is determined by the Octree Root Node Type value in the header, but it's usually a branch node.
Branch Node
A branch node has eight child nodes. Each child occupies one octant of the branch's bounding box.
Offset | Type | Count | Name | Notes |
---|---|---|---|---|
0x0 | u16 | 1 | Child Node Type Flags | Bitfield that specifies the node type of each child node. Each child is allocated two bits, which will be either 0, 1, or 2. The lower bits correspond to the first children. |
0x2 | u16 | 1 | Padding | Padding to align the file to four bytes. |
0x4 | u32 | 8 | Child Node Offsets | Offset of each child node. These are relative to the start of the first child node. |
0x24 | Octree Node | 8 | Child Nodes | Octree child nodes. The type of the node is determined by the node type enum set for this child in the Child Node Type Flags. If the value is 0, then this child doesn't contain any triangles so it doesn't exist. Otherwise, it will be either a branch or a leaf. |
End of Branch Node |
Leaf Node
A leaf node marks the end of a tree branch. It contains a list of triangles that an object in this leaf could be colliding with.
Offset | Type | Count | Name | Notes |
---|---|---|---|---|
0x0 | AABox | 1 | Leaf Bounding Box | Bounding box of the leaf. This is fitted more cleanly to the triangles in the node, so it won't match the bounding box generated for this node by subdividing the parent's bounds. |
0x18 | u16 | 1 | Triangle Count | Number of triangles inside this leaf node. |
0x1A | u16 | Triangle Count | Triangle Index List | List of triangles that are contained in this leaf. At this point, an actor inside this leaf would need to look up each triangle in this list and check for collisions against each of them. |
Pad to 4 bytes | ||||
End of Leaf Node |
Octree Node Type Enum
ID | Type |
---|---|
0 | None |
1 | Branch |
2 | Leaf |