DKRDS Track (File Format): Difference between revisions

From Wexos's Wiki
Jump to navigationJump to search
 
(5 intermediate revisions by the same user not shown)
Line 19: Line 19:
| 0x0C || Byte[4] || {{unknown-left|'''Unknown'''. Always 0xCCCCCCCC.}}
| 0x0C || Byte[4] || {{unknown-left|'''Unknown'''. Always 0xCCCCCCCC.}}
|-
|-
| 0x10 || Int32 || '''[[#Unknown Section 2|Unknown Section 2]]''' offset.
| 0x10 || Int32 || '''[[#Culling Groups|Culling Groups]]''' offset.
|-
|-
| 0x14 || Int32 || '''[[#Unknown Section 2|Unknown Section 2]]''' data type:
| 0x14 || Int32 || '''[[#Culling Groups|Culling Groups]]''' data type:
* 1 = 4-byte per '''N''' group.
* 1 = 4-byte per '''N''' group.
* 2 = 8-byte per '''N''' group.
* 2 = 8-byte per '''N''' group.
Line 29: Line 29:
| 0x1C || Int32 || '''[[#Texture Group|Texture Group]]''' offset.
| 0x1C || Int32 || '''[[#Texture Group|Texture Group]]''' offset.
|-
|-
| 0x20 || Int32 || '''[[#Unknown Section 3|Unknown Section 3]]''' offset.
| 0x20 || Int32 || '''[[#Unknown Section 2|Unknown Section 2]]''' offset.
|-
|-
| 0x24 || Int32 || '''[[#Wish Race Unknown Section|Wish Race Unknown Section]]''' entry count.
| 0x24 || Int32 || '''[[#Wish Race Unknown Section|Wish Race Unknown Section]]''' entry count.
Line 67: Line 67:
| 0x02 || UInt16 || {{unknown-left|'''Unknown'''.}}
| 0x02 || UInt16 || {{unknown-left|'''Unknown'''.}}
|-
|-
| 0x04 || UInt16 || '''Number of entries''' in [[#Track Section Collision Data|Track Section Collision]] ('''1E''').
| 0x04 || UInt16 || '''Number of polygon groups''' ('''P''').
|-
|-
| 0x06 || UInt16 || '''Number of vertices''' in [[#Track Section Vertex Data|Track Section Vertex Data]] ('''2E''').
| 0x06 || UInt16 || '''Number of vertices''' in [[#Track Section Vertex Data|Track Section Vertex Data]] ('''V''').
|-
|-
| 0x08 || UInt16 || '''Number of entries''' in [[#Track Section UV|Track Section UV Data]] ('''3E''').
| 0x08 || UInt16 || '''Number of UVs''' in [[#Track Section UV|Track Section UV Data]] ('''U''').
|-
|-
| 0x0A || UInt16 || '''Number of colors''' in [[#Track Section Color Data|Track Section Color Data]] ('''4E''').
| 0x0A || UInt16 || '''Number of colors''' in [[#Track Section Color Data|Track Section Color Data]] ('''C''').
|-
|-
| 0x0C || Int32 || {{unknown-left|'''Unknown'''.}}
| 0x0C || Int32 || '''[[#Track Section Triangle Data|Track Section Triangle Data]]''' offset.
|-
|-
| 0x10 || Int32 || '''[[#Track Section Unknown Data 1|Track Section Unknown Data 1]]''' offset.
| 0x10 || Int32 || '''[[#Track Section Collision Data|Track Section Collision Data]]''' offset.
|-
|-
| 0x14 || Int32 || '''[[#Track Section Vertex Data|Track Section Vertex Data]]''' offset.
| 0x14 || Int32 || '''[[#Track Section Vertex Data|Track Section Vertex Data]]''' offset.
|-
|-
| 0x18 || Int32 || '''[[#Track Section Unknown Data 2|Track Section Unknown Data 2]]''' offset.
| 0x18 || Int32 || '''[[#Track Section UV Data|Track Section UV Data]]''' offset.
|-
|-
| 0x1C || Int32 || '''[[#Track Section Color Data|Track Section Color Data]]''' offset.
| 0x1C || Int32 || '''[[#Track Section Color Data|Track Section Color Data]]''' offset.
Line 89: Line 89:


==== Track Section Data ====
==== Track Section Data ====
This data starts with an unknown size header and some data, followed by the model and collision data referenced by the previous header's offsets.
This data follows directly after the header of the section entry and starts with a 76-byte header.
 
{|class=wikitable
! Offset !! Type !! Description
|-
| 0x00 || Int32 || {{unknown-left|'''Unknown'''. Seems to be always 0xFFFFFFFF and set to an address when loaded in memory.}}
|-
| 0x04 || Int32[3] || '''Collision XYZ offset'''.
|-
| 0x10 || Int32[3] || '''Visual model XYZ offset'''. The units are not the same as the collision offset.
|-
| 0x1C || UInt16[12][2] || {{unknown-left|'''Unknown'''. Both 24-byte arrays seem to always be the same? They affect collision data.}}
|-
| 0x4C || colspan=2 {{unknown|End of header, start of [[#Track Section Polygon Data|Track Section Polygon Data]]}}
|}
 
===== Track Section Polygon Data =====
This section seems to store '''P''' polygon groups' attributes.
 
{|class=wikitable
! Offset !! Type !! Description
|-
| 0x00 || Polygon Group Entry['''P'''] || '''Polygon group entries'''.
|}
 
====== Polygon Group Entry ======
Each polygon group entry is 12 bytes long.
 
{|class=wikitable
! Offset !! Type !! Description
|-
| 0x00 || UInt16 || '''First triangle ID'''.
|-
| 0x02 || UInt16 || '''Number of triangles'''.
|-
| 0x04 || Byte || {{unknown-left|'''Unknown'''.}}
|-
| 0x05 || Byte || {{unknown-left|'''Unknown'''. Seems to affect collision attributes, such as the type of collision and terrain effects.}}
|-
| 0x06 || UInt16 || {{unknown-left|'''Unknown'''.}}
|-
| 0x08 || Byte[4] || {{unknown-left|'''Unknown'''.}}
|}
 
The number of triangles '''T''' can be calculated by adding the first triangle ID to the number of triangles of the last polygon group entry.
 
===== Track Section Triangle Data =====
This section stores '''T''' triangle entries.
 
{|class=wikitable
! Offset !! Type !! Description
|-
| 0x00 || Triangle Entry['''T'''] || '''Triangle entries'''.
|}
 
====== Triangle Entry ======
Each triangle entry is 20 bytes long.
 
{|class=wikitable
! Offset !! Type !! Description
|-
| 0x00 || UInt16 || '''Texture ID'''.
|-
| 0x02 || UInt16[3] || {{unknown-left|'''Unknown'''. Seems to affect the collision only. Perhaps triangle normals?}}
|-
| 0x08 || Byte[4] || '''Vertex position indices'''. The index for each of the 3 vertices is 10 bits long. 2 last bits are unknown.
|-
| 0x0C || Byte[4] || '''UV indices'''. The index for each of the 3 vertices is 10 bits long. 2 last bits are unknown.
|-
| 0x10 || Byte[4] || '''Color indices'''. The index for each of the 3 vertices is 10 bits long. 2 last bits are unknown.
|}


===== Track Section Collision Data =====
===== Track Section Collision Data =====
48-byte data per entry '''1E'''. ''TBD''
4-byte data per triangle (?). ''TBD''


===== Track Section Vertex Data =====
===== Track Section Vertex Data =====
Vertex data is stored as 6-byte groups per entry '''2E'''.
Vertex data is stored as 6-byte groups per entry '''V'''.


{|class=wikitable
{|class=wikitable
! Offset !! Type !! Description
! Offset !! Type !! Description
|-
|-
| 0x00 || Int16[3]['''2E'''] || '''Vertex XYZ position'''.
| 0x00 || Int16[3]['''V'''] || '''Vertex XYZ position'''.
|}
|}


===== Track Section UV Data =====
===== Track Section UV Data =====
UV data is stored as 4-byte groups per entry '''3E'''.
UV data is stored as 4-byte groups per entry '''U'''.


{|class=wikitable
{|class=wikitable
! Offset !! Type !! Description
! Offset !! Type !! Description
|-
|-
| 0x00 || Int16[2]['''3E'''] || '''Vertex UV position'''.
| 0x00 || Int16[2]['''U'''] || '''Vertex UV position'''.
|}
|}


===== Track Section Color Data =====
===== Track Section Color Data =====
Color data is stored as 2-byte groups per entry '''4E'''.
Color data is stored as 2-byte groups per entry '''C'''.


{|class=wikitable
{|class=wikitable
! Offset !! Type !! Description
! Offset !! Type !! Description
|-
|-
| 0x00 || UInt16['''4E'''] || '''RGBA5551 color'''.
| 0x00 || UInt16['''C'''] || '''RGBA5551 color'''.
|}
|}


Line 124: Line 194:
''TBD''
''TBD''


== Unknown Section 2 ==
== Culling Groups ==
''TBD''
This section includes a 4-byte or 8-byte per track section values that determine which section models are loaded when entering a specific section. Each section is represented as 1 bit.
 
{|class=wikitable
! Offset !! Type !! Description
|-
| 0x00 || UInt16['''N''']/UInt32['''N'''] || '''Culled model sections''', represented as '''N''' bits, 1 per section, in order from the least to the most significant bit. 0 if culled, 1 if loaded.
|}


== Texture Group ==
== Texture Group ==
See '''[[DKRDS Texture Group]]'''.
See '''[[DKRDS Texture Group]]'''.


== Unknown Section 3 ==
== Unknown Section 2 ==
''TBD''
''TBD''



Latest revision as of 19:18, 30 June 2024

Under Construction
This article is not finished. Help improve it by adding accurate information or correcting grammar and spelling.

DKRDS Track is the nameless file format used in Diddy Kong Racing DS that stores the tracks' section models, collision and textures. Its type identifier in assets.bin is 0x9A.

File Format

The file byte order is always little endian.

Header

The file starts with a header that is 56 bytes long.

Offset Type Description
0x00 Int32 Number of sections (N).
0x04 Int32 Track Section Group offset.
0x08 Int32 Unknown Section 1 offset.
0x0C Byte[4] Unknown. Always 0xCCCCCCCC.
0x10 Int32 Culling Groups offset.
0x14 Int32 Culling Groups data type:
  • 1 = 4-byte per N group.
  • 2 = 8-byte per N group.
0x18 Int32 Number of textures.
0x1C Int32 Texture Group offset.
0x20 Int32 Unknown Section 2 offset.
0x24 Int32 Wish Race Unknown Section entry count.
0x28 Int32 Wish Race Unknown Section offset.
0x2C Byte[4] Unknown. Seems to be some kind of flags.
0x30 Int32 Unknown.
0x34 Int32 File size.
0x38 End of header

Track Section Group

This group starts with a list of N offsets.

Track Section Header
Offset Type Description
0x00 Int32[N] Track Section Entry offsets. Relative to the start of this group.

Track Section Entry

Every section entry defines model and collision data. The entry starts with a 32-byte header.

Track Section Entry Header
Offset Type Description
0x00 Byte Unknown.
0x01 Byte Unknown. Always 5?
0x02 UInt16 Unknown.
0x04 UInt16 Number of polygon groups (P).
0x06 UInt16 Number of vertices in Track Section Vertex Data (V).
0x08 UInt16 Number of UVs in Track Section UV Data (U).
0x0A UInt16 Number of colors in Track Section Color Data (C).
0x0C Int32 Track Section Triangle Data offset.
0x10 Int32 Track Section Collision Data offset.
0x14 Int32 Track Section Vertex Data offset.
0x18 Int32 Track Section UV Data offset.
0x1C Int32 Track Section Color Data offset.
0x38 End of header, start of Track Section Data

Track Section Data

This data follows directly after the header of the section entry and starts with a 76-byte header.

Offset Type Description
0x00 Int32 Unknown. Seems to be always 0xFFFFFFFF and set to an address when loaded in memory.
0x04 Int32[3] Collision XYZ offset.
0x10 Int32[3] Visual model XYZ offset. The units are not the same as the collision offset.
0x1C UInt16[12][2] Unknown. Both 24-byte arrays seem to always be the same? They affect collision data.
0x4C End of header, start of Track Section Polygon Data
Track Section Polygon Data

This section seems to store P polygon groups' attributes.

Offset Type Description
0x00 Polygon Group Entry[P] Polygon group entries.
Polygon Group Entry

Each polygon group entry is 12 bytes long.

Offset Type Description
0x00 UInt16 First triangle ID.
0x02 UInt16 Number of triangles.
0x04 Byte Unknown.
0x05 Byte Unknown. Seems to affect collision attributes, such as the type of collision and terrain effects.
0x06 UInt16 Unknown.
0x08 Byte[4] Unknown.

The number of triangles T can be calculated by adding the first triangle ID to the number of triangles of the last polygon group entry.

Track Section Triangle Data

This section stores T triangle entries.

Offset Type Description
0x00 Triangle Entry[T] Triangle entries.
Triangle Entry

Each triangle entry is 20 bytes long.

Offset Type Description
0x00 UInt16 Texture ID.
0x02 UInt16[3] Unknown. Seems to affect the collision only. Perhaps triangle normals?
0x08 Byte[4] Vertex position indices. The index for each of the 3 vertices is 10 bits long. 2 last bits are unknown.
0x0C Byte[4] UV indices. The index for each of the 3 vertices is 10 bits long. 2 last bits are unknown.
0x10 Byte[4] Color indices. The index for each of the 3 vertices is 10 bits long. 2 last bits are unknown.
Track Section Collision Data

4-byte data per triangle (?). TBD

Track Section Vertex Data

Vertex data is stored as 6-byte groups per entry V.

Offset Type Description
0x00 Int16[3][V] Vertex XYZ position.
Track Section UV Data

UV data is stored as 4-byte groups per entry U.

Offset Type Description
0x00 Int16[2][U] Vertex UV position.
Track Section Color Data

Color data is stored as 2-byte groups per entry C.

Offset Type Description
0x00 UInt16[C] RGBA5551 color.

Unknown Section 1

TBD

Culling Groups

This section includes a 4-byte or 8-byte per track section values that determine which section models are loaded when entering a specific section. Each section is represented as 1 bit.

Offset Type Description
0x00 UInt16[N]/UInt32[N] Culled model sections, represented as N bits, 1 per section, in order from the least to the most significant bit. 0 if culled, 1 if loaded.

Texture Group

See DKRDS Texture Group.

Unknown Section 2

TBD

Wish Race Unknown Section

This section is only used for the Wish Race tracks. TBD

Tools

The following tools can handle DKRDS Track:

  • (none)