veloren_voxygen_anim/crustacean/
idle.rs1use super::{
2 super::{Animation, vek::*},
3 CrustaceanSkeleton, SkeletonAttr,
4};
5
6pub struct IdleAnimation;
7
8impl Animation for IdleAnimation {
9 type Dependency<'a> = f32;
10 type Skeleton = CrustaceanSkeleton;
11
12 #[cfg(feature = "use-dyn-lib")]
13 const UPDATE_FN: &'static [u8] = b"crustacean_idle\0";
14
15 #[cfg_attr(feature = "be-dyn-lib", export_name = "crustacean_idle")]
16 fn update_skeleton_inner(
17 skeleton: &Self::Skeleton,
18 _global_time: Self::Dependency<'_>,
19 anim_time: f32,
20 _rate: &mut f32,
21 s_a: &SkeletonAttr,
22 ) -> Self::Skeleton {
23 let mut next = (*skeleton).clone();
24
25 next.chest.scale = Vec3::one() * s_a.scaler;
26
27 next.chest.position = Vec3::new(0.0, s_a.chest.0, s_a.chest.1);
28
29 let arm = (anim_time * 0.2).sin() * 0.03;
30 let clasp_l =
31 (((anim_time * 0.1).fract() * 2.0 - 1.0) * (anim_time * 2.0).sin().powi(2)).powi(16);
32 let clasp_r = (((anim_time * 0.105 + 33.0).fract() * 2.0 - 1.0)
33 * (anim_time * 1.95 + 20.0).sin().powi(2))
34 .powi(16);
35
36 next.arm_l.position = Vec3::zero();
37 next.arm_l.orientation = Quaternion::rotation_x(arm);
38 next.arm_r.position = Vec3::zero();
39 next.arm_r.orientation = Quaternion::rotation_x(arm);
40
41 next.pincer_l0.position = Vec3::zero();
42 next.pincer_l1.position = Vec3::zero();
43 next.pincer_l1.orientation = Quaternion::rotation_z(clasp_l * 0.15);
44 next.pincer_r0.position = Vec3::zero();
45 next.pincer_r1.position = Vec3::zero();
46 next.pincer_r1.orientation = Quaternion::rotation_z(-clasp_r * 0.15);
47
48 next.leg_fl.position = Vec3::new(-s_a.leg_f.0, s_a.leg_f.1, s_a.leg_f.2);
49 next.leg_fr.position = Vec3::new(s_a.leg_f.0, s_a.leg_f.1, s_a.leg_f.2);
50 next.leg_fl.orientation = Quaternion::rotation_z(s_a.leg_ori.0);
51 next.leg_fr.orientation = Quaternion::rotation_z(-s_a.leg_ori.0);
52
53 next.leg_cl.position = Vec3::new(-s_a.leg_c.0, s_a.leg_c.1, s_a.leg_c.2);
54 next.leg_cr.position = Vec3::new(s_a.leg_c.0, s_a.leg_c.1, s_a.leg_c.2);
55 next.leg_cl.orientation = Quaternion::rotation_z(s_a.leg_ori.1);
56 next.leg_cr.orientation = Quaternion::rotation_z(-s_a.leg_ori.1);
57
58 next.leg_bl.position = Vec3::new(-s_a.leg_b.0, s_a.leg_b.1, s_a.leg_b.2);
59 next.leg_br.position = Vec3::new(s_a.leg_b.0, s_a.leg_b.1, s_a.leg_b.2);
60 next.leg_bl.orientation = Quaternion::rotation_z(s_a.leg_ori.2);
61 next.leg_br.orientation = Quaternion::rotation_z(-s_a.leg_ori.2);
62
63 next
64 }
65}