> 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/binary-file-containers-.mesh-.cmesh-.animation.md).

# Binary file containers (.mesh, .cmesh, .animation)

Files **.mesh**, **.cmesh**, and **.animation** are containers designed to store multiple files of the same type within a single binary file. The primary purpose of these containers is to reduce the number of individual files in the file system and improve resource loading performance.

Data inside a container is organized as a sequence of chunks. Each chunk begins with a four-character identifier (FourCC, Chunk ID), which defines the type of data stored in the chunk.

The container includes a file table, where each file is represented by its name and `data_offset`.

The size of each file inside the container, except the last one, is determined by the following formula:

```
data_size = entries[N + 1].data_offset - entries[N].data_offset
```

For the last file in the container, its end coincides with the end of the container.

When reading a file, the parser processes chunks sequentially and determines their type by the FourCC value.

{% hint style="danger" %}
Encountering an unknown FourCC value is considered a fatal error. The parser must not skip unknown chunks.
{% endhint %}

**Data structure**

```
PMSH | ANIM | CMHR
MTBL
   entry_count
   entries[entry_count]
       entry_name
       data_offset
   resources[entry_count]
       MESH | EANM | EVLM
           resource_data
```

## Container identifiers

<table><thead><tr><th width="105.73046875">FourCC</th><th width="121.22265625">Type</th><th>Description</th></tr></thead><tbody><tr><td><code>PMSH</code></td><td>uint8[4]</td><td>Mesh container. <br>Contains <code>.ply</code> resources.</td></tr><tr><td><code>ANIM</code></td><td>uint8[4]</td><td>Animation container. <br>Contains <code>.anm</code> resources.</td></tr><tr><td><code>CMHR</code></td><td>uint8[4]</td><td>Physics and collision volume container. <br>Contains <code>.vol</code> resources.</td></tr></tbody></table>

## Chunk `MTBL`

Contains a list of all files stored inside the container, as well as offsets to the corresponding data.

**Data structure**

```
MTBL
   entry_count
   entries[entry_count]
       entry_name
       data_offset
   resources[entry_count]
```

<table><thead><tr><th width="121.75390625">Name</th><th width="176.37109375">Type</th><th width="88.15234375">Size</th><th>Description</th></tr></thead><tbody><tr><td>FourCC</td><td>uint8[4]</td><td>4</td><td><code>MTBL</code></td></tr><tr><td>entry_count</td><td>uint32</td><td>4</td><td>Number of entries in the table</td></tr><tr><td>entries</td><td>struct[entry_count]</td><td></td><td>Array of container entries</td></tr></tbody></table>

### Container entry array (struct)

<table><thead><tr><th width="130.69921875">Name</th><th width="93.1171875">Type</th><th width="76.21875">Size</th><th>Description</th></tr></thead><tbody><tr><td>entry_name</td><td>string8</td><td>1+</td><td>Entry name</td></tr><tr><td>data_offset</td><td>uint32</td><td>4</td><td>Offset of the resource data. It’s relative, the end of the <code>MTBL</code> chunk is considered as 0.</td></tr></tbody></table>

## Chunk `MESH`

Contains data in the **.ply** format.

<table><thead><tr><th width="107.140625">Name</th><th width="110.5546875">Type</th><th>Description</th></tr></thead><tbody><tr><td>FourCC</td><td>uint8[4]</td><td><code>MESH</code></td></tr><tr><td>ply_data</td><td>.ply</td><td>Mesh data in the <strong>.ply</strong> format.</td></tr></tbody></table>

## Chunk `EANM`

Contains data in the **.anm** format.

<table><thead><tr><th width="123.5703125">Name</th><th width="112.66796875">Type</th><th>Description</th></tr></thead><tbody><tr><td>FourCC</td><td>uint8[4]</td><td><code>EANM</code></td></tr><tr><td>anm_data</td><td>.anm</td><td>Animation data in the <strong>.anm</strong> format.</td></tr></tbody></table>

## Chunk `EVLM`

Contains data in the **.vol** format.

<table><thead><tr><th width="107.9296875">Name</th><th width="99.33984375">Type</th><th>Description</th></tr></thead><tbody><tr><td>FourCC</td><td>uint8[4]</td><td><code>EVLM</code></td></tr><tr><td>vol_data</td><td>.vol</td><td>Volume data in the <strong>.vol</strong> format.</td></tr></tbody></table>
