Skip to main content

draco_io/
fbx_node.rs

1//! The FBX document tree: what both containers decode to and encode from.
2//!
3//! An FBX document is a tree of named records, each carrying a list of typed
4//! properties and a list of children. Nothing above this file needs to know
5//! whether those records arrived as binary node records or as ASCII text, and
6//! nothing below it needs to know what `Objects` or `Connections` mean.
7//!
8//! This lives apart from either container because the two halves of the crate
9//! are independently selectable: [`crate::fbx_container`] is behind
10//! `fbx-reader`, [`crate::fbx_writer`] behind `fbx-writer`, and a type they
11//! both name cannot sit inside either.
12
13/// An FBX node with properties and children.
14#[derive(Debug, Clone)]
15pub struct FbxNode {
16    /// Node name, such as `Objects`, `Geometry`, `Model`, or `Connections`.
17    pub name: String,
18    /// Properties stored directly on this node.
19    pub properties: Vec<FbxProperty>,
20    /// Child nodes nested under this node.
21    pub children: Vec<FbxNode>,
22}
23
24/// FBX property value.
25#[derive(Debug, Clone)]
26pub enum FbxProperty {
27    /// Boolean property.
28    Bool(bool),
29    /// Single-byte `Z` property, kept unsigned.
30    ///
31    /// The reverse-engineered specification calls `Z` a signed `i8`, while
32    /// `ufbx` -- the de-facto compatibility oracle, and what Blender ships --
33    /// reads all of `B`, `C` and `Z` as unsigned bytes. This follows `ufbx`.
34    U8(u8),
35    /// 16-bit signed integer property.
36    I16(i16),
37    /// 32-bit signed integer property.
38    I32(i32),
39    /// 64-bit signed integer property.
40    I64(i64),
41    /// 32-bit floating-point property.
42    F32(f32),
43    /// 64-bit floating-point property.
44    F64(f64),
45    /// UTF-8-ish string property decoded lossily from FBX bytes.
46    String(String),
47    /// Raw binary property.
48    Raw(Vec<u8>),
49    /// Boolean array property.
50    BoolArray(Vec<bool>),
51    /// 32-bit signed integer array property.
52    I32Array(Vec<i32>),
53    /// 64-bit signed integer array property.
54    I64Array(Vec<i64>),
55    /// 32-bit floating-point array property.
56    F32Array(Vec<f32>),
57    /// 64-bit floating-point array property.
58    F64Array(Vec<f64>),
59}