veloren_voxygen_anim/biped_small/
mod.rs

1pub mod alpha;
2pub mod beam;
3pub mod block;
4pub mod combomelee;
5pub mod dash;
6pub mod idle;
7pub mod leapmelee;
8pub mod rapidmelee;
9pub mod ripostemelee;
10pub mod run;
11pub mod shockwave;
12pub mod shoot;
13pub mod spritesummon;
14pub mod stunned;
15pub mod summon;
16pub mod wield;
17
18// Reexports
19pub use self::{
20    alpha::AlphaAnimation, beam::BeamAnimation, block::BlockAnimation, combomelee::ComboAnimation,
21    dash::DashAnimation, idle::IdleAnimation, leapmelee::LeapAnimation,
22    rapidmelee::RapidMeleeAnimation, ripostemelee::RiposteMeleeAnimation, run::RunAnimation,
23    shockwave::ShockwaveAnimation, shoot::ShootAnimation, spritesummon::SpriteSummonAnimation,
24    stunned::StunnedAnimation, summon::SummonAnimation, wield::WieldAnimation,
25};
26
27use super::{FigureBoneData, Offsets, Skeleton, make_bone, vek::*};
28use common::comp::{self};
29use core::convert::TryFrom;
30use std::f32::consts::PI;
31
32pub type Body = comp::biped_small::Body;
33
34skeleton_impls!(struct BipedSmallSkeleton {
35    + head,
36    + chest,
37    + pants,
38    + tail,
39    + main,
40    + hand_l,
41    + hand_r,
42    + foot_l,
43    + foot_r,
44    control,
45    control_l,
46    control_r,
47    :: // Begin non-bone fields
48    // Allows right hand to not be moved by control bone
49    detach_right: bool,
50});
51
52impl Skeleton for BipedSmallSkeleton {
53    type Attr = SkeletonAttr;
54    type Body = Body;
55
56    const BONE_COUNT: usize = 9;
57    #[cfg(feature = "use-dyn-lib")]
58    const COMPUTE_FN: &'static [u8] = b"biped_small_compute_mats\0";
59
60    #[cfg_attr(
61        feature = "be-dyn-lib",
62        unsafe(export_name = "biped_small_compute_mats")
63    )]
64    fn compute_matrices_inner(
65        &self,
66        base_mat: Mat4<f32>,
67        buf: &mut [FigureBoneData; super::MAX_BONE_COUNT],
68        body: Self::Body,
69    ) -> Offsets {
70        let base_mat = base_mat * Mat4::scaling_3d(SkeletonAttr::from(&body).scaler / 11.0);
71
72        let chest_mat = base_mat * Mat4::<f32>::from(self.chest);
73        let pants_mat = chest_mat * Mat4::<f32>::from(self.pants);
74        let control_mat = chest_mat * Mat4::<f32>::from(self.control);
75        let control_l_mat = Mat4::<f32>::from(self.control_l);
76        let control_r_mat = Mat4::<f32>::from(self.control_r);
77        let head_mat = chest_mat * Mat4::<f32>::from(self.head);
78        let tail_mat = pants_mat * Mat4::<f32>::from(self.tail);
79        *(<&mut [_; Self::BONE_COUNT]>::try_from(&mut buf[0..Self::BONE_COUNT]).unwrap()) = [
80            make_bone(head_mat),
81            make_bone(chest_mat),
82            make_bone(pants_mat),
83            make_bone(tail_mat),
84            make_bone(control_mat * Mat4::<f32>::from(self.main)),
85            make_bone(control_mat * control_l_mat * Mat4::<f32>::from(self.hand_l)),
86            make_bone(
87                if self.detach_right {
88                    chest_mat
89                } else {
90                    control_mat
91                } * control_r_mat
92                    * Mat4::<f32>::from(self.hand_r),
93            ),
94            make_bone(base_mat * Mat4::<f32>::from(self.foot_l)),
95            make_bone(base_mat * Mat4::<f32>::from(self.foot_r)),
96        ];
97
98        use comp::biped_small::Species::*;
99        let (mount_mat, mount_orientation) = match (body.species, body.body_type) {
100            (Sahagin | Mandragora | Kappa | Gnoll | Bushly | Irrwurz | TreasureEgg, _) => {
101                (chest_mat, self.chest.orientation)
102            },
103            (GoblinThug | GoblinChucker | GoblinRuffian, _) => (
104                chest_mat,
105                self.chest.orientation * Quaternion::rotation_x(0.7),
106            ),
107            (Myrmidon, _) => (
108                tail_mat,
109                self.chest.orientation * self.pants.orientation * self.tail.orientation,
110            ),
111            _ => (head_mat, self.chest.orientation * self.head.orientation),
112        };
113        let mount_position = mount_mat.mul_point(mount_point(&body));
114
115        Offsets {
116            viewpoint: Some((head_mat * Vec4::new(0.0, 0.0, 0.0, 1.0)).xyz()),
117            // TODO: see quadruped_medium for how to animate this
118            mount_bone: Transform {
119                position: mount_position,
120                orientation: mount_orientation,
121                scale: Vec3::one(),
122            },
123            ..Default::default()
124        }
125    }
126}
127
128pub struct SkeletonAttr {
129    head: (f32, f32),
130    chest: (f32, f32),
131    pants: (f32, f32),
132    tail: (f32, f32),
133    hand: (f32, f32, f32),
134    foot: (f32, f32, f32),
135    grip: (f32, f32, f32),
136    scaler: f32,
137    wing_for_foot: bool,
138}
139
140impl<'a> TryFrom<&'a comp::Body> for SkeletonAttr {
141    type Error = ();
142
143    fn try_from(body: &'a comp::Body) -> Result<Self, Self::Error> {
144        match body {
145            comp::Body::BipedSmall(body) => Ok(SkeletonAttr::from(body)),
146            _ => Err(()),
147        }
148    }
149}
150
151impl Default for SkeletonAttr {
152    fn default() -> Self {
153        Self {
154            head: (0.0, 0.0),
155            chest: (0.0, 0.0),
156            pants: (0.0, 0.0),
157            tail: (0.0, 0.0),
158            hand: (0.0, 0.0, 0.0),
159            foot: (0.0, 0.0, 0.0),
160            grip: (0.0, 0.0, 0.0),
161            scaler: 0.0,
162            wing_for_foot: false,
163        }
164    }
165}
166
167impl<'a> From<&'a Body> for SkeletonAttr {
168    fn from(body: &'a Body) -> Self {
169        use comp::biped_small::Species::*;
170        Self {
171            head: match (body.species, body.body_type) {
172                (Gnome, _) => (-1.0, 9.0),
173                (Sahagin, _) => (7.0, -3.5),
174                (Adlet, _) => (0.0, 7.0),
175                (Gnarling, _) => (0.0, 6.0),
176                (Mandragora, _) => (-1.0, 9.0),
177                (Kappa, _) => (8.0, 3.5),
178                (Cactid, _) => (-1.0, 9.0),
179                (Gnoll, _) => (5.5, -1.0),
180                (Haniwa, _) => (0.0, 7.0),
181                (Myrmidon, _) => (0.0, 8.0),
182                (Husk, _) => (0.5, 8.5),
183                (Boreal, _) => (-0.5, 13.0),
184                (Bushly, _) => (-1.0, 9.0),
185                (Irrwurz, _) => (-1.0, 9.0),
186                (IronDwarf, _) => (3.0, 3.5),
187                (Flamekeeper, _) => (3.0, 3.5),
188                (ShamanicSpirit, _) => (-0.5, 4.5),
189                (Jiangshi, _) => (-1.0, 6.5),
190                (TreasureEgg, _) => (-1.0, 9.0),
191                (GnarlingChieftain, _) => (0.0, 6.0),
192                (BloodmoonHeiress, _) => (0.0, 3.5),
193                (Bloodservant, _) => (-1.0, 6.5),
194                (Harlequin, _) => (0.0, 8.0),
195                (GoblinThug, _) => (-0.5, 3.5),
196                (GoblinChucker, _) => (-0.5, 3.5),
197                (GoblinRuffian, _) => (-0.5, 3.5),
198                (GreenLegoom, _) => (0.0, 3.5),
199                (OchreLegoom, _) => (0.0, 3.5),
200                (PurpleLegoom, _) => (-0.5, 3.5),
201                (RedLegoom, _) => (0.0, 3.5),
202            },
203            chest: match (body.species, body.body_type) {
204                (Gnome, _) => (0.0, 9.0),
205                (Sahagin, _) => (0.0, 15.0),
206                (Adlet, _) => (0.0, 11.0),
207                (Gnarling, _) => (0.0, 7.5),
208                (Mandragora, _) => (0.0, 4.0),
209                (Kappa, _) => (0.0, 14.5),
210                (Cactid, _) => (0.0, 7.0),
211                (Gnoll, _) => (0.0, 15.5),
212                (Haniwa, _) => (0.0, 11.0),
213                (Myrmidon, _) => (0.0, 11.0),
214                (Husk, _) => (0.0, 13.0),
215                (Boreal, _) => (0.0, 12.0),
216                (Bushly, _) => (0.0, 4.0),
217                (Irrwurz, _) => (0.0, 6.0),
218                (IronDwarf, _) => (0.0, 14.0),
219                (Flamekeeper, _) => (0.0, 14.0),
220                (ShamanicSpirit, _) => (0.0, 14.5),
221                (Jiangshi, _) => (0.0, 14.0),
222                (TreasureEgg, _) => (0.0, 3.0),
223                (GnarlingChieftain, _) => (0.0, 7.5),
224                (BloodmoonHeiress, _) => (0.0, 21.0),
225                (Bloodservant, _) => (0.0, 14.0),
226                (Harlequin, _) => (0.0, 13.5),
227                (GoblinThug, _) => (0.0, 8.5),
228                (GoblinChucker, _) => (0.0, 8.5),
229                (GoblinRuffian, _) => (0.0, 8.5),
230                (GreenLegoom, _) => (0.0, 7.0),
231                (OchreLegoom, _) => (0.0, 7.0),
232                (PurpleLegoom, _) => (0.0, 7.5),
233                (RedLegoom, _) => (0.0, 7.0),
234            },
235            pants: match (body.species, body.body_type) {
236                (Gnome, _) => (0.0, -3.0),
237                (Sahagin, _) => (0.5, -7.0),
238                (Adlet, _) => (0.0, -3.0),
239                (Gnarling, _) => (0.0, -3.0),
240                (Mandragora, _) => (0.0, 0.0),
241                (Kappa, _) => (0.0, -3.0),
242                (Cactid, _) => (0.0, -2.0),
243                (Gnoll, _) => (0.5, -7.5),
244                (Haniwa, _) => (0.0, -3.5),
245                (Myrmidon, _) => (0.0, -3.0),
246                (Husk, _) => (-1.0, -3.0),
247                (Boreal, _) => (1.5, -5.0),
248                (Bushly, _) => (0.0, 1.0),
249                (Irrwurz, _) => (-5.5, -0.5),
250                (IronDwarf, _) => (-1.0, -8.0),
251                (Flamekeeper, _) => (-1.0, -8.0),
252                (ShamanicSpirit, _) => (0.0, -8.0),
253                (Jiangshi, _) => (0.5, -6.0),
254                (TreasureEgg, _) => (0.0, 1.0),
255                (GnarlingChieftain, _) => (0.0, -3.0),
256                (BloodmoonHeiress, _) => (0.0, -8.0),
257                (Bloodservant, _) => (0.0, -6.0),
258                (Harlequin, _) => (0.0, -5.5),
259                (GoblinThug, _) => (0.0, -4.5),
260                (GoblinChucker, _) => (0.0, -4.5),
261                (GoblinRuffian, _) => (0.0, -4.5),
262                (GreenLegoom, _) => (0.0, -3.5),
263                (OchreLegoom, _) => (0.0, -3.5),
264                (PurpleLegoom, _) => (0.0, -4.0),
265                (RedLegoom, _) => (0.0, -3.5),
266            },
267            tail: match (body.species, body.body_type) {
268                (Gnome, _) => (0.0, 0.0),
269                (Sahagin, _) => (-2.5, -2.0),
270                (Adlet, _) => (-4.5, -2.0),
271                (Gnarling, _) => (-2.0, 1.5),
272                (Mandragora, _) => (0.0, -1.0),
273                (Kappa, _) => (0.0, -4.0),
274                (Cactid, _) => (0.0, 0.0),
275                (Gnoll, _) => (-2.5, -2.0),
276                (Haniwa, _) => (-4.5, -2.0),
277                (Myrmidon, _) => (-2.5, -1.0),
278                (Husk, _) => (0.0, 0.0),
279                (Boreal, _) => (0.0, 0.0),
280                (Bushly, _) => (0.0, -1.0),
281                (Irrwurz, _) => (0.0, -1.0),
282                (IronDwarf, _) => (0.0, 0.0),
283                (Flamekeeper, _) => (0.0, 0.0),
284                (ShamanicSpirit, _) => (0.0, 0.0),
285                (Jiangshi, _) => (0.0, 0.0),
286                (TreasureEgg, _) => (0.0, 0.0),
287                (GnarlingChieftain, _) => (-2.0, 1.5),
288                (BloodmoonHeiress, _) => (0.0, 0.0),
289                (Bloodservant, _) => (0.0, 0.0),
290                (Harlequin, _) => (0.0, 0.0),
291                (GoblinThug, _) => (0.0, 0.0),
292                (GoblinChucker, _) => (0.0, 0.0),
293                (GoblinRuffian, _) => (0.0, 0.0),
294                (GreenLegoom, _) => (0.0, 0.0),
295                (OchreLegoom, _) => (0.0, 0.0),
296                (PurpleLegoom, _) => (0.0, 0.0),
297                (RedLegoom, _) => (0.0, 0.0),
298            },
299            hand: match (body.species, body.body_type) {
300                (Gnome, _) => (4.0, 0.5, -1.0),
301                (Sahagin, _) => (3.5, 3.5, -2.0),
302                (Adlet, _) => (4.5, -0.5, 2.0),
303                (Gnarling, _) => (4.0, 0.0, 1.5),
304                (Mandragora, _) => (4.0, -0.5, 4.0),
305                (Kappa, _) => (4.0, 3.5, -0.5),
306                (Cactid, _) => (3.0, -0.5, 1.5),
307                (Gnoll, _) => (3.5, 0.5, -1.0),
308                (Haniwa, _) => (4.25, -1.0, 1.5),
309                (Myrmidon, _) => (3.5, 1.5, 2.0),
310                (Husk, _) => (4.0, 0.0, 1.0),
311                (Boreal, _) => (5.0, 0.5, 5.0),
312                (Bushly, _) => (5.0, 2.0, 8.0),
313                (Irrwurz, _) => (3.5, 2.0, 3.0),
314                (IronDwarf, _) => (4.0, 1.5, -3.5),
315                (Flamekeeper, _) => (4.0, 1.5, -3.5),
316                (ShamanicSpirit, _) => (5.0, 0.0, 1.0),
317                (Jiangshi, _) => (5.0, -1.0, 3.0),
318                (TreasureEgg, _) => (5.0, 2.0, 5.0),
319                (GnarlingChieftain, _) => (4.0, 0.0, 1.5),
320                (BloodmoonHeiress, _) => (2.5, 2.5, 7.0),
321                (Bloodservant, _) => (5.0, -1.0, 2.0),
322                (Harlequin, _) => (5.0, 0.0, 2.5),
323                (GoblinThug, _) => (4.5, 0.0, 2.0),
324                (GoblinChucker, _) => (4.5, 0.0, 2.0),
325                (GoblinRuffian, _) => (4.5, 0.0, 2.0),
326                (GreenLegoom, _) => (3.0, 0.0, 1.5),
327                (OchreLegoom, _) => (3.0, 0.0, 1.5),
328                (PurpleLegoom, _) => (3.0, 0.0, 1.5),
329                (RedLegoom, _) => (3.0, 0.0, 1.5),
330            },
331            foot: match (body.species, body.body_type) {
332                (Gnome, _) => (3.0, 0.0, 4.0),
333                (Sahagin, _) => (3.0, 1.0, 8.0),
334                (Adlet, _) => (3.0, 0.5, 7.0),
335                (Gnarling, _) => (2.5, 1.0, 5.0),
336                (Mandragora, _) => (3.0, 0.0, 4.0),
337                (Kappa, _) => (3.0, 3.0, 9.0),
338                (Cactid, _) => (2.5, 0.0, 5.0),
339                (Gnoll, _) => (3.0, 1.0, 7.0),
340                (Haniwa, _) => (3.0, 0.5, 8.0),
341                (Myrmidon, _) => (3.0, 0.5, 7.0),
342                (Husk, _) => (4.0, 0.5, 7.0),
343                (Boreal, _) => (3.0, 0.0, 9.0),
344                (Bushly, _) => (2.5, 0.0, 7.0),
345                (Irrwurz, _) => (4.0, 0.0, 6.0),
346                (IronDwarf, _) => (3.5, 3.0, 7.0),
347                (Flamekeeper, _) => (3.5, 3.0, 7.0),
348                (ShamanicSpirit, _) => (3.5, 3.0, 7.0),
349                (Jiangshi, _) => (3.0, 0.0, 8.0),
350                (TreasureEgg, _) => (2.0, 0.5, 4.0),
351                (GnarlingChieftain, _) => (2.5, 1.0, 5.0),
352                (BloodmoonHeiress, _) => (8.0, 0.5, 32.5),
353                (Bloodservant, _) => (2.5, 1.0, 7.0),
354                (Harlequin, _) => (2.5, 2.0, 10.0),
355                (GoblinThug, _) => (3.0, 0.5, 5.0),
356                (GoblinChucker, _) => (3.0, 0.5, 5.0),
357                (GoblinRuffian, _) => (3.0, 0.5, 5.0),
358                (GreenLegoom, _) => (2.0, -0.5, 4.0),
359                (OchreLegoom, _) => (2.0, -0.5, 4.0),
360                (PurpleLegoom, _) => (2.0, -0.5, 4.0),
361                (RedLegoom, _) => (2.0, -0.5, 4.0),
362            },
363            grip: match (body.species, body.body_type) {
364                (Gnome, _) => (0.0, 0.0, 5.0),
365                (Sahagin, _) => (1.0, 0.0, 13.0),
366                (Adlet, _) => (0.0, 0.0, 7.0),
367                (Gnarling, _) => (0.0, 0.0, 7.0),
368                (Mandragora, _) => (0.0, 0.0, 7.0),
369                (Kappa, _) => (0.75, 1.0, 12.0),
370                (Cactid, _) => (0.0, 0.0, 8.0),
371                (Gnoll, _) => (1.0, 0.0, 9.0),
372                (Haniwa, _) => (0.0, 0.5, 8.0),
373                (Myrmidon, _) => (0.0, 0.0, 8.0),
374                (Husk, _) => (0.0, 0.0, 8.0),
375                (Boreal, _) => (1.0, 0.0, 5.0),
376                (Bushly, _) => (0.0, 0.0, 7.0),
377                (Irrwurz, _) => (0.0, 0.0, 7.0),
378                (IronDwarf, _) => (0.0, 0.0, 8.0),
379                (Flamekeeper, _) => (0.0, 0.0, 8.0),
380                (ShamanicSpirit, _) => (0.0, 0.0, 8.0),
381                (Jiangshi, _) => (0.0, 0.0, 8.0),
382                (TreasureEgg, _) => (0.0, 0.0, 7.0),
383                (GnarlingChieftain, _) => (0.0, 0.0, 7.0),
384                (BloodmoonHeiress, _) => (0.0, 0.0, 8.0),
385                (Bloodservant, _) => (0.0, 0.0, 8.0),
386                (Harlequin, _) => (0.0, 0.0, 8.0),
387                (GoblinThug, _) => (0.0, 0.0, 8.0),
388                (GoblinChucker, _) => (0.0, 0.0, 8.0),
389                (GoblinRuffian, _) => (0.0, 0.0, 8.0),
390                (GreenLegoom, _) => (0.0, 0.0, 8.0),
391                (OchreLegoom, _) => (0.0, 0.0, 8.0),
392                (PurpleLegoom, _) => (0.0, 0.0, 8.0),
393                (RedLegoom, _) => (0.0, 0.0, 8.0),
394            },
395            scaler: match (body.species, body.body_type) {
396                (Gnome, _) => 0.8,
397                (Sahagin, _) => 1.05,
398                (Adlet, _) => 1.0,
399                (Gnarling, _) => 0.8,
400                (Mandragora, _) => 0.8,
401                (Kappa, _) => 0.8,
402                (Cactid, _) => 0.8,
403                (Gnoll, _) => 0.8,
404                (Haniwa, _) => 1.12,
405                (Myrmidon, _) => 1.24,
406                (Husk, _) => 1.12,
407                (Boreal, _) => 1.8,
408                (Bushly, _) => 1.0,
409                (Irrwurz, _) => 1.0,
410                (IronDwarf, _) => 1.5,
411                (Flamekeeper, _) => 1.0,
412                (ShamanicSpirit, _) => 1.0,
413                (Jiangshi, _) => 1.0,
414                (TreasureEgg, _) => 1.0,
415                (GnarlingChieftain, _) => 0.8,
416                (BloodmoonHeiress, _) => 1.5,
417                (Bloodservant, _) => 1.0,
418                (Harlequin, _) => 1.0,
419                (GoblinThug, _) => 1.0,
420                (GoblinChucker, _) => 1.0,
421                (GoblinRuffian, _) => 1.0,
422                (GreenLegoom, _) => 1.0,
423                (OchreLegoom, _) => 1.0,
424                (PurpleLegoom, _) => 1.0,
425                (RedLegoom, _) => 1.0,
426            },
427            wing_for_foot: matches!((body.species, body.body_type), (BloodmoonHeiress, _)),
428        }
429    }
430}
431
432pub fn init_biped_small_alpha(next: &mut BipedSmallSkeleton, s_a: &SkeletonAttr) {
433    next.hand_l.position = Vec3::new(s_a.grip.0 * 4.0, 0.0, s_a.grip.2);
434    next.hand_r.position = Vec3::new(-s_a.grip.0 * 4.0, 0.0, s_a.grip.2);
435    next.main.position = Vec3::new(0.0, 0.0, 0.0);
436    next.main.orientation = Quaternion::rotation_x(0.0);
437    next.hand_l.orientation = Quaternion::rotation_x(0.0);
438    next.hand_r.orientation = Quaternion::rotation_x(0.0);
439}
440
441pub fn biped_small_alpha_spear(
442    next: &mut BipedSmallSkeleton,
443    s_a: &SkeletonAttr,
444    move1abs: f32,
445    move2abs: f32,
446    anim_time: f32,
447    speednormcancel: f32,
448) {
449    let fast = (anim_time * 10.0).sin();
450    let fastalt = (anim_time * 10.0 + PI / 2.0).sin();
451
452    next.head.position = Vec3::new(0.0, s_a.head.0, s_a.head.1);
453    next.head.orientation = Quaternion::rotation_x(move1abs * 0.2 + move2abs * 0.3)
454        * Quaternion::rotation_z(move1abs * -0.2 + move2abs * 0.6)
455        * Quaternion::rotation_y(move1abs * 0.3 + move2abs * -0.5);
456    next.chest.position = Vec3::new(0.0, s_a.chest.0, s_a.chest.1);
457    next.chest.orientation = Quaternion::rotation_x(move1abs * -0.2 + move2abs * 0.3)
458        * Quaternion::rotation_z(move1abs * 0.5 + move2abs * -0.6);
459
460    next.pants.position = Vec3::new(0.0, s_a.pants.0, s_a.pants.1);
461    next.pants.orientation = Quaternion::rotation_x(move1abs * 0.2 + move2abs * -0.3)
462        * Quaternion::rotation_z(move1abs * -0.2 + move2abs * 0.2);
463
464    next.control_l.position = Vec3::new(1.0 - s_a.grip.0 * 2.0, 2.0, -2.0);
465    next.control_r.position = Vec3::new(-1.0 + s_a.grip.0 * 2.0, 2.0, 2.0);
466
467    next.control.position = Vec3::new(
468        -3.0 + move1abs * -3.0 + move2abs * 5.0,
469        s_a.grip.2 + move1abs * -12.0 + move2abs * 17.0,
470        -s_a.grip.2 / 2.5 + s_a.grip.0 * -2.0 + move2abs * 5.0,
471    );
472
473    next.control_l.orientation =
474        Quaternion::rotation_x(PI / 1.5 + move1abs * -1.5 + move2abs * 2.5)
475            * Quaternion::rotation_y(-0.3);
476    next.control_r.orientation =
477        Quaternion::rotation_x(PI / 1.5 + s_a.grip.0 * 0.2 + move1abs * -1.5 + move2abs * 2.5)
478            * Quaternion::rotation_y(0.5 + s_a.grip.0 * 0.2);
479
480    next.control.orientation = Quaternion::rotation_x(-1.35 + move1abs * -0.3 + move2abs * 0.5)
481        * Quaternion::rotation_z(move1abs * 1.0 + move2abs * -1.0)
482        * Quaternion::rotation_y(move2abs * 0.0);
483
484    next.tail.position = Vec3::new(0.0, s_a.tail.0, s_a.tail.1);
485    next.tail.orientation = Quaternion::rotation_x(0.05 * fastalt * speednormcancel)
486        * Quaternion::rotation_z(fast * 0.15 * speednormcancel);
487}
488
489pub fn biped_small_alpha_axe(
490    next: &mut BipedSmallSkeleton,
491    s_a: &SkeletonAttr,
492    move1abs: f32,
493    move2abs: f32,
494) {
495    next.main.position = Vec3::new(2.0, 2.0, 0.0);
496    next.control_l.position = Vec3::new(2.0 - 2.0 * s_a.grip.0, 1.0, 3.0);
497    next.control_l.orientation = Quaternion::rotation_x(PI / 2.0);
498
499    next.head.orientation = Quaternion::rotation_z(0.3 * move1abs - 0.6 * move2abs);
500    next.chest.orientation = Quaternion::rotation_z(0.5 * move1abs - 1.2 * move2abs);
501    next.foot_l.orientation = Quaternion::rotation_z(0.5 * move1abs - 0.8 * move2abs);
502    next.foot_r.orientation = Quaternion::rotation_z(0.3 * move1abs - 0.6 * move2abs);
503
504    next.control.position = Vec3::new(
505        -5.0 + 5.0 * move1abs,
506        -1.0 + s_a.grip.2,
507        -1.0 + 3.0 * move1abs + -s_a.grip.2 / 2.5 - 2.0 * s_a.grip.0,
508    );
509    next.control.orientation = Quaternion::rotation_x(-0.3 - move2abs)
510        * Quaternion::rotation_y(-0.9 * move1abs + 1.0 * move2abs)
511        * Quaternion::rotation_z(-0.3);
512    next.control_r.position = Vec3::new(
513        9.0 - 5.0 * move1abs + 2.0 * s_a.grip.0,
514        -1.0 + 2.0 * move1abs,
515        3.0 * move1abs - 2.0,
516    );
517    next.control_r.orientation = Quaternion::rotation_x(0.5 + 1.5 * move1abs + 0.2 * s_a.grip.0)
518        * Quaternion::rotation_y(0.2 + 0.2 * s_a.grip.0);
519}
520
521pub fn biped_small_alpha_dagger(
522    next: &mut BipedSmallSkeleton,
523    s_a: &SkeletonAttr,
524    move1abs: f32,
525    move2abs: f32,
526) {
527    next.head.orientation = Quaternion::rotation_x(move1abs * 0.15 + move2abs * -0.15)
528        * Quaternion::rotation_z(move1abs * 0.15 + move2abs * -0.3);
529    next.control_l.position = Vec3::new(2.0 - s_a.grip.0 * 2.0, 1.0, 3.0);
530    next.control_r.position = Vec3::new(
531        9.0 + move1abs * -7.0 + s_a.grip.0 * 2.0,
532        -1.0 + move1abs * 6.0,
533        -2.0,
534    );
535    let z_offset = if s_a.wing_for_foot {
536        s_a.grip.2 / 3.0
537    } else {
538        -s_a.grip.2 / 2.5
539    };
540    next.control.position = Vec3::new(
541        -5.0 + move1abs * 5.0 + move2abs * 9.0,
542        -1.0 + move2abs * -3.0 + s_a.grip.2,
543        -1.0 + move1abs * 3.0 + z_offset + s_a.grip.0 * -2.0,
544    );
545
546    next.control_l.orientation = Quaternion::rotation_x(PI / 2.0)
547        * Quaternion::rotation_y(-0.0)
548        * Quaternion::rotation_z(-0.0);
549    next.control_r.orientation = Quaternion::rotation_x(0.5 + move1abs * 1.5 + s_a.grip.0 * 0.2)
550        * Quaternion::rotation_y(0.2 + s_a.grip.0 * 0.2)
551        * Quaternion::rotation_z(-0.0);
552
553    next.control.orientation = Quaternion::rotation_x(-0.3 + move2abs * -1.0)
554        * Quaternion::rotation_y(move1abs * -0.4 + move2abs * 1.0)
555        * Quaternion::rotation_z(-0.3 + move2abs * -2.2);
556}
557
558pub fn biped_small_wield_sword(
559    next: &mut BipedSmallSkeleton,
560    s_a: &SkeletonAttr,
561    speednorm: f32,
562    slow: f32,
563) {
564    next.control_l.position = Vec3::new(2.0 - s_a.grip.0 * 2.0, 1.0, 3.0);
565    next.control_r.position = Vec3::new(9.0 + s_a.grip.0 * 2.0, -1.0, -2.0 + speednorm * -3.0);
566    let z_offset = if s_a.wing_for_foot {
567        s_a.grip.2 / 3.0
568    } else {
569        -s_a.grip.2 / 2.5
570    };
571    next.control.position = Vec3::new(
572        -5.0,
573        -1.0 + s_a.grip.2,
574        -1.0 + z_offset + s_a.grip.0 * -2.0 + speednorm * 2.0,
575    );
576
577    next.control_l.orientation = Quaternion::rotation_x(PI / 2.0 + slow * 0.1)
578        * Quaternion::rotation_y(-0.0)
579        * Quaternion::rotation_z(-0.0);
580    next.control_r.orientation = Quaternion::rotation_x(0.5 + slow * 0.1 + s_a.grip.0 * 0.2)
581        * Quaternion::rotation_y(0.2 + slow * 0.0 + s_a.grip.0 * 0.2)
582        * Quaternion::rotation_z(-0.0);
583
584    next.control.orientation = Quaternion::rotation_x(-0.3 + 0.2 * speednorm)
585        * Quaternion::rotation_y(-0.2 * speednorm)
586        * Quaternion::rotation_z(-0.3);
587}
588
589pub fn biped_small_wield_spear(
590    next: &mut BipedSmallSkeleton,
591    s_a: &SkeletonAttr,
592    anim_time: f32,
593    speed: f32,
594    fastacc: f32,
595) {
596    let speednorm = speed / 9.4;
597    let speednormcancel = 1.0 - speednorm;
598    let fastalt = (anim_time * 10.0 + PI / 2.0).sin();
599    let slow = (anim_time * 2.0).sin();
600
601    next.control_l.position = Vec3::new(1.0 - s_a.grip.0 * 2.0, 2.0, -2.0);
602    next.control_r.position = Vec3::new(-1.0 + s_a.grip.0 * 2.0, 2.0, 2.0);
603
604    next.control.position = Vec3::new(
605        -3.0,
606        s_a.grip.2,
607        -s_a.grip.2 / 2.5
608            + s_a.grip.0 * -2.0
609            + fastacc * 1.5
610            + fastalt * 0.5 * speednormcancel
611            + speednorm * 2.0,
612    );
613
614    next.control_l.orientation =
615        Quaternion::rotation_x(PI / 1.5 + slow * 0.1) * Quaternion::rotation_y(-0.3);
616    next.control_r.orientation = Quaternion::rotation_x(PI / 1.5 + slow * 0.1 + s_a.grip.0 * 0.2)
617        * Quaternion::rotation_y(0.5 + slow * 0.0 + s_a.grip.0 * 0.2);
618
619    next.control.orientation = Quaternion::rotation_x(-1.35 + 0.5 * speednorm);
620}
621
622pub fn biped_small_wield_bow(
623    next: &mut BipedSmallSkeleton,
624    s_a: &SkeletonAttr,
625    anim_time: f32,
626    speed: f32,
627    fastacc: f32,
628) {
629    let speednorm = speed / 9.4;
630    let speednormcancel = 1.0 - speednorm;
631    let fastalt = (anim_time * 10.0 + PI / 2.0).sin();
632    let slow = (anim_time * 2.0).sin();
633
634    next.control_l.position = Vec3::new(-1.0 - s_a.grip.0 * 2.0, 0.0, 0.0);
635    next.control_r.position = Vec3::new(1.0 + s_a.grip.0 * 2.0, 3.0, -2.0);
636
637    next.control.position = Vec3::new(
638        -1.0,
639        2.0 + s_a.grip.2,
640        3.0 + -s_a.grip.2 / 2.5
641            + s_a.grip.0 * -2.0
642            + fastacc * 1.5
643            + fastalt * 0.5 * speednormcancel
644            + speednorm * 2.0,
645    );
646
647    next.control_l.orientation =
648        Quaternion::rotation_x(PI / 2.0 + slow * 0.1) * Quaternion::rotation_y(-0.3);
649    next.control_r.orientation = Quaternion::rotation_x(PI / 2.0 + slow * 0.1 + s_a.grip.0 * 0.2)
650        * Quaternion::rotation_y(0.5 + slow * 0.0 + s_a.grip.0 * 0.2);
651
652    next.control.orientation =
653        Quaternion::rotation_x(-0.3 + 0.5 * speednorm) * Quaternion::rotation_y(0.5 * speednorm);
654}
655
656fn mount_point(body: &Body) -> Vec3<f32> {
657    use comp::biped_small::Species::*;
658    // TODO: Come up with a way to position rider
659    match (body.species, body.body_type) {
660        (Gnome, _) => (0.0, -4.0, -1.0),
661        (Sahagin, _) => (0.0, 0.0, 5.0),
662        (Adlet, _) => (0.0, -4.0, 1.0),
663        (Gnarling, _) => (0.0, -4.0, 1.5),
664        (Mandragora, _) => (0.0, -3.5, 6.0),
665        (Kappa, _) => (0.0, -5.0, 1.0),
666        (Cactid, _) => (0.0, -2.5, -0.5),
667        (Gnoll, _) => (0.0, -4.0, 2.0),
668        (Haniwa, _) => (0.0, -6.0, 1.0),
669        (Myrmidon, _) => (0.0, -5.5, 1.5),
670        (Husk, _) => (0.0, -5.5, 1.5),
671        (Boreal, _) => (0.0, -4.5, 2.0),
672        (Bushly, _) => (0.0, -3.0, 16.0),
673        (Irrwurz, _) => (0.0, -4.0, 10.0),
674        (IronDwarf, _) => (0.0, -4.0, 4.5),
675        (Flamekeeper, _) => (0.0, -6.5, 7.0),
676        (ShamanicSpirit, _) => (0.0, 0.0, 6.5),
677        (Jiangshi, _) => (0.0, -1.5, 7.5),
678        (TreasureEgg, _) => (0.0, -3.5, 8.0),
679        (GnarlingChieftain, _) => (0.0, -4.0, 4.5),
680        (BloodmoonHeiress, _) => (0.0, -1.0, 14.0),
681        (Bloodservant, _) => (0.0, -1.5, 4.5),
682        (Harlequin, _) => (0.0, -3.0, 2.5),
683        (GoblinThug, _) => (0.0, -4.0, -3.0),
684        (GoblinChucker, _) => (0.0, -9.0, -3.0),
685        (GoblinRuffian, _) => (0.0, -4.0, -3.0),
686        (GreenLegoom, _) => (0.0, -4.5, 6.0),
687        (OchreLegoom, _) => (0.0, -4.5, 3.0),
688        (PurpleLegoom, _) => (0.0, -3.5, 7.5),
689        (RedLegoom, _) => (0.0, -3.5, 5.0),
690    }
691    .into()
692}