veloren_voxygen_anim/biped_large/
leapmelee.rs1use super::{
2 super::{Animation, vek::*},
3 BipedLargeSkeleton, SkeletonAttr,
4};
5use common::{comp::item::ToolKind, states::utils::StageSection};
6use core::f32::consts::PI;
7
8pub struct LeapAnimation;
9
10impl Animation for LeapAnimation {
11 type Dependency<'a> = (
12 Option<ToolKind>,
13 Option<ToolKind>,
14 Vec3<f32>,
15 f32,
16 Option<StageSection>,
17 Option<&'a str>,
18 );
19 type Skeleton = BipedLargeSkeleton;
20
21 #[cfg(feature = "use-dyn-lib")]
22 const UPDATE_FN: &'static [u8] = b"biped_large_leapmelee\0";
23
24 #[cfg_attr(feature = "be-dyn-lib", unsafe(export_name = "biped_large_leapmelee"))]
25 fn update_skeleton_inner(
26 skeleton: &Self::Skeleton,
27 (active_tool_kind, _second_tool_kind, _velocity, _global_time, stage_section, ability_id): Self::Dependency<'_>,
28 anim_time: f32,
29 rate: &mut f32,
30 s_a: &SkeletonAttr,
31 ) -> Self::Skeleton {
32 *rate = 1.0;
33 let mut next = (*skeleton).clone();
34
35 let (movement1, movement2, movement3, movement4) = match stage_section {
36 Some(StageSection::Buildup) => (anim_time, 0.0, 0.0, 0.0),
37 Some(StageSection::Movement) => (1.0, anim_time.powf(0.25), 0.0, 0.0),
38 Some(StageSection::Action) => (1.0, 1.0, anim_time.powf(0.25), 0.0),
39 Some(StageSection::Recover) => (1.0, 1.0, 1.0, anim_time),
40 _ => (0.0, 0.0, 0.0, 0.0),
41 };
42
43 match active_tool_kind {
44 Some(ToolKind::Hammer) => {
45 next.hand_l.position = Vec3::new(s_a.hhl.0, s_a.hhl.1, s_a.hhl.2);
46 next.hand_l.orientation = Quaternion::rotation_x(s_a.hhl.3);
47 next.hand_r.position = Vec3::new(s_a.hhr.0, s_a.hhr.1, s_a.hhr.2);
48 next.hand_r.orientation = Quaternion::rotation_x(s_a.hhr.3);
49 next.main.position = Vec3::new(0.0, 0.0, 0.0);
50 next.main.orientation = Quaternion::rotation_y(0.0) * Quaternion::rotation_z(0.0);
51
52 next.head.position = Vec3::new(0.0, s_a.head.0, s_a.head.1);
53
54 next.control.position = Vec3::new(
55 s_a.hc.0 + movement2 * -10.0 + movement3 * 6.0,
56 s_a.hc.1 + movement2 * 5.0 + movement3 * 7.0,
57 s_a.hc.2 + movement2 * 5.0 + movement3 * -10.0,
58 );
59 next.control.orientation =
60 Quaternion::rotation_x(s_a.hc.3 + movement2 * PI / 2.0 + movement3 * -2.3)
61 * Quaternion::rotation_y(s_a.hc.4 + movement2 * 1.3)
62 * Quaternion::rotation_z(s_a.hc.5 + movement2 * -1.0 + movement3 * 0.5);
63 next.upper_torso.orientation = Quaternion::rotation_x(
64 movement1 * 0.3 + movement2 * 0.3 + movement3 * -0.9 + movement4 * 0.3,
65 ) * Quaternion::rotation_z(
66 movement1 * 0.5 + movement2 * 0.2 + movement3 * -0.7,
67 );
68
69 next.head.orientation = Quaternion::rotation_x(movement3 * 0.2)
70 * Quaternion::rotation_y(0.0 + movement2 * -0.1)
71 * Quaternion::rotation_z(movement1 * -0.4 + movement2 * -0.2 + movement3 * 0.6);
72
73 next.foot_l.position = Vec3::new(
76 -s_a.foot.0,
77 s_a.foot.1 + movement3 * 13.0,
78 s_a.foot.2 + movement3 * -2.0,
79 );
80 next.foot_l.orientation = Quaternion::rotation_x(-0.8 + movement3 * 1.7);
81
82 next.foot_r.position = Vec3::new(
83 s_a.foot.0,
84 s_a.foot.1 + 8.0 + movement3 * -13.0,
85 s_a.foot.2 + 5.0 + movement3 * -5.0,
86 );
87 next.foot_r.orientation = Quaternion::rotation_x(0.9 + movement3 * -1.7);
88 },
89 Some(ToolKind::Natural) => match ability_id {
90 Some("common.abilities.custom.tursus.tusk_bash_leap") => {
91 next.head.position = Vec3::new(
92 0.0,
93 s_a.head.0 + movement3 * 12.0,
94 s_a.head.1 + movement3 * 8.0,
95 );
96 next.upper_torso.position =
97 Vec3::new(0.0, s_a.upper_torso.0, s_a.upper_torso.1 + movement1 * -4.0);
98 next.upper_torso.orientation = Quaternion::rotation_x(
99 movement1 * -0.3 + movement2 * -0.3 + movement3 * 0.2,
100 ) * Quaternion::rotation_z(
101 movement1 * 0.1 + movement2 * 0.2 + movement3 * -0.3,
102 );
103
104 next.head.orientation = Quaternion::rotation_x(
105 movement1 * -0.1 + movement2 * -0.1 + movement3 * 1.4,
106 );
107 next.foot_l.position = Vec3::new(
108 -s_a.foot.0,
109 s_a.foot.1 + movement3 * 1.0,
110 s_a.foot.2 + movement1 * -0.3 + movement3 * -2.0,
111 );
112 next.foot_l.orientation = Quaternion::rotation_x(
113 movement1 * -0.1 + movement2 * -0.2 + movement3 * 0.7,
114 );
115
116 next.foot_r.position = Vec3::new(
117 s_a.foot.0,
118 s_a.foot.1 + 1.0 + movement3 * -1.0,
119 s_a.foot.2 - 1.0 + movement1 * -0.3 + movement3 * -2.0,
120 );
121 next.foot_r.orientation = Quaternion::rotation_x(
122 movement1 * -0.1 + movement2 * -0.2 + movement3 * -0.7,
123 );
124 next.shoulder_l.orientation = Quaternion::rotation_x(
125 movement1 * 0.5 + movement2 * 0.1 + movement3 * -1.5,
126 );
127 next.shoulder_r.orientation = Quaternion::rotation_x(
128 movement1 * 0.9 + movement2 * 0.1 + movement3 * -1.5,
129 );
130 next.hand_l.orientation = Quaternion::rotation_x(
131 movement1 * 0.5 + movement2 * 0.1 + movement3 * -1.5,
132 );
133 next.hand_r.orientation = Quaternion::rotation_x(
134 movement1 * 0.9 + movement2 * 0.1 + movement3 * -1.5,
135 );
136 },
137 _ => {},
138 },
139 Some(ToolKind::Sword) => match ability_id {
140 Some("common.abilities.custom.gigas_fire.lava_leap") => {
141 let move1 = (PI * movement1).sin();
142 let move2 = movement2 * (1.0 - movement3);
143 let move3 = movement3 * (1.0 - movement4.powi(3));
144
145 next.control.position = Vec3::new(s_a.sc.0, s_a.sc.1, s_a.sc.2);
146 next.control.orientation = Quaternion::rotation_x(s_a.sc.3)
147 * Quaternion::rotation_y(s_a.sc.4)
148 * Quaternion::rotation_z(s_a.sc.5);
149 next.hand_l.position = Vec3::new(s_a.shl.0, s_a.shl.1, s_a.shl.2);
150 next.hand_l.orientation =
151 Quaternion::rotation_x(s_a.shl.3) * Quaternion::rotation_y(s_a.shl.4);
152 next.hand_r.position = Vec3::new(s_a.shr.0, s_a.shr.1, s_a.shr.2);
153 next.hand_r.orientation =
154 Quaternion::rotation_x(s_a.shr.3) * Quaternion::rotation_y(s_a.shr.4);
155 next.main.position = Vec3::new(1.0, 10.0, 0.0);
156 next.main.orientation =
157 Quaternion::rotation_y(0.0) * Quaternion::rotation_z(0.0);
158
159 next.torso.position += Vec3::new(0.0, -3.0, -3.0) * move1;
160 next.leg_l.position += Vec3::new(0.0, 1.5, 1.5) * move1;
161 next.leg_l.orientation.rotate_x(PI / 3.0 * move1);
162 next.foot_l.position += Vec3::new(0.0, 3.0, 3.0) * move1;
163 next.leg_r.position += Vec3::new(0.0, 1.5, 1.5) * move1;
164 next.leg_r.orientation.rotate_x(PI / 3.0 * move1);
165 next.foot_r.position += Vec3::new(0.0, 3.0, 3.0) * move1;
166
167 next.torso.orientation.rotate_x(PI / 5.0 * move2);
168 next.torso.position += Vec3::new(0.0, 5.0, 0.0) * move2;
169 next.foot_l.orientation.rotate_x(-PI / 8.0 * move2);
170 next.leg_r.position += Vec3::new(0.0, 5.0, 0.0) * move2;
171 next.leg_r.orientation.rotate_x(PI / 8.0 * move2);
172 next.foot_r.position += Vec3::new(0.0, 2.0, 0.0) * move2;
173 next.foot_r.orientation.rotate_x(-PI / 6.0 * move2);
174 next.shoulder_l.orientation.rotate_x(PI / 2.5 * move2);
175 next.shoulder_r.position += Vec3::new(-3.0, 7.0, 0.0) * move2;
176 next.shoulder_r.orientation.rotate_x(PI / 1.5 * move2);
177 next.shoulder_r.orientation.rotate_z(PI / 4.0 * move2);
178 next.control.position += Vec3::new(-8.0, 0.0, 15.0) * move2;
179 next.control.orientation.rotate_x(PI / 3.0 * move2);
180 next.control.orientation.rotate_z(-PI / 10.0 * move2);
181 next.control_r.position += Vec3::new(13.0, 4.0, -8.0) * move2;
182 next.control_r.orientation.rotate_x(PI / 8.0 * move2);
183 next.control_r.orientation.rotate_z(PI / 3.0 * move2);
184 next.control_l.position += Vec3::new(0.0, 0.0, -7.0) * move2;
185 next.control_l.orientation.rotate_x(PI / 8.0 * move2);
186
187 next.torso.position += Vec3::new(0.0, -9.0, 0.0) * move3;
188 next.torso.orientation.rotate_x(-PI / 8.0 * move3);
189 next.lower_torso.position += Vec3::new(0.0, 0.0, 1.0) * move3;
190 next.lower_torso.orientation.rotate_x(PI / 8.0 * move3);
191 next.shoulder_r.position += Vec3::new(-3.0, 6.0, 0.0) * move3;
192 next.shoulder_r.orientation.rotate_z(PI / 4.0 * move3);
193 next.shoulder_l.position += Vec3::new(3.0, 6.0, 0.0) * move3;
194 next.shoulder_l.orientation.rotate_z(-PI / 4.0 * move3);
195 next.control.position += Vec3::new(0.0, 0.0, 0.0) * move3;
196 next.control.orientation.rotate_x(-PI / 2.5 * move3);
197 },
198 Some("common.abilities.adlet.elder.leap") => {
199 next.hand_l.position = Vec3::new(s_a.hhl.0 * 1.5, -s_a.hhl.1, 5.0);
200 next.hand_l.orientation = Quaternion::rotation_x(s_a.hhl.3);
201 next.hand_r.position = Vec3::new(s_a.hhr.0 / 2.0, 12.0, 5.0);
202 next.hand_r.orientation = Quaternion::rotation_x(s_a.hhr.3);
203 next.main.position = Vec3::new(-6.0, 18.0, 4.0);
204 next.main.orientation =
205 Quaternion::rotation_y(0.0) * Quaternion::rotation_z(0.0);
206 next.head.position = Vec3::new(0.0, s_a.head.0, s_a.head.1);
207 next.control.orientation =
208 Quaternion::rotation_x(movement2 * PI / 2.5 + movement3 * -2.3);
209 next.upper_torso.orientation = Quaternion::rotation_x(
210 movement1 * 0.3 + movement2 * 0.3 + movement3 * -0.9 + movement4 * 0.3,
211 ) * Quaternion::rotation_z(
212 movement1 * 0.5 + movement2 * 0.2 + movement3 * -0.7,
213 );
214
215 next.head.orientation = Quaternion::rotation_x(movement3 * 0.2)
216 * Quaternion::rotation_y(0.0 + movement2 * -0.1)
217 * Quaternion::rotation_z(
218 movement1 * -0.4 + movement2 * -0.2 + movement3 * 0.6,
219 );
220
221 next.foot_l.position = Vec3::new(
222 -s_a.foot.0,
223 s_a.foot.1 + movement3 * 13.0,
224 s_a.foot.2 + movement3 * -2.0,
225 );
226 next.foot_l.orientation = Quaternion::rotation_x(-0.8 + movement3 * 1.7);
227
228 next.foot_r.position = Vec3::new(
229 s_a.foot.0,
230 s_a.foot.1 + 8.0 + movement3 * -13.0,
231 s_a.foot.2 + 5.0 + movement3 * -5.0,
232 );
233 next.foot_r.orientation = Quaternion::rotation_x(0.9 + movement3 * -1.7);
234 if ability_id == Some("common.abilities.adlet.elder.leap") {
235 next.second.position = Vec3::new(-2.0, 20.0, 4.0);
236 next.second.orientation =
237 Quaternion::rotation_y(0.0) * Quaternion::rotation_z(0.0);
238 } else {
239 next.second.scale = Vec3::one() * 0.0;
240 }
241 },
242 _ => {},
243 },
244 _ => {},
245 }
246
247 next
248 }
249}