Skip to main content

Module scene

Module scene 

Source
Expand description

The scene chunk: the tree of nodes that places the meshes (SPEC.md, section 5).

A Scene names everything by index, as the chunk does: meshes in the order of the file’s mesh chunks, and nodes in the order they are listed, which is how other chunks name them. A mesh several leaves show is one index they share, stored once.

Nodes are listed children first: a node names only nodes listed before it, and a reference only a subtree whose root is, so no node can contain itself. Each node has at most one place: a group’s child, a root, or a subtree’s root. The decoder refuses a payload that breaks these rules, and the encoder a scene that does, so it never writes one a reader must refuse.

metadata    u8 0 | 1, then name and comment (u8 0 | 1, u32 length, UTF-8)
meshes      u32 number of mesh chunks
resources   u32 count, then u32 mesh per mesh resource
records     u32 count, then per record a u8 kind:
              0 group      node, u32 count, u32 child nodes
              1 leaf       node, u32 mesh
              2 leaf       node, u32 mesh resource
              4 reference  node, u32 subtree
              5 subtree    u32 node, the root of the next subtree
            where node is its metadata, then its transform:
            u8 0 (identity) | 1 and 12 f64 (rows of the linear part, then
            the translation)
roots       u32 count, u32 nodes

Structs§

Node
A node of the scene.
Scene
A scene: the meshes, and the nodes that place them.
Transform
An affine transform: a point p goes to linear · p + translation.

Enums§

DecodeSceneError
Why a scene payload could not be decoded.
EncodeSceneError
Why a scene could not be encoded.
NodeKind
What a node is.

Constants§

SCENE_TAG
The tag of the scene chunk.
SCENE_VERSION
The scene payload layout this build writes and reads.

Functions§

decode_scene
Decodes a scene chunk payload over the meshes of the file’s mesh chunks, in file order.
encode_scene
Encodes scene as a scene chunk payload. Its meshes go in mesh chunks of their own, in order.