veloren_voxygen_anim/quadruped_medium/
idle.rs1use super::{
2 super::{Animation, vek::*},
3 QuadrupedMediumSkeleton, SkeletonAttr,
4};
5use std::{f32::consts::PI, ops::Mul};
6
7pub struct IdleAnimation;
8
9impl Animation for IdleAnimation {
10 type Dependency<'a> = f32;
11 type Skeleton = QuadrupedMediumSkeleton;
12
13 #[cfg(feature = "use-dyn-lib")]
14 const UPDATE_FN: &'static [u8] = b"quadruped_medium_idle\0";
15
16 #[cfg_attr(feature = "be-dyn-lib", export_name = "quadruped_medium_idle")]
17 fn update_skeleton_inner(
18 skeleton: &Self::Skeleton,
19 global_time: Self::Dependency<'_>,
20 anim_time: f32,
21 _rate: &mut f32,
22 s_a: &SkeletonAttr,
23 ) -> Self::Skeleton {
24 let mut next = (*skeleton).clone();
25
26 let slower = (anim_time * 1.0 + PI).sin();
27 let slow = (anim_time * 3.5 + PI).sin();
28
29 let look = Vec2::new(
30 (global_time / 2.0 + anim_time / 8.0)
31 .floor()
32 .mul(7331.0)
33 .sin()
34 * 0.5,
35 (global_time / 2.0 + anim_time / 8.0)
36 .floor()
37 .mul(1337.0)
38 .sin()
39 * 0.25,
40 );
41 let tailmove = Vec2::new(
42 (global_time / 2.0 + anim_time / 2.0)
43 .floor()
44 .mul(7331.0)
45 .sin()
46 * 0.25,
47 (global_time / 2.0 + anim_time / 2.0)
48 .floor()
49 .mul(1337.0)
50 .sin()
51 * 0.125,
52 );
53
54 next.neck.scale = Vec3::one() * 1.02;
55 next.jaw.scale = Vec3::one() * 1.02;
56 next.leg_fl.scale = Vec3::one() * 1.02;
57 next.leg_fr.scale = Vec3::one() * 1.02;
58 next.leg_bl.scale = Vec3::one() * 1.02;
59 next.leg_br.scale = Vec3::one() * 1.02;
60 next.foot_fl.scale = Vec3::one() * 0.96;
61 next.foot_fr.scale = Vec3::one() * 0.96;
62 next.foot_bl.scale = Vec3::one() * 0.96;
63 next.foot_br.scale = Vec3::one() * 0.96;
64 next.ears.scale = Vec3::one() * 1.02;
65
66 next.head.position = Vec3::new(0.0, s_a.head.0, s_a.head.1 + slower * 0.2);
67 next.head.orientation =
68 Quaternion::rotation_z(0.3 * look.x) * Quaternion::rotation_x(0.3 * look.y);
69
70 next.neck.position = Vec3::new(0.0, s_a.neck.0, s_a.neck.1 + slower * 0.1);
71
72 next.jaw.position = Vec3::new(0.0, s_a.jaw.0 - slower * 0.12, s_a.jaw.1 + slow * 0.2);
73 next.jaw.orientation = Quaternion::rotation_x(slow * 0.05 - 0.08);
74 next.jaw.scale = Vec3::one() * 1.02;
75
76 next.tail.position = Vec3::new(0.0, s_a.tail.0, s_a.tail.1);
77 next.tail.orientation =
78 Quaternion::rotation_z(0.0 + slow * 0.2 + tailmove.x) * Quaternion::rotation_x(0.0);
79
80 next.torso_front.position =
81 Vec3::new(0.0, s_a.torso_front.0, s_a.torso_front.1 + slower * 0.3);
82 next.torso_front.orientation = Quaternion::rotation_y(slow * 0.02);
83
84 next.torso_back.position =
85 Vec3::new(0.0, s_a.torso_back.0, s_a.torso_back.1 + slower * 0.2);
86 next.torso_back.orientation = Quaternion::rotation_y(-slow * 0.005);
87
88 next.ears.position = Vec3::new(0.0, s_a.ears.0, s_a.ears.1);
89 next.ears.orientation = Quaternion::rotation_x(0.0 + slower * 0.03);
90
91 next.leg_fl.position = Vec3::new(
92 -s_a.leg_f.0,
93 s_a.leg_f.1,
94 s_a.leg_f.2 + slow * -0.15 + slower * -0.15,
95 );
96 next.leg_fl.orientation = Quaternion::rotation_y(slow * -0.02);
97 next.leg_fl.scale = Vec3::one() * 1.02;
98
99 next.leg_fr.position = Vec3::new(
100 s_a.leg_f.0,
101 s_a.leg_f.1,
102 s_a.leg_f.2 + slow * 0.15 + slower * -0.15,
103 );
104 next.leg_fr.orientation = Quaternion::rotation_y(slow * -0.02);
105
106 next.leg_bl.position = Vec3::new(-s_a.leg_b.0, s_a.leg_b.1, s_a.leg_b.2 + slower * -0.3);
107 next.leg_bl.orientation = Quaternion::rotation_y(slow * -0.02);
108
109 next.leg_br.position = Vec3::new(s_a.leg_b.0, s_a.leg_b.1, s_a.leg_b.2 + slower * -0.3);
110 next.leg_br.orientation = Quaternion::rotation_y(slow * -0.02);
111
112 next.foot_fl.position =
113 Vec3::new(-s_a.feet_f.0, s_a.feet_f.1, s_a.feet_f.2 + slower * -0.2);
114
115 next.foot_fr.position = Vec3::new(s_a.feet_f.0, s_a.feet_f.1, s_a.feet_f.2 + slower * -0.2);
116
117 next.foot_bl.position =
118 Vec3::new(-s_a.feet_b.0, s_a.feet_b.1, s_a.feet_b.2 + slower * -0.2);
119
120 next.foot_br.position = Vec3::new(s_a.feet_b.0, s_a.feet_b.1, s_a.feet_b.2 + slower * -0.2);
121
122 next
123 }
124}