2019-05-24 23:01:10 +00:00
|
|
|
pub mod attack;
|
2019-08-25 16:48:12 +00:00
|
|
|
pub mod block;
|
2019-08-29 02:17:08 +00:00
|
|
|
pub mod blockidle;
|
2019-06-13 18:09:50 +00:00
|
|
|
pub mod cidle;
|
2019-09-09 19:11:40 +00:00
|
|
|
pub mod climb;
|
2019-05-16 19:23:45 +00:00
|
|
|
pub mod gliding;
|
2019-04-21 17:35:43 +00:00
|
|
|
pub mod idle;
|
2019-05-09 10:32:44 +00:00
|
|
|
pub mod jump;
|
2019-06-11 04:08:55 +00:00
|
|
|
pub mod roll;
|
2019-06-13 18:09:50 +00:00
|
|
|
pub mod run;
|
2019-09-09 19:11:40 +00:00
|
|
|
pub mod sit;
|
2019-08-29 02:17:08 +00:00
|
|
|
pub mod stand;
|
2019-09-09 19:11:40 +00:00
|
|
|
pub mod swim;
|
2019-08-29 02:17:08 +00:00
|
|
|
pub mod wield;
|
2019-01-14 14:40:22 +00:00
|
|
|
|
2019-04-21 17:35:43 +00:00
|
|
|
// Reexports
|
2019-05-24 23:01:10 +00:00
|
|
|
pub use self::attack::AttackAnimation;
|
2019-08-25 16:48:12 +00:00
|
|
|
pub use self::block::BlockAnimation;
|
2019-08-29 02:17:08 +00:00
|
|
|
pub use self::blockidle::BlockIdleAnimation;
|
2019-06-13 18:09:50 +00:00
|
|
|
pub use self::cidle::CidleAnimation;
|
2019-09-09 19:11:40 +00:00
|
|
|
pub use self::climb::ClimbAnimation;
|
2019-05-16 19:23:45 +00:00
|
|
|
pub use self::gliding::GlidingAnimation;
|
2019-04-21 17:35:43 +00:00
|
|
|
pub use self::idle::IdleAnimation;
|
2019-05-09 10:32:44 +00:00
|
|
|
pub use self::jump::JumpAnimation;
|
2019-06-11 04:08:55 +00:00
|
|
|
pub use self::roll::RollAnimation;
|
2019-06-13 18:09:50 +00:00
|
|
|
pub use self::run::RunAnimation;
|
2019-09-09 19:11:40 +00:00
|
|
|
pub use self::sit::SitAnimation;
|
2019-08-29 02:17:08 +00:00
|
|
|
pub use self::stand::StandAnimation;
|
2019-09-09 19:11:40 +00:00
|
|
|
pub use self::swim::SwimAnimation;
|
2019-08-29 02:17:08 +00:00
|
|
|
pub use self::wield::WieldAnimation;
|
2019-05-19 17:36:55 +00:00
|
|
|
|
2019-04-29 20:37:19 +00:00
|
|
|
use super::{Bone, Skeleton};
|
2019-06-06 14:48:41 +00:00
|
|
|
use crate::render::FigureBoneData;
|
2019-01-14 14:40:22 +00:00
|
|
|
|
2019-04-21 17:35:43 +00:00
|
|
|
#[derive(Clone)]
|
|
|
|
pub struct CharacterSkeleton {
|
|
|
|
head: Bone,
|
|
|
|
chest: Bone,
|
|
|
|
belt: Bone,
|
|
|
|
shorts: Bone,
|
|
|
|
l_hand: Bone,
|
|
|
|
r_hand: Bone,
|
|
|
|
l_foot: Bone,
|
|
|
|
r_foot: Bone,
|
|
|
|
weapon: Bone,
|
|
|
|
l_shoulder: Bone,
|
|
|
|
r_shoulder: Bone,
|
2019-05-13 00:52:30 +00:00
|
|
|
draw: Bone,
|
2019-05-16 04:40:35 +00:00
|
|
|
torso: Bone,
|
2019-04-21 17:35:43 +00:00
|
|
|
}
|
2019-04-24 00:17:50 +00:00
|
|
|
|
2019-04-21 17:35:43 +00:00
|
|
|
impl CharacterSkeleton {
|
|
|
|
pub fn new() -> Self {
|
|
|
|
Self {
|
|
|
|
head: Bone::default(),
|
|
|
|
chest: Bone::default(),
|
|
|
|
belt: Bone::default(),
|
|
|
|
shorts: Bone::default(),
|
|
|
|
l_hand: Bone::default(),
|
|
|
|
r_hand: Bone::default(),
|
|
|
|
l_foot: Bone::default(),
|
|
|
|
r_foot: Bone::default(),
|
|
|
|
weapon: Bone::default(),
|
|
|
|
l_shoulder: Bone::default(),
|
|
|
|
r_shoulder: Bone::default(),
|
2019-05-13 00:52:30 +00:00
|
|
|
draw: Bone::default(),
|
2019-05-16 04:40:35 +00:00
|
|
|
torso: Bone::default(),
|
2019-04-21 17:35:43 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2019-01-14 14:40:22 +00:00
|
|
|
|
2019-04-21 17:35:43 +00:00
|
|
|
impl Skeleton for CharacterSkeleton {
|
|
|
|
fn compute_matrices(&self) -> [FigureBoneData; 16] {
|
|
|
|
let chest_mat = self.chest.compute_base_matrix();
|
|
|
|
let torso_mat = self.torso.compute_base_matrix();
|
2019-05-13 00:52:30 +00:00
|
|
|
let l_hand_mat = self.l_hand.compute_base_matrix();
|
2019-05-19 17:36:55 +00:00
|
|
|
let weapon_mat = self.weapon.compute_base_matrix();
|
2019-06-28 08:24:13 +00:00
|
|
|
let head_mat = self.head.compute_base_matrix();
|
2019-04-21 17:35:43 +00:00
|
|
|
[
|
2019-06-28 08:24:13 +00:00
|
|
|
FigureBoneData::new(torso_mat * head_mat),
|
2019-04-21 17:35:43 +00:00
|
|
|
FigureBoneData::new(torso_mat * chest_mat),
|
|
|
|
FigureBoneData::new(torso_mat * self.belt.compute_base_matrix()),
|
|
|
|
FigureBoneData::new(torso_mat * self.shorts.compute_base_matrix()),
|
2019-06-30 02:13:34 +00:00
|
|
|
FigureBoneData::new(torso_mat * chest_mat * l_hand_mat),
|
|
|
|
FigureBoneData::new(torso_mat * chest_mat * self.r_hand.compute_base_matrix()),
|
2019-04-21 17:35:43 +00:00
|
|
|
FigureBoneData::new(torso_mat * self.l_foot.compute_base_matrix()),
|
|
|
|
FigureBoneData::new(torso_mat * self.r_foot.compute_base_matrix()),
|
2019-05-22 05:11:31 +00:00
|
|
|
FigureBoneData::new(torso_mat * chest_mat * weapon_mat),
|
2019-05-13 00:52:30 +00:00
|
|
|
FigureBoneData::new(torso_mat * chest_mat * self.l_shoulder.compute_base_matrix()),
|
|
|
|
FigureBoneData::new(torso_mat * chest_mat * self.r_shoulder.compute_base_matrix()),
|
2019-05-22 05:11:31 +00:00
|
|
|
FigureBoneData::new(torso_mat * self.draw.compute_base_matrix()),
|
2019-05-16 04:40:35 +00:00
|
|
|
FigureBoneData::new(torso_mat),
|
2019-04-21 17:35:43 +00:00
|
|
|
FigureBoneData::default(),
|
2019-06-30 02:13:34 +00:00
|
|
|
FigureBoneData::default(),
|
|
|
|
FigureBoneData::default(),
|
2019-04-21 17:35:43 +00:00
|
|
|
]
|
|
|
|
}
|
2019-04-16 18:15:49 +00:00
|
|
|
|
2019-06-16 17:45:01 +00:00
|
|
|
fn interpolate(&mut self, target: &Self, dt: f32) {
|
|
|
|
self.head.interpolate(&target.head, dt);
|
|
|
|
self.chest.interpolate(&target.chest, dt);
|
|
|
|
self.belt.interpolate(&target.belt, dt);
|
|
|
|
self.shorts.interpolate(&target.shorts, dt);
|
|
|
|
self.l_hand.interpolate(&target.l_hand, dt);
|
|
|
|
self.r_hand.interpolate(&target.r_hand, dt);
|
|
|
|
self.l_foot.interpolate(&target.l_foot, dt);
|
|
|
|
self.r_foot.interpolate(&target.r_foot, dt);
|
|
|
|
self.weapon.interpolate(&target.weapon, dt);
|
|
|
|
self.l_shoulder.interpolate(&target.l_shoulder, dt);
|
|
|
|
self.r_shoulder.interpolate(&target.r_shoulder, dt);
|
|
|
|
self.draw.interpolate(&target.draw, dt);
|
|
|
|
self.torso.interpolate(&target.torso, dt);
|
2019-04-16 18:15:49 +00:00
|
|
|
}
|
2019-01-14 14:40:22 +00:00
|
|
|
}
|