veloren/voxygen/src/anim/character/mod.rs

67 lines
1.8 KiB
Rust
Raw Normal View History

2019-01-14 14:40:22 +00:00
pub mod run;
// Reexports
pub use self::run::RunAnimation;
// Crate
use crate::render::FigureBoneData;
// Local
use super::{
Skeleton,
Bone,
};
pub struct CharacterSkeleton {
head: Bone,
chest: Bone,
belt: Bone,
shorts: Bone,
l_hand: Bone,
r_hand: Bone,
2019-01-14 14:40:22 +00:00
l_foot: Bone,
r_foot: Bone,
back: Bone,
}
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(),
2019-01-14 14:40:22 +00:00
l_foot: Bone::default(),
r_foot: Bone::default(),
back: Bone::default(),
}
}
}
impl Skeleton for CharacterSkeleton {
fn compute_matrices(&self) -> [FigureBoneData; 16] {
let chest_mat = self.chest.compute_base_matrix();
[
FigureBoneData::new(self.head.compute_base_matrix()),
FigureBoneData::new(chest_mat),
FigureBoneData::new(self.belt.compute_base_matrix()),
FigureBoneData::new(self.shorts.compute_base_matrix()),
FigureBoneData::new(self.l_hand.compute_base_matrix()),
FigureBoneData::new(self.r_hand.compute_base_matrix()),
2019-01-14 14:40:22 +00:00
FigureBoneData::new(self.l_foot.compute_base_matrix()),
FigureBoneData::new(self.r_foot.compute_base_matrix()),
FigureBoneData::new(chest_mat * self.back.compute_base_matrix()),
FigureBoneData::default(),
FigureBoneData::default(),
FigureBoneData::default(),
FigureBoneData::default(),
FigureBoneData::default(),
FigureBoneData::default(),
FigureBoneData::default(),
]
}
}