> For the complete documentation index, see [llms.txt](https://docs.bestway.com.ua/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.bestway.com.ua/foundational-knowledge/gem-rts-binary-file-formats.md).

# GEM RTS Binary File Formats

Most of the binary files in GEM RTS are chunk-based containers.

Each chunk begins with a four-byte magic identifier (FourCC), usually a human-readable combination of four ascii chars, and followed by a data block of variable or zero length.

{% hint style="warning" %}
Because these chunks do not have total size, a parser should calculate it based on a certain structure.
{% endhint %}

All multi-byte values in GEM RTS binary formats are stored in Little-endian format, where the least significant byte is stored first.

## Binary containers

<table><thead><tr><th width="135.3125">File name</th><th>Description</th></tr></thead><tbody><tr><td><code>.mesh</code></td><td>Container file that stores one or more mesh resources in <strong>.ply</strong> format.</td></tr><tr><td><code>.cmesh</code></td><td>Container file that stores one or more collision and physics mesh resources in <strong>.vol</strong> format.</td></tr><tr><td><code>.animation</code></td><td>Container file that stores one or more animation resources in <strong>.anm</strong> format.</td></tr></tbody></table>

## Binary files (legacy)

<table><thead><tr><th width="121.28125">Extension</th><th>Description</th></tr></thead><tbody><tr><td><code>.ply</code></td><td>Mesh resource.<br>In GEM RTS it is stored inside a <code>.mesh</code> container.</td></tr><tr><td><code>.anm</code></td><td><p>Animation resource.</p><p>In GEM RTS it is stored inside an <code>.animation</code> container.</p></td></tr><tr><td><code>.vol</code></td><td><p>Collision and physics mesh resource.</p><p>In GEM RTS it is stored inside a <code>.cmesh</code> container.</p></td></tr></tbody></table>

## Data types

<table><thead><tr><th>Type</th><th width="328.2109375">Description</th><th>Size</th></tr></thead><tbody><tr><td>FourCC</td><td>Chunk ID. <br>Quadruple byte magic identifier, four ASCII symbols.</td><td>4</td></tr><tr><td>int8 / uint8</td><td>Single byte signed / unsigned integer.</td><td>1</td></tr><tr><td>int16 / uint16</td><td>Double byte signed / unsigned integer.</td><td>2</td></tr><tr><td>int32 / uint32</td><td>Quadruple byte signed / unsigned integer.</td><td>4</td></tr><tr><td>float</td><td>Quadruple byte floating point number.</td><td>4</td></tr><tr><td>string8</td><td><p>Short string:</p><ul><li>uint8 length</li><li>uint8[length] symbols, <strong>no null terminator</strong>.</li></ul></td><td>1+</td></tr><tr><td>string8/24<br>or<br>string24</td><td><p>Smart long string.<br>For short strings, where length is less than 255, the structure is the same as string8.<br>If length is greater than or equal to 255:</p><ul><li>uint8 signature 0xFF</li><li>uint24 long_length</li><li>uint8[long_length] symbols, <strong>no null terminator.</strong></li></ul></td><td>1+</td></tr><tr><td>string32</td><td><p>Legacy format:</p><ul><li>uint32 long_length</li><li>uint8[long_length] symbols, <strong>no null terminator</strong>.</li></ul></td><td>4+</td></tr></tbody></table>

## Other conventions

| **Convention**     | **Description**                                                                                                                           |
| ------------------ | ----------------------------------------------------------------------------------------------------------------------------------------- |
| struct             | Nested data structure.                                                                                                                    |
| `<type>[<number>]` | Fixed-size array of type `<type>` containing `<number>` elements.                                                                         |
| `<type>[<name>]`   | Variable-size array of type `<type>`. The number of elements is specified by the value stored in field `<name>`.                          |
| `unorm8`           | Representation of fractional floating-point values in the range \[0..1] using an 8-bit unsigned integer (`uint8`) in the range \[0..255]. |
| Little-endian      | Byte order convention used for multi-byte integer values. The least significant byte is stored first.                                     |
