2020-01-26 00:22:48 +00:00
|
|
|
use super::{super::Animation, QuadrupedSmallSkeleton, SkeletonAttr};
|
2020-02-25 06:47:56 +00:00
|
|
|
use std::f32::consts::PI;
|
2019-05-13 23:43:10 +00:00
|
|
|
use vek::*;
|
|
|
|
|
|
|
|
pub struct RunAnimation;
|
|
|
|
|
|
|
|
impl Animation for RunAnimation {
|
|
|
|
type Dependency = (f32, f64);
|
2020-02-01 20:39:39 +00:00
|
|
|
type Skeleton = QuadrupedSmallSkeleton;
|
2019-05-13 23:43:10 +00:00
|
|
|
|
|
|
|
fn update_skeleton(
|
|
|
|
skeleton: &Self::Skeleton,
|
2019-07-04 14:58:59 +00:00
|
|
|
(_velocity, _global_time): Self::Dependency,
|
2019-05-13 23:43:10 +00:00
|
|
|
anim_time: f64,
|
2019-09-09 19:11:40 +00:00
|
|
|
_rate: &mut f32,
|
2020-01-26 00:22:48 +00:00
|
|
|
skeleton_attr: &SkeletonAttr,
|
2019-05-13 23:43:10 +00:00
|
|
|
) -> Self::Skeleton {
|
|
|
|
let mut next = (*skeleton).clone();
|
|
|
|
|
2020-02-25 06:47:56 +00:00
|
|
|
let slow = (anim_time as f32 * 14.0).sin();
|
|
|
|
let fast = (anim_time as f32 * 20.0).sin();
|
|
|
|
let fast_alt = (anim_time as f32 * 20.0 + PI / 2.0).sin();
|
|
|
|
let slow_alt = (anim_time as f32 * 14.0 + PI / 2.0).sin();
|
2019-05-13 23:43:10 +00:00
|
|
|
|
2020-01-26 00:22:48 +00:00
|
|
|
next.head.offset =
|
2020-02-25 06:47:56 +00:00
|
|
|
Vec3::new(0.0, skeleton_attr.head.0, skeleton_attr.head.1 + slow * 1.5) / 11.0;
|
2019-10-26 02:20:38 +00:00
|
|
|
next.head.ori =
|
2020-02-25 06:47:56 +00:00
|
|
|
Quaternion::rotation_x(0.2 + slow * 0.05) * Quaternion::rotation_y(slow_alt * 0.03);
|
2019-10-26 02:20:38 +00:00
|
|
|
next.head.scale = Vec3::one() / 10.5;
|
2019-05-13 23:43:10 +00:00
|
|
|
|
2020-01-26 00:22:48 +00:00
|
|
|
next.chest.offset = Vec3::new(
|
|
|
|
0.0,
|
|
|
|
skeleton_attr.chest.0,
|
2020-02-25 06:47:56 +00:00
|
|
|
skeleton_attr.chest.1 + slow_alt * 1.2,
|
2020-01-26 00:22:48 +00:00
|
|
|
) / 11.0;
|
2020-02-25 06:47:56 +00:00
|
|
|
next.chest.ori = Quaternion::rotation_x(slow * 0.1);
|
2019-10-26 02:20:38 +00:00
|
|
|
next.chest.scale = Vec3::one() / 11.0;
|
2019-05-13 23:43:10 +00:00
|
|
|
|
2020-01-26 00:22:48 +00:00
|
|
|
next.leg_lf.offset = Vec3::new(
|
|
|
|
-skeleton_attr.feet_f.0,
|
2020-02-25 06:47:56 +00:00
|
|
|
skeleton_attr.feet_f.1 + fast * 0.8,
|
|
|
|
skeleton_attr.feet_f.2 + fast_alt * 1.5,
|
2020-01-26 00:22:48 +00:00
|
|
|
) / 11.0;
|
2020-02-25 06:47:56 +00:00
|
|
|
next.leg_lf.ori = Quaternion::rotation_x(fast * 0.3);
|
2019-10-26 02:20:38 +00:00
|
|
|
next.leg_lf.scale = Vec3::one() / 11.0;
|
2019-05-13 23:43:10 +00:00
|
|
|
|
2020-01-26 00:22:48 +00:00
|
|
|
next.leg_rf.offset = Vec3::new(
|
|
|
|
skeleton_attr.feet_f.0,
|
2020-02-25 06:47:56 +00:00
|
|
|
skeleton_attr.feet_f.1 + fast_alt * -0.8,
|
|
|
|
skeleton_attr.feet_f.2 + fast * 1.5,
|
2020-01-26 00:22:48 +00:00
|
|
|
) / 11.0;
|
2020-02-25 06:47:56 +00:00
|
|
|
next.leg_rf.ori = Quaternion::rotation_x(fast_alt * -0.3);
|
2019-10-26 02:20:38 +00:00
|
|
|
next.leg_rf.scale = Vec3::one() / 11.0;
|
2019-05-13 23:43:10 +00:00
|
|
|
|
2020-01-26 00:22:48 +00:00
|
|
|
next.leg_lb.offset = Vec3::new(
|
|
|
|
-skeleton_attr.feet_b.0,
|
2020-02-25 06:47:56 +00:00
|
|
|
skeleton_attr.feet_b.1 + fast_alt * -0.8,
|
|
|
|
skeleton_attr.feet_b.2 + fast * 1.5,
|
2020-01-26 00:22:48 +00:00
|
|
|
) / 11.0;
|
2020-02-25 06:47:56 +00:00
|
|
|
next.leg_lb.ori = Quaternion::rotation_x(fast_alt * -0.3);
|
2019-10-26 02:20:38 +00:00
|
|
|
next.leg_lb.scale = Vec3::one() / 11.0;
|
2019-05-13 23:43:10 +00:00
|
|
|
|
2020-01-26 00:22:48 +00:00
|
|
|
next.leg_rb.offset = Vec3::new(
|
|
|
|
skeleton_attr.feet_b.0,
|
2020-02-25 06:47:56 +00:00
|
|
|
skeleton_attr.feet_b.1 + fast * 0.8,
|
|
|
|
skeleton_attr.feet_b.2 + fast_alt * 1.5,
|
2020-01-26 00:22:48 +00:00
|
|
|
) / 11.0;
|
2020-02-25 06:47:56 +00:00
|
|
|
next.leg_rb.ori = Quaternion::rotation_x(fast * 0.3);
|
2019-10-26 02:20:38 +00:00
|
|
|
next.leg_rb.scale = Vec3::one() / 11.0;
|
2019-05-13 23:43:10 +00:00
|
|
|
|
2020-06-01 00:33:24 +00:00
|
|
|
next.tail.offset = Vec3::new(0.0, skeleton_attr.tail.0, skeleton_attr.tail.1);
|
|
|
|
next.tail.ori = Quaternion::rotation_z(0.0);
|
|
|
|
next.tail.scale = Vec3::one();
|
2019-05-13 23:43:10 +00:00
|
|
|
next
|
|
|
|
}
|
|
|
|
}
|