use std::env;
use std::process;
use rust_usd::Stage;
fn main() {
let path = env::args().nth(1).unwrap_or_else(|| {
eprintln!("usage: dump_meshes <path-to-usd-file>");
process::exit(2);
});
let stage = Stage::open(&path).unwrap_or_else(|e| {
eprintln!("failed to open stage: {}", e.what());
process::exit(1);
});
let meshes = stage.meshes();
if meshes.is_empty() {
println!("(no UsdGeomMesh prims in {})", path);
return;
}
for mesh in meshes {
println!("mesh: {}", mesh.prim_path());
println!(" subdivision: {}", mesh.subdivision_scheme());
let pts = mesh.points();
println!(" points: {} floats ({} verts)", pts.len(), pts.len() / 3);
let counts = mesh.face_vertex_counts();
println!(" face_vertex_counts: {} ({} faces)", counts.len(), counts.len());
let idx = mesh.face_vertex_indices();
println!(" face_vertex_indices: {}", idx.len());
let normals = mesh.normals();
if normals.is_empty() {
println!(" normals: (unauthored)");
} else {
println!(" normals: {} floats ({} normals)", normals.len(), normals.len() / 3);
}
let st = mesh.st();
if st.is_empty() {
println!(" primvars:st: (unauthored)");
} else {
println!(" primvars:st: {} floats ({} uvs)", st.len(), st.len() / 2);
}
let st_idx = mesh.st_indices();
if st_idx.is_empty() {
println!(" primvars:st:indices: (none)");
} else {
println!(" primvars:st:indices: {}", st_idx.len());
}
let m = mesh.local_to_world();
println!(" local_to_world (row-major):");
for row in &m {
println!(
" [{:8.3} {:8.3} {:8.3} {:8.3}]",
row[0], row[1], row[2], row[3]
);
}
}
}