Skip to content

Commit

Permalink
0.1.8 + pivo fixes?
Browse files Browse the repository at this point in the history
  • Loading branch information
DotWith committed Apr 1, 2024
1 parent 0840f31 commit 62b72f7
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 2 deletions.
2 changes: 1 addition & 1 deletion b3d/Cargo.toml
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
24 changes: 24 additions & 0 deletions b3d/examples/read.rs
Original file line number Diff line number Diff line change
@@ -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(())
}
8 changes: 8 additions & 0 deletions b3d/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()),
}
}
Expand Down Expand Up @@ -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()),
}
}
Expand Down
2 changes: 1 addition & 1 deletion bevy_b3d/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"

0 comments on commit 62b72f7

Please sign in to comment.