diff --git a/b3d/Cargo.toml b/b3d/Cargo.toml index 9369973..04f7feb 100644 --- a/b3d/Cargo.toml +++ b/b3d/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "b3d" -version = "0.1.7" +version = "0.1.8" edition = "2021" license = "MIT OR Apache-2.0" description = "A parser for the b3d extension" diff --git a/b3d/examples/read.rs b/b3d/examples/read.rs new file mode 100644 index 0000000..3fdc4b7 --- /dev/null +++ b/b3d/examples/read.rs @@ -0,0 +1,24 @@ +use b3d::{B3D, Error}; + +fn main() -> Result<(), Error> { + let mut args = std::env::args(); + let _ = args.next(); + let bytes = std::fs::read(args.next().expect("No b3d file provided")).unwrap(); + let b3d = B3D::read(&bytes)?; + + let mut min_z = f32::INFINITY; + let mut max_z = -f32::INFINITY; + + for vertex in &b3d.node.mesh.vertices.vertices { + let z = vertex.position[2]; + min_z = min_z.min(z); + max_z = max_z.max(z); + } + + let depth = max_z - min_z; + + println!("{:#?}", b3d); + println!("Mesh Depth: {depth}"); + + Ok(()) +} diff --git a/b3d/src/lib.rs b/b3d/src/lib.rs index 9e86a03..1911691 100644 --- a/b3d/src/lib.rs +++ b/b3d/src/lib.rs @@ -350,6 +350,10 @@ impl Node { "NODE" => children.push(Node::read(data, chunk.next)?), "ANIM" => animation = Animation::read(data, chunk.next)?, "SEQS" => sequences.push(Sequence::read(data, chunk.next)?), + "PIVO" => { + let mut buf = vec![0; chunk.size as usize]; + data.read_exact(&mut buf)?; + } _ => return Err(Error::InvalidChunk(chunk).into()), } } @@ -419,6 +423,10 @@ impl B3D { "TEXS" => textures = Self::read_textures(&mut cursor, chunk.next)?, "BRUS" => brushes = Self::read_brushes(&mut cursor, chunk.next)?, "NODE" => node = Node::read(&mut cursor, chunk.next)?, + "PIVO" => { + let mut buf = vec![0; chunk.size as usize]; + cursor.read_exact(&mut buf)?; + } _ => return Err(Error::InvalidChunk(chunk).into()), } } diff --git a/bevy_b3d/Cargo.toml b/bevy_b3d/Cargo.toml index 767e7ab..b72daa6 100755 --- a/bevy_b3d/Cargo.toml +++ b/bevy_b3d/Cargo.toml @@ -12,6 +12,6 @@ keywords = ["bevy"] [dependencies] bevy = { version = "0.13.0", default-features = false, features = ["bevy_asset", "bevy_pbr", "bevy_render", "bevy_scene",] } -b3d = { path = "../b3d", version = "0.1.7" } +b3d = { path = "../b3d", version = "0.1.8" } thiserror = "1.0.51" anyhow = "1.0.76"