Skip to content

Commit

Permalink
Clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
tommy-xr committed Sep 20, 2024
1 parent dac61a2 commit beb619e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ use std::io::Cursor;

use cgmath::num_traits::ToPrimitive;
use cgmath::{vec2, vec3, Matrix4};
use gltf::camera::Projection;
use gltf::{buffer::Source as BufferSource, image::Source as ImageSource};

use crate::model::{Model, ModelMesh, Skeleton, SkeletonBuilder};
Expand Down Expand Up @@ -200,9 +199,10 @@ fn process_node(

// Process skinning data
if let Some(skin) = node.skin() {
println!("Skin: {:?}", skin.name());
let reader = skin.reader(|buffer| Some(&buffers[buffer.index()]));
let inverse_bind_matrices = reader

// TODO: Save inverse bind matrices with model
let _inverse_bind_matrices = reader
.read_inverse_bind_matrices()
.map(|v| v.collect::<Vec<_>>())
.unwrap_or_default();
Expand All @@ -212,22 +212,10 @@ fn process_node(
let maybe_root = skin.skeleton();

if let Some(root) = maybe_root {
println!("Root: {:?}", root.name());
process_joints(&root, None, &mut skeleton_builder);
}

*maybe_skeleton = Some(skeleton_builder.build());

for (i, joint) in skin.joints().enumerate() {
println!(
"Joint {} -> {}: {:?} -> {:?}",
i,
joint.index(),
joint.name().unwrap_or("<no name>"),
joint.transform(),
);
// Process joint transformation and hierarchy
}
}

for child in node.children() {
Expand All @@ -240,8 +228,6 @@ fn process_joints(
parent_id: Option<i32>,
skeleton_builder: &mut SkeletonBuilder,
) {
println!("visiting node: {:?} : {:?}", node.name(), node.transform());

let id = node.index().to_i32().unwrap();
let name = node.name().unwrap_or("None");
let transform = node.transform().matrix().into();
Expand All @@ -259,10 +245,11 @@ fn process_animations(document: &gltf::Document, buffers: &[gltf::buffer::Data])
// println!("!! Animation: {:?}", animation.name());
for channel in animation.channels() {
let reader = channel.reader(|buffer| Some(&buffers[buffer.index()]));
let keyframe_timestamps = if let Some(inputs) = reader.read_inputs() {
// TODO:
let _keyframe_timestamps = if let Some(inputs) = reader.read_inputs() {
match inputs {
gltf::accessor::Iter::Standard(times) => {
let times: Vec<f32> = times.collect();
let _times: Vec<f32> = times.collect();
// println!("Time: {}", times.len());
// dbg!(times);
}
Expand All @@ -272,8 +259,9 @@ fn process_animations(document: &gltf::Document, buffers: &[gltf::buffer::Data])
}
};

// TODO:
let mut keyframes_vec: Vec<Vec<f32>> = Vec::new();
let keyframes = if let Some(outputs) = reader.read_outputs() {
let _keyframes = if let Some(outputs) = reader.read_outputs() {
match outputs {
gltf::animation::util::ReadOutputs::Translations(translation) => {
translation.for_each(|tr| {
Expand All @@ -283,9 +271,9 @@ fn process_animations(document: &gltf::Document, buffers: &[gltf::buffer::Data])
keyframes_vec.push(vector);
});
}
other => (), // gltf::animation::util::ReadOutputs::Rotations(_) => todo!(),
// gltf::animation::util::ReadOutputs::Scales(_) => todo!(),
// gltf::animation::util::ReadOutputs::MorphTargetWeights(_) => todo!(),
_other => (), // gltf::animation::util::ReadOutputs::Rotations(_) => todo!(),
// gltf::animation::util::ReadOutputs::Scales(_) => todo!(),
// gltf::animation::util::ReadOutputs::MorphTargetWeights(_) => todo!(),
}
};

Expand Down
2 changes: 1 addition & 1 deletion runtime/functor-runtime-common/src/scene3d/mod.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
use std::{cell::RefCell, sync::Arc};

use cgmath::{point3, vec3, vec4, Matrix4, SquareMatrix, Transform};
use gltf::json::extensions::scene;
use serde::{Deserialize, Serialize};

use fable_library_rust::NativeArray_::Array;
Expand Down Expand Up @@ -230,6 +229,7 @@ impl Scene3D {
mesh.mesh.draw(&render_context.gl)
}

// TEMPORARY: Render joints
let joints = hydrated_model.skeleton.get_transforms();
for joint_transform in joints {
let mut color_material =
Expand Down

0 comments on commit beb619e

Please sign in to comment.