2020-01-26 00:22:48 +00:00
|
|
|
use super::{super::Animation, BipedLargeSkeleton, SkeletonAttr};
|
2020-01-29 06:38:08 +00:00
|
|
|
use std::{f32::consts::PI, ops::Mul};
|
2019-10-24 01:10:26 +00:00
|
|
|
use vek::*;
|
|
|
|
|
|
|
|
pub struct IdleAnimation;
|
|
|
|
|
|
|
|
impl Animation for IdleAnimation {
|
|
|
|
type Skeleton = BipedLargeSkeleton;
|
2019-11-04 17:26:32 +00:00
|
|
|
type Dependency = f64;
|
2019-10-24 01:10:26 +00:00
|
|
|
|
|
|
|
fn update_skeleton(
|
|
|
|
skeleton: &Self::Skeleton,
|
2020-01-29 06:38:08 +00:00
|
|
|
global_time: Self::Dependency,
|
|
|
|
anim_time: f64,
|
2019-10-24 01:10:26 +00:00
|
|
|
_rate: &mut f32,
|
2020-01-29 06:38:08 +00:00
|
|
|
skeleton_attr: &SkeletonAttr,
|
2019-10-24 01:10:26 +00:00
|
|
|
) -> Self::Skeleton {
|
|
|
|
let mut next = (*skeleton).clone();
|
|
|
|
|
2020-01-29 06:38:08 +00:00
|
|
|
let lab = 1.0;
|
|
|
|
let torso = (anim_time as f32 * lab as f32 + 1.5 * PI).sin();
|
2019-10-24 01:10:26 +00:00
|
|
|
|
2020-01-29 06:38:08 +00:00
|
|
|
let 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,
|
|
|
|
);
|
|
|
|
|
|
|
|
next.head.offset = Vec3::new(
|
|
|
|
0.0,
|
|
|
|
skeleton_attr.head.0,
|
|
|
|
skeleton_attr.head.1 + torso * 0.6,
|
|
|
|
) / 8.0;
|
|
|
|
next.head.ori = Quaternion::rotation_z(look.x * 0.6) * Quaternion::rotation_x(look.y * 0.6);
|
|
|
|
next.head.scale = Vec3::one() / 8.0;
|
|
|
|
|
|
|
|
next.upper_torso.offset = Vec3::new(
|
|
|
|
0.0,
|
|
|
|
skeleton_attr.upper_torso.0,
|
|
|
|
skeleton_attr.upper_torso.1 + torso * 0.5,
|
|
|
|
) / 8.0;
|
2019-10-25 23:18:34 +00:00
|
|
|
next.upper_torso.ori = Quaternion::rotation_z(0.0) * Quaternion::rotation_x(0.0);
|
2020-01-29 06:38:08 +00:00
|
|
|
next.upper_torso.scale = Vec3::one() / 8.0;
|
2019-10-24 01:10:26 +00:00
|
|
|
|
2020-01-29 06:38:08 +00:00
|
|
|
next.lower_torso.offset = Vec3::new(
|
|
|
|
0.0,
|
|
|
|
skeleton_attr.lower_torso.0,
|
|
|
|
skeleton_attr.lower_torso.1 + torso * 0.35,
|
|
|
|
);
|
2019-10-25 23:18:34 +00:00
|
|
|
next.lower_torso.ori = Quaternion::rotation_z(0.0) * Quaternion::rotation_x(0.0);
|
2020-01-29 06:38:08 +00:00
|
|
|
next.lower_torso.scale = Vec3::one() * 1.02;
|
2019-10-24 01:10:26 +00:00
|
|
|
|
2020-01-29 06:38:08 +00:00
|
|
|
next.shoulder_l.offset = Vec3::new(
|
|
|
|
-skeleton_attr.shoulder.0,
|
|
|
|
skeleton_attr.shoulder.1,
|
|
|
|
skeleton_attr.shoulder.2,
|
|
|
|
);
|
2019-10-25 23:18:34 +00:00
|
|
|
next.shoulder_l.ori = Quaternion::rotation_z(0.0) * Quaternion::rotation_x(0.0);
|
2020-01-26 00:22:48 +00:00
|
|
|
next.shoulder_l.scale = Vec3::one();
|
2019-10-24 01:10:26 +00:00
|
|
|
|
2020-01-29 06:38:08 +00:00
|
|
|
next.shoulder_r.offset = Vec3::new(
|
|
|
|
skeleton_attr.shoulder.0,
|
|
|
|
skeleton_attr.shoulder.1,
|
|
|
|
skeleton_attr.shoulder.2,
|
|
|
|
);
|
2019-10-25 23:18:34 +00:00
|
|
|
next.shoulder_r.ori = Quaternion::rotation_z(0.0) * Quaternion::rotation_x(0.0);
|
2020-01-26 00:22:48 +00:00
|
|
|
next.shoulder_r.scale = Vec3::one();
|
2019-10-24 01:10:26 +00:00
|
|
|
|
2020-01-29 06:38:08 +00:00
|
|
|
next.hand_l.offset = Vec3::new(
|
|
|
|
-skeleton_attr.hand.0,
|
|
|
|
skeleton_attr.hand.1,
|
|
|
|
skeleton_attr.hand.2 + torso * 0.6,
|
|
|
|
);
|
2019-10-25 23:18:34 +00:00
|
|
|
next.hand_l.ori = Quaternion::rotation_z(0.0) * Quaternion::rotation_x(0.0);
|
2020-01-26 00:22:48 +00:00
|
|
|
next.hand_l.scale = Vec3::one();
|
2019-10-24 01:10:26 +00:00
|
|
|
|
2020-01-29 06:38:08 +00:00
|
|
|
next.hand_r.offset = Vec3::new(
|
|
|
|
skeleton_attr.hand.0,
|
|
|
|
skeleton_attr.hand.1,
|
|
|
|
skeleton_attr.hand.2 + torso * 0.6,
|
|
|
|
);
|
2019-10-25 23:18:34 +00:00
|
|
|
next.hand_r.ori = Quaternion::rotation_z(0.0) * Quaternion::rotation_x(0.0);
|
2020-01-26 00:22:48 +00:00
|
|
|
next.hand_r.scale = Vec3::one();
|
2019-10-24 01:10:26 +00:00
|
|
|
|
2020-01-29 06:38:08 +00:00
|
|
|
next.leg_l.offset = Vec3::new(
|
|
|
|
-skeleton_attr.leg.0,
|
|
|
|
skeleton_attr.leg.1,
|
|
|
|
skeleton_attr.leg.2 + torso * 0.2,
|
|
|
|
) / 8.0;
|
2019-10-25 23:18:34 +00:00
|
|
|
next.leg_l.ori = Quaternion::rotation_z(0.0) * Quaternion::rotation_x(0.0);
|
2020-01-29 06:38:08 +00:00
|
|
|
next.leg_l.scale = Vec3::one() / 8.0;
|
2019-10-24 01:10:26 +00:00
|
|
|
|
2020-01-29 06:38:08 +00:00
|
|
|
next.leg_r.offset = Vec3::new(
|
|
|
|
skeleton_attr.leg.0,
|
|
|
|
skeleton_attr.leg.1,
|
|
|
|
skeleton_attr.leg.2 + torso * 0.2,
|
|
|
|
) / 8.0;
|
2019-10-25 23:18:34 +00:00
|
|
|
next.leg_r.ori = Quaternion::rotation_z(0.0) * Quaternion::rotation_x(0.0);
|
2020-01-29 06:38:08 +00:00
|
|
|
next.leg_r.scale = Vec3::one() / 8.0;
|
2019-10-24 01:10:26 +00:00
|
|
|
|
2020-01-29 06:38:08 +00:00
|
|
|
next.foot_l.offset = Vec3::new(
|
|
|
|
-skeleton_attr.foot.0,
|
|
|
|
skeleton_attr.foot.1,
|
|
|
|
skeleton_attr.foot.2,
|
|
|
|
) / 8.0;
|
2019-10-25 23:18:34 +00:00
|
|
|
next.foot_l.ori = Quaternion::rotation_z(0.0) * Quaternion::rotation_x(0.0);
|
2020-01-29 06:38:08 +00:00
|
|
|
next.foot_l.scale = Vec3::one() / 8.0;
|
2019-10-24 01:10:26 +00:00
|
|
|
|
2020-01-29 06:38:08 +00:00
|
|
|
next.foot_r.offset = Vec3::new(
|
|
|
|
skeleton_attr.foot.0,
|
|
|
|
skeleton_attr.foot.1,
|
|
|
|
skeleton_attr.foot.2,
|
|
|
|
) / 8.0;
|
2019-10-25 23:18:34 +00:00
|
|
|
next.foot_r.ori = Quaternion::rotation_z(0.0) * Quaternion::rotation_x(0.0);
|
2020-01-29 06:38:08 +00:00
|
|
|
next.foot_r.scale = Vec3::one() / 8.0;
|
|
|
|
|
|
|
|
next.torso.offset = Vec3::new(0.0, 0.0, 0.0);
|
|
|
|
next.torso.ori = Quaternion::rotation_z(0.0) * Quaternion::rotation_x(0.0);
|
|
|
|
next.torso.scale = Vec3::one();
|
2019-10-24 01:10:26 +00:00
|
|
|
next
|
|
|
|
}
|
|
|
|
}
|