Add beast attributes

This commit is contained in:
Snowram 2020-08-14 23:42:44 +02:00 committed by Robin Gilh
parent a4f4fa38e2
commit 4dcd450382
3 changed files with 82 additions and 52 deletions

View File

@ -54,13 +54,18 @@ impl Animation for IdleAnimation {
* 0.125,
);
// Controls for the beast breathing
let intensity = 0.04;
let lenght = 1.0;
let chop = 0.15;
let chop_freq = 40.0;
let breathing = intensity * (lenght * anim_time as f32).sin() + 0.05 * chop * (anim_time as f32 * chop_freq).sin() * (anim_time as f32 * lenght).cos();
let breathing = if skeleton_attr.beast {
// Controls for the beast breathing
let intensity = 0.04;
let lenght = 1.5;
let chop = 0.2;
let chop_freq = 60.0;
intensity * (lenght * anim_time as f32).sin() + 0.05 * chop * (anim_time as f32 * chop_freq).sin() * (anim_time as f32 * lenght).cos()
} else {
0.0
};
next.head.position = Vec3::new(
0.0,
@ -86,11 +91,19 @@ impl Animation for IdleAnimation {
next.lower_torso.orientation = Quaternion::rotation_z(0.0) * Quaternion::rotation_x(breathing);
next.lower_torso.scale = Vec3::one() * 1.02 + breathing * 0.4;
next.jaw.position = Vec3::new(
0.0,
skeleton_attr.jaw.0 - slower * 0.12,
skeleton_attr.jaw.1 + slow * 0.2,
);
if skeleton_attr.beast {
next.jaw.position = Vec3::new(
0.0,
skeleton_attr.jaw.0,
skeleton_attr.jaw.1,
);
} else {
next.jaw.position = Vec3::new(
0.0,
skeleton_attr.jaw.0 - slower * 0.12,
skeleton_attr.jaw.1 + slow * 0.2,
);
}
next.jaw.orientation = Quaternion::rotation_x(-0.1 + breathing * 2.0);
next.jaw.scale = Vec3::one() * 1.02;

View File

@ -90,6 +90,10 @@ pub struct SkeletonAttr {
leg: (f32, f32, f32),
foot: (f32, f32, f32),
beast: bool,
beast_ori: f32,
beast_head: (f32, f32),
beast_foot: (f32, f32, f32),
beast_hand: (f32, f32, f32),
}
impl<'a> std::convert::TryFrom<&'a comp::Body> for SkeletonAttr {
@ -116,6 +120,10 @@ impl Default for SkeletonAttr {
leg: (0.0, 0.0, 0.0),
foot: (0.0, 0.0, 0.0),
beast: false,
beast_ori: 0.0,
beast_head: (0.0, 0.0),
beast_foot: (0.0, 0.0, 0.0),
beast_hand: (0.0, 0.0, 0.0),
}
}
}
@ -207,6 +215,22 @@ impl<'a> From<&'a Body> for SkeletonAttr {
(Werewolf, _) => (true),
_ => (false),
},
beast_ori: match (body.species, body.body_type) {
(Werewolf, _) => (0.45),
_ => (0.0),
},
beast_head: match (body.species, body.body_type) {
(Werewolf, _) => (-3.0, 4.0),
_ => (0.0, 0.0),
},
beast_foot: match (body.species, body.body_type) {
(Werewolf, _) => (0.0, -11.0, 0.0),
_ => (0.0, 0.0, 0.0),
},
beast_hand: match (body.species, body.body_type) {
(Werewolf, _) => (0.0, 2.0, 1.0),
_ => (0.0, 0.0, 0.0),
},
}
}
}

View File

@ -55,59 +55,52 @@ impl Animation for RunAnimation {
.sqrt())
* ((anim_time as f32 * 16.0 * lab as f32 + PI * 0.4).sin());
let foothoril2 = (((1.0)
/ (0.4
/ (0.5
+ (0.6)
* ((anim_time as f32 * 16.0 * lab as f32 - PI * 0.4).sin()).powf(2.0 as f32)))
* ((anim_time as f32 * 16.0 * lab as f32 + PI * 1.5).sin()).powf(2.0 as f32)))
.sqrt())
* ((anim_time as f32 * 16.0 * lab as f32 - PI * 0.4).sin());
* ((anim_time as f32 * 16.0 * lab as f32 + PI * 1.5).sin());
let foothorir2 = (((1.0)
/ (0.4
/ (0.5
+ (0.6)
* ((anim_time as f32 * 16.0 * lab as f32).cos()).powf(2.0 as f32)))
* ((anim_time as f32 * 16.0 * lab as f32 + PI * 0.5).sin()).powf(2.0 as f32)))
.sqrt())
* ((anim_time as f32 * 16.0 * lab as f32).cos());
let footvertl2 = (anim_time as f32 * 16.0 * lab as f32 + 1.4 * PI).cos();
let footvertr2 = (anim_time as f32 * 16.0 * lab as f32 + 1.4 * PI).sin();
let handhoril2 = (anim_time as f32 * 16.0 * lab as f32).sin();
let handhorir2 = (anim_time as f32 * 16.0 * lab as f32 + PI).sin();
* ((anim_time as f32 * 16.0 * lab as f32 + PI * 0.5).sin());
let footvertl2 = (anim_time as f32 * 16.0 * lab as f32 + 0.5 * PI).sin();
let footvertr2 = (anim_time as f32 * 16.0 * lab as f32 + 1.5 * PI).sin();
let handhoril2 = (anim_time as f32 * 16.0 * lab as f32 + 0.5 * PI).sin();
let handhorir2 = (anim_time as f32 * 16.0 * lab as f32 + 1.5 * PI).sin();
let footrotl2 = (((5.0)
/ (2.5
+ (2.5)
* ((anim_time as f32 * 16.0 * lab as f32 + PI * 1.1).cos()).powf(2.0 as f32)))
* ((anim_time as f32 * 16.0 * lab as f32 + PI * 1.5).sin()).powf(2.0 as f32)))
.sqrt())
* ((anim_time as f32 * 16.0 * lab as f32 + PI * 1.1).cos());
* ((anim_time as f32 * 16.0 * lab as f32 + PI * 1.5).sin());
let footrotr2 = (((5.0)
/ (2.5
+ (2.5)
* ((anim_time as f32 * 16.0 * lab as f32 + PI * 0.4).sin()).powf(2.0 as f32)))
* ((anim_time as f32 * 16.0 * lab as f32 + PI * 0.5).sin()).powf(2.0 as f32)))
.sqrt())
* ((anim_time as f32 * 16.0 * lab as f32 + PI * 0.4).sin());
* ((anim_time as f32 * 16.0 * lab as f32 + PI * 0.5).sin());
let short = (anim_time as f32 * lab as f32 * 16.0).sin();
let shortalt = (anim_time as f32 * lab as f32 * 16.0 + PI / 2.0).sin();
if skeleton_attr.beast {
next.head.position = Vec3::new(0.0, skeleton_attr.head.0 - 3.0, skeleton_attr.head.1 + 4.0) * 1.02;
next.head.orientation = Quaternion::rotation_z(short * -0.18) * Quaternion::rotation_x(0.45 - short * 0.05);
next.head.position = Vec3::new(0.0, skeleton_attr.head.0 + skeleton_attr.beast_head.0, skeleton_attr.head.1 + skeleton_attr.beast_head.1) * 1.02;
next.head.orientation = Quaternion::rotation_z(shortalt * -0.18) * Quaternion::rotation_x(skeleton_attr.beast_ori - short * 0.05);
next.head.scale = Vec3::one() * 1.02;
next.upper_torso.position = Vec3::new(
0.0,
skeleton_attr.upper_torso.0,
skeleton_attr.upper_torso.1 + shortalt * -1.5,
skeleton_attr.upper_torso.1 + short * -1.5,
);
next.upper_torso.orientation = Quaternion::rotation_x(-0.45) * Quaternion::rotation_z(short * 0.18);
next.upper_torso.orientation = Quaternion::rotation_x(-skeleton_attr.beast_ori) * Quaternion::rotation_z(shortalt * 0.18);
next.upper_torso.scale = Vec3::one();
next.lower_torso.position = Vec3::new(
@ -124,7 +117,7 @@ impl Animation for RunAnimation {
next.tail.position = Vec3::new(0.0, skeleton_attr.tail.0, skeleton_attr.tail.1);
next.tail.orientation =
Quaternion::rotation_x(shortalt * 0.1 + 0.45);
Quaternion::rotation_x(shortalt * 0.1 + skeleton_attr.beast_ori);
next.tail.scale = Vec3::one();
next.second.position = Vec3::new(0.0, 0.0, 0.0);
@ -146,7 +139,7 @@ impl Animation for RunAnimation {
skeleton_attr.shoulder.1 + foothoril2 * -3.0,
skeleton_attr.shoulder.2,
);
next.shoulder_l.orientation = Quaternion::rotation_x(footrotl2 * -0.36 + 0.45)
next.shoulder_l.orientation = Quaternion::rotation_x(footrotl2 * -0.36 + skeleton_attr.beast_ori)
* Quaternion::rotation_y(0.1)
* Quaternion::rotation_z(footrotl2 * -0.3);
next.shoulder_l.scale = Vec3::one();
@ -156,27 +149,27 @@ impl Animation for RunAnimation {
skeleton_attr.shoulder.1 + foothorir2 * -3.0,
skeleton_attr.shoulder.2,
);
next.shoulder_r.orientation = Quaternion::rotation_x(footrotr2 * -0.36 + 0.45)
next.shoulder_r.orientation = Quaternion::rotation_x(footrotr2 * -0.36 + skeleton_attr.beast_ori)
* Quaternion::rotation_y(-0.1)
* Quaternion::rotation_z(footrotr2 * -0.3);
next.shoulder_r.scale = Vec3::one();
next.hand_l.position = Vec3::new(
-skeleton_attr.hand.0,
skeleton_attr.hand.1 + foothoril2 * -4.0 + 2.0,
skeleton_attr.hand.2 + foothoril2 * 0.5 + 2.0,
skeleton_attr.hand.1 + foothoril2 * -4.0 + skeleton_attr.beast_hand.1,
skeleton_attr.hand.2 + foothoril2 * 0.5 + skeleton_attr.beast_hand.2,
);
next.hand_l.orientation = Quaternion::rotation_x(0.15 + (handhoril2 * -1.2).max(-0.3) + 0.45)
* Quaternion::rotation_y(handhoril2 * 0.1);
next.hand_l.orientation = Quaternion::rotation_x(0.15 + (handhorir2 * -1.2).max(-0.3) + skeleton_attr.beast_ori)
* Quaternion::rotation_y(handhorir2 * 0.1);
next.hand_l.scale = Vec3::one() * 1.02;
next.hand_r.position = Vec3::new(
skeleton_attr.hand.0,
skeleton_attr.hand.1 + foothorir2 * -4.0 + 2.0,
skeleton_attr.hand.2 + foothorir2 * 0.5 + 2.0,
skeleton_attr.hand.1 + foothorir2 * -4.0 + skeleton_attr.beast_hand.1,
skeleton_attr.hand.2 + foothorir2 * 0.5 + skeleton_attr.beast_hand.2,
);
next.hand_r.orientation = Quaternion::rotation_x(0.15 + (handhorir2 * -1.2).max(-0.3) + 0.45)
* Quaternion::rotation_y(handhorir2 * -0.1);
next.hand_r.orientation = Quaternion::rotation_x(0.15 + (handhoril2 * -1.2).max(-0.3) + skeleton_attr.beast_ori)
* Quaternion::rotation_y(handhoril2 * -0.1);
next.hand_r.scale = Vec3::one() * 1.02;
next.leg_l.position = Vec3::new(
@ -185,7 +178,7 @@ impl Animation for RunAnimation {
skeleton_attr.leg.2,
) * 0.98;
next.leg_l.orientation =
Quaternion::rotation_z(short * 0.18) * Quaternion::rotation_x(foothoril2 * 0.6 - 0.45);
Quaternion::rotation_z(short * 0.18) * Quaternion::rotation_x(foothoril2 * 0.6 - skeleton_attr.beast_ori);
next.leg_l.scale = Vec3::one() * 0.98;
next.leg_r.position = Vec3::new(
@ -194,12 +187,12 @@ impl Animation for RunAnimation {
skeleton_attr.leg.2,
) * 0.98;
next.leg_r.orientation =
Quaternion::rotation_z(short * 0.18) * Quaternion::rotation_x(foothorir2 * 0.6 - 0.45);
Quaternion::rotation_z(short * 0.18) * Quaternion::rotation_x(foothorir2 * 0.6 - skeleton_attr.beast_ori);
next.leg_r.scale = Vec3::one() * 0.98;
next.foot_l.position = Vec3::new(
-skeleton_attr.foot.0,
4.0 + skeleton_attr.foot.1 + foothoril2 * 4.0 - 11.0,
4.0 + skeleton_attr.foot.1 + foothoril2 * 4.0 + skeleton_attr.beast_foot.1,
skeleton_attr.foot.2 + ((footvertl2 * 6.0).max(0.0)),
) / 8.0;
next.foot_l.orientation =
@ -208,7 +201,7 @@ impl Animation for RunAnimation {
next.foot_r.position = Vec3::new(
skeleton_attr.foot.0,
4.0 + skeleton_attr.foot.1 + foothorir2 * 4.0 - 11.0,
4.0 + skeleton_attr.foot.1 + foothorir2 * 4.0 + skeleton_attr.beast_foot.1,
skeleton_attr.foot.2 + ((footvertr2 * 6.0).max(0.0)),
) / 8.0;
next.foot_r.orientation =