From f94a4ec90d61ea386deb6005b62824f37cd808fb Mon Sep 17 00:00:00 2001 From: Snowram Date: Sun, 29 Nov 2020 17:22:13 +0100 Subject: [PATCH] Improves fish_small, new npc --- assets/common/npc_names.json | 8 ++-- .../voxel/fish_small_central_manifest.ron | 28 ++++------- .../voxel/fish_small_lateral_manifest.ron | 20 ++++---- .../voxel/npc/clownfish/male/chest.vox | 3 ++ .../voxel/npc/clownfish/male/fin_l.vox | 3 ++ .../voxel/npc/clownfish/male/fin_r.vox | 3 ++ .../voxygen/voxel/npc/clownfish/male/tail.vox | 3 ++ assets/voxygen/voxel/npc/gecko/male/Gecko.vox | 3 -- assets/voxygen/voxel/npc/mindflayer/leg_l.vox | 3 -- assets/voxygen/voxel/npc/mindflayer/leg_r.vox | 3 -- .../voxel/npc/mindflayer/torso_lower.vox | 3 -- .../voxel/npc/mindflayer/torso_lower2.vox | 3 -- common/src/comp/body.rs | 2 +- common/src/comp/body/fish_small.rs | 8 ++-- common/src/npc.rs | 8 ++-- voxygen/anim/src/fish_medium/idle.rs | 1 - voxygen/anim/src/fish_small/idle.rs | 5 +- voxygen/anim/src/fish_small/jump.rs | 5 +- voxygen/anim/src/fish_small/mod.rs | 21 ++++----- voxygen/anim/src/fish_small/run.rs | 5 +- voxygen/src/anim/src/fish_medium/swim.rs | 8 +--- voxygen/src/anim/src/fish_medium/swimidle.rs | 7 ++- voxygen/src/anim/src/fish_small/swim.rs | 35 ++++++++++---- voxygen/src/anim/src/fish_small/swimidle.rs | 46 +++++++++++++++++++ voxygen/src/scene/figure/load.rs | 22 +-------- voxygen/src/scene/figure/mod.rs | 10 +++- 26 files changed, 144 insertions(+), 122 deletions(-) create mode 100644 assets/voxygen/voxel/npc/clownfish/male/chest.vox create mode 100644 assets/voxygen/voxel/npc/clownfish/male/fin_l.vox create mode 100644 assets/voxygen/voxel/npc/clownfish/male/fin_r.vox create mode 100644 assets/voxygen/voxel/npc/clownfish/male/tail.vox delete mode 100644 assets/voxygen/voxel/npc/gecko/male/Gecko.vox delete mode 100644 assets/voxygen/voxel/npc/mindflayer/leg_l.vox delete mode 100644 assets/voxygen/voxel/npc/mindflayer/leg_r.vox delete mode 100644 assets/voxygen/voxel/npc/mindflayer/torso_lower.vox delete mode 100644 assets/voxygen/voxel/npc/mindflayer/torso_lower2.vox create mode 100644 voxygen/src/anim/src/fish_small/swimidle.rs diff --git a/assets/common/npc_names.json b/assets/common/npc_names.json index 121b6da491..210da2b2db 100644 --- a/assets/common/npc_names.json +++ b/assets/common/npc_names.json @@ -686,7 +686,7 @@ "species": { "reddragon": { "keyword": "reddragon", - "generic": "Reddragon" + "generic": "Red Dragon" } } }, @@ -705,9 +705,9 @@ ] }, "species": { - "sardine": { - "keyword": "sardine", - "generic": "Sardine" + "clownfish": { + "keyword": "clownfish", + "generic": "Clownfish" } } }, diff --git a/assets/voxygen/voxel/fish_small_central_manifest.ron b/assets/voxygen/voxel/fish_small_central_manifest.ron index 13abb5b285..cd6a16b8f8 100644 --- a/assets/voxygen/voxel/fish_small_central_manifest.ron +++ b/assets/voxygen/voxel/fish_small_central_manifest.ron @@ -1,30 +1,22 @@ ({ - (Sardine, Male): ( - head: ( - offset: (-4.0, 0.0, -3.0), - central: ("npc.sardine.male.head"), - ), + (Clownfish, Male): ( chest: ( - offset: (-5.0, -7.5, -3.0), - central: ("npc.sardine.male.chest"), + offset: (-1.5, -7.5, -5.0), + central: ("npc.clownfish.male.chest"), ), tail: ( - offset: (-1.0, -9.0, -1.5), - central: ("npc.sardine.male.tail"), + offset: (-0.5, -5.0, -2.5), + central: ("npc.clownfish.male.tail"), ), ), - (Sardine, Female): ( - head: ( - offset: (-4.0, 0.0, -3.0), - central: ("npc.sardine.male.head"), - ), + (Clownfish, Female): ( chest: ( - offset: (-5.0, -7.5, -3.0), - central: ("npc.sardine.male.chest"), + offset: (-1.5, -7.5, -5.0), + central: ("npc.clownfish.male.chest"), ), tail: ( - offset: (-1.0, -9.0, -1.5), - central: ("npc.sardine.male.tail"), + offset: (-0.5, -5.0, -2.5), + central: ("npc.clownfish.male.tail"), ), ), }) diff --git a/assets/voxygen/voxel/fish_small_lateral_manifest.ron b/assets/voxygen/voxel/fish_small_lateral_manifest.ron index c93e3579df..55415f9a5d 100644 --- a/assets/voxygen/voxel/fish_small_lateral_manifest.ron +++ b/assets/voxygen/voxel/fish_small_lateral_manifest.ron @@ -1,22 +1,22 @@ ({ - (Sardine, Male): ( + (Clownfish, Male): ( fin_l: ( - offset: (-1.5, -5.0, -3.0), - lateral: ("npc.sardine.male.fin_l"), + offset: (-0.5, -3.0, -4.0), + lateral: ("npc.clownfish.male.fin_l"), ), fin_r: ( - offset: (-1.5, -5.0, -3.0), - lateral: ("npc.sardine.male.fin_r"), + offset: (-0.5, -3.0, -4.0), + lateral: ("npc.clownfish.male.fin_r"), ), ), - (Sardine, Female): ( + (Clownfish, Female): ( fin_l: ( - offset: (-1.5, -5.0, -3.0), - lateral: ("npc.sardine.male.fin_l"), + offset: (-0.5, -3.0, -4.0), + lateral: ("npc.clownfish.male.fin_l"), ), fin_r: ( - offset: (-1.5, -5.0, -3.0), - lateral: ("npc.sardine.male.fin_r"), + offset: (-0.5, -3.0, -4.0), + lateral: ("npc.clownfish.male.fin_r"), ), ), }) diff --git a/assets/voxygen/voxel/npc/clownfish/male/chest.vox b/assets/voxygen/voxel/npc/clownfish/male/chest.vox new file mode 100644 index 0000000000..997ad9f76e --- /dev/null +++ b/assets/voxygen/voxel/npc/clownfish/male/chest.vox @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:7883cddef22e596ae73716f6c877f3c747792a0752414fa95b85f4ca204d98df +size 1756 diff --git a/assets/voxygen/voxel/npc/clownfish/male/fin_l.vox b/assets/voxygen/voxel/npc/clownfish/male/fin_l.vox new file mode 100644 index 0000000000..fbab630e4f --- /dev/null +++ b/assets/voxygen/voxel/npc/clownfish/male/fin_l.vox @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:5e07ac13b045455fa6a13115b0de82884d9475b39a8ac450a0e4e51c663fa4e5 +size 1132 diff --git a/assets/voxygen/voxel/npc/clownfish/male/fin_r.vox b/assets/voxygen/voxel/npc/clownfish/male/fin_r.vox new file mode 100644 index 0000000000..fbab630e4f --- /dev/null +++ b/assets/voxygen/voxel/npc/clownfish/male/fin_r.vox @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:5e07ac13b045455fa6a13115b0de82884d9475b39a8ac450a0e4e51c663fa4e5 +size 1132 diff --git a/assets/voxygen/voxel/npc/clownfish/male/tail.vox b/assets/voxygen/voxel/npc/clownfish/male/tail.vox new file mode 100644 index 0000000000..9ee4906b93 --- /dev/null +++ b/assets/voxygen/voxel/npc/clownfish/male/tail.vox @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:7f60c0fb6701d3cff1bf170cf30d21434fc3fbebb2682ce292bf24014f53899c +size 1172 diff --git a/assets/voxygen/voxel/npc/gecko/male/Gecko.vox b/assets/voxygen/voxel/npc/gecko/male/Gecko.vox deleted file mode 100644 index 9d9bcbae4c..0000000000 --- a/assets/voxygen/voxel/npc/gecko/male/Gecko.vox +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:68ba19e7cea78b0523ed843f958700d4a0c55cd63adf1f04968d6d0f0015f963 -size 57760 diff --git a/assets/voxygen/voxel/npc/mindflayer/leg_l.vox b/assets/voxygen/voxel/npc/mindflayer/leg_l.vox deleted file mode 100644 index 90aba41f0d..0000000000 --- a/assets/voxygen/voxel/npc/mindflayer/leg_l.vox +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:4b68f2846d392c090b550c14ef335db326683d72d09f701de917ba6b7aad6f21 -size 4940 diff --git a/assets/voxygen/voxel/npc/mindflayer/leg_r.vox b/assets/voxygen/voxel/npc/mindflayer/leg_r.vox deleted file mode 100644 index 353b007258..0000000000 --- a/assets/voxygen/voxel/npc/mindflayer/leg_r.vox +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:34c4aa529fa76c169aa1fcd668efe11cd6105b80a0ded0bac4180e58272680a7 -size 4940 diff --git a/assets/voxygen/voxel/npc/mindflayer/torso_lower.vox b/assets/voxygen/voxel/npc/mindflayer/torso_lower.vox deleted file mode 100644 index 45cd9ea15e..0000000000 --- a/assets/voxygen/voxel/npc/mindflayer/torso_lower.vox +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:4c9420360d1425d1487bceccd8a73c623c84523ba5609cf7f643451b05e3269e -size 9004 diff --git a/assets/voxygen/voxel/npc/mindflayer/torso_lower2.vox b/assets/voxygen/voxel/npc/mindflayer/torso_lower2.vox deleted file mode 100644 index 57b073e2fb..0000000000 --- a/assets/voxygen/voxel/npc/mindflayer/torso_lower2.vox +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:d754404c12663dd01f8775cf016411c7130abc99384598629c4f23380a51f92f -size 1996 diff --git a/common/src/comp/body.rs b/common/src/comp/body.rs index 90a25eb131..b528698b2d 100644 --- a/common/src/comp/body.rs +++ b/common/src/comp/body.rs @@ -87,7 +87,7 @@ impl core::ops::Index for AllBodies &self.quadruped_small.body, NpcKind::Wolf => &self.quadruped_medium.body, NpcKind::Duck => &self.bird_medium.body, - NpcKind::Sardine => &self.fish_medium.body, + NpcKind::Clownfish => &self.fish_medium.body, NpcKind::Marlin => &self.fish_small.body, NpcKind::Ogre => &self.biped_large.body, NpcKind::StoneGolem => &self.golem.body, diff --git a/common/src/comp/body/fish_small.rs b/common/src/comp/body/fish_small.rs index b962d56ea4..90c7597436 100644 --- a/common/src/comp/body/fish_small.rs +++ b/common/src/comp/body/fish_small.rs @@ -34,7 +34,7 @@ make_case_elim!( #[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)] #[repr(u32)] pub enum Species { - Sardine = 0, + Clownfish = 0, } ); @@ -43,7 +43,7 @@ make_case_elim!( /// NOTE: Deliberately don't (yet?) implement serialize. #[derive(Clone, Debug, Deserialize)] pub struct AllSpecies { - pub sardine: SpeciesMeta, + pub clownfish: SpeciesMeta, } impl<'a, SpeciesMeta> core::ops::Index<&'a Species> for AllSpecies { @@ -52,12 +52,12 @@ impl<'a, SpeciesMeta> core::ops::Index<&'a Species> for AllSpecies #[inline] fn index(&self, &index: &'a Species) -> &Self::Output { match index { - Species::Sardine => &self.sardine, + Species::Clownfish => &self.clownfish, } } } -pub const ALL_SPECIES: [Species; 1] = [Species::Sardine]; +pub const ALL_SPECIES: [Species; 1] = [Species::Clownfish]; impl<'a, SpeciesMeta: 'a> IntoIterator for &'a AllSpecies { type IntoIter = std::iter::Copied>; diff --git a/common/src/npc.rs b/common/src/npc.rs index ee997f4726..806a34d24f 100644 --- a/common/src/npc.rs +++ b/common/src/npc.rs @@ -13,7 +13,7 @@ pub enum NpcKind { Wolf, Pig, Duck, - Sardine, + Clownfish, Marlin, Ogre, Archaeos, @@ -27,7 +27,7 @@ pub const ALL_NPCS: [NpcKind; 11] = [ NpcKind::Wolf, NpcKind::Pig, NpcKind::Duck, - NpcKind::Sardine, + NpcKind::Clownfish, NpcKind::Marlin, NpcKind::Ogre, NpcKind::Archaeos, @@ -97,7 +97,7 @@ pub fn kind_to_body(kind: NpcKind) -> Body { NpcKind::Pig => comp::quadruped_small::Body::random().into(), NpcKind::Wolf => comp::quadruped_medium::Body::random().into(), NpcKind::Duck => comp::bird_medium::Body::random().into(), - NpcKind::Sardine => comp::fish_small::Body::random().into(), + NpcKind::Clownfish => comp::fish_small::Body::random().into(), NpcKind::Marlin => comp::fish_medium::Body::random().into(), NpcKind::Ogre => comp::biped_large::Body::random().into(), NpcKind::Archaeos => comp::theropod::Body::random().into(), @@ -204,7 +204,7 @@ impl NpcBody { .or_else(|| { parse( s, - NpcKind::Sardine, + NpcKind::Clownfish, &npc_names.fish_small, comp::fish_small::Body::random_with, ) diff --git a/voxygen/anim/src/fish_medium/idle.rs b/voxygen/anim/src/fish_medium/idle.rs index 3c8497f5e7..26c57a6d54 100644 --- a/voxygen/anim/src/fish_medium/idle.rs +++ b/voxygen/anim/src/fish_medium/idle.rs @@ -22,7 +22,6 @@ impl Animation for IdleAnimation { ) -> Self::Skeleton { let mut next = (*skeleton).clone(); - let slower = (anim_time as f32 * 1.0 + PI).sin(); let slow = (anim_time as f32 * 3.5 + PI).sin(); let slowalt = (anim_time as f32 * 3.5 + PI + 0.2).sin(); diff --git a/voxygen/anim/src/fish_small/idle.rs b/voxygen/anim/src/fish_small/idle.rs index 42a0fd663e..3622cf8b67 100644 --- a/voxygen/anim/src/fish_small/idle.rs +++ b/voxygen/anim/src/fish_small/idle.rs @@ -21,10 +21,7 @@ impl Animation for IdleAnimation { ) -> Self::Skeleton { let mut next = (*skeleton).clone(); - next.head.scale = Vec3::one() / 11.0; - - next.head.position = Vec3::new(0.0, s_a.head.0, s_a.head.1); - next.head.orientation = Quaternion::rotation_z(0.0) * Quaternion::rotation_x(0.0); + next.chest.scale = Vec3::one() / 11.0; next.chest.position = Vec3::new(0.0, s_a.chest.0, s_a.chest.1) / 11.0; next.chest.orientation = Quaternion::rotation_x(0.0); diff --git a/voxygen/anim/src/fish_small/jump.rs b/voxygen/anim/src/fish_small/jump.rs index b02202ee0f..5b9511184d 100644 --- a/voxygen/anim/src/fish_small/jump.rs +++ b/voxygen/anim/src/fish_small/jump.rs @@ -21,10 +21,7 @@ impl Animation for JumpAnimation { ) -> Self::Skeleton { let mut next = (*skeleton).clone(); - next.head.scale = Vec3::one() / 11.0; - - next.head.position = Vec3::new(0.0, s_a.head.0, s_a.head.1); - next.head.orientation = Quaternion::rotation_z(0.0) * Quaternion::rotation_x(0.0); + next.chest.scale = Vec3::one() / 11.0; next.chest.position = Vec3::new(0.0, s_a.chest.0, s_a.chest.1) / 11.0; next.chest.orientation = Quaternion::rotation_x(0.0); diff --git a/voxygen/anim/src/fish_small/mod.rs b/voxygen/anim/src/fish_small/mod.rs index a18c569e2f..dafa89e9f0 100644 --- a/voxygen/anim/src/fish_small/mod.rs +++ b/voxygen/anim/src/fish_small/mod.rs @@ -2,9 +2,13 @@ pub mod idle; pub mod jump; pub mod run; pub mod swim; +pub mod swimidle; // Reexports -pub use self::{idle::IdleAnimation, jump::JumpAnimation, run::RunAnimation, swim::SwimAnimation}; +pub use self::{ + idle::IdleAnimation, jump::JumpAnimation, run::RunAnimation, swim::SwimAnimation, + swimidle::SwimIdleAnimation, +}; use super::{make_bone, vek::*, FigureBoneData, Skeleton}; use common::comp::{self}; @@ -13,7 +17,6 @@ use core::convert::TryFrom; pub type Body = comp::fish_small::Body; skeleton_impls!(struct FishSmallSkeleton { - + head, + chest, + tail, + fin_l, @@ -24,7 +27,7 @@ impl Skeleton for FishSmallSkeleton { type Attr = SkeletonAttr; type Body = Body; - const BONE_COUNT: usize = 5; + const BONE_COUNT: usize = 4; #[cfg(feature = "use-dyn-lib")] const COMPUTE_FN: &'static [u8] = b"fish_small_compute_mats\0"; @@ -37,7 +40,6 @@ impl Skeleton for FishSmallSkeleton { let chest_mat = base_mat * Mat4::::from(self.chest); *(<&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(chest_mat * Mat4::::from(self.tail)), make_bone(chest_mat * Mat4::::from(self.fin_l)), @@ -48,7 +50,6 @@ impl Skeleton for FishSmallSkeleton { } pub struct SkeletonAttr { - head: (f32, f32), chest: (f32, f32), tail: (f32, f32), fin: (f32, f32, f32), @@ -68,7 +69,6 @@ impl<'a> std::convert::TryFrom<&'a comp::Body> for SkeletonAttr { impl Default for SkeletonAttr { fn default() -> Self { Self { - head: (0.0, 0.0), chest: (0.0, 0.0), tail: (0.0, 0.0), fin: (0.0, 0.0, 0.0), @@ -80,17 +80,14 @@ impl<'a> From<&'a Body> for SkeletonAttr { fn from(body: &'a Body) -> Self { use comp::fish_small::Species::*; Self { - head: match (body.species, body.body_type) { - (Sardine, _) => (1.5, 2.0), - }, chest: match (body.species, body.body_type) { - (Sardine, _) => (0.0, 5.0), + (Clownfish, _) => (0.0, 5.0), }, tail: match (body.species, body.body_type) { - (Sardine, _) => (-6.0, 0.0), + (Clownfish, _) => (-7.5, -0.5), }, fin: match (body.species, body.body_type) { - (Sardine, _) => (3.5, 6.0, -1.0), + (Clownfish, _) => (2.0, 0.5, 1.0), }, } } diff --git a/voxygen/anim/src/fish_small/run.rs b/voxygen/anim/src/fish_small/run.rs index c3fa97be8e..2af8984b6d 100644 --- a/voxygen/anim/src/fish_small/run.rs +++ b/voxygen/anim/src/fish_small/run.rs @@ -21,10 +21,7 @@ impl Animation for RunAnimation { ) -> Self::Skeleton { let mut next = (*skeleton).clone(); - next.head.scale = Vec3::one() / 11.0; - - next.head.position = Vec3::new(0.0, s_a.head.0, s_a.head.1); - next.head.orientation = Quaternion::rotation_z(0.0) * Quaternion::rotation_x(0.0); + next.chest.scale = Vec3::one() / 11.0; next.chest.position = Vec3::new(0.0, s_a.chest.0, s_a.chest.1) / 11.0; next.chest.orientation = Quaternion::rotation_x(0.0); diff --git a/voxygen/src/anim/src/fish_medium/swim.rs b/voxygen/src/anim/src/fish_medium/swim.rs index dc4ebf2c55..97a1dc2629 100644 --- a/voxygen/src/anim/src/fish_medium/swim.rs +++ b/voxygen/src/anim/src/fish_medium/swim.rs @@ -19,15 +19,13 @@ impl Animation for SwimAnimation { fn update_skeleton_inner( skeleton: &Self::Skeleton, - (velocity, orientation, last_ori, global_time, avg_vel): Self::Dependency, + (velocity, orientation, last_ori, _global_time, avg_vel): Self::Dependency, anim_time: f64, - rate: &mut f32, + _rate: &mut f32, s_a: &SkeletonAttr, ) -> Self::Skeleton { let mut next = (*skeleton).clone(); - let slower = (anim_time as f32 * 1.0 + PI).sin(); - let slow = (anim_time as f32 * 3.5 + PI).sin(); let slowalt = (anim_time as f32 * 3.5 + PI + 0.2).sin(); let fast = (anim_time as f32 * 5.5 + PI).sin(); let fastalt = (anim_time as f32 * 5.5 + PI + 0.2).sin(); @@ -48,8 +46,6 @@ impl Animation for SwimAnimation { let abstilt = tilt.abs(); let x_tilt = avg_vel.z.atan2(avg_vel.xy().magnitude()); - let squash = if abstilt > 0.2 { 0.35 } else { 1.0 }; //condenses the body at strong turns - next.chest_front.scale = Vec3::one() / 11.0; next.head.position = Vec3::new(0.0, s_a.head.0, s_a.head.1); diff --git a/voxygen/src/anim/src/fish_medium/swimidle.rs b/voxygen/src/anim/src/fish_medium/swimidle.rs index 3abd898a32..049e3abc46 100644 --- a/voxygen/src/anim/src/fish_medium/swimidle.rs +++ b/voxygen/src/anim/src/fish_medium/swimidle.rs @@ -2,7 +2,7 @@ use super::{ super::{vek::*, Animation}, FishMediumSkeleton, SkeletonAttr, }; -use std::{f32::consts::PI, ops::Mul}; +use std::f32::consts::PI; pub struct SwimIdleAnimation; @@ -19,14 +19,13 @@ impl Animation for SwimIdleAnimation { fn update_skeleton_inner( skeleton: &Self::Skeleton, - (velocity, orientation, last_ori, global_time, avg_vel): Self::Dependency, + (_velocity, _orientation, _last_ori, _global_time, _avg_vel): Self::Dependency, anim_time: f64, - rate: &mut f32, + _rate: &mut f32, s_a: &SkeletonAttr, ) -> Self::Skeleton { let mut next = (*skeleton).clone(); - let slower = (anim_time as f32 * 1.0 + PI).sin(); let slow = (anim_time as f32 * 3.5 + PI).sin(); let slowalt = (anim_time as f32 * 3.5 + PI + 0.2).sin(); diff --git a/voxygen/src/anim/src/fish_small/swim.rs b/voxygen/src/anim/src/fish_small/swim.rs index 774dc43316..9672c471e6 100644 --- a/voxygen/src/anim/src/fish_small/swim.rs +++ b/voxygen/src/anim/src/fish_small/swim.rs @@ -2,6 +2,7 @@ use super::{ super::{vek::*, Animation}, FishSmallSkeleton, SkeletonAttr, }; +use std::f32::consts::PI; pub struct SwimAnimation; @@ -18,29 +19,45 @@ impl Animation for SwimAnimation { fn update_skeleton_inner( skeleton: &Self::Skeleton, - (velocity, orientation, last_ori, global_time, avg_vel): Self::Dependency, - _anim_time: f64, + (velocity, orientation, last_ori, _global_time, avg_vel): Self::Dependency, + anim_time: f64, _rate: &mut f32, s_a: &SkeletonAttr, ) -> Self::Skeleton { let mut next = (*skeleton).clone(); - next.head.scale = Vec3::one() / 11.0; + let fast = (anim_time as f32 * 7.0 + PI).sin(); - next.head.position = Vec3::new(0.0, s_a.head.0, s_a.head.1); - next.head.orientation = Quaternion::rotation_z(0.0) * Quaternion::rotation_x(0.0); + let ori: Vec2 = Vec2::from(orientation); + let last_ori = Vec2::from(last_ori); + let tilt = if ::vek::Vec2::new(ori, last_ori) + .map(|o| o.magnitude_squared()) + .map(|m| m > 0.001 && m.is_finite()) + .reduce_and() + && ori.angle_between(last_ori).is_finite() + { + ori.angle_between(last_ori).min(0.8) + * last_ori.determine_side(Vec2::zero(), ori).signum() + } else { + 0.0 + } * 1.3; + let abstilt = tilt.abs(); + let x_tilt = avg_vel.z.atan2(avg_vel.xy().magnitude()); + + next.chest.scale = Vec3::one() / 11.0; next.chest.position = Vec3::new(0.0, s_a.chest.0, s_a.chest.1) / 11.0; - next.chest.orientation = Quaternion::rotation_x(0.0); + next.chest.orientation = Quaternion::rotation_z(fast * -0.1) + + Quaternion::rotation_x(velocity.z.abs() * -0.005 + abstilt * 1.0 + x_tilt); next.tail.position = Vec3::new(0.0, s_a.tail.0, s_a.tail.1); - next.tail.orientation = Quaternion::rotation_z(0.0) * Quaternion::rotation_x(0.0); + next.tail.orientation = Quaternion::rotation_z(fast * 0.3 + tilt * 2.0); next.fin_l.position = Vec3::new(-s_a.fin.0, s_a.fin.1, s_a.fin.2); - next.fin_l.orientation = Quaternion::rotation_y(0.0); + next.fin_l.orientation = Quaternion::rotation_z(fast * 0.3 - 0.3 + tilt * -0.5); next.fin_r.position = Vec3::new(s_a.fin.0, s_a.fin.1, s_a.fin.2); - next.fin_r.orientation = Quaternion::rotation_y(0.0); + next.fin_r.orientation = Quaternion::rotation_z(-fast * 0.3 + 0.3 + tilt * -0.5); next } } diff --git a/voxygen/src/anim/src/fish_small/swimidle.rs b/voxygen/src/anim/src/fish_small/swimidle.rs new file mode 100644 index 0000000000..551e7e8b0c --- /dev/null +++ b/voxygen/src/anim/src/fish_small/swimidle.rs @@ -0,0 +1,46 @@ +use super::{ + super::{vek::*, Animation}, + FishSmallSkeleton, SkeletonAttr, +}; +use std::f32::consts::PI; + +pub struct SwimIdleAnimation; + +type SwimIdleAnimationDependency = (Vec3, Vec3, Vec3, f64, Vec3); + +impl Animation for SwimIdleAnimation { + type Dependency = SwimIdleAnimationDependency; + type Skeleton = FishSmallSkeleton; + + #[cfg(feature = "use-dyn-lib")] + const UPDATE_FN: &'static [u8] = b"fish_small_swimidle\0"; + + #[cfg_attr(feature = "be-dyn-lib", export_name = "fish_small_swimidle")] + + fn update_skeleton_inner( + skeleton: &Self::Skeleton, + (_velocity, _orientation, _last_ori, _global_time, _avg_vel): Self::Dependency, + anim_time: f64, + _rate: &mut f32, + s_a: &SkeletonAttr, + ) -> Self::Skeleton { + let mut next = (*skeleton).clone(); + + let slow = (anim_time as f32 * 3.5 + PI).sin(); + + next.chest.scale = Vec3::one() / 11.0; + + next.chest.position = Vec3::new(0.0, s_a.chest.0, s_a.chest.1) / 11.0; + next.chest.orientation = Quaternion::rotation_x(0.0); + + next.tail.position = Vec3::new(0.0, s_a.tail.0, s_a.tail.1); + next.tail.orientation = Quaternion::rotation_z(slow * 0.1); + + next.fin_l.position = Vec3::new(-s_a.fin.0, s_a.fin.1, s_a.fin.2); + next.fin_l.orientation = Quaternion::rotation_z(slow * 0.1 - 0.1); + + next.fin_r.position = Vec3::new(s_a.fin.0, s_a.fin.1, s_a.fin.2); + next.fin_r.orientation = Quaternion::rotation_z(-slow * 0.1 + 0.1); + next + } +} diff --git a/voxygen/src/scene/figure/load.rs b/voxygen/src/scene/figure/load.rs index 12ef0b1ea9..c4b69a1134 100644 --- a/voxygen/src/scene/figure/load.rs +++ b/voxygen/src/scene/figure/load.rs @@ -2287,7 +2287,6 @@ struct FishSmallCentralSpec(HashMap<(FSSpecies, FSBodyType), SidedFSCentralVoxSp #[derive(Deserialize)] struct SidedFSCentralVoxSpec { - head: FishSmallCentralSubSpec, chest: FishSmallCentralSubSpec, tail: FishSmallCentralSubSpec, } @@ -2317,10 +2316,6 @@ make_vox_spec!( }, |FigureKey { body, .. }, spec| { [ - Some(spec.central.asset.mesh_head( - body.species, - body.body_type, - )), Some(spec.central.asset.mesh_chest( body.species, body.body_type, @@ -2348,27 +2343,12 @@ make_vox_spec!( None, None, None, + None, ] }, ); impl FishSmallCentralSpec { - fn mesh_head(&self, species: FSSpecies, body_type: FSBodyType) -> BoneMeshes { - let spec = match self.0.get(&(species, body_type)) { - Some(spec) => spec, - None => { - error!( - "No head 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.head.central.0); - - (central, Vec3::from(spec.head.offset)) - } - fn mesh_chest(&self, species: FSSpecies, body_type: FSBodyType) -> BoneMeshes { let spec = match self.0.get(&(species, body_type)) { Some(spec) => spec, diff --git a/voxygen/src/scene/figure/mod.rs b/voxygen/src/scene/figure/mod.rs index cd58b7d409..3eabc4eb58 100644 --- a/voxygen/src/scene/figure/mod.rs +++ b/voxygen/src/scene/figure/mod.rs @@ -2605,8 +2605,16 @@ impl FigureMgr { &mut state_animation_rate, skeleton_attr, ), + // Idle Water + (_, false, true) => anim::fish_small::SwimIdleAnimation::update_skeleton( + &FishSmallSkeleton::default(), + (vel.0, ori, state.last_ori, time, state.avg_vel), + state.state_time, + &mut state_animation_rate, + skeleton_attr, + ), // Swim - (_, _, true) => anim::fish_small::SwimAnimation::update_skeleton( + (_, true, true) => anim::fish_small::SwimAnimation::update_skeleton( &FishSmallSkeleton::default(), (vel.0, ori, state.last_ori, time, state.avg_vel), state.state_time,