Skip to content

Instantly share code, notes, and snippets.

@xycaleth
Created April 15, 2019 18:39
Show Gist options
  • Save xycaleth/c9c1e6a5294b82184fd802f4148cf439 to your computer and use it in GitHub Desktop.
Save xycaleth/c9c1e6a5294b82184fd802f4148cf439 to your computer and use it in GitHub Desktop.
Ghoul2 file formats

Ghoul 2 formats

Model format

GLM is the Ghoul2 model format. Meshes/surfaces in the model are arranged in a hierarchy, starting from the torso going outwards, to make it easy to not render whole parts of the model, e.g. limbs.

LODs are built into the model format.

Header

type name description
int32 ident Always MD3
int32 version Always 2
char[MAX_QPATH] name Full model path
char[MAX_QPATH] animName Animation file name
int32 animIndex Unused
int32 numBones Number of bones
int32 numLODs Number of LODs
int32 ofsLODs Byte offset from start of file to the beginning of the LOD data
int32 numSurfaces Number of surfaces
int32 ofsSurfHierarchy Byte offset from start of file to beginning of surface hierarchy data
int32 ofsEnd Byte offset from start of file to end of file

Surface hierarchy

At the start of fileBase + header.ofsSurfHierarchy is the surface hierarchy data. The data in this section is split into its own header and the list of surface data.

The header is a list of byte offsets of size header.numSurfaces. Following this is the list of surface data:

type name description
char[MAX_QPATH] name Surface name
uint32 flags Flags
char[MAX_QPATH] shader Shader path
int32 shaderIndex Unused
int32 parentIndex Index of parent surface, or -1 if this is the root surface
int32 numChildren Number of child surfaces
int32[numChildren] childIndexes Variable-sized list of child surface indexes

LOD models

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment