Parses .off
(Object File Format) files.
This implementation follows this spec from the Princeton Shape Benchmark.
Sample .off
file:
```off
OFF
8 6 12
1.632993 0.000000 1.154701 0.000000 1.632993 1.154701 -1.632993 0.000000 1.154701 0.000000 -1.632993 1.154701 1.632993 0.000000 -1.154701 0.000000 1.632993 -1.154701 -1.632993 0.000000 -1.154701 0.000000 -1.632993 -1.154701
4 0 1 2 3 1.000 0.000 0.000 0.75 4 7 4 0 3 0.300 0.400 0.000 0.75 4 4 5 1 0 0.200 0.500 0.100 0.75 4 5 6 2 1 0.100 0.600 0.200 0.75 4 3 2 6 7 0.000 0.700 0.300 0.75 4 6 5 4 7 0.000 1.000 0.000 0.75 ```
This cube.off file is parsed using off-rs
in this example.
```rust let off_string = r#" OFF 3 1 1.0 0.0 0.0 0.0 1.0 0.0 0.0 0.0 1.0 4 0 1 2 3 255 0 0 # red "#;
let mesh = offrs::parse( offstring, Default::default() // optional ParserOptions );
println!("{:#?}", mesh); ```
Will return a structure like this:
jsonc
Mesh {
vertices: [
Vertex {
position: Position {
x: 1.0,
y: 0.0,
z: 0.0,
},
color: None,
},
...
faces: [
Face {
vertices: [
0,
1,
2,
3,
],
color: Some(
Color {
red: 1.0,
green: 0.0,
blue: 0.0,
alpha: 1.0,
},
),
},
...