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", export_name = "biped_small_idle")]
19
20 fn update_skeleton_inner(
21 skeleton: &Self::Skeleton,
22 (_velocity, _orientation, _last_ori, _global_time, _avg_vel): Self::Dependency<'_>,
23 anim_time: f32,
24 _rate: &mut f32,
25 s_a: &SkeletonAttr,
26 ) -> Self::Skeleton {
27 let mut next = (*skeleton).clone();
28 let slow = (anim_time * 4.0).sin();
29 let medium = (anim_time * 10.0).sin();
30
31 next.head.position = Vec3::new(0.0, s_a.head.0, s_a.head.1 + slow * -0.1);
32
33 next.chest.position = Vec3::new(0.0, s_a.chest.0, s_a.chest.1 + slow * 0.3);
34 next.pants.position = Vec3::new(0.0, s_a.pants.0, s_a.pants.1);
35 next.main.position = Vec3::new(2.0, -3.0, -3.0);
36 next.main.orientation = Quaternion::rotation_y(-0.5) * Quaternion::rotation_z(PI / 2.0);
37
38 next.tail.position = Vec3::new(0.0, s_a.tail.0, s_a.tail.1);
39 next.hand_l.position = Vec3::new(-s_a.hand.0, s_a.hand.1, s_a.hand.2 + slow * -0.1);
40 next.hand_r.position = Vec3::new(s_a.hand.0, s_a.hand.1, s_a.hand.2 + slow * -0.1);
41
42 if s_a.wing_for_foot {
43 next.foot_l.position = Vec3::new(-s_a.foot.0, s_a.foot.1, s_a.foot.2);
44 next.foot_l.orientation =
45 Quaternion::rotation_x(-0.6 - medium * 0.6) * Quaternion::rotation_z(medium * 0.4);
46
47 next.foot_r.position = Vec3::new(s_a.foot.0, s_a.foot.1, s_a.foot.2);
48 next.foot_r.orientation =
49 Quaternion::rotation_x(-0.6 - medium * 0.6) * Quaternion::rotation_z(medium * -0.4);
50 } else {
51 next.foot_l.position = Vec3::new(-s_a.foot.0, s_a.foot.1, s_a.foot.2);
52 next.foot_r.position = Vec3::new(s_a.foot.0, s_a.foot.1, s_a.foot.2);
53 }
54
55 next
56 }
57}