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", 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.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.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.back.orientation = Quaternion::rotation_x(-0.2);
137            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.35 + head_look.y.abs() + look_dir.z * 0.7);
170                        next.chest.orientation = Quaternion::rotation_x(-0.35)
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 + 2.0, s_a.ahr.2);
185                    next.hand_r.orientation = Quaternion::rotation_x(s_a.ahr.3)
186                        * Quaternion::rotation_z(s_a.ahr.5)
187                        * Quaternion::rotation_y(PI * -0.25);
188
189                    next.control.position =
190                        Vec3::new(s_a.ac.0, s_a.ac.1 - 4.0, s_a.ac.2 + direction * -5.0);
191                    next.control.orientation = Quaternion::rotation_x(s_a.ac.3)
192                        * Quaternion::rotation_y(s_a.ac.4)
193                        * Quaternion::rotation_z(s_a.ac.5);
194                },
195                Some(ToolKind::Hammer | ToolKind::Pick) => {
196                    next.hand_l.position = Vec3::new(s_a.hhl.0, s_a.hhl.1 + 3.0, s_a.hhl.2 - 1.0);
197                    next.hand_l.orientation = Quaternion::rotation_x(s_a.hhl.3)
198                        * Quaternion::rotation_y(s_a.hhl.4)
199                        * Quaternion::rotation_z(s_a.hhl.5);
200                    next.hand_r.position = Vec3::new(s_a.hhr.0, s_a.hhr.1 + 3.0, s_a.hhr.2 + 1.0);
201                    next.hand_r.orientation = Quaternion::rotation_x(s_a.hhr.3)
202                        * Quaternion::rotation_y(s_a.hhr.4)
203                        * Quaternion::rotation_z(s_a.hhr.5);
204
205                    next.control.position =
206                        Vec3::new(s_a.hc.0 - 1.0, s_a.hc.1, s_a.hc.2 + direction * -5.0 - 3.0);
207                    next.control.orientation = Quaternion::rotation_x(s_a.hc.3 + u_slow * 0.15)
208                        * Quaternion::rotation_y(s_a.hc.4)
209                        * Quaternion::rotation_z(s_a.hc.5 + u_slowalt * 0.07);
210                },
211                Some(ToolKind::Staff) | Some(ToolKind::Sceptre) => {
212                    next.control_l.position = next.hand_l.position * 0.2
213                        + Vec3::new(
214                            s_a.sc.0 + 1.0,
215                            s_a.sc.1 - slow * 2.0 * speednorm - 3.0,
216                            s_a.sc.2 + direction * -5.0 - slow * 2.0 * speednorm - 3.0,
217                        );
218                    next.control_r.position = next.control_l.position;
219
220                    next.hand_l.position = Vec3::new(s_a.shl.0 - 0.5, s_a.shl.1, s_a.shl.2 + 0.0);
221                    next.hand_l.orientation =
222                        Quaternion::rotation_x(s_a.shl.3) * Quaternion::rotation_y(s_a.shl.4);
223                    next.control_l.orientation = Quaternion::rotation_x(s_a.sc.3 + u_slow * 0.05)
224                        * Quaternion::rotation_z(u_slowalt * 0.04);
225                    next.control_r.orientation = Quaternion::rotation_x(s_a.sc.3 + u_slow * 0.15)
226                        * Quaternion::rotation_z(u_slowalt * 0.08);
227                    next.hand_r.position = Vec3::new(0.0, 0.0, 8.0);
228                    next.hand_r.orientation =
229                        next.hand_l.orientation * Quaternion::rotation_y(PI * 0.3);
230                },
231                Some(ToolKind::Bow) => {
232                    next.main.position = Vec3::new(0.0, 0.0, 0.0);
233                    next.main.orientation = Quaternion::rotation_x(0.0);
234                    next.hand_l.position = Vec3::new(s_a.bhl.0, s_a.bhl.1, s_a.bhl.2);
235                    next.hand_l.orientation = Quaternion::rotation_x(s_a.bhl.3);
236                    next.hand_r.position = Vec3::new(s_a.bhr.0, s_a.bhr.1, s_a.bhr.2);
237                    next.hand_r.orientation = Quaternion::rotation_x(s_a.bhr.3);
238
239                    next.hold.position = Vec3::new(0.0, -1.0, -5.2);
240                    next.hold.orientation = Quaternion::rotation_x(-PI / 2.0);
241                    next.hold.scale = Vec3::one() * 1.0;
242
243                    next.control.position =
244                        Vec3::new(s_a.bc.0, s_a.bc.1, s_a.bc.2 + direction * -5.0);
245                    next.control.orientation = Quaternion::rotation_x(u_slow * 0.06)
246                        * Quaternion::rotation_y(s_a.bc.4)
247                        * Quaternion::rotation_z(s_a.bc.5 + u_slowalt * 0.1);
248                },
249                Some(ToolKind::Debug) => {
250                    next.hand_l.position = Vec3::new(-7.0, 4.0, 3.0);
251                    next.hand_l.orientation = Quaternion::rotation_x(1.27);
252                    next.main.position = Vec3::new(-5.0, 5.0, 23.0);
253                    next.main.orientation = Quaternion::rotation_x(PI);
254                },
255                Some(ToolKind::Farming) => {
256                    if speed < 0.5 {
257                        next.head.orientation = Quaternion::rotation_z(head_look.x)
258                            * Quaternion::rotation_x(-0.2 + head_look.y.abs() + look_dir.z * 0.7);
259                    }
260                    next.hand_l.position = Vec3::new(9.0, 1.0, 1.0);
261                    next.hand_l.orientation = Quaternion::rotation_x(PI / 2.0);
262                    next.hand_r.position = Vec3::new(9.0, 1.0, 11.0);
263                    next.hand_r.orientation = Quaternion::rotation_x(PI / 2.0);
264                    next.main.position = Vec3::new(7.5, 7.5, 13.2);
265                    next.main.orientation = Quaternion::rotation_y(PI);
266
267                    next.control.position = Vec3::new(-11.0 + slow * 2.0, 1.8, 4.0);
268                    next.control.orientation = Quaternion::rotation_x(u_slow * 0.1)
269                        * Quaternion::rotation_y(0.6 + u_slow * 0.1)
270                        * Quaternion::rotation_z(u_slowalt * 0.1);
271                },
272                Some(ToolKind::Shovel) => {
273                    next.hand_l.position = Vec3::new(8.0, 6.0, 3.0);
274                    next.hand_l.orientation = Quaternion::rotation_x(PI / 2.0);
275                    next.hand_r.position = Vec3::new(8.0, 6.0, 15.0);
276                    next.hand_r.orientation = Quaternion::rotation_x(PI / 2.0);
277                    next.main.position = Vec3::new(7.5, 7.5, 13.2);
278                    next.main.orientation = Quaternion::rotation_y(PI);
279
280                    next.control.position = Vec3::new(-11.0 + slow * 0.02, 1.8, 4.0);
281                    next.control.orientation = Quaternion::rotation_x(u_slow * 0.01)
282                        * Quaternion::rotation_y(0.8 + u_slow * 0.01)
283                        * Quaternion::rotation_z(u_slowalt * 0.01);
284                },
285                Some(ToolKind::Instrument) => {
286                    if let Some(AbilitySpec::Custom(spec)) = active_tool_spec {
287                        match spec.as_str() {
288                            "Lyre" | "IcyTalharpa" | "WildskinDrum" | "Steeltonguedrum" => {
289                                if speed < 0.5 {
290                                    next.head.orientation = Quaternion::rotation_z(head_look.x)
291                                        * Quaternion::rotation_x(
292                                            0.0 + head_look.y.abs() + look_dir.z * 0.7,
293                                        );
294                                }
295                                next.hand_l.position = Vec3::new(0.0, 2.0, -4.0);
296                                next.hand_l.orientation =
297                                    Quaternion::rotation_x(PI / 2.0) * Quaternion::rotation_z(PI);
298                                next.hand_r.position = Vec3::new(-4.0, 2.0, 6.0);
299                                next.hand_r.orientation = Quaternion::rotation_x(PI / 2.0)
300                                    * Quaternion::rotation_z(PI / 2.0);
301                                next.main.position = Vec3::new(-2.0, 10.0, 12.0);
302                                next.main.orientation = Quaternion::rotation_y(PI);
303
304                                next.control.position = Vec3::new(-2.0 + slow * 0.5, 0.5, 0.8);
305                                next.control.orientation = Quaternion::rotation_x(u_slow * 0.1)
306                                    * Quaternion::rotation_y(2.0 + u_slow * 0.1)
307                                    * Quaternion::rotation_z(u_slowalt * 0.1);
308                            },
309                            "Flute" | "GlassFlute" => {
310                                if speed < 0.5 {
311                                    next.head.orientation = Quaternion::rotation_z(head_look.x)
312                                        * Quaternion::rotation_x(
313                                            0.0 + head_look.y.abs() + look_dir.z * 0.7,
314                                        );
315                                }
316                                next.hand_l.position = Vec3::new(-1.0, 4.0, -1.0);
317                                next.hand_l.orientation = Quaternion::rotation_x(2.5)
318                                    * Quaternion::rotation_y(0.9)
319                                    * Quaternion::rotation_z(PI);
320                                next.hand_r.position = Vec3::new(-4.0, 2.0, 6.0);
321                                next.hand_r.orientation = Quaternion::rotation_x(PI / 2.0);
322                                next.main.position = Vec3::new(12.0, 3.0, 4.0);
323                                next.main.orientation =
324                                    Quaternion::rotation_x(PI) * Quaternion::rotation_y(-1.2);
325
326                                next.control.position = Vec3::new(-2.0 + slow * 0.5, 0.5, 0.8);
327                                next.control.orientation = Quaternion::rotation_x(u_slow * 0.1)
328                                    * Quaternion::rotation_y(2.0 + u_slow * 0.1)
329                                    * Quaternion::rotation_z(u_slowalt * 0.1);
330                            },
331                            "DoubleBass" => {
332                                if speed < 0.5 {
333                                    next.head.orientation = Quaternion::rotation_z(head_look.x)
334                                        * Quaternion::rotation_x(
335                                            0.0 + head_look.y.abs() + look_dir.z * 0.7,
336                                        );
337                                }
338                                next.hand_l.position = Vec3::new(-6.0, 6.0, -5.0);
339                                next.hand_l.orientation = Quaternion::rotation_x((PI / 2.0) + 0.3)
340                                    * Quaternion::rotation_y(0.7)
341                                    * Quaternion::rotation_y(0.25)
342                                    * Quaternion::rotation_z(PI);
343                                next.hand_r.position = Vec3::new(-2.0, 4.0, 5.0);
344                                next.hand_r.orientation = Quaternion::rotation_x(PI / 2.0)
345                                    * Quaternion::rotation_z(PI / 2.0);
346                                next.main.position = Vec3::new(-14.0, 6.0, -6.0);
347                                next.main.orientation = Quaternion::rotation_x(-0.2)
348                                    * Quaternion::rotation_y(1.2)
349                                    * Quaternion::rotation_z(-1.2);
350
351                                next.control.position = Vec3::new(-2.0 + slow * 0.5, 0.5, 0.8);
352                                next.control.orientation = Quaternion::rotation_x(u_slow * 0.1)
353                                    * Quaternion::rotation_y(2.0 + u_slow * 0.1)
354                                    * Quaternion::rotation_z(u_slowalt * 0.1);
355                            },
356                            "Kora" => {
357                                if speed < 0.5 {
358                                    next.head.orientation = Quaternion::rotation_z(head_look.x)
359                                        * Quaternion::rotation_x(
360                                            0.0 + head_look.y.abs() + look_dir.z * 0.7,
361                                        );
362                                }
363                                next.hand_l.position = Vec3::new(-6.0, 6.0, -5.0);
364                                next.hand_l.orientation = Quaternion::rotation_x((PI / 2.0) + 0.3)
365                                    * Quaternion::rotation_y(0.7)
366                                    * Quaternion::rotation_y(0.25)
367                                    * Quaternion::rotation_z(PI);
368                                next.hand_r.position = Vec3::new(-2.0, 4.0, 5.0);
369                                next.hand_r.orientation = Quaternion::rotation_x(PI / 2.0)
370                                    * Quaternion::rotation_z(PI / 2.0);
371                                next.main.position = Vec3::new(-14.0, 6.0, -6.0);
372                                next.main.orientation = Quaternion::rotation_x(-0.2)
373                                    * Quaternion::rotation_y(1.2)
374                                    * Quaternion::rotation_z(1.3);
375
376                                next.control.position = Vec3::new(-2.0 + slow * 0.5, 0.5, 0.8);
377                                next.control.orientation = Quaternion::rotation_x(u_slow * 0.1)
378                                    * Quaternion::rotation_y(2.0 + u_slow * 0.1)
379                                    * Quaternion::rotation_z(u_slowalt * 0.1);
380                            },
381                            "Washboard" | "TimbrelOfChaos" | "Rhythmo" | "StarlightConch" => {
382                                if speed < 0.5 {
383                                    next.head.orientation = Quaternion::rotation_z(head_look.x)
384                                        * Quaternion::rotation_x(
385                                            0.0 + head_look.y.abs() + look_dir.z * 0.7,
386                                        );
387                                }
388                                next.hand_l.position = Vec3::new(0.0, 2.0, -4.0);
389                                next.hand_l.orientation =
390                                    Quaternion::rotation_x(PI / 2.0) * Quaternion::rotation_z(PI);
391                                next.hand_r.position = Vec3::new(-4.0, 2.0, 6.0);
392                                next.hand_r.orientation = Quaternion::rotation_x(PI / 2.0)
393                                    * Quaternion::rotation_z(PI / 2.0);
394                                next.main.position = Vec3::new(-2.0, 10.0, 12.0);
395                                next.main.orientation = Quaternion::rotation_y(PI);
396
397                                next.control.position = Vec3::new(-2.0 + slow * 0.5, 0.5, 0.8);
398                                next.control.orientation = Quaternion::rotation_x(u_slow * 0.1)
399                                    * Quaternion::rotation_y(2.0 + u_slow * 0.1)
400                                    * Quaternion::rotation_z(u_slowalt * 0.1);
401                            },
402                            "Kalimba" => {
403                                if speed < 0.5 {
404                                    next.head.orientation = Quaternion::rotation_z(head_look.x)
405                                        * Quaternion::rotation_x(
406                                            0.0 + head_look.y.abs() + look_dir.z * 0.7,
407                                        );
408                                }
409                                next.hand_l.position = Vec3::new(0.0, 2.0, -4.0);
410                                next.hand_l.orientation =
411                                    Quaternion::rotation_x(PI / 2.0) * Quaternion::rotation_z(PI);
412                                next.hand_r.position = Vec3::new(-4.0, 2.0, 6.0);
413                                next.hand_r.orientation = Quaternion::rotation_x(PI / 2.0)
414                                    * Quaternion::rotation_z(PI / 2.0);
415                                next.main.position = Vec3::new(0.0, 7.0, 12.0);
416                                next.main.orientation =
417                                    Quaternion::rotation_y(PI) * Quaternion::rotation_z(PI);
418
419                                next.control.position = Vec3::new(-2.0 + slow * 0.5, 0.5, 0.8);
420                                next.control.orientation = Quaternion::rotation_x(u_slow * 0.1)
421                                    * Quaternion::rotation_y(2.0 + u_slow * 0.1)
422                                    * Quaternion::rotation_z(u_slowalt * 0.1);
423                            },
424                            "Lute" | "Shamisen" | "Banjo" | "Oud" => {
425                                if speed < 0.5 {
426                                    next.head.orientation = Quaternion::rotation_z(head_look.x)
427                                        * Quaternion::rotation_x(
428                                            0.0 + head_look.y.abs() + look_dir.z * 0.7,
429                                        );
430                                }
431                                next.hand_l.position = Vec3::new(-2.0, 5.0, -5.0);
432                                next.hand_l.orientation = Quaternion::rotation_x((PI / 2.0) + 0.3)
433                                    * Quaternion::rotation_y(0.7)
434                                    * Quaternion::rotation_y(0.25)
435                                    * Quaternion::rotation_z(PI);
436                                next.hand_r.position = Vec3::new(-5.0, 2.0, 6.0);
437                                next.hand_r.orientation = Quaternion::rotation_x(PI / 2.0)
438                                    * Quaternion::rotation_z(PI / 2.0);
439                                next.main.position = Vec3::new(-2.0, 4.0, -12.0);
440                                next.main.orientation = Quaternion::rotation_x(0.0)
441                                    * Quaternion::rotation_y(0.2)
442                                    * Quaternion::rotation_z(-1.3);
443
444                                next.control.position = Vec3::new(-2.0 + slow * 0.5, 0.5, 0.8);
445                                next.control.orientation = Quaternion::rotation_x(u_slow * 0.1)
446                                    * Quaternion::rotation_y(2.0 + u_slow * 0.1)
447                                    * Quaternion::rotation_z(u_slowalt * 0.1);
448                            },
449                            "ViolaPizzicato" => {
450                                if speed < 0.5 {
451                                    next.head.orientation = Quaternion::rotation_z(head_look.x)
452                                        * Quaternion::rotation_x(
453                                            0.0 + head_look.y.abs() + look_dir.z * 0.7,
454                                        );
455                                }
456                                next.hand_l.position = Vec3::new(-2.0, 5.0, -5.0);
457                                next.hand_l.orientation = Quaternion::rotation_x((PI / 2.0) + 0.3)
458                                    * Quaternion::rotation_y(0.7)
459                                    * Quaternion::rotation_y(0.25)
460                                    * Quaternion::rotation_z(PI);
461                                next.hand_r.position = Vec3::new(-5.0, 2.0, 6.0);
462                                next.hand_r.orientation = Quaternion::rotation_x(PI / 2.0)
463                                    * Quaternion::rotation_z(PI / 2.0);
464                                next.main.position = Vec3::new(-2.0, 6.0, -12.0);
465                                next.main.orientation = Quaternion::rotation_x(0.0)
466                                    * Quaternion::rotation_y(0.2)
467                                    * Quaternion::rotation_z(-1.3);
468
469                                next.control.position = Vec3::new(-2.0 + slow * 0.5, 0.5, 0.8);
470                                next.control.orientation = Quaternion::rotation_x(u_slow * 0.1)
471                                    * Quaternion::rotation_y(2.0 + u_slow * 0.1)
472                                    * Quaternion::rotation_z(u_slowalt * 0.1);
473                            },
474                            "Guitar" | "DarkGuitar" => {
475                                if speed < 0.5 {
476                                    next.head.orientation = Quaternion::rotation_z(head_look.x)
477                                        * Quaternion::rotation_x(
478                                            0.0 + head_look.y.abs() + look_dir.z * 0.7,
479                                        );
480                                }
481                                next.hand_l.position = Vec3::new(0.0, 5.0, -4.0);
482                                next.hand_l.orientation = Quaternion::rotation_x((PI / 2.0) + 0.3)
483                                    * Quaternion::rotation_y(0.7)
484                                    * Quaternion::rotation_y(0.25)
485                                    * Quaternion::rotation_z(PI);
486                                next.hand_r.position = Vec3::new(-5.0, 2.0, 6.0);
487                                next.hand_r.orientation = Quaternion::rotation_x(PI / 2.0)
488                                    * Quaternion::rotation_z(PI / 2.0);
489                                next.main.position = Vec3::new(-2.0, 4.0, -12.0);
490                                next.main.orientation = Quaternion::rotation_x(0.0)
491                                    * Quaternion::rotation_y(0.2)
492                                    * Quaternion::rotation_z(-1.3);
493
494                                next.control.position = Vec3::new(-2.0 + slow * 0.5, 0.5, 0.8);
495                                next.control.orientation = Quaternion::rotation_x(u_slow * 0.1)
496                                    * Quaternion::rotation_y(2.0 + u_slow * 0.1)
497                                    * Quaternion::rotation_z(u_slowalt * 0.1);
498                            },
499                            "Melodica" => {
500                                if speed < 0.5 {
501                                    next.head.orientation = Quaternion::rotation_z(head_look.x)
502                                        * Quaternion::rotation_x(
503                                            0.0 + head_look.y.abs() + look_dir.z * 0.7,
504                                        );
505                                }
506                                next.hand_l.position = Vec3::new(-1.0, 3.0, -2.0);
507                                next.hand_l.orientation = Quaternion::rotation_x(2.0)
508                                    * Quaternion::rotation_z(-0.5)
509                                    * Quaternion::rotation_y(0.4)
510                                    * Quaternion::rotation_z(PI);
511                                next.hand_r.position = Vec3::new(-4.0, 2.0, 6.0);
512                                next.hand_r.orientation = Quaternion::rotation_x(1.2)
513                                    * Quaternion::rotation_y(-0.3)
514                                    * Quaternion::rotation_z(1.5);
515                                next.main.position = Vec3::new(-14.0, 3.0, -6.0);
516                                next.main.orientation = Quaternion::rotation_x(0.0)
517                                    * Quaternion::rotation_y(1.1)
518                                    * Quaternion::rotation_z(-1.5);
519
520                                next.control.position = Vec3::new(-2.0 + slow * 0.5, 0.5, 0.8);
521                                next.control.orientation = Quaternion::rotation_x(u_slow * 0.1)
522                                    * Quaternion::rotation_y(2.0 + u_slow * 0.1)
523                                    * Quaternion::rotation_z(u_slowalt * 0.1);
524                            },
525                            "Sitar" => {
526                                if speed < 0.5 {
527                                    next.head.orientation = Quaternion::rotation_z(head_look.x)
528                                        * Quaternion::rotation_x(
529                                            0.0 + head_look.y.abs() + look_dir.z * 0.7,
530                                        );
531                                }
532                                next.hand_l.position = Vec3::new(-1.0, 5.0, -2.5);
533                                next.hand_l.orientation = Quaternion::rotation_x((PI / 2.0) + 0.3)
534                                    * Quaternion::rotation_y(0.2)
535                                    * Quaternion::rotation_y(0.25)
536                                    * Quaternion::rotation_z(PI);
537                                next.hand_r.position = Vec3::new(-5.0, 2.0, 6.0);
538                                next.hand_r.orientation = Quaternion::rotation_x(PI / 2.0)
539                                    * Quaternion::rotation_z(PI / 2.0);
540                                next.main.position = Vec3::new(-2.0, 4.0, -12.0);
541                                next.main.orientation = Quaternion::rotation_x(0.0)
542                                    * Quaternion::rotation_y(0.2)
543                                    * Quaternion::rotation_z(-1.3);
544
545                                next.control.position = Vec3::new(-2.0 + slow * 0.5, 0.5, 0.8);
546                                next.control.orientation = Quaternion::rotation_x(u_slow * 0.1)
547                                    * Quaternion::rotation_y(2.0 + u_slow * 0.1)
548                                    * Quaternion::rotation_z(u_slowalt * 0.1);
549                            },
550                            _ => {},
551                        }
552                    }
553                },
554                Some(ToolKind::Shield) => {
555                    next.hand_l.position = Vec3::new(0.0, -2.0, 0.0);
556                    next.hand_l.orientation = Quaternion::rotation_x(PI / 2.0);
557
558                    next.hand_r.position = Vec3::new(0.0, 0.0, 0.0);
559                    next.hand_r.orientation =
560                        Quaternion::rotation_x(PI / 2.0) * Quaternion::rotation_y(2.0);
561
562                    next.control.position = Vec3::new(0.0, 7.0, 4.0);
563                    next.control.orientation =
564                        Quaternion::rotation_y(-0.5) * Quaternion::rotation_z(-1.25);
565                },
566                _ => {},
567            },
568            ((_, _), _, _) => {},
569        };
570        match hands {
571            (Some(Hands::One), _) => {
572                next.control_l.position =
573                    next.hand_l.position * Vec3::new(0.5, 0.5, 0.3) + Vec3::new(-4.0, 0.0, 0.0);
574                next.control_l.orientation = Quaternion::lerp(
575                    next.hand_l.orientation,
576                    Quaternion::rotation_x(PI * -0.5),
577                    0.65,
578                );
579                next.hand_l.position = Vec3::new(0.0, -2.0, 0.0);
580                next.hand_l.orientation = Quaternion::rotation_x(PI * 0.5);
581            },
582            (_, _) => {},
583        };
584        match hands {
585            (None | Some(Hands::One), Some(Hands::One)) => {
586                next.control_r.position =
587                    next.hand_r.position * Vec3::new(0.5, 0.5, 0.3) + Vec3::new(4.0, 0.0, 0.0);
588                next.control_r.orientation = Quaternion::lerp(
589                    next.hand_r.orientation,
590                    Quaternion::rotation_x(PI * -0.5),
591                    0.65,
592                );
593                next.hand_r.position = Vec3::new(0.0, -2.0, 0.0);
594                next.hand_r.orientation = Quaternion::rotation_x(PI * 0.5);
595            },
596            (_, _) => {},
597        };
598        match hands {
599            (None, None) | (None, Some(Hands::One)) => {
600                next.hand_l.position = Vec3::new(-8.0, 2.0, 1.0);
601                next.hand_l.orientation =
602                    Quaternion::rotation_x(0.5) * Quaternion::rotation_y(0.25);
603            },
604            (_, _) => {},
605        };
606        match hands {
607            (None, None) | (Some(Hands::One), None) => {
608                // next.hand_r.position = Vec3::new(8.0, 2.0, 1.0);
609                // next.hand_r.orientation =
610                //     Quaternion::rotation_x(0.5) *
611                // Quaternion::rotation_y(-0.25);
612            },
613            (_, _) => {},
614        };
615
616        if let (None, Some(Hands::Two)) = hands {
617            next.second = next.main;
618        }
619
620        next.do_hold_lantern(s_a, anim_time, anim_time, speednorm, 0.0, tilt);
621
622        next
623    }
624}