Skip to main content

load_obj

Function load_obj 

Source
pub fn load_obj<P: AsRef<Path> + Debug>(path: P) -> Result<Mesh, Err>
Examples found in repository?
examples/obj.rs (line 10)
8fn main() -> Result<(), Box<dyn std::error::Error>> {
9    // Create mesh from an obj file, for example.
10    let mesh = load_obj("mesh.obj").unwrap();
11
12    // Create a buffer that we write the encoded data to.
13    // This time we use 'Vec<u8>' as the output buffer, but draco-oxide can stream-write to anything
14    // that implements draco_oxide::core::bit_coder::ByteWriter.
15    let mut buffer = Vec::new();
16
17    // Encode the mesh into the buffer.
18    encode(mesh, &mut buffer, encode::Config::default()).unwrap();
19
20    let mut file = std::fs::File::create("output.drc").unwrap();
21    file.write_all(&buffer)?;
22    Ok(())
23}