diff --git a/voxygen/src/anim/character/attack.rs b/voxygen/src/anim/character/alpha.rs similarity index 98% rename from voxygen/src/anim/character/attack.rs rename to voxygen/src/anim/character/alpha.rs index ca41ed49b0..e2a0ac9a0d 100644 --- a/voxygen/src/anim/character/attack.rs +++ b/voxygen/src/anim/character/alpha.rs @@ -3,12 +3,9 @@ use common::comp::item::ToolKind; use std::f32::consts::PI; use vek::*; -pub struct Input { - pub attack: bool, -} -pub struct AttackAnimation; +pub struct AlphaAnimation; -impl Animation for AttackAnimation { +impl Animation for AlphaAnimation { type Dependency = (Option, f32, f64); type Skeleton = CharacterSkeleton; @@ -25,9 +22,12 @@ impl Animation for AttackAnimation { let lab = 1.0; let foot = (((5.0) - / (1.1 + 3.9 * ((anim_time as f32 * lab as f32 * 13.0).sin()).powf(2.0 as f32))) + / (1.1 + + 3.9 + * ((anim_time as f32 * lab as f32 * 1.3 * velocity).sin()).powf(2.0 as f32))) .sqrt()) - * ((anim_time as f32 * lab as f32 * 13.0).sin()); + * ((anim_time as f32 * lab as f32 * 1.3 * velocity).sin()); + let accel_med = 1.0 - (anim_time as f32 * 16.0 * lab as f32).cos(); let accel_slow = 1.0 - (anim_time as f32 * 12.0 * lab as f32).cos(); let accel_fast = 1.0 - (anim_time as f32 * 24.0 * lab as f32).cos(); @@ -86,8 +86,8 @@ impl Animation for AttackAnimation { next.main.scale = Vec3::one(); next.control.offset = Vec3::new(-8.0 - slow * 1.0, 3.0 - slow * 5.0, 0.0); - next.control.ori = Quaternion::rotation_x(-1.2) - * Quaternion::rotation_y(slow * 1.5) + next.control.ori = Quaternion::rotation_x(-1.4) + * Quaternion::rotation_y(slow * 1.5 + 0.7) * Quaternion::rotation_z(1.4 + slow * 0.5); next.control.scale = Vec3::one(); next.l_foot.offset = Vec3::new(-3.4, foot * 3.0 + slow * -5.0, 8.0); diff --git a/voxygen/src/anim/character/beta.rs b/voxygen/src/anim/character/beta.rs new file mode 100644 index 0000000000..ffeba742a5 --- /dev/null +++ b/voxygen/src/anim/character/beta.rs @@ -0,0 +1,132 @@ +use super::{super::Animation, CharacterSkeleton, SkeletonAttr}; +use common::comp::item::ToolKind; +use std::f32::consts::PI; +use vek::*; + +pub struct BetaAnimation; + +impl Animation for BetaAnimation { + type Dependency = (Option, f32, f64); + type Skeleton = CharacterSkeleton; + + fn update_skeleton( + skeleton: &Self::Skeleton, + (active_tool_kind, velocity, _global_time): Self::Dependency, + anim_time: f64, + rate: &mut f32, + skeleton_attr: &SkeletonAttr, + ) -> Self::Skeleton { + *rate = 1.0; + let mut next = (*skeleton).clone(); + + let lab = 1.0; + + let foot = (((5.0) + / (1.1 + 3.9 * ((anim_time as f32 * lab as f32 * 1.3 * velocity).sin()).powf(2.0 as f32))) + .sqrt()) + * ((anim_time as f32 * lab as f32 * 1.3 * velocity).sin()); + + let accel_med = 1.0 - (anim_time as f32 * 16.0 * lab as f32).cos(); + let accel_slow = 1.0 - (anim_time as f32 * 12.0 * lab as f32).cos(); + let accel_fast = 1.0 - (anim_time as f32 * 24.0 * lab as f32).cos(); + let decel = (anim_time as f32 * 16.0 * lab as f32).min(PI / 2.0).sin(); + + let slow = (((5.0) + / (0.6 + 4.4 * ((anim_time as f32 * lab as f32 * 11.0).sin()).powf(2.0 as f32))) + .sqrt()) + * ((anim_time as f32 * lab as f32 * 11.0).sin()); + let slower = (((5.0) + / (0.1 + 4.9 * ((anim_time as f32 * lab as f32 * 4.0).sin()).powf(2.0 as f32))) + .sqrt()) + * ((anim_time as f32 * lab as f32 * 4.0).sin()); + let slowax = (((5.0) + / (0.1 + 4.9 * ((anim_time as f32 * lab as f32 * 4.0 + 1.9).cos()).powf(2.0 as f32))) + .sqrt()) + * ((anim_time as f32 * lab as f32 * 4.0 + 1.9).cos()); + + match active_tool_kind { + //TODO: Inventory + Some(ToolKind::Sword(_)) => { + next.head.offset = Vec3::new( + 0.0 + skeleton_attr.neck_right, + -2.0 + skeleton_attr.neck_forward, + skeleton_attr.neck_height + 14.0, + ); + next.head.ori = Quaternion::rotation_z(slow * 0.08) + * Quaternion::rotation_x(0.0 + slow * 0.08) + * Quaternion::rotation_y(slow * -0.08); + next.head.scale = Vec3::one() * skeleton_attr.head_scale; + + next.chest.offset = Vec3::new(0.0, 0.0, 7.0); + next.chest.ori = Quaternion::rotation_z(slow * -0.2) + * Quaternion::rotation_x(0.0 + slow * -0.2) + * Quaternion::rotation_y(slow * 0.2); + next.chest.scale = Vec3::one(); + + next.belt.offset = Vec3::new(0.0, 0.0, -2.0); + next.belt.ori = next.chest.ori * -0.2; + next.belt.scale = Vec3::one(); + + next.shorts.offset = Vec3::new(0.0, 0.0, -5.0); + next.shorts.ori = next.chest.ori * -0.15; + next.shorts.scale = Vec3::one(); + + next.l_hand.offset = Vec3::new(0.0, 1.0, 0.0); + next.l_hand.ori = Quaternion::rotation_x(1.27); + next.l_hand.scale = Vec3::one() * 1.04; + next.r_hand.offset = Vec3::new(0.0, 0.0, -3.0); + next.r_hand.ori = Quaternion::rotation_x(1.27); + next.r_hand.scale = Vec3::one() * 1.05; + next.main.offset = Vec3::new(0.0, 6.0, -1.0); + next.main.ori = Quaternion::rotation_x(-0.3) + * Quaternion::rotation_y(0.0) + * Quaternion::rotation_z(0.0); + next.main.scale = Vec3::one(); + + next.control.offset = Vec3::new(-8.0 - slow * 1.0, 3.0 - slow * 5.0, 0.0); + next.control.ori = Quaternion::rotation_x(-1.4) + * Quaternion::rotation_y(slow * 1.5 + 0.7) + * Quaternion::rotation_z(1.4 + slow * 0.5); + next.control.scale = Vec3::one(); + next.l_foot.offset = Vec3::new(-3.4, foot * 3.0 + slow * -5.0, 8.0); + next.l_foot.ori = Quaternion::rotation_x(foot * -0.6); + next.l_foot.scale = Vec3::one(); + + next.r_foot.offset = Vec3::new(3.4, foot * -3.0 + slow * 5.0, 8.0); + next.r_foot.ori = Quaternion::rotation_x(foot * 0.6); + next.r_foot.scale = Vec3::one(); + next.torso.offset = Vec3::new(0.0, 0.0, 0.1) * skeleton_attr.scaler; + next.torso.ori = Quaternion::rotation_z(0.0) + * Quaternion::rotation_x(0.0) + * Quaternion::rotation_y(0.0); + next.torso.scale = Vec3::one() / 11.0 * skeleton_attr.scaler; + }, + _ => {}, + } + + next.l_shoulder.offset = Vec3::new(-5.0, 0.0, 4.7); + next.l_shoulder.ori = Quaternion::rotation_x(0.0); + next.l_shoulder.scale = Vec3::one() * 1.1; + + next.r_shoulder.offset = Vec3::new(5.0, 0.0, 4.7); + next.r_shoulder.ori = Quaternion::rotation_x(0.0); + next.r_shoulder.scale = Vec3::one() * 1.1; + + next.glider.offset = Vec3::new(0.0, 5.0, 0.0); + next.glider.ori = Quaternion::rotation_y(0.0); + next.glider.scale = Vec3::one() * 0.0; + + next.lantern.offset = Vec3::new(0.0, 0.0, 0.0); + next.lantern.ori = Quaternion::rotation_x(0.0); + next.lantern.scale = Vec3::one() * 0.0; + + next.l_control.offset = Vec3::new(0.0, 0.0, 0.0); + next.l_control.ori = Quaternion::rotation_x(0.0); + next.l_control.scale = Vec3::one(); + + next.r_control.offset = Vec3::new(0.0, 0.0, 0.0); + next.r_control.ori = Quaternion::rotation_x(0.0); + next.r_control.scale = Vec3::one(); + next + } +} diff --git a/voxygen/src/anim/character/mod.rs b/voxygen/src/anim/character/mod.rs index b441d4a937..122f427312 100644 --- a/voxygen/src/anim/character/mod.rs +++ b/voxygen/src/anim/character/mod.rs @@ -1,4 +1,4 @@ -pub mod attack; +pub mod alpha; pub mod block; pub mod blockidle; pub mod charge; @@ -18,7 +18,7 @@ pub mod wield; // Reexports pub use self::{ - attack::AttackAnimation, block::BlockAnimation, blockidle::BlockIdleAnimation, + alpha::AlphaAnimation, block::BlockAnimation, blockidle::BlockIdleAnimation, charge::ChargeAnimation, climb::ClimbAnimation, equip::EquipAnimation, gliding::GlidingAnimation, idle::IdleAnimation, jump::JumpAnimation, roll::RollAnimation, run::RunAnimation, shoot::ShootAnimation, sit::SitAnimation, spin::SpinAnimation, diff --git a/voxygen/src/anim/character/shoot.rs b/voxygen/src/anim/character/shoot.rs index 2e4bfdd978..8cd71eb4be 100644 --- a/voxygen/src/anim/character/shoot.rs +++ b/voxygen/src/anim/character/shoot.rs @@ -103,7 +103,7 @@ impl Animation for ShootAnimation { * Quaternion::rotation_z(-0.6); next.main.scale = Vec3::one(); - next.control.offset = Vec3::new(-7.0, 6.0, 6.0); + next.control.offset = Vec3::new(-9.0, 6.0, 8.0); next.control.ori = Quaternion::rotation_x((sloweralt * 0.4).max(0.4)) * Quaternion::rotation_y(0.0) * Quaternion::rotation_z(0.0); diff --git a/voxygen/src/anim/character/sit.rs b/voxygen/src/anim/character/sit.rs index 0a4cad45ae..5027adf884 100644 --- a/voxygen/src/anim/character/sit.rs +++ b/voxygen/src/anim/character/sit.rs @@ -39,7 +39,7 @@ impl Animation for SitAnimation { ); next.head.offset = Vec3::new( 0.0 + skeleton_attr.neck_right, - wave_stop * -3.6 + skeleton_attr.neck_forward, + -3.0 + skeleton_attr.neck_forward, skeleton_attr.neck_height + 14.0 + wave_slow * 0.1 + wave_stop * -0.8, ); next.head.ori = diff --git a/voxygen/src/anim/character/swim.rs b/voxygen/src/anim/character/swim.rs index d5fdec6df5..9b5e1193f8 100644 --- a/voxygen/src/anim/character/swim.rs +++ b/voxygen/src/anim/character/swim.rs @@ -23,13 +23,15 @@ impl Animation for SwimAnimation { let lab = 1.0; - let short = (anim_time as f32 * lab as f32 * 2.0).sin(); + let short = (anim_time as f32 * lab as f32 * 2.0 * speed / 5.0).sin(); - let shortalt = (anim_time as f32 * lab as f32 * 2.0 + PI / 2.0).sin(); + let shortalt = (anim_time as f32 * lab as f32 * 2.0 * speed / 5.0 + PI / 2.0).sin(); - let foot = (anim_time as f32 * lab as f32 * 2.0).sin(); + let foot = (anim_time as f32 * lab as f32 * 2.0 * speed / 5.0).sin(); - let wave_stop = (anim_time as f32 * 3.0).min(PI / 2.0 / 2.0).sin(); + let wave_stop = (anim_time as f32 * 3.0 * speed / 5.0) + .min(PI / 2.0 / 2.0) + .sin(); let head_look = Vec2::new( ((global_time + anim_time) as f32 / 18.0) @@ -115,7 +117,7 @@ impl Animation for SwimAnimation { next.torso.offset = Vec3::new(0.0, -0.3 + shortalt * -0.065, 0.4) * skeleton_attr.scaler; next.torso.ori = - Quaternion::rotation_x(speed * -0.157 * wave_stop * 1.6) * Quaternion::rotation_y(0.0); + Quaternion::rotation_x(speed * -0.190 * wave_stop * 1.6) * Quaternion::rotation_y(0.0); next.torso.scale = Vec3::one() / 11.0 * skeleton_attr.scaler; next.control.offset = Vec3::new(0.0, 0.0, 0.0); diff --git a/voxygen/src/scene/figure/mod.rs b/voxygen/src/scene/figure/mod.rs index c0ae0e3530..322620727a 100644 --- a/voxygen/src/scene/figure/mod.rs +++ b/voxygen/src/scene/figure/mod.rs @@ -472,7 +472,7 @@ impl FigureMgr { ) }, CharacterState::BasicMelee(_) => { - anim::character::AttackAnimation::update_skeleton( + anim::character::AlphaAnimation::update_skeleton( &target_base, (active_tool_kind, vel.0.magnitude(), time), state.state_time, @@ -490,7 +490,7 @@ impl FigureMgr { ) }, CharacterState::Boost(_) => { - anim::character::AttackAnimation::update_skeleton( + anim::character::AlphaAnimation::update_skeleton( &target_base, (active_tool_kind, vel.0.magnitude(), time), state.state_time, @@ -509,7 +509,7 @@ impl FigureMgr { }, CharacterState::TripleStrike(s) => match s.stage { triple_strike::Stage::First => { - anim::character::AttackAnimation::update_skeleton( + anim::character::AlphaAnimation::update_skeleton( &target_base, (active_tool_kind, vel.0.magnitude(), time), state.state_time, @@ -527,7 +527,7 @@ impl FigureMgr { ) }, triple_strike::Stage::Third => { - anim::character::AttackAnimation::update_skeleton( + anim::character::AlphaAnimation::update_skeleton( &target_base, (active_tool_kind, vel.0.magnitude(), time), state.state_time, @@ -537,7 +537,7 @@ impl FigureMgr { }, }, CharacterState::TimedCombo(s) => match s.stage { - 0 | 2 => anim::character::AttackAnimation::update_skeleton( + 0 | 2 => anim::character::AlphaAnimation::update_skeleton( &target_base, (active_tool_kind, vel.0.magnitude(), time), state.state_time,