1use super::{
2 super::{Animation, vek::*},
3 CharacterSkeleton, SkeletonAttr,
4};
5use common::{
6 comp::item::{AbilitySpec, Hands, ToolKind},
7 util::Dir,
8};
9use core::{f32::consts::PI, ops::Mul};
10
11pub struct WieldAnimation;
12
13type WieldAnimationDependency<'a> = (
14 (Option<ToolKind>, Option<&'a AbilitySpec>),
15 Option<ToolKind>,
16 (Option<Hands>, Option<Hands>),
17 Vec3<f32>,
18 Vec3<f32>,
19 Dir,
20 Vec3<f32>,
21 bool,
22 f32,
23);
24impl Animation for WieldAnimation {
25 type Dependency<'a> = WieldAnimationDependency<'a>;
26 type Skeleton = CharacterSkeleton;
27
28 #[cfg(feature = "use-dyn-lib")]
29 const UPDATE_FN: &'static [u8] = b"character_wield\0";
30
31 #[cfg_attr(feature = "be-dyn-lib", unsafe(export_name = "character_wield"))]
32 fn update_skeleton_inner(
33 skeleton: &Self::Skeleton,
34 (
35 (active_tool_kind, active_tool_spec),
36 second_tool_kind,
37 hands,
38 orientation,
39 last_ori,
40 look_dir,
41 velocity,
42 is_riding,
43 global_time,
44 ): Self::Dependency<'_>,
45 anim_time: f32,
46 rate: &mut f32,
47 s_a: &SkeletonAttr,
48 ) -> Self::Skeleton {
49 *rate = 1.0;
50 let lab: f32 = 0.8;
51 let speed = Vec2::<f32>::from(velocity).magnitude();
52 let speednorm = speed / 9.5;
53 let mut next = (*skeleton).clone();
54 let head_look = Vec2::new(
55 (global_time + anim_time / 3.0).floor().mul(7331.0).sin() * 0.2,
56 (global_time + anim_time / 3.0).floor().mul(1337.0).sin() * 0.1,
57 );
58
59 let beltstatic = (anim_time * 10.0 * lab + PI / 2.0).sin();
60 let footvertlstatic = (anim_time * 10.0 * lab).sin();
61 let footvertrstatic = (anim_time * 10.0 * lab + PI).sin();
62
63 let slowalt = (anim_time * 9.0 + PI).cos();
64 let u_slow = (anim_time * 4.5 + PI).sin();
65 let slow = (anim_time * 7.0 + PI).sin();
66
67 let u_slowalt = (anim_time * 5.0 + PI).cos();
68 let direction = velocity.y * -0.098 * orientation.y + velocity.x * -0.098 * orientation.x;
69
70 let ori: Vec2<f32> = Vec2::from(orientation);
71 let last_ori = Vec2::from(last_ori);
72 let tilt = (if vek::Vec2::new(ori, last_ori)
73 .map(|o| o.magnitude_squared())
74 .map(|m| m > 0.001 && m.is_finite())
75 .reduce_and()
76 && ori.angle_between(last_ori).is_finite()
77 {
78 ori.angle_between(last_ori).min(0.2)
79 * last_ori.determine_side(Vec2::zero(), ori).signum()
80 } else {
81 0.0
82 } * 1.25)
83 * 4.0;
84 let jump = if velocity.z == 0.0 { 0.0 } else { 1.0 };
85
86 next.main.position = Vec3::new(0.0, 0.0, 0.0);
91 next.main.orientation = Quaternion::rotation_z(0.0);
92 next.main.scale = Vec3::one();
93 next.second.position = Vec3::new(0.0, 0.0, 0.0);
94 next.second.orientation = Quaternion::rotation_z(0.0);
95 next.second.scale = Vec3::one();
96
97 let is_moving = (speed > 0.2 && velocity.z == 0.0) || is_riding;
98
99 if !is_moving {
100 next.head.position = Vec3::new(0.0, s_a.head.0, s_a.head.1 + u_slow * 0.1);
101 next.head.orientation = Quaternion::rotation_z(head_look.x + tilt * -0.75)
102 * Quaternion::rotation_x(head_look.y.abs() + look_dir.z * 0.7);
103
104 next.chest.position =
105 Vec3::new(slowalt * 0.2, s_a.chest.0, s_a.chest.1 + u_slow * 0.35);
106 next.belt.orientation = Quaternion::rotation_z(0.15 + beltstatic * tilt * 0.1);
107
108 next.shorts.orientation = Quaternion::rotation_z(0.3 + beltstatic * tilt * 0.2);
109 next.torso.orientation = Quaternion::rotation_z(tilt * 0.4);
110
111 next.foot_l.position = Vec3::new(
112 -s_a.foot.0,
113 -2.0 + s_a.foot.1 + jump * -4.0,
114 s_a.foot.2 + (tilt * footvertlstatic * 1.0).max(0.0),
115 );
116 next.foot_l.orientation = Quaternion::rotation_x(
117 jump * -0.7 + u_slowalt * 0.035 + tilt * footvertlstatic * 0.1
118 - tilt.abs() * 0.3 * speednorm,
119 ) * Quaternion::rotation_z(-tilt * 0.3);
120
121 next.foot_r.position = Vec3::new(
122 s_a.foot.0,
123 2.0 + s_a.foot.1 + jump * 4.0,
124 s_a.foot.2 + (tilt * footvertrstatic * 1.0).max(0.0),
125 );
126 next.foot_r.orientation = Quaternion::rotation_x(
127 jump * 0.7 + u_slow * 0.035 + tilt * footvertrstatic * 0.1
128 - tilt.abs() * 0.3 * speednorm,
129 ) * Quaternion::rotation_z(-tilt * 0.3);
130
131 next.chest.orientation = Quaternion::rotation_y(u_slowalt * 0.04)
132 * Quaternion::rotation_z(0.15 + tilt * -0.4);
133
134 next.belt.position = Vec3::new(0.0, s_a.belt.0, s_a.belt.1);
135
136 next.shorts.position = Vec3::new(0.0, s_a.shorts.0, s_a.shorts.1);
138 }
139 match (hands, active_tool_kind, second_tool_kind) {
140 ((Some(Hands::Two), _), tool, _) | ((None, Some(Hands::Two)), _, tool) => match tool {
141 Some(ToolKind::Sword) => {
142 next.control_l.position = next.hand_l.position * 0.2
143 + Vec3::new(
144 s_a.sc.0,
145 s_a.sc.1 - slow * 2.0 * speednorm,
146 s_a.sc.2 + direction * -5.0 - slow * 2.0 * speednorm,
147 );
148 next.control_r.position = next.control_l.position;
149
150 next.hand_l.position = Vec3::new(s_a.shl.0 - 0.5, s_a.shl.1, s_a.shl.2);
151 next.hand_l.orientation =
152 Quaternion::rotation_x(s_a.shl.3) * Quaternion::rotation_y(s_a.shl.4);
153 next.control_l.orientation = Quaternion::rotation_x(s_a.sc.3 + u_slow * 0.05)
154 * Quaternion::rotation_z(u_slowalt * 0.04);
155 next.control_r.orientation = Quaternion::rotation_x(s_a.sc.3 + u_slow * 0.15)
156 * Quaternion::rotation_z(u_slowalt * 0.08);
157 next.hand_r.position = Vec3::zero();
158 next.hand_r.orientation =
159 next.hand_l.orientation * Quaternion::rotation_y(PI * 0.3);
160 },
161 Some(ToolKind::Axe) => {
162 next.main.position = Vec3::new(0.0, 0.0, 0.0);
163 next.main.orientation = Quaternion::rotation_x(0.0);
164
165 if speed < 0.5 {
166 next.head.position =
167 Vec3::new(0.0, 0.0 + s_a.head.0, s_a.head.1 + u_slow * 0.1);
168 next.head.orientation = Quaternion::rotation_z(head_look.x)
169 * Quaternion::rotation_x(0.15 + head_look.y.abs() + look_dir.z * 0.7);
170 next.chest.orientation = Quaternion::rotation_x(-0.15)
171 * Quaternion::rotation_y(u_slowalt * 0.04)
172 * Quaternion::rotation_z(0.15);
173 next.belt.position = Vec3::new(0.0, 1.0 + s_a.belt.0, s_a.belt.1);
174 next.belt.orientation = Quaternion::rotation_x(0.15)
175 * Quaternion::rotation_y(u_slowalt * 0.03)
176 * Quaternion::rotation_z(0.15);
177 next.shorts.position = Vec3::new(0.0, 1.0 + s_a.shorts.0, s_a.shorts.1);
178 next.shorts.orientation =
179 Quaternion::rotation_x(0.15) * Quaternion::rotation_z(0.25);
180 }
181 next.hand_l.position = Vec3::new(s_a.ahl.0, s_a.ahl.1, s_a.ahl.2);
182 next.hand_l.orientation =
183 Quaternion::rotation_x(s_a.ahl.3) * Quaternion::rotation_y(s_a.ahl.4);
184 next.hand_r.position = Vec3::new(s_a.ahr.0, s_a.ahr.1, s_a.ahr.2);
185 next.hand_r.orientation =
186 Quaternion::rotation_x(s_a.ahr.3) * Quaternion::rotation_z(PI);
187
188 next.control.position =
189 Vec3::new(s_a.ac.0, s_a.ac.1, s_a.ac.2 + direction * -5.0);
190 next.control.orientation = Quaternion::rotation_x(s_a.ac.3)
191 * Quaternion::rotation_y(s_a.ac.4)
192 * Quaternion::rotation_z(s_a.ac.5);
193 },
194 Some(ToolKind::Hammer | ToolKind::Pick) => {
195 next.hand_l.position = Vec3::new(s_a.hhl.0, s_a.hhl.1 + 3.0, s_a.hhl.2 - 1.0);
196 next.hand_l.orientation = Quaternion::rotation_x(s_a.hhl.3)
197 * Quaternion::rotation_y(s_a.hhl.4)
198 * Quaternion::rotation_z(s_a.hhl.5);
199 next.hand_r.position = Vec3::new(s_a.hhr.0, s_a.hhr.1 + 3.0, s_a.hhr.2 + 1.0);
200 next.hand_r.orientation = Quaternion::rotation_x(s_a.hhr.3)
201 * Quaternion::rotation_y(s_a.hhr.4)
202 * Quaternion::rotation_z(s_a.hhr.5);
203
204 next.control.position =
205 Vec3::new(s_a.hc.0 - 1.0, s_a.hc.1, s_a.hc.2 + direction * -5.0 - 3.0);
206 next.control.orientation = Quaternion::rotation_x(s_a.hc.3 + u_slow * 0.15)
207 * Quaternion::rotation_y(s_a.hc.4)
208 * Quaternion::rotation_z(s_a.hc.5 + u_slowalt * 0.07);
209 },
210 Some(ToolKind::Staff) | Some(ToolKind::Sceptre) => {
211 next.control_l.position = next.hand_l.position * 0.2
212 + Vec3::new(
213 s_a.sc.0 + 1.0,
214 s_a.sc.1 - slow * 2.0 * speednorm - 3.0,
215 s_a.sc.2 + direction * -5.0 - slow * 2.0 * speednorm - 3.0,
216 );
217 next.control_r.position = next.control_l.position;
218
219 next.hand_l.position = Vec3::new(s_a.shl.0 - 0.5, s_a.shl.1, s_a.shl.2 + 0.0);
220 next.hand_l.orientation =
221 Quaternion::rotation_x(s_a.shl.3) * Quaternion::rotation_y(s_a.shl.4);
222 next.control_l.orientation = Quaternion::rotation_x(s_a.sc.3 + u_slow * 0.05)
223 * Quaternion::rotation_z(u_slowalt * 0.04);
224 next.control_r.orientation = Quaternion::rotation_x(s_a.sc.3 + u_slow * 0.15)
225 * Quaternion::rotation_z(u_slowalt * 0.08);
226 next.hand_r.position = Vec3::new(0.0, 0.0, 8.0);
227 next.hand_r.orientation =
228 next.hand_l.orientation * Quaternion::rotation_y(PI * 0.3);
229 },
230 Some(ToolKind::Bow) => {
231 next.main.position = Vec3::new(0.0, 0.0, 0.0);
232 next.main.orientation = Quaternion::rotation_x(0.0);
233 next.hand_l.position = Vec3::new(s_a.bhl.0, s_a.bhl.1, s_a.bhl.2);
234 next.hand_l.orientation = Quaternion::rotation_x(s_a.bhl.3);
235 next.hand_r.position = Vec3::new(s_a.bhr.0, s_a.bhr.1, s_a.bhr.2);
236 next.hand_r.orientation = Quaternion::rotation_x(s_a.bhr.3);
237
238 next.hold.position = Vec3::new(0.0, -1.0, -5.2);
239 next.hold.orientation = Quaternion::rotation_x(-PI / 2.0);
240 next.hold.scale = Vec3::one() * 1.0;
241
242 next.control.position =
243 Vec3::new(s_a.bc.0, s_a.bc.1, s_a.bc.2 + direction * -5.0);
244 next.control.orientation = Quaternion::rotation_x(u_slow * 0.06)
245 * Quaternion::rotation_y(s_a.bc.4)
246 * Quaternion::rotation_z(s_a.bc.5 + u_slowalt * 0.1);
247 },
248 Some(ToolKind::Debug) => {
249 next.hand_l.position = Vec3::new(-7.0, 4.0, 3.0);
250 next.hand_l.orientation = Quaternion::rotation_x(1.27);
251 next.main.position = Vec3::new(-5.0, 5.0, 23.0);
252 next.main.orientation = Quaternion::rotation_x(PI);
253 },
254 Some(ToolKind::Farming) => {
255 if speed < 0.5 {
256 next.head.orientation = Quaternion::rotation_z(head_look.x)
257 * Quaternion::rotation_x(-0.2 + head_look.y.abs() + look_dir.z * 0.7);
258 }
259 next.hand_l.position = Vec3::new(9.0, 1.0, 1.0);
260 next.hand_l.orientation = Quaternion::rotation_x(PI / 2.0);
261 next.hand_r.position = Vec3::new(9.0, 1.0, 11.0);
262 next.hand_r.orientation = Quaternion::rotation_x(PI / 2.0);
263 next.main.position = Vec3::new(7.5, 7.5, 13.2);
264 next.main.orientation = Quaternion::rotation_y(PI);
265
266 next.control.position = Vec3::new(-11.0 + slow * 2.0, 1.8, 4.0);
267 next.control.orientation = Quaternion::rotation_x(u_slow * 0.1)
268 * Quaternion::rotation_y(0.6 + u_slow * 0.1)
269 * Quaternion::rotation_z(u_slowalt * 0.1);
270 },
271 Some(ToolKind::Shovel) => {
272 next.hand_l.position = Vec3::new(8.0, 6.0, 3.0);
273 next.hand_l.orientation = Quaternion::rotation_x(PI / 2.0);
274 next.hand_r.position = Vec3::new(8.0, 6.0, 15.0);
275 next.hand_r.orientation = Quaternion::rotation_x(PI / 2.0);
276 next.main.position = Vec3::new(7.5, 7.5, 13.2);
277 next.main.orientation = Quaternion::rotation_y(PI);
278
279 next.control.position = Vec3::new(-11.0 + slow * 0.02, 1.8, 4.0);
280 next.control.orientation = Quaternion::rotation_x(u_slow * 0.01)
281 * Quaternion::rotation_y(0.8 + u_slow * 0.01)
282 * Quaternion::rotation_z(u_slowalt * 0.01);
283 },
284 Some(ToolKind::Instrument) => {
285 if let Some(AbilitySpec::Custom(spec)) = active_tool_spec {
286 match spec.as_str() {
287 "Lyre" | "IcyTalharpa" | "WildskinDrum" | "Steeltonguedrum" => {
288 if speed < 0.5 {
289 next.head.orientation = Quaternion::rotation_z(head_look.x)
290 * Quaternion::rotation_x(
291 0.0 + head_look.y.abs() + look_dir.z * 0.7,
292 );
293 }
294 next.hand_l.position = Vec3::new(0.0, 2.0, -4.0);
295 next.hand_l.orientation =
296 Quaternion::rotation_x(PI / 2.0) * Quaternion::rotation_z(PI);
297 next.hand_r.position = Vec3::new(-4.0, 2.0, 6.0);
298 next.hand_r.orientation = Quaternion::rotation_x(PI / 2.0)
299 * Quaternion::rotation_z(PI / 2.0);
300 next.main.position = Vec3::new(-2.0, 10.0, 12.0);
301 next.main.orientation = Quaternion::rotation_y(PI);
302
303 next.control.position = Vec3::new(-2.0 + slow * 0.5, 0.5, 0.8);
304 next.control.orientation = Quaternion::rotation_x(u_slow * 0.1)
305 * Quaternion::rotation_y(2.0 + u_slow * 0.1)
306 * Quaternion::rotation_z(u_slowalt * 0.1);
307 },
308 "Flute" | "GlassFlute" => {
309 if speed < 0.5 {
310 next.head.orientation = Quaternion::rotation_z(head_look.x)
311 * Quaternion::rotation_x(
312 0.0 + head_look.y.abs() + look_dir.z * 0.7,
313 );
314 }
315 next.hand_l.position = Vec3::new(-1.0, 4.0, -1.0);
316 next.hand_l.orientation = Quaternion::rotation_x(2.5)
317 * Quaternion::rotation_y(0.9)
318 * Quaternion::rotation_z(PI);
319 next.hand_r.position = Vec3::new(-4.0, 2.0, 6.0);
320 next.hand_r.orientation = Quaternion::rotation_x(PI / 2.0);
321 next.main.position = Vec3::new(12.0, 3.0, 4.0);
322 next.main.orientation =
323 Quaternion::rotation_x(PI) * Quaternion::rotation_y(-1.2);
324
325 next.control.position = Vec3::new(-2.0 + slow * 0.5, 0.5, 0.8);
326 next.control.orientation = Quaternion::rotation_x(u_slow * 0.1)
327 * Quaternion::rotation_y(2.0 + u_slow * 0.1)
328 * Quaternion::rotation_z(u_slowalt * 0.1);
329 },
330 "DoubleBass" => {
331 if speed < 0.5 {
332 next.head.orientation = Quaternion::rotation_z(head_look.x)
333 * Quaternion::rotation_x(
334 0.0 + head_look.y.abs() + look_dir.z * 0.7,
335 );
336 }
337 next.hand_l.position = Vec3::new(-6.0, 6.0, -5.0);
338 next.hand_l.orientation = Quaternion::rotation_x((PI / 2.0) + 0.3)
339 * Quaternion::rotation_y(0.7)
340 * Quaternion::rotation_y(0.25)
341 * Quaternion::rotation_z(PI);
342 next.hand_r.position = Vec3::new(-2.0, 4.0, 5.0);
343 next.hand_r.orientation = Quaternion::rotation_x(PI / 2.0)
344 * Quaternion::rotation_z(PI / 2.0);
345 next.main.position = Vec3::new(-14.0, 6.0, -6.0);
346 next.main.orientation = Quaternion::rotation_x(-0.2)
347 * Quaternion::rotation_y(1.2)
348 * Quaternion::rotation_z(-1.2);
349
350 next.control.position = Vec3::new(-2.0 + slow * 0.5, 0.5, 0.8);
351 next.control.orientation = Quaternion::rotation_x(u_slow * 0.1)
352 * Quaternion::rotation_y(2.0 + u_slow * 0.1)
353 * Quaternion::rotation_z(u_slowalt * 0.1);
354 },
355 "Kora" => {
356 if speed < 0.5 {
357 next.head.orientation = Quaternion::rotation_z(head_look.x)
358 * Quaternion::rotation_x(
359 0.0 + head_look.y.abs() + look_dir.z * 0.7,
360 );
361 }
362 next.hand_l.position = Vec3::new(-6.0, 6.0, -5.0);
363 next.hand_l.orientation = Quaternion::rotation_x((PI / 2.0) + 0.3)
364 * Quaternion::rotation_y(0.7)
365 * Quaternion::rotation_y(0.25)
366 * Quaternion::rotation_z(PI);
367 next.hand_r.position = Vec3::new(-2.0, 4.0, 5.0);
368 next.hand_r.orientation = Quaternion::rotation_x(PI / 2.0)
369 * Quaternion::rotation_z(PI / 2.0);
370 next.main.position = Vec3::new(-14.0, 6.0, -6.0);
371 next.main.orientation = Quaternion::rotation_x(-0.2)
372 * Quaternion::rotation_y(1.2)
373 * Quaternion::rotation_z(1.3);
374
375 next.control.position = Vec3::new(-2.0 + slow * 0.5, 0.5, 0.8);
376 next.control.orientation = Quaternion::rotation_x(u_slow * 0.1)
377 * Quaternion::rotation_y(2.0 + u_slow * 0.1)
378 * Quaternion::rotation_z(u_slowalt * 0.1);
379 },
380 "Washboard" | "TimbrelOfChaos" | "Rhythmo" | "StarlightConch" => {
381 if speed < 0.5 {
382 next.head.orientation = Quaternion::rotation_z(head_look.x)
383 * Quaternion::rotation_x(
384 0.0 + head_look.y.abs() + look_dir.z * 0.7,
385 );
386 }
387 next.hand_l.position = Vec3::new(0.0, 2.0, -4.0);
388 next.hand_l.orientation =
389 Quaternion::rotation_x(PI / 2.0) * Quaternion::rotation_z(PI);
390 next.hand_r.position = Vec3::new(-4.0, 2.0, 6.0);
391 next.hand_r.orientation = Quaternion::rotation_x(PI / 2.0)
392 * Quaternion::rotation_z(PI / 2.0);
393 next.main.position = Vec3::new(-2.0, 10.0, 12.0);
394 next.main.orientation = Quaternion::rotation_y(PI);
395
396 next.control.position = Vec3::new(-2.0 + slow * 0.5, 0.5, 0.8);
397 next.control.orientation = Quaternion::rotation_x(u_slow * 0.1)
398 * Quaternion::rotation_y(2.0 + u_slow * 0.1)
399 * Quaternion::rotation_z(u_slowalt * 0.1);
400 },
401 "Kalimba" => {
402 if speed < 0.5 {
403 next.head.orientation = Quaternion::rotation_z(head_look.x)
404 * Quaternion::rotation_x(
405 0.0 + head_look.y.abs() + look_dir.z * 0.7,
406 );
407 }
408 next.hand_l.position = Vec3::new(0.0, 2.0, -4.0);
409 next.hand_l.orientation =
410 Quaternion::rotation_x(PI / 2.0) * Quaternion::rotation_z(PI);
411 next.hand_r.position = Vec3::new(-4.0, 2.0, 6.0);
412 next.hand_r.orientation = Quaternion::rotation_x(PI / 2.0)
413 * Quaternion::rotation_z(PI / 2.0);
414 next.main.position = Vec3::new(0.0, 7.0, 12.0);
415 next.main.orientation =
416 Quaternion::rotation_y(PI) * Quaternion::rotation_z(PI);
417
418 next.control.position = Vec3::new(-2.0 + slow * 0.5, 0.5, 0.8);
419 next.control.orientation = Quaternion::rotation_x(u_slow * 0.1)
420 * Quaternion::rotation_y(2.0 + u_slow * 0.1)
421 * Quaternion::rotation_z(u_slowalt * 0.1);
422 },
423 "Lute" | "Shamisen" | "Banjo" | "Oud" => {
424 if speed < 0.5 {
425 next.head.orientation = Quaternion::rotation_z(head_look.x)
426 * Quaternion::rotation_x(
427 0.0 + head_look.y.abs() + look_dir.z * 0.7,
428 );
429 }
430 next.hand_l.position = Vec3::new(-2.0, 5.0, -5.0);
431 next.hand_l.orientation = Quaternion::rotation_x((PI / 2.0) + 0.3)
432 * Quaternion::rotation_y(0.7)
433 * Quaternion::rotation_y(0.25)
434 * Quaternion::rotation_z(PI);
435 next.hand_r.position = Vec3::new(-5.0, 2.0, 6.0);
436 next.hand_r.orientation = Quaternion::rotation_x(PI / 2.0)
437 * Quaternion::rotation_z(PI / 2.0);
438 next.main.position = Vec3::new(-2.0, 4.0, -12.0);
439 next.main.orientation = Quaternion::rotation_x(0.0)
440 * Quaternion::rotation_y(0.2)
441 * Quaternion::rotation_z(-1.3);
442
443 next.control.position = Vec3::new(-2.0 + slow * 0.5, 0.5, 0.8);
444 next.control.orientation = Quaternion::rotation_x(u_slow * 0.1)
445 * Quaternion::rotation_y(2.0 + u_slow * 0.1)
446 * Quaternion::rotation_z(u_slowalt * 0.1);
447 },
448 "ViolaPizzicato" => {
449 if speed < 0.5 {
450 next.head.orientation = Quaternion::rotation_z(head_look.x)
451 * Quaternion::rotation_x(
452 0.0 + head_look.y.abs() + look_dir.z * 0.7,
453 );
454 }
455 next.hand_l.position = Vec3::new(-2.0, 5.0, -5.0);
456 next.hand_l.orientation = Quaternion::rotation_x((PI / 2.0) + 0.3)
457 * Quaternion::rotation_y(0.7)
458 * Quaternion::rotation_y(0.25)
459 * Quaternion::rotation_z(PI);
460 next.hand_r.position = Vec3::new(-5.0, 2.0, 6.0);
461 next.hand_r.orientation = Quaternion::rotation_x(PI / 2.0)
462 * Quaternion::rotation_z(PI / 2.0);
463 next.main.position = Vec3::new(-2.0, 6.0, -12.0);
464 next.main.orientation = Quaternion::rotation_x(0.0)
465 * Quaternion::rotation_y(0.2)
466 * Quaternion::rotation_z(-1.3);
467
468 next.control.position = Vec3::new(-2.0 + slow * 0.5, 0.5, 0.8);
469 next.control.orientation = Quaternion::rotation_x(u_slow * 0.1)
470 * Quaternion::rotation_y(2.0 + u_slow * 0.1)
471 * Quaternion::rotation_z(u_slowalt * 0.1);
472 },
473 "Guitar" | "DarkGuitar" => {
474 if speed < 0.5 {
475 next.head.orientation = Quaternion::rotation_z(head_look.x)
476 * Quaternion::rotation_x(
477 0.0 + head_look.y.abs() + look_dir.z * 0.7,
478 );
479 }
480 next.hand_l.position = Vec3::new(0.0, 5.0, -4.0);
481 next.hand_l.orientation = Quaternion::rotation_x((PI / 2.0) + 0.3)
482 * Quaternion::rotation_y(0.7)
483 * Quaternion::rotation_y(0.25)
484 * Quaternion::rotation_z(PI);
485 next.hand_r.position = Vec3::new(-5.0, 2.0, 6.0);
486 next.hand_r.orientation = Quaternion::rotation_x(PI / 2.0)
487 * Quaternion::rotation_z(PI / 2.0);
488 next.main.position = Vec3::new(-2.0, 4.0, -12.0);
489 next.main.orientation = Quaternion::rotation_x(0.0)
490 * Quaternion::rotation_y(0.2)
491 * Quaternion::rotation_z(-1.3);
492
493 next.control.position = Vec3::new(-2.0 + slow * 0.5, 0.5, 0.8);
494 next.control.orientation = Quaternion::rotation_x(u_slow * 0.1)
495 * Quaternion::rotation_y(2.0 + u_slow * 0.1)
496 * Quaternion::rotation_z(u_slowalt * 0.1);
497 },
498 "Melodica" => {
499 if speed < 0.5 {
500 next.head.orientation = Quaternion::rotation_z(head_look.x)
501 * Quaternion::rotation_x(
502 0.0 + head_look.y.abs() + look_dir.z * 0.7,
503 );
504 }
505 next.hand_l.position = Vec3::new(-1.0, 3.0, -2.0);
506 next.hand_l.orientation = Quaternion::rotation_x(2.0)
507 * Quaternion::rotation_z(-0.5)
508 * Quaternion::rotation_y(0.4)
509 * Quaternion::rotation_z(PI);
510 next.hand_r.position = Vec3::new(-4.0, 2.0, 6.0);
511 next.hand_r.orientation = Quaternion::rotation_x(1.2)
512 * Quaternion::rotation_y(-0.3)
513 * Quaternion::rotation_z(1.5);
514 next.main.position = Vec3::new(-14.0, 3.0, -6.0);
515 next.main.orientation = Quaternion::rotation_x(0.0)
516 * Quaternion::rotation_y(1.1)
517 * Quaternion::rotation_z(-1.5);
518
519 next.control.position = Vec3::new(-2.0 + slow * 0.5, 0.5, 0.8);
520 next.control.orientation = Quaternion::rotation_x(u_slow * 0.1)
521 * Quaternion::rotation_y(2.0 + u_slow * 0.1)
522 * Quaternion::rotation_z(u_slowalt * 0.1);
523 },
524 "Sitar" => {
525 if speed < 0.5 {
526 next.head.orientation = Quaternion::rotation_z(head_look.x)
527 * Quaternion::rotation_x(
528 0.0 + head_look.y.abs() + look_dir.z * 0.7,
529 );
530 }
531 next.hand_l.position = Vec3::new(-1.0, 5.0, -2.5);
532 next.hand_l.orientation = Quaternion::rotation_x((PI / 2.0) + 0.3)
533 * Quaternion::rotation_y(0.2)
534 * Quaternion::rotation_y(0.25)
535 * Quaternion::rotation_z(PI);
536 next.hand_r.position = Vec3::new(-5.0, 2.0, 6.0);
537 next.hand_r.orientation = Quaternion::rotation_x(PI / 2.0)
538 * Quaternion::rotation_z(PI / 2.0);
539 next.main.position = Vec3::new(-2.0, 4.0, -12.0);
540 next.main.orientation = Quaternion::rotation_x(0.0)
541 * Quaternion::rotation_y(0.2)
542 * Quaternion::rotation_z(-1.3);
543
544 next.control.position = Vec3::new(-2.0 + slow * 0.5, 0.5, 0.8);
545 next.control.orientation = Quaternion::rotation_x(u_slow * 0.1)
546 * Quaternion::rotation_y(2.0 + u_slow * 0.1)
547 * Quaternion::rotation_z(u_slowalt * 0.1);
548 },
549 _ => {},
550 }
551 }
552 },
553 Some(ToolKind::Shield) => {
554 next.hand_l.position = Vec3::new(0.0, -2.0, 0.0);
555 next.hand_l.orientation = Quaternion::rotation_x(PI / 2.0);
556
557 next.hand_r.position = Vec3::new(0.0, 0.0, 0.0);
558 next.hand_r.orientation =
559 Quaternion::rotation_x(PI / 2.0) * Quaternion::rotation_y(2.0);
560
561 next.control.position = Vec3::new(0.0, 7.0, 4.0);
562 next.control.orientation =
563 Quaternion::rotation_y(-0.5) * Quaternion::rotation_z(-1.25);
564 },
565 _ => {},
566 },
567 ((_, _), _, _) => {},
568 };
569 match hands {
570 (Some(Hands::One), _) => {
571 next.control_l.position =
572 next.hand_l.position * Vec3::new(0.5, 0.5, 0.3) + Vec3::new(-4.0, 0.0, 0.0);
573 next.control_l.orientation = Quaternion::lerp(
574 next.hand_l.orientation,
575 Quaternion::rotation_x(PI * -0.5),
576 0.65,
577 );
578 next.hand_l.position = Vec3::new(0.0, -2.0, 0.0);
579 next.hand_l.orientation = Quaternion::rotation_x(PI * 0.5);
580 },
581 (_, _) => {},
582 };
583 match hands {
584 (None | Some(Hands::One), Some(Hands::One)) => {
585 next.control_r.position =
586 next.hand_r.position * Vec3::new(0.5, 0.5, 0.3) + Vec3::new(4.0, 0.0, 0.0);
587 next.control_r.orientation = Quaternion::lerp(
588 next.hand_r.orientation,
589 Quaternion::rotation_x(PI * -0.5),
590 0.65,
591 );
592 next.hand_r.position = Vec3::new(0.0, -2.0, 0.0);
593 next.hand_r.orientation = Quaternion::rotation_x(PI * 0.5);
594 },
595 (_, _) => {},
596 };
597 match hands {
598 (None, None) | (None, Some(Hands::One)) => {
599 next.hand_l.position = Vec3::new(-8.0, 2.0, 1.0);
600 next.hand_l.orientation =
601 Quaternion::rotation_x(0.5) * Quaternion::rotation_y(0.25);
602 },
603 (_, _) => {},
604 };
605 match hands {
606 (None, None) | (Some(Hands::One), None) => {
607 },
612 (_, _) => {},
613 };
614
615 if let (None, Some(Hands::Two)) = hands {
616 next.second = next.main;
617 }
618
619 next.do_hold_lantern(s_a, anim_time, anim_time, speednorm, 0.0, tilt);
620
621 next
622 }
623}