veloren_voxygen_anim/biped_small/
idle.rs1use super::{
2 super::{Animation, vek::*},
3 BipedSmallSkeleton, SkeletonAttr,
4};
5use core::f32::consts::PI;
6
7pub struct IdleAnimation;
8
9type IdleAnimationDependency = (Vec3<f32>, Vec3<f32>, Vec3<f32>, f32, Vec3<f32>);
10
11impl Animation for IdleAnimation {
12 type Dependency<'a> = IdleAnimationDependency;
13 type Skeleton = BipedSmallSkeleton;
14
15 #[cfg(feature = "use-dyn-lib")]
16 const UPDATE_FN: &'static [u8] = b"biped_small_idle\0";
17
18 #[cfg_attr(feature = "be-dyn-lib", unsafe(export_name = "biped_small_idle"))]
19 fn update_skeleton_inner(
20 skeleton: &Self::Skeleton,
21 (_velocity, _orientation, _last_ori, _global_time, _avg_vel): Self::Dependency<'_>,
22 anim_time: f32,
23 _rate: &mut f32,
24 s_a: &SkeletonAttr,
25 ) -> Self::Skeleton {
26 let mut next = (*skeleton).clone();
27 let slow = (anim_time * 4.0).sin();
28 let medium = (anim_time * 10.0).sin();
29
30 next.head.position = Vec3::new(0.0, s_a.head.0, s_a.head.1 + slow * -0.1);
31
32 next.chest.position = Vec3::new(0.0, s_a.chest.0, s_a.chest.1 + slow * 0.3);
33 next.pants.position = Vec3::new(0.0, s_a.pants.0, s_a.pants.1);
34 next.main.position = Vec3::new(4.0, -4.0, -3.0);
35 next.main.orientation = Quaternion::rotation_y(-0.5) * Quaternion::rotation_z(PI / 2.0);
36 next.second.position = Vec3::new(-4.0, -4.0, -3.0);
37 next.second.orientation = Quaternion::rotation_y(0.5) * Quaternion::rotation_z(-PI / 2.0);
38
39 next.tail.position = Vec3::new(0.0, s_a.tail.0, s_a.tail.1);
40 next.hand_l.position = Vec3::new(-s_a.hand.0, s_a.hand.1, s_a.hand.2 + slow * -0.1);
41 next.hand_r.position = Vec3::new(s_a.hand.0, s_a.hand.1, s_a.hand.2 + slow * -0.1);
42
43 if s_a.wing_for_foot {
44 next.foot_l.position = Vec3::new(-s_a.foot.0, s_a.foot.1, s_a.foot.2);
45 next.foot_l.orientation =
46 Quaternion::rotation_x(-0.6 - medium * 0.6) * Quaternion::rotation_z(medium * 0.4);
47
48 next.foot_r.position = Vec3::new(s_a.foot.0, s_a.foot.1, s_a.foot.2);
49 next.foot_r.orientation =
50 Quaternion::rotation_x(-0.6 - medium * 0.6) * Quaternion::rotation_z(medium * -0.4);
51 } else {
52 next.foot_l.position = Vec3::new(-s_a.foot.0, s_a.foot.1, s_a.foot.2);
53 next.foot_r.position = Vec3::new(s_a.foot.0, s_a.foot.1, s_a.foot.2);
54 }
55
56 next
57 }
58}