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