2020-01-26 00:22:48 +00:00
|
|
|
use super::{super::Animation, BirdMediumSkeleton, SkeletonAttr};
|
|
|
|
use std::ops::Mul;
|
2019-10-23 02:56:45 +00:00
|
|
|
use vek::*;
|
|
|
|
|
|
|
|
pub struct IdleAnimation;
|
|
|
|
|
|
|
|
impl Animation for IdleAnimation {
|
|
|
|
type Skeleton = BirdMediumSkeleton;
|
2019-11-04 17:26:32 +00:00
|
|
|
type Dependency = f64;
|
2019-10-23 02:56:45 +00:00
|
|
|
|
|
|
|
fn update_skeleton(
|
|
|
|
skeleton: &Self::Skeleton,
|
2020-01-26 00:22:48 +00:00
|
|
|
global_time: Self::Dependency,
|
|
|
|
anim_time: f64,
|
2019-10-23 02:56:45 +00:00
|
|
|
_rate: &mut f32,
|
2020-01-26 00:22:48 +00:00
|
|
|
skeleton_attr: &SkeletonAttr,
|
2019-10-23 02:56:45 +00:00
|
|
|
) -> Self::Skeleton {
|
|
|
|
let mut next = (*skeleton).clone();
|
|
|
|
|
2020-01-26 00:22:48 +00:00
|
|
|
let wave_slow = (anim_time as f32 * 3.5).sin();
|
|
|
|
let wave_slow_cos = (anim_time as f32 * 3.5).cos();
|
2019-10-23 02:56:45 +00:00
|
|
|
|
2020-01-26 00:22:48 +00:00
|
|
|
let duck_head_look = Vec2::new(
|
|
|
|
((global_time + anim_time) as f32 / 8.0)
|
|
|
|
.floor()
|
|
|
|
.mul(7331.0)
|
|
|
|
.sin()
|
|
|
|
* 0.5,
|
|
|
|
((global_time + anim_time) as f32 / 8.0)
|
|
|
|
.floor()
|
|
|
|
.mul(1337.0)
|
|
|
|
.sin()
|
|
|
|
* 0.25,
|
|
|
|
);
|
2019-10-23 02:56:45 +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) / 11.0;
|
|
|
|
next.head.ori = Quaternion::rotation_z(duck_head_look.x)
|
|
|
|
* Quaternion::rotation_x(duck_head_look.y + wave_slow_cos * 0.03);
|
|
|
|
next.head.scale = Vec3::one();
|
2019-10-23 02:56:45 +00:00
|
|
|
|
2020-01-26 00:22:48 +00:00
|
|
|
next.torso.offset = Vec3::new(
|
|
|
|
0.0,
|
|
|
|
skeleton_attr.chest.0,
|
|
|
|
wave_slow * 0.3 + skeleton_attr.chest.1,
|
|
|
|
) / 11.0;
|
|
|
|
next.torso.ori = Quaternion::rotation_y(wave_slow * 0.03);
|
|
|
|
next.torso.scale = Vec3::one() / 11.0;
|
2019-10-23 02:56:45 +00:00
|
|
|
|
2020-01-26 00:22:48 +00:00
|
|
|
next.tail.offset = Vec3::new(0.0, skeleton_attr.tail.0, skeleton_attr.tail.1) / 11.0;
|
|
|
|
next.tail.ori = Quaternion::rotation_x(wave_slow_cos * 0.03);
|
|
|
|
next.tail.scale = Vec3::one();
|
|
|
|
|
|
|
|
next.wing_l.offset = Vec3::new(
|
|
|
|
-skeleton_attr.wing.0,
|
|
|
|
skeleton_attr.wing.1,
|
|
|
|
skeleton_attr.wing.2,
|
|
|
|
) / 11.0;
|
|
|
|
next.wing_l.ori = Quaternion::rotation_z(0.0);
|
|
|
|
next.wing_l.scale = Vec3::one() * 1.05;
|
|
|
|
|
|
|
|
next.wing_r.offset = Vec3::new(
|
|
|
|
skeleton_attr.wing.0,
|
|
|
|
skeleton_attr.wing.1,
|
|
|
|
skeleton_attr.wing.2,
|
|
|
|
) / 11.0;
|
2019-10-25 23:18:34 +00:00
|
|
|
next.wing_r.ori = Quaternion::rotation_y(0.0);
|
2020-01-26 00:22:48 +00:00
|
|
|
next.wing_r.scale = Vec3::one() * 1.05;
|
2019-10-23 02:56:45 +00:00
|
|
|
|
2020-01-26 00:22:48 +00:00
|
|
|
next.leg_l.offset = Vec3::new(
|
|
|
|
-skeleton_attr.foot.0,
|
|
|
|
skeleton_attr.foot.1,
|
|
|
|
skeleton_attr.foot.2,
|
|
|
|
) / 11.0;
|
2019-10-25 23:18:34 +00:00
|
|
|
next.leg_l.ori = Quaternion::rotation_y(0.0);
|
2020-01-26 00:22:48 +00:00
|
|
|
next.leg_l.scale = Vec3::one() / 11.0;
|
2019-10-23 02:56:45 +00:00
|
|
|
|
2020-01-26 00:22:48 +00:00
|
|
|
next.leg_r.offset = Vec3::new(
|
|
|
|
skeleton_attr.foot.0,
|
|
|
|
skeleton_attr.foot.1,
|
|
|
|
skeleton_attr.foot.2,
|
|
|
|
) / 11.0;
|
2019-10-25 23:18:34 +00:00
|
|
|
next.leg_r.ori = Quaternion::rotation_x(0.0);
|
2020-01-26 00:22:48 +00:00
|
|
|
next.leg_r.scale = Vec3::one() / 11.0;
|
2019-10-23 02:56:45 +00:00
|
|
|
next
|
|
|
|
}
|
|
|
|
}
|