diff --git a/assets/voxygen/voxel/glider.vox b/assets/voxygen/voxel/glider.vox new file mode 100644 index 0000000000..b688b4ef97 --- /dev/null +++ b/assets/voxygen/voxel/glider.vox @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:d7009423cc546742c28963b443e2553dfc359a72cd996f9d159d7242e7a083c7 +size 9040 diff --git a/common/src/comp/actor.rs b/common/src/comp/actor.rs index 5772350fa8..eca896ee17 100644 --- a/common/src/comp/actor.rs +++ b/common/src/comp/actor.rs @@ -223,6 +223,7 @@ pub enum Animation { Idle, Run, Jump, + Gliding, } impl Component for AnimationHistory { diff --git a/common/src/sys/control.rs b/common/src/sys/control.rs index 7c1f41ce91..d84d50c410 100644 --- a/common/src/sys/control.rs +++ b/common/src/sys/control.rs @@ -81,7 +81,7 @@ impl<'a> System<'a> for Sys { Animation::Idle } } else { - Animation::Jump + Animation::Gliding }; let last_history = anims.get_mut(entity).cloned(); diff --git a/voxygen/src/anim/character/gliding.rs b/voxygen/src/anim/character/gliding.rs new file mode 100644 index 0000000000..19ebfbece8 --- /dev/null +++ b/voxygen/src/anim/character/gliding.rs @@ -0,0 +1,105 @@ +// Standard +use std::{f32::consts::PI, ops::Mul}; + +// Library +use vek::*; + +// Local +use super::{super::Animation, CharacterSkeleton, SCALE}; +// + +pub struct GlidingAnimation; + +impl Animation for GlidingAnimation { + 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 * 14.0).sin(); + let waveslow = (anim_time as f32 * 7.0).sin(); + let wavecos_slow = (anim_time as f32 * 7.0).cos(); + let arcwave = (1.0f32.ln_1p() - 1.5).abs(); + let wavetest = (wave.cbrt()); + let fuzzwave = (anim_time as f32 * 12.0).sin(); + let wavecos = (anim_time as f32 * 14.0).cos(); + let wave_stop = (anim_time as f32 * 1.5).min(PI / 2.0).sin(); + let wave_stopalt = (anim_time as f32 * 5.0).min(PI / 2.0).sin(); + let waveveryslow = (anim_time as f32 * 3.0).sin(); + let waveveryslowalt = (anim_time as f32 * 2.5).sin(); + let waveveryslowcos = (anim_time as f32 * 3.0).cos(); + + + let wave_slowtest = (anim_time as f32).min(PI / 2.0).sin(); + + let head_look = Vec2::new( + ((global_time + anim_time) as f32 / 4.0) + .floor() + .mul(7331.0) + .sin() + * 0.5, + ((global_time + anim_time) as f32 / 4.0) + .floor() + .mul(1337.0) + .sin() + * 0.25, + ); + next.head.offset = Vec3::new(5.5, 2.0, 12.0); + next.head.ori = Quaternion::rotation_x(0.35 - waveveryslow * 0.10 + head_look.y) * Quaternion::rotation_z(head_look.x + waveveryslowcos * 0.15); + next.head.scale = Vec3::one(); + + next.chest.offset = Vec3::new(5.5, 0.0, 8.0); + next.chest.ori = Quaternion::rotation_z(waveveryslowcos * 0.15); + next.chest.scale = Vec3::one(); + + next.belt.offset = Vec3::new(5.5, 0.0, 6.0); + next.belt.ori = Quaternion::rotation_z(waveveryslowcos * 0.20); + next.belt.scale = Vec3::one(); + + next.shorts.offset = Vec3::new(5.5, 0.0, 3.0); + next.shorts.ori = Quaternion::rotation_z(waveveryslowcos * 0.25); + next.shorts.scale = Vec3::one(); + + next.l_hand.offset = Vec3::new(-8.0, -10.0 + waveveryslow * 2.5, 18.5 + waveveryslow * 1.0); + next.l_hand.ori = Quaternion::rotation_x(0.9 - waveveryslow * 0.10); + next.l_hand.scale = Vec3::one(); + + next.r_hand.offset = Vec3::new(11.0, -10.0 + waveveryslow * 2.5, 18.5 + waveveryslow * 1.0); + next.r_hand.ori = Quaternion::rotation_x(0.9 - waveveryslow * 0.10); + next.r_hand.scale = Vec3::one(); + + next.l_foot.offset = Vec3::new(-3.4, 1.0, 8.0); + next.l_foot.ori = Quaternion::rotation_x(wave_stop * -0.7 - wavecos_slow * -0.21 + waveveryslow * 0.19); + next.l_foot.scale = Vec3::one(); + + next.r_foot.offset = Vec3::new(3.4, 1.0, 8.0); + next.r_foot.ori = Quaternion::rotation_x(wave_stop * -0.8 + waveslow * -0.25 + waveveryslowalt * 0.13); + next.r_foot.scale = Vec3::one(); + + next.weapon.offset = Vec3::new(-5.0, -6.0, 19.0); + next.weapon.ori = Quaternion::rotation_y(2.5); + next.weapon.scale = Vec3::one(); + + next.l_shoulder.offset = Vec3::new(-10.0, -3.0, 2.5); + next.l_shoulder.ori = Quaternion::rotation_x(0.0); + next.l_shoulder.scale = Vec3::one(); + + next.r_shoulder.offset = Vec3::new(0.0, -3.0, 2.5); + next.r_shoulder.ori = Quaternion::rotation_x(0.0); + next.r_shoulder.scale = Vec3::one(); + + next.torso.offset = Vec3::new(-0.5, -0.2, 0.0); + next.torso.ori = Quaternion::rotation_x(-0.8 + waveveryslow * 0.10); + next.torso.scale = Vec3::one() / 11.0; + + next.draw.offset = Vec3::new(13.5, 3.0, -1.0); + next.draw.ori = Quaternion::rotation_y(waveveryslowcos * 0.05); + next.draw.scale = Vec3::one(); + + next + } +} diff --git a/voxygen/src/anim/character/idle.rs b/voxygen/src/anim/character/idle.rs index 1a629d3b0b..bef3f44247 100644 --- a/voxygen/src/anim/character/idle.rs +++ b/voxygen/src/anim/character/idle.rs @@ -100,9 +100,9 @@ impl Animation for IdleAnimation { next.torso.ori = Quaternion::rotation_x(0.0); next.torso.scale = Vec3::one() / 11.0; - next.draw.offset = Vec3::new(0.0, 1.0, -8.0); - next.draw.ori = Quaternion::rotation_y(-0.2); - next.draw.scale = Vec3::one(); + next.draw.offset = Vec3::new(0.0, 0.0, 0.0); + next.draw.ori = Quaternion::rotation_y(0.0); + next.draw.scale = Vec3::one() * 0.0; next } } diff --git a/voxygen/src/anim/character/jump.rs b/voxygen/src/anim/character/jump.rs index acbd79adb0..ffcbf8b718 100644 --- a/voxygen/src/anim/character/jump.rs +++ b/voxygen/src/anim/character/jump.rs @@ -80,6 +80,9 @@ impl Animation for JumpAnimation { next.torso.ori = Quaternion::rotation_x(-0.2); next.torso.scale = Vec3::one() / 11.0; + next.draw.offset = Vec3::new(0.0, 0.0, 0.0); + next.draw.ori = Quaternion::rotation_y(0.0); + next.draw.scale = Vec3::one() * 0.0; next } } diff --git a/voxygen/src/anim/character/mod.rs b/voxygen/src/anim/character/mod.rs index 8a348ce769..3605286cfc 100644 --- a/voxygen/src/anim/character/mod.rs +++ b/voxygen/src/anim/character/mod.rs @@ -1,11 +1,14 @@ pub mod idle; pub mod jump; pub mod run; +pub mod gliding; + // Reexports pub use self::idle::IdleAnimation; pub use self::jump::JumpAnimation; pub use self::run::RunAnimation; +pub use self::gliding::GlidingAnimation; // Crate use crate::render::FigureBoneData; @@ -27,8 +30,8 @@ pub struct CharacterSkeleton { weapon: Bone, l_shoulder: Bone, r_shoulder: Bone, - torso: Bone, draw: Bone, + torso: Bone, } impl CharacterSkeleton { @@ -45,8 +48,8 @@ impl CharacterSkeleton { weapon: Bone::default(), l_shoulder: Bone::default(), r_shoulder: Bone::default(), - torso: Bone::default(), draw: Bone::default(), + torso: Bone::default(), } } } @@ -68,8 +71,8 @@ impl Skeleton for CharacterSkeleton { FigureBoneData::new(torso_mat * chest_mat * self.weapon.compute_base_matrix()), FigureBoneData::new(torso_mat * chest_mat * self.l_shoulder.compute_base_matrix()), FigureBoneData::new(torso_mat * chest_mat * self.r_shoulder.compute_base_matrix()), - FigureBoneData::new(torso_mat), FigureBoneData::new(torso_mat * l_hand_mat * self.draw.compute_base_matrix()), + FigureBoneData::new(torso_mat), FigureBoneData::default(), FigureBoneData::default(), FigureBoneData::default(), @@ -88,7 +91,7 @@ impl Skeleton for CharacterSkeleton { self.weapon.interpolate(&target.weapon); self.l_shoulder.interpolate(&target.l_shoulder); self.r_shoulder.interpolate(&target.r_shoulder); - self.torso.interpolate(&target.torso); self.draw.interpolate(&target.draw); + self.torso.interpolate(&target.torso); } } diff --git a/voxygen/src/anim/character/run.rs b/voxygen/src/anim/character/run.rs index 22b738e27c..f0c6d733a1 100644 --- a/voxygen/src/anim/character/run.rs +++ b/voxygen/src/anim/character/run.rs @@ -76,9 +76,9 @@ impl Animation for RunAnimation { next.torso.ori = Quaternion::rotation_x(-velocity * 0.05 - wavecos * 0.1); next.torso.scale = Vec3::one() / 11.0; - next.draw.offset = Vec3::new(0.0, 1.0, -8.0); - next.draw.ori = Quaternion::rotation_y(-0.2); - next.draw.scale = Vec3::one(); + next.draw.offset = Vec3::new(0.0, 0.0, 0.0); + next.draw.ori = Quaternion::rotation_y(0.0); + next.draw.scale = Vec3::one() * 0.0; next } diff --git a/voxygen/src/anim/quadruped/jump.rs b/voxygen/src/anim/quadruped/jump.rs index a8724c7ce2..9d25f69d3e 100644 --- a/voxygen/src/anim/quadruped/jump.rs +++ b/voxygen/src/anim/quadruped/jump.rs @@ -39,7 +39,7 @@ impl Animation for JumpAnimation { next.pigchest.scale = Vec3::one() / 11.0; next.piglf_leg.offset = Vec3::new(-4.5, 3.0, 1.5) / 11.0; - next.piglf_leg.ori = Quaternion::rotation_x(wave_stop * 0.6); + next.piglf_leg.ori = Quaternion::rotation_x(wave_stop * 0.6 - wave_slow * 0.3); next.piglf_leg.scale = Vec3::one() / 11.0; next.pigrf_leg.offset = Vec3::new(2.5, 3.0, 1.5) / 11.0; diff --git a/voxygen/src/menu/char_selection/mod.rs b/voxygen/src/menu/char_selection/mod.rs index cbe77c7d6e..e1b86311da 100644 --- a/voxygen/src/menu/char_selection/mod.rs +++ b/voxygen/src/menu/char_selection/mod.rs @@ -82,7 +82,7 @@ impl PlayState for CharSelectionState { .postbox .send_message(ClientMsg::Character { name: self.char_selection_ui.character_name.clone(), - body: comp::Body::Quadruped(comp::QuadrupedBody::random()), // comp::Body::Humanoid(self.char_selection_ui.character_body), + body: comp::Body::Humanoid(self.char_selection_ui.character_body), //body: comp::Body::Quadruped(comp::QuadrupedBody::random()), }); return PlayStateResult::Switch(Box::new(SessionState::new( &mut global_state.window, diff --git a/voxygen/src/scene/figure.rs b/voxygen/src/scene/figure.rs index d4e98dee22..3c771579dc 100644 --- a/voxygen/src/scene/figure.rs +++ b/voxygen/src/scene/figure.rs @@ -15,7 +15,7 @@ use common::{ assets, comp::{ self, - actor::{Belt, Chest, Foot, Hand, Head, Pants, Shoulder, Weapon, Pighead, Pigchest, Pigleg_l, Pigleg_r}, + actor::{Belt, Chest, Foot, Hand, Head, Pants, Shoulder, Weapon, Draw, Pighead, Pigchest, Pigleg_l, Pigleg_r}, Body, HumanoidBody, QuadrupedBody }, figure::Segment, @@ -65,7 +65,7 @@ impl FigureModelCache { Some(Self::load_weapon(body.weapon)), Some(Self::load_left_shoulder(body.shoulder)), Some(Self::load_right_shoulder(body.shoulder)), - None, + Some(Self::load_draw(body.draw)), None, None, None, @@ -226,17 +226,17 @@ impl FigureModelCache { Vec3::new(2.5, 0.0, 0.0), ) } - // fn load_draw(draw: Draw) -> Mesh { - // Self::load_mesh( - // match draw { - // //Draw::DefaultDraw => "sword.vox", - // - // }, - // Vec3::new(0.0, 0.0, -2.0) - // - // - // ) - // } + fn load_draw(draw: Draw) -> Mesh { + Self::load_mesh( + match draw { + Draw::Default => "glider.vox", + + }, + Vec3::new(-26.0, -26.0, -5.0) + + + ) + } fn load_pighead(pighead: Pighead) -> Mesh { Self::load_mesh( @@ -350,6 +350,11 @@ impl FigureMgr { time, animation_history.time, ), + comp::Animation::Gliding => character::GlidingAnimation::update_skeleton( + state.skeleton_mut(), + time, + animation_history.time, + ), }; state.skeleton.interpolate(&target_skeleton); @@ -377,6 +382,7 @@ impl FigureMgr { (vel.0.magnitude(), time), animation_history.time, ), + // TODO! _ => state.skeleton_mut().clone(), };