From dec963246022c418880cba89d7e855579cdb80ed Mon Sep 17 00:00:00 2001 From: jshipsey Date: Sun, 12 May 2019 20:52:30 -0400 Subject: [PATCH] animation adjustments Former-commit-id: 8752caf0bdcac1c2938f048878a008e8f5cd18e0 --- assets/voxygen/voxel/hand.vox | 2 +- assets/voxygen/voxel/head.vox | 2 +- assets/voxygen/voxel/shoulder_l.vox | 3 ++ assets/voxygen/voxel/shoulder_r.vox | 3 ++ common/src/comp/character.rs | 24 +++++++++++++ voxygen/src/anim/character/idle.rs | 53 ++++++++++++++++------------- voxygen/src/anim/character/jump.rs | 41 +++++++++++----------- voxygen/src/anim/character/mod.rs | 25 +++++++++----- voxygen/src/anim/character/run.rs | 34 ++++++++++-------- voxygen/src/scene/figure.rs | 40 +++++++++++++++++++--- 10 files changed, 154 insertions(+), 73 deletions(-) create mode 100644 assets/voxygen/voxel/shoulder_l.vox create mode 100644 assets/voxygen/voxel/shoulder_r.vox diff --git a/assets/voxygen/voxel/hand.vox b/assets/voxygen/voxel/hand.vox index 24c3057396..6e70edea1f 100644 --- a/assets/voxygen/voxel/hand.vox +++ b/assets/voxygen/voxel/hand.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:3dded9ffed6bbf593fdd9d8c807e06f0383e951476531ffedfe06849f7159686 +oid sha256:b95056f14ca3b7cd02a6ea781e04c124a79702d664705fb01e5709de1f614564 size 1272 diff --git a/assets/voxygen/voxel/head.vox b/assets/voxygen/voxel/head.vox index 0ebfea4bf0..fb8d2832fe 100644 --- a/assets/voxygen/voxel/head.vox +++ b/assets/voxygen/voxel/head.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:57c31358507b87f7c88e18a54466f97e4f2603427dcd4892e14bfa38a4fa3dda +oid sha256:a166d4b60b7caeeb9ecc194a23b1df127c839de17564de0aa85cbe685136794d size 4608 diff --git a/assets/voxygen/voxel/shoulder_l.vox b/assets/voxygen/voxel/shoulder_l.vox new file mode 100644 index 0000000000..60968c9220 --- /dev/null +++ b/assets/voxygen/voxel/shoulder_l.vox @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:fd10e204c13d7dcaf07b5fbc9f36f32e8e8a7ae9b591586316240a4c16a04d63 +size 1368 diff --git a/assets/voxygen/voxel/shoulder_r.vox b/assets/voxygen/voxel/shoulder_r.vox new file mode 100644 index 0000000000..007b678060 --- /dev/null +++ b/assets/voxygen/voxel/shoulder_r.vox @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:d5eb89bce7b57178f3486fbd9546289bfbebea6edccf69742a2d5c8932ec9461 +size 1368 diff --git a/common/src/comp/character.rs b/common/src/comp/character.rs index d164b6d74b..9c47827055 100644 --- a/common/src/comp/character.rs +++ b/common/src/comp/character.rs @@ -60,6 +60,17 @@ pub enum Weapon { Staff, } +#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)] +pub enum Shoulder { + DefaultShoulder +} + +#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)] +pub enum Draw { + DefaultDraw +} + + use Belt::*; use Chest::*; use Foot::*; @@ -69,6 +80,9 @@ use Head::*; use Pants::*; use Race::*; use Weapon::*; +use Shoulder::*; +use Draw::*; + const ALL_RACES: [Race; 6] = [Danari, Dwarf, Elf, Human, Orc, Undead]; const ALL_GENDERS: [Gender; 3] = [Female, Male, Unspecified]; @@ -79,6 +93,10 @@ const ALL_PANTS: [Pants; 1] = [DefaultPants]; const ALL_HANDS: [Hand; 1] = [DefaultHand]; const ALL_FEET: [Foot; 1] = [DefaultFoot]; const ALL_WEAPONS: [Weapon; 7] = [Daggers, SwordShield, Sword, Axe, Hammer, Bow, Staff]; +const ALL_SHOULDERS: [Shoulder; 1] = [DefaultShoulder]; +const ALL_DRAW: [Draw; 1] = [DefaultDraw]; + + #[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)] pub struct Character { @@ -91,6 +109,9 @@ pub struct Character { pub hand: Hand, pub foot: Foot, pub weapon: Weapon, + pub shoulder: Shoulder, + pub draw: Draw, + } impl Character { @@ -105,6 +126,9 @@ impl Character { hand: *thread_rng().choose(&ALL_HANDS).unwrap(), foot: *thread_rng().choose(&ALL_FEET).unwrap(), weapon: *thread_rng().choose(&ALL_WEAPONS).unwrap(), + shoulder: *thread_rng().choose(&ALL_SHOULDERS).unwrap(), + draw: *thread_rng().choose(&ALL_DRAW).unwrap(), + } } } diff --git a/voxygen/src/anim/character/idle.rs b/voxygen/src/anim/character/idle.rs index 74472e622b..cc6b97cef4 100644 --- a/voxygen/src/anim/character/idle.rs +++ b/voxygen/src/anim/character/idle.rs @@ -7,6 +7,9 @@ use vek::*; // Local use super::{super::Animation, CharacterSkeleton, SCALE}; +pub struct Input { + pub attack: bool, +} pub struct IdleAnimation; impl Animation for IdleAnimation { @@ -40,62 +43,66 @@ impl Animation for IdleAnimation { .sin() * 0.25, ); - next.head.offset = Vec3::new(5.5, 2.0, 11.5 + waveultra_slow * 0.4); + next.head.offset = Vec3::new(5.5, 2.0, 11.0 + waveultra_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(5.5, 0.0, 7.5 + waveultra_slow * 0.4); + next.chest.offset = Vec3::new(5.5, 0.0, 7.0 + waveultra_slow * 0.3); next.chest.ori = Quaternion::rotation_x(0.0); next.chest.scale = Vec3::one(); - next.belt.offset = Vec3::new(5.5, 0.0, 5.5 + waveultra_slow * 0.4); + next.belt.offset = Vec3::new(5.5, 0.0, 5.0 + waveultra_slow * 0.3); next.belt.ori = Quaternion::rotation_x(0.0); next.belt.scale = Vec3::one(); - next.shorts.offset = Vec3::new(5.5, 0.0, 2.5 + waveultra_slow * 0.4); + next.shorts.offset = Vec3::new(5.5, 0.0, 2.0 + waveultra_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 + waveultracos_slow * 0.3, - 12.0 + waveultra_slow * 1.1, + -6.0, + -2.0 + waveultracos_slow * 0.15, + 11.5 + waveultra_slow * 0.5, ); + next.l_hand.ori = Quaternion::rotation_x(0.0 + waveultra_slow * 0.06); next.l_hand.scale = Vec3::one(); next.r_hand.offset = Vec3::new( - 7.5, - -2.0 + waveultracos_slow * 0.3, - 12.0 + waveultra_slow * 1.1, + 9.0, + -2.0 + waveultracos_slow * 0.15, + 11.5 + waveultra_slow * 0.5, ); next.r_hand.ori = Quaternion::rotation_x(0.0 + waveultra_slow * 0.06); next.r_hand.scale = Vec3::one(); - next.l_foot.offset = Vec3::new(-3.4, 0.0, 8.0); + next.l_foot.offset = Vec3::new(-3.3, -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.0, 8.0); + next.r_foot.offset = Vec3::new(4.1, -0.1, 8.0); next.r_foot.ori = Quaternion::identity(); - next.r_foot.scale = Vec3::one(); + next.r_foot.scale = Vec3::one(); - next.weapon.offset = Vec3::new(-5.0, -6.0, 18.5); + next.weapon.offset = Vec3::new(-5.0, -6.0, 18.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.1); next.torso.ori = Quaternion::rotation_x(0.0); next.torso.scale = Vec3::one() / 11.0; - next.l_shoulder.offset = Vec3::new(2.9, 6.0, 18.0); - next.l_shoulder.ori = Quaternion::rotation_x(0.0); - next.l_shoulder.scale = Vec3::one(); - - next.r_shoulder.offset = Vec3::new(2.9, -6.0, 18.0); - next.r_shoulder.ori = Quaternion::rotation_x(0.0); - next.r_shoulder.scale = Vec3::one(); - + 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 } } diff --git a/voxygen/src/anim/character/jump.rs b/voxygen/src/anim/character/jump.rs index b966bce36e..435ac49213 100644 --- a/voxygen/src/anim/character/jump.rs +++ b/voxygen/src/anim/character/jump.rs @@ -21,18 +21,19 @@ impl Animation for JumpAnimation { ) -> Self::Skeleton { let mut next = (*skeleton).clone(); let wave = (anim_time as f32 * 14.0).sin(); - let arcwave = (1.0f32.ln_1p() - 1.0).abs(); + let waveslow = (anim_time as f32 * 7.0).sin(); + 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_slow = (anim_time as f32 * 5.0 + PI).min(PI / 2.0).sin(); + let wave_stop = (anim_time as f32 * 4.5).min(PI / 2.0).sin(); + let wave_stopalt = (anim_time as f32 * 5.0).min(PI / 2.0).sin(); + let wave_slowtest = (anim_time as f32).min(PI / 2.0).sin(); let wavecos_slow = (anim_time as f32 * 8.0 + PI).cos(); - let wave_dip = (wave_slow.abs() - 0.5).abs(); - let mult = wave_slow / (wave_slow.abs()); next.head.offset = Vec3::new(5.5, 2.0, 12.0); - next.head.ori = Quaternion::rotation_x(0.15); + next.head.ori = Quaternion::rotation_x(0.25); next.head.scale = Vec3::one(); next.chest.offset = Vec3::new(5.5, 0.0, 8.0); @@ -47,38 +48,38 @@ impl Animation for JumpAnimation { next.shorts.ori = Quaternion::rotation_z(0.0); next.shorts.scale = Vec3::one(); - next.l_hand.offset = Vec3::new(-7.5, -2.0, 12.0); - next.l_hand.ori = Quaternion::rotation_x(0.8); + next.l_hand.offset = Vec3::new(-7.5, 0.0, 12.0); + next.l_hand.ori = Quaternion::rotation_x(wave_stopalt * 1.2 - waveslow * 0.15); next.l_hand.scale = Vec3::one(); - next.r_hand.offset = Vec3::new(7.5, -2.0, 12.0); - next.r_hand.ori = Quaternion::rotation_x(-0.8); + next.r_hand.offset = Vec3::new(7.5, 0.0, 12.0); + next.r_hand.ori = Quaternion::rotation_x(wave_stopalt * -1.2 + waveslow * 0.15); 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_slow * -1.2); + next.l_foot.ori = Quaternion::rotation_x(wave_stop * -1.2 - waveslow * 0.2); next.l_foot.scale = Vec3::one(); next.r_foot.offset = Vec3::new(3.4, -1.0, 6.0); - next.r_foot.ori = Quaternion::rotation_x(wave_slow * 1.2); + next.r_foot.ori = Quaternion::rotation_x(wave_stop * 1.2 + waveslow * 0.2); 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.torso.offset = Vec3::new(-0.5, 0.0, 0.2); - next.torso.ori = Quaternion::rotation_x(0.0); - next.torso.scale = Vec3::one() / 11.0; - - next.l_shoulder.offset = Vec3::new(3.0, 6.0, 18.0); - next.l_shoulder.ori = Quaternion::rotation_y(0.0); + + 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(3.0, -6.0, 18.0); - next.r_shoulder.ori = Quaternion::rotation_y(0.0); + 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.2); + 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 8671f5ca10..71e0f8a7d5 100644 --- a/voxygen/src/anim/character/mod.rs +++ b/voxygen/src/anim/character/mod.rs @@ -25,9 +25,11 @@ pub struct CharacterSkeleton { l_foot: Bone, r_foot: Bone, weapon: Bone, - torso: Bone, l_shoulder: Bone, r_shoulder: Bone, + torso: Bone, + draw: Bone, + } impl CharacterSkeleton { @@ -42,9 +44,11 @@ impl CharacterSkeleton { l_foot: Bone::default(), r_foot: Bone::default(), weapon: Bone::default(), - torso: Bone::default(), l_shoulder: Bone::default(), r_shoulder: Bone::default(), + torso: Bone::default(), + draw: Bone::default(), + } } } @@ -53,22 +57,21 @@ impl Skeleton for CharacterSkeleton { fn compute_matrices(&self) -> [FigureBoneData; 16] { let chest_mat = self.chest.compute_base_matrix(); let torso_mat = self.torso.compute_base_matrix(); + let l_hand_mat = self.l_hand.compute_base_matrix(); [ FigureBoneData::new(torso_mat * self.head.compute_base_matrix()), 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(torso_mat * self.l_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 * 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 * self.l_shoulder.compute_base_matrix()), - //FigureBoneData::new(torso_mat * self.r_shoulder.compute_base_matrix()), - FigureBoneData::default(), - FigureBoneData::default(), - FigureBoneData::default(), + FigureBoneData::new(torso_mat * l_hand_mat * self.draw.compute_base_matrix()), FigureBoneData::default(), FigureBoneData::default(), FigureBoneData::default(), @@ -85,8 +88,12 @@ impl Skeleton for CharacterSkeleton { self.l_foot.interpolate(&target.l_foot); self.r_foot.interpolate(&target.r_foot); self.weapon.interpolate(&target.weapon); - self.torso.interpolate(&target.torso); self.l_shoulder.interpolate(&target.l_shoulder); self.r_shoulder.interpolate(&target.r_shoulder); + self.torso.interpolate(&target.torso); + self.draw.interpolate(&target.draw); + + + } } diff --git a/voxygen/src/anim/character/run.rs b/voxygen/src/anim/character/run.rs index e6f2f6a8c0..e38f2937ca 100644 --- a/voxygen/src/anim/character/run.rs +++ b/voxygen/src/anim/character/run.rs @@ -28,27 +28,27 @@ impl Animation for RunAnimation { let wavecos_slow = (anim_time as f32 * 8.0 + PI).cos(); let wave_dip = (wave_slow.abs() - 0.5).abs(); - next.head.offset = Vec3::new(5.5, 2.0, 12.0 + wavecos * 1.3); + next.head.offset = Vec3::new(5.5, 2.0, 11.0 + wavecos * 1.3); next.head.ori = Quaternion::rotation_x(0.15); next.head.scale = Vec3::one(); - next.chest.offset = Vec3::new(5.5, 0.0, 8.0 + wavecos * 1.1); + next.chest.offset = Vec3::new(5.5, 0.0, 7.0 + wavecos * 1.1); next.chest.ori = Quaternion::rotation_z(wave * 0.1); next.chest.scale = Vec3::one(); - next.belt.offset = Vec3::new(5.5, 0.0, 6.0 + wavecos * 1.1); + next.belt.offset = Vec3::new(5.5, 0.0, 5.0 + wavecos * 1.1); next.belt.ori = Quaternion::rotation_z(wave * 0.25); next.belt.scale = Vec3::one(); - next.shorts.offset = Vec3::new(5.5, 0.0, 3.0 + wavecos * 1.1); + next.shorts.offset = Vec3::new(5.5, 0.0, 2.0 + wavecos * 1.1); next.shorts.ori = Quaternion::rotation_z(wave * 0.6); next.shorts.scale = Vec3::one(); - next.l_hand.offset = Vec3::new(-7.5, -2.0 + wavecos * 2.5, 12.0 - wave * 1.5); + next.l_hand.offset = Vec3::new(-7.5, 0.0 + wavecos * 2.5, 11.0 - wave * 1.5); next.l_hand.ori = Quaternion::rotation_x(wavecos * 0.9); next.l_hand.scale = Vec3::one(); - next.r_hand.offset = Vec3::new(7.5, -2.0 - wavecos * 2.5, 12.0 + wave * 1.5); + next.r_hand.offset = Vec3::new(7.5, 0.0 - wavecos * 2.5, 11.0 + wave * 1.5); next.r_hand.ori = Quaternion::rotation_x(wavecos * -0.9); next.r_hand.scale = Vec3::one(); @@ -60,21 +60,27 @@ impl Animation for RunAnimation { next.r_foot.ori = Quaternion::rotation_x(-0.0 + wave * 1.5); next.r_foot.scale = Vec3::one(); - next.weapon.offset = Vec3::new(-5.0, -6.0, 19.0); + next.weapon.offset = Vec3::new(-5.0, -6.0, 18.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.torso.offset = Vec3::new(-0.5, -0.2, 0.2); + 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.4); next.torso.ori = Quaternion::rotation_x(-velocity * 0.05 - wavecos * 0.1); next.torso.scale = Vec3::one() / 11.0; - next.l_shoulder.offset = Vec3::new(3.0, 6.0, 18.0); - next.l_shoulder.ori = Quaternion::rotation_y(0.0); - next.l_shoulder.scale = Vec3::one(); + 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.r_shoulder.offset = Vec3::new(3.0, -6.0, 18.0); - next.r_shoulder.ori = Quaternion::rotation_y(0.0); - next.r_shoulder.scale = Vec3::one(); next } diff --git a/voxygen/src/scene/figure.rs b/voxygen/src/scene/figure.rs index b9763f6731..59f11f827d 100644 --- a/voxygen/src/scene/figure.rs +++ b/voxygen/src/scene/figure.rs @@ -14,7 +14,7 @@ use common::{ assets, comp::{ self, - character::{Belt, Character, Chest, Foot, Hand, Head, Pants, Weapon}, + character::{Belt, Character, Chest, Foot, Hand, Head, Pants, Weapon, Shoulder, Draw}, }, figure::Segment, msg, @@ -62,8 +62,9 @@ impl FigureCache { Some(Self::load_left_foot(character.foot)), Some(Self::load_right_foot(character.foot)), Some(Self::load_weapon(character.weapon)), - None, - None, + Some(Self::load_left_shoulder(character.shoulder)), + Some(Self::load_right_shoulder(character.shoulder)), + //Some(Self::load_draw(character.draw)), None, None, None, @@ -146,7 +147,7 @@ impl FigureCache { match hand { Hand::DefaultHand => "hand.vox", }, - Vec3::new(3.5, 0.0, -7.0), + Vec3::new(2.0, 0.0, -7.0), ) } @@ -155,7 +156,7 @@ impl FigureCache { match hand { Hand::DefaultHand => "hand.vox", }, - Vec3::new(3.5, 0.0, -7.0), + Vec3::new(2.0, 0.0, -7.0), ) } @@ -188,6 +189,35 @@ impl FigureCache { ) } + fn load_left_shoulder(shoulder: Shoulder) -> Mesh { + Self::load_mesh( + match shoulder { + Shoulder::DefaultShoulder => "shoulder_l.vox", + }, + Vec3::new(2.5, 0.0, 0.0), + ) + } + + fn load_right_shoulder(shoulder: Shoulder) -> Mesh { + Self::load_mesh( + match shoulder { + Shoulder::DefaultShoulder => "shoulder_r.vox", + }, + 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) +// +// +// ) +// } + pub fn maintain(&mut self, renderer: &mut Renderer, client: &mut Client) { let time = client.state().get_time(); let ecs = client.state_mut().ecs_mut();