veloren_voxygen_anim/biped_large/
jump.rs1use super::{
2 super::{Animation, vek::*},
3 BipedLargeSkeleton, SkeletonAttr,
4};
5use common::comp::item::ToolKind;
6use core::f32::consts::PI;
7
8pub struct JumpAnimation;
9
10impl Animation for JumpAnimation {
11 type Dependency<'a> = (Option<ToolKind>, Option<ToolKind>, f32);
12 type Skeleton = BipedLargeSkeleton;
13
14 #[cfg(feature = "use-dyn-lib")]
15 const UPDATE_FN: &'static [u8] = b"biped_large_jump\0";
16
17 #[cfg_attr(feature = "be-dyn-lib", export_name = "biped_large_jump")]
18 fn update_skeleton_inner(
19 skeleton: &Self::Skeleton,
20 (active_tool_kind, _second_tool_kind, _global_time): Self::Dependency<'_>,
21 anim_time: f32,
22 _rate: &mut f32,
23 s_a: &SkeletonAttr,
24 ) -> Self::Skeleton {
25 let mut next = (*skeleton).clone();
26
27 let lab: f32 = 1.0;
28 let torso = (anim_time * lab + 1.5 * PI).sin();
29
30 let wave_slow = (anim_time * 0.8).sin();
31 next.hold.scale = Vec3::one() * 0.0;
32 next.second.scale = Vec3::one() * 0.0;
33
34 next.head.scale = Vec3::one() * 1.02;
35
36 next.hand_l.scale = Vec3::one() * 1.04;
37
38 next.head.position = Vec3::new(0.0, s_a.head.0, s_a.head.1 + torso * 0.2) * 1.02;
39 next.head.orientation = Quaternion::rotation_z(0.0) * Quaternion::rotation_x(0.0);
40
41 next.upper_torso.position =
42 Vec3::new(0.0, s_a.upper_torso.0, s_a.upper_torso.1 + torso * 0.5);
43 next.upper_torso.orientation = Quaternion::rotation_x(-0.3);
44
45 next.lower_torso.position =
46 Vec3::new(0.0, s_a.lower_torso.0, s_a.lower_torso.1 + torso * 0.15);
47 next.lower_torso.orientation = Quaternion::rotation_z(0.0) * Quaternion::rotation_x(0.2);
48 next.lower_torso.scale = Vec3::one() * 1.02;
49
50 next.jaw.position = Vec3::new(0.0, s_a.jaw.0, s_a.jaw.1);
51 next.jaw.orientation = Quaternion::rotation_x(wave_slow * 0.09);
52
53 next.tail.position = Vec3::new(0.0, s_a.tail.0, s_a.tail.1 + torso * 0.0);
54 next.tail.orientation = Quaternion::rotation_z(0.0);
55
56 next.control.position = Vec3::new(0.0, 0.0, 0.0);
57 next.control.orientation = Quaternion::rotation_z(0.0);
58
59 if active_tool_kind != Some(ToolKind::Axe) {
60 next.second.position = Vec3::new(0.0, 0.0, 0.0);
61 next.second.orientation = Quaternion::rotation_x(PI)
62 * Quaternion::rotation_y(0.0)
63 * Quaternion::rotation_z(0.0);
64 next.second.scale = Vec3::one() * 1.0;
65 };
66
67 match active_tool_kind {
68 Some(ToolKind::Bow) => {
69 next.main.position = Vec3::new(-2.0, -5.0, -6.0);
70 next.main.orientation =
71 Quaternion::rotation_y(2.5) * Quaternion::rotation_z(PI / 2.0);
72 },
73 Some(ToolKind::Staff) | Some(ToolKind::Sceptre) => {
74 next.main.position = Vec3::new(-6.0, -5.0, -12.0);
75 next.main.orientation =
76 Quaternion::rotation_y(0.6) * Quaternion::rotation_z(PI / 2.0);
77 },
78 Some(ToolKind::Sword) => {
79 next.main.position = Vec3::new(-10.0, -8.0, 12.0);
80 next.main.orientation =
81 Quaternion::rotation_y(2.5) * Quaternion::rotation_z(PI / 2.0);
82 },
83 Some(ToolKind::Hammer) | Some(ToolKind::Axe) => {
84 next.main.position = Vec3::new(-10.0, -8.0, 12.0);
85 next.main.orientation =
86 Quaternion::rotation_y(2.5) * Quaternion::rotation_z(PI / 2.0);
87 },
88 _ => {
89 next.main.position = Vec3::new(-2.0, -5.0, -6.0);
90 next.main.orientation =
91 Quaternion::rotation_y(0.6) * Quaternion::rotation_z(PI / 2.0);
92 },
93 }
94
95 next.shoulder_l.position = Vec3::new(-s_a.shoulder.0, s_a.shoulder.1, s_a.shoulder.2);
96 next.shoulder_l.orientation = Quaternion::rotation_z(0.0) * Quaternion::rotation_x(0.5);
97
98 next.shoulder_r.position = Vec3::new(s_a.shoulder.0, s_a.shoulder.1, s_a.shoulder.2);
99 next.shoulder_r.orientation = Quaternion::rotation_z(0.0) * Quaternion::rotation_x(-0.5);
100
101 next.hand_l.position = Vec3::new(-s_a.hand.0, s_a.hand.1, s_a.hand.2 + torso * 0.6);
102 next.hand_l.orientation = Quaternion::rotation_z(0.0) * Quaternion::rotation_x(0.8);
103
104 next.hand_r.position = Vec3::new(s_a.hand.0, s_a.hand.1, s_a.hand.2 + torso * 0.6);
105 next.hand_r.orientation = Quaternion::rotation_z(0.0) * Quaternion::rotation_x(-0.8);
106 next.hand_r.scale = Vec3::one() * 1.04;
107
108 next.leg_l.position = Vec3::new(-s_a.leg.0, s_a.leg.1, s_a.leg.2 + torso * 0.2) * 1.02;
109 next.leg_l.orientation = Quaternion::rotation_z(0.0) * Quaternion::rotation_x(-0.4);
110 next.leg_l.scale = Vec3::one() * 1.02;
111
112 next.leg_r.position = Vec3::new(s_a.leg.0, s_a.leg.1, s_a.leg.2 + torso * 0.2) * 1.02;
113 next.leg_r.orientation = Quaternion::rotation_z(0.0) * Quaternion::rotation_x(0.4);
114 next.leg_r.scale = Vec3::one() * 1.02;
115
116 next.foot_l.position = Vec3::new(-s_a.foot.0, -5.0 + s_a.foot.1, s_a.foot.2);
117 next.foot_l.orientation = Quaternion::rotation_z(0.0) * Quaternion::rotation_x(-0.4);
118
119 next.foot_r.position = Vec3::new(s_a.foot.0, 5.0 + s_a.foot.1, s_a.foot.2);
120 next.foot_r.orientation = Quaternion::rotation_z(0.0) * Quaternion::rotation_x(0.4);
121
122 next.torso.position = Vec3::new(0.0, 0.0, 0.0);
123 next.torso.orientation = Quaternion::rotation_z(0.0) * Quaternion::rotation_x(0.0);
124
125 next
126 }
127}