From bcc257f893533e568a61a81bd84c099d3f5c2c22 Mon Sep 17 00:00:00 2001 From: jshipsey Date: Sat, 1 Aug 2020 02:19:01 -0400 Subject: [PATCH] cleanup, last tweaks --- .../voxel/biped_large_center_manifest.ron | 24 ++--- .../voxel/bird_medium_center_manifest.ron | 12 +-- .../voxygen/voxel/npc/peacock/male/chest.vox | 3 - .../voxygen/voxel/npc/peacock/male/torso.vox | 4 +- voxygen/src/anim/src/biped_large/mod.rs | 22 ++--- voxygen/src/anim/src/biped_large/wield.rs | 2 - voxygen/src/anim/src/bird_medium/feed.rs | 94 +++++++++++++++++++ voxygen/src/anim/src/bird_medium/mod.rs | 21 ++++- voxygen/src/anim/src/dragon/run.rs | 21 +---- voxygen/src/anim/src/quadruped_small/mod.rs | 2 +- voxygen/src/scene/figure/mod.rs | 23 ++++- 11 files changed, 165 insertions(+), 63 deletions(-) delete mode 100644 assets/voxygen/voxel/npc/peacock/male/chest.vox create mode 100644 voxygen/src/anim/src/bird_medium/feed.rs diff --git a/assets/voxygen/voxel/biped_large_center_manifest.ron b/assets/voxygen/voxel/biped_large_center_manifest.ron index 2e5c424de2..78447fca21 100644 --- a/assets/voxygen/voxel/biped_large_center_manifest.ron +++ b/assets/voxygen/voxel/biped_large_center_manifest.ron @@ -9,12 +9,12 @@ center: ("npc.ogre.male.torso_upper"), ), torso_lower: ( - offset: (-5.0, -4.5, -4.5), + offset: (-5.0, -4.5, -9.0), center: ("npc.ogre.male.torso_lower"), ), main: ( offset: (-8.0, -4.5, -5.0), - center: ("npc.ogre.male.torso_upper"), + center: ("armor.empty"), ) ), (Ogre, Female): ( @@ -27,12 +27,12 @@ center: ("npc.ogre.male.torso_upper"), ), torso_lower: ( - offset: (-5.0, -4.5, -4.5), + offset: (-5.0, -4.5, -9.0), center: ("npc.ogre.male.torso_lower"), ), main: ( offset: (-8.0, -4.5, -5.0), - center: ("npc.ogre.male.torso_upper"), + center: ("armor.empty"), ) ), (Cyclops, Male): ( @@ -81,12 +81,12 @@ center: ("npc.wendigo.male.torso_upper"), ), torso_lower: ( - offset: (-4.0, -2.0, -2.0), + offset: (-4.0, -2.0, -4.0), center: ("npc.wendigo.male.torso_lower"), ), main: ( offset: (-8.0, -4.5, -5.0), - center: ("npc.ogre.male.torso_upper"), + center: ("armor.empty"), ) ), (Wendigo, Female): ( @@ -99,12 +99,12 @@ center: ("npc.wendigo.male.torso_upper"), ), torso_lower: ( - offset: (-4.0, -2.0, -2.0), + offset: (-4.0, -2.0, -4.0), center: ("npc.wendigo.male.torso_lower"), ), main: ( offset: (-8.0, -4.5, -5.0), - center: ("npc.ogre.male.torso_upper"), + center: ("armor.empty"), ) ), (Troll, Male): ( @@ -117,12 +117,12 @@ center: ("npc.troll.male.torso_upper"), ), torso_lower: ( - offset: (-6.0, -3.5, -2.5), + offset: (-6.0, -3.5, -5.0), center: ("npc.troll.male.torso_lower"), ), main: ( offset: (-8.0, -4.5, -5.0), - center: ("npc.ogre.male.torso_upper"), + center: ("armor.empty"), ) ), (Troll, Female): ( @@ -135,12 +135,12 @@ center: ("npc.troll.male.torso_upper"), ), torso_lower: ( - offset: (-6.0, -3.5, -2.5), + offset: (-6.0, -3.5, -5.0), center: ("npc.troll.male.torso_lower"), ), main: ( offset: (-8.0, -4.5, -5.0), - center: ("npc.ogre.male.torso_upper"), + center: ("armor.empty"), ) ), }) diff --git a/assets/voxygen/voxel/bird_medium_center_manifest.ron b/assets/voxygen/voxel/bird_medium_center_manifest.ron index 7f79179c51..6657154280 100644 --- a/assets/voxygen/voxel/bird_medium_center_manifest.ron +++ b/assets/voxygen/voxel/bird_medium_center_manifest.ron @@ -57,7 +57,7 @@ ), (Goose, Male): ( head: ( - offset: (-2.0, -3.5, -2.5), + offset: (-2.0, -3.5, -0.0), center: ("npc.goose.male.head"), ), torso: ( @@ -71,7 +71,7 @@ ), (Goose, Female): ( head: ( - offset: (-2.0, -3.5, -2.5), + offset: (-2.0, -3.5, -0.0), center: ("npc.goose.male.head"), ), torso: ( @@ -85,7 +85,7 @@ ), (Peacock, Male): ( head: ( - offset: (-2.0, -1.5, -6.5), + offset: (-2.0, -1.5, -0.0), center: ("npc.peacock.male.head"), ), torso: ( @@ -99,7 +99,7 @@ ), (Peacock, Female): ( head: ( - offset: (-2.0, -1.5, -6.5), + offset: (-2.0, -1.5, -0.0), center: ("npc.peacock.female.head"), ), torso: ( @@ -197,7 +197,7 @@ ), (Cockatrice, Male): ( head: ( - offset: (-2.5, -3.5, -8.0), + offset: (-2.5, 0.0, -8.0), center: ("npc.cockatrice.male.head"), ), torso: ( @@ -211,7 +211,7 @@ ), (Cockatrice, Female): ( head: ( - offset: (-2.5, -3.5, -8.0), + offset: (-2.5, 0.0, -8.0), center: ("npc.cockatrice.male.head"), ), torso: ( diff --git a/assets/voxygen/voxel/npc/peacock/male/chest.vox b/assets/voxygen/voxel/npc/peacock/male/chest.vox deleted file mode 100644 index efec8ac0ca..0000000000 --- a/assets/voxygen/voxel/npc/peacock/male/chest.vox +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:24688eaad7d459d4a4c0eba71edaca1ba83ec09552b970ac581c6e2e2081f880 -size 1932 diff --git a/assets/voxygen/voxel/npc/peacock/male/torso.vox b/assets/voxygen/voxel/npc/peacock/male/torso.vox index 58b5a9b000..efec8ac0ca 100644 --- a/assets/voxygen/voxel/npc/peacock/male/torso.vox +++ b/assets/voxygen/voxel/npc/peacock/male/torso.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:3887edeebda253b90f44441205a28eadd1e5b94c9f3868c0f8f610d31af02aba -size 2296 +oid sha256:24688eaad7d459d4a4c0eba71edaca1ba83ec09552b970ac581c6e2e2081f880 +size 1932 diff --git a/voxygen/src/anim/src/biped_large/mod.rs b/voxygen/src/anim/src/biped_large/mod.rs index a15d030039..e3f9432623 100644 --- a/voxygen/src/anim/src/biped_large/mod.rs +++ b/voxygen/src/anim/src/biped_large/mod.rs @@ -145,14 +145,14 @@ impl<'a> From<&'a comp::biped_large::Body> for SkeletonAttr { upper_torso: match (body.species, body.body_type) { (Ogre, _) => (0.0, 19.0), (Cyclops, _) => (-2.0, 27.0), - (Wendigo, _) => (-1.0, 27.0), - (Troll, _) => (-1.0, 25.5), + (Wendigo, _) => (-1.0, 29.0), + (Troll, _) => (-1.0, 27.5), }, lower_torso: match (body.species, body.body_type) { - (Ogre, _) => (1.0, -9.5), + (Ogre, _) => (1.0, -5.5), (Cyclops, _) => (1.0, -4.5), - (Wendigo, _) => (-1.5, -8.0), - (Troll, _) => (1.0, -12.5), + (Wendigo, _) => (-1.5, -6.0), + (Troll, _) => (1.0, -10.5), }, shoulder: match (body.species, body.body_type) { (Ogre, _) => (6.1, 0.5, 2.5), @@ -167,16 +167,16 @@ impl<'a> From<&'a comp::biped_large::Body> for SkeletonAttr { (Troll, _) => (11.5, 0.0, -1.5), }, leg: match (body.species, body.body_type) { - (Ogre, _) => (0.0, 0.0, -6.0), + (Ogre, _) => (0.0, 0.0, 0.0), (Cyclops, _) => (0.0, 0.0, -5.0), - (Wendigo, _) => (2.0, 0.0, -8.5), - (Troll, _) => (5.0, 0.0, -16.0), + (Wendigo, _) => (2.0, 2.0, -2.5), + (Troll, _) => (5.0, 0.0, -6.0), }, foot: match (body.species, body.body_type) { - (Ogre, _) => (4.0, 0.5, 5.5), + (Ogre, _) => (4.0, 2.5, 2.5), (Cyclops, _) => (4.0, 0.5, 5.0), - (Wendigo, _) => (5.0, 0.5, 5.5), - (Troll, _) => (6.0, 0.5, 3.0), + (Wendigo, _) => (5.0, 0.5, 6.0), + (Troll, _) => (6.0, 0.5, 4.0), }, } } diff --git a/voxygen/src/anim/src/biped_large/wield.rs b/voxygen/src/anim/src/biped_large/wield.rs index 332e1ecfa0..4edd995536 100644 --- a/voxygen/src/anim/src/biped_large/wield.rs +++ b/voxygen/src/anim/src/biped_large/wield.rs @@ -52,8 +52,6 @@ impl Animation for WieldAnimation { * ((anim_time as f32 * 16.0 * lab as f32 + PI * 0.4).sin()); let footvertl = (anim_time as f32 * 16.0 * lab as f32).sin(); let footvertr = (anim_time as f32 * 16.0 * lab as f32 + PI).sin(); - let handhoril = (anim_time as f32 * 16.0 * lab as f32 + PI * 1.4).sin(); - let handhorir = (anim_time as f32 * 16.0 * lab as f32 + PI * 0.4).sin(); let footrotl = (((5.0) / (2.5 diff --git a/voxygen/src/anim/src/bird_medium/feed.rs b/voxygen/src/anim/src/bird_medium/feed.rs new file mode 100644 index 0000000000..a5ca080177 --- /dev/null +++ b/voxygen/src/anim/src/bird_medium/feed.rs @@ -0,0 +1,94 @@ +use super::{super::Animation, BirdMediumSkeleton, SkeletonAttr}; +use std::ops::Mul; +use vek::*; + +pub struct FeedAnimation; + +impl Animation for FeedAnimation { + type Dependency = f64; + type Skeleton = BirdMediumSkeleton; + + #[cfg(feature = "use-dyn-lib")] + const UPDATE_FN: &'static [u8] = b"bird_medium_feed\0"; + + #[cfg_attr(feature = "be-dyn-lib", export_name = "bird_medium_feed")] + + fn update_skeleton_inner( + skeleton: &Self::Skeleton, + global_time: Self::Dependency, + anim_time: f64, + _rate: &mut f32, + skeleton_attr: &SkeletonAttr, + ) -> Self::Skeleton { + let mut next = (*skeleton).clone(); + + let wave_slow = (anim_time as f32 * 4.5).sin(); + let wave = (anim_time as f32 * 8.0).sin(); + + let wave_slow_cos = (anim_time as f32 * 4.5).cos(); + + let duck_head_look = Vec2::new( + ((global_time + anim_time) as f32 / 2.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, skeleton_attr.head.0 + 1.0, -2.0 + skeleton_attr.head.1); + next.head.ori = Quaternion::rotation_z(duck_head_look.x) + * Quaternion::rotation_x(-0.3 / skeleton_attr.feed + wave_slow_cos * 0.03 + wave * 0.1); + next.head.scale = Vec3::one(); + + next.torso.offset = Vec3::new( + 0.0, + skeleton_attr.chest.0 + skeleton_attr.feed, + -1.0 - 5.0 * (skeleton_attr.feed - 1.0) + wave_slow * 0.3 + skeleton_attr.chest.1, + ) / 11.0; + next.torso.ori = Quaternion::rotation_x(-0.5 * skeleton_attr.feed) + * Quaternion::rotation_y(wave_slow * 0.03); + next.torso.scale = Vec3::one() / 11.0; + + next.tail.offset = Vec3::new(0.0, skeleton_attr.tail.0, skeleton_attr.tail.1); + next.tail.ori = Quaternion::rotation_x(wave_slow_cos * 0.03); + next.tail.scale = Vec3::one(); + + next.wing_l.offset = Vec3::new( + -skeleton_attr.wing.0, + skeleton_attr.wing.1, + skeleton_attr.wing.2, + ); + next.wing_l.ori = Quaternion::rotation_y(0.4 - wave_slow * 0.1); + next.wing_l.scale = Vec3::one() * 1.05; + + next.wing_r.offset = Vec3::new( + skeleton_attr.wing.0, + skeleton_attr.wing.1, + skeleton_attr.wing.2, + ); + next.wing_r.ori = Quaternion::rotation_y(-0.4 + wave_slow * 0.1); + next.wing_r.scale = Vec3::one() * 1.05; + + next.leg_l.offset = Vec3::new( + -skeleton_attr.foot.0, + skeleton_attr.foot.1, + skeleton_attr.foot.2, + ) / 11.0; + next.leg_l.ori = Quaternion::rotation_y(0.0); + next.leg_l.scale = Vec3::one() / 11.0; + + next.leg_r.offset = Vec3::new( + skeleton_attr.foot.0, + skeleton_attr.foot.1, + skeleton_attr.foot.2, + ) / 11.0; + next.leg_r.ori = Quaternion::rotation_x(0.0); + next.leg_r.scale = Vec3::one() / 11.0; + next + } +} diff --git a/voxygen/src/anim/src/bird_medium/mod.rs b/voxygen/src/anim/src/bird_medium/mod.rs index d759616c7a..fddd7dfa07 100644 --- a/voxygen/src/anim/src/bird_medium/mod.rs +++ b/voxygen/src/anim/src/bird_medium/mod.rs @@ -1,9 +1,10 @@ +pub mod feed; pub mod fly; pub mod idle; pub mod run; // Reexports -pub use self::{fly::FlyAnimation, idle::IdleAnimation, run::RunAnimation}; +pub use self::{feed::FeedAnimation, fly::FlyAnimation, idle::IdleAnimation, run::RunAnimation}; use super::{Bone, FigureBoneData, Skeleton}; use common::comp::{self}; @@ -77,6 +78,7 @@ pub struct SkeletonAttr { tail: (f32, f32), wing: (f32, f32, f32), foot: (f32, f32, f32), + feed: f32, } impl<'a> std::convert::TryFrom<&'a comp::Body> for SkeletonAttr { @@ -98,6 +100,7 @@ impl Default for SkeletonAttr { tail: (0.0, 0.0), wing: (0.0, 0.0, 0.0), foot: (0.0, 0.0, 0.0), + feed: 0.0, } } } @@ -109,12 +112,12 @@ impl<'a> From<&'a comp::bird_medium::Body> for SkeletonAttr { head: match (body.species, body.body_type) { (Duck, _) => (4.0, 3.0), (Chicken, _) => (4.0, 3.0), - (Goose, _) => (5.0, 5.0), - (Peacock, _) => (4.0, 7.0), + (Goose, _) => (5.0, 2.5), + (Peacock, _) => (1.0, 1.0), (Eagle, _) => (2.5, 5.0), (Snowyowl, _) => (2.5, 5.0), (Parrot, _) => (0.5, 4.5), - (Cockatrice, _) => (3.0, 4.0), + (Cockatrice, _) => (0.0, 4.0), }, chest: match (body.species, body.body_type) { (Duck, _) => (0.0, 5.0), @@ -156,6 +159,16 @@ impl<'a> From<&'a comp::bird_medium::Body> for SkeletonAttr { (Parrot, _) => (1.5, -3.0, 3.0), (Cockatrice, _) => (4.0, -3.5, 12.0), }, + feed: match (body.species, body.body_type) { + (Duck, _) => 1.0, + (Chicken, _) => 1.0, + (Goose, _) => 1.4, + (Peacock, _) => 1.6, + (Eagle, _) => 1.2, + (Snowyowl, _) => 1.0, + (Parrot, _) => 1.2, + (Cockatrice, _) => 1.3, + }, } } } diff --git a/voxygen/src/anim/src/dragon/run.rs b/voxygen/src/anim/src/dragon/run.rs index 255349dd7a..49f42dcf12 100644 --- a/voxygen/src/anim/src/dragon/run.rs +++ b/voxygen/src/anim/src/dragon/run.rs @@ -1,5 +1,5 @@ use super::{super::Animation, DragonSkeleton, SkeletonAttr}; -use std::{f32::consts::PI, ops::Mul}; +use std::f32::consts::PI; use vek::*; pub struct RunAnimation; @@ -14,7 +14,7 @@ impl Animation for RunAnimation { #[cfg_attr(feature = "be-dyn-lib", export_name = "dragon_run")] 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, skeleton_attr: &SkeletonAttr, @@ -34,20 +34,6 @@ impl Animation for RunAnimation { let shortalt = (anim_time as f32 * 16.0 * lab as f32 + PI * 0.5).sin(); - let footvert = (anim_time as f32 * 16.0 * lab as f32 + PI * 0.0).sin(); - let footvertt = (anim_time as f32 * 16.0 * lab as f32 + PI * 0.4).sin(); - let footvertalt = (anim_time as f32 * 16.0 * lab as f32 + PI * 1.2).sin(); - let footverttalt = (anim_time as f32 * 16.0 * lab as f32 + PI * 1.6).sin(); - - let footvertf = (anim_time as f32 * 16.0 * lab as f32 + PI * 0.3).sin(); - let footverttf = (anim_time as f32 * 16.0 * lab as f32 + PI * 0.7).sin(); - let footvertaltf = (anim_time as f32 * 16.0 * lab as f32 + PI * 1.5).sin(); - let footverttaltf = (anim_time as f32 * 16.0 * lab as f32 + PI * 1.9).sin(); - - let footvertfslow = (anim_time as f32 * 16.0 * lab as f32 + PI * 0.6).sin(); - let footverttfslow = (anim_time as f32 * 16.0 * lab as f32 + PI * 1.0).sin(); - let footvertaltfslow = (anim_time as f32 * 16.0 * lab as f32 + PI * 1.8).sin(); - let footverttaltfslow = (anim_time as f32 * 16.0 * lab as f32 + PI * 2.2).sin(); // let ori: Vec2 = Vec2::from(orientation); let last_ori = Vec2::from(last_ori); @@ -79,9 +65,6 @@ impl Animation for RunAnimation { let horilboffset = (anim_time as f32 * lab as f32 + PI * 1.4).sin(); let horirb = (anim_time as f32 * lab as f32 + PI * 0.4).sin(); - let vertchest = (anim_time as f32 * lab as f32 + PI * 0.3).sin().max(0.2); - let horichest = (anim_time as f32 * lab as f32 + PI * 0.8).sin(); - let center = (anim_time as f32 * lab as f32 + PI / 2.0).sin(); let centeroffset = (anim_time as f32 * lab as f32 + PI * 1.5).sin(); diff --git a/voxygen/src/anim/src/quadruped_small/mod.rs b/voxygen/src/anim/src/quadruped_small/mod.rs index dc860029ec..0c19fc6ed2 100644 --- a/voxygen/src/anim/src/quadruped_small/mod.rs +++ b/voxygen/src/anim/src/quadruped_small/mod.rs @@ -312,7 +312,7 @@ impl<'a> From<&'a comp::quadruped_small::Body> for SkeletonAttr { (Hyena, _) => (1.0), (Rabbit, _) => (1.2), (Truffler, _) => (0.6), - (Frog, _) => (1.2), + (Frog, _) => (0.7), }, } } diff --git a/voxygen/src/scene/figure/mod.rs b/voxygen/src/scene/figure/mod.rs index c937e7d2e0..d0b962808e 100644 --- a/voxygen/src/scene/figure/mod.rs +++ b/voxygen/src/scene/figure/mod.rs @@ -1231,12 +1231,29 @@ impl FigureMgr { &mut state_animation_rate, skeleton_attr, ), - + _ => anim::bird_medium::IdleAnimation::update_skeleton( + &BirdMediumSkeleton::new(), + time, + state.state_time, + &mut state_animation_rate, + skeleton_attr, + ), + }; + let target_bones = match &character { + CharacterState::Sit { .. } => { + anim::bird_medium::FeedAnimation::update_skeleton( + &target_base, + time, + state.state_time, + &mut state_animation_rate, + skeleton_attr, + ) + }, // TODO! - _ => state.skeleton_mut().clone(), + _ => target_base, }; - state.skeleton.interpolate(&target_base, dt); + state.skeleton.interpolate(&target_bones, dt); state.update( renderer, pos.0,