gltforge_unity/mesh.rs
1/// A glTF mesh converted into Unity's left-handed coordinate system,
2/// ready to be assigned to a `UnityEngine.Mesh`.
3pub struct UnityMesh {
4 /// Derived name for `UnityEngine.Mesh.name`.
5 pub name: String,
6
7 /// All vertex positions concatenated across every primitive (left-handed, X negated).
8 /// Tightly packed `[x, y, z]` floats.
9 pub positions: Vec<[f32; 3]>,
10
11 /// One submesh per glTF primitive. All indices are absolute into `positions`.
12 pub submeshes: Vec<UnitySubmesh>,
13}
14
15/// A single submesh, corresponding to one glTF primitive.
16pub struct UnitySubmesh {
17 /// Triangle indices with winding order reversed for Unity's left-handed convention.
18 /// Format is shared across all submeshes and determined by total vertex count.
19 pub indices: UnityIndices,
20}
21
22/// Index buffer format, selected once based on total vertex count across all primitives.
23pub enum UnityIndices {
24 /// Used when `total_vertex_count <= 65535`. Maps to Unity's `IndexFormat.UInt16`.
25 U16(Vec<u16>),
26 /// Used when `total_vertex_count > 65535`. Maps to Unity's `IndexFormat.UInt32`.
27 U32(Vec<u32>),
28}