Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

working ik hopefully works in vr #4

Merged
merged 5 commits into from
Sep 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
209 changes: 209 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ bevy_mod_xr = { git = "https://github.com/awtterpip/bevy_oxr", optional = true }
bevy_vrm = "0.0.12"
bevy_xr_utils = { git = "https://github.com/awtterpip/bevy_oxr", optional = true }
paste = "1.0.15"
bevy_mod_picking = "0.20.1"
bevy_transform_gizmo = "0.12.0"

[target.'cfg(not(target_family = "wasm"))'.dependencies]
bevy_mod_openxr = { git = "https://github.com/awtterpip/bevy_oxr", optional = true }
Expand Down
3 changes: 3 additions & 0 deletions examples/player.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ use bevy::prelude::*;
use bevy_vr_controller::{
animation::defaults::default_character_animations, player::PlayerSettings, VrControllerPlugin,
};
use bevy_xr_utils::{
tracking_utils::TrackingUtilitiesPlugin, xr_utils_actions::XRUtilsActionsPlugin,
};

fn main() {
let mut app = App::new();
Expand Down
53 changes: 50 additions & 3 deletions src/animation/load.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
use bevy::{gltf::GltfNode, prelude::*, utils::HashMap};
use bevy_vrm::{animations::vrm::VRM_ANIMATION_TARGETS, BoneName};

use super::{
mixamo::{MIXAMO_ANIMATION_TARGETS, MIXAMO_BONE_NAMES},
AnimationName,
};
use crate::ik::RunHumanoidIk;
use bevy::{gltf::GltfNode, prelude::*, utils::HashMap};
use bevy_vrm::{animations::vrm::VRM_ANIMATION_TARGETS, BoneName};

#[derive(Component, Clone)]
pub struct AvatarAnimationClips(pub HashMap<AnimationName, AvatarAnimation>);
Expand All @@ -25,6 +25,7 @@ pub(crate) fn load_animation_nodes(
mut gltfs: ResMut<Assets<Gltf>>,
mut graphs: ResMut<Assets<AnimationGraph>>,
nodes: Res<Assets<GltfNode>>,
run_humanoid_ik: Res<RunHumanoidIk>,
) {
for (entity, animations) in avatars.iter() {
let mut graph = AnimationGraph::default();
Expand Down Expand Up @@ -57,6 +58,52 @@ pub(crate) fn load_animation_nodes(
continue;
}

if run_humanoid_ik.0 {
match name {
BoneName::LeftShoulder
| BoneName::RightShoulder
| BoneName::LeftUpperArm
| BoneName::RightUpperArm
| BoneName::LeftLowerArm
| BoneName::RightLowerArm
| BoneName::LeftHand
| BoneName::RightHand
| BoneName::LeftThumbProximal
| BoneName::LeftThumbIntermediate
| BoneName::LeftThumbDistal
| BoneName::LeftIndexProximal
| BoneName::LeftIndexIntermediate
| BoneName::LeftIndexDistal
| BoneName::LeftMiddleProximal
| BoneName::LeftMiddleIntermediate
| BoneName::LeftMiddleDistal
| BoneName::LeftRingProximal
| BoneName::LeftRingIntermediate
| BoneName::LeftRingDistal
| BoneName::LeftLittleProximal
| BoneName::LeftLittleIntermediate
| BoneName::LeftLittleDistal
| BoneName::RightThumbProximal
| BoneName::RightThumbIntermediate
| BoneName::RightThumbDistal
| BoneName::RightIndexProximal
| BoneName::RightIndexIntermediate
| BoneName::RightIndexDistal
| BoneName::RightMiddleProximal
| BoneName::RightMiddleIntermediate
| BoneName::RightMiddleDistal
| BoneName::RightRingProximal
| BoneName::RightRingIntermediate
| BoneName::RightRingDistal
| BoneName::RightLittleProximal
| BoneName::RightLittleIntermediate
| BoneName::RightLittleDistal => {
continue;
}
_ => {}
}
}

if let Some(mut curves) = clip_curves.remove(target) {
let mut to_remove = Vec::default();

Expand Down
4 changes: 2 additions & 2 deletions src/animation/weights.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
use bevy::{animation::ActiveAnimation, prelude::*, utils::HashMap};

use super::{AnimationName, AvatarAnimationNodes};
use crate::ik::RunHumanoidIk;
use crate::{
player::{PlayerAvatar, PlayerBody},
velocity::AverageVelocity,
};

use super::{AnimationName, AvatarAnimationNodes};

#[derive(Component, Clone, Default, Deref, DerefMut)]
pub struct AnimationWeights(pub HashMap<AnimationName, f32>);

Expand Down
Loading
Loading