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