Compare commits
4 Commits
940a2291a3
...
main
Author | SHA1 | Date |
---|---|---|
_ | 514f0d4ac9 | |
_ | 10bd7278d7 | |
_ | 5515362d7b | |
_ | 003cbe4547 |
|
@ -1,4 +1,5 @@
|
||||||
/target
|
/target
|
||||||
|
/videos
|
||||||
|
|
||||||
*.blend
|
*.blend
|
||||||
*.glb
|
*.glb
|
||||||
|
|
92
src/main.rs
92
src/main.rs
|
@ -164,6 +164,12 @@ fn main () {
|
||||||
format: iqm::FLOAT,
|
format: iqm::FLOAT,
|
||||||
size: 3,
|
size: 3,
|
||||||
},
|
},
|
||||||
|
iqm::VertexArrayUnplaced {
|
||||||
|
r#type: iqm::TANGENT,
|
||||||
|
flags: 0,
|
||||||
|
format: iqm::FLOAT,
|
||||||
|
size: 4,
|
||||||
|
},
|
||||||
iqm::VertexArrayUnplaced {
|
iqm::VertexArrayUnplaced {
|
||||||
r#type: iqm::BLENDINDEXES,
|
r#type: iqm::BLENDINDEXES,
|
||||||
flags: 0,
|
flags: 0,
|
||||||
|
@ -183,7 +189,7 @@ fn main () {
|
||||||
name: u32::try_from (texts.len ()).unwrap (),
|
name: u32::try_from (texts.len ()).unwrap (),
|
||||||
parent: -1,
|
parent: -1,
|
||||||
translate: [0.0, 0.0, 0.0],
|
translate: [0.0, 0.0, 0.0],
|
||||||
rotate: [1.0, 0.0, 0.0, 0.0],
|
rotate: [0.0, 0.0, 0.0, 1.0],
|
||||||
scale: [1.0, 1.0, 1.0],
|
scale: [1.0, 1.0, 1.0],
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
@ -193,11 +199,33 @@ fn main () {
|
||||||
iqm::Pose {
|
iqm::Pose {
|
||||||
parent: -1,
|
parent: -1,
|
||||||
channelmask: 1, // Should be X translation
|
channelmask: 1, // Should be X translation
|
||||||
channeloffset: [0.0; 10],
|
channeloffset: [
|
||||||
|
0.0, 0.0, 0.0,
|
||||||
|
0.0, 0.0, 0.0, 1.0,
|
||||||
|
1.0, 1.0, 1.0,
|
||||||
|
],
|
||||||
channelscale: [16.0 / 32768.0; 10],
|
channelscale: [16.0 / 32768.0; 10],
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
|
let anims = [
|
||||||
|
iqm::Anim {
|
||||||
|
name: u32::try_from (texts.len ()).unwrap (),
|
||||||
|
first_frame: 0,
|
||||||
|
num_frames: 2,
|
||||||
|
framerate: 0.5,
|
||||||
|
flags: 0,
|
||||||
|
},
|
||||||
|
];
|
||||||
|
texts.push_str ("bogus_anim\0");
|
||||||
|
|
||||||
|
let num_framechannels = 1;
|
||||||
|
|
||||||
|
let frames = [
|
||||||
|
0,
|
||||||
|
32768,
|
||||||
|
];
|
||||||
|
|
||||||
let vertexes = vertexes;
|
let vertexes = vertexes;
|
||||||
let triangles = triangles;
|
let triangles = triangles;
|
||||||
let meshes = meshes;
|
let meshes = meshes;
|
||||||
|
@ -208,6 +236,8 @@ fn main () {
|
||||||
|
|
||||||
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_poses = u32::try_from (poses.len ()).unwrap ();
|
||||||
|
let num_anims = u32::try_from (anims.len ()).unwrap ();
|
||||||
|
let num_frames = u32::try_from (frames.len ()).unwrap () / num_framechannels;
|
||||||
|
|
||||||
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 ();
|
||||||
|
@ -245,13 +275,22 @@ fn main () {
|
||||||
|
|
||||||
let ofs_triangles = offset;
|
let ofs_triangles = offset;
|
||||||
offset += num_triangles * 3 * 4;
|
offset += num_triangles * 3 * 4;
|
||||||
let ofs_text = offset;
|
|
||||||
offset += num_text;
|
|
||||||
let ofs_joints = offset;
|
let ofs_joints = offset;
|
||||||
offset += num_joints * 48;
|
offset += num_joints * 48;
|
||||||
|
|
||||||
let ofs_poses = offset;
|
let ofs_poses = offset;
|
||||||
offset += num_poses * 88;
|
offset += num_poses * 88;
|
||||||
|
|
||||||
|
let ofs_anims = offset;
|
||||||
|
offset += num_anims * 5 * 4;
|
||||||
|
|
||||||
|
let ofs_frames = offset;
|
||||||
|
offset += num_frames * num_framechannels * 2;
|
||||||
|
|
||||||
|
let ofs_text = offset;
|
||||||
|
offset += num_text;
|
||||||
|
|
||||||
let filesize = offset;
|
let filesize = offset;
|
||||||
let _ = offset;
|
let _ = offset;
|
||||||
|
|
||||||
|
@ -294,13 +333,13 @@ fn main () {
|
||||||
f.write_all (&(ofs_poses.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 (&(num_anims.to_le_bytes ())).unwrap ();
|
||||||
f.write_all (&(0u32.to_le_bytes ())).unwrap ();
|
f.write_all (&(ofs_anims.to_le_bytes ())).unwrap ();
|
||||||
|
|
||||||
// num_frames, num_framechannels, ofs_frames, ofs_bounds
|
// num_frames, num_framechannels, ofs_frames, ofs_bounds
|
||||||
f.write_all (&(0u32.to_le_bytes ())).unwrap ();
|
f.write_all (&(num_frames.to_le_bytes ())).unwrap ();
|
||||||
f.write_all (&(0u32.to_le_bytes ())).unwrap ();
|
f.write_all (&(num_framechannels.to_le_bytes ())).unwrap ();
|
||||||
f.write_all (&(0u32.to_le_bytes ())).unwrap ();
|
f.write_all (&(ofs_frames.to_le_bytes ())).unwrap ();
|
||||||
f.write_all (&(0u32.to_le_bytes ())).unwrap ();
|
f.write_all (&(0u32.to_le_bytes ())).unwrap ();
|
||||||
|
|
||||||
// num_comment, ofs_comment
|
// num_comment, ofs_comment
|
||||||
|
@ -346,6 +385,12 @@ fn main () {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for v in &vertexes {
|
||||||
|
for x in [0.0, 0.0, 0.0, 1.0] {
|
||||||
|
f.write_all (&(f32::to_le_bytes (x))).unwrap ();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
for v in &vertexes {
|
for v in &vertexes {
|
||||||
f.write_all (&[0, 0, 0, 0]).unwrap ();
|
f.write_all (&[0, 0, 0, 0]).unwrap ();
|
||||||
}
|
}
|
||||||
|
@ -362,10 +407,6 @@ fn main () {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Text
|
|
||||||
|
|
||||||
f.write_all (texts.as_bytes ()).unwrap ();
|
|
||||||
|
|
||||||
// Joints
|
// Joints
|
||||||
|
|
||||||
for j in joints {
|
for j in joints {
|
||||||
|
@ -394,6 +435,22 @@ fn main () {
|
||||||
f.write_all (&(f32::to_le_bytes (x))).unwrap ();
|
f.write_all (&(f32::to_le_bytes (x))).unwrap ();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for a in anims {
|
||||||
|
f.write_all (&(u32::to_le_bytes (a.name))).unwrap ();
|
||||||
|
f.write_all (&(u32::to_le_bytes (a.first_frame))).unwrap ();
|
||||||
|
f.write_all (&(u32::to_le_bytes (a.num_frames))).unwrap ();
|
||||||
|
f.write_all (&(f32::to_le_bytes (a.framerate))).unwrap ();
|
||||||
|
f.write_all (&(u32::to_le_bytes (a.flags))).unwrap ();
|
||||||
|
}
|
||||||
|
|
||||||
|
for x in frames {
|
||||||
|
f.write_all (&(u16::to_le_bytes (x))).unwrap ();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Text
|
||||||
|
|
||||||
|
f.write_all (texts.as_bytes ()).unwrap ();
|
||||||
}
|
}
|
||||||
|
|
||||||
fn gltf_node_get_mat4 (node: &gltf::Node) -> Mat4 {
|
fn gltf_node_get_mat4 (node: &gltf::Node) -> Mat4 {
|
||||||
|
@ -414,6 +471,7 @@ mod iqm {
|
||||||
|
|
||||||
pub const POSITION: u32 = 0;
|
pub const POSITION: u32 = 0;
|
||||||
pub const NORMAL: u32 = 2;
|
pub const NORMAL: u32 = 2;
|
||||||
|
pub const TANGENT: u32 = 3;
|
||||||
pub const BLENDINDEXES: u32 = 4;
|
pub const BLENDINDEXES: u32 = 4;
|
||||||
pub const BLENDWEIGHTS: u32 = 5;
|
pub const BLENDWEIGHTS: u32 = 5;
|
||||||
|
|
||||||
|
@ -466,6 +524,14 @@ mod iqm {
|
||||||
pub channelscale: [f32; 10],
|
pub channelscale: [f32; 10],
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub struct Anim {
|
||||||
|
pub name: u32,
|
||||||
|
pub first_frame: u32,
|
||||||
|
pub num_frames: u32,
|
||||||
|
pub framerate: f32,
|
||||||
|
pub flags: u32,
|
||||||
|
}
|
||||||
|
|
||||||
pub struct Vertex {
|
pub struct Vertex {
|
||||||
pub position: [f32; 3],
|
pub position: [f32; 3],
|
||||||
pub normal: [f32; 3],
|
pub normal: [f32; 3],
|
||||||
|
|
Loading…
Reference in New Issue