I am learning rust by writing a terminal utility I need.
This tool needs to take a gltf file and apply a linear transformation to the nodes and to the buffers.
Right now I am trying to scale down the inverse bind matrix data.
To that effect I am using this crate:
https://docs.rs/gltf/latest/gltf/
With the data loaded I am trying reach the binary data like this:
use gltf::Gltf;
fn main() -> Result<(), gltf::Error>
{
let gltf = Gltf::open("Assets/werewolf_animated.gltf")?;
for skin in gltf.skins() {
for joint in skin.joints()
{
println!(
"Skin #{} has {} joint",
skin.index(),
joint.index(),
);
}
for ibm_accessor in skin.inverse_bind_matrices()
{
println!("Accessor #{}", ibm_accessor.index());
println!("offset: {}", ibm_accessor.offset());
println!("count: {}", ibm_accessor.count());
println!("data_type: {:?}", ibm_accessor.data_type());
println!("dimensions: {:?}", ibm_accessor.dimensions());
println!("buffer: {:?}", ibm_accessor.view().unwrap().buffer().source());
}
}
Ok(())
}
If this were C or C++ at this stage I would have a float* and I would be able to start reading and writing to the binary data, treating it as a float array. But this is rust.
Any suggestions as to how I can start tampering with the data under ibm_accessor.view().unwrap().buffer().source()?