2019-05-15 04:24:36 +00:00
|
|
|
pub mod idle;
|
|
|
|
pub mod jump;
|
2019-05-16 19:23:45 +00:00
|
|
|
pub mod run;
|
2019-05-13 23:43:10 +00:00
|
|
|
|
|
|
|
// Reexports
|
2020-02-01 20:39:39 +00:00
|
|
|
pub use self::{idle::IdleAnimation, jump::JumpAnimation, run::RunAnimation};
|
2019-05-15 04:24:36 +00:00
|
|
|
|
2019-05-13 23:43:10 +00:00
|
|
|
use super::{Bone, Skeleton};
|
2019-06-06 14:48:41 +00:00
|
|
|
use crate::render::FigureBoneData;
|
2020-01-26 00:22:48 +00:00
|
|
|
use common::comp::{self};
|
2020-05-04 15:15:31 +00:00
|
|
|
use vek::Vec3;
|
2019-05-13 23:43:10 +00:00
|
|
|
|
2020-01-26 00:22:48 +00:00
|
|
|
#[derive(Clone, Default)]
|
2019-10-25 01:26:32 +00:00
|
|
|
pub struct QuadrupedSmallSkeleton {
|
2019-10-26 02:20:38 +00:00
|
|
|
head: Bone,
|
|
|
|
chest: Bone,
|
|
|
|
leg_lf: Bone,
|
|
|
|
leg_rf: Bone,
|
|
|
|
leg_lb: Bone,
|
|
|
|
leg_rb: Bone,
|
2020-06-01 00:33:24 +00:00
|
|
|
tail: Bone,
|
2019-05-13 23:43:10 +00:00
|
|
|
}
|
|
|
|
|
2019-10-25 01:26:32 +00:00
|
|
|
impl QuadrupedSmallSkeleton {
|
2020-02-01 20:39:39 +00:00
|
|
|
pub fn new() -> Self { Self::default() }
|
2019-05-13 23:43:10 +00:00
|
|
|
}
|
|
|
|
|
2019-10-25 01:26:32 +00:00
|
|
|
impl Skeleton for QuadrupedSmallSkeleton {
|
2020-01-26 00:22:48 +00:00
|
|
|
type Attr = SkeletonAttr;
|
2020-02-01 20:39:39 +00:00
|
|
|
|
2020-06-01 00:33:24 +00:00
|
|
|
fn bone_count(&self) -> usize { 7 }
|
2020-04-25 14:38:17 +00:00
|
|
|
|
2020-05-04 15:15:31 +00:00
|
|
|
fn compute_matrices(&self) -> ([FigureBoneData; 16], Vec3<f32>) {
|
2020-06-01 00:33:24 +00:00
|
|
|
let chest_mat = self.chest.compute_base_matrix();
|
2020-05-04 15:15:31 +00:00
|
|
|
(
|
|
|
|
[
|
|
|
|
FigureBoneData::new(self.head.compute_base_matrix()),
|
2020-06-01 00:33:24 +00:00
|
|
|
FigureBoneData::new(chest_mat),
|
2020-05-04 15:15:31 +00:00
|
|
|
FigureBoneData::new(self.leg_lf.compute_base_matrix()),
|
|
|
|
FigureBoneData::new(self.leg_rf.compute_base_matrix()),
|
|
|
|
FigureBoneData::new(self.leg_lb.compute_base_matrix()),
|
|
|
|
FigureBoneData::new(self.leg_rb.compute_base_matrix()),
|
2020-06-01 00:33:24 +00:00
|
|
|
FigureBoneData::new(chest_mat * self.tail.compute_base_matrix()),
|
2020-05-04 15:15:31 +00:00
|
|
|
FigureBoneData::default(),
|
|
|
|
FigureBoneData::default(),
|
|
|
|
FigureBoneData::default(),
|
|
|
|
FigureBoneData::default(),
|
|
|
|
FigureBoneData::default(),
|
|
|
|
FigureBoneData::default(),
|
|
|
|
FigureBoneData::default(),
|
|
|
|
FigureBoneData::default(),
|
|
|
|
FigureBoneData::default(),
|
|
|
|
],
|
|
|
|
Vec3::default(),
|
|
|
|
)
|
2019-05-13 23:43:10 +00:00
|
|
|
}
|
|
|
|
|
2019-06-16 17:45:01 +00:00
|
|
|
fn interpolate(&mut self, target: &Self, dt: f32) {
|
2019-10-26 02:20:38 +00:00
|
|
|
self.head.interpolate(&target.head, dt);
|
|
|
|
self.chest.interpolate(&target.chest, dt);
|
|
|
|
self.leg_lf.interpolate(&target.leg_lf, dt);
|
|
|
|
self.leg_rf.interpolate(&target.leg_rf, dt);
|
|
|
|
self.leg_lb.interpolate(&target.leg_lb, dt);
|
|
|
|
self.leg_rb.interpolate(&target.leg_rb, dt);
|
2020-06-01 00:33:24 +00:00
|
|
|
self.tail.interpolate(&target.tail, dt);
|
2019-05-13 23:43:10 +00:00
|
|
|
}
|
|
|
|
}
|
2020-01-26 00:22:48 +00:00
|
|
|
|
|
|
|
pub struct SkeletonAttr {
|
|
|
|
head: (f32, f32),
|
|
|
|
chest: (f32, f32),
|
|
|
|
feet_f: (f32, f32, f32),
|
|
|
|
feet_b: (f32, f32, f32),
|
2020-06-01 00:33:24 +00:00
|
|
|
tail: (f32, f32),
|
2020-01-26 00:22:48 +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::QuadrupedSmall(body) => Ok(SkeletonAttr::from(body)),
|
|
|
|
_ => Err(()),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl Default for SkeletonAttr {
|
|
|
|
fn default() -> Self {
|
|
|
|
Self {
|
|
|
|
head: (0.0, 0.0),
|
|
|
|
chest: (0.0, 0.0),
|
|
|
|
feet_f: (0.0, 0.0, 0.0),
|
|
|
|
feet_b: (0.0, 0.0, 0.0),
|
2020-06-01 00:33:24 +00:00
|
|
|
tail: (0.0, 0.0),
|
2020-01-26 00:22:48 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl<'a> From<&'a comp::quadruped_small::Body> for SkeletonAttr {
|
|
|
|
fn from(body: &'a comp::quadruped_small::Body) -> Self {
|
|
|
|
use comp::quadruped_small::Species::*;
|
|
|
|
Self {
|
|
|
|
head: match (body.species, body.body_type) {
|
|
|
|
(Pig, _) => (6.0, 7.0),
|
|
|
|
(Fox, _) => (8.0, 8.0),
|
|
|
|
(Sheep, _) => (8.0, 8.0),
|
|
|
|
(Boar, _) => (13.0, 8.0),
|
|
|
|
(Jackalope, _) => (6.0, 9.0),
|
|
|
|
(Skunk, _) => (7.0, 9.0),
|
|
|
|
(Cat, _) => (7.0, 8.0),
|
|
|
|
(Batfox, _) => (8.0, 9.0),
|
|
|
|
(Raccoon, _) => (9.0, 7.0),
|
|
|
|
(Quokka, _) => (10.0, 10.0),
|
|
|
|
(Dodarock, _) => (8.0, 9.0),
|
|
|
|
(Holladon, _) => (8.0, 8.0),
|
2020-04-28 03:13:23 +00:00
|
|
|
(Hyena, _) => (7.5, 13.0),
|
2020-01-26 00:22:48 +00:00
|
|
|
},
|
|
|
|
chest: match (body.species, body.body_type) {
|
|
|
|
(Pig, _) => (0.0, 8.0),
|
2020-06-01 00:33:24 +00:00
|
|
|
(Fox, _) => (1.0, 5.0),
|
|
|
|
(Sheep, _) => (-1.0, 6.0),
|
|
|
|
(Boar, _) => (0.0, 7.0),
|
2020-01-26 00:22:48 +00:00
|
|
|
(Jackalope, _) => (-2.0, 6.0),
|
2020-06-01 00:33:24 +00:00
|
|
|
(Skunk, _) => (0.0, 6.0),
|
|
|
|
(Cat, _) => (0.0, 6.0),
|
2020-01-26 00:22:48 +00:00
|
|
|
(Batfox, _) => (-2.0, 6.0),
|
2020-06-01 00:33:24 +00:00
|
|
|
(Raccoon, _) => (0.0, 6.0),
|
2020-01-26 00:22:48 +00:00
|
|
|
(Quokka, _) => (2.0, 8.0),
|
|
|
|
(Dodarock, _) => (-2.0, 8.0),
|
|
|
|
(Holladon, _) => (-2.0, 6.0),
|
2020-04-28 03:13:23 +00:00
|
|
|
(Hyena, _) => (-2.0, 9.0),
|
2020-01-26 00:22:48 +00:00
|
|
|
},
|
|
|
|
feet_f: match (body.species, body.body_type) {
|
|
|
|
(Pig, _) => (3.0, 5.0, 2.0),
|
|
|
|
(Fox, _) => (3.0, 5.0, 3.0),
|
|
|
|
(Sheep, _) => (3.0, 3.0, 3.0),
|
|
|
|
(Boar, _) => (3.0, 5.0, 3.0),
|
|
|
|
(Jackalope, _) => (3.0, 5.0, 4.0),
|
|
|
|
(Skunk, _) => (3.0, 3.0, 4.0),
|
|
|
|
(Cat, _) => (3.0, 5.0, 3.0),
|
|
|
|
(Batfox, _) => (2.5, 5.0, 3.0),
|
|
|
|
(Raccoon, _) => (3.0, 5.0, 3.0),
|
|
|
|
(Quokka, _) => (3.0, 5.0, 3.0),
|
|
|
|
(Dodarock, _) => (3.5, 5.0, 4.0),
|
|
|
|
(Holladon, _) => (3.0, 5.0, 4.0),
|
2020-04-28 03:13:23 +00:00
|
|
|
(Hyena, _) => (2.5, 5.0, 6.0),
|
2020-01-26 00:22:48 +00:00
|
|
|
},
|
|
|
|
feet_b: match (body.species, body.body_type) {
|
|
|
|
(Pig, _) => (3.0, -2.0, 2.0),
|
|
|
|
(Fox, _) => (2.5, -2.0, 3.0),
|
|
|
|
(Sheep, _) => (3.0, -4.0, 3.0),
|
|
|
|
(Boar, _) => (3.0, -3.0, 5.0),
|
|
|
|
(Jackalope, _) => (3.0, -2.0, 4.0),
|
|
|
|
(Skunk, _) => (3.0, -4.0, 4.0),
|
|
|
|
(Cat, _) => (2.0, -2.0, 3.0),
|
|
|
|
(Batfox, _) => (2.5, -2.0, 3.0),
|
|
|
|
(Raccoon, _) => (3.0, -2.0, 3.0),
|
|
|
|
(Quokka, _) => (3.0, -4.0, 3.0),
|
|
|
|
(Dodarock, _) => (4.5, -3.0, 4.0),
|
2020-01-29 06:38:08 +00:00
|
|
|
(Holladon, _) => (4.0, -4.0, 3.0),
|
2020-04-28 03:13:23 +00:00
|
|
|
(Hyena, _) => (2.5, -7.0, 6.0),
|
2020-01-26 00:22:48 +00:00
|
|
|
},
|
2020-06-01 00:33:24 +00:00
|
|
|
tail: match (body.species, body.body_type) {
|
|
|
|
(Pig, _) => (-4.0, 3.0),
|
|
|
|
(Fox, _) => (-3.5, 1.0),
|
|
|
|
(Sheep, _) => (-5.0, 0.0),
|
|
|
|
(Boar, _) => (-8.5, 2.0),
|
|
|
|
(Jackalope, _) => (0.0, 5.0),
|
|
|
|
(Skunk, _) => (-3.0, 1.5),
|
|
|
|
(Cat, _) => (-3.0, 2.0),
|
|
|
|
(Batfox, _) => (0.0, 5.0),
|
|
|
|
(Raccoon, _) => (-4.0, 1.0),
|
|
|
|
(Quokka, _) => (0.0, 6.0),
|
|
|
|
(Dodarock, _) => (0.0, 5.0),
|
|
|
|
(Holladon, _) => (0.0, 4.0),
|
|
|
|
(Hyena, _) => (-8.0, 1.0),
|
|
|
|
},
|
2020-01-26 00:22:48 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|