veloren_voxygen_anim/character/
wield.rs

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", 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.second.scale = match hands {
87        //     (Some(Hands::One), Some(Hands::One)) => Vec3::one(),
88        //    (_, _) => Vec3::zero(),
89        // };
90        next.main.position = Vec3::new(0.0, 0.0, 0.0);
91        next.main.orientation = Quaternion::rotation_z(0.0);
92        next.second.position = Vec3::new(0.0, 0.0, 0.0);
93        next.second.orientation = Quaternion::rotation_z(0.0);
94
95        let is_moving = (speed > 0.2 && velocity.z == 0.0) || is_riding;
96
97        if !is_moving {
98            next.head.position = Vec3::new(0.0, s_a.head.0, s_a.head.1 + u_slow * 0.1);
99            next.head.orientation = Quaternion::rotation_z(head_look.x + tilt * -0.75)
100                * Quaternion::rotation_x(head_look.y.abs() + look_dir.z * 0.7);
101
102            next.chest.position =
103                Vec3::new(slowalt * 0.2, s_a.chest.0, s_a.chest.1 + u_slow * 0.35);
104            next.belt.orientation = Quaternion::rotation_z(0.15 + beltstatic * tilt * 0.1);
105
106            next.shorts.orientation = Quaternion::rotation_z(0.3 + beltstatic * tilt * 0.2);
107            next.torso.orientation = Quaternion::rotation_z(tilt * 0.4);
108
109            next.foot_l.position = Vec3::new(
110                -s_a.foot.0,
111                -2.0 + s_a.foot.1 + jump * -4.0,
112                s_a.foot.2 + (tilt * footvertlstatic * 1.0).max(0.0),
113            );
114            next.foot_l.orientation = Quaternion::rotation_x(
115                jump * -0.7 + u_slowalt * 0.035 + tilt * footvertlstatic * 0.1
116                    - tilt.abs() * 0.3 * speednorm,
117            ) * Quaternion::rotation_z(-tilt * 0.3);
118
119            next.foot_r.position = Vec3::new(
120                s_a.foot.0,
121                2.0 + s_a.foot.1 + jump * 4.0,
122                s_a.foot.2 + (tilt * footvertrstatic * 1.0).max(0.0),
123            );
124            next.foot_r.orientation = Quaternion::rotation_x(
125                jump * 0.7 + u_slow * 0.035 + tilt * footvertrstatic * 0.1
126                    - tilt.abs() * 0.3 * speednorm,
127            ) * Quaternion::rotation_z(-tilt * 0.3);
128
129            next.chest.orientation = Quaternion::rotation_y(u_slowalt * 0.04)
130                * Quaternion::rotation_z(0.15 + tilt * -0.4);
131
132            next.belt.position = Vec3::new(0.0, s_a.belt.0, s_a.belt.1);
133
134            // next.back.orientation = Quaternion::rotation_x(-0.2);
135            next.shorts.position = Vec3::new(0.0, s_a.shorts.0, s_a.shorts.1);
136        }
137        match (hands, active_tool_kind, second_tool_kind) {
138            ((Some(Hands::Two), _), tool, _) | ((None, Some(Hands::Two)), _, tool) => match tool {
139                Some(ToolKind::Sword) => {
140                    next.control_l.position = next.hand_l.position * 0.2
141                        + Vec3::new(
142                            s_a.sc.0,
143                            s_a.sc.1 - slow * 2.0 * speednorm,
144                            s_a.sc.2 + direction * -5.0 - slow * 2.0 * speednorm,
145                        );
146                    next.control_r.position = next.control_l.position;
147
148                    next.hand_l.position = Vec3::new(s_a.shl.0 - 0.5, s_a.shl.1, s_a.shl.2);
149                    next.hand_l.orientation =
150                        Quaternion::rotation_x(s_a.shl.3) * Quaternion::rotation_y(s_a.shl.4);
151                    next.control_l.orientation = Quaternion::rotation_x(s_a.sc.3 + u_slow * 0.05)
152                        * Quaternion::rotation_z(u_slowalt * 0.04);
153                    next.control_r.orientation = Quaternion::rotation_x(s_a.sc.3 + u_slow * 0.15)
154                        * Quaternion::rotation_z(u_slowalt * 0.08);
155                    next.hand_r.position = Vec3::zero();
156                    next.hand_r.orientation =
157                        next.hand_l.orientation * Quaternion::rotation_y(PI * 0.3);
158                },
159                Some(ToolKind::Axe) => {
160                    next.main.position = Vec3::new(0.0, 0.0, 0.0);
161                    next.main.orientation = Quaternion::rotation_x(0.0);
162
163                    if speed < 0.5 {
164                        next.head.position =
165                            Vec3::new(0.0, 0.0 + s_a.head.0, s_a.head.1 + u_slow * 0.1);
166                        next.head.orientation = Quaternion::rotation_z(head_look.x)
167                            * Quaternion::rotation_x(0.35 + head_look.y.abs() + look_dir.z * 0.7);
168                        next.chest.orientation = Quaternion::rotation_x(-0.35)
169                            * Quaternion::rotation_y(u_slowalt * 0.04)
170                            * Quaternion::rotation_z(0.15);
171                        next.belt.position = Vec3::new(0.0, 1.0 + s_a.belt.0, s_a.belt.1);
172                        next.belt.orientation = Quaternion::rotation_x(0.15)
173                            * Quaternion::rotation_y(u_slowalt * 0.03)
174                            * Quaternion::rotation_z(0.15);
175                        next.shorts.position = Vec3::new(0.0, 1.0 + s_a.shorts.0, s_a.shorts.1);
176                        next.shorts.orientation =
177                            Quaternion::rotation_x(0.15) * Quaternion::rotation_z(0.25);
178                    }
179                    next.hand_l.position = Vec3::new(s_a.ahl.0, s_a.ahl.1, s_a.ahl.2);
180                    next.hand_l.orientation =
181                        Quaternion::rotation_x(s_a.ahl.3) * Quaternion::rotation_y(s_a.ahl.4);
182                    next.hand_r.position = Vec3::new(s_a.ahr.0, s_a.ahr.1 + 2.0, s_a.ahr.2);
183                    next.hand_r.orientation = Quaternion::rotation_x(s_a.ahr.3)
184                        * Quaternion::rotation_z(s_a.ahr.5)
185                        * Quaternion::rotation_y(PI * -0.25);
186
187                    next.control.position =
188                        Vec3::new(s_a.ac.0, s_a.ac.1 - 4.0, s_a.ac.2 + direction * -5.0);
189                    next.control.orientation = Quaternion::rotation_x(s_a.ac.3)
190                        * Quaternion::rotation_y(s_a.ac.4)
191                        * Quaternion::rotation_z(s_a.ac.5);
192                },
193                Some(ToolKind::Hammer | ToolKind::Pick) => {
194                    next.hand_l.position = Vec3::new(s_a.hhl.0, s_a.hhl.1 + 3.0, s_a.hhl.2 - 1.0);
195                    next.hand_l.orientation = Quaternion::rotation_x(s_a.hhl.3)
196                        * Quaternion::rotation_y(s_a.hhl.4)
197                        * Quaternion::rotation_z(s_a.hhl.5);
198                    next.hand_r.position = Vec3::new(s_a.hhr.0, s_a.hhr.1 + 3.0, s_a.hhr.2 + 1.0);
199                    next.hand_r.orientation = Quaternion::rotation_x(s_a.hhr.3)
200                        * Quaternion::rotation_y(s_a.hhr.4)
201                        * Quaternion::rotation_z(s_a.hhr.5);
202
203                    next.control.position =
204                        Vec3::new(s_a.hc.0 - 1.0, s_a.hc.1, s_a.hc.2 + direction * -5.0 - 3.0);
205                    next.control.orientation = Quaternion::rotation_x(s_a.hc.3 + u_slow * 0.15)
206                        * Quaternion::rotation_y(s_a.hc.4)
207                        * Quaternion::rotation_z(s_a.hc.5 + u_slowalt * 0.07);
208                },
209                Some(ToolKind::Staff) | Some(ToolKind::Sceptre) => {
210                    next.control_l.position = next.hand_l.position * 0.2
211                        + Vec3::new(
212                            s_a.sc.0 + 1.0,
213                            s_a.sc.1 - slow * 2.0 * speednorm - 3.0,
214                            s_a.sc.2 + direction * -5.0 - slow * 2.0 * speednorm - 3.0,
215                        );
216                    next.control_r.position = next.control_l.position;
217
218                    next.hand_l.position = Vec3::new(s_a.shl.0 - 0.5, s_a.shl.1, s_a.shl.2 + 0.0);
219                    next.hand_l.orientation =
220                        Quaternion::rotation_x(s_a.shl.3) * Quaternion::rotation_y(s_a.shl.4);
221                    next.control_l.orientation = Quaternion::rotation_x(s_a.sc.3 + u_slow * 0.05)
222                        * Quaternion::rotation_z(u_slowalt * 0.04);
223                    next.control_r.orientation = Quaternion::rotation_x(s_a.sc.3 + u_slow * 0.15)
224                        * Quaternion::rotation_z(u_slowalt * 0.08);
225                    next.hand_r.position = Vec3::new(0.0, 0.0, 8.0);
226                    next.hand_r.orientation =
227                        next.hand_l.orientation * Quaternion::rotation_y(PI * 0.3);
228                },
229                Some(ToolKind::Bow) => {
230                    next.main.position = Vec3::new(0.0, 0.0, 0.0);
231                    next.main.orientation = Quaternion::rotation_x(0.0);
232                    next.hand_l.position = Vec3::new(s_a.bhl.0, s_a.bhl.1, s_a.bhl.2);
233                    next.hand_l.orientation = Quaternion::rotation_x(s_a.bhl.3);
234                    next.hand_r.position = Vec3::new(s_a.bhr.0, s_a.bhr.1, s_a.bhr.2);
235                    next.hand_r.orientation = Quaternion::rotation_x(s_a.bhr.3);
236
237                    next.hold.position = Vec3::new(0.0, -1.0, -5.2);
238                    next.hold.orientation = Quaternion::rotation_x(-PI / 2.0);
239                    next.hold.scale = Vec3::one() * 1.0;
240
241                    next.control.position =
242                        Vec3::new(s_a.bc.0, s_a.bc.1, s_a.bc.2 + direction * -5.0);
243                    next.control.orientation = Quaternion::rotation_x(u_slow * 0.06)
244                        * Quaternion::rotation_y(s_a.bc.4)
245                        * Quaternion::rotation_z(s_a.bc.5 + u_slowalt * 0.1);
246                },
247                Some(ToolKind::Debug) => {
248                    next.hand_l.position = Vec3::new(-7.0, 4.0, 3.0);
249                    next.hand_l.orientation = Quaternion::rotation_x(1.27);
250                    next.main.position = Vec3::new(-5.0, 5.0, 23.0);
251                    next.main.orientation = Quaternion::rotation_x(PI);
252                },
253                Some(ToolKind::Farming) => {
254                    if speed < 0.5 {
255                        next.head.orientation = Quaternion::rotation_z(head_look.x)
256                            * Quaternion::rotation_x(-0.2 + head_look.y.abs() + look_dir.z * 0.7);
257                    }
258                    next.hand_l.position = Vec3::new(9.0, 1.0, 1.0);
259                    next.hand_l.orientation = Quaternion::rotation_x(PI / 2.0);
260                    next.hand_r.position = Vec3::new(9.0, 1.0, 11.0);
261                    next.hand_r.orientation = Quaternion::rotation_x(PI / 2.0);
262                    next.main.position = Vec3::new(7.5, 7.5, 13.2);
263                    next.main.orientation = Quaternion::rotation_y(PI);
264
265                    next.control.position = Vec3::new(-11.0 + slow * 2.0, 1.8, 4.0);
266                    next.control.orientation = Quaternion::rotation_x(u_slow * 0.1)
267                        * Quaternion::rotation_y(0.6 + u_slow * 0.1)
268                        * Quaternion::rotation_z(u_slowalt * 0.1);
269                },
270                Some(ToolKind::Shovel) => {
271                    next.hand_l.position = Vec3::new(8.0, 6.0, 3.0);
272                    next.hand_l.orientation = Quaternion::rotation_x(PI / 2.0);
273                    next.hand_r.position = Vec3::new(8.0, 6.0, 15.0);
274                    next.hand_r.orientation = Quaternion::rotation_x(PI / 2.0);
275                    next.main.position = Vec3::new(7.5, 7.5, 13.2);
276                    next.main.orientation = Quaternion::rotation_y(PI);
277
278                    next.control.position = Vec3::new(-11.0 + slow * 0.02, 1.8, 4.0);
279                    next.control.orientation = Quaternion::rotation_x(u_slow * 0.01)
280                        * Quaternion::rotation_y(0.8 + u_slow * 0.01)
281                        * Quaternion::rotation_z(u_slowalt * 0.01);
282                },
283                Some(ToolKind::Instrument) => {
284                    if let Some(AbilitySpec::Custom(spec)) = active_tool_spec {
285                        match spec.as_str() {
286                            "Lyre" | "IcyTalharpa" | "WildskinDrum" | "Steeltonguedrum" => {
287                                if speed < 0.5 {
288                                    next.head.orientation = Quaternion::rotation_z(head_look.x)
289                                        * Quaternion::rotation_x(
290                                            0.0 + head_look.y.abs() + look_dir.z * 0.7,
291                                        );
292                                }
293                                next.hand_l.position = Vec3::new(0.0, 2.0, -4.0);
294                                next.hand_l.orientation =
295                                    Quaternion::rotation_x(PI / 2.0) * Quaternion::rotation_z(PI);
296                                next.hand_r.position = Vec3::new(-4.0, 2.0, 6.0);
297                                next.hand_r.orientation = Quaternion::rotation_x(PI / 2.0)
298                                    * Quaternion::rotation_z(PI / 2.0);
299                                next.main.position = Vec3::new(-2.0, 10.0, 12.0);
300                                next.main.orientation = Quaternion::rotation_y(PI);
301
302                                next.control.position = Vec3::new(-2.0 + slow * 0.5, 0.5, 0.8);
303                                next.control.orientation = Quaternion::rotation_x(u_slow * 0.1)
304                                    * Quaternion::rotation_y(2.0 + u_slow * 0.1)
305                                    * Quaternion::rotation_z(u_slowalt * 0.1);
306                            },
307                            "Flute" | "GlassFlute" => {
308                                if speed < 0.5 {
309                                    next.head.orientation = Quaternion::rotation_z(head_look.x)
310                                        * Quaternion::rotation_x(
311                                            0.0 + head_look.y.abs() + look_dir.z * 0.7,
312                                        );
313                                }
314                                next.hand_l.position = Vec3::new(-1.0, 4.0, -1.0);
315                                next.hand_l.orientation = Quaternion::rotation_x(2.5)
316                                    * Quaternion::rotation_y(0.9)
317                                    * Quaternion::rotation_z(PI);
318                                next.hand_r.position = Vec3::new(-4.0, 2.0, 6.0);
319                                next.hand_r.orientation = Quaternion::rotation_x(PI / 2.0);
320                                next.main.position = Vec3::new(12.0, 3.0, 4.0);
321                                next.main.orientation =
322                                    Quaternion::rotation_x(PI) * Quaternion::rotation_y(-1.2);
323
324                                next.control.position = Vec3::new(-2.0 + slow * 0.5, 0.5, 0.8);
325                                next.control.orientation = Quaternion::rotation_x(u_slow * 0.1)
326                                    * Quaternion::rotation_y(2.0 + u_slow * 0.1)
327                                    * Quaternion::rotation_z(u_slowalt * 0.1);
328                            },
329                            "DoubleBass" => {
330                                if speed < 0.5 {
331                                    next.head.orientation = Quaternion::rotation_z(head_look.x)
332                                        * Quaternion::rotation_x(
333                                            0.0 + head_look.y.abs() + look_dir.z * 0.7,
334                                        );
335                                }
336                                next.hand_l.position = Vec3::new(-6.0, 6.0, -5.0);
337                                next.hand_l.orientation = Quaternion::rotation_x((PI / 2.0) + 0.3)
338                                    * Quaternion::rotation_y(0.7)
339                                    * Quaternion::rotation_y(0.25)
340                                    * Quaternion::rotation_z(PI);
341                                next.hand_r.position = Vec3::new(-2.0, 4.0, 5.0);
342                                next.hand_r.orientation = Quaternion::rotation_x(PI / 2.0)
343                                    * Quaternion::rotation_z(PI / 2.0);
344                                next.main.position = Vec3::new(-14.0, 6.0, -6.0);
345                                next.main.orientation = Quaternion::rotation_x(-0.2)
346                                    * Quaternion::rotation_y(1.2)
347                                    * Quaternion::rotation_z(-1.2);
348
349                                next.control.position = Vec3::new(-2.0 + slow * 0.5, 0.5, 0.8);
350                                next.control.orientation = Quaternion::rotation_x(u_slow * 0.1)
351                                    * Quaternion::rotation_y(2.0 + u_slow * 0.1)
352                                    * Quaternion::rotation_z(u_slowalt * 0.1);
353                            },
354                            "Kora" => {
355                                if speed < 0.5 {
356                                    next.head.orientation = Quaternion::rotation_z(head_look.x)
357                                        * Quaternion::rotation_x(
358                                            0.0 + head_look.y.abs() + look_dir.z * 0.7,
359                                        );
360                                }
361                                next.hand_l.position = Vec3::new(-6.0, 6.0, -5.0);
362                                next.hand_l.orientation = Quaternion::rotation_x((PI / 2.0) + 0.3)
363                                    * Quaternion::rotation_y(0.7)
364                                    * Quaternion::rotation_y(0.25)
365                                    * Quaternion::rotation_z(PI);
366                                next.hand_r.position = Vec3::new(-2.0, 4.0, 5.0);
367                                next.hand_r.orientation = Quaternion::rotation_x(PI / 2.0)
368                                    * Quaternion::rotation_z(PI / 2.0);
369                                next.main.position = Vec3::new(-14.0, 6.0, -6.0);
370                                next.main.orientation = Quaternion::rotation_x(-0.2)
371                                    * Quaternion::rotation_y(1.2)
372                                    * Quaternion::rotation_z(1.3);
373
374                                next.control.position = Vec3::new(-2.0 + slow * 0.5, 0.5, 0.8);
375                                next.control.orientation = Quaternion::rotation_x(u_slow * 0.1)
376                                    * Quaternion::rotation_y(2.0 + u_slow * 0.1)
377                                    * Quaternion::rotation_z(u_slowalt * 0.1);
378                            },
379                            "Washboard" => {
380                                if speed < 0.5 {
381                                    next.head.orientation = Quaternion::rotation_z(head_look.x)
382                                        * Quaternion::rotation_x(
383                                            0.0 + head_look.y.abs() + look_dir.z * 0.7,
384                                        );
385                                }
386                                next.hand_l.position = Vec3::new(0.0, 2.0, -4.0);
387                                next.hand_l.orientation =
388                                    Quaternion::rotation_x(PI / 2.0) * Quaternion::rotation_z(PI);
389                                next.hand_r.position = Vec3::new(-4.0, 2.0, 6.0);
390                                next.hand_r.orientation = Quaternion::rotation_x(PI / 2.0)
391                                    * Quaternion::rotation_z(PI / 2.0);
392                                next.main.position = Vec3::new(-2.0, 10.0, 12.0);
393                                next.main.orientation = Quaternion::rotation_y(PI);
394
395                                next.control.position = Vec3::new(-2.0 + slow * 0.5, 0.5, 0.8);
396                                next.control.orientation = Quaternion::rotation_x(u_slow * 0.1)
397                                    * Quaternion::rotation_y(2.0 + u_slow * 0.1)
398                                    * Quaternion::rotation_z(u_slowalt * 0.1);
399                            },
400                            "Kalimba" => {
401                                if speed < 0.5 {
402                                    next.head.orientation = Quaternion::rotation_z(head_look.x)
403                                        * Quaternion::rotation_x(
404                                            0.0 + head_look.y.abs() + look_dir.z * 0.7,
405                                        );
406                                }
407                                next.hand_l.position = Vec3::new(0.0, 2.0, -4.0);
408                                next.hand_l.orientation =
409                                    Quaternion::rotation_x(PI / 2.0) * Quaternion::rotation_z(PI);
410                                next.hand_r.position = Vec3::new(-4.0, 2.0, 6.0);
411                                next.hand_r.orientation = Quaternion::rotation_x(PI / 2.0)
412                                    * Quaternion::rotation_z(PI / 2.0);
413                                next.main.position = Vec3::new(0.0, 7.0, 12.0);
414                                next.main.orientation =
415                                    Quaternion::rotation_y(PI) * Quaternion::rotation_z(PI);
416
417                                next.control.position = Vec3::new(-2.0 + slow * 0.5, 0.5, 0.8);
418                                next.control.orientation = Quaternion::rotation_x(u_slow * 0.1)
419                                    * Quaternion::rotation_y(2.0 + u_slow * 0.1)
420                                    * Quaternion::rotation_z(u_slowalt * 0.1);
421                            },
422                            "Lute" | "Shamisen" | "Banjo" => {
423                                if speed < 0.5 {
424                                    next.head.orientation = Quaternion::rotation_z(head_look.x)
425                                        * Quaternion::rotation_x(
426                                            0.0 + head_look.y.abs() + look_dir.z * 0.7,
427                                        );
428                                }
429                                next.hand_l.position = Vec3::new(-2.0, 5.0, -5.0);
430                                next.hand_l.orientation = Quaternion::rotation_x((PI / 2.0) + 0.3)
431                                    * Quaternion::rotation_y(0.7)
432                                    * Quaternion::rotation_y(0.25)
433                                    * Quaternion::rotation_z(PI);
434                                next.hand_r.position = Vec3::new(-5.0, 2.0, 6.0);
435                                next.hand_r.orientation = Quaternion::rotation_x(PI / 2.0)
436                                    * Quaternion::rotation_z(PI / 2.0);
437                                next.main.position = Vec3::new(-2.0, 4.0, -12.0);
438                                next.main.orientation = Quaternion::rotation_x(0.0)
439                                    * Quaternion::rotation_y(0.2)
440                                    * Quaternion::rotation_z(-1.3);
441
442                                next.control.position = Vec3::new(-2.0 + slow * 0.5, 0.5, 0.8);
443                                next.control.orientation = Quaternion::rotation_x(u_slow * 0.1)
444                                    * Quaternion::rotation_y(2.0 + u_slow * 0.1)
445                                    * Quaternion::rotation_z(u_slowalt * 0.1);
446                            },
447                            "Guitar" | "DarkGuitar" => {
448                                if speed < 0.5 {
449                                    next.head.orientation = Quaternion::rotation_z(head_look.x)
450                                        * Quaternion::rotation_x(
451                                            0.0 + head_look.y.abs() + look_dir.z * 0.7,
452                                        );
453                                }
454                                next.hand_l.position = Vec3::new(0.0, 5.0, -4.0);
455                                next.hand_l.orientation = Quaternion::rotation_x((PI / 2.0) + 0.3)
456                                    * Quaternion::rotation_y(0.7)
457                                    * Quaternion::rotation_y(0.25)
458                                    * Quaternion::rotation_z(PI);
459                                next.hand_r.position = Vec3::new(-5.0, 2.0, 6.0);
460                                next.hand_r.orientation = Quaternion::rotation_x(PI / 2.0)
461                                    * Quaternion::rotation_z(PI / 2.0);
462                                next.main.position = Vec3::new(-2.0, 4.0, -12.0);
463                                next.main.orientation = Quaternion::rotation_x(0.0)
464                                    * Quaternion::rotation_y(0.2)
465                                    * Quaternion::rotation_z(-1.3);
466
467                                next.control.position = Vec3::new(-2.0 + slow * 0.5, 0.5, 0.8);
468                                next.control.orientation = Quaternion::rotation_x(u_slow * 0.1)
469                                    * Quaternion::rotation_y(2.0 + u_slow * 0.1)
470                                    * Quaternion::rotation_z(u_slowalt * 0.1);
471                            },
472                            "Melodica" => {
473                                if speed < 0.5 {
474                                    next.head.orientation = Quaternion::rotation_z(head_look.x)
475                                        * Quaternion::rotation_x(
476                                            0.0 + head_look.y.abs() + look_dir.z * 0.7,
477                                        );
478                                }
479                                next.hand_l.position = Vec3::new(-1.0, 3.0, -2.0);
480                                next.hand_l.orientation = Quaternion::rotation_x(2.0)
481                                    * Quaternion::rotation_z(-0.5)
482                                    * Quaternion::rotation_y(0.4)
483                                    * Quaternion::rotation_z(PI);
484                                next.hand_r.position = Vec3::new(-4.0, 2.0, 6.0);
485                                next.hand_r.orientation = Quaternion::rotation_x(1.2)
486                                    * Quaternion::rotation_y(-0.3)
487                                    * Quaternion::rotation_z(1.5);
488                                next.main.position = Vec3::new(-14.0, 3.0, -6.0);
489                                next.main.orientation = Quaternion::rotation_x(0.0)
490                                    * Quaternion::rotation_y(1.1)
491                                    * Quaternion::rotation_z(-1.5);
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                            "Sitar" => {
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, 5.0, -2.5);
506                                next.hand_l.orientation = Quaternion::rotation_x((PI / 2.0) + 0.3)
507                                    * Quaternion::rotation_y(0.2)
508                                    * Quaternion::rotation_y(0.25)
509                                    * Quaternion::rotation_z(PI);
510                                next.hand_r.position = Vec3::new(-5.0, 2.0, 6.0);
511                                next.hand_r.orientation = Quaternion::rotation_x(PI / 2.0)
512                                    * Quaternion::rotation_z(PI / 2.0);
513                                next.main.position = Vec3::new(-2.0, 4.0, -12.0);
514                                next.main.orientation = Quaternion::rotation_x(0.0)
515                                    * Quaternion::rotation_y(0.2)
516                                    * Quaternion::rotation_z(-1.3);
517
518                                next.control.position = Vec3::new(-2.0 + slow * 0.5, 0.5, 0.8);
519                                next.control.orientation = Quaternion::rotation_x(u_slow * 0.1)
520                                    * Quaternion::rotation_y(2.0 + u_slow * 0.1)
521                                    * Quaternion::rotation_z(u_slowalt * 0.1);
522                            },
523                            _ => {},
524                        }
525                    }
526                },
527                Some(ToolKind::Shield) => {
528                    next.hand_l.position = Vec3::new(0.0, -2.0, 0.0);
529                    next.hand_l.orientation = Quaternion::rotation_x(PI / 2.0);
530
531                    next.hand_r.position = Vec3::new(0.0, 0.0, 0.0);
532                    next.hand_r.orientation =
533                        Quaternion::rotation_x(PI / 2.0) * Quaternion::rotation_y(2.0);
534
535                    next.control.position = Vec3::new(0.0, 7.0, 4.0);
536                    next.control.orientation =
537                        Quaternion::rotation_y(-0.5) * Quaternion::rotation_z(-1.25);
538                },
539                _ => {},
540            },
541            ((_, _), _, _) => {},
542        };
543        match hands {
544            (Some(Hands::One), _) => {
545                next.control_l.position =
546                    next.hand_l.position * Vec3::new(0.5, 0.5, 0.3) + Vec3::new(-4.0, 0.0, 0.0);
547                next.control_l.orientation = Quaternion::lerp(
548                    next.hand_l.orientation,
549                    Quaternion::rotation_x(PI * -0.5),
550                    0.65,
551                );
552                next.hand_l.position = Vec3::new(0.0, -2.0, 0.0);
553                next.hand_l.orientation = Quaternion::rotation_x(PI * 0.5);
554            },
555            (_, _) => {},
556        };
557        match hands {
558            (None | Some(Hands::One), Some(Hands::One)) => {
559                next.control_r.position =
560                    next.hand_r.position * Vec3::new(0.5, 0.5, 0.3) + Vec3::new(4.0, 0.0, 0.0);
561                next.control_r.orientation = Quaternion::lerp(
562                    next.hand_r.orientation,
563                    Quaternion::rotation_x(PI * -0.5),
564                    0.65,
565                );
566                next.hand_r.position = Vec3::new(0.0, -2.0, 0.0);
567                next.hand_r.orientation = Quaternion::rotation_x(PI * 0.5);
568            },
569            (_, _) => {},
570        };
571        match hands {
572            (None, None) | (None, Some(Hands::One)) => {
573                next.hand_l.position = Vec3::new(-8.0, 2.0, 1.0);
574                next.hand_l.orientation =
575                    Quaternion::rotation_x(0.5) * Quaternion::rotation_y(0.25);
576            },
577            (_, _) => {},
578        };
579        match hands {
580            (None, None) | (Some(Hands::One), None) => {
581                // next.hand_r.position = Vec3::new(8.0, 2.0, 1.0);
582                // next.hand_r.orientation =
583                //     Quaternion::rotation_x(0.5) *
584                // Quaternion::rotation_y(-0.25);
585            },
586            (_, _) => {},
587        };
588
589        if let (None, Some(Hands::Two)) = hands {
590            next.second = next.main;
591        }
592
593        next.do_hold_lantern(s_a, anim_time, anim_time, speednorm, 0.0, tilt);
594
595        next
596    }
597}