[Home]GameInfo/GK3Files

HomePage | GameInfo | RecentChanges | Preferences | TableOfContents | AboutTheWiki

The Files of Gabriel Knight 3

There's lots of different file types that GK3 uses. Some are custom and some are standard. Here's a short list with short descriptions:

Extension Format Description
ACT ? Script for animation? Streaming, therefore ZLib compressed within barns
ANM Text Animation?
BMP Binary Bitmap, though GK3 uses a custom format, so these aren't Windows bitmaps
BSP Binary BSP vertex data, though not much is known about the specifics of this format
DOC Binary Word document
EXE Binary Windows executable
GAS Text GEngine auto script
HTML Text Standard HTML file (used for Sydney)
MOD Binary Possibly model data?
MOM ? ???
MP3 Binary MP3 file
MUL Binary Some type of lightmap file
NVC Text Noun verb case file
SCN Text Scene file
SEQ Text ???
SHP Binary Sheep script file
SIF Text Scene initialization file
STK Text Sound track file
TXT Text Plain old ASCII text file
YAK Text Dialog file (used for subtitles)
WAV Binary WAV data, though might use MP3 compression

It should be noted that the character's spoken dialog is all WAV data but the files do not have a .wav extension.

Bitmaps

All bitmaps in GK3 have the following format:

Offset Size Type Description
0 4 4cc? Some type of bitmap identifier; should be "61nM"
4 2 unsigned short Height of the image
6 2 unsigned short Width of the image
8 2 unsigned short pixels ...

The pixels are stored in RGB565 format. They are not stored upside down like in a Windows bitmap. If the width of the bitmap is odd then there will be an extra pad byte at the end of each row.

ACT files

ACT files are used for cutscene animation. They're binary, so not much is known about this format yet. It appears to have a header and then many sections. Here is the header:

Offset Size Type Description
0 4 4cc? Some type of identifier; should be "HTCA"
4 4 unsigned int Version?
8 4 unsigned int Number of entries
12 4 unsigned int Unknown (seems to frequently be "1")
16 4 unsigned int Total size of data section
20 32 string Character that uses the animation?

After this header is an array of offsets to the data entries.

Offset Size Type Description
? 4 unsigned int Offset

Here's the format of the data sections:
Offset Size Type Description
? 2 unsigned int ?
? + 2 2 unsigned int Size of data section?
? + 4 2 unsigned int ?

The rest of the data section is unknown.

MOD files

The MOD files are the 3D models used throughout the game. Not much is known about this format, and all this information should be taken with several grains of salt as it little more than just a guess.

Offset Size Type Description
0 4 4cc? Some type of identifier; should be "LDOM"
4 1 unsigned byte Minor version of header
5 1 unsigned byte Major version of header
6 2 unsigned short Unknown
8 4 unsigned int Number of meshes
12 4 unsigned int Total size of data section?
16 4 float? Unknown
20 4 unsigned int? Unknown

There is also a v1.09 header that contains this additional info:

Offset Size Type Description
? 4 unsigned int Unknown
? + 4 4 unsigned int Unknown
? + 8 4 unsigned int Unknown
? + 12 4 unsigned int Unknown
? + 16 4 unsigned int Unknown
? + 20 4 unsigned int Unknown

After this header is the MESH section:

Offset Size Type Description
? 4 4cc "HSEM"
? + 4 4 float Transformation coord? X1?
? + 8 4 float Transformation coord? Y1?
? + 12 4 float Transformation coord? Z1?
? + 16 4 float Transformation coord? X2?
? + 20 4 float Transformation coord? Y2?
? + 24 4 float Transformation coord? Z2?
? + 28 4 float Transformation coord? X3?
? + 32 4 float Transformation coord? Y3?
? + 36 4 float Transformation coord? Z3?
? + 40 4 float Transformation coord? X4?
? + 44 4 float Transformation coord? Y4?
? + 48 4 float Transformation coord? Z4?
? + 52 4 unsigned int Number of sections?
? + 56 4 float Bounding box coord (x1?)
? + 60 4 float Bounding box coord (y1?)
? + 64 4 flaot Bounding box coord (z1?)
? + 68 4 float Bounding box coord (x2?)
? + 72 4 float Bounding box coord (y2?)
? + 76 4 float Bounding box coord (z2?)

Here begins the mesh sections.

Offset Size Type Description
? 4 4cc? Section type? ("PRGM")
? + 4 32 string Texture file
? + 36 4 unsigned int Unknown
? + 40 4 unsigned int # faces?
? + 44 4 unsigned int # verticies
? + 48 4 unsigned int # triangles
? + 52 4 unsigned int? # LOD levels?
? + 56 4 unsigned int? Unknown

After this comes an array of vertex data:

Offset Size Type Description
? 4 float x
? + 4 4 float y
? + 8 4 float z

Followed by what looks like an array of normal coordinates:

Offset Size Type Description
? 4 float x
? + 4 4 float y
? + 8 4 float z

Followed by an array of texture coordinates:

Offset Size Type Description
? 4 float u
? + 4 4 float v

Next seems to be the triangle connectivity information in groups of 3 with a 0 between each group. After that are some LOD sections, denoted by LODK. After all the meshes there is sometimes a XDOM section with multiple XPRG sections. There seems to be the same number of XPRG's as there are PRGM's. My guess is that these are some kind of extension to the file format, and contains additional data about each group. What that data is I don't know. It might be extra triangle connectivity between groups, or maybe boning info.

More info to come...

BSP Files

The .bsp files store the room vertex data. They're serialized BSP trees. It appears that the data comes several main sections. The first section is the header. The second is an array of models. Each model defines a different action (clicking on a polygon that is part of a model "door" will present the verb options for a door, for example). These are not actual "models," they only represent groups of polygons.

This is the header:
Offset Size Type Description
0 4 4cc Appears as NECS in file
4 4 unsigned int Version (usually appears as 0x202)
8 4 unsigned int Filesize - header size
12 4 unsigned int Index of root node
16 4 unsigned int Number of models
20 4 unsigned int Number of verticies
24 4 unsigned int Number of texture coords
28 4 unsigned int Number of vertex indicies
32 4 unsigned int Number of texture vertex indicies
36 4 unsigned int Number of surfaces
40 4 unsigned int Number of planes
44 4 unsigned int Number of nodes
48 4 unsigned int Number of polygons

Next comes an array of models. The number of models in the header tells how many models there are:
Offset Size Type Description
? 32 string Name of the surface type

This is followed by an array of surfaces. Surfaces describe texture info. The number of surfaces in the header tells how many surfaces there are:
Offset Size Type Description
? 4 unsigned int The index of the model this surface belongs to
? + 4 32 string Texture for this surface
? + 36 4 float U texture coord
? + 40 4 float V texture coord
? + 44 4 float U texture scale
? + 48 4 float V texture scale
? + 52 4 float Size?
? + 56 4 unsigned int Flags

This is followed by an array of nodes. These nodes make up the actual BSP tree. Their number is defined in the header.
Offset Size Type Description
? 2 unsigned short Index of child node?
? + 2 2 unsigned short Index of child node?
? + 4 2 unsigned short Plane index
? + 6 2 unsigned short Starting index of polygons
? + 8 2 unsigned short Unknown
? + 10 2 unsigned short Number of polys in this node
? + 12 2 unsigned short Unknown
? + 14 2 unsigned short Unknown

Next is an array of polygons. The polygons work by defining the number of verticies in the polygon and the offset to the index array where the polygon begins. The number of polygons is defined in the header.
Offset Size Type Description
? 2 unsigned short Index of vertex coord
? + 2 2 unsigned short Flags?
? + 4 2 unsigned short Number of verticies
? + 6 2 unsigned short Index of surface

Next is the array of planes. Planes are defined using the traditional plane equation.
Offset Size Type Description
? 4 float x
? + 4 4 float y
? + 8 4 float z
? + 12 4 float d

Next is the array of verticies.
Offset Size Type Description
? 4 float x
? + 4 4 float y
? + 8 4 float z

Next is the array of texture verticies.
Offset Size Type Description
? 4 float u
? + 4 4 float v

Next is the array of vertex indicies.
Offset Size Type Description
? 2 unsigned short Index

Next is the array of texture vertex indicies.
Offset Size Type Description
? 2 unsigned short Index

Next is an array of bounding spheres. The size of this array is equal to the number of nodes defined in the header.
Offset Size Type Description
? 4 float X?
? + 4 4 float Y?
? + 8 4 float Z?
? + 12 4 float radius?

Version 1.02 and up have an array of the following structure:
Offset Size Type Description
? 4 float Bounding sphere X
? + 4 4 float Bounding sphere Y
? + 8 4 float Bounding sphere Z
? + 12 4 float Bounding sphere radius
? + 16 4 float Chrome value
? + 20 4 float Grazing value
? + 24 4 COLORREF Chrome color
? + 28 4 unsigned int Number of indicies
? + 32 4 unsigned int Number of triangles

Following each element in this array are two arrays:
Offset Size Type Description
? 2 unsigned short Vertex indicies[number of indicies]
And
Offset Size Type Description
? 2 unsigned short Triangles[number of triangles * 3]

MUL Files

The MUL files contain lightmap data.

The first section is a header.
Offset Size Type Description
0 4 4cc "TLUM"
4 4 unsigned int Number of surfaces

Next comes an array of standard 24-bit Windows bitmaps.

TODO

The text files should be relativly easy to decode, but the binary files, like the BSP, MOD, and SHP formats might be pretty difficult. Any help on these formats would be greatly appreciated.

HomePage | GameInfo | RecentChanges | Preferences | TableOfContents | AboutTheWiki
This page is read-only | View other revisions
Last edited July 2, 2006 6:58 pm CDT by c-71-226-79-33.hsd1.ms.comcast.net (diff)
Search:
Creative Commons License
All articles licensed under a Creative Commons License.