From 940a2291a33343367328bf05fd6ea6fd53af2d43 Mon Sep 17 00:00:00 2001 From: _ <_@_> Date: Wed, 23 Feb 2022 00:46:08 +0000 Subject: [PATCH] :construction: wip: write bogus iqmpose --- src/main.rs | 39 ++++++++++++++++++++++++++++++++++++--- 1 file changed, 36 insertions(+), 3 deletions(-) diff --git a/src/main.rs b/src/main.rs index 9749695..ef9026a 100644 --- a/src/main.rs +++ b/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],