Difference between revisions of "Pikmin 2 collision format"
m (fix mistake, collision is in grid.bin files) |
|||
Line 21: | Line 21: | ||
| 0x8 || {{Unknown|Unknown.}} | | 0x8 || {{Unknown|Unknown.}} | ||
|- | |- | ||
− | | Remaining data || Contains groups of triangles. Each group starts with one 32 bit unsigned integer describing the amount of triangles in the group, followed by that many 32 bit unsigned integers describing the index of each triangle (0-indexed). Amount of groups equals to the width of the grid | + | | Remaining data || Contains groups of triangles. Each group starts with one 32 bit unsigned integer describing the amount of triangles in the group, followed by that many 32 bit unsigned integers describing the index of each triangle (0-indexed). Amount of groups equals to the width of the grid multiplied by its length. |
|} | |} | ||
Revision as of 16:24, 23 July 2017
The following describes the format of Pikmin 2's grid.bin
files, which describe the collision of overworld levels and cave units. The information might be incorrect or incomplete.
The format has no header and directly starts off with data. The Y coordinate points upwards. All values are big endian. Size of data is in bytes.
General data
Size of data | Description |
---|---|
0x4 | Unsigned integer describing how many vertices are defined. |
0xC*(vertex count) | 3 32-bit floats describing the XYZ coordinates for each vertex. |
0x4 | Unsigned integer describing how many triangles are defined. |
0x4C*(triangle count) | For each triangle in the collision there are 76 bytes of data describing the vertices of the triangle, normals, tangents, and more. |
0x18 | Unknown, maybe data about the level size.[unsure] |
0x8 | Two 32 bit unsigned integers describing the width and length of a grid of triangle groups. Is not related to the actual size of the map. |
0x8 | Unknown.[unsure] |
Remaining data | Contains groups of triangles. Each group starts with one 32 bit unsigned integer describing the amount of triangles in the group, followed by that many 32 bit unsigned integers describing the index of each triangle (0-indexed). Amount of groups equals to the width of the grid multiplied by its length. |
Triangle data
Size of data | Description |
---|---|
0xC | 3 32 bit unsigned integers describing the (0-based) indices of the vertices v1, v2, v3 in this triangle. |
0xC | 3 floats describing the normal vector of the triangle. |
0x4 | float that affects collision in the direction of the normal, distance_normal. |
0xC | 3 floats describing the tangent of the edge (v1, v2). |
0x4 | float that affects collision in the direction of the tangent of (v1,v2), distance_tan1. |
0xC | 3 floats describing the tangent of the edge (v2, v3). |
0x4 | float that affects collision in the direction of the tangent of (v2,v3), distance_tan2. |
0xC | 3 floats describing the tangent of the edge (v3, v1). |
0x4 | float that affects collision in the direction of the tangent of (v3, v1), distance_tan3. |
The values distance_normal, distance_tan1, distance_tan2, distance_tan3 can be calculated as follows:
distance_normal = normal_x*middle_x + normal_y*middle_y + normal_z*middle_z, where middle_x/y/z are the coordinates of the middle between vertices v1, v2, v3
distance_tan1 = tan1_x*v1_x + tan1_y*v1_y + tan1_z*v1_z, where tan1_x/y/z are the xyz components of the tangent of (v1,v2), and v1_x/y/z are the coordinates of the vertex v1
distance_tan2 = tan2_x*v2_x + tan2_y*v2_y + tan2_z*v2_z, similar to above but for tangent of (v2, v3)
distance_tan3 = tan3_x*v3_x + tan3_y*v3_y + tan3_z*v3_z, similar to above but for tangent of (v3, v1)