2020-01-26 00:22:48 +00:00
|
|
|
use super::{super::Animation, QuadrupedSmallSkeleton, SkeletonAttr};
|
2019-05-13 23:43:10 +00:00
|
|
|
use vek::*;
|
|
|
|
|
|
|
|
pub struct RunAnimation;
|
|
|
|
|
|
|
|
impl Animation for RunAnimation {
|
2019-10-25 01:26:32 +00:00
|
|
|
type Skeleton = QuadrupedSmallSkeleton;
|
2019-05-13 23:43:10 +00:00
|
|
|
type Dependency = (f32, f64);
|
|
|
|
|
|
|
|
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();
|
|
|
|
|
|
|
|
let wave = (anim_time as f32 * 14.0).sin();
|
2019-05-17 09:22:32 +00:00
|
|
|
let wave_quick = (anim_time as f32 * 20.0).sin();
|
|
|
|
let wave_quick_cos = (anim_time as f32 * 20.0).cos();
|
|
|
|
let wave_cos = (anim_time as f32 * 14.0).cos();
|
2019-05-13 23:43:10 +00:00
|
|
|
|
2020-01-26 00:22:48 +00:00
|
|
|
next.head.offset =
|
|
|
|
Vec3::new(0.0, skeleton_attr.head.0, skeleton_attr.head.1 + wave * 1.5) / 11.0;
|
2019-10-26 02:20:38 +00:00
|
|
|
next.head.ori =
|
2019-05-17 09:22:32 +00:00
|
|
|
Quaternion::rotation_x(0.2 + wave * 0.05) * Quaternion::rotation_y(wave_cos * 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,
|
|
|
|
skeleton_attr.chest.1 + wave_cos * 1.2,
|
|
|
|
) / 11.0;
|
2019-10-26 02:20:38 +00:00
|
|
|
next.chest.ori = Quaternion::rotation_x(wave * 0.1);
|
|
|
|
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,
|
|
|
|
skeleton_attr.feet_f.1 + wave_quick * 0.8,
|
|
|
|
skeleton_attr.feet_f.2 + wave_quick_cos * 1.5,
|
|
|
|
) / 11.0;
|
2019-10-26 02:20:38 +00:00
|
|
|
next.leg_lf.ori = Quaternion::rotation_x(wave_quick * 0.3);
|
|
|
|
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,
|
|
|
|
skeleton_attr.feet_f.1 - wave_quick_cos * 0.8,
|
|
|
|
skeleton_attr.feet_f.2 + wave_quick * 1.5,
|
|
|
|
) / 11.0;
|
2019-10-26 02:20:38 +00:00
|
|
|
next.leg_rf.ori = Quaternion::rotation_x(wave_quick_cos * -0.3);
|
|
|
|
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,
|
|
|
|
skeleton_attr.feet_b.1 - wave_quick_cos * 0.8,
|
|
|
|
skeleton_attr.feet_b.2 + wave_quick * 1.5,
|
|
|
|
) / 11.0;
|
2019-10-26 02:20:38 +00:00
|
|
|
next.leg_lb.ori = Quaternion::rotation_x(wave_quick_cos * -0.3);
|
|
|
|
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,
|
|
|
|
skeleton_attr.feet_b.1 + wave_quick * 0.8,
|
|
|
|
skeleton_attr.feet_b.2 + wave_quick_cos * 1.5,
|
|
|
|
) / 11.0;
|
2019-10-26 02:20:38 +00:00
|
|
|
next.leg_rb.ori = Quaternion::rotation_x(wave_quick * 0.3);
|
|
|
|
next.leg_rb.scale = Vec3::one() / 11.0;
|
2019-05-13 23:43:10 +00:00
|
|
|
|
|
|
|
next
|
|
|
|
}
|
|
|
|
}
|