1pub mod alpha;
2pub mod breathe;
3pub mod dash;
4pub mod feed;
5pub mod fly;
6pub mod idle;
7pub mod run;
8pub mod shockwave;
9pub mod shoot;
10pub mod stunned;
11pub mod summon;
12pub mod swim;
13
14pub use self::{
16 alpha::AlphaAnimation, breathe::BreatheAnimation, dash::DashAnimation, feed::FeedAnimation,
17 fly::FlyAnimation, idle::IdleAnimation, run::RunAnimation, shockwave::ShockwaveAnimation,
18 shoot::ShootAnimation, stunned::StunnedAnimation, summon::SummonAnimation, swim::SwimAnimation,
19};
20
21use super::{FigureBoneData, Offsets, Skeleton, make_bone, vek::*};
22use common::comp::{self};
23use core::convert::TryFrom;
24
25pub type Body = comp::bird_medium::Body;
26
27skeleton_impls!(struct BirdMediumSkeleton {
28 + head,
29 + chest,
30 + tail,
31 + wing_in_l,
32 + wing_in_r,
33 + wing_out_l,
34 + wing_out_r,
35 + leg_l,
36 + leg_r,
37});
38
39impl Skeleton for BirdMediumSkeleton {
40 type Attr = SkeletonAttr;
41 type Body = Body;
42
43 const BONE_COUNT: usize = 9;
44 #[cfg(feature = "use-dyn-lib")]
45 const COMPUTE_FN: &'static [u8] = b"bird_medium_compute_mats\0";
46
47 #[cfg_attr(
48 feature = "be-dyn-lib",
49 unsafe(export_name = "bird_medium_compute_mats")
50 )]
51
52 fn compute_matrices_inner(
53 &self,
54 base_mat: Mat4<f32>,
55 buf: &mut [FigureBoneData; super::MAX_BONE_COUNT],
56 body: Self::Body,
57 ) -> Offsets {
58 let base_mat = base_mat * Mat4::scaling_3d(SkeletonAttr::from(&body).scaler / 8.0);
59
60 let chest_mat = base_mat * Mat4::<f32>::from(self.chest);
61 let head_mat = chest_mat * Mat4::<f32>::from(self.head);
62 let tail_mat = chest_mat * Mat4::<f32>::from(self.tail);
63 let wing_in_l_mat = chest_mat * Mat4::<f32>::from(self.wing_in_l);
64 let wing_in_r_mat = chest_mat * Mat4::<f32>::from(self.wing_in_r);
65 let wing_out_l_mat = wing_in_l_mat * Mat4::<f32>::from(self.wing_out_l);
66 let wing_out_r_mat = wing_in_r_mat * Mat4::<f32>::from(self.wing_out_r);
67 let leg_l_mat = base_mat * Mat4::<f32>::from(self.leg_l);
68 let leg_r_mat = base_mat * Mat4::<f32>::from(self.leg_r);
69
70 *(<&mut [_; Self::BONE_COUNT]>::try_from(&mut buf[0..Self::BONE_COUNT]).unwrap()) = [
71 make_bone(head_mat),
72 make_bone(chest_mat),
73 make_bone(tail_mat),
74 make_bone(wing_in_l_mat),
75 make_bone(wing_in_r_mat),
76 make_bone(wing_out_l_mat),
77 make_bone(wing_out_r_mat),
78 make_bone(leg_l_mat),
79 make_bone(leg_r_mat),
80 ];
81 use common::comp::body::bird_medium::Species::*;
82
83 let (mount_bone_mat, mount_bone_ori) = (chest_mat, self.chest.orientation);
84 let mount_position = mount_bone_mat.mul_point(mount_point(&body));
85 let mount_orientation = mount_bone_ori;
86
87 Offsets {
88 viewpoint: match body.species {
89 Bat | BloodmoonBat | VampireBat => {
90 Some((head_mat * Vec4::new(0.0, 5.0, -4.0, 1.0)).xyz())
91 },
92 _ => Some((head_mat * Vec4::new(0.0, 3.0, 2.0, 1.0)).xyz()),
93 },
94 mount_bone: Transform {
95 position: mount_position,
96 orientation: mount_orientation,
97 scale: Vec3::one(),
98 },
99 ..Default::default()
100 }
101 }
102}
103
104pub struct SkeletonAttr {
105 head: (f32, f32),
106 chest: (f32, f32),
107 tail: (f32, f32),
108 wing_in: (f32, f32, f32),
109 wing_out: (f32, f32, f32),
110 leg: (f32, f32, f32),
111 scaler: f32,
112 feed: f32,
113}
114
115impl<'a> TryFrom<&'a comp::Body> for SkeletonAttr {
116 type Error = ();
117
118 fn try_from(body: &'a comp::Body) -> Result<Self, Self::Error> {
119 match body {
120 comp::Body::BirdMedium(body) => Ok(SkeletonAttr::from(body)),
121 _ => Err(()),
122 }
123 }
124}
125
126impl Default for SkeletonAttr {
127 fn default() -> Self {
128 Self {
129 chest: (0.0, 0.0),
130 head: (0.0, 0.0),
131 tail: (0.0, 0.0),
132 wing_in: (0.0, 0.0, 0.0),
133 wing_out: (0.0, 0.0, 0.0),
134 leg: (0.0, 0.0, 0.0),
135 scaler: 0.0,
136 feed: 0.0,
137 }
138 }
139}
140
141impl<'a> From<&'a Body> for SkeletonAttr {
142 fn from(body: &'a Body) -> Self {
143 use comp::bird_medium::{BodyType::*, Species::*};
144 Self {
145 chest: match (body.species, body.body_type) {
146 (SnowyOwl, _) => (0.0, 4.5),
147 (HornedOwl, _) => (0.0, 4.5),
148 (Duck, _) => (0.0, 4.0),
149 (Cockatiel, _) => (0.0, 4.0),
150 (Chicken, Male) => (0.0, 5.5),
151 (Chicken, Female) => (0.0, 5.5),
152 (Bat, _) => (0.0, 7.0),
153 (Penguin, _) => (0.0, 7.0),
154 (Goose, _) => (0.0, 6.5),
155 (Peacock, _) => (0.0, 7.5),
156 (Eagle, _) => (0.0, 6.0),
157 (Parrot, _) => (0.0, 5.0),
158 (Crow, _) => (0.0, 4.0),
159 (Dodo, _) => (0.0, 6.0),
160 (Parakeet, _) => (0.0, 3.5),
161 (Puffin, _) => (0.0, 6.0),
162 (Toucan, _) => (0.0, 5.0),
163 (BloodmoonBat, _) => (0.0, 7.0),
164 (VampireBat, _) => (0.0, 7.5),
165 },
166 head: match (body.species, body.body_type) {
167 (SnowyOwl, _) => (3.5, 5.0),
168 (HornedOwl, _) => (3.5, 5.0),
169 (Duck, _) => (2.0, 5.5),
170 (Cockatiel, _) => (3.0, 5.5),
171 (Chicken, Male) => (3.0, 4.5),
172 (Chicken, Female) => (3.0, 6.0),
173 (Bat, _) => (2.5, 5.0),
174 (Penguin, _) => (1.5, 6.0),
175 (Goose, _) => (5.0, 4.0),
176 (Peacock, _) => (3.0, 5.0),
177 (Eagle, _) => (4.5, 5.0),
178 (Parrot, _) => (1.5, 4.5),
179 (Crow, _) => (4.5, 4.0),
180 (Dodo, _) => (3.5, 4.5),
181 (Parakeet, _) => (2.0, 4.0),
182 (Puffin, _) => (3.5, 5.5),
183 (Toucan, _) => (2.5, 4.5),
184 (BloodmoonBat, _) => (4.0, 5.0),
185 (VampireBat, _) => (2.5, 5.0),
186 },
187 tail: match (body.species, body.body_type) {
188 (SnowyOwl, _) => (-6.0, -2.0),
189 (HornedOwl, _) => (-6.0, -2.0),
190 (Duck, _) => (-5.0, 1.0),
191 (Cockatiel, _) => (-3.0, -0.5),
192 (Chicken, Male) => (-7.5, 3.5),
193 (Chicken, Female) => (-4.5, 3.0),
194 (Bat, _) => (-8.0, -4.0),
195 (Penguin, _) => (-3.0, -4.0),
196 (Goose, _) => (-4.0, 3.0),
197 (Peacock, _) => (-5.5, 1.0),
198 (Eagle, _) => (-6.0, -2.0),
199 (Parrot, _) => (-6.0, 0.0),
200 (Crow, _) => (-5.0, -1.5),
201 (Dodo, _) => (-7.5, -0.5),
202 (Parakeet, _) => (-5.0, -1.0),
203 (Puffin, _) => (-7.0, -2.0),
204 (Toucan, _) => (-6.0, 0.0),
205 (BloodmoonBat, _) => (-6.0, 1.0),
206 (VampireBat, _) => (-5.0, -4.0),
207 },
208 wing_in: match (body.species, body.body_type) {
209 (SnowyOwl, _) => (2.5, 1.0, 1.5),
210 (HornedOwl, _) => (2.5, 1.0, 1.5),
211 (Duck, _) => (2.5, 0.5, 1.0),
212 (Cockatiel, _) => (1.5, 0.5, 1.0),
213 (Chicken, Male) => (2.0, 1.0, 1.0),
214 (Chicken, Female) => (2.0, 1.5, 1.0),
215 (Bat, _) => (2.0, 2.0, -2.0),
216 (Penguin, _) => (3.0, 0.5, 1.0),
217 (Goose, _) => (2.5, 1.0, 2.0),
218 (Peacock, _) => (2.0, 1.0, 1.0),
219 (Eagle, _) => (3.0, 1.5, 1.0),
220 (Parrot, _) => (2.0, 0.5, 0.0),
221 (Crow, _) => (2.0, 0.5, 1.0),
222 (Dodo, _) => (3.0, -1.0, 1.0),
223 (Parakeet, _) => (1.0, 0.5, 0.0),
224 (Puffin, _) => (2.0, 0.0, 1.0),
225 (Toucan, _) => (2.0, 0.5, 0.0),
226 (BloodmoonBat, _) => (4.0, 3.0, 1.5),
227 (VampireBat, _) => (2.0, 2.0, -2.0),
228 },
229 wing_out: match (body.species, body.body_type) {
230 (SnowyOwl, _) => (4.5, 3.5, 1.0),
231 (HornedOwl, _) => (4.5, 3.5, 1.0),
232 (Duck, _) => (3.0, 2.0, 0.5),
233 (Cockatiel, _) => (3.0, 2.0, 0.5),
234 (Chicken, Male) => (3.0, 2.0, 0.5),
235 (Chicken, Female) => (3.0, 2.0, 0.5),
236 (Bat, _) => (5.0, 3.0, 0.0),
237 (Penguin, _) => (3.0, 2.5, 0.5),
238 (Goose, _) => (4.0, 3.0, 0.5),
239 (Peacock, _) => (5.0, 3.0, 0.5),
240 (Eagle, _) => (8.0, 4.5, 0.5),
241 (Parrot, _) => (5.0, 3.0, 0.5),
242 (Crow, _) => (5.0, 3.0, 0.5),
243 (Dodo, _) => (3.0, 3.0, 0.5),
244 (Parakeet, _) => (3.0, 0.0, 0.5),
245 (Puffin, _) => (5.0, 3.0, 0.5),
246 (Toucan, _) => (5.0, 3.0, 0.5),
247 (BloodmoonBat, _) => (11.0, 6.0, 0.0),
248 (VampireBat, _) => (5.0, 5.0, 0.0),
249 },
250 leg: match (body.species, body.body_type) {
251 (SnowyOwl, _) => (1.5, -2.5, 4.8),
252 (HornedOwl, _) => (1.5, -2.5, 4.8),
253 (Duck, _) => (1.5, 0.0, 3.0),
254 (Cockatiel, _) => (1.0, -1.0, 3.0),
255 (Chicken, Male) => (1.0, 0.0, 4.4),
256 (Chicken, Female) => (1.0, 0.0, 4.4),
257 (Bat, _) => (2.5, -1.0, 6.0),
258 (Penguin, _) => (1.5, -1.5, 4.5),
259 (Goose, _) => (2.0, -2.5, 4.4),
260 (Peacock, _) => (2.0, -2.0, 7.0),
261 (Eagle, _) => (1.5, -4.0, 4.4),
262 (Parrot, _) => (1.5, -1.0, 2.2),
263 (Crow, _) => (1.5, -2.5, 2.1),
264 (Dodo, _) => (1.5, -3.0, 3.0),
265 (Parakeet, _) => (1.0, -2.0, 1.3),
266 (Puffin, _) => (1.5, -2.2, 2.5),
267 (Toucan, _) => (1.5, -3.0, 2.3),
268 (BloodmoonBat, _) => (1.5, -3.5, 6.0),
269 (VampireBat, _) => (2.5, -1.0, 6.0),
270 },
271 scaler: match (body.species, body.body_type) {
272 (SnowyOwl, _) => 0.75,
273 (HornedOwl, _) => 0.75,
274 (Duck, _) => 0.75,
275 (Cockatiel, _) => 0.75,
276 (Chicken, _) => 0.75,
277 (Bat, _) => 0.75,
278 (Penguin, _) => 0.75,
279 (Goose, _) => 0.75,
280 (Peacock, _) => 0.75,
281 (Eagle, _) => 0.75,
282 (Parrot, _) => 0.75,
283 (Crow, _) => 0.75,
284 (Dodo, _) => 0.75,
285 (Parakeet, _) => 0.75,
286 (Puffin, _) => 0.75,
287 (Toucan, _) => 0.75,
288 (BloodmoonBat, _) => 1.05,
289 (VampireBat, _) => 0.75,
290 },
291 feed: match (body.species, body.body_type) {
292 (SnowyOwl, _) => -0.65,
293 (HornedOwl, _) => -0.65,
294 (Duck, _) => -0.55,
295 (Cockatiel, _) => -0.60,
296 (Chicken, _) => -0.65,
297 (Bat, _) => -0.55,
298 (Penguin, _) => -0.75,
299 (Goose, _) => -0.65,
300 (Peacock, _) => -1.2,
301 (Eagle, _) => -0.75,
302 (Parrot, _) => -0.60,
303 (Crow, _) => -0.65,
304 (Dodo, _) => -0.65,
305 (Parakeet, _) => -0.60,
306 (Puffin, _) => -0.75,
307 (Toucan, _) => -0.50,
308 (BloodmoonBat, _) => -0.55,
309 (VampireBat, _) => -0.55,
310 },
311 }
312 }
313}
314
315fn mount_point(body: &Body) -> Vec3<f32> {
316 use comp::bird_medium::{BodyType::*, Species::*};
317 match (body.species, body.body_type) {
318 (SnowyOwl, _) => (0.0, -4.0, 2.0),
319 (HornedOwl, _) => (0.0, -4.0, 1.0),
320 (Duck, _) => (0.0, -3.0, 2.0),
321 (Cockatiel, _) => (0.0, -1.5, 1.5),
322 (Chicken, Female) => (0.0, -2.5, 2.5),
323 (Chicken, Male) => (0.0, -2.0, 2.5),
324 (Bat, _) => (0.0, 0.0, -1.5),
325 (Penguin, _) => (0.0, -2.5, 4.5),
326 (Goose, _) => (0.0, -1.0, 3.0),
327 (Peacock, _) => (0.0, -3.0, 2.5),
328 (Eagle, _) => (0.0, -4.0, 2.0),
329 (Parrot, _) => (0.0, -3.0, 1.5),
330 (Crow, _) => (0.0, -1.5, 2.0),
331 (Dodo, _) => (0.0, -4.0, 3.0),
332 (Parakeet, _) => (0.0, -1.5, 1.5),
333 (Puffin, _) => (0.0, -3.5, 1.0),
334 (Toucan, _) => (0.0, -2.0, 1.5),
335 (BloodmoonBat, _) => (0.0, 0.5, 3.5),
336 (VampireBat, _) => (0.0, 0.0, -1.5),
337 }
338 .into()
339}