From 4de5489367c490261c72d50d7438013f904cdd56 Mon Sep 17 00:00:00 2001 From: jshipsey Date: Tue, 11 Jun 2019 00:08:55 -0400 Subject: [PATCH] groundwork for role, crun, cidle --- common/src/comp/animation.rs | 3 + common/src/comp/controller.rs | 5 +- common/src/comp/inputs.rs | 53 ++++++++++++++ common/src/comp/mod.rs | 3 + common/src/msg/ecs_packet.rs | 8 +++ common/src/state.rs | 3 + common/src/sys/animation.rs | 15 +++- common/src/sys/controller.rs | 16 ++++- common/src/sys/phys.rs | 20 +++++- voxygen/src/anim/character/cidle.rs | 104 ++++++++++++++++++++++++++++ voxygen/src/anim/character/crun.rs | 97 ++++++++++++++++++++++++++ voxygen/src/anim/character/mod.rs | 7 ++ voxygen/src/anim/character/roll.rs | 98 ++++++++++++++++++++++++++ voxygen/src/scene/figure.rs | 15 ++++ voxygen/src/session.rs | 9 +++ voxygen/src/settings.rs | 8 +++ voxygen/src/window.rs | 7 ++ 17 files changed, 463 insertions(+), 8 deletions(-) create mode 100644 voxygen/src/anim/character/cidle.rs create mode 100644 voxygen/src/anim/character/crun.rs create mode 100644 voxygen/src/anim/character/roll.rs diff --git a/common/src/comp/animation.rs b/common/src/comp/animation.rs index 85ec2e1453..d3e89dc18c 100644 --- a/common/src/comp/animation.rs +++ b/common/src/comp/animation.rs @@ -7,6 +7,9 @@ pub enum Animation { Jump, Gliding, Attack, + Roll, + Crun, + Cidle, } #[derive(Copy, Clone, Debug, Serialize, Deserialize)] diff --git a/common/src/comp/controller.rs b/common/src/comp/controller.rs index 83383e5674..8e5fd5db4f 100644 --- a/common/src/comp/controller.rs +++ b/common/src/comp/controller.rs @@ -5,8 +5,11 @@ use vek::*; pub struct Controller { pub move_dir: Vec2, pub jump: bool, - pub glide: bool, pub attack: bool, + pub roll: bool, + pub crun: bool, + pub cidle: bool, + pub glide: bool, pub respawn: bool, } diff --git a/common/src/comp/inputs.rs b/common/src/comp/inputs.rs index 1ae61033b8..c2afea0432 100644 --- a/common/src/comp/inputs.rs +++ b/common/src/comp/inputs.rs @@ -13,6 +13,24 @@ pub struct Attacking { pub applied: bool, } +#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)] +pub struct Rolling { + pub time: f32, + pub applied: bool, +} + +#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)] +pub struct Crunning { + pub time: f32, + pub applied: bool, +} + +#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)] +pub struct Cidling { + pub time: f32, + pub applied: bool, +} + #[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)] pub struct OnGround; @@ -35,6 +53,32 @@ impl Attacking { } } +impl Rolling { + pub fn start() -> Self { + Self { + time: 0.0, + applied: false, + } + } +} + +impl Crunning { + pub fn start() -> Self { + Self { + time: 0.0, + applied: false, + } + } +} +impl Cidling { + pub fn start() -> Self { + Self { + time: 0.0, + applied: false, + } + } +} + impl Component for MoveDir { type Storage = VecStorage; } @@ -43,6 +87,15 @@ impl Component for Attacking { type Storage = FlaggedStorage>; } +impl Component for Rolling { + type Storage = FlaggedStorage>; +} +impl Component for Crunning { + type Storage = FlaggedStorage>; +} +impl Component for Cidling { + type Storage = FlaggedStorage>; +} impl Component for OnGround { type Storage = NullStorage; } diff --git a/common/src/comp/mod.rs b/common/src/comp/mod.rs index 92d785dd77..88af37d3cb 100644 --- a/common/src/comp/mod.rs +++ b/common/src/comp/mod.rs @@ -18,6 +18,9 @@ pub use animation::Animation; pub use animation::AnimationInfo; pub use controller::Controller; pub use inputs::Attacking; +pub use inputs::Rolling; +pub use inputs::Crunning; +pub use inputs::Cidling; pub use inputs::Gliding; pub use inputs::Jumping; pub use inputs::MoveDir; diff --git a/common/src/msg/ecs_packet.rs b/common/src/msg/ecs_packet.rs index 5d860ae85c..6918bfdf89 100644 --- a/common/src/msg/ecs_packet.rs +++ b/common/src/msg/ecs_packet.rs @@ -24,6 +24,10 @@ sphynx::sum_type! { Player(comp::Player), Stats(comp::Stats), Attacking(comp::Attacking), + Rolling(comp::Rolling), + Crunning(comp::Crunning), + Cidling(comp::Cidling), + } } // Automatically derive From for EcsCompPhantom @@ -38,6 +42,10 @@ sphynx::sum_type! { Player(PhantomData), Stats(PhantomData), Attacking(PhantomData), + Rolling(PhantomData), + Crunning(PhantomData), + Cidling(PhantomData), + } } impl sphynx::CompPacket for EcsCompPacket { diff --git a/common/src/state.rs b/common/src/state.rs index de959c47c4..dd01b34ac2 100644 --- a/common/src/state.rs +++ b/common/src/state.rs @@ -103,6 +103,9 @@ impl State { ecs.register_synced::(); ecs.register_synced::(); ecs.register_synced::(); // TODO: Don't send this to the client? + ecs.register_synced::(); // TODO: Don't send this to the client? + ecs.register_synced::(); // TODO: Don't send this to the client? + ecs.register_synced::(); // TODO: Don't send this to the client? ecs.register::(); // Register components synced by other means diff --git a/common/src/sys/animation.rs b/common/src/sys/animation.rs index 29d5b08d7a..ea7e617d38 100644 --- a/common/src/sys/animation.rs +++ b/common/src/sys/animation.rs @@ -1,5 +1,5 @@ use crate::{ - comp::{phys, Animation, AnimationInfo, Attacking, Gliding, Jumping, OnGround}, + comp::{phys, Animation, AnimationInfo, Attacking, Rolling, Crunning, Cidling, Gliding, Jumping, OnGround}, state::DeltaTime, }; use specs::{Entities, Join, Read, ReadStorage, System, WriteStorage}; @@ -15,20 +15,26 @@ impl<'a> System<'a> for Sys { ReadStorage<'a, Jumping>, ReadStorage<'a, Gliding>, ReadStorage<'a, Attacking>, + ReadStorage<'a, Rolling>, + ReadStorage<'a, Crunning>, + ReadStorage<'a, Cidling>, WriteStorage<'a, AnimationInfo>, ); fn run( &mut self, - (entities, dt, velocities, on_grounds, jumpings, glidings, attackings, mut animation_infos): Self::SystemData, + (entities, dt, velocities, on_grounds, jumpings, glidings, attackings, rollings, crunnings, cidlings, mut animation_infos): Self::SystemData, ) { - for (entity, vel, on_ground, jumping, gliding, attacking, mut animation_info) in ( + for (entity, vel, on_ground, jumping, gliding, attacking, rolling, crunning, cidling, mut animation_info) in ( &entities, &velocities, on_grounds.maybe(), jumpings.maybe(), glidings.maybe(), attackings.maybe(), + rollings.maybe(), + crunnings.maybe(), + cidlings.maybe(), &mut animation_infos, ) .join() @@ -52,6 +58,9 @@ impl<'a> System<'a> for Sys { (false, _, false, false) => Animation::Jump, (_, _, false, true) => Animation::Gliding, (_, _, true, false) => Animation::Attack, + (true, true, false, false) => Animation::Roll, + (_, true, false, false) => Animation::Crun, + (true, false, false, false) => Animation::Cidle, (_, _, true, true) => impossible_animation(), }; diff --git a/common/src/sys/controller.rs b/common/src/sys/controller.rs index d32cb7eae4..9a01134fae 100644 --- a/common/src/sys/controller.rs +++ b/common/src/sys/controller.rs @@ -1,7 +1,8 @@ use crate::{ comp::{ phys::{ForceUpdate, Ori, Pos, Vel}, - Attacking, Controller, Gliding, Jumping, MoveDir, OnGround, Respawning, Stats, + Animation, AnimationInfo, Attacking, Rolling, Crunning, Cidling, Controller, Gliding, HealthSource, Jumping, MoveDir, + OnGround, Respawning, Stats, }, state::DeltaTime, }; @@ -22,6 +23,9 @@ impl<'a> System<'a> for Sys { WriteStorage<'a, OnGround>, WriteStorage<'a, Jumping>, WriteStorage<'a, Attacking>, + WriteStorage<'a, Rolling>, + WriteStorage<'a, Crunning>, + WriteStorage<'a, Cidling>, WriteStorage<'a, Respawning>, WriteStorage<'a, Gliding>, WriteStorage<'a, ForceUpdate>, @@ -41,6 +45,9 @@ impl<'a> System<'a> for Sys { mut on_grounds, mut jumpings, mut attackings, + mut rollings, + mut crunnings, + mut cidlings, mut respawns, mut glidings, force_updates, @@ -107,6 +114,13 @@ impl<'a> System<'a> for Sys { } else { jumping = None; } + + // Roll + if on_grounds.get(entity).is_some() && controller.roll { + rollings.insert(entity, Rolling::start()); + } else { + rollings.remove(entity); + } } } } diff --git a/common/src/sys/phys.rs b/common/src/sys/phys.rs index 1fa7d7c848..a63837295d 100644 --- a/common/src/sys/phys.rs +++ b/common/src/sys/phys.rs @@ -1,7 +1,7 @@ use crate::{ comp::{ phys::{Ori, Pos, Vel}, - Gliding, Jumping, MoveDir, OnGround, Stats, + Gliding, Jumping, MoveDir, OnGround, Stats, Rolling, Cidling, Crunning, }, state::DeltaTime, terrain::TerrainMap, @@ -58,7 +58,10 @@ impl<'a> System<'a> for Sys { ReadStorage<'a, MoveDir>, ReadStorage<'a, Jumping>, ReadStorage<'a, Gliding>, - WriteStorage<'a, Stats>, + ReadStorage<'a, Rolling>, + ReadStorage<'a, Crunning>, + ReadStorage<'a, Cidling>, + ReadStorage<'a, Stats>, ); fn run( @@ -74,11 +77,14 @@ impl<'a> System<'a> for Sys { move_dirs, jumpings, glidings, + rollings, + crunnings, + cidlings, stats, ): Self::SystemData, ) { // Apply movement inputs - for (entity, mut pos, mut vel, mut ori, mut on_ground, move_dir, jumping, gliding, stats) in + for (entity, mut pos, mut vel, mut ori, mut on_ground, move_dir, jumping, gliding, rolling, crunning, cidling, stats) in ( &entities, &mut positions, @@ -88,6 +94,9 @@ impl<'a> System<'a> for Sys { move_dirs.maybe(), jumpings.maybe(), glidings.maybe(), + rollings.maybe(), + crunnings.maybe(), + cidlings.maybe(), &stats, ) .join() @@ -122,6 +131,11 @@ impl<'a> System<'a> for Sys { vel.0.z += dt.0 * lift * Vec2::::from(vel.0 * 0.15).magnitude().min(1.0); } + // TODO: + if rolling.is_some() {} + if crunning.is_some() {} + if cidling.is_some() {} + // Set direction based on velocity if vel.0.magnitude_squared() != 0.0 { ori.0 = vel.0.normalized() * Vec3::new(1.0, 1.0, 0.0); diff --git a/voxygen/src/anim/character/cidle.rs b/voxygen/src/anim/character/cidle.rs new file mode 100644 index 0000000000..e8f44cd1f0 --- /dev/null +++ b/voxygen/src/anim/character/cidle.rs @@ -0,0 +1,104 @@ +use super::{super::Animation, CharacterSkeleton}; +use std::{f32::consts::PI, ops::Mul}; +use vek::*; + +pub struct CidleAnimation; + +impl Animation for CidleAnimation { + type Skeleton = CharacterSkeleton; + type Dependency = f64; + + fn update_skeleton( + skeleton: &Self::Skeleton, + global_time: f64, + anim_time: f64, + ) -> Self::Skeleton { + let mut next = (*skeleton).clone(); + + let wave_ultra_slow = (anim_time as f32 * 1.0 + PI).sin(); + let wave_ultra_slow_cos = (anim_time as f32 * 1.0 + PI).cos(); + + let head_look = Vec2::new( + ((global_time + anim_time) as f32 / 8.0) + .floor() + .mul(7331.0) + .sin() + * 0.5, + ((global_time + anim_time) as f32 / 8.0) + .floor() + .mul(1337.0) + .sin() + * 0.25, + ); + next.head.offset = Vec3::new(0.0, 2.0, 11.0 + wave_ultra_slow * 0.3); + next.head.ori = Quaternion::rotation_z(head_look.x) * Quaternion::rotation_x(head_look.y); + next.head.scale = Vec3::one(); + + next.chest.offset = Vec3::new(0.0, 0.0, 7.0 + wave_ultra_slow * 0.3); + next.chest.ori = Quaternion::rotation_x(0.0); + next.chest.scale = Vec3::one(); + + next.belt.offset = Vec3::new(0.0, 0.0, 5.0 + wave_ultra_slow * 0.3); + next.belt.ori = Quaternion::rotation_x(0.0); + next.belt.scale = Vec3::one(); + + next.shorts.offset = Vec3::new(0.0, 0.0, 2.0 + wave_ultra_slow * 0.3); + next.shorts.ori = Quaternion::rotation_x(0.0); + next.shorts.scale = Vec3::one(); + + 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; + + next.l_hand.ori = Quaternion::rotation_x(0.0 + wave_ultra_slow * 0.06); + next.l_hand.scale = Vec3::one() / 11.0; + + 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.; + + next.l_foot.offset = Vec3::new(-3.4, -0.1, 8.0); + next.l_foot.ori = Quaternion::identity(); + next.l_foot.scale = Vec3::one(); + + next.r_foot.offset = Vec3::new(3.4, -0.1, 8.0); + next.r_foot.ori = Quaternion::identity(); + 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.scale = Vec3::one(); + + next.l_shoulder.offset = Vec3::new(-10.0, -3.2, 2.5); + next.l_shoulder.ori = Quaternion::rotation_x(0.0); + next.l_shoulder.scale = Vec3::one() * 1.04; + + next.r_shoulder.offset = Vec3::new(0.0, -3.2, 2.5); + next.r_shoulder.ori = Quaternion::rotation_x(0.0); + next.r_shoulder.scale = Vec3::one() * 1.04; + + next.draw.offset = Vec3::new(0.0, 5.0, 0.0); + next.draw.ori = Quaternion::rotation_y(0.0); + next.draw.scale = Vec3::one() * 0.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.ori = Quaternion::rotation_x(0.0);; + next.right_equip.scale = Vec3::one() * 0.0; + + next.torso.offset = Vec3::new(0.0, -0.2, 0.1); + next.torso.ori = Quaternion::rotation_x(0.0); + next.torso.scale = Vec3::one() / 11.0; + + next + } +} diff --git a/voxygen/src/anim/character/crun.rs b/voxygen/src/anim/character/crun.rs new file mode 100644 index 0000000000..54b7c079a8 --- /dev/null +++ b/voxygen/src/anim/character/crun.rs @@ -0,0 +1,97 @@ +use super::{super::Animation, CharacterSkeleton}; +use std::ops::Mul; +use vek::*; + +pub struct CrunAnimation; + +impl Animation for CrunAnimation { + type Skeleton = CharacterSkeleton; + type Dependency = (f32, f64); + + fn update_skeleton( + skeleton: &Self::Skeleton, + (velocity, global_time): Self::Dependency, + anim_time: f64, + ) -> Self::Skeleton { + let mut next = (*skeleton).clone(); + + let wave = (anim_time as f32 * 14.0).sin(); + let wave_cos = (anim_time as f32 * 14.0).cos(); + + let head_look = Vec2::new( + ((global_time + anim_time) as f32 / 2.0) + .floor() + .mul(7331.0) + .sin() + * 0.2, + ((global_time + anim_time) as f32 / 2.0) + .floor() + .mul(1337.0) + .sin() + * 0.1, + ); + + next.head.offset = Vec3::new(0.0, 3.0, 12.0 + wave_cos * 1.3); + next.head.ori = Quaternion::rotation_z(head_look.x + wave * 0.1) + * Quaternion::rotation_x(head_look.y + 0.35); + next.head.scale = Vec3::one(); + + next.chest.offset = Vec3::new(0.0, 0.0, 7.0 + wave_cos * 1.1); + next.chest.ori = Quaternion::rotation_z(wave * 0.1); + next.chest.scale = Vec3::one(); + + next.belt.offset = Vec3::new(0.0, 0.0, 5.0 + wave_cos * 1.1); + next.belt.ori = Quaternion::rotation_z(wave * 0.25); + next.belt.scale = Vec3::one(); + + next.shorts.offset = Vec3::new(0.0, 0.0, 2.0 + wave_cos * 1.1); + 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.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.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); + next.l_foot.scale = Vec3::one(); + + next.r_foot.offset = Vec3::new(3.4, 0.0 - wave_cos * 1.0, 6.0); + next.r_foot.ori = Quaternion::rotation_x(-0.0 + wave_cos * 1.5); + 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.scale = Vec3::one(); + + next.l_shoulder.offset = Vec3::new(-10.0, -3.2, 2.5); + next.l_shoulder.ori = Quaternion::rotation_x(0.0); + next.l_shoulder.scale = Vec3::one() * 1.04; + + next.r_shoulder.offset = Vec3::new(0.0, -3.2, 2.5); + next.r_shoulder.ori = Quaternion::rotation_x(0.0); + next.r_shoulder.scale = Vec3::one() * 1.04; + + next.draw.offset = Vec3::new(0.0, 5.0, 0.0); + next.draw.ori = Quaternion::rotation_y(0.0); + next.draw.scale = Vec3::one() * 0.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.ori = Quaternion::rotation_x(0.0);; + 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.scale = Vec3::one() / 11.0; + + next + } +} diff --git a/voxygen/src/anim/character/mod.rs b/voxygen/src/anim/character/mod.rs index 8311183815..b0c4a4f67d 100644 --- a/voxygen/src/anim/character/mod.rs +++ b/voxygen/src/anim/character/mod.rs @@ -3,6 +3,9 @@ pub mod gliding; pub mod idle; pub mod jump; pub mod run; +pub mod roll; +pub mod crun; +pub mod cidle; // Reexports pub use self::attack::AttackAnimation; @@ -10,6 +13,10 @@ pub use self::gliding::GlidingAnimation; pub use self::idle::IdleAnimation; pub use self::jump::JumpAnimation; pub use self::run::RunAnimation; +pub use self::roll::RollAnimation; +pub use self::crun::CrunAnimation; +pub use self::cidle::CidleAnimation; + use super::{Bone, Skeleton}; use crate::render::FigureBoneData; diff --git a/voxygen/src/anim/character/roll.rs b/voxygen/src/anim/character/roll.rs new file mode 100644 index 0000000000..88b9ca0f54 --- /dev/null +++ b/voxygen/src/anim/character/roll.rs @@ -0,0 +1,98 @@ +use super::{super::Animation, CharacterSkeleton}; +use std::{f32::consts::PI, ops::Mul}; +use vek::*; + +pub struct RollAnimation; + +impl Animation for RollAnimation { + type Skeleton = CharacterSkeleton; + type Dependency = f64; + + fn update_skeleton( + skeleton: &Self::Skeleton, + global_time: f64, + anim_time: f64, + ) -> Self::Skeleton { + let mut next = (*skeleton).clone(); + + let wave = (anim_time as f32 * 4.0).sin(); + let wave_quick = (anim_time as f32 * 7.0).sin(); + let wave_quick_cos = (anim_time as f32 * 7.0).cos(); + let wave_cos = (anim_time as f32 * 4.0).cos(); + 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.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.ori = Quaternion::rotation_x(wave_dub * -0.5); + next.chest.scale = Vec3::one() * 1.01; + + next.belt.offset = Vec3::new(0.0, 0.0, 5.0); + next.belt.ori = Quaternion::rotation_x(0.0); + next.belt.scale = Vec3::one(); + + next.shorts.offset = Vec3::new(0.0, 0.0, 2.0); + next.shorts.ori = Quaternion::rotation_x(0.0); + next.shorts.scale = Vec3::one(); + + 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; + + 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.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; + 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.l_foot.offset = Vec3::new(-3.4, -0.1, 9.0 - 0.0 + wave * 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.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.ori = + Quaternion::rotation_y(2.5) * Quaternion::rotation_z(1.57 + wave_quick * 1.0); + next.weapon.scale = Vec3::one(); + + next.l_shoulder.offset = Vec3::new(-10.0, -3.2, 2.5); + next.l_shoulder.ori = Quaternion::rotation_x(0.0); + next.l_shoulder.scale = Vec3::one() * 1.04; + + next.r_shoulder.offset = Vec3::new(0.0, -3.2, 2.5); + next.r_shoulder.ori = Quaternion::rotation_x(0.0); + next.r_shoulder.scale = Vec3::one() * 1.04; + + next.draw.offset = Vec3::new(0.0, 5.0, 0.0); + next.draw.ori = Quaternion::rotation_y(0.0); + next.draw.scale = Vec3::one() * 0.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.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.ori = Quaternion::rotation_x(wave_slow * 6.0); + next.torso.scale = Vec3::one() / 11.0; + next + } +} diff --git a/voxygen/src/scene/figure.rs b/voxygen/src/scene/figure.rs index 815c5bcb42..a92a16e9d7 100644 --- a/voxygen/src/scene/figure.rs +++ b/voxygen/src/scene/figure.rs @@ -556,6 +556,21 @@ impl FigureMgr { time, animation_info.time, ), + comp::Animation::Roll => character::RollAnimation::update_skeleton( + state.skeleton_mut(), + time, + animation_info.time, + ), + comp::Animation::Crun => character::CrunAnimation::update_skeleton( + state.skeleton_mut(), + (vel.0.magnitude(), time), + animation_info.time, + ), + comp::Animation::Cidle => character::CidleAnimation::update_skeleton( + state.skeleton_mut(), + time, + animation_info.time, + ), comp::Animation::Gliding => { character::GlidingAnimation::update_skeleton( state.skeleton_mut(), diff --git a/voxygen/src/session.rs b/voxygen/src/session.rs index dd5f038a75..aad72636c6 100644 --- a/voxygen/src/session.rs +++ b/voxygen/src/session.rs @@ -119,6 +119,15 @@ impl PlayState for SessionState { self.controller.attack = state; self.controller.respawn = state; // TODO: Don't do both } + Event::InputUpdate(GameInput::Roll, state) => { + self.controller.roll = state; + } + Event::InputUpdate(GameInput::Crun, state) => { + self.controller.crun = state; + } + Event::InputUpdate(GameInput::Cidle, state) => { + self.controller.cidle = state; + } Event::InputUpdate(GameInput::Jump, state) => { self.controller.jump = state; } diff --git a/voxygen/src/settings.rs b/voxygen/src/settings.rs index 0e8d73cc18..9d116fa124 100644 --- a/voxygen/src/settings.rs +++ b/voxygen/src/settings.rs @@ -31,6 +31,11 @@ pub struct ControlSettings { pub screenshot: KeyMouse, pub toggle_ingame_ui: KeyMouse, pub attack: KeyMouse, + pub roll: KeyMouse, + pub crun: KeyMouse, + pub cidle: KeyMouse, + + } impl Default for ControlSettings { @@ -59,6 +64,9 @@ impl Default for ControlSettings { screenshot: KeyMouse::Key(VirtualKeyCode::F4), toggle_ingame_ui: KeyMouse::Key(VirtualKeyCode::F6), attack: KeyMouse::Mouse(MouseButton::Left), + roll: KeyMouse::Mouse(MouseButton::Middle), + crun: KeyMouse::Key(VirtualKeyCode::K), + cidle: KeyMouse::Key(VirtualKeyCode::J), } } } diff --git a/voxygen/src/window.rs b/voxygen/src/window.rs index fd158a4708..22aef60d8a 100644 --- a/voxygen/src/window.rs +++ b/voxygen/src/window.rs @@ -34,6 +34,9 @@ pub enum GameInput { Screenshot, ToggleIngameUi, Attack, + Roll, + Crun, + Cidle, Respawn, } @@ -134,6 +137,10 @@ impl Window { GameInput::ToggleIngameUi, ); key_map.insert(settings.controls.attack, GameInput::Attack); + key_map.insert(settings.controls.roll, GameInput::Roll); + key_map.insert(settings.controls.crun, GameInput::Crun); + key_map.insert(settings.controls.cidle, GameInput::Cidle); + Ok(Self { events_loop,