veloren_voxygen_anim/crustacean/
jump.rs1use super::{
2 super::{Animation, vek::*},
3 CrustaceanSkeleton, SkeletonAttr,
4};
5
6pub struct JumpAnimation;
7
8impl Animation for JumpAnimation {
9 type Dependency<'a> = (f32, Vec3<f32>, Vec3<f32>, f32, Vec3<f32>);
10 type Skeleton = CrustaceanSkeleton;
11
12 #[cfg(feature = "use-dyn-lib")]
13 const UPDATE_FN: &'static [u8] = b"crustacean_jump\0";
14
15 #[cfg_attr(feature = "be-dyn-lib", export_name = "crustacean_jump")]
16 fn update_skeleton_inner(
17 skeleton: &Self::Skeleton,
18 (_velocity, _orientation, _last_ori, _global_time, _avg_vel): 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 up_rot = 0.2;
30
31 next.leg_fl.position = Vec3::new(-s_a.leg_f.0, s_a.leg_f.1, s_a.leg_f.2);
32 next.leg_fr.position = Vec3::new(s_a.leg_f.0, s_a.leg_f.1, s_a.leg_f.2);
33 next.leg_fl.orientation =
34 Quaternion::rotation_z(s_a.leg_ori.0) * Quaternion::rotation_y(up_rot);
35 next.leg_fr.orientation =
36 Quaternion::rotation_z(-s_a.leg_ori.0) * Quaternion::rotation_y(-up_rot);
37
38 next.leg_cl.position = Vec3::new(-s_a.leg_c.0, s_a.leg_c.1, s_a.leg_c.2);
39 next.leg_cr.position = Vec3::new(s_a.leg_c.0, s_a.leg_c.1, s_a.leg_c.2);
40 next.leg_cl.orientation =
41 Quaternion::rotation_z(s_a.leg_ori.1) * Quaternion::rotation_y(up_rot);
42 next.leg_cr.orientation =
43 Quaternion::rotation_z(-s_a.leg_ori.1) * Quaternion::rotation_y(-up_rot);
44
45 next.leg_bl.position = Vec3::new(-s_a.leg_b.0, s_a.leg_b.1, s_a.leg_b.2);
46 next.leg_br.position = Vec3::new(s_a.leg_b.0, s_a.leg_b.1, s_a.leg_b.2);
47 next.leg_bl.orientation =
48 Quaternion::rotation_z(s_a.leg_ori.2) * Quaternion::rotation_y(up_rot);
49 next.leg_br.orientation =
50 Quaternion::rotation_z(-s_a.leg_ori.2) * Quaternion::rotation_y(-up_rot);
51
52 next
53 }
54}