Skip to content

Commit

Permalink
assign vertex ids buffer
Browse files Browse the repository at this point in the history
  • Loading branch information
nokonoko1203 committed Dec 14, 2023
1 parent 8173859 commit c76931e
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion nusamai-gltf/examples/object_to_gltf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -289,9 +289,11 @@ fn make_gltf_json(triangles: &Triangles) -> String {
fn make_binary_buffer(triangles: &Triangles) -> Vec<u8> {
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 {
Expand All @@ -306,7 +308,14 @@ fn make_binary_buffer(triangles: &Triangles) -> Vec<u8> {
}
}

[&indices_buf[..], &vertices_buf[..]].concat()
if let Some(vertex_ids) = vertex_ids {
for vertex_id in vertex_ids {
vertex_ids_buf
.write_u64::<LittleEndian>(*vertex_id)
.unwrap();
}
}
[&indices_buf[..], &vertices_buf[..], &vertex_ids_buf[..]].concat()
}

fn tessellation(
Expand Down

0 comments on commit c76931e

Please sign in to comment.