🚧 wip: write bogus iqmpose
parent
af7328ed05
commit
940a2291a3
39
src/main.rs
39
src/main.rs
|
@ -185,10 +185,19 @@ fn main () {
|
|||
translate: [0.0, 0.0, 0.0],
|
||||
rotate: [1.0, 0.0, 0.0, 0.0],
|
||||
scale: [1.0, 1.0, 1.0],
|
||||
}
|
||||
},
|
||||
];
|
||||
texts.push_str ("bogus_joint\0");
|
||||
|
||||
let poses = [
|
||||
iqm::Pose {
|
||||
parent: -1,
|
||||
channelmask: 1, // Should be X translation
|
||||
channeloffset: [0.0; 10],
|
||||
channelscale: [16.0 / 32768.0; 10],
|
||||
},
|
||||
];
|
||||
|
||||
let vertexes = vertexes;
|
||||
let triangles = triangles;
|
||||
let meshes = meshes;
|
||||
|
@ -198,6 +207,7 @@ fn main () {
|
|||
let num_triangles = u32::try_from (triangles.len ()).unwrap ();
|
||||
|
||||
let num_joints = u32::try_from (joints.len ()).unwrap ();
|
||||
let num_poses = u32::try_from (poses.len ()).unwrap ();
|
||||
|
||||
let num_text = texts.len ();
|
||||
let num_text = u32::try_from (num_text).unwrap ();
|
||||
|
@ -239,6 +249,8 @@ fn main () {
|
|||
offset += num_text;
|
||||
let ofs_joints = offset;
|
||||
offset += num_joints * 48;
|
||||
let ofs_poses = offset;
|
||||
offset += num_poses * 88;
|
||||
|
||||
let filesize = offset;
|
||||
let _ = offset;
|
||||
|
@ -278,8 +290,8 @@ fn main () {
|
|||
f.write_all (&(ofs_joints.to_le_bytes ())).unwrap ();
|
||||
|
||||
// num_poses, ofs_poses
|
||||
f.write_all (&(0u32.to_le_bytes ())).unwrap ();
|
||||
f.write_all (&(0u32.to_le_bytes ())).unwrap ();
|
||||
f.write_all (&(num_poses.to_le_bytes ())).unwrap ();
|
||||
f.write_all (&(ofs_poses.to_le_bytes ())).unwrap ();
|
||||
|
||||
// num_anims, ofs_anims
|
||||
f.write_all (&(0u32.to_le_bytes ())).unwrap ();
|
||||
|
@ -370,6 +382,18 @@ fn main () {
|
|||
f.write_all (&(f32::to_le_bytes (x))).unwrap ();
|
||||
}
|
||||
}
|
||||
|
||||
for p in poses {
|
||||
f.write_all (&(i32::to_le_bytes (p.parent))).unwrap ();
|
||||
f.write_all (&(u32::to_le_bytes (p.channelmask))).unwrap ();
|
||||
|
||||
for x in p.channeloffset {
|
||||
f.write_all (&(f32::to_le_bytes (x))).unwrap ();
|
||||
}
|
||||
for x in p.channelscale {
|
||||
f.write_all (&(f32::to_le_bytes (x))).unwrap ();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn gltf_node_get_mat4 (node: &gltf::Node) -> Mat4 {
|
||||
|
@ -433,6 +457,15 @@ mod iqm {
|
|||
pub scale: [f32; 3],
|
||||
}
|
||||
|
||||
// Basically extra data about the joint
|
||||
|
||||
pub struct Pose {
|
||||
pub parent: i32,
|
||||
pub channelmask: u32,
|
||||
pub channeloffset: [f32; 10],
|
||||
pub channelscale: [f32; 10],
|
||||
}
|
||||
|
||||
pub struct Vertex {
|
||||
pub position: [f32; 3],
|
||||
pub normal: [f32; 3],
|
||||
|
|
Loading…
Reference in New Issue