2020-11-21 19:06:36 +00:00
|
|
|
pub mod alpha;
|
|
|
|
pub mod beta;
|
2021-03-14 13:23:54 +00:00
|
|
|
pub mod dash;
|
2020-08-29 08:23:12 +00:00
|
|
|
pub mod idle;
|
|
|
|
pub mod jump;
|
|
|
|
pub mod run;
|
|
|
|
|
|
|
|
// Reexports
|
2020-11-21 20:59:25 +00:00
|
|
|
pub use self::{
|
2021-03-14 13:23:54 +00:00
|
|
|
alpha::AlphaAnimation, beta::BetaAnimation, dash::DashAnimation, idle::IdleAnimation,
|
|
|
|
jump::JumpAnimation, run::RunAnimation,
|
2020-11-21 20:59:25 +00:00
|
|
|
};
|
2020-08-29 08:23:12 +00:00
|
|
|
|
2021-04-29 00:42:38 +00:00
|
|
|
use super::{make_bone, vek::*, FigureBoneData, Offsets, Skeleton};
|
2020-08-29 08:23:12 +00:00
|
|
|
use common::comp::{self};
|
|
|
|
use core::convert::TryFrom;
|
|
|
|
|
|
|
|
pub type Body = comp::theropod::Body;
|
|
|
|
|
|
|
|
skeleton_impls!(struct TheropodSkeleton {
|
|
|
|
+ head,
|
|
|
|
+ jaw,
|
|
|
|
+ neck,
|
|
|
|
+ chest_front,
|
|
|
|
+ chest_back,
|
|
|
|
+ tail_front,
|
|
|
|
+ tail_back,
|
|
|
|
+ hand_l,
|
|
|
|
+ hand_r,
|
|
|
|
+ leg_l,
|
|
|
|
+ leg_r,
|
|
|
|
+ foot_l,
|
|
|
|
+ foot_r,
|
|
|
|
});
|
|
|
|
|
|
|
|
impl Skeleton for TheropodSkeleton {
|
|
|
|
type Attr = SkeletonAttr;
|
|
|
|
type Body = Body;
|
|
|
|
|
|
|
|
const BONE_COUNT: usize = 13;
|
|
|
|
#[cfg(feature = "use-dyn-lib")]
|
|
|
|
const COMPUTE_FN: &'static [u8] = b"theropod_compute_mats\0";
|
|
|
|
|
|
|
|
#[cfg_attr(feature = "be-dyn-lib", export_name = "theropod_compute_mats")]
|
|
|
|
|
|
|
|
fn compute_matrices_inner(
|
|
|
|
&self,
|
|
|
|
base_mat: Mat4<f32>,
|
|
|
|
buf: &mut [FigureBoneData; super::MAX_BONE_COUNT],
|
2021-04-29 00:42:38 +00:00
|
|
|
) -> Offsets {
|
2020-08-29 08:23:12 +00:00
|
|
|
let chest_front_mat = base_mat * Mat4::<f32>::from(self.chest_front);
|
|
|
|
let neck_mat = chest_front_mat * Mat4::<f32>::from(self.neck);
|
|
|
|
let head_mat = neck_mat * Mat4::<f32>::from(self.head);
|
|
|
|
let chest_back_mat = chest_front_mat * Mat4::<f32>::from(self.chest_back);
|
|
|
|
let tail_front_mat = chest_back_mat * Mat4::<f32>::from(self.tail_front);
|
2020-08-29 23:46:05 +00:00
|
|
|
let leg_l_mat = chest_back_mat * Mat4::<f32>::from(self.leg_l);
|
|
|
|
let leg_r_mat = chest_back_mat * Mat4::<f32>::from(self.leg_r);
|
2020-08-29 08:23:12 +00:00
|
|
|
|
|
|
|
*(<&mut [_; Self::BONE_COUNT]>::try_from(&mut buf[0..Self::BONE_COUNT]).unwrap()) = [
|
|
|
|
make_bone(head_mat),
|
|
|
|
make_bone(head_mat * Mat4::<f32>::from(self.jaw)),
|
|
|
|
make_bone(neck_mat),
|
|
|
|
make_bone(chest_front_mat),
|
|
|
|
make_bone(chest_back_mat),
|
|
|
|
make_bone(tail_front_mat),
|
|
|
|
make_bone(tail_front_mat * Mat4::<f32>::from(self.tail_back)),
|
|
|
|
make_bone(chest_front_mat * Mat4::<f32>::from(self.hand_l)),
|
|
|
|
make_bone(chest_front_mat * Mat4::<f32>::from(self.hand_r)),
|
|
|
|
make_bone(leg_l_mat),
|
|
|
|
make_bone(leg_r_mat),
|
|
|
|
make_bone(leg_l_mat * Mat4::<f32>::from(self.foot_l)),
|
|
|
|
make_bone(leg_r_mat * Mat4::<f32>::from(self.foot_r)),
|
|
|
|
];
|
2021-04-29 00:42:38 +00:00
|
|
|
Offsets {
|
|
|
|
lantern: Vec3::default(),
|
|
|
|
mount_bone: self.chest_front,
|
|
|
|
}
|
2020-08-29 08:23:12 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
pub struct SkeletonAttr {
|
|
|
|
head: (f32, f32),
|
|
|
|
neck: (f32, f32),
|
|
|
|
jaw: (f32, f32),
|
|
|
|
chest_front: (f32, f32),
|
|
|
|
chest_back: (f32, f32),
|
|
|
|
tail_front: (f32, f32),
|
|
|
|
tail_back: (f32, f32),
|
2020-08-29 14:11:48 +00:00
|
|
|
hand: (f32, f32, f32),
|
|
|
|
leg: (f32, f32, f32),
|
|
|
|
foot: (f32, f32, f32),
|
2020-10-04 23:47:54 +00:00
|
|
|
scaler: f32,
|
2020-08-29 08:23:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
impl<'a> std::convert::TryFrom<&'a comp::Body> for SkeletonAttr {
|
|
|
|
type Error = ();
|
|
|
|
|
|
|
|
fn try_from(body: &'a comp::Body) -> Result<Self, Self::Error> {
|
|
|
|
match body {
|
|
|
|
comp::Body::Theropod(body) => Ok(SkeletonAttr::from(body)),
|
|
|
|
_ => Err(()),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl Default for SkeletonAttr {
|
|
|
|
fn default() -> Self {
|
|
|
|
Self {
|
|
|
|
head: (0.0, 0.0),
|
|
|
|
neck: (0.0, 0.0),
|
|
|
|
jaw: (0.0, 0.0),
|
|
|
|
chest_front: (0.0, 0.0),
|
|
|
|
chest_back: (0.0, 0.0),
|
|
|
|
tail_front: (0.0, 0.0),
|
|
|
|
tail_back: (0.0, 0.0),
|
2020-08-29 14:11:48 +00:00
|
|
|
hand: (0.0, 0.0, 0.0),
|
|
|
|
leg: (0.0, 0.0, 0.0),
|
|
|
|
foot: (0.0, 0.0, 0.0),
|
2020-10-04 23:47:54 +00:00
|
|
|
scaler: 0.0,
|
2020-08-29 08:23:12 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl<'a> From<&'a Body> for SkeletonAttr {
|
|
|
|
fn from(body: &'a Body) -> Self {
|
|
|
|
use comp::theropod::Species::*;
|
|
|
|
Self {
|
|
|
|
head: match (body.species, body.body_type) {
|
2020-08-29 14:11:48 +00:00
|
|
|
(Archaeos, _) => (8.0, 4.0),
|
2020-09-22 03:56:03 +00:00
|
|
|
(Odonto, _) => (2.0, 2.0),
|
2020-10-04 23:47:54 +00:00
|
|
|
(Sandraptor, _) => (8.0, 5.0),
|
|
|
|
(Snowraptor, _) => (8.0, 5.0),
|
|
|
|
(Woodraptor, _) => (8.0, 5.0),
|
2021-01-13 23:45:56 +00:00
|
|
|
(Sunlizard, _) => (6.5, 3.5),
|
2021-03-12 00:20:05 +00:00
|
|
|
(Yale, _) => (7.0, 14.0),
|
|
|
|
(Ntouka, _) => (2.0, 2.5),
|
2020-08-29 08:23:12 +00:00
|
|
|
},
|
|
|
|
jaw: match (body.species, body.body_type) {
|
2020-08-29 23:46:05 +00:00
|
|
|
(Archaeos, _) => (1.0, -7.0),
|
2020-09-16 03:17:56 +00:00
|
|
|
(Odonto, _) => (2.0, -7.0),
|
2020-10-04 23:47:54 +00:00
|
|
|
(Sandraptor, _) => (0.0, -4.0),
|
|
|
|
(Snowraptor, _) => (0.0, -4.0),
|
|
|
|
(Woodraptor, _) => (0.0, -4.0),
|
2021-01-13 23:45:56 +00:00
|
|
|
(Sunlizard, _) => (2.0, -2.5),
|
2021-03-12 00:20:05 +00:00
|
|
|
(Yale, _) => (2.0, -9.5),
|
|
|
|
(Ntouka, _) => (0.0, -4.0),
|
2020-08-29 08:23:12 +00:00
|
|
|
},
|
|
|
|
neck: match (body.species, body.body_type) {
|
2020-08-29 14:11:48 +00:00
|
|
|
(Archaeos, _) => (4.5, -2.0),
|
2020-09-22 03:56:03 +00:00
|
|
|
(Odonto, _) => (4.0, 0.0),
|
2020-10-04 23:47:54 +00:00
|
|
|
(Sandraptor, _) => (4.0, 2.5),
|
|
|
|
(Snowraptor, _) => (4.0, 2.5),
|
|
|
|
(Woodraptor, _) => (4.0, 2.5),
|
2021-01-13 23:45:56 +00:00
|
|
|
(Sunlizard, _) => (2.5, 1.5),
|
2021-03-12 00:20:05 +00:00
|
|
|
(Yale, _) => (2.0, 4.0),
|
|
|
|
(Ntouka, _) => (4.0, 0.0),
|
2020-08-29 08:23:12 +00:00
|
|
|
},
|
|
|
|
chest_front: match (body.species, body.body_type) {
|
2020-08-29 23:46:05 +00:00
|
|
|
(Archaeos, _) => (0.0, 20.0),
|
2020-09-16 03:17:56 +00:00
|
|
|
(Odonto, _) => (0.0, 13.0),
|
2020-10-04 23:47:54 +00:00
|
|
|
(Sandraptor, _) => (0.0, 15.5),
|
|
|
|
(Snowraptor, _) => (0.0, 15.5),
|
|
|
|
(Woodraptor, _) => (0.0, 15.5),
|
2021-01-13 23:45:56 +00:00
|
|
|
(Sunlizard, _) => (0.0, 14.0),
|
2021-03-12 00:20:05 +00:00
|
|
|
(Yale, _) => (0.0, 19.5),
|
|
|
|
(Ntouka, _) => (0.0, 13.0),
|
2020-08-29 08:23:12 +00:00
|
|
|
},
|
|
|
|
chest_back: match (body.species, body.body_type) {
|
2020-08-29 14:11:48 +00:00
|
|
|
(Archaeos, _) => (-5.5, -1.0),
|
2020-09-16 03:17:56 +00:00
|
|
|
(Odonto, _) => (-5.0, 2.0),
|
2020-10-04 23:47:54 +00:00
|
|
|
(Sandraptor, _) => (-3.0, 0.5),
|
|
|
|
(Snowraptor, _) => (-3.0, 0.5),
|
|
|
|
(Woodraptor, _) => (-3.0, 0.5),
|
2021-01-13 23:45:56 +00:00
|
|
|
(Sunlizard, _) => (-2.0, 0.0),
|
2021-03-12 00:20:05 +00:00
|
|
|
(Yale, _) => (-3.0, -1.0),
|
|
|
|
(Ntouka, _) => (-4.5, 1.0),
|
2020-08-29 08:23:12 +00:00
|
|
|
},
|
|
|
|
tail_front: match (body.species, body.body_type) {
|
2020-08-29 14:11:48 +00:00
|
|
|
(Archaeos, _) => (-9.0, -1.5),
|
2020-09-16 03:17:56 +00:00
|
|
|
(Odonto, _) => (-7.0, -1.0),
|
2020-10-04 23:47:54 +00:00
|
|
|
(Sandraptor, _) => (-9.5, -1.0),
|
|
|
|
(Snowraptor, _) => (-9.5, -1.0),
|
|
|
|
(Woodraptor, _) => (-9.5, -1.0),
|
2021-01-13 23:45:56 +00:00
|
|
|
(Sunlizard, _) => (-8.5, -2.0),
|
2021-03-12 00:20:05 +00:00
|
|
|
(Yale, _) => (-9.5, -4.0),
|
|
|
|
(Ntouka, _) => (-9.5, -3.5),
|
2020-08-29 08:23:12 +00:00
|
|
|
},
|
|
|
|
tail_back: match (body.species, body.body_type) {
|
2020-08-29 23:46:05 +00:00
|
|
|
(Archaeos, _) => (-8.0, -0.5),
|
2020-09-16 03:17:56 +00:00
|
|
|
(Odonto, _) => (-8.0, 0.5),
|
2020-10-04 23:47:54 +00:00
|
|
|
(Sandraptor, _) => (-10.5, 0.5),
|
|
|
|
(Snowraptor, _) => (-10.5, 1.0),
|
|
|
|
(Woodraptor, _) => (-10.5, 0.5),
|
2021-01-13 23:45:56 +00:00
|
|
|
(Sunlizard, _) => (-10.0, -0.5),
|
2021-03-12 00:20:05 +00:00
|
|
|
(Yale, _) => (-5.0, -2.5),
|
|
|
|
(Ntouka, _) => (-9.5, -2.0),
|
2020-08-29 08:23:12 +00:00
|
|
|
},
|
2020-08-29 14:11:48 +00:00
|
|
|
hand: match (body.species, body.body_type) {
|
2020-08-29 23:46:05 +00:00
|
|
|
(Archaeos, _) => (3.0, 0.0, -4.0),
|
2020-09-16 03:17:56 +00:00
|
|
|
(Odonto, _) => (3.5, 3.0, -4.0),
|
2020-10-04 23:47:54 +00:00
|
|
|
(Sandraptor, _) => (2.5, 3.0, 1.0),
|
|
|
|
(Snowraptor, _) => (2.5, 3.0, 1.0),
|
|
|
|
(Woodraptor, _) => (2.5, 3.0, 1.0),
|
2021-01-13 23:45:56 +00:00
|
|
|
(Sunlizard, _) => (2.5, 1.5, -0.5),
|
2021-03-12 00:20:05 +00:00
|
|
|
(Yale, _) => (3.0, 2.0, -0.5),
|
|
|
|
(Ntouka, _) => (3.5, 3.0, -4.0),
|
2020-08-29 08:23:12 +00:00
|
|
|
},
|
2020-08-29 14:11:48 +00:00
|
|
|
leg: match (body.species, body.body_type) {
|
2021-02-15 01:27:28 +00:00
|
|
|
(Archaeos, _) => (2.5, -3.0, -4.0),
|
|
|
|
(Odonto, _) => (3.5, -2.5, -4.0),
|
2020-10-04 23:47:54 +00:00
|
|
|
(Sandraptor, _) => (1.5, -2.5, -3.0),
|
|
|
|
(Snowraptor, _) => (1.5, -2.5, -3.0),
|
|
|
|
(Woodraptor, _) => (1.5, -2.5, -3.0),
|
2021-01-13 23:45:56 +00:00
|
|
|
(Sunlizard, _) => (2.5, -2.5, -3.0),
|
2021-03-12 00:20:05 +00:00
|
|
|
(Yale, _) => (3.0, -3.5, -4.0),
|
|
|
|
(Ntouka, _) => (4.5, -5.5, -4.0),
|
2020-08-29 08:23:12 +00:00
|
|
|
},
|
2020-08-29 14:11:48 +00:00
|
|
|
foot: match (body.species, body.body_type) {
|
2021-02-15 01:27:28 +00:00
|
|
|
(Archaeos, _) => (3.0, -0.5, -7.0),
|
|
|
|
(Odonto, _) => (4.0, -6.5, -3.0),
|
2020-10-04 23:47:54 +00:00
|
|
|
(Sandraptor, _) => (2.0, 0.0, -3.0),
|
|
|
|
(Snowraptor, _) => (2.0, 0.0, -3.0),
|
|
|
|
(Woodraptor, _) => (2.0, 0.0, -3.0),
|
2021-01-13 23:45:56 +00:00
|
|
|
(Sunlizard, _) => (1.0, -0.5, -2.5),
|
2021-03-12 00:20:05 +00:00
|
|
|
(Yale, _) => (1.5, 1.0, -3.5),
|
|
|
|
(Ntouka, _) => (1.5, -1.0, -2.5),
|
2020-10-04 23:47:54 +00:00
|
|
|
},
|
|
|
|
scaler: match (body.species, body.body_type) {
|
2021-04-19 23:57:17 +00:00
|
|
|
(Archaeos, _) => (3.75),
|
|
|
|
(Odonto, _) => (3.75),
|
|
|
|
(Sandraptor, _) => (10.0),
|
|
|
|
(Snowraptor, _) => (10.0),
|
|
|
|
(Woodraptor, _) => (10.0),
|
|
|
|
(Sunlizard, _) => (10.0),
|
|
|
|
(Yale, _) => (8.75),
|
|
|
|
(Ntouka, _) => (3.75),
|
2020-08-29 08:23:12 +00:00
|
|
|
},
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|