veloren/voxygen/src/anim/bird_medium/idle.rs

87 lines
2.7 KiB
Rust
Raw Normal View History

2020-01-26 00:22:48 +00:00
use super::{super::Animation, BirdMediumSkeleton, SkeletonAttr};
use std::ops::Mul;
use vek::*;
pub struct IdleAnimation;
impl Animation for IdleAnimation {
type Skeleton = BirdMediumSkeleton;
type Dependency = f64;
fn update_skeleton(
skeleton: &Self::Skeleton,
2020-01-26 00:22:48 +00:00
global_time: Self::Dependency,
anim_time: f64,
_rate: &mut f32,
2020-01-26 00:22:48 +00:00
skeleton_attr: &SkeletonAttr,
) -> Self::Skeleton {
let mut next = (*skeleton).clone();
2020-01-29 06:38:08 +00:00
let wave_slow = (anim_time as f32 * 4.5).sin();
let wave_slow_cos = (anim_time as f32 * 4.5).cos();
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,
);
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)
2020-01-29 06:38:08 +00:00
* Quaternion::rotation_x(-duck_head_look.y.abs() + wave_slow_cos * 0.03);
2020-01-26 00:22:48 +00:00
next.head.scale = Vec3::one();
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;
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;
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;
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;
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;
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;
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;
next
}
}