Collision Index Data (File Format)

From Retro Modding Wiki
Revision as of 08:52, 29 December 2016 by >Aruki (Created page with "The '''collision index data''' structure defines collision geometry and materials. It can be found in the MREA format as well as the DCLN (File Format...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

The collision index data structure defines collision geometry and materials. It can be found in the MREA format as well as the DCLN format.

Format

The structure is basically just a sequence of arrays. In Metroid Prime 2, the collision material field was extended from 32 bits to 64 bits, and a new array was added in between the triangle and vertex arrays. Other than that, the format is the same across all games.

Type Count Name Notes MP1 MP2+
u32 1 Collision Material Count Count of collision materials in the mesh.
u32/u64 Collision Material Count Collision Material Array Array of bitfields that controls the collision material/properties. This is a 32-bit field in Metroid Prime, and a 64-bit field in every game after. See below for details.
u32 1 Vertex Index Count Count of vertex material indices. Matches the number of vertices in the collision mesh.
u8 Vertex Index Count Vertex Index Array Array of vertex material indices. Each entry maps the corresponding vertex to a collision material from the Collision Material Array.
u32 1 Edge Index Count Count of edge material indices. Matches the number of edges in the collision mesh.
u8 Edge Index Count Edge Index Array Array of edge material indices. Each entry maps the corresponding edge to a collision material from the Collision Material Array.
u32 1 Triangle Index Count Count of triangle material indices. Matches the number of triangles in the collision mesh.
u8 Triangle Index Count Triangle Index Array Array of triangle material indices. Each entry maps the corresponding triangle to a collision material from the Collision Material Array.
u32 1 Edge Count Count of edges in the collision mesh.
Edge Edge Count Edge Array Array defining all edges in the collision mesh. Each edge is defined with two vertex indices.
u32 1 Triangle Count Count of triangles in the next array. Note this is technically a count of the number of indices in the next array, not the number of triangles, so you need to divide it by 3 to calculate the actual triangle count.
Triangle Triangle Count / 3 Triangle Array Array defining all triangles in the collision mesh. Each triangle is defined with three edge indices. If the triangle's material has the Flipped Tri flag enabled, then reverse winding order; otherwise use the indices in order.
u32 1 Unknown Index Count This array is only in Metroid Prime 2 and later.
u16 Unknown Index Count Unknown Index Array This array is only in Metroid Prime 2 and later.
u32 1 Vertex Count Count of vertices in the next array.
Vector3f Vertex Count Vertex Array Array defining all vertices in the collision mesh.

Edge

Offset Type Name
0x0 u16 Vertex Index A
0x2 u16 Vertex Index B
0x4 End of Edge

Triangle

Offset Type Name
0x0 u16 Edge Index A
0x2 u16 Edge Index B
0x4 u16 Edge Index C
0x6 End of Triangle

Collision Materials

Collision materials are basically properties mapped to every vertex, edge, and triangle in the collision mesh that controls how the game reacts when an object touches it. It controls things like, for example:

  • What sound effect plays when the player walks on the surface
  • Which actors are allowed to pass through the collision
  • Whether the player is allowed to stand on the surface or if it should be treated as a wall

... among some other things. This field is 32 bits in Metroid Prime, and was extended to 64 bits in Metroid Prime 2 and every game after. Prime 2 and 3 share the same property values, whereas Prime 1 and DKCR have unique property sets. In Prime 2 and on, the majority of the fields in the upper 32 bits are only meant for internal use and aren't used by MREA or DCLN collision assets. (These bits exist internally in Prime 1 as well, but they aren't exposed to the collision file format.)

The surface type properties controls what physical material the surface is made of, which changes the sound effect that plays when the player walks/jumps on the surface and in some cases, what particle effect plays on it. In the Metroid Prime series, rather than embedding an enum to set the surface type, each surface type is assigned its own bit. This technically allows for multiple surface types to be set on the same geometry. For sound effect playback, the bit with the largest value takes priority.

Metroid Prime

Bit Hex Name Description
0 0x00000001 Unknown This is a default flag set on most surface types. (Note: This isn't an unknown flag, it's just literally named "Unknown".)
1 0x00000002 Stone Stone surface type.
2 0x00000004 Metal Metal surface type.
3 0x00000008 Grass Grass surface type.
4 0x00000010 Ice Ice surface type.
5 0x00000020 Pillar This flag is toggled on most pillar structures. Unknown function (possibly has something to do with how the morph ball camera interacts with the surface?).
6 0x00000040 Metal Grating Metal grating surface type.
7 0x00000080 Phazon Phazon surface type. If the active AreaAttributes object in this room has the Phazon Type enum set, this collision will cause the player to take Phazon-type damage.
8 0x00000100 Dirt Dirt surface type.
9 0x00000200 Lava Lava surface type. The sound effects for this surface type are in the LavaWorld AGSC, so it won't play back correctly outside of Magmoor.
10 0x00000400 Unknown Unknown surface type found in a few rooms in Magmoor (some walls in Geothermal Core and Plasma Processing, the floors in Save Station A, and the ceiling in Save Station B). Footstep SFX sounds like stone.
11 0x00000800 Snow Snow surface type.
12 0x00001000 Slow Mud Slow mud surface type. The player's speed is reduced while walking on this surface. This is normally unused (only found in a few spots where you can't actually walk on it).
13 0x00002000 Halfpipe Indicates this surface is a half-pipe, which changes how morph ball physics are calculated.
14 0x00004000 Mud Mud surface type. Same as Slow Mud except it doesn't slow down the player. This is normally unused (only found in a few strange spots in Life Grove).
15 0x00008000 Glass Glass surface type.
16 0x00010000 Shield Shield surface type. Generally used on collision for force fields.
17 0x00020000 Sand Sand surface type.
18 0x00040000 Shoot Thru If this flag is enabled, projectiles can pass through this surface. This is used liberally in Prime 1 to make projectile collision appear more accurate.
19 0x00080000 Solid If this flag is disabled, no actors can collide with this surface.
20 0x00100000 Unknown Seems to be set on everything? Not a surface type and no noticeable effect from turning it on/off.
21 0x00200000 Camera Thru If this flag is enabled, the morph ball camera can pass through this surface.
22 0x00400000 Wood Wood surface type.
23 0x00800000 Organic Organic surface type.
24 0x01000000 Unknown
25 0x02000000 Redundant Edge/Flipped Tri Triangles with this flag enabled are flipped around.
26 0x04000000 See Thru Indicates this surface is an invisible wall. Unknown function.
27 0x08000000 Scan Thru If this flag is enabled, this surface doesn't block lock-ons in any visor.
28 0x10000000 AI Walk Thru If this flag is enabled, AI actors can pass through this surface.
29 0x20000000 Ceiling Indicates this surface is a ceiling.
30 0x40000000 Wall Indicates this surface is a wall.
31 0x80000000 Floor Indicates this surface is a floor.

Metroid Prime 2/3

Bit Hex Name Description
0 0x00000000 00000001 Unknown This is a default flag set on most surface types. (Note: This isn't an unknown flag, it's just literally named "Unknown".)
1 0x00000000 00000002 Stone Stone surface type.
2 0x00000000 00000004 Metal Metal surface type.
3 0x00000000 00000008 Grass Grass surface type.
4 0x00000000 00000010 Ice Ice surface type.
5 0x00000000 00000020 Pillar This flag is toggled on most pillar structures. Unknown function (possibly has something to do with how the morph ball camera interacts with the surface?).
6 0x00000000 00000040 Metal Grating Metal grating surface type.
7 0x00000000 00000080 Phazon Phazon surface type. This collision will cause the player to take Phazon-type damage.
8 0x00000000 00000100 Dirt Dirt surface type.
9 0x00000000 00000200 SP_Metal Alternate metal surface type.
10 0x00000000 00000400 Glass Glass surface type.
11 0x00000000 00000800 Snow Snow surface type.
12 0x00000000 00001000 Fabric Fabric surface type.
13 0x00000000 00002000 Halfpipe Indicates this surface is a half-pipe, which changes how morph ball physics are calculated.
14 0x00000000 00004000 Unused3 Unused in Prime 2. Unknown in Prime 3.
15 0x00000000 00008000 Unused4 Unused in Prime 2. Unknown in Prime 3.
16 0x00000000 00010000 Shield Shield surface type. Generally used on collision for force fields.
17 0x00000000 00020000 Sand Sand surface type.
18 0x00000000 00040000 Moth Organics/Seed Organics Alternate organic surface type; used for moth materials in Prime 2 and used in the Leviathan Core rooms in Prime 3.
19 0x00000000 00080000 Web Spider web surface type.
20 0x00000000 00100000 Shoot Thru If this flag is enabled, projectiles can pass through this surface. (Presumably has no effect unless projectiles are configured to use the collision geometry instead of the render geometry.)
21 0x00000000 00200000 Camera Thru If this flag is enabled, the morph ball camera can pass through this surface.
22 0x00000000 00400000 Wood Wood surface type.
23 0x00000000 00800000 Organic Organic surface type.
24 0x00000000 01000000 Redundant Edge/Flipped Tri Triangles with this flag enabled are flipped around.
25 0x00000000 02000000 Rubber Rubber surface type.
26 0x00000000 04000000 See Thru Indicates this surface is an invisible wall. Unknown function.
27 0x00000000 08000000 Scan Thru If this flag is enabled, this surface doesn't block lock-ons in any visor.
28 0x00000000 10000000 AI Walk Thru If this flag is enabled, AI actors can pass through this surface.
29 0x00000000 20000000 Ceiling Indicates this surface is a ceiling.
30 0x00000000 40000000 Wall Indicates this surface is a wall.
31 0x00000000 80000000 Floor Indicates this surface is a floor.
32 0x00000001 00000000 Player (Internal) Internal use only.
33 0x00000002 00000000 Character (Internal) Internal use only.
34 0x00000004 00000000 Trigger (Internal) Internal use only.
35 0x00000008 00000000 Projectile (Internal) Internal use only.
36 0x00000010 00000000 Bomb (Internal) Internal use only.
37 0x00000020 00000000 Ground Collider (Internal) Internal use only.
38 0x00000040 00000000 No Static World Collision (Internal) Internal use only.
39 0x00000080 00000000 Scannable (Internal) Internal use only.
40 0x00000100 00000000 Target (Internal) Internal use only.
41 0x00000200 00000000 Orbit (Internal) Internal use only.
42 0x00000400 00000000 Occluder (Internal) Internal use only.
43 0x00000800 00000000 Immovable (Internal) Internal use only.
44 0x00001000 00000000 Debris (Internal) Internal use only.
45 0x00002000 00000000 Power Bomb (Internal) Internal use only.
46 0x00004000 00000000 Targetable Projectile (Internal) Internal use only.
47 0x00008000 00000000 Collision Only Actor (Internal) Internal use only.
48 0x00010000 00000000 AI Block (Internal) Internal use only.
49 0x00020000 00000000 Platform (Internal) Internal use only.
50 0x00040000 00000000 Non Solid Damageable (Internal) Internal use only.
51 0x00080000 00000000 Show on Radar (Internal) Internal use only.
52 0x00100000 00000000 Platform Slave (Internal) Internal use only.
53 0x00200000 00000000 No Ice Spread (Internal) Internal use only.
54 0x00400000 00000000 Grapple Thru (Internal) Internal use only.
55 0x00800000 00000000 Can Jump on Character (Internal) Internal use only.
56 0x01000000 00000000 Exclude from Line of Sight Test (Internal) Internal use only.
57 0x02000000 00000000 Don't Show on Radar (Internal) Internal use only.
58 0x04000000 00000000 Jump Not Allowed If this flag is enabled, the player won't be able to stand on this surface and instead will slide off it.
59 0x08000000 00000000 Solid (Internal) Internal use only.
60 0x10000000 00000000 Complex (Internal) Internal use only.
61 0x20000000 00000000 Spider Ball If this flag is enabled, the player will be able to use Spider Ball on this surface. This is used for irregularly-shaped spider ball attraction surfaces (like spheres).
62 0x40000000 00000000 Screw Attack Wall Jump If this flag is enabled, the player can wall jump from this wall using Screw Attack.
63 0x80000000 00000000 Seek (Internal) Internal use only.

Donkey Kong Country Returns

Bit Hex Name Description
0 0x00000000 00000001 Unknown
1 0x00000000 00000002 Unknown
2 0x00000000 00000004 Unknown
3 0x00000000 00000008 Unknown
4 0x00000000 00000010 Unknown
5 0x00000000 00000020 Unknown
6 0x00000000 00000040 Unknown
7 0x00000000 00000080 Unknown
8 0x00000000 00000100 Ceiling Indicates this surface is a ceiling.
9 0x00000000 00000200 Wall Indicates this surface is a wall.
10 0x00000000 00000400 Floor Indicates this surface is a floor.
11 0x00000000 00000800 Player Walk Thru If this flag is enabled, the player can pass through this surface.
12 0x00000000 00001000 Unknown
13 0x00000000 00002000 Unknown
14 0x00000000 00004000 AI Walk Thru If this flag is enabled, AI actors can pass through this surface.
15 0x00000000 00008000 Unknown
16 0x00000000 00010000 Unknown
17 0x00000000 00020000 Unknown
18 0x00000000 00040000 Unknown
19 0x00000000 00080000 Unknown
20 0x00000000 00100000 Unknown
21 0x00000000 00200000 Unknown
22 0x00000000 00400000 Unknown
23 0x00000000 00800000 Unknown
24 0x00000000 01000000 Unknown
25 0x00000000 02000000 Unknown
26 0x00000000 04000000 Unknown
27 0x00000000 08000000 Unknown
28 0x00000000 10000000 Redundant Edge/Flipped Tri Triangles with this flag enabled are flipped around.
29 0x00000000 20000000 Unknown
30 0x00000000 40000000 Unknown
31 0x00000000 80000000 Unknown
32 0x00000001 00000000 Unknown
33 0x00000002 00000000 Unknown
34 0x00000004 00000000 Unknown
35 0x00000008 00000000 Unknown
36 0x00000010 00000000 Unknown
37 0x00000020 00000000 Unknown
38 0x00000040 00000000 Unknown
39 0x00000080 00000000 Unknown
40 0x00000100 00000000 Unknown
41 0x00000200 00000000 Unknown
42 0x00000400 00000000 Unknown
43 0x00000800 00000000 Unknown
44 0x00001000 00000000 Unknown
45 0x00002000 00000000 Unknown
46 0x00004000 00000000 Unknown
47 0x00008000 00000000 Unknown
48 0x00010000 00000000 Unknown
49 0x00020000 00000000 Unknown
50 0x00040000 00000000 Unknown
51 0x00080000 00000000 Unknown
52 0x00100000 00000000 Unknown
53 0x00200000 00000000 Unknown
54 0x00400000 00000000 Unknown
55 0x00800000 00000000 Unknown
56 0x01000000 00000000 Unknown
57 0x02000000 00000000 Unknown
58 0x04000000 00000000 Unknown
59 0x08000000 00000000 Unknown
60 0x10000000 00000000 Unknown
61 0x20000000 00000000 Unknown
62 0x40000000 00000000 Unknown
63 0x80000000 00000000 Unknown