stopping for now

This commit is contained in:
Brooks Palin
2024-03-14 19:57:27 -06:00
parent 1ef2afc685
commit 2934c66d53
8 changed files with 52 additions and 20 deletions
+1 -1
View File
@@ -234,8 +234,8 @@ pub struct RetargetMap {
impl RetargetMap {
const MOCAP_NET: [(&'static str, &'static str); 80] = [
// Spine
("LowerBack", "DEF-spine"),
("hip", "DEF-spine"),
("LowerBack", "DEF-spine.001"),
("abdomen", "DEF-spine.002"),
("chest", "DEF-spine.003"),
("Neck", "DEF-spine.004"),
+13 -10
View File
@@ -1,7 +1,7 @@
use bevy::{
animation::{AnimationClip, EntityPath, Keyframes, VariableCurve}, asset::{io::Reader, AssetLoader, AsyncReadExt, LoadContext}, core::Name, math::{Quat, Vec3}, utils::BoxedFuture
};
use studio_bvh::Joint;
use studio_bvh::{joint, Joint};
use crate::anim::RetargetMap;
@@ -28,11 +28,13 @@ impl AssetLoader for BvhLoader {
let mut buf = vec![];
reader.read_to_end(&mut buf).await.anyhow()?;
let bvh = studio_bvh::from_bytes(&buf).anyhow()?;
// println!("{:?}", bvh.joints_len());
let mut anim_clip = AnimationClip::default();
for joint in bvh.joints() {
for (index, joint) in bvh.joints().enumerate() {
let path = get_entity_path(&joint, &RetargetMap::default());
println!("{} - {:?}", index, path);
let mut timestamps = Vec::new();
let mut motions = Vec::new();
let mut rotations = Vec::new();
@@ -54,16 +56,16 @@ impl AssetLoader for BvhLoader {
}
motions.push(frame_pos);
rotations.push(Quat::from_euler(bevy::math::EulerRot::ZXY, frame_rot.x, frame_rot.y, frame_rot.z));
rotations.push(Quat::from_euler(bevy::math::EulerRot::ZXY, frame_rot.x.to_radians(), frame_rot.y.to_radians(), frame_rot.z.to_radians()));
}
if joint.is_root() {
let motion_curve = VariableCurve {
keyframe_timestamps: timestamps.clone(),
keyframes: Keyframes::Translation(motions),
};
anim_clip.add_curve_to_path(path.clone(), motion_curve);
}
// if joint.is_root() {
// let motion_curve = VariableCurve {
// keyframe_timestamps: timestamps.clone(),
// keyframes: Keyframes::Translation(motions),
// };
// anim_clip.add_curve_to_path(path.clone(), motion_curve);
// }
let rotation_curve = VariableCurve {
keyframe_timestamps: timestamps,
@@ -91,6 +93,7 @@ pub fn get_entity_path(current_joint : &Joint, retarget_map : &RetargetMap) -> E
path
} else {
let mut path = EntityPath::default();
path.parts.push("Mannequin_gamerig".into());
path.parts.push(Name::new(name));
path
}
+3 -2
View File
@@ -10,7 +10,7 @@ use serde_repr::{Deserialize_repr, Serialize_repr};
#[cfg(feature = "wasm")]
use wasm_bindgen::prelude::*;
mod anim;
pub mod anim;
mod bvh;
mod camera_controller;
mod change_tracking;
@@ -26,7 +26,7 @@ mod mixamo;
mod path;
mod persistance;
mod remote;
mod scene;
pub mod scene;
pub mod screenshot;
mod skybox;
mod ui;
@@ -92,6 +92,7 @@ impl PluginGroup for CommonPlugins {
.add(WorldGridPlugin)
.add(PersistancePlugin)
.add(AnimPlugin)
.add(BvhPlugin)
}
}
+25 -3
View File
@@ -1,9 +1,8 @@
use bevy::{
app::Update,
window::{close_on_esc, Window},
app::Update, ecs::{query::With, system::Query}, window::{close_on_esc, Window}, prelude::*
};
use clap::Parser;
use studio::{screenshot::ScreenShotPlugin, InitAsset, InitParams, StudioMode};
use studio::{anim::Skeleton, scene::{tag_scene_elements, SceneState}, screenshot::ScreenShotPlugin, InitAsset, InitParams, StudioMode};
#[derive(Parser)]
#[command(name = "StorytellerStudio")]
@@ -37,7 +36,30 @@ fn main() {
// Add any additional systems, resources, etc. for local debugging
app.add_systems(Update, close_on_esc);
app.add_systems(Update, add_anim);
app.add_plugins(ScreenShotPlugin);
app.run();
}
fn add_anim(
mut commands : Commands,
skeletons : Query<Entity, Added<Skeleton>>,
asset_server : Res<AssetServer>,
) {
let bvh_anim : Handle<AnimationClip> = asset_server.load("mocap/shuffle.bvh");
if skeletons.iter().count() > 0 {
println!("Adding animation to skeletons {}", skeletons.iter().count());
}
for skeleton in skeletons.iter() {
let mut animation_player = AnimationPlayer::default();
animation_player.play(bvh_anim.clone());
println!("{:?}", skeleton);
commands.entity(skeleton).insert((
animation_player,
bvh_anim.clone()
));
}
}
+1 -1
View File
@@ -376,7 +376,7 @@ fn init_scene_loading(
}
}
fn tag_scene_elements(
pub fn tag_scene_elements(
mut cmd: Commands,
// A "glTF mesh" is actually a container for one or more "glTF primitives",
// which is basically a bundle of vertices paired with the material used to