🚧 wip: write bogus iqmpose

main
_ 2022-02-23 00:46:08 +00:00
parent af7328ed05
commit 940a2291a3
1 changed files with 36 additions and 3 deletions

View File

@ -185,10 +185,19 @@ fn main () {
translate: [0.0, 0.0, 0.0], translate: [0.0, 0.0, 0.0],
rotate: [1.0, 0.0, 0.0, 0.0], rotate: [1.0, 0.0, 0.0, 0.0],
scale: [1.0, 1.0, 1.0], scale: [1.0, 1.0, 1.0],
} },
]; ];
texts.push_str ("bogus_joint\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 vertexes = vertexes;
let triangles = triangles; let triangles = triangles;
let meshes = meshes; let meshes = meshes;
@ -198,6 +207,7 @@ fn main () {
let num_triangles = u32::try_from (triangles.len ()).unwrap (); let num_triangles = u32::try_from (triangles.len ()).unwrap ();
let num_joints = u32::try_from (joints.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 = texts.len ();
let num_text = u32::try_from (num_text).unwrap (); let num_text = u32::try_from (num_text).unwrap ();
@ -239,6 +249,8 @@ fn main () {
offset += num_text; offset += num_text;
let ofs_joints = offset; let ofs_joints = offset;
offset += num_joints * 48; offset += num_joints * 48;
let ofs_poses = offset;
offset += num_poses * 88;
let filesize = offset; let filesize = offset;
let _ = offset; let _ = offset;
@ -278,8 +290,8 @@ fn main () {
f.write_all (&(ofs_joints.to_le_bytes ())).unwrap (); f.write_all (&(ofs_joints.to_le_bytes ())).unwrap ();
// num_poses, ofs_poses // num_poses, ofs_poses
f.write_all (&(0u32.to_le_bytes ())).unwrap (); f.write_all (&(num_poses.to_le_bytes ())).unwrap ();
f.write_all (&(0u32.to_le_bytes ())).unwrap (); f.write_all (&(ofs_poses.to_le_bytes ())).unwrap ();
// num_anims, ofs_anims // num_anims, ofs_anims
f.write_all (&(0u32.to_le_bytes ())).unwrap (); f.write_all (&(0u32.to_le_bytes ())).unwrap ();
@ -370,6 +382,18 @@ fn main () {
f.write_all (&(f32::to_le_bytes (x))).unwrap (); 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 { fn gltf_node_get_mat4 (node: &gltf::Node) -> Mat4 {
@ -433,6 +457,15 @@ mod iqm {
pub scale: [f32; 3], 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 struct Vertex {
pub position: [f32; 3], pub position: [f32; 3],
pub normal: [f32; 3], pub normal: [f32; 3],