From c76931ebfd762730c2f27ae93763e190b2dcda8b Mon Sep 17 00:00:00 2001 From: nokonoko1203 Date: Thu, 14 Dec 2023 11:24:12 +0900 Subject: [PATCH] assign vertex ids buffer --- nusamai-gltf/examples/object_to_gltf.rs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/nusamai-gltf/examples/object_to_gltf.rs b/nusamai-gltf/examples/object_to_gltf.rs index bc6435485..7c35ef72c 100644 --- a/nusamai-gltf/examples/object_to_gltf.rs +++ b/nusamai-gltf/examples/object_to_gltf.rs @@ -289,9 +289,11 @@ fn make_gltf_json(triangles: &Triangles) -> String { fn make_binary_buffer(triangles: &Triangles) -> Vec { let indices = &triangles.indices; let vertices = &triangles.vertices; + let vertex_ids = &triangles.vertex_ids; let mut indices_buf = Vec::new(); let mut vertices_buf = Vec::new(); + let mut vertex_ids_buf = Vec::new(); // glTFのバイナリはリトルエンディアン for index in indices { @@ -306,7 +308,14 @@ fn make_binary_buffer(triangles: &Triangles) -> Vec { } } - [&indices_buf[..], &vertices_buf[..]].concat() + if let Some(vertex_ids) = vertex_ids { + for vertex_id in vertex_ids { + vertex_ids_buf + .write_u64::(*vertex_id) + .unwrap(); + } + } + [&indices_buf[..], &vertices_buf[..], &vertex_ids_buf[..]].concat() } fn tessellation(