1pub mod alpha;
2pub mod combomelee;
3pub mod feed;
4pub mod idle;
5pub mod jump;
6pub mod run;
7pub mod shockwave;
8pub mod stunned;
9
10pub use self::{
12 alpha::AlphaAnimation, combomelee::ComboAnimation, feed::FeedAnimation, idle::IdleAnimation,
13 jump::JumpAnimation, run::RunAnimation, shockwave::ShockwaveAnimation,
14 stunned::StunnedAnimation,
15};
16
17use super::{FigureBoneData, Skeleton, vek::*};
18use common::comp::{self};
19use core::convert::TryFrom;
20
21pub type Body = comp::quadruped_small::Body;
22
23skeleton_impls!(struct QuadrupedSmallSkeleton ComputedQuadrupedSmallSkeleton {
24 + head
25 + chest
26 + leg_fl
27 + leg_fr
28 + leg_bl
29 + leg_br
30 + tail
31 mount
32});
33
34impl Skeleton for QuadrupedSmallSkeleton {
35 type Attr = SkeletonAttr;
36 type Body = Body;
37 type ComputedSkeleton = ComputedQuadrupedSmallSkeleton;
38
39 const BONE_COUNT: usize = ComputedQuadrupedSmallSkeleton::BONE_COUNT;
40 #[cfg(feature = "use-dyn-lib")]
41 const COMPUTE_FN: &'static [u8] = b"quadruped_small_compute_mats\0";
42
43 #[cfg_attr(
44 feature = "be-dyn-lib",
45 unsafe(export_name = "quadruped_small_compute_mats")
46 )]
47 fn compute_matrices_inner(
48 &self,
49 base_mat: Mat4<f32>,
50 buf: &mut [FigureBoneData; super::MAX_BONE_COUNT],
51 body: Self::Body,
52 ) -> Self::ComputedSkeleton {
53 let chest_mat = base_mat
54 * Mat4::scaling_3d(SkeletonAttr::from(&body).scaler / 11.0)
55 * Mat4::<f32>::from(self.chest);
56 let head_mat = chest_mat * Mat4::<f32>::from(self.head);
57
58 let computed_skeleton = ComputedQuadrupedSmallSkeleton {
59 head: head_mat,
60 chest: chest_mat,
61 leg_fl: chest_mat * Mat4::<f32>::from(self.leg_fl),
62 leg_fr: chest_mat * Mat4::<f32>::from(self.leg_fr),
63 leg_bl: chest_mat * Mat4::<f32>::from(self.leg_bl),
64 leg_br: chest_mat * Mat4::<f32>::from(self.leg_br),
65 tail: chest_mat * Mat4::<f32>::from(self.tail),
66 };
67
68 computed_skeleton.set_figure_bone_data(buf);
69 computed_skeleton
70 }
71}
72
73pub struct SkeletonAttr {
74 head: (f32, f32),
75 chest: (f32, f32),
76 feet_f: (f32, f32, f32),
77 feet_b: (f32, f32, f32),
78 tail: (f32, f32),
79 scaler: f32,
80 tempo: f32,
81 maximize: f32,
82 minimize: f32,
83 spring: f32,
84 feed: f32,
85 lateral: f32,
86}
87impl<'a> TryFrom<&'a comp::Body> for SkeletonAttr {
88 type Error = ();
89
90 fn try_from(body: &'a comp::Body) -> Result<Self, Self::Error> {
91 match body {
92 comp::Body::QuadrupedSmall(body) => Ok(SkeletonAttr::from(body)),
93 _ => Err(()),
94 }
95 }
96}
97
98impl Default for SkeletonAttr {
99 fn default() -> Self {
100 Self {
101 head: (0.0, 0.0),
102 chest: (0.0, 0.0),
103 feet_f: (0.0, 0.0, 0.0),
104 feet_b: (0.0, 0.0, 0.0),
105 tail: (0.0, 0.0),
106 scaler: 0.0,
107 tempo: 0.0,
108 maximize: 0.0,
109 minimize: 0.0,
110 spring: 0.0,
111 feed: 0.0,
112 lateral: 0.0,
113 }
114 }
115}
116
117impl<'a> From<&'a Body> for SkeletonAttr {
118 fn from(body: &'a Body) -> Self {
119 use comp::quadruped_small::{BodyType::*, Species::*};
120 Self {
121 head: match (body.species, body.body_type) {
122 (Pig, _) => (5.0, 2.0),
123 (Fox, _) => (4.0, 3.0),
124 (Sheep, _) => (4.0, 4.0),
125 (Boar, _) => (7.0, 0.0),
126 (Jackalope, _) => (3.0, 2.0),
127 (Skunk, _) => (5.0, 1.5),
128 (Cat, _) => (4.0, 3.0),
129 (Batfox, _) => (5.0, 1.0),
130 (Raccoon, _) => (5.0, 2.0),
131 (Quokka, _) => (6.0, 2.0),
132 (Holladon, _) => (7.0, 1.0),
133 (Hyena, _) => (7.5, 2.0),
134 (Rabbit, _) => (4.0, 3.0),
135 (Truffler, _) => (7.5, -9.0),
136 (Frog, _) => (4.0, 2.0),
137 (Rat, _) => (5.0, -1.0),
138 (Axolotl, _) => (3.0, 2.0),
139 (Gecko, _) => (4.0, 2.0),
140 (Turtle, _) => (5.0, -2.0),
141 (Squirrel, _) => (3.5, 1.0),
142 (Fungome, _) => (1.5, -1.5),
143 (Porcupine, _) => (6.0, 1.0),
144 (Beaver, _) => (5.5, 0.0),
145 (Hare, Male) => (3.0, 2.0),
146 (Hare, Female) => (2.5, 3.0),
147 (Dog, _) => (3.0, 4.5),
148 (Goat, _) => (3.5, 4.0),
149 (Seal, _) => (4.0, 2.5),
150 (TreantSapling, _) => (5.0, -2.0),
151 (MossySnail, _) => (2.0, 2.0),
152 },
153 chest: match (body.species, body.body_type) {
154 (Pig, _) => (0.0, 6.0),
155 (Fox, _) => (0.0, 8.0),
156 (Sheep, _) => (2.0, 7.0),
157 (Boar, _) => (0.0, 9.5),
158 (Jackalope, _) => (-2.0, 6.0),
159 (Skunk, _) => (0.0, 6.0),
160 (Cat, _) => (0.0, 6.0),
161 (Batfox, _) => (-2.0, 6.0),
162 (Raccoon, _) => (0.0, 5.5),
163 (Quokka, _) => (2.0, 6.5),
164 (Holladon, _) => (-2.0, 9.0),
165 (Hyena, _) => (-2.0, 9.0),
166 (Rabbit, _) => (-2.0, 6.0),
167 (Truffler, _) => (-2.0, 16.0),
168 (Frog, _) => (-2.0, 4.5),
169 (Rat, _) => (6.0, 5.0),
170 (Axolotl, _) => (3.0, 5.0),
171 (Gecko, _) => (7.5, 4.0),
172 (Turtle, _) => (1.0, 6.0),
173 (Squirrel, _) => (4.0, 5.0),
174 (Fungome, _) => (4.0, 4.0),
175 (Porcupine, _) => (2.0, 11.0),
176 (Beaver, _) => (2.0, 6.0),
177 (Hare, Male) => (-2.0, 7.0),
178 (Hare, Female) => (-2.0, 6.0),
179 (Dog, _) => (-2.0, 8.5),
180 (Goat, _) => (2.0, 7.5),
181 (Seal, _) => (-2.0, 4.0),
182 (TreantSapling, _) => (1.0, 13.0),
183 (MossySnail, _) => (-2.0, 4.5),
184 },
185 feet_f: match (body.species, body.body_type) {
186 (Pig, _) => (4.5, 3.5, -1.0),
187 (Fox, _) => (3.0, 5.0, -5.5),
188 (Sheep, _) => (3.5, 2.0, -2.0),
189 (Boar, _) => (3.5, 6.0, -5.5),
190 (Jackalope, _) => (3.0, 4.0, -2.0),
191 (Skunk, _) => (3.5, 4.0, -1.0),
192 (Cat, _) => (2.0, 4.0, -1.0),
193 (Batfox, _) => (3.0, 4.0, -0.5),
194 (Raccoon, _) => (4.0, 4.0, -0.0),
195 (Quokka, _) => (3.0, 4.0, -1.0),
196 (Holladon, _) => (5.0, 4.0, -2.5),
197 (Hyena, _) => (2.5, 5.0, -4.0),
198 (Rabbit, _) => (3.0, 3.0, -3.0),
199 (Truffler, _) => (2.5, 5.0, -9.0),
200 (Frog, _) => (4.5, 6.5, 0.0),
201 (Rat, _) => (3.0, 2.5, -1.0),
202 (Axolotl, _) => (2.0, 2.0, -2.0),
203 (Gecko, _) => (2.0, 4.0, -0.5),
204 (Turtle, _) => (5.0, 4.0, -2.0),
205 (Squirrel, _) => (3.5, 3.0, -1.0),
206 (Fungome, _) => (3.0, 2.0, -1.0),
207 (Porcupine, _) => (4.0, 6.5, -9.0),
208 (Beaver, _) => (4.5, 4.5, -4.0),
209 (Hare, Male) => (3.0, 1.0, -3.0),
210 (Hare, Female) => (3.0, 0.5, -4.0),
211 (Dog, _) => (3.5, 3.0, -2.5),
212 (Goat, _) => (3.0, 2.5, -3.5),
213 (Seal, _) => (6.5, 3.0, -2.0),
214 (TreantSapling, _) => (5.0, 4.0, -10.0),
215 (MossySnail, _) => (4.5, 6.5, 0.0),
216 },
217 feet_b: match (body.species, body.body_type) {
218 (Pig, _) => (3.5, -2.0, 0.0),
219 (Fox, _) => (3.0, -3.0, -3.0),
220 (Sheep, _) => (3.5, -3.5, -2.0),
221 (Boar, _) => (3.0, -3.0, -2.5),
222 (Jackalope, _) => (3.5, -2.0, 0.0),
223 (Skunk, _) => (3.5, -4.0, -1.5),
224 (Cat, _) => (2.0, -3.5, -1.0),
225 (Batfox, _) => (3.5, -2.0, -0.5),
226 (Raccoon, _) => (4.5, -3.0, 0.5),
227 (Quokka, _) => (4.0, -4.0, -1.0),
228 (Holladon, _) => (4.0, -2.0, -3.0),
229 (Hyena, _) => (3.0, -5.0, -2.5),
230 (Rabbit, _) => (3.5, -2.0, -1.0),
231 (Truffler, _) => (3.0, -5.0, -9.5),
232 (Frog, _) => (5.0, -3.5, 0.0),
233 (Rat, _) => (3.0, -2.0, 1.0),
234 (Axolotl, _) => (2.0, -3.0, -2.0),
235 (Gecko, _) => (1.5, -2.0, -0.5),
236 (Turtle, _) => (5.5, -2.5, -2.0),
237 (Squirrel, _) => (3.5, -3.0, 0.0),
238 (Fungome, _) => (3.0, -3.5, -1.0),
239 (Porcupine, _) => (4.5, -1.0, -8.0),
240 (Beaver, _) => (4.0, -2.5, -3.0),
241 (Hare, Male) => (3.5, -1.0, -2.0),
242 (Hare, Female) => (3.5, -3.0, -2.0),
243 (Dog, _) => (3.0, -3.5, -2.5),
244 (Goat, _) => (3.0, -4.0, -2.0),
245 (Seal, _) => (4.5, -6.0, -0.5),
246 (TreantSapling, _) => (5.5, -4.0, -10.0),
247 (MossySnail, _) => (5.0, -3.5, 0.0),
248 },
249 tail: match (body.species, body.body_type) {
250 (Pig, _) => (-4.5, 2.5),
251 (Fox, _) => (-4.5, 2.0),
252 (Sheep, _) => (-5.0, 0.0),
253 (Boar, _) => (-6.0, 0.0),
254 (Jackalope, _) => (-4.0, 2.0),
255 (Skunk, _) => (-4.0, 0.5),
256 (Cat, _) => (-3.5, 2.0),
257 (Batfox, _) => (0.0, 5.0),
258 (Raccoon, _) => (-4.0, 1.0),
259 (Quokka, _) => (-6.0, 1.0),
260 (Holladon, _) => (-1.0, 4.0),
261 (Hyena, _) => (-7.0, 0.0),
262 (Rabbit, _) => (-4.0, -0.0),
263 (Truffler, _) => (0.0, 0.0),
264 (Frog, _) => (0.0, -0.0),
265 (Rat, _) => (-3.0, 0.0),
266 (Axolotl, _) => (-4.0, -1.0),
267 (Gecko, _) => (-4.0, 0.0),
268 (Turtle, _) => (-6.0, -2.0),
269 (Squirrel, _) => (-4.0, 0.0),
270 (Fungome, _) => (-4.0, -2.0),
271 (Porcupine, _) => (-6.0, 1.0),
272 (Beaver, _) => (-6.5, -1.0),
273 (Hare, Male) => (-4.0, -1.0),
274 (Hare, Female) => (-4.0, 2.0),
275 (Dog, _) => (-5.0, 0.5),
276 (Goat, _) => (-7.0, 0.0),
277 (Seal, _) => (-1.0, 4.0),
278 (TreantSapling, _) => (-6.0, -2.0),
279 (MossySnail, _) => (0.0, -0.0),
280 },
281 scaler: match (body.species, body.body_type) {
282 (Pig, _) => 0.72,
283 (Fox, _) => 0.72,
284 (Boar, _) => 0.95,
285 (Jackalope, _) => 0.67,
286 (Skunk, _) => 0.72,
287 (Cat, _) => 0.67,
288 (Batfox, _) => 0.9,
289 (Holladon, _) => 1.12,
290 (Rabbit, _) => 0.56,
291 (Frog, _) => 0.56,
292 (Rat, _) => 0.5,
293 (Axolotl, _) => 0.5,
294 (Gecko, _) => 0.56,
295 (Turtle, _) => 0.67,
296 (Squirrel, _) => 0.4,
297 (Fungome, _) => 0.72,
298 (Porcupine, _) => 0.65,
299 (Hare, _) => 0.65,
300 (Seal, _) => 0.9,
301 (MossySnail, _) => 1.0,
302 (Hyena, _) => 0.95,
303 _ => 0.8,
304 },
305 tempo: match (body.species, body.body_type) {
306 (Boar, _) => 1.1,
307 (Cat, _) => 1.1,
308 (Quokka, _) => 1.2,
309 (Hyena, _) => 1.1,
310 (Rabbit, _) => 1.15,
311 (Frog, _) => 1.15,
312 (Rat, _) => 1.0,
313 (Axolotl, _) => 1.2,
314 (Gecko, _) => 1.1,
315 (Turtle, _) => 3.0,
316 (Squirrel, _) => 1.15,
317 (Porcupine, _) => 1.2,
318 (Beaver, _) => 1.2,
319 (Hare, _) => 1.15,
320 (Seal, _) => 2.5,
321 (TreantSapling, _) => 3.0,
322 (MossySnail, _) => 0.5,
323 _ => 1.0,
324 },
325 maximize: match (body.species, body.body_type) {
326 (Fox, _) => 1.3,
327 (Sheep, _) => 1.1,
328 (Boar, _) => 1.4,
329 (Jackalope, _) => 1.2,
330 (Hyena, _) => 1.4,
331 (Rabbit, _) => 1.3,
332 (Frog, _) => 1.3,
333 (Axolotl, _) => 0.9,
334 (Turtle, _) => 0.8,
335 (Fungome, _) => 0.7,
336 (Hare, _) => 1.3,
337 _ => 1.0,
338 },
339 minimize: match (body.species, body.body_type) {
340 (Pig, _) => 0.6,
341 (Fox, _) => 1.3,
342 (Sheep, _) => 0.8,
343 (Jackalope, _) => 0.8,
344 (Skunk, _) => 0.9,
345 (Cat, _) => 0.8,
346 (Quokka, _) => 0.9,
347 (Holladon, _) => 0.7,
348 (Hyena, _) => 1.4,
349 (Rabbit, _) => 0.8,
350 (Frog, _) => 0.8,
351 (Turtle, _) => 0.8,
352 (Fungome, _) => 0.4,
353 (Porcupine, _) => 0.9,
354 (Beaver, _) => 0.9,
355 (Hare, _) => 0.8,
356 (Goat, _) => 0.8,
357 (Seal, _) => 0.7,
358 (TreantSapling, _) => 0.7,
359 _ => 1.0,
360 },
361 spring: match (body.species, body.body_type) {
362 (Sheep, _) => 1.2,
363 (Boar, _) => 0.8,
364 (Jackalope, _) => 2.2,
365 (Cat, _) => 1.4,
366 (Batfox, _) => 1.1,
367 (Raccoon, _) => 1.1,
368 (Quokka, _) => 1.3,
369 (Holladon, _) => 0.7,
370 (Hyena, _) => 1.4,
371 (Rabbit, _) => 2.5,
372 (Truffler, _) => 0.8,
373 (Frog, _) => 2.5,
374 (Axolotl, _) => 0.8,
375 (Gecko, _) => 0.6,
376 (Turtle, _) => 0.7,
377 (Fungome, _) => 0.8,
378 (Porcupine, _) => 1.3,
379 (Beaver, _) => 1.3,
380 (Hare, Male) => 2.2,
381 (Hare, Female) => 2.5,
382 (Goat, _) => 1.2,
383 (Seal, _) => 0.7,
384 (TreantSapling, _) => 0.5,
385 _ => 1.0,
386 },
387 feed: match (body.species, body.body_type) {
388 (Boar, _) => 0.6,
389 (Skunk, _) => 0.8,
390 (Batfox, _) => 0.7,
391 (Raccoon, _) => 0.8,
392 (Rabbit, _) => 1.2,
393 (Truffler, _) => 0.6,
394 (Frog, _) => 0.7,
395 (Axolotl, _) => 0.8,
396 (Gecko, _) => 0.8,
397 (Turtle, _) => 0.5,
398 (Fungome, _) => 0.7,
399 (Hare, _) => 1.2,
400 _ => 1.0,
401 },
402 lateral: match (body.species, body.body_type) {
403 (Axolotl, _) => 1.0,
404 (Gecko, _) => 1.0,
405 (Turtle, _) => 1.0,
406 (Fungome, _) => 1.0,
407 (TreantSapling, _) => 1.0,
408 _ => 0.0,
409 },
410 }
411 }
412}
413
414pub fn mount_mat(
415 computed_skeleton: &ComputedQuadrupedSmallSkeleton,
416 skeleton: &QuadrupedSmallSkeleton,
417) -> (Mat4<f32>, Quaternion<f32>) {
418 (computed_skeleton.chest, skeleton.chest.orientation)
419}
420
421pub fn mount_transform(
422 body: &Body,
423 computed_skeleton: &ComputedQuadrupedSmallSkeleton,
424 skeleton: &QuadrupedSmallSkeleton,
425) -> Transform<f32, f32, f32> {
426 use comp::quadruped_small::{BodyType::*, Species::*};
427
428 let mount_point = match (body.species, body.body_type) {
429 (Pig, _) => (0.0, 1.0, 4.0),
430 (Fox, _) => (0.0, 0.0, 2.5),
431 (Sheep, _) => (0.0, -1.0, 3.5),
432 (Boar, _) => (0.0, -2.0, 3.5),
433 (Jackalope, _) => (0.0, -1.0, 3.5),
434 (Skunk, _) => (0.0, -1.0, 3.0),
435 (Cat, _) => (0.0, -1.0, 2.0),
436 (Batfox, _) => (0.0, 0.0, 3.0),
437 (Raccoon, _) => (0.0, 0.0, 3.5),
438 (Quokka, _) => (0.0, -1.0, 4.0),
439 (Goat, _) => (0.0, 0.0, 2.5),
440 (Holladon, _) => (0.0, -2.0, 2.0),
441 (Hyena, _) => (0.0, -4.0, 2.5),
442 (Rabbit, _) => (0.0, 0.0, 3.0),
443 (Truffler, _) => (0.0, -5.5, 10.0),
444 (Frog, _) => (0.0, 0.0, 3.0),
445 (Rat, _) => (0.0, 0.5, 3.5),
446 (Axolotl, _) => (0.0, -1.0, 1.5),
447 (Gecko, _) => (0.0, -1.0, 1.5),
448 (Turtle, _) => (0.0, -4.0, 3.0),
449 (Squirrel, _) => (0.0, 0.0, 2.5),
450 (Fungome, _) => (0.0, -4.0, 3.0),
451 (Porcupine, _) => (0.0, 7.0, 2.0),
452 (Beaver, _) => (0.0, 0.0, 4.0),
453 (Hare, Male) => (0.0, -2.0, 3.0),
454 (Hare, Female) => (0.0, -2.0, 2.0),
455 (Dog, _) => (0.0, -2.0, 2.5),
456 (Seal, _) => (0.0, 0.0, 3.0),
457 (TreantSapling, _) => (0.0, -4.0, 1.5),
458 (MossySnail, _) => (0.0, -2.0, 6.5),
459 }
460 .into();
461
462 let (mount_mat, orientation) = mount_mat(computed_skeleton, skeleton);
463 Transform {
464 position: mount_mat.mul_point(mount_point),
465 orientation,
466 scale: Vec3::one(),
467 }
468}