From db64972e428decc3f6d1e36fb96c634c7089c396 Mon Sep 17 00:00:00 2001 From: jshipsey <jshipsey18@gmail.com> Date: Fri, 26 Jun 2020 00:57:59 -0400 Subject: [PATCH] starting on trot, removing some warnings --- .../quadruped_medium_lateral_manifest.ron | 32 +-- voxygen/src/anim/src/quadruped_low/mod.rs | 11 - voxygen/src/anim/src/quadruped_low/run.rs | 32 +-- voxygen/src/anim/src/quadruped_medium/mod.rs | 19 +- voxygen/src/anim/src/quadruped_medium/run.rs | 224 ++++++++++++------ 5 files changed, 171 insertions(+), 147 deletions(-) diff --git a/assets/voxygen/voxel/quadruped_medium_lateral_manifest.ron b/assets/voxygen/voxel/quadruped_medium_lateral_manifest.ron index 7e04615de4..70193a70e3 100644 --- a/assets/voxygen/voxel/quadruped_medium_lateral_manifest.ron +++ b/assets/voxygen/voxel/quadruped_medium_lateral_manifest.ron @@ -17,19 +17,19 @@ lateral: ("npc.grolgar.male.leg_br"), ), foot_fl: ( - offset: (-2.5, -6.0, -3.0), + offset: (-2.5, -3.0, -6.0),//y pivot should be -3/4 of the y dimension of the model lateral: ("npc.grolgar.male.foot_fl"), ), foot_fr: ( - offset: (-2.5, -6.0, -3.0), + offset: (-2.5, -3.0, -6.0),//y pivot should be -3/4 of the y dimension of the model lateral: ("npc.grolgar.male.foot_fr"), ), foot_bl: ( - offset: (-2.5, -3.5, -2.0), + offset: (-2.5, -2.0, -4.0),//y pivot should be -3/4 of the y dimension of the model lateral: ("npc.grolgar.male.foot_bl"), ), foot_br: ( - offset: (-2.5, -3.5, -2.0), + offset: (-2.5, -2.0, -4.0),//y pivot should be -3/4 of the y dimension of the model lateral: ("npc.grolgar.male.foot_br"), ), ), @@ -51,19 +51,19 @@ lateral: ("npc.grolgar.female.leg_br"), ), foot_fl: ( - offset: (-2.5, -6.0, -3.0), + offset: (-2.5, -3.0, -6.0), lateral: ("npc.grolgar.female.foot_fl"), ), foot_fr: ( - offset: (-2.5, -6.0, -3.0), + offset: (-2.5, -3.0, -6.0), lateral: ("npc.grolgar.female.foot_fr"), ), foot_bl: ( - offset: (-2.5, -3.5, -2.0), + offset: (-2.5, -2.0, -4.0), lateral: ("npc.grolgar.female.foot_bl"), ), foot_br: ( - offset: (-2.5, -3.5, -2.0), + offset: (-2.5, -2.0, -4.0), lateral: ("npc.grolgar.female.foot_br"), ), ), @@ -221,19 +221,19 @@ lateral: ("npc.lion.male.leg_br"), ), foot_fl: ( - offset: (-2.5, -3.5, -2.5), + offset: (-2.5, -2.0, -2.5), lateral: ("npc.lion.male.foot_fl"), ), foot_fr: ( - offset: (-2.5, -3.5, -2.5), + offset: (-2.5, -2.0, -2.5), lateral: ("npc.lion.male.foot_fr"), ), foot_bl: ( - offset: (-2.5, -3.5, -6.0), + offset: (-2.5, -2.0, -6.0), lateral: ("npc.lion.male.foot_bl"), ), foot_br: ( - offset: (-2.5, -3.5, -6.0), + offset: (-2.5, -2.0, -6.0), lateral: ("npc.lion.male.foot_br"), ), ), @@ -255,19 +255,19 @@ lateral: ("npc.lion.female.leg_br"), ), foot_fl: ( - offset: (-2.5, -3.5, -2.5), + offset: (-2.5, -2.0, -2.5), lateral: ("npc.lion.female.foot_fl"), ), foot_fr: ( - offset: (-2.5, -3.5, -2.5), + offset: (-2.5, -2.0, -2.5), lateral: ("npc.lion.female.foot_fr"), ), foot_bl: ( - offset: (-2.5, -3.5, -6.0), + offset: (-2.5, -2.0, -6.0), lateral: ("npc.lion.female.foot_bl"), ), foot_br: ( - offset: (-2.5, -3.5, -6.0), + offset: (-2.5, -2.0, -6.0), lateral: ("npc.lion.female.foot_br"), ), ), diff --git a/voxygen/src/anim/src/quadruped_low/mod.rs b/voxygen/src/anim/src/quadruped_low/mod.rs index 777879b092..27d7e7cd50 100644 --- a/voxygen/src/anim/src/quadruped_low/mod.rs +++ b/voxygen/src/anim/src/quadruped_low/mod.rs @@ -95,7 +95,6 @@ pub struct SkeletonAttr { tail_rear: (f32, f32), feet_f: (f32, f32, f32), feet_b: (f32, f32, f32), - height: f32, } impl<'a> std::convert::TryFrom<&'a comp::Body> for SkeletonAttr { @@ -120,7 +119,6 @@ impl Default for SkeletonAttr { tail_rear: (0.0, 0.0), feet_f: (0.0, 0.0, 0.0), feet_b: (0.0, 0.0, 0.0), - height: (0.0), } } } @@ -201,15 +199,6 @@ impl<'a> From<&'a comp::quadruped_low::Body> for SkeletonAttr { (Tortoise, _) => (8.0, -8.5, -3.0), (Rocksnapper, _) => (12.0, -12.0, -7.5), }, - height: match (body.species, body.body_type) { - (Crocodile, _) => (1.0), - (Alligator, _) => (1.0), - (Salamander, _) => (1.0), - (Monitor, _) => (1.0), - (Asp, _) => (1.0), - (Tortoise, _) => (1.0), - (Rocksnapper, _) => (1.0), - }, } } } diff --git a/voxygen/src/anim/src/quadruped_low/run.rs b/voxygen/src/anim/src/quadruped_low/run.rs index f96e6ad83a..992f8c0e15 100644 --- a/voxygen/src/anim/src/quadruped_low/run.rs +++ b/voxygen/src/anim/src/quadruped_low/run.rs @@ -14,7 +14,7 @@ impl Animation for RunAnimation { #[cfg_attr(feature = "be-dyn-lib", export_name = "quadruped_low_run")] fn update_skeleton_inner( skeleton: &Self::Skeleton, - (_velocity, global_time): Self::Dependency, + (_velocity, _global_time): Self::Dependency, anim_time: f64, _rate: &mut f32, skeleton_attr: &SkeletonAttr, @@ -23,21 +23,7 @@ impl Animation for RunAnimation { let lab = 0.5; - let wave_ultra_slow_cos = (anim_time as f32 * 3.0 + PI).cos(); - let wave_slow = (anim_time as f32 * 4.5).sin(); - let vertlf = (anim_time as f32 * lab as f32 + PI * 1.8).sin().max(0.15); - let vertrfoffset = (anim_time as f32 * lab as f32 + PI * 0.80).sin().max(0.15); - let vertlboffset = (anim_time as f32 * lab as f32).sin().max(0.15); - let vertrb = (anim_time as f32 * lab as f32 + PI).sin().max(0.15); - - let horilf = (anim_time as f32 * lab as f32 + PI * 1.2).sin(); - let horirfoffset = (anim_time as f32 * lab as f32 + PI * 0.20).sin(); - 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(); @@ -85,7 +71,7 @@ impl Animation for RunAnimation { .powf(2.0 as f32))) .sqrt()) * ((anim_time as f32 * 16.0 * lab as f32 + PI * 0.4).sin()); -/// +// let foothorilb = (((5.0) / (1.0 + (4.0) @@ -125,20 +111,6 @@ impl Animation for RunAnimation { - - let dragon_look = Vec2::new( - ((global_time + anim_time) as f32 / 4.0) - .floor() - .mul(7331.0) - .sin() - * 0.25, - ((global_time + anim_time) as f32 / 4.0) - .floor() - .mul(1337.0) - .sin() - * 0.125, - ); - next.head_upper.offset = Vec3::new(0.0, skeleton_attr.head_upper.0, skeleton_attr.head_upper.1); next.head_upper.ori = diff --git a/voxygen/src/anim/src/quadruped_medium/mod.rs b/voxygen/src/anim/src/quadruped_medium/mod.rs index 8b771dfacf..a4cc6f0652 100644 --- a/voxygen/src/anim/src/quadruped_medium/mod.rs +++ b/voxygen/src/anim/src/quadruped_medium/mod.rs @@ -106,7 +106,6 @@ pub struct SkeletonAttr { leg_b: (f32, f32, f32), feet_f: (f32, f32, f32), feet_b: (f32, f32, f32), - height: f32, } impl<'a> std::convert::TryFrom<&'a comp::Body> for SkeletonAttr { @@ -134,7 +133,6 @@ impl Default for SkeletonAttr { leg_b: (0.0, 0.0, 0.0), feet_f: (0.0, 0.0, 0.0), feet_b: (0.0, 0.0, 0.0), - height: (0.0), } } } @@ -232,7 +230,7 @@ impl<'a> From<&'a comp::quadruped_medium::Body> for SkeletonAttr { (Mouflon, _) => (3.5, -5.5, -5.0), }, leg_b: match (body.species, body.body_type) { - (Grolgar, _) => (6.0, -0.5, -5.5), + (Grolgar, _) => (6.0, -0.5, -3.5), (Saber, _) => (6.0, -1.0, -4.0), (Tuskram, _) => (5.0, 0.5, -3.5), (Lion, _) => (6.0, 0.0, -2.0), @@ -243,7 +241,7 @@ impl<'a> From<&'a comp::quadruped_medium::Body> for SkeletonAttr { (Mouflon, _) => (3.5, -2.0, -4.5), }, feet_f: match (body.species, body.body_type) { - (Grolgar, _) => (0.0, 1.0, -6.0), + (Grolgar, _) => (0.0, -2.0, -4.0), (Saber, _) => (1.0, 3.0, -1.0), (Tuskram, _) => (0.5, 2.0, -5.0), (Lion, _) => (0.0, 2.0, -4.5), @@ -258,23 +256,12 @@ impl<'a> From<&'a comp::quadruped_medium::Body> for SkeletonAttr { (Saber, _) => (1.0, 0.0, 0.0), (Tuskram, _) => (0.5, 0.0, -4.0), (Lion, _) => (0.5, 0.5, -4.0), - (Tarasque, _) => (1.5, -2.5, -2.5), + (Tarasque, _) => (1.5, -1.0, -2.5), (Tiger, _) => (1.0, 0.5, -4.0), (Wolf, _) => (0.0, -0.5, -2.5), (Frostfang, _) => (0.0, -0.5, -3.5), (Mouflon, _) => (-1.0, -2.5, -2.5), }, - height: match (body.species, body.body_type) { - (Grolgar, _) => (1.2), - (Saber, _) => (1.0), - (Tuskram, _) => (1.0), - (Lion, _) => (1.4), - (Tarasque, _) => (1.1), - (Tiger, _) => (1.0), - (Wolf, _) => (1.0), - (Frostfang, _) => (1.0), - (Mouflon, _) => (1.0), - }, } } } diff --git a/voxygen/src/anim/src/quadruped_medium/run.rs b/voxygen/src/anim/src/quadruped_medium/run.rs index a0844bc2d6..c6d5676668 100644 --- a/voxygen/src/anim/src/quadruped_medium/run.rs +++ b/voxygen/src/anim/src/quadruped_medium/run.rs @@ -14,37 +14,38 @@ impl Animation for RunAnimation { #[cfg_attr(feature = "be-dyn-lib", export_name = "quadruped_medium_run")] fn update_skeleton_inner( skeleton: &Self::Skeleton, - (_velocity, global_time): Self::Dependency, + (velocity, _global_time): Self::Dependency, anim_time: f64, - _rate: &mut f32, + rate: &mut f32, skeleton_attr: &SkeletonAttr, ) -> Self::Skeleton { let mut next = (*skeleton).clone(); - - let lab = 0.1; + let speed = Vec2::<f32>::from(velocity).magnitude(); + *rate = 1.0; + let lab = 0.6; - let short = (((5.0) - / (3.6 - + 1.4 * ((anim_time as f32 *16.0* lab as f32+ PI * 1.0).sin()).powf(2.0 as f32))) + let short = (((1.0) + / (0.72 + + 0.28 * ((anim_time as f32 *16.0* lab as f32+ PI * 1.0).sin()).powf(2.0 as f32))) .sqrt()) * ((anim_time as f32 *16.0* lab as f32+ PI * 1.0).sin()); - let foothoril = (((5.0) - / (1.0 - + (4.0) + let foothoril = (((1.0) + / (0.2 + + (0.8) * ((anim_time as f32 * 16.0 * lab as f32 + PI * 1.45).sin()) .powf(2.0 as f32))) .sqrt()) * ((anim_time as f32 * 16.0 * lab as f32 + PI * 1.45).sin()); - let foothorir = (((5.0) - / (1.0 - + (4.0) + let foothorir = (((1.0) + / (0.2 + + (0.8) * ((anim_time as f32 * 16.0 * lab as f32 + PI *0.45).sin()) .powf(2.0 as f32))) .sqrt()) @@ -52,22 +53,22 @@ impl Animation for RunAnimation { let footvertl = (anim_time as f32 * 16.0 * lab as f32+PI*0.0).sin(); let footvertr = (anim_time as f32 * 16.0 * lab as f32 + PI).sin(); - let footrotl = (((5.0) - / (2.5 - + (2.5) + let footrotl = (((1.0) + / (0.5 + + (0.5) * ((anim_time as f32 * 16.0 * lab as f32 + PI * 1.4).sin()) .powf(2.0 as f32))) .sqrt()) * ((anim_time as f32 * 16.0 * lab as f32 + PI * 1.4).sin()); - let footrotr = (((5.0) - / (2.5 - + (2.5) + let footrotr = (((1.0) + / (0.5 + + (0.5) * ((anim_time as f32 * 16.0 * lab as f32 + PI * 0.4).sin()) .powf(2.0 as f32))) .sqrt()) * ((anim_time as f32 * 16.0 * lab as f32 + PI * 0.4).sin()); -/// +// let foothorilb = (((5.0) / (1.0 + (4.0) @@ -75,9 +76,9 @@ impl Animation for RunAnimation { .powf(2.0 as f32))) .sqrt()) * ((anim_time as f32 * 16.0 * lab as f32 + PI * 1.05).sin()); - let foothorirb = (((5.0) - / (1.0 - + (4.0) + let foothorirb = (((1.0) + / (0.2 + + (0.8) * ((anim_time as f32 * 16.0 * lab as f32 + PI *0.05).sin()) .powf(2.0 as f32))) .sqrt()) @@ -85,17 +86,17 @@ impl Animation for RunAnimation { let footvertlb = (anim_time as f32 * 16.0 * lab as f32+PI*(-0.4)).sin(); let footvertrb = (anim_time as f32 * 16.0 * lab as f32 + PI*0.6).sin(); - let footrotlb = (((5.0) - / (2.5 - + (2.5) + let footrotlb = (((1.0) + / (0.5 + + (0.5) * ((anim_time as f32 * 16.0 * lab as f32 + PI * 1.0).sin()) .powf(2.0 as f32))) .sqrt()) * ((anim_time as f32 * 16.0 * lab as f32 + PI * 1.0).sin()); - let footrotrb = (((5.0) - / (2.5 - + (2.5) + let footrotrb = (((1.0) + / (0.5 + + (0.5) * ((anim_time as f32 * 16.0 * lab as f32 + PI * 0.0).sin()) .powf(2.0 as f32))) .sqrt()) @@ -116,60 +117,131 @@ impl Animation for RunAnimation { - - - let vertlf = (anim_time as f32 * lab as f32 + PI * 1.8).sin().max(0.15); - let vertrfoffset = (anim_time as f32 * lab as f32 + PI * 0.80).sin().max(0.15); - let vertlboffset = (anim_time as f32 * lab as f32).sin().max(0.15); - let vertrb = (anim_time as f32 * lab as f32 + PI).sin().max(0.15); - - let horilf = (anim_time as f32 * lab as f32 + PI * 1.2).sin(); - let horirfoffset = (anim_time as f32 * lab as f32 + PI * 0.20).sin(); - 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 verthead = (anim_time as f32 * lab as f32 + PI * 0.3).sin(); - - let wolf_look = Vec2::new( - ((global_time + anim_time) as f32 / 4.0) - .floor() - .mul(7331.0) - .sin() - * 0.25, - ((global_time + anim_time) as f32 / 4.0) - .floor() - .mul(1337.0) - .sin() - * 0.125, - ); - - let wave_ultra_slow = (anim_time as f32 * 1.0 + PI).sin(); - let wave_ultra_slow_cos = (anim_time as f32 * 1.0 + PI).cos(); - let wave_slow = (anim_time as f32 * 3.5 + PI).sin(); - let wave_slow_cos = (anim_time as f32 * 3.5 + PI).cos(); - - let look = Vec2::new( - ((global_time + anim_time) as f32 / 8.0) - .floor() - .mul(7331.0) - .sin() - * 0.5, - ((global_time + anim_time) as f32 / 8.0) - .floor() - .mul(1337.0) - .sin() - * 0.25, - ); +if speed < 8.0{ next.head_upper.offset = Vec3::new( 0.0, skeleton_attr.head_upper.0, skeleton_attr.head_upper.1, ); next.head_upper.ori = - Quaternion::rotation_x(wolf_look.y) * Quaternion::rotation_z(wolf_look.x); + Quaternion::rotation_x(0.0) * Quaternion::rotation_z(0.0); + next.head_upper.scale = Vec3::one(); + + next.head_lower.offset = Vec3::new( + 0.0, + skeleton_attr.head_lower.0 + horichest * 0.8, + skeleton_attr.head_lower.1 + vertchest * -0.8, + ); + next.head_lower.ori = Quaternion::rotation_z(0.0); + next.head_lower.scale = Vec3::one() * 1.02; + + next.jaw.offset = Vec3::new(0.0, skeleton_attr.jaw.0, skeleton_attr.jaw.1); + next.jaw.ori = Quaternion::rotation_x(0.0); + next.jaw.scale = Vec3::one() * 1.02; + + next.tail.offset = Vec3::new(0.0, skeleton_attr.tail.0, skeleton_attr.tail.1); + next.tail.ori = Quaternion::rotation_x(shortalt*0.08); + next.tail.scale = Vec3::one(); + + next.torso_front.offset = Vec3::new( + 0.0, + skeleton_attr.torso_front.0, + skeleton_attr.torso_front.1+shortalt*0.8, + ) / 8.0; + next.torso_front.ori = Quaternion::rotation_x(short * 0.06); + next.torso_front.scale = Vec3::one() / 8.0; + + next.torso_back.offset = Vec3::new( + 0.0, + skeleton_attr.torso_back.0, + skeleton_attr.torso_back.1, + ); + next.torso_back.ori = Quaternion::rotation_x(short * -0.05); + next.torso_back.scale = Vec3::one(); + + next.ears.offset = Vec3::new(0.0, skeleton_attr.ears.0, skeleton_attr.ears.1); + next.ears.ori = Quaternion::rotation_x(0.0); + next.ears.scale = Vec3::one() * 1.02; + + +////left and right functions currently swapped on some bones to change gait + next.leg_fl.offset = Vec3::new( + -skeleton_attr.leg_f.0, + skeleton_attr.leg_f.1 + foothoril * -1.0, + skeleton_attr.leg_f.2 +1.0+ footvertl * -0.06, + ); + next.leg_fl.ori = Quaternion::rotation_x(footrotl * -0.15); + next.leg_fl.scale = Vec3::one()*0.99; + + + next.leg_fr.offset = Vec3::new( + skeleton_attr.leg_f.0, + skeleton_attr.leg_f.1 + foothorir * -1.0, + skeleton_attr.leg_f.2 +1.0+ footvertr * -0.6, + ); + next.leg_fr.ori = Quaternion::rotation_x(footrotr * -0.15); + next.leg_fr.scale = Vec3::one()*0.99; + + next.leg_bl.offset = Vec3::new( + -skeleton_attr.leg_b.0, + skeleton_attr.leg_b.1 + foothorilb * -1.0, + skeleton_attr.leg_b.2 +1.0+ footvertlb * -0.8, + + ); + next.leg_bl.ori = Quaternion::rotation_x(footrotlb * -0.15); + next.leg_bl.scale = Vec3::one() *0.99; + + next.leg_br.offset = Vec3::new( + skeleton_attr.leg_b.0, + skeleton_attr.leg_b.1 + foothorirb * -1.0, + skeleton_attr.leg_b.2 +1.0+ footvertrb * -0.8, + ); + next.leg_br.ori = Quaternion::rotation_x(footrotrb * -0.15); + next.leg_br.scale = Vec3::one() *0.99; + + next.foot_fl.offset = Vec3::new( + -skeleton_attr.feet_f.0, + skeleton_attr.feet_f.1, + skeleton_attr.feet_f.2+ ((footvertl * -1.5).max(-1.0)), + ); + next.foot_fl.ori = Quaternion::rotation_x(footrotl * -0.3); + next.foot_fl.scale = Vec3::one()*0.97; + + next.foot_fr.offset = Vec3::new( + skeleton_attr.feet_f.0, + skeleton_attr.feet_f.1, + skeleton_attr.feet_f.2+ ((footvertr * -1.5).max(-1.0)), + ); + next.foot_fr.ori = Quaternion::rotation_x(footrotr * -0.3); + next.foot_fr.scale = Vec3::one()*0.98; + + next.foot_bl.offset = Vec3::new( + -skeleton_attr.feet_b.0, + skeleton_attr.feet_b.1, + skeleton_attr.feet_b.2+ ((footvertlb * -1.5).max(-1.0)), + ); + next.foot_bl.ori = Quaternion::rotation_x(footrotlb * -0.3); + next.foot_bl.scale = Vec3::one()*0.98; + + next.foot_br.offset = Vec3::new( + skeleton_attr.feet_b.0, + skeleton_attr.feet_b.1, + skeleton_attr.feet_b.2 + ((footvertrb * -1.5).max(-1.0)), + ); + next.foot_br.ori = Quaternion::rotation_x(footrotrb * -0.3); + next.foot_br.scale = Vec3::one()*0.98; +} + else { + next.head_upper.offset = Vec3::new( + 0.0, + skeleton_attr.head_upper.0, + skeleton_attr.head_upper.1, + ); + next.head_upper.ori = + Quaternion::rotation_x(0.0) * Quaternion::rotation_z(0.0); next.head_upper.scale = Vec3::one(); next.head_lower.offset = Vec3::new( @@ -276,6 +348,10 @@ impl Animation for RunAnimation { next.foot_br.ori = Quaternion::rotation_x(footrotrb * -0.7); next.foot_br.scale = Vec3::one()*0.98; + + } next + } + }