2020-03-27 03:51:55 +00:00
|
|
|
pub mod alpha;
|
2020-03-27 05:57:30 +00:00
|
|
|
pub mod beta;
|
2019-08-25 16:48:12 +00:00
|
|
|
pub mod block;
|
2019-08-29 02:17:08 +00:00
|
|
|
pub mod blockidle;
|
2019-12-03 06:30:08 +00:00
|
|
|
pub mod charge;
|
2019-09-09 19:11:40 +00:00
|
|
|
pub mod climb;
|
2020-05-27 06:41:55 +00:00
|
|
|
pub mod dance;
|
2020-03-28 03:59:05 +00:00
|
|
|
pub mod dash;
|
2020-03-24 04:24:31 +00:00
|
|
|
pub mod equip;
|
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;
|
2020-03-20 22:54:27 +00:00
|
|
|
pub mod shoot;
|
2019-09-09 19:11:40 +00:00
|
|
|
pub mod sit;
|
2020-03-21 18:54:29 +00:00
|
|
|
pub mod spin;
|
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
|
2020-02-01 20:39:39 +00:00
|
|
|
pub use self::{
|
2020-03-27 05:57:30 +00:00
|
|
|
alpha::AlphaAnimation, beta::BetaAnimation, block::BlockAnimation,
|
|
|
|
blockidle::BlockIdleAnimation, charge::ChargeAnimation, climb::ClimbAnimation,
|
2020-05-27 06:41:55 +00:00
|
|
|
dance::DanceAnimation, dash::DashAnimation, equip::EquipAnimation, gliding::GlidingAnimation,
|
|
|
|
idle::IdleAnimation, jump::JumpAnimation, roll::RollAnimation, run::RunAnimation,
|
|
|
|
shoot::ShootAnimation, sit::SitAnimation, spin::SpinAnimation, stand::StandAnimation,
|
|
|
|
swim::SwimAnimation, wield::WieldAnimation,
|
2020-02-01 20:39:39 +00:00
|
|
|
};
|
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;
|
2020-04-27 05:11:34 +00:00
|
|
|
use common::comp;
|
2020-05-04 15:15:31 +00:00
|
|
|
use vek::{Vec3, Vec4};
|
2020-05-01 21:27:12 +00:00
|
|
|
|
2020-01-26 00:22:48 +00:00
|
|
|
#[derive(Clone, Default)]
|
2019-04-21 17:35:43 +00:00
|
|
|
pub struct CharacterSkeleton {
|
|
|
|
head: Bone,
|
|
|
|
chest: Bone,
|
|
|
|
belt: Bone,
|
2020-04-07 02:55:16 +00:00
|
|
|
back: Bone,
|
2019-04-21 17:35:43 +00:00
|
|
|
shorts: Bone,
|
|
|
|
l_hand: Bone,
|
|
|
|
r_hand: Bone,
|
|
|
|
l_foot: Bone,
|
|
|
|
r_foot: Bone,
|
|
|
|
l_shoulder: Bone,
|
|
|
|
r_shoulder: Bone,
|
2019-12-03 06:30:08 +00:00
|
|
|
glider: Bone,
|
2020-03-05 14:02:11 +00:00
|
|
|
main: Bone,
|
|
|
|
second: Bone,
|
2019-12-03 06:30:08 +00:00
|
|
|
lantern: Bone,
|
2020-05-27 06:41:55 +00:00
|
|
|
hold: Bone,
|
2019-05-16 04:40:35 +00:00
|
|
|
torso: Bone,
|
2020-03-05 14:02:11 +00:00
|
|
|
control: Bone,
|
|
|
|
l_control: Bone,
|
|
|
|
r_control: 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 {
|
2020-02-01 20:39:39 +00:00
|
|
|
pub fn new() -> Self { Self::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 {
|
2020-01-26 00:22:48 +00:00
|
|
|
type Attr = SkeletonAttr;
|
2020-02-01 20:39:39 +00:00
|
|
|
|
2020-04-25 14:38:17 +00:00
|
|
|
fn bone_count(&self) -> usize { 15 }
|
|
|
|
|
2020-05-04 15:15:31 +00:00
|
|
|
fn compute_matrices(&self) -> ([FigureBoneData; 16], Vec3<f32>) {
|
2019-04-21 17:35:43 +00:00
|
|
|
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();
|
2020-03-05 14:02:11 +00:00
|
|
|
let r_hand_mat = self.r_hand.compute_base_matrix();
|
|
|
|
let control_mat = self.control.compute_base_matrix();
|
|
|
|
let l_control_mat = self.l_control.compute_base_matrix();
|
|
|
|
let r_control_mat = self.r_control.compute_base_matrix();
|
2019-12-03 06:30:08 +00:00
|
|
|
let main_mat = self.main.compute_base_matrix();
|
2020-03-05 14:02:11 +00:00
|
|
|
let second_mat = self.second.compute_base_matrix();
|
2020-04-12 01:02:23 +00:00
|
|
|
let shorts_mat = self.shorts.compute_base_matrix();
|
2019-06-28 08:24:13 +00:00
|
|
|
let head_mat = self.head.compute_base_matrix();
|
2020-05-04 15:15:31 +00:00
|
|
|
|
|
|
|
let lantern_final_mat =
|
|
|
|
torso_mat * chest_mat * shorts_mat * self.lantern.compute_base_matrix();
|
|
|
|
|
|
|
|
(
|
|
|
|
[
|
|
|
|
FigureBoneData::new(torso_mat * chest_mat * head_mat),
|
|
|
|
FigureBoneData::new(torso_mat * chest_mat),
|
|
|
|
FigureBoneData::new(torso_mat * chest_mat * self.belt.compute_base_matrix()),
|
|
|
|
FigureBoneData::new(torso_mat * chest_mat * self.back.compute_base_matrix()),
|
|
|
|
FigureBoneData::new(torso_mat * chest_mat * shorts_mat),
|
|
|
|
FigureBoneData::new(
|
|
|
|
torso_mat * chest_mat * control_mat * l_control_mat * l_hand_mat,
|
|
|
|
),
|
|
|
|
FigureBoneData::new(
|
|
|
|
torso_mat * chest_mat * control_mat * r_control_mat * r_hand_mat,
|
|
|
|
),
|
|
|
|
FigureBoneData::new(torso_mat * self.l_foot.compute_base_matrix()),
|
|
|
|
FigureBoneData::new(torso_mat * self.r_foot.compute_base_matrix()),
|
|
|
|
FigureBoneData::new(torso_mat * chest_mat * self.l_shoulder.compute_base_matrix()),
|
|
|
|
FigureBoneData::new(torso_mat * chest_mat * self.r_shoulder.compute_base_matrix()),
|
|
|
|
FigureBoneData::new(torso_mat * self.glider.compute_base_matrix()),
|
|
|
|
FigureBoneData::new(torso_mat * chest_mat * control_mat * l_control_mat * main_mat),
|
|
|
|
FigureBoneData::new(
|
|
|
|
torso_mat * chest_mat * control_mat * r_control_mat * second_mat,
|
|
|
|
),
|
|
|
|
FigureBoneData::new(lantern_final_mat),
|
2020-05-27 06:41:55 +00:00
|
|
|
FigureBoneData::new(
|
|
|
|
torso_mat * chest_mat * l_hand_mat * self.hold.compute_base_matrix(),
|
|
|
|
),
|
2020-05-04 15:15:31 +00:00
|
|
|
],
|
|
|
|
(lantern_final_mat * Vec4::new(0.0, 0.0, 0.0, 1.0)).xyz(),
|
|
|
|
)
|
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);
|
2020-04-07 02:55:16 +00:00
|
|
|
self.back.interpolate(&target.back, dt);
|
2019-06-16 17:45:01 +00:00
|
|
|
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.l_shoulder.interpolate(&target.l_shoulder, dt);
|
|
|
|
self.r_shoulder.interpolate(&target.r_shoulder, dt);
|
2019-12-03 06:30:08 +00:00
|
|
|
self.glider.interpolate(&target.glider, dt);
|
2020-03-05 14:02:11 +00:00
|
|
|
self.main.interpolate(&target.main, dt);
|
|
|
|
self.second.interpolate(&target.second, dt);
|
2019-12-03 06:30:08 +00:00
|
|
|
self.lantern.interpolate(&target.lantern, dt);
|
2020-05-27 06:41:55 +00:00
|
|
|
self.hold.interpolate(&target.hold, dt);
|
2019-06-16 17:45:01 +00:00
|
|
|
self.torso.interpolate(&target.torso, dt);
|
2020-03-05 14:02:11 +00:00
|
|
|
self.control.interpolate(&target.control, dt);
|
|
|
|
self.l_control.interpolate(&target.l_control, dt);
|
|
|
|
self.r_control.interpolate(&target.r_control, dt);
|
2019-04-16 18:15:49 +00:00
|
|
|
}
|
2019-01-14 14:40:22 +00:00
|
|
|
}
|
2020-01-26 00:22:48 +00:00
|
|
|
|
|
|
|
pub struct SkeletonAttr {
|
|
|
|
scaler: f32,
|
|
|
|
head_scale: f32,
|
2020-04-27 05:11:34 +00:00
|
|
|
head: (f32, f32),
|
|
|
|
chest: (f32, f32),
|
|
|
|
belt: (f32, f32),
|
|
|
|
back: (f32, f32),
|
|
|
|
shorts: (f32, f32),
|
|
|
|
hand: (f32, f32, f32),
|
|
|
|
foot: (f32, f32, f32),
|
|
|
|
shoulder: (f32, f32, f32),
|
|
|
|
lantern: (f32, f32, f32),
|
2020-01-26 00:22:48 +00:00
|
|
|
}
|
2020-04-27 05:11:34 +00:00
|
|
|
|
|
|
|
impl Default for SkeletonAttr {
|
|
|
|
fn default() -> Self {
|
|
|
|
Self {
|
|
|
|
scaler: 0.0,
|
|
|
|
head_scale: 0.0,
|
|
|
|
head: (0.0, 0.0),
|
|
|
|
chest: (0.0, 0.0),
|
|
|
|
belt: (0.0, 0.0),
|
|
|
|
back: (0.0, 0.0),
|
|
|
|
shorts: (0.0, 0.0),
|
|
|
|
hand: (0.0, 0.0, 0.0),
|
|
|
|
foot: (0.0, 0.0, 0.0),
|
|
|
|
shoulder: (0.0, 0.0, 0.0),
|
|
|
|
lantern: (0.0, 0.0, 0.0),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
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::Humanoid(body) => Ok(SkeletonAttr::from(body)),
|
|
|
|
_ => Err(()),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-01-26 00:22:48 +00:00
|
|
|
impl SkeletonAttr {
|
|
|
|
pub fn calculate_scale(body: &comp::humanoid::Body) -> f32 {
|
|
|
|
use comp::humanoid::{BodyType::*, Race::*};
|
|
|
|
match (body.race, body.body_type) {
|
2020-05-01 21:27:12 +00:00
|
|
|
(Orc, Male) => 1.14,
|
|
|
|
(Orc, Female) => 1.02,
|
|
|
|
(Human, Male) => 1.02,
|
|
|
|
(Human, Female) => 0.96,
|
|
|
|
(Elf, Male) => 1.02,
|
|
|
|
(Elf, Female) => 0.96,
|
|
|
|
(Dwarf, Male) => 0.84,
|
|
|
|
(Dwarf, Female) => 0.78,
|
|
|
|
(Undead, Male) => 0.96,
|
|
|
|
(Undead, Female) => 0.9,
|
|
|
|
(Danari, Male) => 0.696,
|
|
|
|
(Danari, Female) => 0.696,
|
2020-01-26 00:22:48 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl<'a> From<&'a comp::humanoid::Body> for SkeletonAttr {
|
|
|
|
fn from(body: &'a comp::humanoid::Body) -> Self {
|
|
|
|
use comp::humanoid::{BodyType::*, Race::*};
|
|
|
|
Self {
|
|
|
|
scaler: SkeletonAttr::calculate_scale(body),
|
|
|
|
head_scale: match (body.race, body.body_type) {
|
|
|
|
(Orc, Male) => 0.9,
|
|
|
|
(Orc, Female) => 1.0,
|
2020-04-30 20:43:24 +00:00
|
|
|
(Human, Male) => 0.9,
|
|
|
|
(Human, Female) => 0.9,
|
|
|
|
(Elf, Male) => 0.9,
|
|
|
|
(Elf, Female) => 0.9,
|
2020-01-26 00:22:48 +00:00
|
|
|
(Dwarf, Male) => 1.0,
|
|
|
|
(Dwarf, Female) => 1.0,
|
2020-04-30 20:43:24 +00:00
|
|
|
(Undead, Male) => 0.9,
|
|
|
|
(Undead, Female) => 0.9,
|
2020-01-26 00:22:48 +00:00
|
|
|
(Danari, Male) => 1.15,
|
|
|
|
(Danari, Female) => 1.15,
|
|
|
|
},
|
2020-04-27 05:11:34 +00:00
|
|
|
head: match (body.race, body.body_type) {
|
2020-05-27 06:41:55 +00:00
|
|
|
(Orc, Male) => (0.0, 13.5),
|
|
|
|
(Orc, Female) => (0.0, 13.0),
|
|
|
|
(Human, Male) => (0.3, 13.0),
|
|
|
|
(Human, Female) => (0.0, 13.5),
|
|
|
|
(Elf, Male) => (0.5, 13.0),
|
|
|
|
(Elf, Female) => (1.0, 13.0),
|
|
|
|
(Dwarf, Male) => (0.0, 14.0),
|
|
|
|
(Dwarf, Female) => (0.0, 13.5),
|
|
|
|
(Undead, Male) => (0.5, 13.0),
|
|
|
|
(Undead, Female) => (0.5, 14.0),
|
|
|
|
(Danari, Male) => (0.5, 12.5),
|
|
|
|
(Danari, Female) => (0.5, 13.5),
|
2020-04-27 05:11:34 +00:00
|
|
|
},
|
|
|
|
chest: match (body.race, body.body_type) {
|
|
|
|
(_, _) => (0.0, 7.0),
|
|
|
|
},
|
|
|
|
belt: match (body.race, body.body_type) {
|
|
|
|
(_, _) => (0.0, -2.0),
|
|
|
|
},
|
|
|
|
back: match (body.race, body.body_type) {
|
|
|
|
(_, _) => (-3.1, 7.25),
|
|
|
|
},
|
|
|
|
shorts: match (body.race, body.body_type) {
|
|
|
|
(_, _) => (0.0, -5.0),
|
2020-01-26 00:22:48 +00:00
|
|
|
},
|
2020-04-27 05:11:34 +00:00
|
|
|
hand: match (body.race, body.body_type) {
|
2020-05-27 06:41:55 +00:00
|
|
|
(_, _) => (7.0, -0.25, 0.5),
|
2020-01-26 00:22:48 +00:00
|
|
|
},
|
2020-04-27 05:11:34 +00:00
|
|
|
foot: match (body.race, body.body_type) {
|
2020-05-27 06:41:55 +00:00
|
|
|
(_, _) => (3.4, 0.5, 1.0),
|
2020-01-26 00:22:48 +00:00
|
|
|
},
|
2020-04-27 05:11:34 +00:00
|
|
|
shoulder: match (body.race, body.body_type) {
|
|
|
|
(_, _) => (5.0, 0.0, 5.0),
|
2020-01-26 00:22:48 +00:00
|
|
|
},
|
2020-04-27 05:11:34 +00:00
|
|
|
lantern: match (body.race, body.body_type) {
|
|
|
|
(_, _) => (5.0, 2.5, 5.5),
|
2020-01-26 00:22:48 +00:00
|
|
|
},
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|