summaryrefslogtreecommitdiff
path: root/doc/SCENE_FORMAT.md
blob: fcf5e16d987165b656af28f49ce05b59b3c9cd4b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# Scene Binary Format (SCN1)

Binary format for 3D scenes exported from Blender.

## File Layout

- **Extension:** `.bin` or `.scene`
- **Endianness:** Little Endian
- **Structure:** Header + Object Blocks

## Format Specification

```cpp
// Header (16 bytes)
struct Header {
  char magic[4];        // "SCN1"
  uint32_t num_objects;
  uint32_t num_cameras; // Reserved
  uint32_t num_lights;  // Reserved
};

// Object Block (repeated num_objects times)
struct ObjectBlock {
  char name[64];        // UTF-8, null-padded
  uint32_t type;        // ObjectType enum
  vec3 position;        // 12 bytes
  quat rotation;        // 16 bytes (x, y, z, w)
  vec3 scale;           // 12 bytes
  vec4 color;           // 16 bytes (r, g, b, a)
  uint32_t mesh_len;    // Mesh name length (N)
  char mesh_name[N];    // If N > 0
  float mass;
  float restitution;
  uint32_t is_static;   // 0=Dynamic, 1=Static
};
```

### Object Types

```cpp
enum class ObjectType {
  CUBE = 0, SPHERE = 1, PLANE = 2, TORUS = 3,
  BOX = 4, SKYBOX = 5, MESH = 6
};
```

## Asset Resolution

Mesh names (e.g., "MESH_CUBE") resolve to runtime `AssetId` via `GetAssetIdByName`.