pub struct B3D {
pub version: u32,
pub textures: Vec<Texture>,
pub brushes: Vec<Brush>,
pub node: Node,
}Fields§
§version: u32§textures: Vec<Texture>§brushes: Vec<Brush>§node: NodeImplementations§
Source§impl B3D
impl B3D
Sourcepub fn read(data: &[u8]) -> Result<Self, Error>
pub fn read(data: &[u8]) -> Result<Self, Error>
Examples found in repository?
examples/read.rs (line 7)
3fn main() -> Result<(), Error> {
4 let mut args = std::env::args();
5 let _ = args.next();
6 let bytes = std::fs::read(args.next().expect("No b3d file provided")).unwrap();
7 let b3d = B3D::read(&bytes)?;
8
9 let mut min_z = f32::INFINITY;
10 let mut max_z = -f32::INFINITY;
11
12 for vertex in &b3d.node.mesh.vertices.vertices {
13 let z = vertex.position[2];
14 min_z = min_z.min(z);
15 max_z = max_z.max(z);
16 }
17
18 let depth = max_z - min_z;
19
20 println!("{:#?}", b3d);
21 println!("Mesh Depth: {depth}");
22
23 Ok(())
24}pub fn read_textures<T>(data: &mut T, next: u64) -> Result<Vec<Texture>, Error>
pub fn read_brushes<T>(data: &mut T, next: u64) -> Result<Vec<Brush>, Error>
Trait Implementations§
Auto Trait Implementations§
impl Freeze for B3D
impl RefUnwindSafe for B3D
impl Send for B3D
impl Sync for B3D
impl Unpin for B3D
impl UnwindSafe for B3D
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more