veloren_voxygen_anim/character/
boost.rs1use super::{
2 super::{Animation, vek::*},
3 CharacterSkeleton, SkeletonAttr,
4};
5
6pub struct BoostAnimation;
7
8type BoostAnimationDependency<'a> = ();
9
10impl Animation for BoostAnimation {
11 type Dependency<'a> = BoostAnimationDependency<'a>;
12 type Skeleton = CharacterSkeleton;
13
14 #[cfg(feature = "use-dyn-lib")]
15 const UPDATE_FN: &'static [u8] = b"character_boost\0";
16
17 #[cfg_attr(feature = "be-dyn-lib", export_name = "character_boost")]
18 fn update_skeleton_inner(
19 skeleton: &Self::Skeleton,
20 _dep: Self::Dependency<'_>,
21 anim_time: f32,
22 rate: &mut f32,
23 s_a: &SkeletonAttr,
24 ) -> Self::Skeleton {
25 *rate = 1.0;
26 let mut next = (*skeleton).clone();
27
28 next.main.position = Vec3::new(10.0, -10.0, -10.0);
29 next.main.orientation = Quaternion::rotation_z(0.0);
30 next.second.position = Vec3::new(0.0, 0.0, 0.0);
31 next.second.orientation = Quaternion::rotation_z(0.0);
32
33 let (move1, move2, move3, tension) = (
34 anim_time.powf(0.25).min(1.0),
35 0.0,
36 0.0,
37 (anim_time * 20.0).sin() - 0.5,
38 );
39 let pullback = 1.0 - move3;
40 let move1 = move1 * pullback;
41 let move2 = move2 * pullback;
42
43 next.hand_l.position = Vec3::new(s_a.shl.0, s_a.shl.1, s_a.shl.2);
44 next.hand_l.orientation =
45 Quaternion::rotation_x(s_a.shl.3) * Quaternion::rotation_y(s_a.shl.4);
46 next.hand_r.position = Vec3::new(-s_a.sc.0 + 6.0 + move1 * -12.0, -4.0 + move1 * 3.0, -2.0);
47 next.hand_r.orientation = Quaternion::rotation_x(std::f32::consts::PI * 0.5);
48 next.control.position = Vec3::new(s_a.sc.0, s_a.sc.1, s_a.sc.2 + move2 * 5.0);
49 next.control.orientation = Quaternion::rotation_x(s_a.sc.3 + move1 * -0.9)
50 * Quaternion::rotation_y(move1 * 1.0 + move2 * -1.0)
51 * Quaternion::rotation_z(move1 * 1.3 + move2 * -1.3);
52
53 next.chest.orientation =
54 Quaternion::rotation_z(move1 * 1.0 + tension * 0.02 + move2 * -1.2);
55 next.head.orientation = Quaternion::rotation_z(move1 * -0.4 + move2 * 0.3);
56 next.belt.orientation = Quaternion::rotation_z(move1 * -0.25 + move2 * 0.2);
57 next.shorts.orientation = Quaternion::rotation_z(move1 * -0.5 + move2 * 0.4);
58
59 next
60 }
61}