B3D

Struct B3D 

Source
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: Node

Implementations§

Source§

impl B3D

Source

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}
Source

pub fn read_textures<T>(data: &mut T, next: u64) -> Result<Vec<Texture>, Error>
where T: Read + Seek,

Source

pub fn read_brushes<T>(data: &mut T, next: u64) -> Result<Vec<Brush>, Error>
where T: Read + Seek,

Trait Implementations§

Source§

impl Debug for B3D

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.