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