2021-01-21 01:57:03 +00:00
|
|
|
pub mod alpha;
|
2021-02-15 01:27:28 +00:00
|
|
|
pub mod dash;
|
2020-12-23 06:24:44 +00:00
|
|
|
pub mod idle;
|
|
|
|
pub mod run;
|
2021-01-21 06:50:46 +00:00
|
|
|
pub mod shoot;
|
2021-03-12 05:38:41 +00:00
|
|
|
pub mod stunned;
|
2021-01-17 19:38:29 +00:00
|
|
|
pub mod wield;
|
2020-12-23 06:24:44 +00:00
|
|
|
|
|
|
|
// Reexports
|
2021-01-21 01:57:03 +00:00
|
|
|
pub use self::{
|
2021-02-15 01:27:28 +00:00
|
|
|
alpha::AlphaAnimation, dash::DashAnimation, idle::IdleAnimation, run::RunAnimation,
|
2021-03-12 05:38:41 +00:00
|
|
|
shoot::ShootAnimation, stunned::StunnedAnimation, wield::WieldAnimation,
|
2021-01-21 01:57:03 +00:00
|
|
|
};
|
2020-12-23 06:24:44 +00:00
|
|
|
|
|
|
|
use super::{make_bone, vek::*, FigureBoneData, Skeleton};
|
|
|
|
use common::comp::{self};
|
|
|
|
use core::convert::TryFrom;
|
|
|
|
|
|
|
|
pub type Body = comp::biped_small::Body;
|
|
|
|
|
|
|
|
skeleton_impls!(struct BipedSmallSkeleton {
|
|
|
|
+ head,
|
|
|
|
+ chest,
|
2021-01-23 22:37:38 +00:00
|
|
|
+ pants,
|
2020-12-23 06:24:44 +00:00
|
|
|
+ tail,
|
|
|
|
+ main,
|
|
|
|
+ hand_l,
|
|
|
|
+ hand_r,
|
|
|
|
+ foot_l,
|
|
|
|
+ foot_r,
|
2021-01-17 19:38:29 +00:00
|
|
|
control,
|
|
|
|
control_l,
|
|
|
|
control_r,
|
|
|
|
|
2020-12-23 06:24:44 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
impl Skeleton for BipedSmallSkeleton {
|
|
|
|
type Attr = SkeletonAttr;
|
|
|
|
type Body = Body;
|
|
|
|
|
|
|
|
const BONE_COUNT: usize = 9;
|
|
|
|
#[cfg(feature = "use-dyn-lib")]
|
|
|
|
const COMPUTE_FN: &'static [u8] = b"biped_small_compute_mats\0";
|
|
|
|
|
|
|
|
#[cfg_attr(feature = "be-dyn-lib", export_name = "biped_small_compute_mats")]
|
|
|
|
fn compute_matrices_inner(
|
|
|
|
&self,
|
|
|
|
base_mat: Mat4<f32>,
|
|
|
|
buf: &mut [FigureBoneData; super::MAX_BONE_COUNT],
|
|
|
|
) -> Vec3<f32> {
|
|
|
|
let chest_mat = base_mat * Mat4::<f32>::from(self.chest);
|
2021-01-23 22:37:38 +00:00
|
|
|
let pants_mat = chest_mat * Mat4::<f32>::from(self.pants);
|
2021-01-17 19:38:29 +00:00
|
|
|
let control_mat = chest_mat * Mat4::<f32>::from(self.control);
|
|
|
|
let control_l_mat = Mat4::<f32>::from(self.control_l);
|
|
|
|
let control_r_mat = Mat4::<f32>::from(self.control_r);
|
2020-12-23 06:24:44 +00:00
|
|
|
*(<&mut [_; Self::BONE_COUNT]>::try_from(&mut buf[0..Self::BONE_COUNT]).unwrap()) = [
|
|
|
|
make_bone(chest_mat * Mat4::<f32>::from(self.head)),
|
|
|
|
make_bone(chest_mat),
|
2021-01-23 22:37:38 +00:00
|
|
|
make_bone(pants_mat),
|
|
|
|
make_bone(pants_mat * Mat4::<f32>::from(self.tail)),
|
2021-01-17 19:38:29 +00:00
|
|
|
make_bone(control_mat * Mat4::<f32>::from(self.main)),
|
|
|
|
make_bone(control_mat * control_l_mat * Mat4::<f32>::from(self.hand_l)),
|
|
|
|
make_bone(control_mat * control_r_mat * Mat4::<f32>::from(self.hand_r)),
|
2020-12-23 06:24:44 +00:00
|
|
|
make_bone(base_mat * Mat4::<f32>::from(self.foot_l)),
|
2020-12-24 07:52:02 +00:00
|
|
|
make_bone(base_mat * Mat4::<f32>::from(self.foot_r)),
|
2020-12-23 06:24:44 +00:00
|
|
|
];
|
|
|
|
Vec3::default()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
pub struct SkeletonAttr {
|
|
|
|
head: (f32, f32),
|
|
|
|
chest: (f32, f32),
|
2021-01-23 22:37:38 +00:00
|
|
|
pants: (f32, f32),
|
2020-12-23 06:24:44 +00:00
|
|
|
tail: (f32, f32),
|
|
|
|
hand: (f32, f32, f32),
|
|
|
|
foot: (f32, f32, f32),
|
2021-01-17 19:38:29 +00:00
|
|
|
grip: (f32, f32, f32),
|
2021-02-20 20:38:27 +00:00
|
|
|
scaler: f32,
|
2020-12-23 06:24:44 +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::BipedSmall(body) => Ok(SkeletonAttr::from(body)),
|
|
|
|
_ => Err(()),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl Default for SkeletonAttr {
|
|
|
|
fn default() -> Self {
|
|
|
|
Self {
|
|
|
|
head: (0.0, 0.0),
|
|
|
|
chest: (0.0, 0.0),
|
2021-01-23 22:37:38 +00:00
|
|
|
pants: (0.0, 0.0),
|
2020-12-23 06:24:44 +00:00
|
|
|
tail: (0.0, 0.0),
|
|
|
|
hand: (0.0, 0.0, 0.0),
|
|
|
|
foot: (0.0, 0.0, 0.0),
|
2021-01-17 19:38:29 +00:00
|
|
|
grip: (0.0, 0.0, 0.0),
|
2021-02-20 20:38:27 +00:00
|
|
|
scaler: 0.0,
|
2020-12-23 06:24:44 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl<'a> From<&'a Body> for SkeletonAttr {
|
|
|
|
fn from(body: &'a Body) -> Self {
|
|
|
|
use comp::biped_small::Species::*;
|
|
|
|
Self {
|
|
|
|
head: match (body.species, body.body_type) {
|
2020-12-24 07:52:02 +00:00
|
|
|
(Gnome, _) => (-1.0, 9.0),
|
2020-12-27 15:01:02 +00:00
|
|
|
(Sahagin, _) => (7.0, -3.5),
|
|
|
|
(Adlet, _) => (0.0, 7.0),
|
2021-01-13 23:45:56 +00:00
|
|
|
(Gnarling, _) => (0.0, 6.0),
|
|
|
|
(Mandragora, _) => (-1.0, 9.0),
|
|
|
|
(Kappa, _) => (8.0, 3.5),
|
2021-01-23 22:37:38 +00:00
|
|
|
(Cactid, _) => (0.0, 7.0),
|
|
|
|
(Gnoll, _) => (5.5, -1.0),
|
|
|
|
(Haniwa, _) => (0.0, 7.0),
|
|
|
|
(Myrmidon, _) => (0.0, 8.0),
|
2021-03-24 02:28:49 +00:00
|
|
|
(Husk, _) => (0.5, 8.5),
|
2020-12-23 06:24:44 +00:00
|
|
|
},
|
|
|
|
chest: match (body.species, body.body_type) {
|
2020-12-24 07:52:02 +00:00
|
|
|
(Gnome, _) => (0.0, 9.0),
|
2020-12-27 15:01:02 +00:00
|
|
|
(Sahagin, _) => (0.0, 15.0),
|
|
|
|
(Adlet, _) => (0.0, 11.0),
|
2021-01-13 23:45:56 +00:00
|
|
|
(Gnarling, _) => (0.0, 7.5),
|
2021-01-17 19:38:29 +00:00
|
|
|
(Mandragora, _) => (0.0, 10.5),
|
2021-01-13 23:45:56 +00:00
|
|
|
(Kappa, _) => (0.0, 14.5),
|
2021-01-23 22:37:38 +00:00
|
|
|
(Cactid, _) => (0.0, 7.0),
|
|
|
|
(Gnoll, _) => (0.0, 15.5),
|
|
|
|
(Haniwa, _) => (0.0, 11.0),
|
|
|
|
(Myrmidon, _) => (0.0, 11.0),
|
2021-03-27 17:12:55 +00:00
|
|
|
(Husk, _) => (0.0, 13.0),
|
2020-12-23 06:24:44 +00:00
|
|
|
},
|
2021-01-23 22:37:38 +00:00
|
|
|
pants: match (body.species, body.body_type) {
|
2020-12-24 07:52:02 +00:00
|
|
|
(Gnome, _) => (0.0, -3.0),
|
2020-12-27 15:01:02 +00:00
|
|
|
(Sahagin, _) => (0.5, -7.0),
|
|
|
|
(Adlet, _) => (0.0, -3.0),
|
2021-01-13 23:45:56 +00:00
|
|
|
(Gnarling, _) => (0.0, -3.0),
|
2021-01-17 19:38:29 +00:00
|
|
|
(Mandragora, _) => (0.0, -6.5),
|
2021-01-13 23:45:56 +00:00
|
|
|
(Kappa, _) => (0.0, -3.0),
|
2021-01-23 22:37:38 +00:00
|
|
|
(Cactid, _) => (0.0, -3.0),
|
|
|
|
(Gnoll, _) => (0.5, -7.5),
|
|
|
|
(Haniwa, _) => (0.0, -3.5),
|
|
|
|
(Myrmidon, _) => (0.0, -3.0),
|
2021-03-27 17:12:55 +00:00
|
|
|
(Husk, _) => (-1.0, -3.0),
|
2020-12-23 06:24:44 +00:00
|
|
|
},
|
|
|
|
tail: match (body.species, body.body_type) {
|
2020-12-24 07:52:02 +00:00
|
|
|
(Gnome, _) => (0.0, 0.0),
|
2020-12-27 15:01:02 +00:00
|
|
|
(Sahagin, _) => (-2.5, -2.0),
|
|
|
|
(Adlet, _) => (-4.5, -2.0),
|
2021-01-13 23:45:56 +00:00
|
|
|
(Gnarling, _) => (-2.0, 1.5),
|
2021-01-17 19:38:29 +00:00
|
|
|
(Mandragora, _) => (0.0, -1.0),
|
|
|
|
(Kappa, _) => (0.0, -4.0),
|
2021-01-23 22:37:38 +00:00
|
|
|
(Cactid, _) => (0.0, 0.0),
|
|
|
|
(Gnoll, _) => (-2.5, -2.0),
|
|
|
|
(Haniwa, _) => (-4.5, -2.0),
|
|
|
|
(Myrmidon, _) => (-2.5, -1.0),
|
2021-03-24 02:28:49 +00:00
|
|
|
(Husk, _) => (0.0, 0.0),
|
2020-12-23 06:24:44 +00:00
|
|
|
},
|
|
|
|
hand: match (body.species, body.body_type) {
|
2021-01-17 19:38:29 +00:00
|
|
|
(Gnome, _) => (4.0, 0.5, -1.0),
|
|
|
|
(Sahagin, _) => (3.5, 3.5, -2.0),
|
|
|
|
(Adlet, _) => (4.5, -0.5, 2.0),
|
|
|
|
(Gnarling, _) => (4.0, 0.0, 1.5),
|
|
|
|
(Mandragora, _) => (4.0, -0.5, -2.5),
|
|
|
|
(Kappa, _) => (4.0, 3.5, -0.5),
|
2021-01-23 22:37:38 +00:00
|
|
|
(Cactid, _) => (4.0, 0.5, -1.0),
|
|
|
|
(Gnoll, _) => (3.5, 0.5, -1.0),
|
|
|
|
(Haniwa, _) => (4.25, -1.0, 1.5),
|
|
|
|
(Myrmidon, _) => (3.5, 1.5, 2.0),
|
2021-03-24 02:28:49 +00:00
|
|
|
(Husk, _) => (4.0, 0.0, 1.0),
|
2020-12-23 06:24:44 +00:00
|
|
|
},
|
|
|
|
foot: match (body.species, body.body_type) {
|
2020-12-24 07:52:02 +00:00
|
|
|
(Gnome, _) => (3.0, 0.0, 4.0),
|
2020-12-27 15:01:02 +00:00
|
|
|
(Sahagin, _) => (3.0, 1.0, 8.0),
|
|
|
|
(Adlet, _) => (3.0, 0.5, 7.0),
|
2021-01-13 23:45:56 +00:00
|
|
|
(Gnarling, _) => (2.5, 1.0, 5.0),
|
|
|
|
(Mandragora, _) => (3.0, 0.0, 4.0),
|
|
|
|
(Kappa, _) => (3.0, 3.0, 9.0),
|
2021-01-23 22:37:38 +00:00
|
|
|
(Cactid, _) => (3.0, 0.0, 5.0),
|
|
|
|
(Gnoll, _) => (3.0, 1.0, 7.0),
|
|
|
|
(Haniwa, _) => (3.0, 0.5, 8.0),
|
|
|
|
(Myrmidon, _) => (3.0, 0.5, 7.0),
|
2021-03-24 02:28:49 +00:00
|
|
|
(Husk, _) => (4.0, 0.5, 7.0),
|
2020-12-23 06:24:44 +00:00
|
|
|
},
|
2021-01-17 19:38:29 +00:00
|
|
|
grip: match (body.species, body.body_type) {
|
|
|
|
(Gnome, _) => (0.0, 0.0, 5.0),
|
|
|
|
(Sahagin, _) => (1.0, 0.0, 13.0),
|
|
|
|
(Adlet, _) => (0.0, 0.0, 7.0),
|
|
|
|
(Gnarling, _) => (0.0, 0.0, 7.0),
|
|
|
|
(Mandragora, _) => (0.0, 0.0, 7.0),
|
|
|
|
(Kappa, _) => (0.75, 1.0, 12.0),
|
2021-01-23 22:37:38 +00:00
|
|
|
(Cactid, _) => (0.0, 0.0, 8.0),
|
|
|
|
(Gnoll, _) => (1.0, 0.0, 9.0),
|
|
|
|
(Haniwa, _) => (0.0, 0.5, 8.0),
|
|
|
|
(Myrmidon, _) => (0.0, 0.0, 8.0),
|
2021-03-24 02:28:49 +00:00
|
|
|
(Husk, _) => (0.0, 0.0, 8.0),
|
2021-01-17 19:38:29 +00:00
|
|
|
},
|
2021-02-20 20:38:27 +00:00
|
|
|
scaler: match (body.species, body.body_type) {
|
2021-04-19 23:57:17 +00:00
|
|
|
(Gnome, _) => 0.8,
|
|
|
|
(Sahagin, _) => 1.05,
|
|
|
|
(Adlet, _) => 1.0,
|
|
|
|
(Gnarling, _) => 0.8,
|
|
|
|
(Mandragora, _) => 0.8,
|
|
|
|
(Kappa, _) => 0.8,
|
|
|
|
(Cactid, _) => 0.8,
|
|
|
|
(Gnoll, _) => 0.8,
|
|
|
|
(Haniwa, _) => 1.12,
|
|
|
|
(Myrmidon, _) => 1.24,
|
|
|
|
(Husk, _) => 1.12,
|
2021-02-20 20:38:27 +00:00
|
|
|
},
|
2020-12-23 06:24:44 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|