From 6a57dd25d0880700330b501698b4fe6407d94ed5 Mon Sep 17 00:00:00 2001 From: jshipsey Date: Sun, 17 Jan 2021 14:38:29 -0500 Subject: [PATCH] wielding --- .../voxel/biped_small_central_manifest.ron | 48 ----------- .../voxel/biped_small_lateral_manifest.ron | 48 +++++------ .../voxel/biped_small_weapon_manifest.ron | 74 ++++++++++++++++ .../voxygen/voxel/npc/basilisk/male/chest.vox | 2 +- .../voxel/npc/basilisk/male/head_lower.vox | 4 +- .../voxel/npc/basilisk/male/tail_front.vox | 4 +- .../voxel/npc/sunlizard/male/chest_back.vox | 4 +- voxygen/anim/src/biped_small/idle.rs | 1 - voxygen/anim/src/biped_small/mod.rs | 47 ++++++---- voxygen/anim/src/biped_small/run.rs | 15 ++-- voxygen/anim/src/biped_small/wield.rs | 85 +++++++++++++++++++ voxygen/src/scene/figure/load.rs | 50 +++++++---- voxygen/src/scene/figure/mod.rs | 34 +++++--- 13 files changed, 284 insertions(+), 132 deletions(-) create mode 100644 assets/voxygen/voxel/biped_small_weapon_manifest.ron create mode 100644 voxygen/anim/src/biped_small/wield.rs diff --git a/assets/voxygen/voxel/biped_small_central_manifest.ron b/assets/voxygen/voxel/biped_small_central_manifest.ron index 53bb7fdf2e..ee77358b9e 100644 --- a/assets/voxygen/voxel/biped_small_central_manifest.ron +++ b/assets/voxygen/voxel/biped_small_central_manifest.ron @@ -16,10 +16,6 @@ offset: (-0.5, -5.0, -2.5), central: ("armor.empty"), ), - main: ( - offset: (-1.5, -7.5, -5.0), - central: ("armor.empty"), - ), ), (Gnome, Female): ( head: ( @@ -38,10 +34,6 @@ offset: (-0.5, -5.0, -2.5), central: ("armor.empty"), ), - main: ( - offset: (-1.5, -7.5, -5.0), - central: ("armor.empty"), - ), ), (Sahagin, Male): ( head: ( @@ -60,10 +52,6 @@ offset: (-1.5, -13.0, -5.0), central: ("npc.sahagin.male.tail"), ), - main: ( - offset: (-0.5, -7.5, -5.0), - central: ("weapon.spear.sahagin"), - ), ), (Sahagin, Female): ( head: ( @@ -82,10 +70,6 @@ offset: (-1.5, -13.0, -5.0), central: ("npc.sahagin.male.tail"), ), - main: ( - offset: (-0.5, -7.5, -5.0), - central: ("weapon.spear.sahagin"), - ), ), (Adlet, Male): ( head: ( @@ -104,10 +88,6 @@ offset: (-1.0, -5.0, -1.0), central: ("npc.adlet.male.tail"), ), - main: ( - offset: (-0.5, -7.5, -5.0), - central: ("weapon.spear.adlet"), - ), ), (Adlet, Female): ( head: ( @@ -126,10 +106,6 @@ offset: (-1.0, -5.0, -1.0), central: ("npc.adlet.male.tail"), ), - main: ( - offset: (-0.5, -7.5, -5.0), - central: ("weapon.spear.adlet"), - ), ), (Gnarling, Male): ( head: ( @@ -148,10 +124,6 @@ offset: (-1.5, -13.0, -3.0), central: ("npc.gnarling.male.tail"), ), - main: ( - offset: (-0.5, -7.5, -5.0), - central: ("weapon.spear.adlet"), - ), ), (Gnarling, Female): ( head: ( @@ -170,10 +142,6 @@ offset: (-1.5, -13.0, -3.0), central: ("npc.gnarling.male.tail"), ), - main: ( - offset: (-0.5, -7.5, -5.0), - central: ("weapon.spear.adlet"), - ), ), (Mandragora, Male): ( head: ( @@ -192,10 +160,6 @@ offset: (0.0, 0.0, 0.0), central: ("armor.empty"), ), - main: ( - offset: (-0.5, -7.5, -5.0), - central: ("weapon.spear.adlet"), - ), ), (Mandragora, Female): ( head: ( @@ -214,10 +178,6 @@ offset: (0.0, 0.0, 0.0), central: ("armor.empty"), ), - main: ( - offset: (-0.5, -7.5, -5.0), - central: ("weapon.spear.adlet"), - ), ), (Kappa, Male): ( head: ( @@ -236,10 +196,6 @@ offset: (-2.5, -10.0, -5.0), central: ("npc.kappa.male.tail"), ), - main: ( - offset: (-0.5, -7.5, -5.0), - central: ("weapon.spear.adlet"), - ), ), (Kappa, Female): ( head: ( @@ -258,9 +214,5 @@ offset: (-2.5, -10.0, -5.0), central: ("npc.kappa.male.tail"), ), - main: ( - offset: (-0.5, -7.5, -5.0), - central: ("weapon.spear.adlet"), - ), ), }) diff --git a/assets/voxygen/voxel/biped_small_lateral_manifest.ron b/assets/voxygen/voxel/biped_small_lateral_manifest.ron index ae965ffae0..a891e4fdf2 100644 --- a/assets/voxygen/voxel/biped_small_lateral_manifest.ron +++ b/assets/voxygen/voxel/biped_small_lateral_manifest.ron @@ -1,11 +1,11 @@ ({ (Gnome, Male): ( hand_l: ( - offset: (-2.0, -2.0, -5.0), + offset: (-4.0, -2.0, -5.0), lateral: ("npc.gnome.male.hand_l"), ), hand_r: ( - offset: (-2.0, -2.0, -5.0), + offset: (0.0, -2.0, -5.0), lateral: ("npc.gnome.male.hand_r"), ), foot_l: ( @@ -19,11 +19,11 @@ ), (Gnome, Female): ( hand_l: ( - offset: (-2.0, -2.0, -5.0), + offset: (-4.0, -2.0, -5.0), lateral: ("npc.gnome.male.hand_l"), ), hand_r: ( - offset: (-2.0, -2.0, -5.0), + offset: (0.0, -2.0, -5.0), lateral: ("npc.gnome.male.hand_r"), ), foot_l: ( @@ -37,11 +37,11 @@ ), (Sahagin, Male): ( hand_l: ( - offset: (0.0, -4.0, -11.0), + offset: (-7.0, -4.0, -13.0), lateral: ("npc.sahagin.male.hand_l"), ), hand_r: ( - offset: (0.0, -4.0, -11.0), + offset: (0.0, -4.0, -13.0), lateral: ("npc.sahagin.male.hand_r"), ), foot_l: ( @@ -55,11 +55,11 @@ ), (Sahagin, Female): ( hand_l: ( - offset: (0.0, -4.0, -11.0), + offset: (-7.0, -4.0, -13.0), lateral: ("npc.sahagin.male.hand_l"), ), hand_r: ( - offset: (-7.0, -4.0, -11.0), + offset: (0.0, -4.0, -13.0), lateral: ("npc.sahagin.male.hand_r"), ), foot_l: ( @@ -73,11 +73,11 @@ ), (Adlet, Male): ( hand_l: ( - offset: (-2.0, -2.0, -6.0), + offset: (-4.0, -2.0, -7.0), lateral: ("npc.adlet.male.hand_l"), ), hand_r: ( - offset: (-2.0, -2.0, -6.0), + offset: (0.0, -2.0, -7.0), lateral: ("npc.adlet.male.hand_r"), ), foot_l: ( @@ -91,11 +91,11 @@ ), (Adlet, Female): ( hand_l: ( - offset: (-2.0, -2.0, -6.0), + offset: (-4.0, -2.0, -7.0), lateral: ("npc.adlet.male.hand_l"), ), hand_r: ( - offset: (-2.0, -2.0, -6.0), + offset: (0.0, -2.0, -7.0), lateral: ("npc.adlet.male.hand_r"), ), foot_l: ( @@ -109,11 +109,11 @@ ), (Gnarling, Male): ( hand_l: ( - offset: (-1.5, -1.5, -7.0), + offset: (-3.0, -1.5, -7.0), lateral: ("npc.gnarling.male.hand_l"), ), hand_r: ( - offset: (-1.5, -1.5, -7.0), + offset: (0.0, -1.5, -7.0), lateral: ("npc.gnarling.male.hand_r"), ), foot_l: ( @@ -127,11 +127,11 @@ ), (Gnarling, Female): ( hand_l: ( - offset: (-1.5, -1.5, -7.0), + offset: (-3.0, -1.5, -7.0), lateral: ("npc.gnarling.male.hand_l"), ), hand_r: ( - offset: (-1.5, -1.5, -7.0), + offset: (0.0, -1.5, -7.0), lateral: ("npc.gnarling.male.hand_r"), ), foot_l: ( @@ -145,11 +145,11 @@ ), (Mandragora, Male): ( hand_l: ( - offset: (-2.0, -1.5, -7.0), + offset: (-4.0, -1.5, -7.0), lateral: ("npc.mandragora.male.hand_l"), ), hand_r: ( - offset: (-2.0, -1.5, -7.0), + offset: (0.0, -1.5, -7.0), lateral: ("npc.mandragora.male.hand_r"), ), foot_l: ( @@ -163,11 +163,11 @@ ), (Mandragora, Female): ( hand_l: ( - offset: (-2.0, -1.5, -7.0), + offset: (-4.0, -1.5, -7.0), lateral: ("npc.mandragora.male.hand_l"), ), hand_r: ( - offset: (-2.0, -1.5, -7.0), + offset: (0.0, -1.5, -7.0), lateral: ("npc.mandragora.male.hand_r"), ), foot_l: ( @@ -181,11 +181,11 @@ ), (Kappa, Male): ( hand_l: ( - offset: (-3.0, -4.0, -10.0), + offset: (-6.0, -4.0, -12.0), lateral: ("npc.kappa.male.hand_l"), ), hand_r: ( - offset: (-3.0, -4.0, -10.0), + offset: (0.0, -4.0, -12.0), lateral: ("npc.kappa.male.hand_r"), ), foot_l: ( @@ -199,11 +199,11 @@ ), (Kappa, Female): ( hand_l: ( - offset: (-3.0, -4.0, -10.0), + offset: (-6.0, -4.0, -12.0), lateral: ("npc.kappa.male.hand_l"), ), hand_r: ( - offset: (-3.0, -4.0, -10.0), + offset: (0.0, -4.0, -12.0), lateral: ("npc.kappa.male.hand_r"), ), foot_l: ( diff --git a/assets/voxygen/voxel/biped_small_weapon_manifest.ron b/assets/voxygen/voxel/biped_small_weapon_manifest.ron new file mode 100644 index 0000000000..06850173f8 --- /dev/null +++ b/assets/voxygen/voxel/biped_small_weapon_manifest.ron @@ -0,0 +1,74 @@ +({ + (Gnome, Male): ( + main: ( + offset: (-1.5, -3.0, -5.0), + weapon: ("weapon.spear.sahagin"), + ), + ), + (Gnome, Female): ( + main: ( + offset: (-1.5, -3.0, -5.0), + weapon: ("weapon.spear.sahagin"), + ), + ), + (Sahagin, Male): ( + main: ( + offset: (-1.5, -3.0, -5.0), + weapon: ("weapon.spear.sahagin"), + ), + ), + (Sahagin, Female): ( + main: ( + offset: (-1.5, -3.0, -5.0), + weapon: ("weapon.spear.sahagin"), + ), + ), + (Adlet, Male): ( + main: ( + offset: (-0.5, -3.0, -5.0), + weapon: ("weapon.spear.adlet"), + ), + ), + (Adlet, Female): ( + main: ( + offset: (-0.5, -3.0, -5.0), + weapon: ("weapon.spear.adlet"), + ), + ), + (Gnarling, Male): ( + main: ( + offset: (-0.5, -3.0, -5.0), + weapon: ("weapon.spear.adlet"), + ), + ), + (Gnarling, Female): ( + main: ( + offset: (-0.5, -3.0, -5.0), + weapon: ("weapon.spear.adlet"), + ), + ), + (Mandragora, Male): ( + main: ( + offset: (-0.5, -3.0, -5.0), + weapon: ("weapon.spear.adlet"), + ), + ), + (Mandragora, Female): ( + main: ( + offset: (-0.5, -3.0, -5.0), + weapon: ("weapon.spear.adlet"), + ), + ), + (Kappa, Male): ( + main: ( + offset: (-0.5, -3.0, -5.0), + weapon: ("weapon.spear.adlet"), + ), + ), + (Kappa, Female): ( + main: ( + offset: (-0.5, -3.0, -5.0), + weapon: ("weapon.spear.adlet"), + ), + ), +}) diff --git a/assets/voxygen/voxel/npc/basilisk/male/chest.vox b/assets/voxygen/voxel/npc/basilisk/male/chest.vox index c4a395dbaa..bf9db901ec 100644 --- a/assets/voxygen/voxel/npc/basilisk/male/chest.vox +++ b/assets/voxygen/voxel/npc/basilisk/male/chest.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:41dc59bb7c25502be8c91377a392da091e2eefc34a90f706fbe403279291352f +oid sha256:052e1f43f55fd46abe5d00d7f55edd0d1d3c16e6f593267a2f1e9e55084c1bee size 10876 diff --git a/assets/voxygen/voxel/npc/basilisk/male/head_lower.vox b/assets/voxygen/voxel/npc/basilisk/male/head_lower.vox index 29bcbca5d8..f030250eca 100644 --- a/assets/voxygen/voxel/npc/basilisk/male/head_lower.vox +++ b/assets/voxygen/voxel/npc/basilisk/male/head_lower.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:82f16f69a291b05f3d6aab73aaa13a9addd13dc26d9ffc4beceb739a9933f3e7 -size 7428 +oid sha256:5dcbdb071a465648417cdb0a3bb7c332347f5a7803f96b6e74bce181cd53b807 +size 7576 diff --git a/assets/voxygen/voxel/npc/basilisk/male/tail_front.vox b/assets/voxygen/voxel/npc/basilisk/male/tail_front.vox index df5e608380..439e72d002 100644 --- a/assets/voxygen/voxel/npc/basilisk/male/tail_front.vox +++ b/assets/voxygen/voxel/npc/basilisk/male/tail_front.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:8b032da5cb40709480fe3850d78beb5c290caf84a2fc57a0559bb50ddceffb69 -size 4416 +oid sha256:cb65b35605d1eb968ec2f45bceeaee2e02d90c18304bbe99b383fff3633c72f4 +size 4564 diff --git a/assets/voxygen/voxel/npc/sunlizard/male/chest_back.vox b/assets/voxygen/voxel/npc/sunlizard/male/chest_back.vox index 6e9341a990..b2a620593d 100644 --- a/assets/voxygen/voxel/npc/sunlizard/male/chest_back.vox +++ b/assets/voxygen/voxel/npc/sunlizard/male/chest_back.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:fe0b0c88fab94154e0652ff9ef40c38aee5d3be680d41d1a3721b407d4ed37d5 -size 2020 +oid sha256:bb218b5541feddcd0943542995f8684298e25eab64efc27f47d6f89d55c10fe9 +size 2316 diff --git a/voxygen/anim/src/biped_small/idle.rs b/voxygen/anim/src/biped_small/idle.rs index 6dad997260..72348a531b 100644 --- a/voxygen/anim/src/biped_small/idle.rs +++ b/voxygen/anim/src/biped_small/idle.rs @@ -2,7 +2,6 @@ use super::{ super::{vek::*, Animation}, BipedSmallSkeleton, SkeletonAttr, }; -use std::{f32::consts::PI, ops::Mul}; pub struct IdleAnimation; diff --git a/voxygen/anim/src/biped_small/mod.rs b/voxygen/anim/src/biped_small/mod.rs index f43aafdeca..c8bf4bdd1a 100644 --- a/voxygen/anim/src/biped_small/mod.rs +++ b/voxygen/anim/src/biped_small/mod.rs @@ -1,8 +1,9 @@ pub mod idle; pub mod run; +pub mod wield; // Reexports -pub use self::{idle::IdleAnimation, run::RunAnimation}; +pub use self::{idle::IdleAnimation, run::RunAnimation, wield::WieldAnimation}; use super::{make_bone, vek::*, FigureBoneData, Skeleton}; use common::comp::{self}; @@ -20,6 +21,10 @@ skeleton_impls!(struct BipedSmallSkeleton { + hand_r, + foot_l, + foot_r, + control, + control_l, + control_r, + }); impl Skeleton for BipedSmallSkeleton { @@ -38,15 +43,17 @@ impl Skeleton for BipedSmallSkeleton { ) -> Vec3 { let chest_mat = base_mat * Mat4::::from(self.chest); let shorts_mat = chest_mat * Mat4::::from(self.shorts); - + let control_mat = chest_mat * Mat4::::from(self.control); + let control_l_mat = Mat4::::from(self.control_l); + let control_r_mat = Mat4::::from(self.control_r); *(<&mut [_; Self::BONE_COUNT]>::try_from(&mut buf[0..Self::BONE_COUNT]).unwrap()) = [ make_bone(chest_mat * Mat4::::from(self.head)), make_bone(chest_mat), make_bone(shorts_mat), make_bone(shorts_mat * Mat4::::from(self.tail)), - make_bone(chest_mat * Mat4::::from(self.main)), - make_bone(chest_mat * Mat4::::from(self.hand_l)), - make_bone(chest_mat * Mat4::::from(self.hand_r)), + make_bone(control_mat * Mat4::::from(self.main)), + make_bone(control_mat * control_l_mat * Mat4::::from(self.hand_l)), + make_bone(control_mat * control_r_mat * Mat4::::from(self.hand_r)), make_bone(base_mat * Mat4::::from(self.foot_l)), make_bone(base_mat * Mat4::::from(self.foot_r)), ]; @@ -61,6 +68,7 @@ pub struct SkeletonAttr { tail: (f32, f32), hand: (f32, f32, f32), foot: (f32, f32, f32), + grip: (f32, f32, f32), } impl<'a> std::convert::TryFrom<&'a comp::Body> for SkeletonAttr { @@ -83,6 +91,7 @@ impl Default for SkeletonAttr { tail: (0.0, 0.0), hand: (0.0, 0.0, 0.0), foot: (0.0, 0.0, 0.0), + grip: (0.0, 0.0, 0.0), } } } @@ -104,7 +113,7 @@ impl<'a> From<&'a Body> for SkeletonAttr { (Sahagin, _) => (0.0, 15.0), (Adlet, _) => (0.0, 11.0), (Gnarling, _) => (0.0, 7.5), - (Mandragora, _) => (0.0, 8.5), + (Mandragora, _) => (0.0, 10.5), (Kappa, _) => (0.0, 14.5), }, shorts: match (body.species, body.body_type) { @@ -112,7 +121,7 @@ impl<'a> From<&'a Body> for SkeletonAttr { (Sahagin, _) => (0.5, -7.0), (Adlet, _) => (0.0, -3.0), (Gnarling, _) => (0.0, -3.0), - (Mandragora, _) => (0.0, -3.0), + (Mandragora, _) => (0.0, -6.5), (Kappa, _) => (0.0, -3.0), }, tail: match (body.species, body.body_type) { @@ -120,16 +129,16 @@ impl<'a> From<&'a Body> for SkeletonAttr { (Sahagin, _) => (-2.5, -2.0), (Adlet, _) => (-4.5, -2.0), (Gnarling, _) => (-2.0, 1.5), - (Mandragora, _) => (0.0, 0.0), - (Kappa, _) => (0.0, -3.0), + (Mandragora, _) => (0.0, -1.0), + (Kappa, _) => (0.0, -4.0), }, hand: match (body.species, body.body_type) { - (Gnome, _) => (6.0, 0.5, -1.0), - (Sahagin, _) => (9.5, 3.5, -2.0), - (Adlet, _) => (6.0, -0.5, 0.0), - (Gnarling, _) => (5.0, 0.0, 1.5), - (Mandragora, _) => (6.0, -0.5, -2.5), - (Kappa, _) => (7.5, 3.5, -2.0), + (Gnome, _) => (4.0, 0.5, -1.0), + (Sahagin, _) => (3.5, 3.5, -2.0), + (Adlet, _) => (4.5, -0.5, 2.0), + (Gnarling, _) => (4.0, 0.0, 1.5), + (Mandragora, _) => (4.0, -0.5, -2.5), + (Kappa, _) => (4.0, 3.5, -0.5), }, foot: match (body.species, body.body_type) { (Gnome, _) => (3.0, 0.0, 4.0), @@ -139,6 +148,14 @@ impl<'a> From<&'a Body> for SkeletonAttr { (Mandragora, _) => (3.0, 0.0, 4.0), (Kappa, _) => (3.0, 3.0, 9.0), }, + grip: match (body.species, body.body_type) { + (Gnome, _) => (0.0, 0.0, 5.0), + (Sahagin, _) => (1.0, 0.0, 13.0), + (Adlet, _) => (0.0, 0.0, 7.0), + (Gnarling, _) => (0.0, 0.0, 7.0), + (Mandragora, _) => (0.0, 0.0, 7.0), + (Kappa, _) => (0.75, 1.0, 12.0), + }, } } } diff --git a/voxygen/anim/src/biped_small/run.rs b/voxygen/anim/src/biped_small/run.rs index 3426dcb806..bf35df919e 100644 --- a/voxygen/anim/src/biped_small/run.rs +++ b/voxygen/anim/src/biped_small/run.rs @@ -19,7 +19,7 @@ impl Animation for RunAnimation { fn update_skeleton_inner( skeleton: &Self::Skeleton, - (velocity, orientation, last_ori, global_time, avg_vel, acc_vel): Self::Dependency, + (velocity, orientation, last_ori, global_time, _avg_vel, acc_vel): Self::Dependency, anim_time: f64, rate: &mut f32, s_a: &SkeletonAttr, @@ -27,7 +27,6 @@ impl Animation for RunAnimation { let mut next = (*skeleton).clone(); let speed = Vec2::::from(velocity).magnitude(); *rate = 1.0; - let impact = (avg_vel.z).max(-8.0); let speednorm = speed / 9.4; let lab = 1.0; @@ -105,9 +104,7 @@ impl Animation for RunAnimation { ) / 13.0; next.chest.orientation = Quaternion::rotation_z(short * 0.06 + tilt * -0.6) * Quaternion::rotation_y(tilt * 1.6) - * Quaternion::rotation_x( - impact * 0.06 + shortalter * 0.035 + speednorm * -0.4 + (tilt.abs()), - ); + * Quaternion::rotation_x(shortalter * 0.035 + speednorm * -0.4 + (tilt.abs())); next.shorts.position = Vec3::new(0.0, s_a.shorts.0, s_a.shorts.1); next.shorts.orientation = Quaternion::rotation_x(0.1 * speednorm) @@ -136,10 +133,10 @@ impl Animation for RunAnimation { next.foot_l.position = Vec3::new( -s_a.foot.0 + footstrafel * sideabs * 3.0 + tilt * -2.0, s_a.foot.1 - + (1.0 - sideabs) * (-1.0 * speednorm + footrotl * -4.5 * speednorm) + + (1.0 - sideabs) * (-1.0 * speednorm + footrotl * -1.5 * speednorm) + (direction * 5.0).max(0.0), s_a.foot.2 - + (1.0 - sideabs) * (2.0 * speednorm + ((footvertl * -2.1 * speednorm).max(-1.0))) + + (1.0 - sideabs) * (2.0 * speednorm + ((footvertl * -1.1 * speednorm).max(-1.0))) + side * ((footvertsl * 1.5).max(-1.0)), ) / 13.0; next.foot_l.orientation = Quaternion::rotation_x( @@ -151,10 +148,10 @@ impl Animation for RunAnimation { next.foot_r.position = Vec3::new( s_a.foot.0 + footstrafer * sideabs * 3.0 + tilt * -2.0, s_a.foot.1 - + (1.0 - sideabs) * (-1.0 * speednorm + footrotr * -4.5 * speednorm) + + (1.0 - sideabs) * (-1.0 * speednorm + footrotr * -1.5 * speednorm) + (direction * 5.0).max(0.0), s_a.foot.2 - + (1.0 - sideabs) * (2.0 * speednorm + ((footvertr * -2.1 * speednorm).max(-1.0))) + + (1.0 - sideabs) * (2.0 * speednorm + ((footvertr * -1.1 * speednorm).max(-1.0))) + side * ((footvertsr * -1.5).max(-1.0)), ) / 13.0; next.foot_r.orientation = Quaternion::rotation_x( diff --git a/voxygen/anim/src/biped_small/wield.rs b/voxygen/anim/src/biped_small/wield.rs new file mode 100644 index 0000000000..eaeed43738 --- /dev/null +++ b/voxygen/anim/src/biped_small/wield.rs @@ -0,0 +1,85 @@ +use super::{ + super::{vek::*, Animation}, + BipedSmallSkeleton, SkeletonAttr, +}; +use std::f32::consts::PI; + +pub struct WieldAnimation; + +type WieldAnimationDependency = (Vec3, Vec3, Vec3, f64, Vec3, f32); + +impl Animation for WieldAnimation { + type Dependency = WieldAnimationDependency; + type Skeleton = BipedSmallSkeleton; + + #[cfg(feature = "use-dyn-lib")] + const UPDATE_FN: &'static [u8] = b"biped_small_wield\0"; + + #[cfg_attr(feature = "be-dyn-lib", export_name = "biped_small_wield")] + + fn update_skeleton_inner( + skeleton: &Self::Skeleton, + (velocity, _orientation, _last_ori, _global_time, _avg_vel, acc_vel): Self::Dependency, + anim_time: f64, + _rate: &mut f32, + s_a: &SkeletonAttr, + ) -> Self::Skeleton { + let mut next = (*skeleton).clone(); + let speed = Vec2::::from(velocity).magnitude(); + + let fastacc = (acc_vel * 2.0).sin(); + let fast = (anim_time as f32 * 10.0).sin(); + let fastalt = (anim_time as f32 * 10.0 + PI / 2.0).sin(); + let slow = (anim_time as f32 * 2.0).sin(); + + let speednorm = speed / 9.4; + let speednormcancel = 1.0 - speednorm; + + next.foot_l.scale = Vec3::one() / 13.0; + next.foot_r.scale = Vec3::one() / 13.0; + + next.chest.scale = Vec3::one() / 13.0; + next.head.position = Vec3::new(0.0, s_a.head.0, s_a.head.1 + fast * -0.1 * speednormcancel); + next.head.orientation = Quaternion::rotation_x(0.45 * speednorm) + * Quaternion::rotation_y(fast * 0.15 * speednormcancel); + next.chest.position = Vec3::new( + 0.0, + s_a.chest.0, + s_a.chest.1 + fastalt * 0.4 * speednormcancel + speednormcancel * -0.5, + ) / 13.0; + + next.shorts.position = Vec3::new(0.0, s_a.shorts.0, s_a.shorts.1); + //next.main.position = Vec3::new(0.0, s_a.hand.2*-1.0, 0.0); + + next.main.position = Vec3::new(0.0, 0.0, 0.0); + + next.hand_l.position = Vec3::new(s_a.grip.0 * 4.0, 0.0, s_a.grip.2); + next.hand_r.position = Vec3::new(-s_a.grip.0 * 4.0, 0.0, s_a.grip.2); + + next.hand_l.orientation = Quaternion::rotation_x(0.0); + next.hand_r.orientation = Quaternion::rotation_x(0.0); + + next.control_l.position = Vec3::new(1.0 - s_a.grip.0 * 2.0, 2.0, -2.0); + next.control_r.position = Vec3::new(-1.0 + s_a.grip.0 * 2.0, 2.0, 2.0); + + next.control.position = Vec3::new( + -3.0, + s_a.grip.2, + -s_a.grip.2 / 2.5 + s_a.grip.0 * -2.0 + fastacc * 1.5 + fastalt * 0.5 * speednormcancel, + ); + + next.control_l.orientation = + Quaternion::rotation_x(PI / 1.5 + slow * 0.1) * Quaternion::rotation_y(-0.3); + next.control_r.orientation = + Quaternion::rotation_x(PI / 1.5 + slow * 0.1 + s_a.grip.0 * 0.2) + * Quaternion::rotation_y(0.5 + slow * 0.0 + s_a.grip.0 * 0.2); + + next.control.orientation = Quaternion::rotation_x(-1.35 + 0.5 * speednorm); + + next.tail.position = Vec3::new(0.0, s_a.tail.0, s_a.tail.1); + next.tail.orientation = Quaternion::rotation_x(0.05 * fastalt * speednormcancel) + * Quaternion::rotation_z(fast * 0.15 * speednormcancel); + + next + } +} diff --git a/voxygen/src/scene/figure/load.rs b/voxygen/src/scene/figure/load.rs index 412d1475e8..8483653367 100644 --- a/voxygen/src/scene/figure/load.rs +++ b/voxygen/src/scene/figure/load.rs @@ -2478,7 +2478,6 @@ struct SidedBSCentralVoxSpec { chest: BipedSmallCentralSubSpec, shorts: BipedSmallCentralSubSpec, tail: BipedSmallCentralSubSpec, - main: BipedSmallCentralSubSpec, } #[derive(Deserialize)] struct BipedSmallCentralSubSpec { @@ -2500,11 +2499,24 @@ struct BipedSmallLateralSubSpec { lateral: VoxSimple, } +#[derive(Deserialize)] +struct BipedSmallWeaponSpec(HashMap<(BSSpecies, BSBodyType), SidedBSWeaponVoxSpec>); +#[derive(Deserialize)] +struct SidedBSWeaponVoxSpec { + main: BipedSmallWeaponSubSpec, +} +#[derive(Deserialize)] +struct BipedSmallWeaponSubSpec { + offset: [f32; 3], // Should be relative to initial origin + weapon: VoxSimple, +} + make_vox_spec!( biped_small::Body, struct BipedSmallSpec { central: BipedSmallCentralSpec = "voxygen.voxel.biped_small_central_manifest", lateral: BipedSmallLateralSpec = "voxygen.voxel.biped_small_lateral_manifest", + weapon: BipedSmallWeaponSpec = "voxygen.voxel.biped_small_weapon_manifest", }, |FigureKey { body, .. }, spec| { [ @@ -2524,7 +2536,7 @@ make_vox_spec!( body.species, body.body_type, )), - Some(spec.central.read().0.mesh_main( + Some(spec.weapon.read().0.mesh_main( body.species, body.body_type, )), @@ -2619,22 +2631,6 @@ impl BipedSmallCentralSpec { (central, Vec3::from(spec.tail.offset)) } - - fn mesh_main(&self, species: BSSpecies, body_type: BSBodyType) -> BoneMeshes { - let spec = match self.0.get(&(species, body_type)) { - Some(spec) => spec, - None => { - error!( - "No main specification exists for the combination of {:?} and {:?}", - species, body_type - ); - return load_mesh("not_found", Vec3::new(-5.0, -5.0, -2.5)); - }, - }; - let central = graceful_load_segment(&spec.main.central.0); - - (central, Vec3::from(spec.main.offset)) - } } impl BipedSmallLateralSpec { @@ -2702,6 +2698,24 @@ impl BipedSmallLateralSpec { (lateral, Vec3::from(spec.foot_r.offset)) } } +impl BipedSmallWeaponSpec { + fn mesh_main(&self, species: BSSpecies, body_type: BSBodyType) -> BoneMeshes { + let spec = match self.0.get(&(species, body_type)) { + Some(spec) => spec, + None => { + error!( + "No main specification exists for the combination of {:?} and {:?}", + species, body_type + ); + return load_mesh("not_found", Vec3::new(-5.0, -5.0, -2.5)); + }, + }; + let weapon = graceful_load_segment(&spec.main.weapon.0); + + (weapon, Vec3::from(spec.main.offset)) + } +} + //// #[derive(Deserialize)] diff --git a/voxygen/src/scene/figure/mod.rs b/voxygen/src/scene/figure/mod.rs index a9d645ae5f..8669f3b3ac 100644 --- a/voxygen/src/scene/figure/mod.rs +++ b/voxygen/src/scene/figure/mod.rs @@ -2624,23 +2624,37 @@ impl FigureMgr { &mut state_animation_rate, skeleton_attr, ), - _ => anim::biped_small::RunAnimation::update_skeleton( + _ => anim::biped_small::IdleAnimation::update_skeleton( &BipedSmallSkeleton::default(), - ( - vel.0, - ori, - state.last_ori, - time, - state.avg_vel, - state.acc_vel, - ), + (vel.0, ori, state.last_ori, time, state.avg_vel), state.state_time, &mut state_animation_rate, skeleton_attr, ), }; - state.skeleton = anim::vek::Lerp::lerp(&state.skeleton, &target_base, dt_lerp); + let target_bones = match &character { + CharacterState::Wielding { .. } => { + anim::biped_small::WieldAnimation::update_skeleton( + &target_base, + ( + vel.0, + ori, + state.last_ori, + time, + state.avg_vel, + state.acc_vel, + ), + state.state_time, + &mut state_animation_rate, + skeleton_attr, + ) + }, + // TODO! + _ => target_base, + }; + + state.skeleton = anim::vek::Lerp::lerp(&state.skeleton, &target_bones, dt_lerp); state.update( renderer, pos.0,