mirror of
https://github.com/storytold/storyteller-bevy.git
synced 2026-10-17 00:13:17 +00:00
Stopping for now
This commit is contained in:
+43
-3
@@ -2,11 +2,11 @@ use bevy::{
|
||||
math::Affine3A,
|
||||
prelude::*,
|
||||
render::{mesh::skinning::SkinnedMesh, view::NoFrustumCulling},
|
||||
utils::{EntityHashMap, EntityHashSet},
|
||||
utils::{EntityHashMap, EntityHashSet, HashMap},
|
||||
};
|
||||
use space_editor::space_prefab::editor_registry::EditorRegistryExt;
|
||||
|
||||
use crate::{hierarchy, scene::SceneElement};
|
||||
use crate::{hierarchy, interaction::Selected, scene::SceneElement};
|
||||
pub use retargeting::*;
|
||||
|
||||
mod camera;
|
||||
@@ -26,15 +26,22 @@ impl Plugin for AnimPlugin {
|
||||
.register_type::<BindPoseGlobal>()
|
||||
.editor_registry::<BindPoseGlobal>()
|
||||
.register_type::<InvBindPose>()
|
||||
.editor_registry::<InvBindPose>();
|
||||
.editor_registry::<InvBindPose>()
|
||||
.register_type::<LoadedAnimations>()
|
||||
;
|
||||
|
||||
app.add_systems(Update, process_skinned_meshes);
|
||||
app.insert_resource(GlobalSeekTime(0.));
|
||||
|
||||
app.add_plugins((retargeting::RetargetingPlugin, camera::CameraAnimPlugin));
|
||||
|
||||
//Stuff for animation atachment
|
||||
app.add_systems(PostUpdate, check_selected_for_animation);
|
||||
|
||||
#[cfg(feature = "wasm")]
|
||||
app.add_systems(Update, wasm::update_global_seek_time);
|
||||
|
||||
app.init_resource::<LoadedAnimations>();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -150,6 +157,39 @@ fn process_skinned_meshes(
|
||||
}
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
// Loaded anims
|
||||
//==============================================================================
|
||||
|
||||
#[derive(Resource, Default, Reflect)]
|
||||
#[reflect(Resource)]
|
||||
pub struct LoadedAnimations {
|
||||
pub animations : Vec<Handle<AnimationClip>>
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
// Animation attachment
|
||||
//==============================================================================
|
||||
|
||||
fn check_selected_for_animation(
|
||||
selected : Query<&Name, (With<SkeletalJoint>, Added<Selected>)>,
|
||||
loaded_animations : Res<LoadedAnimations>,
|
||||
animation_assets : Res<Assets<AnimationClip>>,
|
||||
) {
|
||||
for name in selected.iter() {
|
||||
println!("Thing selected");
|
||||
let animations = loaded_animations.animations.iter()
|
||||
.map(|handle| animation_assets.get(handle).unwrap());
|
||||
|
||||
for animation in animations {
|
||||
println!("Animation Compatible: {}", animation.compatible_with(name));
|
||||
if animation.compatible_with(name) {
|
||||
println!("Compatible animation: {:?}", animation);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "wasm")]
|
||||
mod wasm {
|
||||
use bevy::prelude::*;
|
||||
|
||||
@@ -28,13 +28,12 @@ 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 (index, joint) in bvh.joints().enumerate() {
|
||||
let path = get_entity_path(&joint, &RetargetMap::default());
|
||||
println!("{} - {:?}", index, path);
|
||||
// println!("{} - {:?}", index, path);
|
||||
let mut timestamps = Vec::new();
|
||||
let mut motions = Vec::new();
|
||||
let mut rotations = Vec::new();
|
||||
|
||||
+6
-1
@@ -2,7 +2,7 @@ use bevy::{
|
||||
app::Update, ecs::{query::With, system::Query}, window::{close_on_esc, Window}, prelude::*
|
||||
};
|
||||
use clap::Parser;
|
||||
use studio::{anim::Skeleton, scene::{tag_scene_elements, SceneState}, screenshot::ScreenShotPlugin, InitAsset, InitParams, StudioMode};
|
||||
use studio::{anim::Skeleton, scene::{tag_scene_elements, SceneState}, screenshot::ScreenShotPlugin, InitAsset, InitParams, MixamoImportEvent, MixamoPlugin, StudioMode};
|
||||
|
||||
#[derive(Parser)]
|
||||
#[command(name = "StorytellerStudio")]
|
||||
@@ -39,6 +39,11 @@ fn main() {
|
||||
app.add_systems(Update, add_anim);
|
||||
app.add_plugins(ScreenShotPlugin);
|
||||
|
||||
app.add_plugins(MixamoPlugin);
|
||||
app.add_systems(Startup, move |mut mixamo_load_event : EventWriter<MixamoImportEvent>| {
|
||||
mixamo_load_event.send(MixamoImportEvent("mocap/hip-hop-dancing.gltf".into()))
|
||||
});
|
||||
|
||||
app.run();
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
use bevy::{gltf::Gltf, prelude::*, scene::InstanceId};
|
||||
|
||||
use crate::anim::RetargetSource;
|
||||
use crate::anim::{LoadedAnimations, RetargetSource};
|
||||
|
||||
pub struct MixamoPlugin;
|
||||
impl Plugin for MixamoPlugin {
|
||||
@@ -97,6 +97,8 @@ fn tick_scene_spawning(
|
||||
r_scene_spawner: Res<SceneSpawner>,
|
||||
r_mixamo_scene: Res<MixamoScene>,
|
||||
mut st_next: ResMut<NextState<MixamoState>>,
|
||||
mut loaded_animations : ResMut<LoadedAnimations>,
|
||||
ra_gltfs: Res<Assets<Gltf>>,
|
||||
) {
|
||||
if r_scene_spawner.instance_is_ready(**r_mixamo_scene) {
|
||||
st_next.set(MixamoState::Processing);
|
||||
@@ -112,11 +114,14 @@ fn start_mixamo_anim(
|
||||
r_scene_spawner: Res<SceneSpawner>,
|
||||
q_names: Query<&Name>,
|
||||
mut st_next: ResMut<NextState<MixamoState>>,
|
||||
mut loaded_animations : ResMut<LoadedAnimations>,
|
||||
) {
|
||||
let gltf = ra_gltfs.get(&**r_mixamo_import).unwrap();
|
||||
let src_anim_handle = gltf.animations[0].clone();
|
||||
let src_anim = ra_animations.get(src_anim_handle.clone()).unwrap();
|
||||
|
||||
|
||||
loaded_animations.animations.push(src_anim_handle.clone());
|
||||
|
||||
let Some(src_root) = r_scene_spawner
|
||||
.iter_instance_entities(**r_mixamo_scene)
|
||||
.find(|ent| match q_names.get(*ent) {
|
||||
|
||||
Reference in New Issue
Block a user