2020-06-01 23:56:50 +00:00
|
|
|
use super::{super::Animation, QuadrupedLowSkeleton, SkeletonAttr};
|
|
|
|
use std::{f32::consts::PI, ops::Mul};
|
|
|
|
use vek::*;
|
|
|
|
|
|
|
|
pub struct IdleAnimation;
|
|
|
|
|
|
|
|
impl Animation for IdleAnimation {
|
|
|
|
type Dependency = f64;
|
|
|
|
type Skeleton = QuadrupedLowSkeleton;
|
|
|
|
|
|
|
|
fn update_skeleton(
|
|
|
|
skeleton: &Self::Skeleton,
|
|
|
|
global_time: Self::Dependency,
|
|
|
|
anim_time: f64,
|
|
|
|
_rate: &mut f32,
|
|
|
|
skeleton_attr: &SkeletonAttr,
|
|
|
|
) -> Self::Skeleton {
|
|
|
|
let mut next = (*skeleton).clone();
|
|
|
|
|
2020-06-05 02:04:07 +00:00
|
|
|
let ultra_slow = 0.0*(anim_time as f32 * 1.0).sin();
|
|
|
|
let slow = 0.0*(anim_time as f32 * 2.5).sin();
|
2020-06-06 03:23:09 +00:00
|
|
|
let slowalt = (anim_time as f32 * 2.5 + PI / 2.0).sin();
|
2020-06-01 23:56:50 +00:00
|
|
|
|
|
|
|
let dragon_look = Vec2::new(
|
|
|
|
((global_time + anim_time) as f32 / 8.0)
|
|
|
|
.floor()
|
|
|
|
.mul(7331.0)
|
|
|
|
.sin()
|
2020-06-06 03:23:09 +00:00
|
|
|
* 0.2,
|
2020-06-01 23:56:50 +00:00
|
|
|
((global_time + anim_time) as f32 / 8.0)
|
|
|
|
.floor()
|
|
|
|
.mul(1337.0)
|
|
|
|
.sin()
|
2020-06-06 03:23:09 +00:00
|
|
|
* 0.1,
|
2020-06-01 23:56:50 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
next.head_upper.offset = Vec3::new(
|
|
|
|
0.0,
|
|
|
|
skeleton_attr.head_upper.0,
|
|
|
|
skeleton_attr.head_upper.1 + ultra_slow * 0.20,
|
|
|
|
);
|
|
|
|
next.head_upper.ori = Quaternion::rotation_z(0.8 * dragon_look.x)
|
|
|
|
* Quaternion::rotation_x(0.8 * dragon_look.y);
|
|
|
|
next.head_upper.scale = Vec3::one();
|
|
|
|
|
|
|
|
next.head_lower.offset = Vec3::new(
|
|
|
|
0.0,
|
|
|
|
skeleton_attr.head_lower.0,
|
|
|
|
skeleton_attr.head_lower.1 + ultra_slow * 0.20,
|
|
|
|
);
|
|
|
|
next.head_lower.ori = Quaternion::rotation_z(0.8 * dragon_look.x)
|
2020-06-05 02:04:07 +00:00
|
|
|
* Quaternion::rotation_x( 0.8 * dragon_look.y);
|
|
|
|
next.head_lower.scale = Vec3::one();
|
2020-06-01 23:56:50 +00:00
|
|
|
|
|
|
|
next.jaw.offset = Vec3::new(0.0, skeleton_attr.jaw.0, skeleton_attr.jaw.1);
|
|
|
|
next.jaw.ori = Quaternion::rotation_x(slow * 0.04);
|
2020-06-05 02:04:07 +00:00
|
|
|
next.jaw.scale = Vec3::one()*0.98;
|
2020-06-01 23:56:50 +00:00
|
|
|
|
2020-06-04 21:15:38 +00:00
|
|
|
next.chest.offset = Vec3::new(
|
2020-06-01 23:56:50 +00:00
|
|
|
0.0,
|
2020-06-04 21:15:38 +00:00
|
|
|
skeleton_attr.chest.0,
|
|
|
|
skeleton_attr.chest.1,
|
2020-06-05 02:04:07 +00:00
|
|
|
)/6.0;
|
2020-06-04 21:15:38 +00:00
|
|
|
next.chest.ori = Quaternion::rotation_y(slow * 0.01);
|
2020-06-05 02:04:07 +00:00
|
|
|
next.chest.scale = Vec3::one() /6.0;
|
2020-06-01 23:56:50 +00:00
|
|
|
|
|
|
|
next.tail_front.offset =
|
|
|
|
Vec3::new(0.0, skeleton_attr.tail_front.0, skeleton_attr.tail_front.1);
|
2020-06-06 03:23:09 +00:00
|
|
|
next.tail_front.ori = Quaternion::rotation_x(0.15)*Quaternion::rotation_z(slowalt * 0.12);
|
2020-06-05 02:04:07 +00:00
|
|
|
next.tail_front.scale = Vec3::one()*0.98;
|
2020-06-01 23:56:50 +00:00
|
|
|
|
|
|
|
next.tail_rear.offset =
|
|
|
|
Vec3::new(0.0, skeleton_attr.tail_rear.0, skeleton_attr.tail_rear.1);
|
2020-06-06 03:23:09 +00:00
|
|
|
next.tail_rear.ori = Quaternion::rotation_z(slowalt * 0.12)*Quaternion::rotation_x(-0.12);
|
2020-06-05 02:04:07 +00:00
|
|
|
next.tail_rear.scale = Vec3::one()*0.98;
|
2020-06-01 23:56:50 +00:00
|
|
|
|
|
|
|
next.foot_fl.offset = Vec3::new(
|
|
|
|
-skeleton_attr.feet_f.0,
|
|
|
|
skeleton_attr.feet_f.1,
|
|
|
|
skeleton_attr.feet_f.2,
|
|
|
|
);
|
|
|
|
next.foot_fl.ori = Quaternion::rotation_x(0.0);
|
|
|
|
next.foot_fl.scale = Vec3::one();
|
|
|
|
|
|
|
|
next.foot_fr.offset = Vec3::new(
|
|
|
|
skeleton_attr.feet_f.0,
|
|
|
|
skeleton_attr.feet_f.1,
|
|
|
|
skeleton_attr.feet_f.2,
|
|
|
|
);
|
|
|
|
next.foot_fr.ori = Quaternion::rotation_x(0.0);
|
|
|
|
next.foot_fr.scale = Vec3::one();
|
|
|
|
|
|
|
|
next.foot_bl.offset = Vec3::new(
|
|
|
|
-skeleton_attr.feet_b.0,
|
|
|
|
skeleton_attr.feet_b.1,
|
|
|
|
skeleton_attr.feet_b.2,
|
|
|
|
);
|
|
|
|
next.foot_bl.ori = Quaternion::rotation_x(0.0);
|
|
|
|
next.foot_bl.scale = Vec3::one();
|
|
|
|
|
|
|
|
next.foot_br.offset = Vec3::new(
|
|
|
|
skeleton_attr.feet_b.0,
|
|
|
|
skeleton_attr.feet_b.1,
|
|
|
|
skeleton_attr.feet_b.2,
|
|
|
|
);
|
|
|
|
next.foot_br.ori = Quaternion::rotation_x(0.0);
|
|
|
|
next.foot_br.scale = Vec3::one();
|
|
|
|
|
|
|
|
next
|
|
|
|
}
|
|
|
|
}
|