gltforge_unity_core/unity_mesh.rs
1use crate::unity_submesh::UnitySubMesh;
2
3/// A Unity-shaped glTF mesh: one shared vertex array with N sub-meshes (one per glTF primitive).
4/// Maps directly to a `UnityEngine.Mesh` with `subMeshCount` sub-meshes.
5pub struct UnityMesh {
6 /// Mesh name. Falls back to the glTF mesh index if the source mesh is unnamed.
7 pub name: String,
8
9 /// All vertex positions across all primitives, concatenated.
10 /// Left-handed coordinate system (X negated relative to glTF).
11 /// Tightly packed `[x, y, z]` floats — maps to `mesh.vertices`.
12 pub vertices: Vec<[f32; 3]>,
13
14 /// Vertex normals, same length as `vertices`. Empty if the source mesh has no normals.
15 /// Left-handed coordinate system (X negated relative to glTF).
16 /// Tightly packed `[x, y, z]` floats — maps to `mesh.normals`.
17 pub normals: Vec<[f32; 3]>,
18
19 /// Vertex tangents, same length as `vertices`. Empty if the source mesh has no tangents.
20 /// Left-handed coordinate system (X and W negated relative to glTF).
21 /// Tightly packed `[x, y, z, w]` floats — maps to `mesh.tangents`.
22 pub tangents: Vec<[f32; 4]>,
23
24 /// UV channels, densely packed from channel 0.
25 /// `uvs[k]` holds all vertices for `TEXCOORD_k` (V-flipped for Unity's bottom-left origin).
26 /// Only channels present on every primitive are included; the vec stops at the first absent channel.
27 /// Maps to `mesh.SetUVs(k, uvs[k])`.
28 pub uvs: Vec<Vec<[f32; 2]>>,
29
30 /// One sub-mesh per glTF primitive — maps to `mesh.SetTriangles(tris, submeshIndex)`.
31 pub sub_meshes: Vec<UnitySubMesh>,
32}