idle for theropod, corrections to swimming

This commit is contained in:
jshipsey 2020-08-29 19:46:05 -04:00
parent ee95550355
commit 3eeaf7e8c9
6 changed files with 173 additions and 96 deletions

View File

@ -25,7 +25,7 @@ impl Animation for RunAnimation {
let speed = Vec2::<f32>::from(velocity).magnitude();
*rate = 1.0;
//let increasefreqtest = (((1.0/speed)*3.0).round()).min(5.0);
let lab = 0.1; //6
let lab = 0.6; //6
let amplitude = (speed / 24.0).max(0.25);
let amplitude2 = (speed * 1.4 / 24.0).max(0.6);
let amplitude3 = (speed / 24.0).max(0.35);
@ -106,8 +106,8 @@ impl Animation for RunAnimation {
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(look.y * 0.1 / canceler + amplitude * short * -0.03 - 0.1)
* Quaternion::rotation_z(look.x * 0.1 / canceler + tilt * -1.2)
Quaternion::rotation_x(look.y*0.3 / ((canceler).max(0.5)) + amplitude * short * -0.03 - 0.1)
* Quaternion::rotation_z(look.x*0.3 / ((canceler).max(0.5)) + tilt * -1.2)
* Quaternion::rotation_y(tilt * 0.8);
next.head_upper.scale = Vec3::one();

View File

@ -22,39 +22,43 @@ impl Animation for IdleAnimation {
) -> Self::Skeleton {
let mut next = (*skeleton).clone();
next.head.position = Vec3::new(0.0, skeleton_attr.head.0, skeleton_attr.head.1);
next.head.orientation = Quaternion::rotation_z(0.0);
next.head.scale = Vec3::one();
let breathe = (anim_time as f32 * 0.8).sin();
next.head.position = Vec3::new(0.0, skeleton_attr.head.0, skeleton_attr.head.1+breathe * 0.3);
next.head.orientation = Quaternion::rotation_x(breathe * 0.1-0.1);
next.head.scale = Vec3::one()*1.02;
next.jaw.position = Vec3::new(0.0, skeleton_attr.jaw.0, skeleton_attr.jaw.1);
next.jaw.orientation = Quaternion::rotation_z(0.0);
next.jaw.scale = Vec3::one();
next.jaw.orientation = Quaternion::rotation_x(breathe * 0.05);
next.jaw.scale = Vec3::one()*0.98;
next.neck.position = Vec3::new(0.0, skeleton_attr.neck.0, skeleton_attr.neck.1);
next.neck.orientation = Quaternion::rotation_z(0.0);
next.neck.scale = Vec3::one();
next.neck.position = Vec3::new(0.0, skeleton_attr.neck.0, skeleton_attr.neck.1+breathe * 0.2);
next.neck.orientation = Quaternion::rotation_x(-0.1);
next.neck.scale = Vec3::one()*0.98;
next.chest_front.position = Vec3::new(
0.0,
skeleton_attr.chest_front.0,
skeleton_attr.chest_front.1,
);
next.chest_front.orientation = Quaternion::rotation_z(0.0);
next.chest_front.scale = Vec3::one();
skeleton_attr.chest_front.1+breathe * 0.3,
)/3.0;
next.chest_front.orientation = Quaternion::rotation_x(breathe * 0.04);
next.chest_front.scale = Vec3::one()/3.0;
next.chest_back.position =
Vec3::new(0.0, skeleton_attr.chest_back.0, skeleton_attr.chest_back.1);
next.chest_back.orientation = Quaternion::rotation_z(0.0);
next.chest_back.orientation = Quaternion::rotation_x(breathe * -0.04);
next.chest_back.scale = Vec3::one();
next.tail_front.position =
Vec3::new(0.0, skeleton_attr.tail_front.0, skeleton_attr.tail_front.1);
next.tail_front.orientation = Quaternion::rotation_z(0.0);
next.tail_front.orientation = Quaternion::rotation_x(0.1);
next.tail_front.scale = Vec3::one();
next.tail_back.position =
Vec3::new(0.0, skeleton_attr.tail_back.0, skeleton_attr.tail_back.1);
next.tail_back.orientation = Quaternion::rotation_z(0.0);
next.tail_back.orientation = Quaternion::rotation_x(0.1);
next.tail_back.scale = Vec3::one();
next.hand_l.position = Vec3::new(
@ -62,7 +66,7 @@ impl Animation for IdleAnimation {
skeleton_attr.hand.1,
skeleton_attr.hand.2,
);
next.hand_l.orientation = Quaternion::rotation_z(0.0);
next.hand_l.orientation = Quaternion::rotation_x(breathe * 0.2);
next.hand_l.scale = Vec3::one();
next.hand_r.position = Vec3::new(
@ -70,13 +74,13 @@ impl Animation for IdleAnimation {
skeleton_attr.hand.1,
skeleton_attr.hand.2,
);
next.hand_r.orientation = Quaternion::rotation_z(0.0);
next.hand_r.orientation = Quaternion::rotation_x(breathe * 0.2);
next.hand_r.scale = Vec3::one();
next.leg_l.position = Vec3::new(
-skeleton_attr.leg.0,
skeleton_attr.leg.1,
skeleton_attr.leg.2,
skeleton_attr.leg.2+breathe * 0.05,
);
next.leg_l.orientation = Quaternion::rotation_z(0.0);
next.leg_l.scale = Vec3::one();
@ -84,7 +88,7 @@ impl Animation for IdleAnimation {
next.leg_r.position = Vec3::new(
skeleton_attr.leg.0,
skeleton_attr.leg.1,
skeleton_attr.leg.2,
skeleton_attr.leg.2+breathe * 0.05,
);
next.leg_r.orientation = Quaternion::rotation_z(0.0);
next.leg_r.scale = Vec3::one();
@ -92,18 +96,18 @@ impl Animation for IdleAnimation {
next.foot_l.position = Vec3::new(
-skeleton_attr.foot.0,
skeleton_attr.foot.1,
skeleton_attr.foot.2,
skeleton_attr.foot.2+breathe * -0.35,
);
next.foot_l.orientation = Quaternion::rotation_z(0.0);
next.foot_l.scale = Vec3::one();
next.foot_l.scale = Vec3::one()*1.02;
next.foot_r.position = Vec3::new(
skeleton_attr.foot.0,
skeleton_attr.foot.1,
skeleton_attr.foot.2,
skeleton_attr.foot.2+breathe * -0.45,
);
next.foot_r.orientation = Quaternion::rotation_z(0.0);
next.foot_r.scale = Vec3::one();
next.foot_r.scale = Vec3::one()*1.02;
next
}

View File

@ -15,47 +15,48 @@ impl Animation for JumpAnimation {
fn update_skeleton_inner(
skeleton: &Self::Skeleton,
_global_time: Self::Dependency,
_anim_time: f64,
anim_time: f64,
_rate: &mut f32,
skeleton_attr: &SkeletonAttr,
) -> Self::Skeleton {
let mut next = (*skeleton).clone();
let wave = (_anim_time as f32 * 1.0).sin();
let breathe = (anim_time as f32 * 0.8).sin();
next.head.position = Vec3::new(0.0, skeleton_attr.head.0, skeleton_attr.head.1);
next.head.orientation = Quaternion::rotation_z(0.0);
next.head.scale = Vec3::one();
next.head.position = Vec3::new(0.0, skeleton_attr.head.0, skeleton_attr.head.1+breathe * 0.3);
next.head.orientation = Quaternion::rotation_x(breathe * 0.1-0.1);
next.head.scale = Vec3::one()*1.02;
next.jaw.position = Vec3::new(0.0, skeleton_attr.jaw.0, skeleton_attr.jaw.1);
next.jaw.orientation = Quaternion::rotation_z(0.0);
next.jaw.scale = Vec3::one();
next.jaw.orientation = Quaternion::rotation_x(breathe * 0.05);
next.jaw.scale = Vec3::one()*0.98;
next.neck.position = Vec3::new(0.0, skeleton_attr.neck.0, skeleton_attr.neck.1);
next.neck.orientation = Quaternion::rotation_z(0.0);
next.neck.scale = Vec3::one();
next.neck.position = Vec3::new(0.0, skeleton_attr.neck.0, skeleton_attr.neck.1+breathe * 0.2);
next.neck.orientation = Quaternion::rotation_x(-0.1);
next.neck.scale = Vec3::one()*0.98;
next.chest_front.position = Vec3::new(
0.0,
skeleton_attr.chest_front.0,
skeleton_attr.chest_front.1,
);
next.chest_front.orientation = Quaternion::rotation_z(0.0);
next.chest_front.scale = Vec3::one();
skeleton_attr.chest_front.1+breathe * 0.3,
)/3.0;
next.chest_front.orientation = Quaternion::rotation_x(breathe * 0.04);
next.chest_front.scale = Vec3::one()/3.0;
next.chest_back.position =
Vec3::new(0.0, skeleton_attr.chest_back.0, skeleton_attr.chest_back.1);
next.chest_back.orientation = Quaternion::rotation_z(0.0);
next.chest_back.orientation = Quaternion::rotation_x(breathe * -0.04);
next.chest_back.scale = Vec3::one();
next.tail_front.position =
Vec3::new(0.0, skeleton_attr.tail_front.0, skeleton_attr.tail_front.1);
next.tail_front.orientation = Quaternion::rotation_z(0.0);
next.tail_front.orientation = Quaternion::rotation_x(0.1);
next.tail_front.scale = Vec3::one();
next.tail_back.position =
Vec3::new(0.0, skeleton_attr.tail_back.0, skeleton_attr.tail_back.1);
next.tail_back.orientation = Quaternion::rotation_z(0.0);
next.tail_back.orientation = Quaternion::rotation_x(0.1);
next.tail_back.scale = Vec3::one();
next.hand_l.position = Vec3::new(
@ -63,7 +64,7 @@ impl Animation for JumpAnimation {
skeleton_attr.hand.1,
skeleton_attr.hand.2,
);
next.hand_l.orientation = Quaternion::rotation_z(0.0);
next.hand_l.orientation = Quaternion::rotation_x(breathe * 0.2);
next.hand_l.scale = Vec3::one();
next.hand_r.position = Vec3::new(
@ -71,13 +72,13 @@ impl Animation for JumpAnimation {
skeleton_attr.hand.1,
skeleton_attr.hand.2,
);
next.hand_r.orientation = Quaternion::rotation_z(0.0);
next.hand_l.scale = Vec3::one();
next.hand_r.orientation = Quaternion::rotation_x(breathe * 0.2);
next.hand_r.scale = Vec3::one();
next.leg_l.position = Vec3::new(
-skeleton_attr.leg.0,
skeleton_attr.leg.1,
skeleton_attr.leg.2,
skeleton_attr.leg.2+breathe * 0.05,
);
next.leg_l.orientation = Quaternion::rotation_z(0.0);
next.leg_l.scale = Vec3::one();
@ -85,7 +86,7 @@ impl Animation for JumpAnimation {
next.leg_r.position = Vec3::new(
skeleton_attr.leg.0,
skeleton_attr.leg.1,
skeleton_attr.leg.2,
skeleton_attr.leg.2+breathe * 0.05,
);
next.leg_r.orientation = Quaternion::rotation_z(0.0);
next.leg_r.scale = Vec3::one();
@ -93,18 +94,18 @@ impl Animation for JumpAnimation {
next.foot_l.position = Vec3::new(
-skeleton_attr.foot.0,
skeleton_attr.foot.1,
skeleton_attr.foot.2,
skeleton_attr.foot.2+breathe * -0.35,
);
next.foot_l.orientation = Quaternion::rotation_z(0.0);
next.foot_l.scale = Vec3::one();
next.foot_l.scale = Vec3::one()*1.02;
next.foot_r.position = Vec3::new(
skeleton_attr.foot.0,
skeleton_attr.foot.1,
skeleton_attr.foot.2,
skeleton_attr.foot.2+breathe * -0.45,
);
next.foot_r.orientation = Quaternion::rotation_z(0.0);
next.foot_r.scale = Vec3::one();
next.foot_r.scale = Vec3::one()*1.02;
next
}

View File

@ -47,8 +47,8 @@ impl Skeleton for TheropodSkeleton {
let head_mat = neck_mat * Mat4::<f32>::from(self.head);
let chest_back_mat = chest_front_mat * Mat4::<f32>::from(self.chest_back);
let tail_front_mat = chest_back_mat * Mat4::<f32>::from(self.tail_front);
let leg_l_mat = chest_front_mat * Mat4::<f32>::from(self.leg_l);
let leg_r_mat = chest_front_mat * Mat4::<f32>::from(self.leg_r);
let leg_l_mat = chest_back_mat * Mat4::<f32>::from(self.leg_l);
let leg_r_mat = chest_back_mat * Mat4::<f32>::from(self.leg_r);
*(<&mut [_; Self::BONE_COUNT]>::try_from(&mut buf[0..Self::BONE_COUNT]).unwrap()) = [
make_bone(head_mat),
@ -119,16 +119,16 @@ impl<'a> From<&'a Body> for SkeletonAttr {
(Odontotyrannos, _) => (-2.5, 3.0),
},
jaw: match (body.species, body.body_type) {
(Archaeos, _) => (10.0, -7.0),
(Odontotyrannos, _) => (10.0, -7.0),
(Archaeos, _) => (1.0, -7.0),
(Odontotyrannos, _) => (1.0, -7.0),
},
neck: match (body.species, body.body_type) {
(Archaeos, _) => (4.5, -2.0),
(Odontotyrannos, _) => (4.5, -2.0),
},
chest_front: match (body.species, body.body_type) {
(Archaeos, _) => (4.5, 20.0),
(Odontotyrannos, _) => (4.0, 13.0),
(Archaeos, _) => (0.0, 20.0),
(Odontotyrannos, _) => (0.0, 9.0),
},
chest_back: match (body.species, body.body_type) {
(Archaeos, _) => (-5.5, -1.0),
@ -139,19 +139,19 @@ impl<'a> From<&'a Body> for SkeletonAttr {
(Odontotyrannos, _) => (-8.0, -1.0),
},
tail_back: match (body.species, body.body_type) {
(Archaeos, _) => (-20.0, -0.5),
(Odontotyrannos, _) => (-19.0, -1.5),
(Archaeos, _) => (-8.0, -0.5),
(Odontotyrannos, _) => (-12.0, -1.5),
},
hand: match (body.species, body.body_type) {
(Archaeos, _) => (2.5, -2.5, -4.0),
(Archaeos, _) => (3.0, 0.0, -4.0),
(Odontotyrannos, _) => (3.5, 3.0, -4.0),
},
leg: match (body.species, body.body_type) {
(Archaeos, _) => (4.5, -9.0, -4.0),
(Odontotyrannos, _) => (5.5, -6.5, -2.0),
(Archaeos, _) => (4.5, -3.0, -4.0),
(Odontotyrannos, _) => (5.5, -2.5, -2.0),
},
foot: match (body.species, body.body_type) {
(Archaeos, _) => (1.0, -0.5, -8.0),
(Archaeos, _) => (1.0, -0.5, -7.0),
(Odontotyrannos, _) => (-1.0, -6.5, -3.0),
},
}

View File

@ -26,39 +26,74 @@ impl Animation for RunAnimation {
//let wavealt = (anim_time as f32 * 8.0 + PI / 2.0).sin();
//let wave_slow = (anim_time as f32 * 6.5 + PI).sin();
next.head.position = Vec3::new(0.0, skeleton_attr.head.0, skeleton_attr.head.1);
next.head.orientation = Quaternion::rotation_z(0.0);
next.head.scale = Vec3::one();
let breathe = (anim_time as f32 * 0.8).sin();
let lab = 0.55; //.65
let foothoril = (((1.0)
/ (0.4
+ (0.6)
* ((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 foothorir = (((1.0)
/ (0.4
+ (0.6)
* ((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 footrotl = (((5.0)
/ (2.5
+ (2.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)
/ (1.0
+ (4.0)
* ((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 short = (anim_time as f32 * lab as f32 * 16.0).sin();
next.head.position = Vec3::new(0.0, skeleton_attr.head.0, skeleton_attr.head.1+breathe * 0.3);
next.head.orientation = Quaternion::rotation_x(breathe * 0.1-0.1);
next.head.scale = Vec3::one()*1.02;
next.jaw.position = Vec3::new(0.0, skeleton_attr.jaw.0, skeleton_attr.jaw.1);
next.jaw.orientation = Quaternion::rotation_z(0.0);
next.jaw.scale = Vec3::one();
next.jaw.orientation = Quaternion::rotation_x(breathe * 0.05);
next.jaw.scale = Vec3::one()*0.98;
next.neck.position = Vec3::new(0.0, skeleton_attr.neck.0, skeleton_attr.neck.1);
next.neck.orientation = Quaternion::rotation_z(0.0);
next.neck.scale = Vec3::one();
next.neck.position = Vec3::new(0.0, skeleton_attr.neck.0, skeleton_attr.neck.1+breathe * 0.2);
next.neck.orientation = Quaternion::rotation_x(-0.1);
next.neck.scale = Vec3::one()*0.98;
next.chest_front.position = Vec3::new(
0.0,
skeleton_attr.chest_front.0,
skeleton_attr.chest_front.1,
);
next.chest_front.orientation = Quaternion::rotation_z(0.0);
next.chest_front.scale = Vec3::one();
skeleton_attr.chest_front.1+breathe * 0.3,
)/3.0;
next.chest_front.orientation = Quaternion::rotation_x(breathe * 0.04);
next.chest_front.scale = Vec3::one()/3.0;
next.chest_back.position =
Vec3::new(0.0, skeleton_attr.chest_back.0, skeleton_attr.chest_back.1);
next.chest_back.orientation = Quaternion::rotation_z(0.0);
next.chest_back.orientation = Quaternion::rotation_x(breathe * -0.04);
next.chest_back.scale = Vec3::one();
next.tail_front.position =
Vec3::new(0.0, skeleton_attr.tail_front.0, skeleton_attr.tail_front.1);
next.tail_front.orientation = Quaternion::rotation_z(0.0);
next.tail_front.orientation = Quaternion::rotation_x(0.1);
next.tail_front.scale = Vec3::one();
next.tail_back.position =
Vec3::new(0.0, skeleton_attr.tail_back.0, skeleton_attr.tail_back.1);
next.tail_back.orientation = Quaternion::rotation_z(0.0);
next.tail_back.orientation = Quaternion::rotation_x(0.1);
next.tail_back.scale = Vec3::one();
next.hand_l.position = Vec3::new(
@ -66,7 +101,7 @@ impl Animation for RunAnimation {
skeleton_attr.hand.1,
skeleton_attr.hand.2,
);
next.hand_l.orientation = Quaternion::rotation_z(0.0);
next.hand_l.orientation = Quaternion::rotation_x(breathe * 0.2);
next.hand_l.scale = Vec3::one();
next.hand_r.position = Vec3::new(
@ -74,40 +109,43 @@ impl Animation for RunAnimation {
skeleton_attr.hand.1,
skeleton_attr.hand.2,
);
next.hand_r.orientation = Quaternion::rotation_z(0.0);
next.hand_l.scale = Vec3::one();
next.hand_r.orientation = Quaternion::rotation_x(breathe * 0.2);
next.hand_r.scale = Vec3::one();
next.leg_l.position = Vec3::new(
-skeleton_attr.leg.0,
skeleton_attr.leg.1,
skeleton_attr.leg.2,
skeleton_attr.leg.2+breathe * 0.05,
);
next.leg_l.orientation = Quaternion::rotation_z(0.0);
next.leg_l.scale = Vec3::one();
next.leg_l.orientation =
Quaternion::rotation_z(short * 0.18) * Quaternion::rotation_x(foothoril * 0.3); next.leg_l.scale = Vec3::one();
next.leg_r.position = Vec3::new(
skeleton_attr.leg.0,
skeleton_attr.leg.1,
skeleton_attr.leg.2,
skeleton_attr.leg.2+breathe * 0.05,
);
next.leg_r.orientation = Quaternion::rotation_z(0.0);
next.leg_r.orientation =
Quaternion::rotation_z(short * 0.18) * Quaternion::rotation_x(foothorir * 0.3);
next.leg_r.scale = Vec3::one();
next.foot_l.position = Vec3::new(
-skeleton_attr.foot.0,
skeleton_attr.foot.1,
skeleton_attr.foot.2,
skeleton_attr.foot.2+breathe * -0.35,
);
next.foot_l.orientation = Quaternion::rotation_z(0.0);
next.foot_l.scale = Vec3::one();
next.foot_l.orientation =
Quaternion::rotation_x(-0.1 + footrotl * 0.25);
next.foot_l.scale = Vec3::one()*1.02;
next.foot_r.position = Vec3::new(
skeleton_attr.foot.0,
skeleton_attr.foot.1,
skeleton_attr.foot.2,
skeleton_attr.foot.2+breathe * -0.45,
);
next.foot_r.orientation = Quaternion::rotation_z(0.0);
next.foot_r.scale = Vec3::one();
next.foot_r.orientation =
Quaternion::rotation_x(-0.1 + footrotr * 0.25);
next.foot_r.scale = Vec3::one()*1.02;
next
}

View File

@ -1122,6 +1122,16 @@ impl FigureMgr {
skeleton_attr,
)
},
// Running
(false, _, true) => {
anim::quadruped_small::RunAnimation::update_skeleton(
&QuadrupedSmallSkeleton::default(),
(vel.0.magnitude(), ori, state.last_ori, time, state.avg_vel),
state.state_time,
&mut state_animation_rate,
skeleton_attr,
)
},
// In air
(false, _, false) => anim::quadruped_small::JumpAnimation::update_skeleton(
&QuadrupedSmallSkeleton::default(),
@ -1215,7 +1225,15 @@ impl FigureMgr {
)
},
// Running
(true, true, _) => anim::quadruped_medium::RunAnimation::update_skeleton(
(true, true, false) => anim::quadruped_medium::RunAnimation::update_skeleton(
&QuadrupedMediumSkeleton::default(),
(vel.0.magnitude(), ori, state.last_ori, time, state.avg_vel),
state.state_time,
&mut state_animation_rate,
skeleton_attr,
),
//Swimming
(false, _, true) => anim::quadruped_medium::RunAnimation::update_skeleton(
&QuadrupedMediumSkeleton::default(),
(vel.0.magnitude(), ori, state.last_ori, time, state.avg_vel),
state.state_time,
@ -1317,7 +1335,15 @@ impl FigureMgr {
)
},
// Running
(true, true, _) => anim::quadruped_low::RunAnimation::update_skeleton(
(true, true, false) => anim::quadruped_low::RunAnimation::update_skeleton(
&QuadrupedLowSkeleton::default(),
(vel.0.magnitude(), ori, state.last_ori, time, state.avg_vel),
state.state_time,
&mut state_animation_rate,
skeleton_attr,
),
// Swimming
(false, _, true) => anim::quadruped_low::RunAnimation::update_skeleton(
&QuadrupedLowSkeleton::default(),
(vel.0.magnitude(), ori, state.last_ori, time, state.avg_vel),
state.state_time,
@ -1414,7 +1440,15 @@ impl FigureMgr {
skeleton_attr,
),
// Running
(true, true, _) => anim::bird_medium::RunAnimation::update_skeleton(
(true, true, false) => anim::bird_medium::RunAnimation::update_skeleton(
&BirdMediumSkeleton::default(),
(vel.0.magnitude(), time),
state.state_time,
&mut state_animation_rate,
skeleton_attr,
),
// Running
(false, _, true) => anim::bird_medium::RunAnimation::update_skeleton(
&BirdMediumSkeleton::default(),
(vel.0.magnitude(), time),
state.state_time,