upgraded to 0.7.0

This commit is contained in:
2021-02-14 14:37:58 -08:00
parent a7c74fc47e
commit 60ab3bebd8
4 changed files with 109 additions and 86 deletions

View File

@@ -19,18 +19,12 @@ pub fn vertex(pos: [f32; 3], nor: [f32; 3]) -> Vertex {
}
pub fn import_mesh(mesh_path: &str) -> (Vec<Vertex>, Vec<u32>) {
//let obj_file = "/home/mrh/source/3d-min-viable-eng/resources/Tree_01.obj";
//let mtl_file = "/home/mrh/source/3d-min-viable-eng/resources/Tree_01.mtl";
let (models, materials) = tobj::load_obj(mesh_path, false).expect("Failed to load file");
//let q = tobj::load_mtl(mtl_file).unwrap();
let (models, materials) = tobj::load_obj(mesh_path, false).expect("Failed to load file");
println!("# of models: {}", models.len());
println!("# of materials: {}", materials.len());
//let model = models.get(2).unwrap();
//let mesh = &model.mesh;
let mut index_data : Vec<u32> = Vec::new();
let mut vertex_data = Vec::new();
@@ -44,13 +38,10 @@ pub fn import_mesh(mesh_path: &str) -> (Vec<Vertex>, Vec<u32>) {
for i in face_indices {
index_data.push(*i);
}
//println!(" face[{}] = {:?}", f, face_indices);
next_face = end;
}
// Normals and texture coordinates are also loaded, but not printed in this example
//println!("model[{}].vertices: {}", i, mesh.positions.len() / 3);
assert!(mesh.positions.len() % 3 == 0);
for v in 0..mesh.positions.len() / 3 {
@@ -68,7 +59,6 @@ pub fn import_mesh(mesh_path: &str) -> (Vec<Vertex>, Vec<u32>) {
));
}
}
//println!("{:?}\n\n\n\n\n {:?}", vertex_data, index_data);
(vertex_data.to_vec(), index_data.to_vec())
}