veloren_voxygen_anim/quadruped_small/
feed.rs1use super::{
2 super::{Animation, vek::*},
3 QuadrupedSmallSkeleton, SkeletonAttr,
4};
5use std::{f32::consts::PI, ops::Mul};
6
7pub struct FeedAnimation;
8
9impl Animation for FeedAnimation {
10 type Dependency<'a> = f32;
11 type Skeleton = QuadrupedSmallSkeleton;
12
13 #[cfg(feature = "use-dyn-lib")]
14 const UPDATE_FN: &'static [u8] = b"quadruped_small_feed\0";
15
16 #[cfg_attr(feature = "be-dyn-lib", export_name = "quadruped_small_feed")]
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 slow = (anim_time * 5.0).sin();
27 let quick = (anim_time * 14.0).sin();
28
29 let slow_alt = (anim_time * 3.5 + PI).sin();
30
31 let head_look = Vec2::new(
32 (global_time / 2.0 + anim_time / 2.0)
33 .floor()
34 .mul(7331.0)
35 .sin()
36 * 1.0,
37 (global_time / 2.0 + anim_time / 2.0)
38 .floor()
39 .mul(1337.0)
40 .sin()
41 * 0.5,
42 );
43
44 next.head.position = Vec3::new(0.0, s_a.head.0 + 1.5, s_a.head.1 + slow * 0.2);
45 next.head.orientation = Quaternion::rotation_z(head_look.y)
46 * Quaternion::rotation_x(slow * 0.05 + quick * 0.08 - 0.4 * s_a.feed);
47
48 next.chest.position = Vec3::new(slow * 0.02, s_a.chest.0, s_a.chest.1);
49 next.chest.orientation =
50 Quaternion::rotation_x(-0.35 * s_a.feed) * Quaternion::rotation_y(head_look.y * 0.1);
51
52 next.leg_fl.position = Vec3::new(-s_a.feet_f.0, s_a.feet_f.1, s_a.feet_f.2 + 0.5);
53 next.leg_fl.orientation = Quaternion::rotation_x(slow * 0.01 + 0.25 * s_a.feed)
54 * Quaternion::rotation_y(slow * -0.02 - head_look.y * 0.1);
55
56 next.leg_fr.position = Vec3::new(s_a.feet_f.0, s_a.feet_f.1, s_a.feet_f.2 + 0.5);
57 next.leg_fr.orientation = Quaternion::rotation_x(slow_alt * 0.01 + 0.25 * s_a.feed)
58 * Quaternion::rotation_y(slow * -0.02 - head_look.y * 0.1);
59
60 next.leg_bl.position = Vec3::new(-s_a.feet_b.0, s_a.feet_b.1 + 1.0, s_a.feet_b.2 - 1.0);
61 next.leg_bl.orientation = Quaternion::rotation_x(slow_alt * 0.01 + 0.15 * s_a.feed)
62 * Quaternion::rotation_y(slow * -0.02 - head_look.y * 0.1);
63
64 next.leg_br.position = Vec3::new(s_a.feet_b.0, s_a.feet_b.1 + 1.0, s_a.feet_b.2 - 1.0);
65 next.leg_br.orientation = Quaternion::rotation_x(slow * 0.01 + 0.15 * s_a.feed)
66 * Quaternion::rotation_y(slow * -0.02 - head_look.y * 0.1);
67
68 next.tail.position = Vec3::new(0.0, s_a.tail.0, s_a.tail.1);
69 next.tail.orientation = Quaternion::rotation_z(slow * 0.3 + head_look.y * 0.3);
70
71 next
72 }
73}