Gaffer Docs

GAM - Mesh File Format

GAM is a binary file format which contains 3D mesh data like vertices, triangles, texture coordinates, etc. Each file has a fixed header, followed by vertex, padding, and triangle data, followed by a CRC32 for the entire file up to the CRC.

File Sections

Fixed Header 16 bytes
Vertex Data Variable size. 'Vertex Count' from fixed header multiplied by size of vertices. Depends on vertex type, see below.
Padding Variable size, 0-7 bytes. Ensures triangle data starts on 8 byte boundary.
Triangle Data Variable size. 'Triangle Count' from fixed header multipled by size of triangles (6 bytes, 3 vertex indices * 2 bytes per index)
CRC32 4 bytes. CRC32 is computed for entire file except for this 4 byte section.

Fixed Header Details

Size (bytes) Purpose
4 LE Signature: 0x1a47414d ("GAM\x1a")
1 File format version number. Currently should always be 1.
1 Vertex type:
  • 'A' = Position Only
  • 'B' = Position, Texture
  • 'C' = Position, Texture, Normal
  • 'D' = Position, Texture, Normal, Tangent
2 Vertex Count (unsigned short)
2 Triangle Count (unsigned short)
6 Reserved for future use

Triangle Front Face Orientation

Triangle vertex indices are specified in OpenGL default counter-clockwise orientation.

Vertex Types

Vec3 used below are comprised of 3 32 bit floats for x, y, z coords.