Difference between revisions of "Pikmin 2 collision format"

From Pikmin Technical Knowledge Base
Jump to navigation Jump to search
m (Espyo moved page Pikmin 2 Collision Format to Pikmin 2 collision format without leaving a redirect)
Line 1: Line 1:
The following describes the format of Pikmin 2's .col files which describe the collision of overworld levels and cave units. The information might be incorrect or incomplete.  
+
The following describes the format of ''Pikmin 2'''s <code>.col</code> 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.
 
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==
 
{| class="wikitable"
 
{| class="wikitable"
|Size of data || Description
+
! Size of data || Description
 
|-
 
|-
|  0x4 || unsigned integer describing how many vertices are defined
+
|  0x4 || Unsigned integer describing how many vertices are defined.
 
|-
 
|-
|  0xC*(vertex count) || 3 32-bit floats describing the XYZ coordinates for each vertex
+
|  0xC*(vertex count) || 3 32-bit floats describing the XYZ coordinates for each vertex.
 
|-
 
|-
|  0x4 || unsigned integer describing how many triangles are defined
+
|  0x4 || Unsigned integer describing how many triangles are defined.
 
|-
 
|-
| 0x4C*(triangle count) || for each triangle in the collision there is 76 bytes of data describing the vertices of the trangle, normals, tangents and more
+
| 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
+
| 0x18 || {{unknown|Unknown, maybe data about the level size.}}
 
|-
 
|-
|  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 || 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
+
|  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 multiplying  
+
| 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 multiplying.
 
|}
 
|}
  
Triangle data
+
==Triangle data==
  
 
{| class="wikitable"
 
{| class="wikitable"
|Size of data || Description
+
! 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 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
+
|  0xC || 3 floats describing the normal vector of the triangle.
 
|-
 
|-
|  0x4 || float that affects collision in the direction of the normal, distance_normal
+
|  0x4 || float that affects collision in the direction of the normal, distance_normal.
 
|-
 
|-
|  0xC || 3 floats describing the tangent of the edge (v1, v2)
+
|  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
+
|  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)
+
|  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
+
|  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)
+
|  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
+
|  0x4 || float that affects collision in the direction of the tangent of (v3, v1), distance_tan3.
 
|}
 
|}
  
Line 56: Line 57:
  
 
distance_tan3 = tan3_x*v3_x + tan3_y*v3_y + tan3_z*v3_z, similar to above but for tangent of (v3, v1)
 
distance_tan3 = tan3_x*v3_x + tan3_y*v3_y + tan3_z*v3_z, similar to above but for tangent of (v3, v1)
 +
 +
[[Category:Pikmin 2]]
 +
[[Category:File formats]]

Revision as of 19:22, 18 June 2017

The following describes the format of Pikmin 2's .col 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 multiplying.

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)