veloren_voxygen_anim/biped_small/
mod.rs

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