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, 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 :: 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 (UmberLegoom, _) => (0.0, 3.5),
182 },
183 chest: match (body.species, body.body_type) {
184 (Gnome, _) => (0.0, 9.0),
185 (Sahagin, _) => (0.0, 15.0),
186 (Adlet, _) => (0.0, 11.0),
187 (Gnarling, _) => (0.0, 7.5),
188 (Mandragora, _) => (0.0, 4.0),
189 (Kappa, _) => (0.0, 14.5),
190 (Cactid, _) => (0.0, 7.0),
191 (Gnoll, _) => (0.0, 15.5),
192 (Haniwa, _) => (0.0, 11.0),
193 (Myrmidon, _) => (0.0, 11.0),
194 (Husk, _) => (0.0, 13.0),
195 (Boreal, _) => (0.0, 12.0),
196 (Ashen, _) => (0.0, 14.5),
197 (Bushly, _) => (0.0, 4.0),
198 (Irrwurz, _) => (0.0, 6.0),
199 (IronDwarf, _) => (0.0, 14.0),
200 (Flamekeeper, _) => (0.0, 14.0),
201 (ShamanicSpirit, _) => (0.0, 14.5),
202 (Jiangshi, _) => (0.0, 14.0),
203 (TreasureEgg, _) => (0.0, 3.0),
204 (GnarlingChieftain, _) => (0.0, 7.5),
205 (BloodmoonHeiress, _) => (0.0, 21.0),
206 (Bloodservant, _) => (0.0, 14.0),
207 (Harlequin, _) => (0.0, 13.5),
208 (GoblinThug, _) => (0.0, 8.5),
209 (GoblinChucker, _) => (0.0, 8.5),
210 (GoblinRuffian, _) => (0.0, 8.5),
211 (GreenLegoom, _) => (0.0, 7.0),
212 (OchreLegoom, _) => (0.0, 7.0),
213 (PurpleLegoom, _) => (0.0, 7.5),
214 (RedLegoom, _) => (0.0, 7.0),
215 (UmberLegoom, _) => (0.0, 7.0),
216 },
217 pants: match (body.species, body.body_type) {
218 (Gnome, _) => (0.0, -3.0),
219 (Sahagin, _) => (0.5, -7.0),
220 (Adlet, _) => (0.0, -3.0),
221 (Gnarling, _) => (0.0, -3.0),
222 (Mandragora, _) => (0.0, 0.0),
223 (Kappa, _) => (0.0, -3.0),
224 (Cactid, _) => (0.0, -2.0),
225 (Gnoll, _) => (0.5, -7.5),
226 (Haniwa, _) => (0.0, -3.5),
227 (Myrmidon, _) => (0.0, -3.0),
228 (Husk, _) => (-1.0, -3.0),
229 (Boreal, _) => (1.5, -5.0),
230 (Ashen, _) => (1.5, -5.0),
231 (Bushly, _) => (0.0, 1.0),
232 (Irrwurz, _) => (-5.5, -0.5),
233 (IronDwarf, _) => (-1.0, -8.0),
234 (Flamekeeper, _) => (-1.0, -8.0),
235 (ShamanicSpirit, _) => (0.0, -8.0),
236 (Jiangshi, _) => (0.5, -6.0),
237 (TreasureEgg, _) => (0.0, 1.0),
238 (GnarlingChieftain, _) => (0.0, -3.0),
239 (BloodmoonHeiress, _) => (0.0, -8.0),
240 (Bloodservant, _) => (0.0, -6.0),
241 (Harlequin, _) => (0.0, -5.5),
242 (GoblinThug, _) => (0.0, -4.5),
243 (GoblinChucker, _) => (0.0, -4.5),
244 (GoblinRuffian, _) => (0.0, -4.5),
245 (GreenLegoom, _) => (0.0, -3.5),
246 (OchreLegoom, _) => (0.0, -3.5),
247 (PurpleLegoom, _) => (0.0, -4.0),
248 (RedLegoom, _) => (0.0, -3.5),
249 (UmberLegoom, _) => (0.0, -3.5),
250 },
251 tail: match (body.species, body.body_type) {
252 (Gnome, _) => (0.0, 0.0),
253 (Sahagin, _) => (-2.5, -2.0),
254 (Adlet, _) => (-4.5, -2.0),
255 (Gnarling, _) => (-2.0, 1.5),
256 (Mandragora, _) => (0.0, -1.0),
257 (Kappa, _) => (0.0, -4.0),
258 (Cactid, _) => (0.0, 0.0),
259 (Gnoll, _) => (-2.5, -2.0),
260 (Haniwa, _) => (-4.5, -2.0),
261 (Myrmidon, _) => (-2.5, -1.0),
262 (Husk, _) => (0.0, 0.0),
263 (Boreal, _) => (0.0, 0.0),
264 (Ashen, _) => (0.0, 0.0),
265 (Bushly, _) => (0.0, -1.0),
266 (Irrwurz, _) => (0.0, -1.0),
267 (IronDwarf, _) => (0.0, 0.0),
268 (Flamekeeper, _) => (0.0, 0.0),
269 (ShamanicSpirit, _) => (0.0, 0.0),
270 (Jiangshi, _) => (0.0, 0.0),
271 (TreasureEgg, _) => (0.0, 0.0),
272 (GnarlingChieftain, _) => (-2.0, 1.5),
273 (BloodmoonHeiress, _) => (0.0, 0.0),
274 (Bloodservant, _) => (0.0, 0.0),
275 (Harlequin, _) => (0.0, 0.0),
276 (GoblinThug, _) => (0.0, 0.0),
277 (GoblinChucker, _) => (0.0, 0.0),
278 (GoblinRuffian, _) => (0.0, 0.0),
279 (GreenLegoom, _) => (0.0, 0.0),
280 (OchreLegoom, _) => (0.0, 0.0),
281 (PurpleLegoom, _) => (0.0, 0.0),
282 (RedLegoom, _) => (0.0, 0.0),
283 (UmberLegoom, _) => (0.0, 0.0),
284 },
285 hand: match (body.species, body.body_type) {
286 (Gnome, _) => (4.0, 0.5, -1.0),
287 (Sahagin, _) => (3.5, 3.5, -2.0),
288 (Adlet, _) => (4.5, -0.5, 2.0),
289 (Gnarling, _) => (4.0, 0.0, 1.5),
290 (Mandragora, _) => (4.0, -0.5, 4.0),
291 (Kappa, _) => (4.0, 3.5, -0.5),
292 (Cactid, _) => (3.0, -0.5, 1.5),
293 (Gnoll, _) => (3.5, 0.5, -1.0),
294 (Haniwa, _) => (4.25, -1.0, 1.5),
295 (Myrmidon, _) => (3.5, 1.5, 2.0),
296 (Husk, _) => (4.0, 0.0, 1.0),
297 (Boreal, _) => (5.0, 0.5, 5.0),
298 (Ashen, _) => (6.0, 1.0, 2.0),
299 (Bushly, _) => (5.0, 2.0, 8.0),
300 (Irrwurz, _) => (3.5, 2.0, 3.0),
301 (IronDwarf, _) => (4.0, 1.5, -3.5),
302 (Flamekeeper, _) => (4.0, 1.5, -3.5),
303 (ShamanicSpirit, _) => (5.0, 0.0, 1.0),
304 (Jiangshi, _) => (5.0, -1.0, 3.0),
305 (TreasureEgg, _) => (5.0, 2.0, 5.0),
306 (GnarlingChieftain, _) => (4.0, 0.0, 1.5),
307 (BloodmoonHeiress, _) => (2.5, 2.5, 7.0),
308 (Bloodservant, _) => (5.0, -1.0, 2.0),
309 (Harlequin, _) => (5.0, 0.0, 2.5),
310 (GoblinThug, _) => (4.5, 0.0, 2.0),
311 (GoblinChucker, _) => (4.5, 0.0, 2.0),
312 (GoblinRuffian, _) => (4.5, 0.0, 2.0),
313 (GreenLegoom, _) => (3.0, 0.0, 1.5),
314 (OchreLegoom, _) => (3.0, 0.0, 1.5),
315 (PurpleLegoom, _) => (3.0, 0.0, 1.5),
316 (RedLegoom, _) => (3.0, 0.0, 1.5),
317 (UmberLegoom, _) => (3.0, 0.0, 1.5),
318 },
319 foot: match (body.species, body.body_type) {
320 (Gnome, _) => (3.0, 0.0, 4.0),
321 (Sahagin, _) => (3.0, 1.0, 8.0),
322 (Adlet, _) => (3.0, 0.5, 7.0),
323 (Gnarling, _) => (2.5, 1.0, 5.0),
324 (Mandragora, _) => (3.0, 0.0, 4.0),
325 (Kappa, _) => (3.0, 3.0, 9.0),
326 (Cactid, _) => (2.5, 0.0, 5.0),
327 (Gnoll, _) => (3.0, 1.0, 7.0),
328 (Haniwa, _) => (3.0, 0.5, 8.0),
329 (Myrmidon, _) => (3.0, 0.5, 7.0),
330 (Husk, _) => (4.0, 0.5, 7.0),
331 (Boreal, _) => (3.0, 0.0, 9.0),
332 (Ashen, _) => (3.0, 1.0, 9.0),
333 (Bushly, _) => (2.5, 0.0, 7.0),
334 (Irrwurz, _) => (4.0, 0.0, 6.0),
335 (IronDwarf, _) => (3.5, 3.0, 7.0),
336 (Flamekeeper, _) => (3.5, 3.0, 7.0),
337 (ShamanicSpirit, _) => (3.5, 3.0, 7.0),
338 (Jiangshi, _) => (3.0, 0.0, 8.0),
339 (TreasureEgg, _) => (2.0, 0.5, 4.0),
340 (GnarlingChieftain, _) => (2.5, 1.0, 5.0),
341 (BloodmoonHeiress, _) => (8.0, 0.5, 32.5),
342 (Bloodservant, _) => (2.5, 1.0, 7.0),
343 (Harlequin, _) => (2.5, 2.0, 10.0),
344 (GoblinThug, _) => (3.0, 0.5, 5.0),
345 (GoblinChucker, _) => (3.0, 0.5, 5.0),
346 (GoblinRuffian, _) => (3.0, 0.5, 5.0),
347 (GreenLegoom, _) => (2.0, -0.5, 4.0),
348 (OchreLegoom, _) => (2.0, -0.5, 4.0),
349 (PurpleLegoom, _) => (2.0, -0.5, 4.0),
350 (RedLegoom, _) => (2.0, -0.5, 4.0),
351 (UmberLegoom, _) => (2.0, -0.5, 4.0),
352 },
353 grip: match (body.species, body.body_type) {
354 (Gnome, _) => (0.0, 0.0, 5.0),
355 (Sahagin, _) => (1.0, 0.0, 13.0),
356 (Adlet, _) => (0.0, 0.0, 7.0),
357 (Gnarling, _) => (0.0, 0.0, 7.0),
358 (Mandragora, _) => (0.0, 0.0, 7.0),
359 (Kappa, _) => (0.75, 1.0, 12.0),
360 (Cactid, _) => (0.0, 0.0, 8.0),
361 (Gnoll, _) => (1.0, 0.0, 9.0),
362 (Haniwa, _) => (0.0, 0.5, 8.0),
363 (Myrmidon, _) => (0.0, 0.0, 8.0),
364 (Husk, _) => (0.0, 0.0, 8.0),
365 (Boreal, _) => (1.0, 0.0, 5.0),
366 (Ashen, _) => (-1.0, 0.0, 7.0),
367 (Bushly, _) => (0.0, 0.0, 7.0),
368 (Irrwurz, _) => (0.0, 0.0, 7.0),
369 (IronDwarf, _) => (0.0, 0.0, 8.0),
370 (Flamekeeper, _) => (0.0, 0.0, 8.0),
371 (ShamanicSpirit, _) => (0.0, 0.0, 8.0),
372 (Jiangshi, _) => (0.0, 0.0, 8.0),
373 (TreasureEgg, _) => (0.0, 0.0, 7.0),
374 (GnarlingChieftain, _) => (0.0, 0.0, 7.0),
375 (BloodmoonHeiress, _) => (0.0, 0.0, 8.0),
376 (Bloodservant, _) => (0.0, 0.0, 8.0),
377 (Harlequin, _) => (0.0, 0.0, 8.0),
378 (GoblinThug, _) => (0.0, 0.0, 8.0),
379 (GoblinChucker, _) => (0.0, 0.0, 8.0),
380 (GoblinRuffian, _) => (0.0, 0.0, 8.0),
381 (GreenLegoom, _) => (0.0, 0.0, 8.0),
382 (OchreLegoom, _) => (0.0, 0.0, 8.0),
383 (PurpleLegoom, _) => (0.0, 0.0, 8.0),
384 (RedLegoom, _) => (0.0, 0.0, 8.0),
385 (UmberLegoom, _) => (0.0, 0.0, 8.0),
386 },
387 scaler: match (body.species, body.body_type) {
388 (Gnome, _) => 0.8,
389 (Sahagin, _) => 1.05,
390 (Adlet, _) => 1.0,
391 (Gnarling, _) => 0.8,
392 (Mandragora, _) => 0.8,
393 (Kappa, _) => 0.8,
394 (Cactid, _) => 0.8,
395 (Gnoll, _) => 0.8,
396 (Haniwa, _) => 1.12,
397 (Myrmidon, _) => 1.24,
398 (Husk, _) => 1.12,
399 (Boreal, _) => 1.8,
400 (Ashen, _) => 1.0,
401 (Bushly, _) => 1.0,
402 (Irrwurz, _) => 1.0,
403 (IronDwarf, _) => 1.5,
404 (Flamekeeper, _) => 1.0,
405 (ShamanicSpirit, _) => 1.0,
406 (Jiangshi, _) => 1.0,
407 (TreasureEgg, _) => 1.0,
408 (GnarlingChieftain, _) => 0.8,
409 (BloodmoonHeiress, _) => 1.5,
410 (Bloodservant, _) => 1.0,
411 (Harlequin, _) => 1.0,
412 (GoblinThug, _) => 1.0,
413 (GoblinChucker, _) => 1.0,
414 (GoblinRuffian, _) => 1.0,
415 (GreenLegoom, _) => 0.65,
416 (OchreLegoom, _) => 0.65,
417 (PurpleLegoom, _) => 0.65,
418 (RedLegoom, _) => 0.65,
419 (UmberLegoom, _) => 0.65,
420 },
421 wing_for_foot: matches!((body.species, body.body_type), (BloodmoonHeiress, _)),
422 }
423 }
424}
425
426pub fn init_biped_small_alpha(next: &mut BipedSmallSkeleton, s_a: &SkeletonAttr) {
427 next.hand_l.position = Vec3::new(s_a.grip.0 * 4.0, 0.0, s_a.grip.2);
428 next.hand_r.position = Vec3::new(-s_a.grip.0 * 4.0, 0.0, s_a.grip.2);
429 next.main.position = Vec3::new(s_a.grip.0, 0.0, 0.0);
430 next.main.orientation = Quaternion::rotation_x(0.0);
431 next.second.position = Vec3::new(-s_a.grip.0, 0.0, 0.0);
432 next.second.orientation = Quaternion::rotation_x(0.0);
433 next.hand_l.orientation = Quaternion::rotation_x(0.0);
434 next.hand_r.orientation = Quaternion::rotation_x(0.0);
435}
436
437pub fn biped_small_alpha_spear(
438 next: &mut BipedSmallSkeleton,
439 s_a: &SkeletonAttr,
440 move1abs: f32,
441 move2abs: f32,
442 anim_time: f32,
443 speednormcancel: f32,
444) {
445 let fast = (anim_time * 10.0).sin();
446 let fastalt = (anim_time * 10.0 + PI / 2.0).sin();
447
448 next.head.position = Vec3::new(0.0, s_a.head.0, s_a.head.1);
449 next.head.orientation = Quaternion::rotation_x(move1abs * 0.2 + move2abs * 0.3)
450 * Quaternion::rotation_z(move1abs * -0.2 + move2abs * 0.6)
451 * Quaternion::rotation_y(move1abs * 0.3 + move2abs * -0.5);
452 next.chest.position = Vec3::new(0.0, s_a.chest.0, s_a.chest.1);
453 next.chest.orientation = Quaternion::rotation_x(move1abs * -0.2 + move2abs * 0.3)
454 * Quaternion::rotation_z(move1abs * 0.5 + move2abs * -0.6);
455
456 next.pants.position = Vec3::new(0.0, s_a.pants.0, s_a.pants.1);
457 next.pants.orientation = Quaternion::rotation_x(move1abs * 0.2 + move2abs * -0.3)
458 * Quaternion::rotation_z(move1abs * -0.2 + move2abs * 0.2);
459
460 next.control_l.position = Vec3::new(1.0 - s_a.grip.0 * 2.0, 2.0, -2.0);
461 next.control_r.position = Vec3::new(-1.0 + s_a.grip.0 * 2.0, 2.0, 2.0);
462
463 next.control.position = Vec3::new(
464 -3.0 + move1abs * -3.0 + move2abs * 5.0,
465 s_a.grip.2 + move1abs * -12.0 + move2abs * 17.0,
466 -s_a.grip.2 / 2.5 + s_a.grip.0 * -2.0 + move2abs * 5.0,
467 );
468
469 next.control_l.orientation =
470 Quaternion::rotation_x(PI / 1.5 + move1abs * -1.5 + move2abs * 2.5)
471 * Quaternion::rotation_y(-0.3);
472 next.control_r.orientation =
473 Quaternion::rotation_x(PI / 1.5 + s_a.grip.0 * 0.2 + move1abs * -1.5 + move2abs * 2.5)
474 * Quaternion::rotation_y(0.5 + s_a.grip.0 * 0.2);
475
476 next.control.orientation = Quaternion::rotation_x(-1.35 + move1abs * -0.3 + move2abs * 0.5)
477 * Quaternion::rotation_z(move1abs * 1.0 + move2abs * -1.0)
478 * Quaternion::rotation_y(move2abs * 0.0);
479
480 next.tail.position = Vec3::new(0.0, s_a.tail.0, s_a.tail.1);
481 next.tail.orientation = Quaternion::rotation_x(0.05 * fastalt * speednormcancel)
482 * Quaternion::rotation_z(fast * 0.15 * speednormcancel);
483}
484
485pub fn biped_small_alpha_axe(
486 next: &mut BipedSmallSkeleton,
487 s_a: &SkeletonAttr,
488 move1abs: f32,
489 move2abs: f32,
490) {
491 next.main.position = Vec3::new(2.0, 2.0, 0.0);
492 next.control_l.position = Vec3::new(2.0 - 2.0 * s_a.grip.0, 1.0, 3.0);
493 next.control_l.orientation = Quaternion::rotation_x(PI / 2.0);
494
495 next.head.orientation = Quaternion::rotation_z(0.3 * move1abs - 0.6 * move2abs);
496 next.chest.orientation = Quaternion::rotation_z(0.5 * move1abs - 1.2 * move2abs);
497 next.foot_l.orientation = Quaternion::rotation_z(0.5 * move1abs - 0.8 * move2abs);
498 next.foot_r.orientation = Quaternion::rotation_z(0.3 * move1abs - 0.6 * move2abs);
499
500 next.control.position = Vec3::new(
501 -5.0 + 5.0 * move1abs,
502 -1.0 + s_a.grip.2,
503 -1.0 + 3.0 * move1abs + -s_a.grip.2 / 2.5 - 2.0 * s_a.grip.0,
504 );
505 next.control.orientation = Quaternion::rotation_x(-0.3 - move2abs)
506 * Quaternion::rotation_y(-0.9 * move1abs + 1.0 * move2abs)
507 * Quaternion::rotation_z(-0.3);
508 next.control_r.position = Vec3::new(
509 9.0 - 5.0 * move1abs + 2.0 * s_a.grip.0,
510 -1.0 + 2.0 * move1abs,
511 3.0 * move1abs - 2.0,
512 );
513 next.control_r.orientation = Quaternion::rotation_x(0.5 + 1.5 * move1abs + 0.2 * s_a.grip.0)
514 * Quaternion::rotation_y(0.2 + 0.2 * s_a.grip.0);
515}
516
517pub fn biped_small_alpha_dagger(
518 next: &mut BipedSmallSkeleton,
519 s_a: &SkeletonAttr,
520 move1abs: f32,
521 move2abs: f32,
522) {
523 next.head.orientation = Quaternion::rotation_x(move1abs * 0.15 + move2abs * -0.15)
524 * Quaternion::rotation_z(move1abs * 0.15 + move2abs * -0.3);
525 next.control_l.position = Vec3::new(2.0 - s_a.grip.0 * 2.0, 1.0, 3.0);
526 next.control_r.position = Vec3::new(
527 9.0 + move1abs * -7.0 + s_a.grip.0 * 2.0,
528 -1.0 + move1abs * 6.0,
529 -2.0,
530 );
531 let z_offset = if s_a.wing_for_foot {
532 s_a.grip.2 / 3.0
533 } else {
534 -s_a.grip.2 / 2.5
535 };
536 next.control.position = Vec3::new(
537 -5.0 + move1abs * 5.0 + move2abs * 9.0,
538 -1.0 + move2abs * -3.0 + s_a.grip.2,
539 -1.0 + move1abs * 3.0 + z_offset + s_a.grip.0 * -2.0,
540 );
541
542 next.control_l.orientation = Quaternion::rotation_x(PI / 2.0)
543 * Quaternion::rotation_y(-0.0)
544 * Quaternion::rotation_z(-0.0);
545 next.control_r.orientation = Quaternion::rotation_x(0.5 + move1abs * 1.5 + s_a.grip.0 * 0.2)
546 * Quaternion::rotation_y(0.2 + s_a.grip.0 * 0.2)
547 * Quaternion::rotation_z(-0.0);
548
549 next.control.orientation = Quaternion::rotation_x(-0.3 + move2abs * -1.0)
550 * Quaternion::rotation_y(move1abs * -0.4 + move2abs * 1.0)
551 * Quaternion::rotation_z(-0.3 + move2abs * -2.2);
552}
553
554pub fn biped_small_wield_sword(
555 next: &mut BipedSmallSkeleton,
556 s_a: &SkeletonAttr,
557 speednorm: f32,
558 slow: f32,
559) {
560 next.control_l.position = Vec3::new(2.0 - s_a.grip.0 * 2.0, 1.0, 3.0);
561 next.control_r.position = Vec3::new(9.0 + s_a.grip.0 * 2.0, -1.0, -2.0 + speednorm * -3.0);
562 let z_offset = if s_a.wing_for_foot {
563 s_a.grip.2 / 3.0
564 } else {
565 -s_a.grip.2 / 2.5
566 };
567 next.control.position = Vec3::new(
568 -5.0,
569 -1.0 + s_a.grip.2,
570 -1.0 + z_offset + s_a.grip.0 * -2.0 + speednorm * 2.0,
571 );
572
573 next.control_l.orientation = Quaternion::rotation_x(PI / 2.0 + slow * 0.1)
574 * Quaternion::rotation_y(-0.0)
575 * Quaternion::rotation_z(-0.0);
576 next.control_r.orientation = Quaternion::rotation_x(0.5 + slow * 0.1 + s_a.grip.0 * 0.2)
577 * Quaternion::rotation_y(0.2 + slow * 0.0 + s_a.grip.0 * 0.2)
578 * Quaternion::rotation_z(-0.0);
579
580 next.control.orientation = Quaternion::rotation_x(-0.3 + 0.2 * speednorm)
581 * Quaternion::rotation_y(-0.2 * speednorm)
582 * Quaternion::rotation_z(-0.3);
583}
584
585pub fn biped_small_wield_spear(
586 next: &mut BipedSmallSkeleton,
587 s_a: &SkeletonAttr,
588 anim_time: f32,
589 speed: f32,
590 fastacc: f32,
591) {
592 let speednorm = speed / 9.4;
593 let speednormcancel = 1.0 - speednorm;
594 let fastalt = (anim_time * 10.0 + PI / 2.0).sin();
595 let slow = (anim_time * 2.0).sin();
596
597 next.control_l.position = Vec3::new(1.0 - s_a.grip.0 * 2.0, 2.0, -2.0);
598 next.control_r.position = Vec3::new(-1.0 + s_a.grip.0 * 2.0, 2.0, 2.0);
599
600 next.control.position = Vec3::new(
601 -3.0,
602 s_a.grip.2,
603 -s_a.grip.2 / 2.5
604 + s_a.grip.0 * -2.0
605 + fastacc * 1.5
606 + fastalt * 0.5 * speednormcancel
607 + speednorm * 2.0,
608 );
609
610 next.control_l.orientation =
611 Quaternion::rotation_x(PI / 1.5 + slow * 0.1) * Quaternion::rotation_y(-0.3);
612 next.control_r.orientation = Quaternion::rotation_x(PI / 1.5 + slow * 0.1 + s_a.grip.0 * 0.2)
613 * Quaternion::rotation_y(0.5 + slow * 0.0 + s_a.grip.0 * 0.2);
614
615 next.control.orientation = Quaternion::rotation_x(-1.35 + 0.5 * speednorm);
616}
617
618pub fn biped_small_wield_bow(
619 next: &mut BipedSmallSkeleton,
620 s_a: &SkeletonAttr,
621 anim_time: f32,
622 speed: f32,
623 fastacc: f32,
624) {
625 let speednorm = speed / 9.4;
626 let speednormcancel = 1.0 - speednorm;
627 let fastalt = (anim_time * 10.0 + PI / 2.0).sin();
628 let slow = (anim_time * 2.0).sin();
629
630 next.control_l.position = Vec3::new(-1.0 - s_a.grip.0 * 2.0, 0.0, 0.0);
631 next.control_r.position = Vec3::new(1.0 + s_a.grip.0 * 2.0, 3.0, -2.0);
632
633 next.control.position = Vec3::new(
634 -1.0,
635 2.0 + s_a.grip.2,
636 3.0 + -s_a.grip.2 / 2.5
637 + s_a.grip.0 * -2.0
638 + fastacc * 1.5
639 + fastalt * 0.5 * speednormcancel
640 + speednorm * 2.0,
641 );
642
643 next.control_l.orientation =
644 Quaternion::rotation_x(PI / 2.0 + slow * 0.1) * Quaternion::rotation_y(-0.3);
645 next.control_r.orientation = Quaternion::rotation_x(PI / 2.0 + slow * 0.1 + s_a.grip.0 * 0.2)
646 * Quaternion::rotation_y(0.5 + slow * 0.0 + s_a.grip.0 * 0.2);
647
648 next.control.orientation =
649 Quaternion::rotation_x(-0.3 + 0.5 * speednorm) * Quaternion::rotation_y(0.5 * speednorm);
650}
651
652pub fn mount_mat(
653 body: &Body,
654 computed_skeleton: &ComputedBipedSmallSkeleton,
655 skeleton: &BipedSmallSkeleton,
656) -> (Mat4<f32>, Quaternion<f32>) {
657 use comp::biped_small::Species::*;
658
659 match (body.species, body.body_type) {
660 (Sahagin | Mandragora | Kappa | Gnoll | Bushly | Irrwurz | TreasureEgg, _) => {
661 (computed_skeleton.chest, skeleton.chest.orientation)
662 },
663 (GoblinThug | GoblinChucker | GoblinRuffian, _) => (
664 computed_skeleton.chest,
665 skeleton.chest.orientation * Quaternion::rotation_x(0.7),
666 ),
667 (Myrmidon, _) => (
668 computed_skeleton.tail,
669 skeleton.chest.orientation * skeleton.pants.orientation * skeleton.tail.orientation,
670 ),
671 _ => (
672 computed_skeleton.head,
673 skeleton.chest.orientation * skeleton.head.orientation,
674 ),
675 }
676}
677
678pub fn mount_transform(
679 body: &Body,
680 computed_skeleton: &ComputedBipedSmallSkeleton,
681 skeleton: &BipedSmallSkeleton,
682) -> Transform<f32, f32, f32> {
683 use comp::biped_small::Species::*;
684
685 let mount_point = match (body.species, body.body_type) {
687 (Gnome, _) => (0.0, -4.0, -1.0),
688 (Sahagin, _) => (0.0, 0.0, 5.0),
689 (Adlet, _) => (0.0, -4.0, 1.0),
690 (Gnarling, _) => (0.0, -4.0, 1.5),
691 (Mandragora, _) => (0.0, -3.5, 6.0),
692 (Kappa, _) => (0.0, -5.0, 1.0),
693 (Cactid, _) => (0.0, -2.5, -0.5),
694 (Gnoll, _) => (0.0, -4.0, 2.0),
695 (Haniwa, _) => (0.0, -6.0, 1.0),
696 (Myrmidon, _) => (0.0, -5.5, 1.5),
697 (Husk, _) => (0.0, -5.5, 1.5),
698 (Boreal, _) => (0.0, -4.5, 2.0),
699 (Ashen, _) => (0.0, -4.5, 2.0),
700 (Bushly, _) => (0.0, -3.0, 16.0),
701 (Irrwurz, _) => (0.0, -4.0, 10.0),
702 (IronDwarf, _) => (0.0, -4.0, 4.5),
703 (Flamekeeper, _) => (0.0, -6.5, 7.0),
704 (ShamanicSpirit, _) => (0.0, 0.0, 6.5),
705 (Jiangshi, _) => (0.0, -1.5, 7.5),
706 (TreasureEgg, _) => (0.0, -3.5, 8.0),
707 (GnarlingChieftain, _) => (0.0, -4.0, 4.5),
708 (BloodmoonHeiress, _) => (0.0, -1.0, 14.0),
709 (Bloodservant, _) => (0.0, -1.5, 4.5),
710 (Harlequin, _) => (0.0, -3.0, 2.5),
711 (GoblinThug, _) => (0.0, -4.0, -3.0),
712 (GoblinChucker, _) => (0.0, -9.0, -3.0),
713 (GoblinRuffian, _) => (0.0, -4.0, -3.0),
714 (GreenLegoom, _) => (0.0, -4.5, 6.0),
715 (OchreLegoom, _) => (0.0, -4.5, 3.0),
716 (PurpleLegoom, _) => (0.0, -3.5, 7.5),
717 (RedLegoom, _) => (0.0, -3.5, 5.0),
718 (UmberLegoom, _) => (0.0, -3.5, 5.0),
719 }
720 .into();
721
722 let (mount_mat, orientation) = mount_mat(body, computed_skeleton, skeleton);
723 Transform {
724 position: mount_mat.mul_point(mount_point),
725 orientation,
726 scale: Vec3::one(),
727 }
728}