Talk:Project Gotham Racing 2
Reverse engineering notes for file formats
--Zaykho (talk) 10:34, 22 September 2017 (PDT)
Project Gotham Racing 2 use a .PAK container for storing 3D elements, textures and 3D configurations files.
Multiple types of .PAK name can be seen in PGR2, their names are related to their functions and indicate what type of elements are stored:
.PAK for objects ( Cache\Objects & Cache\Cars )
.pak
.PAK for cars ( Cache\Cars )
.pak_cth
.pak_hrd
.pak_opn ( only for roadster : open mode)
.pak_sft ( only for roadster : closed mode for rain)
.PAK for maps ( Game\Areas )
.pak_common
.pak_day
.pak_night
.pak_overcast
.pak_stream (This uses a non-standard PAK format)
To extract those .PAK files, a tool called quickbms and a PGR2 bms script ( both made by Luigi Auriemma ) can be used to get most of the contents stored in the archive.
When extracted, the content stored in the archive is sliced in sections, creating a folder for each of them and joining a file with the actual contents in it, mostly with a .dat suffix.
Here an example for objects:
.PAK for object : red_cone.pak
WMSH \ 00000000.dat
MAT \ 00000001.dat
GPUD \ 00000002.dat
TEXT \ 00000003.nfc
VB \ 00000004.dat
END ( nothing, no folder, no files )
PAK File format
The PAK format is a chunked format. Each chunk starts with:
- u32 chunk-type (can be interpreted as 4 byte ASCII magic)
- u32 unknown
- u32 size of chunk (excluding this field?)
The chunk can contain compressed or uncompressed data. Compression is probably indicated by the upper bits of the size (0xC0000000) being set.
Compression seems to be with a zlib header (0x78, 0xDA
).
Data can be inline, directly following the header. However, in INDX chunks, the data is pointed to by an extra u32 field after each header.
INDX
- u32: number of chunks
- array of chunk headers, each with additional u32 field pointing to the data
- array of chunk data
WMSH
The 00000000.dat file contain the faces indices, and supposedly, the strip and the how the vertices are read ( float, word ? ).
MESH
Same as WMSH?
MAT
Material properties
The 00000001.dat file contain the material properties : diffuse, specular, ambient etc... of each material applied to the 3D file.
SKY
WRAP
INST
Header has some field set to != 0. Seems to contain subchunks which end with "END" chunk?
TIME
RCAM
ANIC
ROUT
RPRM
RTMP
GPUD
GPUS
TEX
LGHT
ACT
INFO
DRVP
AUDI
TVC
END
Marks the end of the file. Can also be inside a file and might mark the end of a subchunk there?
GPUD
GPU Data?
The 00000002.dat file contain all the textures, each of them followed by a small part of data ( texture configuration ? mipmaps ? ). Finally, after all the textures, the vertices and UV position are stored in one chunk of data.
TEXT
Texture information
The 00000003.dat file contain all the text and name related to the texture, it also indicate where each textures are located inside GPUD.
VB
Vertex buffer information
The 00000004.dat file contain the start address offset of the vertices and UV section in the GPUD. If the 3D mesh have multiples groups/sections, the VB file will store each address.