Wiki

Clone wiki

toolkit / DPC File Format

DPC File Format

The DPC file format stores vertices, polygons, meshes, collision boxes, and various instructions for rendering levels, vehicles, and game menus.

Structures

  • Bounding Sphere
  • Background Entity
  • Vertex
  • Polygon
  • Mesh
  • File Pointer

Bounding Sphere Structure

Bounding spheres are used to quickly determine if an entity is visible on the screen.

  • ushort Bounding Sphere Tag - Always 0x0701
  • ushort Unknown parameter
  • int X Position
  • int Y Position
  • int Z Position
  • int Radius
  • byte Unknown parameter
  • byte Unknown parameter
  • byte Unknown parameter

Background Entity Structure

An entity with a mesh scaled 4x larger. The entity always appears far away from the player.

  • ushort Background Entity Tag - Always 0x030c
  • byte Unknown parameter
  • byte Unknown parameter
  • byte Unknown parameter
  • byte Amount of children
  • byte Unknown parameter

Vertex Structure

Vertices define the X, Y, Z coordinates of a vertex. They always have an 8-byte stride. DPC files usually define every vertex immediately after the file header.

  • short X Position
  • short Y Position
  • short Z Position
  • short Empty - Always zero

Polygon Structure

Polygons define which vertices belong to the polygon as well as texture coordinates. Polygons have different byte strides that are determined by the header. The header also determines if the polygon has a texture or is a solid color. Vertices are assigned to polygons using index values (Vertex ID numbers.) If you want to learn more about the polygons, use the Polygon Panel under the tools menu or look at the PolygonController class.

Header

  • uint Header - The first two bytes of the header determine if the polygon has three or four vertices.

Indices

  • ushort Index 0 - The index of the first vertex.
  • ushort Index 1 - The index of the second vertex.
  • ushort Index 2 - The index of the third vertex.
  • ushort Index 3 - The index of the fourth vertex. Always zero if the polygon only has three vertices.

Normals

  • short Normal X - The X value of the polygon's normal vector.
  • short Normal Y - The Y value of the polygon's normal vector.
  • short Normal Z - The Z value of the polygon's normal vector.
  • ushort Render Flag - Used to determine how the polygon is rendered (default, billboard, etc.)

Vertex Diffuse Color Values

Skipped if the polygon does not have a texture.

  • byte Vertex 0 Diffuse Blue - The blue value of the first vertex's diffuse color.
  • byte Vertex 0 Diffuse Green - The green value of the first vertex's diffuse color.
  • byte Vertex 0 Diffuse Red - The red value of the first vertex's diffuse color.
  • byte Vertex 0 Diffuse Alpha - The alpha value of the first vertex's diffuse color.
  • byte Vertex 1 Diffuse Blue - The blue value of the second vertex's diffuse color.
  • byte Vertex 1 Diffuse Green - The green value of the second vertex's diffuse color.
  • byte Vertex 1 Diffuse Red - The red value of the second vertex's diffuse color.
  • byte Vertex 1 Diffuse Alpha - The alpha value of the second vertex's diffuse color.
  • byte Vertex 2 Diffuse Blue - The blue value of the third vertex's diffuse color.
  • byte Vertex 2 Diffuse Green - The green value of the third vertex's diffuse color.
  • byte Vertex 2 Diffuse Red - The red value of the third vertex's diffuse color.
  • byte Vertex 2 Diffuse Alpha - The alpha value of the third vertex's diffuse color.
  • byte Vertex 3 Diffuse Blue - The blue value of the fourth vertex's diffuse color. Skipped if only three vertices exist.
  • byte Vertex 3 Diffuse Green - The green value of the fourth vertex's diffuse color. Skipped if only three vertices exist.
  • byte Vertex 3 Diffuse Red - The red value of the fourth vertex's diffuse color. Skipped if only three vertices exist.
  • byte Vertex 3 Diffuse Alpha - The alpha value of the fourth vertex's diffuse color. Skipped if only three vertices exist.

Texture Coordinates

Skipped if the polygon does not have a texture.

  • short Tex Coord 0 S - The S value of the first texture coordinate.
  • short Tex Coord 0 T - The T value of the first texture coordinate.
  • short Tex Coord 1 S - The S value of the second texture coordinate.
  • short Tex Coord 1 T - The T value of the second texture coordinate.
  • short Tex Coord 2 S - The S value of the third texture coordinate.
  • short Tex Coord 2 T - The T value of the third texture coordinate.
  • short Tex Coord 3 S - The S value of the fourth texture coordinate. Skipped if only three vertices exist.
  • short Tex Coord 3 T - The T value of the fourth texture coordinate. Skipped if only three vertices exist.
  • ushort Texture ID - The first byte is the ID of the texture used by the TPC file.

Extra Flags

  • byte Extra Flag - Flags that appear at the end of every polygon. May have zero or more.

Mesh Structure

Mesh Header

Before defining the polygons of a mesh, a mesh header defines where the vertices start, where the indices start, and how many polygons exist. In TM2, the header is 44 bytes long.

  • uint Mesh Tag - Always 0x0000FF00
  • uint Vertex Start Pointer - A pointer that points to the address of the first vertex
  • uint Unknown Pointer
  • uint Index Start Pointer - A pointer that points to the address of the first index value
  • byte Polygon Count - The number of polygons needed by the mesh

The rest of the mesh header is unknown.

File Pointer Structure

File pointers are 4 byte values used to point to a different address in the DPC file.

  • ushort Value - The address without the offset
  • ushort Offset - Used to determine which number is added to the value to get the final address

Offsets start at 0x8001, 0x8002, 0x8003, etc

For example, the offset for 0x8001 is -40,000. If a pointer's value is 45,000 and the offset is 0x8001, you will need to subtract 40,000 from the value to get the final point to address. In this case you would take 45,000 - 40,000 and get 5,000 as the pointer address.

Updated