diff --git a/common/src/sys/phys.rs b/common/src/sys/phys.rs index d756b66ca1..55e1044b81 100644 --- a/common/src/sys/phys.rs +++ b/common/src/sys/phys.rs @@ -15,6 +15,8 @@ const HUMANOID_SPEED: f32 = 500.0; const HUMANOID_AIR_ACCEL: f32 = 10.0; const HUMANOID_AIR_SPEED: f32 = 100.0; const HUMANOID_JUMP_ACCEL: f32 = 16.0; +const ROLL_ACCEL: f32 = 200.0; +const ROLL_SPEED: f32 = 800.0; const GLIDE_ACCEL: f32 = 15.0; const GLIDE_SPEED: f32 = 45.0; // Gravity is 9.81 * 4, so this makes gravity equal to .15 @@ -102,12 +104,17 @@ impl<'a> System<'a> for Sys { * match ( on_grounds.get(entity).is_some(), glidings.get(entity).is_some(), + rollings.get(entity).is_some(), ) { - (true, false) if vel.0.magnitude() < HUMANOID_SPEED => HUMANOID_ACCEL, - (false, true) if vel.0.magnitude() < GLIDE_SPEED => GLIDE_ACCEL, - (false, false) if vel.0.magnitude() < HUMANOID_AIR_SPEED => { + (true, false, false) if vel.0.magnitude() < HUMANOID_SPEED => { + HUMANOID_ACCEL + } + (false, true, false) if vel.0.magnitude() < GLIDE_SPEED => GLIDE_ACCEL, + (false, false, false) if vel.0.magnitude() < HUMANOID_AIR_SPEED => { HUMANOID_AIR_ACCEL } + (true, false, true) if vel.0.magnitude() < ROLL_SPEED => ROLL_ACCEL, + _ => 0.0, }; } diff --git a/voxygen/src/anim/character/attack.rs b/voxygen/src/anim/character/attack.rs index ab8e7bf109..4676411c0c 100644 --- a/voxygen/src/anim/character/attack.rs +++ b/voxygen/src/anim/character/attack.rs @@ -46,11 +46,11 @@ impl Animation for AttackAnimation { -8.0 + wave_quicken_slow * 10.0, 4.0 + wave_quicken_double * 3.0, 9.0, - ) / 11.0; + ); next.l_hand.ori = Quaternion::rotation_z(-0.8) * Quaternion::rotation_x(0.0 + wave_quicken * -0.8) * Quaternion::rotation_y(0.0 + wave_quicken * -0.4); - next.l_hand.scale = Vec3::one() / 11.0; + next.l_hand.scale = Vec3::one(); next.r_hand.offset = Vec3::new(0.0, -2.0, 6.5) / 11.0; next.r_hand.ori = Quaternion::rotation_x(0.0); diff --git a/voxygen/src/anim/character/cidle.rs b/voxygen/src/anim/character/cidle.rs index e8f44cd1f0..7baff85c1e 100644 --- a/voxygen/src/anim/character/cidle.rs +++ b/voxygen/src/anim/character/cidle.rs @@ -73,7 +73,7 @@ impl Animation for CidleAnimation { next.weapon.offset = Vec3::new(-7.0, -5.0, 15.0); next.weapon.ori = Quaternion::rotation_y(2.5) * Quaternion::rotation_z(1.57); - next.weapon.scale = Vec3::one(); + next.weapon.scale = Vec3::one() * 0.0; next.l_shoulder.offset = Vec3::new(-10.0, -3.2, 2.5); next.l_shoulder.ori = Quaternion::rotation_x(0.0); diff --git a/voxygen/src/anim/character/crun.rs b/voxygen/src/anim/character/crun.rs index 54b7c079a8..7b1adb5047 100644 --- a/voxygen/src/anim/character/crun.rs +++ b/voxygen/src/anim/character/crun.rs @@ -66,7 +66,7 @@ impl Animation for CrunAnimation { next.weapon.offset = Vec3::new(-7.0, -5.0, 15.0); next.weapon.ori = Quaternion::rotation_y(2.5) * Quaternion::rotation_z(1.57); - next.weapon.scale = Vec3::one(); + next.weapon.scale = Vec3::one() * 0.0; next.l_shoulder.offset = Vec3::new(-10.0, -3.2, 2.5); next.l_shoulder.ori = Quaternion::rotation_x(0.0); diff --git a/voxygen/src/anim/character/gliding.rs b/voxygen/src/anim/character/gliding.rs index 8c21326638..82edf35f15 100644 --- a/voxygen/src/anim/character/gliding.rs +++ b/voxygen/src/anim/character/gliding.rs @@ -6,11 +6,11 @@ pub struct GlidingAnimation; impl Animation for GlidingAnimation { type Skeleton = CharacterSkeleton; - type Dependency = f64; + type Dependency = (f32, f64); fn update_skeleton( skeleton: &Self::Skeleton, - global_time: f64, + (velocity, global_time): Self::Dependency, anim_time: f64, ) -> Self::Skeleton { let mut next = (*skeleton).clone(); @@ -35,48 +35,40 @@ impl Animation for GlidingAnimation { .sin() * 0.25, ); - next.head.offset = Vec3::new(0.0, 2.0, 12.0); + next.head.offset = Vec3::new(0.0, 2.0, 2.0); next.head.ori = Quaternion::rotation_x(0.35 - wave_very_slow * 0.10 + head_look.y) * Quaternion::rotation_z(head_look.x + wave_very_slow_cos * 0.15); next.head.scale = Vec3::one(); - next.chest.offset = Vec3::new(0.0, 0.0, 8.0); + next.chest.offset = Vec3::new(0.0, 0.0, -2.0); next.chest.ori = Quaternion::rotation_z(wave_very_slow_cos * 0.15); next.chest.scale = Vec3::one(); - next.belt.offset = Vec3::new(0.0, 0.0, 6.0); + next.belt.offset = Vec3::new(0.0, 0.0, -4.0); next.belt.ori = Quaternion::rotation_z(wave_very_slow_cos * 0.20); next.belt.scale = Vec3::one(); - next.shorts.offset = Vec3::new(0.0, 0.0, 3.0); + next.shorts.offset = Vec3::new(0.0, 0.0, -7.0); next.shorts.ori = Quaternion::rotation_z(wave_very_slow_cos * 0.25); next.shorts.scale = Vec3::one(); - next.l_hand.offset = Vec3::new( - -10.0, - 6.0 - wave_very_slow * 1.50, - 15.0 + wave_very_slow * 0.50, - ) / 11.0; - next.l_hand.ori = Quaternion::rotation_x(0.2 + wave_very_slow_cos * 0.05); - next.l_hand.scale = Vec3::one() / 11.0; + next.l_hand.offset = Vec3::new(-10.0, -2.0 + wave_very_slow * 0.10, 10.5); + next.l_hand.ori = Quaternion::rotation_x(1.0 + wave_very_slow_cos * -0.10); + next.l_hand.scale = Vec3::one(); - next.r_hand.offset = Vec3::new( - 10.0, - 6.0 - wave_very_slow * 1.50, - 14.5 + wave_very_slow * 0.50, - ) / 11.0; - next.r_hand.ori = Quaternion::rotation_x(0.1 + wave_very_slow * 0.05); - next.r_hand.scale = Vec3::one() / 11.0; + next.r_hand.offset = Vec3::new(10.0, -2.0 + wave_very_slow * 0.10, 10.5); + next.r_hand.ori = Quaternion::rotation_x(1.0 + wave_very_slow_cos * -0.10); + next.r_hand.scale = Vec3::one(); - next.l_foot.offset = Vec3::new(-3.4, 1.0, 8.0); + next.l_foot.offset = Vec3::new(-3.4, 1.0, -2.0); next.l_foot.ori = Quaternion::rotation_x( - wave_stop * -0.7 - wave_slow_cos * -0.21 + wave_very_slow * 0.19, + (wave_stop * -0.7 - wave_slow_cos * -0.21 + wave_very_slow * 0.19) * velocity * 0.07, ); next.l_foot.scale = Vec3::one(); - next.r_foot.offset = Vec3::new(3.4, 1.0, 8.0); + next.r_foot.offset = Vec3::new(3.4, 1.0, -2.0); next.r_foot.ori = Quaternion::rotation_x( - wave_stop * -0.8 + wave_slow * -0.25 + wave_very_slow_alt * 0.13, + (wave_stop * -0.8 + wave_slow * -0.25 + wave_very_slow_alt * 0.13) * velocity * 0.07, ); next.r_foot.scale = Vec3::one(); @@ -92,21 +84,21 @@ impl Animation for GlidingAnimation { next.r_shoulder.ori = Quaternion::rotation_x(0.0); next.r_shoulder.scale = Vec3::one() * 1.04; - next.draw.offset = Vec3::new(0.0, -9.0 + wave_very_slow * 0.10, 18.0); - next.draw.ori = Quaternion::rotation_x(0.95 - wave_very_slow * 0.15) + next.draw.offset = Vec3::new(0.0, -9.0 + wave_very_slow * 0.10, 8.0); + next.draw.ori = Quaternion::rotation_x(1.0)//0.95 - wave_very_slow * 0.08) * Quaternion::rotation_y(wave_very_slow_cos * 0.04); next.draw.scale = Vec3::one(); - next.left_equip.offset = Vec3::new(0.0, 0.0, 5.0) / 11.0; + next.left_equip.offset = Vec3::new(0.0, 0.0, -5.0) / 11.0; next.left_equip.ori = Quaternion::rotation_x(0.0);; next.left_equip.scale = Vec3::one() * 0.0; - next.right_equip.offset = Vec3::new(0.0, 0.0, 5.0) / 11.0; + next.right_equip.offset = Vec3::new(0.0, 0.0, -5.0) / 11.0; next.right_equip.ori = Quaternion::rotation_x(0.0);; next.right_equip.scale = Vec3::one() * 0.0; - next.torso.offset = Vec3::new(0.0, -0.2, 0.0); - next.torso.ori = Quaternion::rotation_x(-0.8 + wave_very_slow * 0.10); + next.torso.offset = Vec3::new(0.0, -0.2, 10.0) / 11.0; + next.torso.ori = Quaternion::rotation_x(-0.05 * velocity + wave_very_slow * 0.10); next.torso.scale = Vec3::one() / 11.0; next diff --git a/voxygen/src/anim/character/idle.rs b/voxygen/src/anim/character/idle.rs index 9203c8b99d..8b68ff656b 100644 --- a/voxygen/src/anim/character/idle.rs +++ b/voxygen/src/anim/character/idle.rs @@ -51,20 +51,20 @@ impl Animation for IdleAnimation { next.l_hand.offset = Vec3::new( -7.5, - -2.0 + wave_ultra_slow_cos * 0.15, - 8.0 + wave_ultra_slow * 0.5, - ) / 11.0; + 0.0 + wave_ultra_slow_cos * 0.15, + 7.0 + wave_ultra_slow * 0.5, + ); - next.l_hand.ori = Quaternion::rotation_x(0.0 + wave_ultra_slow * 0.06); - next.l_hand.scale = Vec3::one() / 11.0; + next.l_hand.ori = Quaternion::rotation_x(0.0 + wave_ultra_slow * -0.06); + next.l_hand.scale = Vec3::one(); next.r_hand.offset = Vec3::new( 7.5, - -2.0 + wave_ultra_slow_cos * 0.15, - 8.0 + wave_ultra_slow * 0.5, - ) / 11.0; - next.r_hand.ori = Quaternion::rotation_x(0.0 + wave_ultra_slow * 0.06); - next.r_hand.scale = Vec3::one() / 11.; + 0.0 + wave_ultra_slow_cos * 0.15, + 7.0 + wave_ultra_slow * 0.5, + ); + next.r_hand.ori = Quaternion::rotation_x(0.0 + wave_ultra_slow * -0.06); + next.r_hand.scale = Vec3::one(); next.l_foot.offset = Vec3::new(-3.4, -0.1, 8.0); next.l_foot.ori = Quaternion::identity(); diff --git a/voxygen/src/anim/character/jump.rs b/voxygen/src/anim/character/jump.rs index 6a1e7d95fc..d3487b388f 100644 --- a/voxygen/src/anim/character/jump.rs +++ b/voxygen/src/anim/character/jump.rs @@ -39,17 +39,17 @@ impl Animation for JumpAnimation { -8.0, 0.0 + wave_stop * 3.8, 7.0 + wave_stop * 3.2 - wave * 0.4, - ) / 11.0; + ); next.l_hand.ori = Quaternion::rotation_x(wave_stop_alt * 0.6); - next.l_hand.scale = Vec3::one() / 11.0; + next.l_hand.scale = Vec3::one(); next.r_hand.offset = Vec3::new( 8.0, 0.0 + wave_stop * -3.8, 7.0 + wave_stop * 3.2 - wave * 0.4, - ) / 11.0; + ); next.r_hand.ori = Quaternion::rotation_x(-wave_stop_alt * 0.6); - next.r_hand.scale = Vec3::one() / 11.0; + next.r_hand.scale = Vec3::one(); next.l_foot.offset = Vec3::new(-3.4, 1.0, 6.0); next.l_foot.ori = Quaternion::rotation_x(wave_stop * -1.2 - wave_slow * 0.2); diff --git a/voxygen/src/anim/character/mod.rs b/voxygen/src/anim/character/mod.rs index b50f3e89ea..e570b7cf0a 100644 --- a/voxygen/src/anim/character/mod.rs +++ b/voxygen/src/anim/character/mod.rs @@ -74,8 +74,8 @@ impl Skeleton for CharacterSkeleton { FigureBoneData::new(torso_mat * chest_mat), FigureBoneData::new(torso_mat * self.belt.compute_base_matrix()), FigureBoneData::new(torso_mat * self.shorts.compute_base_matrix()), - FigureBoneData::new(l_hand_mat), - FigureBoneData::new(self.r_hand.compute_base_matrix()), + FigureBoneData::new(torso_mat * l_hand_mat), + FigureBoneData::new(torso_mat * self.r_hand.compute_base_matrix()), FigureBoneData::new(torso_mat * self.l_foot.compute_base_matrix()), FigureBoneData::new(torso_mat * self.r_foot.compute_base_matrix()), FigureBoneData::new(torso_mat * chest_mat * weapon_mat), diff --git a/voxygen/src/anim/character/roll.rs b/voxygen/src/anim/character/roll.rs index 88b9ca0f54..48e5ca8d46 100644 --- a/voxygen/src/anim/character/roll.rs +++ b/voxygen/src/anim/character/roll.rs @@ -22,11 +22,11 @@ impl Animation for RollAnimation { let wave_slow = (anim_time as f32 * 2.0 + PI).sin(); let wave_dub = (anim_time as f32 * 4.0).sin(); - next.head.offset = Vec3::new(0.0, -1.0 + wave_slow * -3.0, 16.0 + wave_dub * -3.0); + next.head.offset = Vec3::new(0.0, 0.0 + wave_slow * -3.0, 9.0 + wave_dub * -5.0); next.head.ori = Quaternion::rotation_x(wave_dub * -0.4); next.head.scale = Vec3::one(); - next.chest.offset = Vec3::new(0.0, 0.0, 7.0 + wave_dub * -1.5); + next.chest.offset = Vec3::new(0.0, 0.0, 7.0 + wave_dub * -2.5); next.chest.ori = Quaternion::rotation_x(wave_dub * -0.5); next.chest.scale = Vec3::one() * 1.01; @@ -40,32 +40,32 @@ impl Animation for RollAnimation { next.l_hand.offset = Vec3::new( -5.5 + wave * -0.5, - -2.0 + wave_quick_cos * 5.5, - 8.0 + wave_quick * -5.5, - ) / 11.0; + -2.0 + wave_quick_cos * -5.5, + 8.0 + wave_quick * 0.5, + ); next.l_hand.ori = Quaternion::rotation_x(wave_slow * 6.5) * Quaternion::rotation_y(wave * 0.3); - next.l_hand.scale = Vec3::one() / 11.0; + next.l_hand.scale = Vec3::one(); next.r_hand.offset = Vec3::new( 5.5 + wave * 0.5, - -2.0 + wave_quick_cos * 5.5, - 8.0 + wave_quick * -5.5, - ) / 11.0; + -2.0 + wave_quick_cos * 2.5, + 8.0 + wave_quick * 3.0, + ); next.r_hand.ori = Quaternion::rotation_x(wave_slow * 6.5) * Quaternion::rotation_y(wave * 0.3); - next.r_hand.scale = Vec3::one() / 11.; + next.r_hand.scale = Vec3::one(); - next.l_foot.offset = Vec3::new(-3.4, -0.1, 9.0 - 0.0 + wave * 1.2); + next.l_foot.offset = Vec3::new(-3.4, -0.1, 9.0 - 0.0 + wave_dub * -1.2); next.l_foot.ori = Quaternion::rotation_x(wave * 0.6); next.l_foot.scale = Vec3::one(); - next.r_foot.offset = Vec3::new(3.4, -0.1, 9.0 - 0.0 + wave * 1.0); + next.r_foot.offset = Vec3::new(3.4, -0.1, 9.0 - 0.0 + wave_dub * -1.0); next.r_foot.ori = Quaternion::rotation_x(wave * -0.4); next.r_foot.scale = Vec3::one(); - next.weapon.offset = Vec3::new(-7.0, -7.0, 18.0); + next.weapon.offset = Vec3::new(-7.0, -7.0, 15.0); next.weapon.ori = Quaternion::rotation_y(2.5) * Quaternion::rotation_z(1.57 + wave_quick * 1.0); next.weapon.scale = Vec3::one(); @@ -90,7 +90,7 @@ impl Animation for RollAnimation { next.right_equip.ori = Quaternion::rotation_x(0.0);; next.right_equip.scale = Vec3::one() * 0.0; - next.torso.offset = Vec3::new(0.0, -2.2, 0.1 + wave_dub * 12.0) / 11.0; + next.torso.offset = Vec3::new(0.0, -2.2, 0.1 + wave_dub * 16.0) / 11.0; next.torso.ori = Quaternion::rotation_x(wave_slow * 6.0); next.torso.scale = Vec3::one() / 11.0; next diff --git a/voxygen/src/anim/character/run.rs b/voxygen/src/anim/character/run.rs index 0c188fde45..b5405cfdc7 100644 --- a/voxygen/src/anim/character/run.rs +++ b/voxygen/src/anim/character/run.rs @@ -1,4 +1,5 @@ use super::{super::Animation, CharacterSkeleton}; +use std::f32::consts::PI; use std::ops::Mul; use vek::*; @@ -17,6 +18,9 @@ impl Animation for RunAnimation { let wave = (anim_time as f32 * 14.0).sin(); let wave_cos = (anim_time as f32 * 14.0).cos(); + let wave_diff = (anim_time as f32 * 14.0 + PI / 2.0).sin(); + let wave_cos_dub = (anim_time as f32 * 28.0).cos(); + let wave_stop = (anim_time as f32 * 3.0).min(PI / 2.0).sin(); let head_look = Vec2::new( ((global_time + anim_time) as f32 / 2.0) @@ -48,13 +52,21 @@ impl Animation for RunAnimation { next.shorts.ori = Quaternion::rotation_z(wave * 0.6); next.shorts.scale = Vec3::one(); - next.l_hand.offset = Vec3::new(-9.0, 3.0 + wave_cos * 8.0, 12.0 - wave * 1.0) / 11.0; - next.l_hand.ori = Quaternion::rotation_x(wave_cos * 1.1); - next.l_hand.scale = Vec3::one() / 11.0; + next.l_hand.offset = Vec3::new( + -8.5 + wave_cos_dub * 0.8, + 2.0 + wave_cos * 6.0, + 7.0 - wave * 1.0, + ); + next.l_hand.ori = Quaternion::rotation_x(wave_cos * 0.8); + next.l_hand.scale = Vec3::one(); - next.r_hand.offset = Vec3::new(9.0, 3.0 - wave_cos * 8.0, 12.0 + wave * 1.0) / 11.0; - next.r_hand.ori = Quaternion::rotation_x(wave_cos * -1.1); - next.r_hand.scale = Vec3::one() / 11.0; + next.r_hand.offset = Vec3::new( + 8.5 - wave_cos_dub * 0.8, + 2.0 - wave_cos * 6.0, + 7.0 + wave * 1.0, + ); + next.r_hand.ori = Quaternion::rotation_x(wave_cos * -0.8); + next.r_hand.scale = Vec3::one(); next.l_foot.offset = Vec3::new(-3.4, 0.0 + wave_cos * 1.0, 6.0); next.l_foot.ori = Quaternion::rotation_x(-0.0 - wave_cos * 1.5); @@ -65,7 +77,8 @@ impl Animation for RunAnimation { next.r_foot.scale = Vec3::one(); next.weapon.offset = Vec3::new(-7.0, -5.0, 15.0); - next.weapon.ori = Quaternion::rotation_y(2.5) * Quaternion::rotation_z(1.57); + next.weapon.ori = + Quaternion::rotation_y(2.5) * Quaternion::rotation_z(1.57 + wave_cos * 0.25); next.weapon.scale = Vec3::one(); next.l_shoulder.offset = Vec3::new(-10.0, -3.2, 2.5); @@ -89,7 +102,8 @@ impl Animation for RunAnimation { next.right_equip.scale = Vec3::one() * 0.0; next.torso.offset = Vec3::new(0.0, -0.2, 0.4); - next.torso.ori = Quaternion::rotation_x(-velocity * 0.04 - wave_cos * 0.10); + next.torso.ori = + Quaternion::rotation_x(wave_stop * velocity * -0.04 + wave_diff * velocity * -0.005); next.torso.scale = Vec3::one() / 11.0; next diff --git a/voxygen/src/scene/figure.rs b/voxygen/src/scene/figure.rs index 547be1e146..8d07489fa6 100644 --- a/voxygen/src/scene/figure.rs +++ b/voxygen/src/scene/figure.rs @@ -574,7 +574,7 @@ impl FigureMgr { comp::Animation::Gliding => { character::GlidingAnimation::update_skeleton( state.skeleton_mut(), - time, + (vel.0.magnitude(), time), animation_info.time, ) }