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 tilt = (if vek::Vec2::new(ori, last_ori.xy())
72            .map(|o| o.magnitude_squared())
73            .map(|m| m > 0.001 && m.is_finite())
74            .reduce_and()
75            && ori.angle_between(last_ori.xy()).is_finite()
76        {
77            ori.angle_between(last_ori.xy()).min(0.2)
78                * last_ori.xy().determine_side(Vec2::zero(), ori).signum()
79        } else {
80            0.0
81        } * 1.25)
82            * 4.0;
83        let jump = if velocity.z == 0.0 { 0.0 } else { 1.0 };
84
85        // next.second.scale = match hands {
86        //     (Some(Hands::One), Some(Hands::One)) => Vec3::one(),
87        //    (_, _) => Vec3::zero(),
88        // };
89        next.main.position = Vec3::new(0.0, 0.0, 0.0);
90        next.main.orientation = Quaternion::rotation_z(0.0);
91        next.main.scale = Vec3::one();
92        next.second.position = Vec3::new(0.0, 0.0, 0.0);
93        next.second.orientation = Quaternion::rotation_z(0.0);
94        next.second.scale = Vec3::one();
95
96        let is_moving = (speed > 0.2 && velocity.z == 0.0) || is_riding;
97
98        if !is_moving {
99            next.head.position = Vec3::new(0.0, s_a.head.0, s_a.head.1 + u_slow * 0.1);
100            next.head.orientation = Quaternion::rotation_z(head_look.x + tilt * -0.75)
101                * Quaternion::rotation_x(head_look.y.abs() + look_dir.z * 0.7);
102
103            next.chest.position =
104                Vec3::new(slowalt * 0.2, s_a.chest.0, s_a.chest.1 + u_slow * 0.35);
105            next.belt.orientation = Quaternion::rotation_z(0.15 + beltstatic * tilt * 0.1);
106
107            next.shorts.orientation = Quaternion::rotation_z(0.3 + beltstatic * tilt * 0.2);
108            next.torso.orientation = Quaternion::rotation_z(tilt * 0.4);
109
110            next.foot_l.position = Vec3::new(
111                -s_a.foot.0,
112                -2.0 + s_a.foot.1 + jump * -4.0,
113                s_a.foot.2 + (tilt * footvertlstatic * 1.0).max(0.0),
114            );
115            next.foot_l.orientation = Quaternion::rotation_x(
116                jump * -0.7 + u_slowalt * 0.035 + tilt * footvertlstatic * 0.1
117                    - tilt.abs() * 0.3 * speednorm,
118            ) * Quaternion::rotation_z(-tilt * 0.3);
119
120            next.foot_r.position = Vec3::new(
121                s_a.foot.0,
122                2.0 + s_a.foot.1 + jump * 4.0,
123                s_a.foot.2 + (tilt * footvertrstatic * 1.0).max(0.0),
124            );
125            next.foot_r.orientation = Quaternion::rotation_x(
126                jump * 0.7 + u_slow * 0.035 + tilt * footvertrstatic * 0.1
127                    - tilt.abs() * 0.3 * speednorm,
128            ) * Quaternion::rotation_z(-tilt * 0.3);
129
130            next.chest.orientation = Quaternion::rotation_y(u_slowalt * 0.04)
131                * Quaternion::rotation_z(0.15 + tilt * -0.4);
132
133            next.belt.position = Vec3::new(0.0, s_a.belt.0, s_a.belt.1);
134
135            // next.back.orientation = Quaternion::rotation_x(-0.2);
136            next.shorts.position = Vec3::new(0.0, s_a.shorts.0, s_a.shorts.1);
137        }
138        match (hands, active_tool_kind, second_tool_kind) {
139            ((Some(Hands::Two), _), tool, _) | ((None, Some(Hands::Two)), _, tool) => match tool {
140                Some(ToolKind::Sword) => {
141                    next.control_l.position = next.hand_l.position * 0.2
142                        + Vec3::new(
143                            s_a.sc.0,
144                            s_a.sc.1 - slow * 2.0 * speednorm,
145                            s_a.sc.2 + direction * -5.0 - slow * 2.0 * speednorm,
146                        );
147                    next.control_r.position = next.control_l.position;
148
149                    next.hand_l.position = Vec3::new(s_a.shl.0 - 0.5, s_a.shl.1, s_a.shl.2);
150                    next.hand_l.orientation =
151                        Quaternion::rotation_x(s_a.shl.3) * Quaternion::rotation_y(s_a.shl.4);
152                    next.control_l.orientation = Quaternion::rotation_x(s_a.sc.3 + u_slow * 0.05)
153                        * Quaternion::rotation_z(u_slowalt * 0.04);
154                    next.control_r.orientation = Quaternion::rotation_x(s_a.sc.3 + u_slow * 0.15)
155                        * Quaternion::rotation_z(u_slowalt * 0.08);
156                    next.hand_r.position = Vec3::zero();
157                    next.hand_r.orientation =
158                        next.hand_l.orientation * Quaternion::rotation_y(PI * 0.3);
159                },
160                Some(ToolKind::Axe) => {
161                    next.main.position = Vec3::new(0.0, 0.0, 0.0);
162                    next.main.orientation = Quaternion::rotation_x(0.0);
163
164                    if speed < 0.5 {
165                        next.head.position =
166                            Vec3::new(0.0, 0.0 + s_a.head.0, s_a.head.1 + u_slow * 0.1);
167                        next.head.orientation = Quaternion::rotation_z(head_look.x)
168                            * Quaternion::rotation_x(0.15 + head_look.y.abs() + look_dir.z * 0.7);
169                        next.chest.orientation = Quaternion::rotation_x(-0.15)
170                            * Quaternion::rotation_y(u_slowalt * 0.04)
171                            * Quaternion::rotation_z(0.15);
172                        next.belt.position = Vec3::new(0.0, 1.0 + s_a.belt.0, s_a.belt.1);
173                        next.belt.orientation = Quaternion::rotation_x(0.15)
174                            * Quaternion::rotation_y(u_slowalt * 0.03)
175                            * Quaternion::rotation_z(0.15);
176                        next.shorts.position = Vec3::new(0.0, 1.0 + s_a.shorts.0, s_a.shorts.1);
177                        next.shorts.orientation =
178                            Quaternion::rotation_x(0.15) * Quaternion::rotation_z(0.25);
179                    }
180                    next.hand_l.position = Vec3::new(s_a.ahl.0, s_a.ahl.1, s_a.ahl.2);
181                    next.hand_l.orientation =
182                        Quaternion::rotation_x(s_a.ahl.3) * Quaternion::rotation_y(s_a.ahl.4);
183                    next.hand_r.position = Vec3::new(s_a.ahr.0, s_a.ahr.1, s_a.ahr.2);
184                    next.hand_r.orientation =
185                        Quaternion::rotation_x(s_a.ahr.3) * Quaternion::rotation_z(PI);
186
187                    next.control.position =
188                        Vec3::new(s_a.ac.0, s_a.ac.1, 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" | "TimbrelOfChaos" | "Rhythmo" | "StarlightConch" => {
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" | "Oud" => {
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                            "ViolaPizzicato" => {
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(-2.0, 5.0, -5.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, 6.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                            "Guitar" | "DarkGuitar" => {
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(0.0, 5.0, -4.0);
480                                next.hand_l.orientation = Quaternion::rotation_x((PI / 2.0) + 0.3)
481                                    * Quaternion::rotation_y(0.7)
482                                    * Quaternion::rotation_y(0.25)
483                                    * Quaternion::rotation_z(PI);
484                                next.hand_r.position = Vec3::new(-5.0, 2.0, 6.0);
485                                next.hand_r.orientation = Quaternion::rotation_x(PI / 2.0)
486                                    * Quaternion::rotation_z(PI / 2.0);
487                                next.main.position = Vec3::new(-2.0, 4.0, -12.0);
488                                next.main.orientation = Quaternion::rotation_x(0.0)
489                                    * Quaternion::rotation_y(0.2)
490                                    * Quaternion::rotation_z(-1.3);
491
492                                next.control.position = Vec3::new(-2.0 + slow * 0.5, 0.5, 0.8);
493                                next.control.orientation = Quaternion::rotation_x(u_slow * 0.1)
494                                    * Quaternion::rotation_y(2.0 + u_slow * 0.1)
495                                    * Quaternion::rotation_z(u_slowalt * 0.1);
496                            },
497                            "Melodica" => {
498                                if speed < 0.5 {
499                                    next.head.orientation = Quaternion::rotation_z(head_look.x)
500                                        * Quaternion::rotation_x(
501                                            0.0 + head_look.y.abs() + look_dir.z * 0.7,
502                                        );
503                                }
504                                next.hand_l.position = Vec3::new(-1.0, 3.0, -2.0);
505                                next.hand_l.orientation = Quaternion::rotation_x(2.0)
506                                    * Quaternion::rotation_z(-0.5)
507                                    * Quaternion::rotation_y(0.4)
508                                    * Quaternion::rotation_z(PI);
509                                next.hand_r.position = Vec3::new(-4.0, 2.0, 6.0);
510                                next.hand_r.orientation = Quaternion::rotation_x(1.2)
511                                    * Quaternion::rotation_y(-0.3)
512                                    * Quaternion::rotation_z(1.5);
513                                next.main.position = Vec3::new(-14.0, 3.0, -6.0);
514                                next.main.orientation = Quaternion::rotation_x(0.0)
515                                    * Quaternion::rotation_y(1.1)
516                                    * Quaternion::rotation_z(-1.5);
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                            "Sitar" => {
524                                if speed < 0.5 {
525                                    next.head.orientation = Quaternion::rotation_z(head_look.x)
526                                        * Quaternion::rotation_x(
527                                            0.0 + head_look.y.abs() + look_dir.z * 0.7,
528                                        );
529                                }
530                                next.hand_l.position = Vec3::new(-1.0, 5.0, -2.5);
531                                next.hand_l.orientation = Quaternion::rotation_x((PI / 2.0) + 0.3)
532                                    * Quaternion::rotation_y(0.2)
533                                    * Quaternion::rotation_y(0.25)
534                                    * Quaternion::rotation_z(PI);
535                                next.hand_r.position = Vec3::new(-5.0, 2.0, 6.0);
536                                next.hand_r.orientation = Quaternion::rotation_x(PI / 2.0)
537                                    * Quaternion::rotation_z(PI / 2.0);
538                                next.main.position = Vec3::new(-2.0, 4.0, -12.0);
539                                next.main.orientation = Quaternion::rotation_x(0.0)
540                                    * Quaternion::rotation_y(0.2)
541                                    * Quaternion::rotation_z(-1.3);
542
543                                next.control.position = Vec3::new(-2.0 + slow * 0.5, 0.5, 0.8);
544                                next.control.orientation = Quaternion::rotation_x(u_slow * 0.1)
545                                    * Quaternion::rotation_y(2.0 + u_slow * 0.1)
546                                    * Quaternion::rotation_z(u_slowalt * 0.1);
547                            },
548                            _ => {},
549                        }
550                    }
551                },
552                Some(ToolKind::Shield) => {
553                    next.hand_l.position = Vec3::new(0.0, -2.0, 0.0);
554                    next.hand_l.orientation = Quaternion::rotation_x(PI / 2.0);
555
556                    next.hand_r.position = Vec3::new(0.0, 0.0, 0.0);
557                    next.hand_r.orientation =
558                        Quaternion::rotation_x(PI / 2.0) * Quaternion::rotation_y(2.0);
559
560                    next.control.position = Vec3::new(0.0, 7.0, 4.0);
561                    next.control.orientation =
562                        Quaternion::rotation_y(-0.5) * Quaternion::rotation_z(-1.25);
563                },
564                _ => {},
565            },
566            ((_, _), _, _) => {},
567        };
568        match hands {
569            (Some(Hands::One), _) => {
570                next.control_l.position =
571                    next.hand_l.position * Vec3::new(0.5, 0.5, 0.3) + Vec3::new(-4.0, 0.0, 0.0);
572                next.control_l.orientation = Quaternion::lerp(
573                    next.hand_l.orientation,
574                    Quaternion::rotation_x(PI * -0.5),
575                    0.65,
576                );
577                next.hand_l.position = Vec3::new(0.0, -2.0, 0.0);
578                next.hand_l.orientation = Quaternion::rotation_x(PI * 0.5);
579            },
580            (_, _) => {},
581        };
582        match hands {
583            (None | Some(Hands::One), Some(Hands::One)) => {
584                next.control_r.position =
585                    next.hand_r.position * Vec3::new(0.5, 0.5, 0.3) + Vec3::new(4.0, 0.0, 0.0);
586                next.control_r.orientation = Quaternion::lerp(
587                    next.hand_r.orientation,
588                    Quaternion::rotation_x(PI * -0.5),
589                    0.65,
590                );
591                next.hand_r.position = Vec3::new(0.0, -2.0, 0.0);
592                next.hand_r.orientation = Quaternion::rotation_x(PI * 0.5);
593            },
594            (_, _) => {},
595        };
596        match hands {
597            (None, None) | (None, Some(Hands::One)) => {
598                next.hand_l.position = Vec3::new(-8.0, 2.0, 1.0);
599                next.hand_l.orientation =
600                    Quaternion::rotation_x(0.5) * Quaternion::rotation_y(0.25);
601            },
602            (_, _) => {},
603        };
604        match hands {
605            (None, None) | (Some(Hands::One), None) => {
606                // next.hand_r.position = Vec3::new(8.0, 2.0, 1.0);
607                // next.hand_r.orientation =
608                //     Quaternion::rotation_x(0.5) *
609                // Quaternion::rotation_y(-0.25);
610            },
611            (_, _) => {},
612        };
613
614        if let (None, Some(Hands::Two)) = hands {
615            next.second = next.main;
616        }
617
618        next.do_hold_lantern(
619            s_a,
620            anim_time,
621            anim_time,
622            speednorm,
623            0.0,
624            tilt,
625            Some(last_ori),
626            Some(*look_dir),
627        );
628
629        next
630    }
631}