Indigo Mesh File Format Specification

This is the Indigo Mesh format, which has the extension .igmesh on disk.

See IndigoMesh.h in the SDK for code to read and write this structure.

Notes:
uint32 is an unsigned 32 bit integer.
Byte order is little endian (Intel byte order).
Struct a[9] means that 'a' is an array of 9 'Struct's.

Specification

uint32 MAGIC_NUMBER // = 5456751

uint32 FORMAT_VERSION // = 4

uint32 compression // = 1 if Zstandard compression is used, 0 otherwise.

uint32 data_filtering // = 1 if data is filtered before compression, 0 otherwise.

uint32 num_uv_mappings // Number of UV mappings (UV layers) for this mesh. >= 0

uint32 num_material_names
String used_material_names[num_material_names] // Only used for old <model> scene format, not used for new <model2> scene format where materials are specified in the model2 element. num_material_names may be set to zero.

String format on disk is:

uint32 len // num bytes in string. <= 1024
char string_bytes[len] // data

The string is a Unicode string with UTF-8 encoding.

uint32 num_vert_positions
Vec3f vert_positions[num_vert_positions] // An array of vertex positions. Each vertex position is a single precision, floating-point 3-vector.

uint32 num_vert_normals
Vec3f vert_normals[num_vert_normals] // An array of vertex shading normals. This array can be empty if vertex shading normals are not available. If it is not empty then num_vert_normals should be equal to num_vert_positions.

uint32 uv_layout // Should be either MESH_UV_LAYOUT_VERTEX_LAYER (0) or MESH_UV_LAYOUT_LAYER_VERTEX (1).
Vec2f uv_pairs[num_uv_mappings*n]

An array of UV coordinates. The number of pairs must be a multiple of num_uv_mappings.
This array can be laid out in two possible ways.

MESH_UV_LAYOUT_VERTEX_LAYER UV layout is as follows (in this example num uvs = n, num layers = 2):

uv_0 layer 0
uv_0 layer 1

uv_1 layer 0
uv_1 layer 1

uv_2 layer 0
uv_2 layer 1

...

uv_n layer 0
uv_n layer 1

MESH_UV_LAYOUT_LAYER_VERTEX UV layout is as follows (in this example num uvs = n, num layers = 2):

layer 0 uv_0
layer 0 uv_1
layer 0 uv_2
layer 0 uv_3
...
layer 0 uv_n

layer 1 uv_0
layer 1 uv_1
layer 1 uv_2
layer 1 uv_3
...
layer 1 uv_n

uint32 num_triangles
Triangle triangles[num_triangles]

Where a triangle is defined as:

struct Triangle
{
uint32 vertex_indices[3]; /// Stores indices into the mesh vertex position array.
uint32 uv_indices[3]; /// Stores indices into the mesh uv_pairs array.
uint32 tri_mat_index; /// An index into the materials used by this mesh.
};

uint32 num_quads
Quad quads[num_quads]

Where a quad is defined as:

struct Quad
{
uint32 vertex_indices[4]; /// Stores indices into the mesh vertex position array.
uint32 uv_indices[4]; /// Stores indices into the mesh uv_pairs array.
uint32 mat_index; /// An index into the materials used by this mesh.
};