1pub mod alpha;
2pub mod aura;
3pub mod breathe;
4pub mod combomelee;
5pub mod dash;
6pub mod feed;
7pub mod fly;
8pub mod idle;
9pub mod run;
10pub mod selfbuff;
11pub mod shockwave;
12pub mod shoot;
13pub mod stunned;
14pub mod summon;
15pub mod swim;
16
17pub use self::{
19 alpha::AlphaAnimation, aura::AuraAnimation, breathe::BreatheAnimation,
20 combomelee::ComboAnimation, dash::DashAnimation, feed::FeedAnimation, fly::FlyAnimation,
21 idle::IdleAnimation, run::RunAnimation, selfbuff::SelfBuffAnimation,
22 shockwave::ShockwaveAnimation, shoot::ShootAnimation, stunned::StunnedAnimation,
23 summon::SummonAnimation, swim::SwimAnimation,
24};
25
26use super::{FigureBoneData, Skeleton, vek::*};
27use common::comp::{self};
28use core::convert::TryFrom;
29
30pub type Body = comp::bird_large::Body;
31
32skeleton_impls!(struct BirdLargeSkeleton ComputedBirdLargeSkeleton {
33 + head
34 + beak
35 + neck
36 + chest
37 + tail_front
38 + tail_rear
39 + wing_in_l
40 + wing_in_r
41 + wing_mid_l
42 + wing_mid_r
43 + wing_out_l
44 + wing_out_r
45 + leg_l
46 + leg_r
47 + foot_l
48 + foot_r
49});
50
51impl Skeleton for BirdLargeSkeleton {
52 type Attr = SkeletonAttr;
53 type Body = Body;
54 type ComputedSkeleton = ComputedBirdLargeSkeleton;
55
56 const BONE_COUNT: usize = ComputedBirdLargeSkeleton::BONE_COUNT;
57 #[cfg(feature = "use-dyn-lib")]
58 const COMPUTE_FN: &'static [u8] = b"bird_large_compute_mats\0";
59
60 #[cfg_attr(
61 feature = "be-dyn-lib",
62 unsafe(export_name = "bird_large_compute_mats")
63 )]
64 fn compute_matrices_inner(
65 &self,
66 base_mat: Mat4<f32>,
67 buf: &mut [FigureBoneData; super::MAX_BONE_COUNT],
68 body: Self::Body,
69 ) -> Self::ComputedSkeleton {
70 let base_mat = base_mat * Mat4::scaling_3d(SkeletonAttr::from(&body).scaler / 8.0);
71
72 let chest_mat = base_mat * Mat4::<f32>::from(self.chest);
73 let neck_mat = chest_mat * Mat4::<f32>::from(self.neck);
74 let head_mat = neck_mat * Mat4::<f32>::from(self.head);
75 let beak_mat = head_mat * Mat4::<f32>::from(self.beak);
76 let tail_front_mat = chest_mat * Mat4::<f32>::from(self.tail_front);
77 let tail_rear_mat = tail_front_mat * Mat4::<f32>::from(self.tail_rear);
78 let wing_in_l_mat = chest_mat * Mat4::<f32>::from(self.wing_in_l);
79 let wing_in_r_mat = chest_mat * Mat4::<f32>::from(self.wing_in_r);
80 let wing_mid_l_mat = wing_in_l_mat * Mat4::<f32>::from(self.wing_mid_l);
81 let wing_mid_r_mat = wing_in_r_mat * Mat4::<f32>::from(self.wing_mid_r);
82 let wing_out_l_mat = wing_mid_l_mat * Mat4::<f32>::from(self.wing_out_l);
83 let wing_out_r_mat = wing_mid_r_mat * Mat4::<f32>::from(self.wing_out_r);
84 let leg_l_mat = base_mat * Mat4::<f32>::from(self.leg_l);
85 let leg_r_mat = base_mat * Mat4::<f32>::from(self.leg_r);
86 let foot_l_mat = leg_l_mat * Mat4::<f32>::from(self.foot_l);
87 let foot_r_mat = leg_r_mat * Mat4::<f32>::from(self.foot_r);
88
89 let computed_skeleton = ComputedBirdLargeSkeleton {
90 head: head_mat,
91 beak: beak_mat,
92 neck: neck_mat,
93 chest: chest_mat,
94 tail_front: tail_front_mat,
95 tail_rear: tail_rear_mat,
96 wing_in_l: wing_in_l_mat,
97 wing_in_r: wing_in_r_mat,
98 wing_mid_l: wing_mid_l_mat,
99 wing_mid_r: wing_mid_r_mat,
100 wing_out_l: wing_out_l_mat,
101 wing_out_r: wing_out_r_mat,
102 leg_l: leg_l_mat,
103 leg_r: leg_r_mat,
104 foot_l: foot_l_mat,
105 foot_r: foot_r_mat,
106 };
107
108 computed_skeleton.set_figure_bone_data(buf);
109 computed_skeleton
110 }
111}
112
113pub struct SkeletonAttr {
114 chest: (f32, f32),
115 neck: (f32, f32),
116 head: (f32, f32),
117 beak: (f32, f32),
118 tail_front: (f32, f32),
119 tail_rear: (f32, f32),
120 wing_in: (f32, f32, f32),
121 wing_mid: (f32, f32, f32),
122 wing_out: (f32, f32, f32),
123 leg: (f32, f32, f32),
124 foot: (f32, f32, f32),
125 scaler: f32,
126 feed: f32,
127 wyvern: bool,
128}
129
130impl<'a> TryFrom<&'a comp::Body> for SkeletonAttr {
131 type Error = ();
132
133 fn try_from(body: &'a comp::Body) -> Result<Self, Self::Error> {
134 match body {
135 comp::Body::BirdLarge(body) => Ok(SkeletonAttr::from(body)),
136 _ => Err(()),
137 }
138 }
139}
140
141impl Default for SkeletonAttr {
142 fn default() -> Self {
143 Self {
144 chest: (0.0, 0.0),
145 neck: (0.0, 0.0),
146 head: (0.0, 0.0),
147 beak: (0.0, 0.0),
148 tail_front: (0.0, 0.0),
149 tail_rear: (0.0, 0.0),
150 wing_in: (0.0, 0.0, 0.0),
151 wing_mid: (0.0, 0.0, 0.0),
152 wing_out: (0.0, 0.0, 0.0),
153 leg: (0.0, 0.0, 0.0),
154 foot: (0.0, 0.0, 0.0),
155 scaler: 0.0,
156 feed: 0.0,
157 wyvern: false,
158 }
159 }
160}
161
162impl<'a> From<&'a Body> for SkeletonAttr {
163 fn from(body: &'a Body) -> Self {
164 use comp::bird_large::Species::*;
165 Self {
166 chest: match (body.species, body.body_type) {
167 (Phoenix, _) => (2.5, 16.0),
168 (Cockatrice, _) => (2.5, 16.0),
169 (Roc, _) => (2.5, 27.5),
170 (FlameWyvern, _) => (2.5, 20.5),
171 (CloudWyvern, _) => (2.5, 20.5),
172 (FrostWyvern, _) => (2.5, 20.5),
173 (SeaWyvern, _) => (2.5, 20.5),
174 (WealdWyvern, _) => (2.5, 20.5),
175 },
176 neck: match (body.species, body.body_type) {
177 (Phoenix, _) => (2.5, -5.5),
178 (Cockatrice, _) => (5.0, -1.5),
179 (Roc, _) => (9.5, -1.5),
180 (FlameWyvern, _) => (11.0, -0.5),
181 (CloudWyvern, _) => (11.0, -0.5),
182 (FrostWyvern, _) => (11.0, -0.5),
183 (SeaWyvern, _) => (11.0, -0.5),
184 (WealdWyvern, _) => (11.0, -0.5),
185 },
186 head: match (body.species, body.body_type) {
187 (Phoenix, _) => (6.0, 12.0),
188 (Cockatrice, _) => (8.0, 4.5),
189 (Roc, _) => (17.0, -3.5),
190 (FlameWyvern, _) => (10.0, -1.5),
191 (CloudWyvern, _) => (10.0, -1.5),
192 (FrostWyvern, _) => (10.0, -1.5),
193 (SeaWyvern, _) => (10.0, 2.5),
194 (WealdWyvern, _) => (10.0, -1.5),
195 },
196 beak: match (body.species, body.body_type) {
197 (Phoenix, _) => (5.0, 3.0),
198 (Cockatrice, _) => (2.0, -3.0),
199 (Roc, _) => (0.0, -3.0),
200 (FlameWyvern, _) => (-3.0, 2.0),
201 (CloudWyvern, _) => (-3.0, 2.0),
202 (FrostWyvern, _) => (-3.0, 2.0),
203 (SeaWyvern, _) => (-3.0, 2.0),
204 (WealdWyvern, _) => (-3.0, 2.0),
205 },
206 tail_front: match (body.species, body.body_type) {
207 (Phoenix, _) => (-9.5, -1.0),
208 (Cockatrice, _) => (-5.0, -2.5),
209 (Roc, _) => (-7.5, -3.5),
210 (FlameWyvern, _) => (-10.0, -5.0),
211 (CloudWyvern, _) => (-10.0, -5.0),
212 (FrostWyvern, _) => (-10.0, -5.0),
213 (SeaWyvern, _) => (-10.0, -5.0),
214 (WealdWyvern, _) => (-10.0, -5.0),
215 },
216 tail_rear: match (body.species, body.body_type) {
217 (Phoenix, _) => (-11.0, 0.0),
218 (Cockatrice, _) => (-8.0, -3.0),
219 (Roc, _) => (-8.0, -3.0),
220 (FlameWyvern, _) => (-11.0, -1.0),
221 (CloudWyvern, _) => (-11.0, -1.0),
222 (FrostWyvern, _) => (-11.0, -1.0),
223 (SeaWyvern, _) => (-11.0, -1.0),
224 (WealdWyvern, _) => (-11.0, -1.0),
225 },
226 wing_in: match (body.species, body.body_type) {
227 (Phoenix, _) => (3.0, 2.5, 2.0),
228 (Cockatrice, _) => (3.5, 7.0, 3.5),
229 (Roc, _) => (5.5, 7.5, -1.0),
230 (FlameWyvern, _) => (6.5, 11.5, -2.0),
231 (CloudWyvern, _) => (3.5, 11.5, -1.5),
232 (FrostWyvern, _) => (5.0, 10.5, -1.5),
233 (SeaWyvern, _) => (4.0, 11.5, -0.0),
234 (WealdWyvern, _) => (5.0, 11.5, -1.0),
235 },
236 wing_mid: match (body.species, body.body_type) {
237 (Phoenix, _) => (10.0, 1.0, 0.0),
238 (Cockatrice, _) => (6.0, 0.0, 0.0),
239 (Roc, _) => (12.0, 1.0, -0.5),
240 (FlameWyvern, _) => (19.0, 11.5, 1.0),
241 (CloudWyvern, _) => (19.0, 10.5, 1.0),
242 (FrostWyvern, _) => (18.5, 11.5, 0.5),
243 (SeaWyvern, _) => (19.0, 11.5, 0.5),
244 (WealdWyvern, _) => (19.0, 11.5, 0.0),
245 },
246 wing_out: match (body.species, body.body_type) {
247 (Phoenix, _) => (7.0, 2.0, 1.5),
248 (Cockatrice, _) => (4.0, -1.0, 1.0),
249 (Roc, _) => (10.0, -2.0, 0.0),
250 (FlameWyvern, _) => (11.0, -1.0, 0.0),
251 (CloudWyvern, _) => (11.0, -2.0, 0.0),
252 (FrostWyvern, _) => (10.0, -1.5, 0.5),
253 (SeaWyvern, _) => (12.0, -1.0, 0.0),
254 (WealdWyvern, _) => (16.0, -4.0, -1.0),
255 },
256 leg: match (body.species, body.body_type) {
257 (Phoenix, _) => (4.0, 1.5, 12.0),
258 (Cockatrice, _) => (3.5, 2.5, 13.0),
259 (Roc, _) => (5.5, -1.5, 17.5),
260 (FlameWyvern, _) => (5.5, 2.0, 15.5),
261 (CloudWyvern, _) => (5.5, 2.0, 15.5),
262 (FrostWyvern, _) => (5.5, 2.0, 15.5),
263 (SeaWyvern, _) => (5.5, 2.0, 15.5),
264 (WealdWyvern, _) => (5.5, 2.0, 15.5),
265 },
266 foot: match (body.species, body.body_type) {
267 (Phoenix, _) => (0.5, -0.5, -2.5),
268 (Cockatrice, _) => (0.5, -3.0, -3.0),
269 (Roc, _) => (2.5, -2.5, -5.5),
270 (FlameWyvern, _) => (0.5, 0.0, -3.5),
271 (CloudWyvern, _) => (0.5, 0.0, -3.5),
272 (FrostWyvern, _) => (0.5, 0.0, -3.5),
273 (SeaWyvern, _) => (0.5, 0.0, -3.5),
274 (WealdWyvern, _) => (0.5, 0.0, -3.5),
275 },
276 scaler: match (body.species, body.body_type) {
277 (Phoenix, _) => 1.0,
278 (Cockatrice, _) => 1.0,
279 (Roc, _) => 1.0,
280 (FlameWyvern, _)
281 | (CloudWyvern, _)
282 | (FrostWyvern, _)
283 | (SeaWyvern, _)
284 | (WealdWyvern, _) => 1.0,
285 },
286 feed: match (body.species, body.body_type) {
287 (Phoenix, _) => -0.65,
288 (Cockatrice, _) => -0.5,
289 (Roc, _) => -0.4,
290 (FlameWyvern, _)
291 | (CloudWyvern, _)
292 | (FrostWyvern, _)
293 | (SeaWyvern, _)
294 | (WealdWyvern, _) => -0.65,
295 },
296 wyvern: matches!(
297 (body.species, body.body_type),
298 (FlameWyvern, _)
299 | (CloudWyvern, _)
300 | (FrostWyvern, _)
301 | (SeaWyvern, _)
302 | (WealdWyvern, _)
303 ),
304 }
305 }
306}
307
308pub fn mount_mat(
309 body: &Body,
310 computed_skeleton: &ComputedBirdLargeSkeleton,
311 skeleton: &BirdLargeSkeleton,
312) -> (Mat4<f32>, Quaternion<f32>) {
313 use comp::bird_large::Species::*;
314
315 match (body.species, body.body_type) {
316 (SeaWyvern | FlameWyvern | Phoenix | Cockatrice, _) => {
317 (computed_skeleton.chest, skeleton.chest.orientation)
318 },
319 _ => (
320 computed_skeleton.neck,
321 skeleton.chest.orientation * skeleton.neck.orientation,
322 ),
323 }
324}
325
326pub fn mount_transform(
327 body: &Body,
328 computed_skeleton: &ComputedBirdLargeSkeleton,
329 skeleton: &BirdLargeSkeleton,
330) -> Transform<f32, f32, f32> {
331 use comp::bird_large::Species::*;
332
333 let mount_point = match (body.species, body.body_type) {
334 (Phoenix, _) => (0.0, 0.5, 7.5),
335 (Cockatrice, _) => (0.0, 5.0, 6.5),
336 (Roc, _) => (0.0, 5.5, 6.5),
337 (FlameWyvern, _) => (0.0, 9.5, 7.0),
338 (CloudWyvern, _) => (0.0, -0.5, 6.5),
339 (FrostWyvern, _) => (0.0, 0.5, 6.0),
340 (SeaWyvern, _) => (0.0, 8.0, 7.0),
341 (WealdWyvern, _) => (0.0, 0.0, 9.0),
342 }
343 .into();
344
345 let (mount_mat, orientation) = mount_mat(body, computed_skeleton, skeleton);
346 Transform {
347 position: mount_mat.mul_point(mount_point),
348 orientation,
349 scale: Vec3::one(),
350 }
351}