simplify quadmed run, integrate dampener variable

This commit is contained in:
jshipsey 2020-07-01 01:26:59 -04:00
parent ce9cd29720
commit 9ef383ff03
8 changed files with 102 additions and 147 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -9,7 +9,7 @@
central: ("npc.grolgar.male.head_lower"),
),
jaw: (
offset: (-2.0, -7.0, -1.5),
offset: (-2.0, 0.0, -1.5),
central: ("npc.grolgar.male.jaw"),
),
torso_front: (
@ -39,7 +39,7 @@
central: ("npc.grolgar.female.head_lower"),
),
jaw: (
offset: (-2.0, -7.0, -1.5),
offset: (-2.0, 0.0, -1.5),
central: ("npc.grolgar.female.jaw"),
),
torso_front: (
@ -61,7 +61,7 @@
),
(Saber, Male): (
upper: (
offset: (-5.5, 11.0, -6.5),
offset: (-5.5, 0.0, -6.5),
central: ("npc.saber.male.head_upper"),
),
lower: (
@ -69,7 +69,7 @@
central: ("npc.saber.male.head_lower"),
),
jaw: (
offset: (-2.5, -7.0, -1.5),
offset: (-2.5, 0.0, -1.5),
central: ("npc.saber.male.jaw"),
),
torso_front: (
@ -91,7 +91,7 @@
),
(Saber, Female): (
upper: (
offset: (-5.5, 11.0, -6.5),
offset: (-5.5, 0.0, -6.5),
central: ("npc.saber.female.head_upper"),
),
lower: (
@ -99,7 +99,7 @@
central: ("npc.saber.female.head_lower"),
),
jaw: (
offset: (-2.5, -7.0, -1.5),
offset: (-2.5, 0.0, -1.5),
central: ("npc.saber.female.jaw"),
),
torso_front: (
@ -121,7 +121,7 @@
),
(Tuskram, Male): (
upper: (
offset: (-10.0, -11.0, -6.5),
offset: (-10.0, -6.0, -6.5),
central: ("npc.tuskram.male.head_upper"),
),
lower: (
@ -129,7 +129,7 @@
central: ("npc.tuskram.male.head_lower"),
),
jaw: (
offset: (-2.0, -3.0, -1.5),
offset: (-2.0, 0.0, -1.5),
central: ("npc.tuskram.male.jaw"),
),
torso_front: (
@ -151,7 +151,7 @@
),
(Tuskram, Female): (
upper: (
offset: (-10.0, -11.0, -6.5),
offset: (-10.0, -6.0, -6.5),
central: ("npc.tuskram.female.head_upper"),
),
lower: (
@ -159,7 +159,7 @@
central: ("npc.tuskram.female.head_lower"),
),
jaw: (
offset: (-2.0, -3.0, -1.5),
offset: (-2.0, 0.0, -1.5),
central: ("npc.tuskram.female.jaw"),
),
torso_front: (
@ -181,7 +181,7 @@
),
(Lion, Male): (
upper: (
offset: (-4.5, -10.0, -4.5),
offset: (-4.5, 0.0, -4.5),
central: ("npc.lion.male.head_upper"),
),
lower: (
@ -189,7 +189,7 @@
central: ("npc.lion.male.head_lower"),
),
jaw: (
offset: (-2.5, -6.0, -1.0),
offset: (-2.5, 0.0, -1.0),
central: ("npc.lion.male.jaw"),
),
torso_front: (
@ -211,7 +211,7 @@
),
(Lion, Female): (
upper: (
offset: (-4.5, -10.0, -4.5),
offset: (-4.5, 0.0, -4.5),
central: ("npc.lion.female.head_upper"),
),
lower: (
@ -219,7 +219,7 @@
central: ("npc.lion.female.head_lower"),
),
jaw: (
offset: (-2.5, -6.0, -1.0),
offset: (-2.5, 0.0, -1.0),
central: ("npc.lion.female.jaw"),
),
torso_front: (
@ -241,7 +241,7 @@
),
(Tarasque, Male): (
upper: (
offset: (-10.0, -9.0, -10.0),
offset: (-10.0, 0.0, -10.0),
central: ("npc.tarasque.male.head_upper"),
),
lower: (
@ -249,7 +249,7 @@
central: ("npc.tarasque.male.head_lower"),
),
jaw: (
offset: (-5.0, -9.0, -0.0),
offset: (-5.0, 0.0, -0.0),
central: ("npc.tarasque.male.jaw"),
),
torso_front: (
@ -271,7 +271,7 @@
),
(Tarasque, Female): (
upper: (
offset: (-10.0, -9.0, -10.0),
offset: (-10.0, 0.0, -10.0),
central: ("npc.tarasque.female.head_upper"),
),
lower: (
@ -279,7 +279,7 @@
central: ("npc.tarasque.female.head_lower"),
),
jaw: (
offset: (-5.0, -9.0, -0.0),
offset: (-5.0, 0.0, -0.0),
central: ("npc.tarasque.female.jaw"),
),
torso_front: (
@ -309,7 +309,7 @@
central: ("npc.tiger.male.head_lower"),
),
jaw: (
offset: (-2.5, -3.0, -1.0),
offset: (-2.5, 0.0, -1.0),
central: ("npc.tiger.male.jaw"),
),
torso_front: (
@ -339,7 +339,7 @@
central: ("npc.tiger.female.head_lower"),
),
jaw: (
offset: (-2.5, -3.0, -1.0),
offset: (-2.5, 0.0, -1.0),
central: ("npc.tiger.female.jaw"),
),
torso_front: (

View File

@ -425,19 +425,19 @@
lateral: ("npc.wolf.male.leg_br"),
),
foot_fl: (
offset: (-1.5, -1.5, -9.0),
offset: (-1.5, -2.5, -10.0),
lateral: ("npc.wolf.male.foot_fl"),
),
foot_fr: (
offset: (-1.5, -1.5, -9.0),
offset: (-1.5, -2.5, -10.0),
lateral: ("npc.wolf.male.foot_fr"),
),
foot_bl: (
offset: (-1.5, -1.5, -9.0),
offset: (-1.5, -2.5, -10.0),
lateral: ("npc.wolf.male.foot_bl"),
),
foot_br: (
offset: (-1.5, -1.5, -9.0),
offset: (-1.5, -2.5, -10.0),
lateral: ("npc.wolf.male.foot_br"),
),
),
@ -459,19 +459,19 @@
lateral: ("npc.wolf.female.leg_br"),
),
foot_fl: (
offset: (-1.5, -1.5, -9.0),
offset: (-1.5, -2.5, -10.0),
lateral: ("npc.wolf.female.foot_fl"),
),
foot_fr: (
offset: (-1.5, -1.5, -9.0),
offset: (-1.5, -2.5, -10.0),
lateral: ("npc.wolf.female.foot_fr"),
),
foot_bl: (
offset: (-1.5, -1.5, -9.0),
offset: (-1.5, -2.5, -10.0),
lateral: ("npc.wolf.female.foot_bl"),
),
foot_br: (
offset: (-1.5, -1.5, -9.0),
offset: (-1.5, -2.5, -10.0),
lateral: ("npc.wolf.female.foot_br"),
),
),

View File

@ -131,6 +131,7 @@ pub struct SkeletonAttr {
feet_f: (f32, f32, f32),
feet_b: (f32, f32, f32),
scaler: f32,
dampen: f32,
}
impl<'a> std::convert::TryFrom<&'a comp::Body> for SkeletonAttr {
@ -159,6 +160,7 @@ impl Default for SkeletonAttr {
feet_f: (0.0, 0.0, 0.0),
feet_b: (0.0, 0.0, 0.0),
scaler: 0.0,
dampen: 0.0,
}
}
}
@ -169,14 +171,14 @@ impl<'a> From<&'a comp::quadruped_medium::Body> for SkeletonAttr {
Self {
head_upper: match (body.species, body.body_type) {
(Grolgar, _) => (-8.0, 1.5),
(Saber, _) => (-10.0, -3.0),
(Tuskram, _) => (2.0, 1.0),
(Lion, _) => (12.5, 2.0),
(Tarasque, _) => (5.5, 3.5),
(Saber, _) => (0.0, -3.0),
(Tuskram, _) => (0.0, 1.0),
(Lion, _) => (2.5, 2.0),
(Tarasque, _) => (-4.0, 3.5),
(Tiger, _) => (2.0, 1.0),
(Wolf, _) => (-0.5, 3.0),
(Frostfang, _) => (1.0, -2.0),
(Mouflon, _) => (-5.5, 6.0),
(Mouflon, _) => (-2.5, 6.0),
},
head_lower: match (body.species, body.body_type) {
(Grolgar, _) => (3.5, -3.0),
@ -190,12 +192,12 @@ impl<'a> From<&'a comp::quadruped_medium::Body> for SkeletonAttr {
(Mouflon, _) => (-1.0, 0.5),
},
jaw: match (body.species, body.body_type) {
(Grolgar, _) => (-2.5, 0.5),
(Saber, _) => (21.0, -2.0),
(Tuskram, _) => (1.5, -4.0),
(Lion, _) => (0.0, -4.5),
(Grolgar, _) => (8.5, 4.5),
(Saber, _) => (3.5, -2.0),
(Tuskram, _) => (5.5, -4.0),
(Lion, _) => (3.5, -4.5),
(Tarasque, _) => (9.0, -10.0),
(Tiger, _) => (7.0, -4.0),
(Tiger, _) => (3.5, -4.0),
(Wolf, _) => (5.0, -3.0),
(Frostfang, _) => (5.0, -3.0),
(Mouflon, _) => (10.5, -4.0),
@ -214,11 +216,11 @@ impl<'a> From<&'a comp::quadruped_medium::Body> for SkeletonAttr {
torso_front: match (body.species, body.body_type) {
(Grolgar, _) => (10.0, 11.0),
(Saber, _) => (14.0, 13.0),
(Tuskram, _) => (10.0, 15.5),
(Tuskram, _) => (10.0, 14.5),
(Lion, _) => (10.0, 13.0),
(Tarasque, _) => (11.5, 18.5),
(Tiger, _) => (10.0, 14.0),
(Wolf, _) => (12.0, 14.0),
(Wolf, _) => (12.0, 13.0),
(Frostfang, _) => (9.0, 11.5),
(Mouflon, _) => (11.0, 13.5),
},
@ -235,10 +237,10 @@ impl<'a> From<&'a comp::quadruped_medium::Body> for SkeletonAttr {
},
ears: match (body.species, body.body_type) {
(Grolgar, _) => (5.0, 8.0),
(Saber, _) => (12.0, 5.5),
(Saber, _) => (3.0, 5.5),
(Tuskram, _) => (5.5, 12.0),
(Lion, _) => (-7.0, 3.5),
(Tarasque, _) => (2.0, -3.0),
(Lion, _) => (2.0, 3.5),
(Tarasque, _) => (11.0, -3.0),
(Tiger, _) => (2.5, 4.0),
(Wolf, _) => (3.0, 2.5),
(Frostfang, _) => (2.0, 3.5),
@ -269,22 +271,22 @@ impl<'a> From<&'a comp::quadruped_medium::Body> for SkeletonAttr {
feet_f: match (body.species, body.body_type) {
(Grolgar, _) => (0.0, -3.0, -3.0),
(Saber, _) => (1.0, 0.0, -1.0),
(Tuskram, _) => (0.5, 0.5, -5.0),
(Tuskram, _) => (0.5, 0.5, -4.0),
(Lion, _) => (0.0, 0.0, -1.5),
(Tarasque, _) => (1.0, 0.0, -3.0),
(Tiger, _) => (0.5, 0.0, -5.0),
(Wolf, _) => (0.5, -1.0, -3.5),
(Wolf, _) => (0.5, 0.0, -2.0),
(Frostfang, _) => (0.5, 1.5, -3.5),
(Mouflon, _) => (-0.5, -0.5, -1.5),
},
feet_b: match (body.species, body.body_type) {
(Grolgar, _) => (0.0, 0.0, -5.0),
(Saber, _) => (1.0, -2.0, 0.0),
(Tuskram, _) => (0.5, 0.0, -4.0),
(Tuskram, _) => (0.5, 0.0, -3.0),
(Lion, _) => (0.5, 0.5, -4.0),
(Tarasque, _) => (1.5, -1.0, -2.5),
(Tiger, _) => (1.0, 0.5, -4.0),
(Wolf, _) => (0.0, -2.0, -3.0),
(Wolf, _) => (0.0, -1.0, -1.5),
(Frostfang, _) => (0.0, -1.5, -3.5),
(Mouflon, _) => (-1.0, -1.5, -2.5),
},
@ -299,6 +301,17 @@ impl<'a> From<&'a comp::quadruped_medium::Body> for SkeletonAttr {
(Frostfang, _) => (1.0),
(Mouflon, _) => (1.0),
},
dampen: match (body.species, body.body_type) {
(Grolgar, _) => (0.5),
(Saber, _) => (0.7),
(Tuskram, _) => (0.9),
(Lion, _) => (0.7),
(Tarasque, _) => (0.7),
(Tiger, _) => (0.6),
(Wolf, _) => (1.0),
(Frostfang, _) => (1.0),
(Mouflon, _) => (1.0),
},
}
}
}

View File

@ -22,7 +22,7 @@ impl Animation for RunAnimation {
let mut next = (*skeleton).clone();
let speed = Vec2::<f32>::from(velocity).magnitude();
*rate = 1.0;
let lab = 0.6;
let lab = 0.6; //6
let speedmult = if speed > 8.0 {
1.2 * (1.0 / skeleton_attr.scaler)
@ -38,71 +38,7 @@ impl Animation for RunAnimation {
.sqrt())
* ((anim_time as f32 * 16.0 * lab as f32 * speedmult + PI * 1.0).sin());
let foothoril = (((1.0)
/ (0.5
+ (0.5)
* ((anim_time as f32 * 16.0 * lab as f32 * speedmult + PI * 1.45).sin())
.powf(2.0 as f32)))
.sqrt())
* ((anim_time as f32 * 16.0 * lab as f32 * speedmult + PI * 1.45).sin());
let foothorir = (((1.0)
/ (0.2
+ (0.8)
* ((anim_time as f32 * 16.0 * lab as f32 * speedmult + PI * 0.45).sin())
.powf(2.0 as f32)))
.sqrt())
* ((anim_time as f32 * 16.0 * lab as f32 * speedmult + PI * 0.45).sin());
let footvertl = (anim_time as f32 * 16.0 * lab as f32 * speedmult + PI * 0.0).sin();
let footvertr = (anim_time as f32 * 16.0 * lab as f32 * speedmult + PI).sin();
let footrotl = (((1.0)
/ (0.5
+ (0.5)
* ((anim_time as f32 * 16.0 * lab as f32 * speedmult + PI * 1.4).sin())
.powf(2.0 as f32)))
.sqrt())
* ((anim_time as f32 * 16.0 * lab as f32 * speedmult + PI * 1.4).sin());
let footrotr = (((1.0)
/ (0.5
+ (0.5)
* ((anim_time as f32 * 16.0 * lab as f32 * speedmult + PI * 1.8).sin())
.powf(2.0 as f32)))
.sqrt())
* ((anim_time as f32 * 16.0 * lab as f32 * speedmult + PI * 1.8).sin());
//
let foothorilb = (((5.0)
/ (1.0
+ (4.0)
* ((anim_time as f32 * 16.0 * lab as f32 * speedmult + PI * 1.05).sin())
.powf(2.0 as f32)))
.sqrt())
* ((anim_time as f32 * 16.0 * lab as f32 * speedmult + PI * 1.05).sin());
let foothorirb = (((1.0)
/ (0.2
+ (0.8)
* ((anim_time as f32 * 16.0 * lab as f32 * speedmult + PI * 0.05).sin())
.powf(2.0 as f32)))
.sqrt())
* ((anim_time as f32 * 16.0 * lab as f32 * speedmult + PI * 0.05).sin());
let footvertlb = (anim_time as f32 * 16.0 * lab as f32 * speedmult + PI * (-0.4)).sin();
let footvertrb = (anim_time as f32 * 16.0 * lab as f32 * speedmult + PI * 0.6).sin();
let footrotlb = (((1.0)
/ (0.5
+ (0.5)
* ((anim_time as f32 * 16.0 * lab as f32 * speedmult + PI * 0.0).sin())
.powf(2.0 as f32)))
.sqrt())
* ((anim_time as f32 * 16.0 * lab as f32 * speedmult + PI * 0.0).sin());
let footrotrb = (((1.0)
/ (0.5
+ (0.5)
* ((anim_time as f32 * 16.0 * lab as f32 * speedmult + PI * 0.4).sin())
.powf(2.0 as f32)))
.sqrt())
* ((anim_time as f32 * 16.0 * lab as f32 * speedmult + PI * 0.4).sin());
let shortalt = (anim_time as f32 * 16.0 * lab as f32 * speedmult + PI * 0.5).sin();
@ -127,7 +63,7 @@ impl Animation for RunAnimation {
} * 1.3;
//let tilt = 0.0;
if speed < 8.0 {
//Trot
/* //Trot
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(tilt * -1.2);
@ -236,7 +172,7 @@ impl Animation for RunAnimation {
skeleton_attr.feet_b.2 + 1.0 + ((footvertrb * -1.0).max(-1.0)),
);
next.foot_br.ori = Quaternion::rotation_x(footrotrb * -0.3);
next.foot_br.scale = Vec3::one() * 0.98;
next.foot_br.scale = Vec3::one() * 0.98;*/
} else {
//Gallop
next.head_upper.offset =
@ -272,8 +208,11 @@ impl Animation for RunAnimation {
Quaternion::rotation_x(short * 0.13) * Quaternion::rotation_z(tilt * -1.5);
next.torso_front.scale = Vec3::one() * skeleton_attr.scaler / 11.0;
next.torso_back.offset =
Vec3::new(0.0, skeleton_attr.torso_back.0, skeleton_attr.torso_back.1 + shortalt * 0.2 - 0.2);
next.torso_back.offset = Vec3::new(
0.0,
skeleton_attr.torso_back.0,
skeleton_attr.torso_back.1 + shortalt * 0.2 - 0.2,
);
next.torso_back.ori =
Quaternion::rotation_x(short * 0.1) * Quaternion::rotation_z(tilt * 1.8);
next.torso_back.scale = Vec3::one();
@ -281,74 +220,77 @@ impl Animation for RunAnimation {
next.ears.offset = Vec3::new(0.0, skeleton_attr.ears.0, skeleton_attr.ears.1);
next.ears.ori = Quaternion::rotation_x(shortalt * 0.2 + 0.2);
next.ears.scale = Vec3::one() * 1.02;
let footvertl = (anim_time as f32 * 16.0 * lab as f32 * speedmult + PI * 0.0).sin();
let footvertlt = (anim_time as f32 * 16.0 * lab as f32 * speedmult + PI * 0.4).sin();
let footvertlalt = (anim_time as f32 * 16.0 * lab as f32 * speedmult + PI * 1.2).sin();
let footvertltalt = (anim_time as f32 * 16.0 * lab as f32 * speedmult + PI * 1.6).sin();
////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 * -2.5,
skeleton_attr.leg_f.2 + 1.0 + footvertl * -1.0,
skeleton_attr.leg_f.1 + footvertlalt * -2.0,
skeleton_attr.leg_f.2 + 1.0 + footvertltalt * -1.9,
);
next.leg_fl.ori =
Quaternion::rotation_x(footrotl * -0.6) * Quaternion::rotation_z(tilt * -0.5);
Quaternion::rotation_x(footvertltalt * -0.4) * Quaternion::rotation_z(tilt * -0.5);
next.leg_fl.scale = Vec3::one() * 0.99;
next.leg_fr.offset = Vec3::new(
skeleton_attr.leg_f.0,
skeleton_attr.leg_f.1 + foothoril * -2.5,
skeleton_attr.leg_f.2 + 1.0 + footvertl * -1.0,
skeleton_attr.leg_f.1 + footvertlalt * -2.0,
skeleton_attr.leg_f.2 + 1.0 + footvertltalt * -1.9,
);
next.leg_fr.ori =
Quaternion::rotation_x(footrotr * -0.6) * Quaternion::rotation_z(tilt * -0.5);
Quaternion::rotation_x(footvertltalt * -0.4) * Quaternion::rotation_z(tilt * -0.5);
next.leg_fr.scale = Vec3::one() * 0.99;
next.leg_bl.offset = Vec3::new(
-skeleton_attr.leg_b.0,
skeleton_attr.leg_b.1 + foothorirb * -2.5,
skeleton_attr.leg_b.2 + 1.0 + footvertrb * -1.2,
skeleton_attr.leg_b.1 + footvertl * -1.7,
skeleton_attr.leg_b.2 + 1.0 + footvertlt * -1.5,
);
next.leg_bl.ori =
Quaternion::rotation_x(footrotlb * -0.6) * Quaternion::rotation_z(tilt * -1.5);
next.leg_bl.ori = Quaternion::rotation_x(footvertlt * -0.4 - 0.2)
* Quaternion::rotation_z(tilt * -1.5);
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 * -2.5,
skeleton_attr.leg_b.2 + 1.0 + footvertrb * -1.2,
skeleton_attr.leg_b.1 + footvertl * -1.7,
skeleton_attr.leg_b.2 + 1.0 + footvertlt * -1.5,
);
next.leg_br.ori =
Quaternion::rotation_x(footrotrb * -0.6) * Quaternion::rotation_z(tilt * -1.5);
next.leg_br.ori = Quaternion::rotation_x(footvertlt * -0.4 - 0.2)
* Quaternion::rotation_z(tilt * -1.5);
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 + 2.0 + ((footvertl * -2.0).max(-1.0)),
skeleton_attr.feet_f.2 + ((footvertl * -2.7).max(0.0)),
);
next.foot_fl.ori = Quaternion::rotation_x(footrotl * -0.7);
next.foot_fl.ori = Quaternion::rotation_x(footvertlt * 0.9 * skeleton_attr.dampen);
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 + 2.0 + ((footvertl * -2.0).max(-1.0)),
skeleton_attr.feet_f.2 + ((footvertl * -2.7).max(0.0)),
);
next.foot_fr.ori = Quaternion::rotation_x(footrotr * -0.7);
next.foot_fr.ori = Quaternion::rotation_x(footvertlt * 0.9 * skeleton_attr.dampen);
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 + 2.0 + ((footvertrb * -2.0).max(-1.0)),
skeleton_attr.feet_b.2 + ((footvertl * 2.4).max(0.0)),
);
next.foot_bl.ori = Quaternion::rotation_x(footrotlb * -0.7);
next.foot_bl.ori = Quaternion::rotation_x(footvertlt * -0.9 - 0.2);
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 + 2.0 + ((footvertrb * -2.0).max(-1.0)),
skeleton_attr.feet_b.2 + ((footvertl * 2.4).max(-0.0)),
);
next.foot_br.ori = Quaternion::rotation_x(footrotrb * -0.7);
next.foot_br.ori = Quaternion::rotation_x(footvertlt * -0.9 - 0.2);
next.foot_br.scale = Vec3::one() * 0.98;
}
next