refining pace setup. refined species anim variables

This commit is contained in:
jshipsey 2020-08-26 02:47:21 -04:00
parent 47d5c635de
commit 883aa1754b
2 changed files with 76 additions and 63 deletions

View File

@ -229,7 +229,7 @@ impl<'a> From<&'a Body> for SkeletonAttr {
(Lion, _) => (6.5, -6.5, -2.0),
(Tarasque, _) => (7.0, -8.0, -6.0),
(Tiger, _) => (6.0, -5.0, -3.0),
(Wolf, _) => (4.5, -6.5, -1.0),
(Wolf, _) => (4.5, -6.5, -1.5),
(Frostfang, _) => (5.5, -5.5, -2.0),
(Mouflon, _) => (4.0, -5.0, -5.0),
(Catoblepas, _) => (7.0, 2.0, -6.0),
@ -242,7 +242,7 @@ impl<'a> From<&'a Body> for SkeletonAttr {
(Lion, _) => (6.0, -6.0, -2.0),
(Tarasque, _) => (6.0, -6.5, -6.5),
(Tiger, _) => (6.0, -7.5, -3.0),
(Wolf, _) => (5.0, -6.5, -2.5),
(Wolf, _) => (5.0, -6.5, -3.0),
(Frostfang, _) => (3.5, -4.5, -2.0),
(Mouflon, _) => (3.5, -8.0, -4.5),
(Catoblepas, _) => (6.0, -2.5, -2.5),
@ -310,7 +310,7 @@ impl<'a> From<&'a Body> for SkeletonAttr {
(Wolf, _) => (1.0),
(Frostfang, _) => (1.2),
(Mouflon, _) => (1.1),
(Catoblepas, _) => (0.9),
(Catoblepas, _) => (0.0),
(Bonerattler, _) => (0.8),
},
tempo: match (body.species, body.body_type) {

View File

@ -2,7 +2,7 @@ use super::{
super::{vek::*, Animation},
QuadrupedMediumSkeleton, SkeletonAttr,
};
use std::f32::consts::PI;
use std::{f32::consts::PI, ops::Mul};
pub struct RunAnimation;
@ -16,7 +16,7 @@ impl Animation for RunAnimation {
#[cfg_attr(feature = "be-dyn-lib", export_name = "quadruped_medium_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,
@ -24,30 +24,39 @@ impl Animation for RunAnimation {
let mut next = (*skeleton).clone();
let speed = Vec2::<f32>::from(velocity).magnitude();
*rate = 1.0;
//let increasefreqtest = (((1.0/speed)*3.0).round()).min(5.0);
let lab = 0.6; //6
let amplitude = (speed / 24.0).max(0.25);
let amplitude2 = (speed * 1.4 / 24.0).min(0.8);
let amplitude3 = (speed / 24.0).min(0.7);
let amplitude2 = (speed * 1.4 / 24.0).max(0.6);
let amplitude3 = (speed / 24.0).max(0.35);
let speedmult = if speed > 0.0 {
1.2 * (1.0 * skeleton_attr.tempo)
} else {
0.9 * (1.0 * skeleton_attr.tempo)
};
//println!("{:?}", avg_speed);
let canceler = speed / 24.0;
let short = (((1.0)
/ (0.72
+ 0.28
* ((anim_time as f32 * 16.0 * lab as f32 * speedmult + PI * -0.15).sin())
* ((anim_time as f32 * (16.0) * lab as f32 * speedmult + PI * -0.15).sin())
.powf(2.0 as f32)))
.sqrt())
* ((anim_time as f32 * 16.0 * lab as f32 * speedmult + PI * -0.15).sin());
* ((anim_time as f32 * (16.0) * lab as f32 * speedmult + PI * -0.15).sin());
//
let shortalt = (anim_time as f32 * 16.0 * lab as f32 * speedmult + PI * 0.35).sin();
let noisify1 = (anim_time as f32 * 13.0 * lab as f32 * speedmult).sin() * 0.1;
let noisify2 = (anim_time as f32 * 17.0 * lab as f32 * speedmult).sin() * 0.1;
let shortalt = (anim_time as f32 * (16.0) * lab as f32 * speedmult + PI * 0.35).sin();
let look = Vec2::new(
((global_time + anim_time) as f32 / 2.0)
.floor()
.mul(7331.0)
.sin()
* 0.5,
((global_time + anim_time) as f32 / 2.0)
.floor()
.mul(1337.0)
.sin()
* 0.25,
);
let speedadjust = if speed < 5.0 { 0.0 } else { speed };
let shift1 = speedadjust / 24.0 * 0.0;
@ -56,39 +65,32 @@ impl Animation for RunAnimation {
let shift4 = speedadjust / 24.0 * PI / 4.0;
//FL
let foot1a =
(anim_time as f32 * 16.0 * lab as f32 * speedmult + noisify1 + PI * (0.0 + shift1))
.sin(); //1.5
let foot1b =
(anim_time as f32 * 16.0 * lab as f32 * speedmult + noisify1 + PI * (0.4 + shift1))
.sin(); //1.9
let foot1a = (anim_time as f32 * (16.0) * lab as f32 * speedmult
+ PI * (0.0 + canceler * 0.08 + shift1))
.sin(); //1.5
let foot1b = (anim_time as f32 * (16.0) * lab as f32 * speedmult
+ PI * (0.4 + canceler * 0.08 + shift1))
.sin(); //1.9
//FR
let foot2a = (anim_time as f32 * 16.0 * lab as f32 * speedmult
+ noisify2
+ PI * (PI / 4.0 + shift2))
.sin(); //1.2
let foot2b = (anim_time as f32 * 16.0 * lab as f32 * speedmult
+ noisify2
let foot2a =
(anim_time as f32 * (16.0) * lab as f32 * speedmult + PI * (PI / 4.0 + shift2)).sin(); //1.2
let foot2b = (anim_time as f32 * (16.0) * lab as f32 * speedmult
+ PI * (0.4 + PI / 4.0 + shift2))
.sin(); //1.6
//BL
let foot3a =
(anim_time as f32 * 16.0 * lab as f32 * speedmult + noisify1 + PI * (0.0 + shift3))
.sin(); //0.0
(anim_time as f32 * (16.0) * lab as f32 * speedmult + PI * (0.0 + shift3)).sin(); //0.0
let foot3b =
(anim_time as f32 * 16.0 * lab as f32 * speedmult + noisify1 + PI * (0.4 + shift3))
.sin(); //0.4
(anim_time as f32 * (16.0) * lab as f32 * speedmult + PI * (0.4 + shift3)).sin(); //0.4
//BR
let foot4a = (anim_time as f32 * 16.0 * lab as f32 * speedmult
+ noisify2
+ PI * (0.0 + PI / 4.0 + shift4))
let foot4a = (anim_time as f32 * (16.0) * lab as f32 * speedmult
+ PI * (0.0 + canceler * 0.15 + PI / 4.0 + shift4))
.sin(); //0.3
let foot4b = (anim_time as f32 * 16.0 * lab as f32 * speedmult
+ noisify2
+ PI * (0.4 + PI / 4.0 + shift4))
let foot4b = (anim_time as f32 * (16.0) * lab as f32 * speedmult
+ PI * (0.4 + canceler * 0.15 + PI / 4.0 + shift4))
.sin(); //0.7
//
@ -110,9 +112,10 @@ impl Animation for RunAnimation {
//Gallop
next.head_upper.position =
Vec3::new(0.0, skeleton_attr.head_upper.0, skeleton_attr.head_upper.1);
next.head_upper.orientation = Quaternion::rotation_x(amplitude * short * -0.03 - 0.1)
* Quaternion::rotation_z(tilt * -1.2)
* Quaternion::rotation_y(tilt * 0.8);
next.head_upper.orientation =
Quaternion::rotation_x(look.y * 0.1 / canceler + amplitude * short * -0.03 - 0.1)
* Quaternion::rotation_z(look.x * 0.1 / canceler + tilt * -1.2)
* Quaternion::rotation_y(tilt * 0.8);
next.head_upper.scale = Vec3::one();
next.head_lower.position =
@ -134,12 +137,16 @@ impl Animation for RunAnimation {
next.torso_front.position = Vec3::new(
0.0,
skeleton_attr.torso_front.0,
skeleton_attr.torso_front.1 + canceler * shortalt * 2.5 + x_tilt * 10.0,
skeleton_attr.torso_front.1
+ canceler * 1.0
+ canceler * shortalt * 2.5
+ x_tilt * 10.0,
) * skeleton_attr.scaler
/ 11.0;
next.torso_front.orientation = Quaternion::rotation_x(amplitude * short * -0.13 + x_tilt)
* Quaternion::rotation_y(tilt * 0.8)
* Quaternion::rotation_z(tilt * -1.5);
next.torso_front.orientation =
Quaternion::rotation_x((amplitude * (short * -0.13).max(-0.2)) + x_tilt)
* Quaternion::rotation_y(tilt * 0.8)
* Quaternion::rotation_z(tilt * -1.5);
next.torso_front.scale = Vec3::one() * skeleton_attr.scaler / 11.0;
next.torso_back.position = Vec3::new(
@ -161,7 +168,7 @@ impl Animation for RunAnimation {
skeleton_attr.leg_f.1 + amplitude3 * foot1a * -1.3,
skeleton_attr.leg_f.2 + canceler + amplitude3 * foot1b * -1.9,
);
next.leg_fl.orientation = Quaternion::rotation_x(amplitude3 * foot1b * -0.65)
next.leg_fl.orientation = Quaternion::rotation_x(amplitude3 * foot1b * -0.55)
* Quaternion::rotation_z(tilt * -0.5)
* Quaternion::rotation_y(tilt * 1.5);
next.leg_fl.scale = Vec3::one() * 1.02;
@ -171,39 +178,43 @@ impl Animation for RunAnimation {
skeleton_attr.leg_f.1 + amplitude3 * foot2a * -1.3,
skeleton_attr.leg_f.2 + canceler + amplitude3 * foot2b * -1.9,
);
next.leg_fr.orientation = Quaternion::rotation_x(amplitude3 * foot2b * -0.65)
next.leg_fr.orientation = Quaternion::rotation_x(amplitude3 * foot2b * -0.55)
* Quaternion::rotation_z(tilt * -0.5)
* Quaternion::rotation_y(tilt * 1.5);
next.leg_fr.scale = Vec3::one() * 1.02;
next.leg_bl.position = Vec3::new(
-skeleton_attr.leg_b.0,
skeleton_attr.leg_b.1 + amplitude3 * foot3a * -1.7,
skeleton_attr.leg_b.2 + canceler + amplitude3 * foot3b * -1.9,
skeleton_attr.leg_b.1 + amplitude3 * foot3a * -1.9,
skeleton_attr.leg_b.2 + canceler + amplitude3 * ((foot3b * -2.6).min(1.0)),
);
next.leg_bl.orientation = Quaternion::rotation_x(amplitude3 * foot3b * -0.45 - 0.2)
* Quaternion::rotation_y(tilt * 1.5)
* Quaternion::rotation_z(tilt * -1.5);
next.leg_bl.orientation =
Quaternion::rotation_x(amplitude3 * foot3b * -0.5 - 0.2 * canceler)
* Quaternion::rotation_y(tilt * 1.5)
* Quaternion::rotation_z(tilt * -1.5);
next.leg_bl.scale = Vec3::one() * 1.02;
next.leg_br.position = Vec3::new(
skeleton_attr.leg_b.0,
skeleton_attr.leg_b.1 + amplitude3 * foot4a * -1.7,
skeleton_attr.leg_b.2 + canceler + amplitude3 * foot4b * -1.9,
skeleton_attr.leg_b.1 + amplitude3 * foot4a * -1.9,
skeleton_attr.leg_b.2 + canceler + amplitude3 * ((foot4b * -2.6).min(1.0)),
);
next.leg_br.orientation = Quaternion::rotation_x(amplitude3 * foot4b * -0.45 - 0.2)
* Quaternion::rotation_y(tilt * 1.5)
* Quaternion::rotation_z(tilt * -1.5);
next.leg_br.orientation =
Quaternion::rotation_x(amplitude3 * foot4b * -0.5 - 0.2 * canceler)
* Quaternion::rotation_y(tilt * 1.5)
* Quaternion::rotation_z(tilt * -1.5);
next.leg_br.scale = Vec3::one() * 1.02;
next.foot_fl.position = Vec3::new(
-skeleton_attr.feet_f.0,
skeleton_attr.feet_f.1,
skeleton_attr.feet_f.2
+ ((amplitude2 * foot1a * 2.7 * skeleton_attr.maximize).max(0.0)),
+ ((amplitude2 * foot1a * 2.7
+ amplitude2 * foot1a * skeleton_attr.maximize * canceler)
.max(0.0)),
);
next.foot_fl.orientation = Quaternion::rotation_x(
(1.0 - skeleton_attr.dampen) * -1.0 + amplitude2 * foot1b * -0.9,
((1.0 - skeleton_attr.dampen) * -1.0) * canceler + amplitude2 * foot1b * -0.7,
) * Quaternion::rotation_y(tilt * -1.0);
next.foot_fl.scale = Vec3::one() * 0.96;
@ -211,30 +222,32 @@ impl Animation for RunAnimation {
skeleton_attr.feet_f.0,
skeleton_attr.feet_f.1,
skeleton_attr.feet_f.2
+ ((amplitude2 * foot2a * 2.7 * skeleton_attr.maximize).max(0.0)),
+ ((amplitude2 * foot2a * 2.7
+ amplitude2 * foot2a * skeleton_attr.maximize * canceler)
.max(0.0)),
);
next.foot_fr.orientation = Quaternion::rotation_x(
(1.0 - skeleton_attr.dampen) * -1.0 + amplitude2 * foot2b * -0.9,
((1.0 - skeleton_attr.dampen) * -1.0) * canceler + amplitude2 * foot2b * -0.7,
) * Quaternion::rotation_y(tilt * -1.0);
next.foot_fr.scale = Vec3::one() * 0.96;
next.foot_bl.position = Vec3::new(
-skeleton_attr.feet_b.0,
skeleton_attr.feet_b.1,
skeleton_attr.feet_b.2 + ((amplitude2 * foot3a * 1.8).max(-0.0)),
skeleton_attr.feet_b.2 + ((amplitude2 * foot3a * 2.5).max(-1.0)),
);
next.foot_bl.orientation =
Quaternion::rotation_x(amplitude2 * foot3b * -1.3 - 0.2 * speed / 24.0)
Quaternion::rotation_x(amplitude2 * foot3b * -0.5 - 0.2 * canceler)
* Quaternion::rotation_y(tilt * -1.0);
next.foot_bl.scale = Vec3::one() * 0.96;
next.foot_br.position = Vec3::new(
skeleton_attr.feet_b.0,
skeleton_attr.feet_b.1,
skeleton_attr.feet_b.2 + ((amplitude2 * foot4a * 1.8).max(0.0)),
skeleton_attr.feet_b.2 + ((amplitude2 * foot4a * 2.5).max(-1.0)),
);
next.foot_br.orientation =
Quaternion::rotation_x(amplitude2 * foot4b * -1.3 - 0.2 * speed / 24.0)
Quaternion::rotation_x(amplitude2 * foot4b * -0.5 - 0.2 * canceler)
* Quaternion::rotation_y(tilt * -1.0);
next.foot_br.scale = Vec3::one() * 0.96;
next