initial cape implementation

This commit is contained in:
jshipsey 2020-04-06 22:55:16 -04:00 committed by Pfauenauge90
parent fa03f9ddb9
commit ea2c646df3
20 changed files with 96 additions and 78 deletions

Binary file not shown.

View File

@ -5,7 +5,7 @@
),
map: {
Short0: (
vox_spec: ("armor.back.short-0", (10.0, 10.0, 10.0)),
vox_spec: ("armor.back.short-0", (-5.0, -1.0, -11.0)),
color: None
),
},

View File

@ -47,7 +47,7 @@ impl BipedLargeSkeleton {
impl Skeleton for BipedLargeSkeleton {
type Attr = SkeletonAttr;
fn compute_matrices(&self) -> [FigureBoneData; 18] {
fn compute_matrices(&self) -> [FigureBoneData; 19] {
let upper_torso_mat = self.upper_torso.compute_base_matrix();
let shoulder_l_mat = self.shoulder_l.compute_base_matrix();
let shoulder_r_mat = self.shoulder_r.compute_base_matrix();
@ -80,6 +80,7 @@ impl Skeleton for BipedLargeSkeleton {
FigureBoneData::default(),
FigureBoneData::default(),
FigureBoneData::default(),
FigureBoneData::default(),
]
}

View File

@ -27,7 +27,7 @@ impl BirdMediumSkeleton {
impl Skeleton for BirdMediumSkeleton {
type Attr = SkeletonAttr;
fn compute_matrices(&self) -> [FigureBoneData; 18] {
fn compute_matrices(&self) -> [FigureBoneData; 19] {
let torso_mat = self.torso.compute_base_matrix();
[
@ -49,6 +49,7 @@ impl Skeleton for BirdMediumSkeleton {
FigureBoneData::default(),
FigureBoneData::default(),
FigureBoneData::default(),
FigureBoneData::default(),
]
}

View File

@ -31,7 +31,7 @@ impl BirdSmallSkeleton {
impl Skeleton for BirdSmallSkeleton {
type Attr = SkeletonAttr;
fn compute_matrices(&self) -> [FigureBoneData; 18] {
fn compute_matrices(&self) -> [FigureBoneData; 19] {
let torso_mat = self.torso.compute_base_matrix();
[
@ -53,6 +53,7 @@ impl Skeleton for BirdSmallSkeleton {
FigureBoneData::default(),
FigureBoneData::default(),
FigureBoneData::default(),
FigureBoneData::default(),
]
}

View File

@ -36,6 +36,10 @@ impl Animation for JumpAnimation {
next.belt.ori = Quaternion::rotation_z(0.0);
next.belt.scale = Vec3::one();
next.back.offset = Vec3::new(0.0, -2.8, 7.25);
next.back.ori = Quaternion::rotation_z(0.0);
next.back.scale = Vec3::one() * 1.02;
next.shorts.offset = Vec3::new(0.0, 0.0, -5.0);
next.shorts.ori = Quaternion::rotation_z(0.0);
next.shorts.scale = Vec3::one();

View File

@ -37,6 +37,7 @@ pub struct CharacterSkeleton {
head: Bone,
chest: Bone,
belt: Bone,
back: Bone,
shorts: Bone,
l_hand: Bone,
r_hand: Bone,
@ -61,7 +62,7 @@ impl CharacterSkeleton {
impl Skeleton for CharacterSkeleton {
type Attr = SkeletonAttr;
fn compute_matrices(&self) -> [FigureBoneData; 18] {
fn compute_matrices(&self) -> [FigureBoneData; 19] {
let chest_mat = self.chest.compute_base_matrix();
let torso_mat = self.torso.compute_base_matrix();
let l_hand_mat = self.l_hand.compute_base_matrix();
@ -77,6 +78,7 @@ impl Skeleton for CharacterSkeleton {
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 * self.shorts.compute_base_matrix()),
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),
@ -99,6 +101,7 @@ impl Skeleton for CharacterSkeleton {
self.head.interpolate(&target.head, dt);
self.chest.interpolate(&target.chest, dt);
self.belt.interpolate(&target.belt, dt);
self.back.interpolate(&target.back, dt);
self.shorts.interpolate(&target.shorts, dt);
self.l_hand.interpolate(&target.l_hand, dt);
self.r_hand.interpolate(&target.r_hand, dt);

View File

@ -90,6 +90,10 @@ impl Animation for RunAnimation {
next.belt.ori = Quaternion::rotation_z(short * 0.25);
next.belt.scale = Vec3::one();
next.back.offset = Vec3::new(0.0, -2.8, 7.25);
next.back.ori = Quaternion::rotation_z(0.0);
next.back.scale = Vec3::one() * 1.02;
next.shorts.offset = Vec3::new(0.0, 0.0, -5.0);
next.shorts.ori = Quaternion::rotation_z(short * 0.4);
next.shorts.scale = Vec3::one();

View File

@ -50,6 +50,10 @@ impl Animation for StandAnimation {
next.belt.ori = Quaternion::rotation_z(head_look.x * -0.1);
next.belt.scale = Vec3::one() + breathe * -0.05;
next.back.offset = Vec3::new(0.0, -2.8, 7.25);
next.back.ori = Quaternion::rotation_z(0.0);
next.back.scale = Vec3::one() * 1.02;
next.shorts.offset = Vec3::new(0.0, 0.0, -5.0); //2
next.shorts.ori = Quaternion::rotation_x(head_look.x * -0.2);
next.shorts.scale = Vec3::one() + breathe * -0.05;
@ -101,7 +105,7 @@ impl Animation for StandAnimation {
next.lantern.offset = Vec3::new(0.0, 0.0, 0.0);
next.lantern.ori = Quaternion::rotation_x(0.0);
next.lantern.scale = Vec3::one() * 0.0;
next.lantern.scale = Vec3::one() * 5.0;
next.torso.offset = Vec3::new(0.0, -0.1, 0.1) * skeleton_attr.scaler;
next.torso.ori = Quaternion::rotation_x(0.0);

View File

@ -32,7 +32,7 @@ impl CritterSkeleton {
impl Skeleton for CritterSkeleton {
type Attr = CritterAttr;
fn compute_matrices(&self) -> [FigureBoneData; 18] {
fn compute_matrices(&self) -> [FigureBoneData; 19] {
[
FigureBoneData::new(self.head.compute_base_matrix()),
FigureBoneData::new(self.chest.compute_base_matrix()),
@ -52,6 +52,7 @@ impl Skeleton for CritterSkeleton {
FigureBoneData::default(),
FigureBoneData::default(),
FigureBoneData::default(),
FigureBoneData::default(),
]
}

View File

@ -49,7 +49,7 @@ impl DragonSkeleton {
impl Skeleton for DragonSkeleton {
type Attr = SkeletonAttr;
fn compute_matrices(&self) -> [FigureBoneData; 18] {
fn compute_matrices(&self) -> [FigureBoneData; 19] {
let chest_front_mat = self.chest_front.compute_base_matrix();
let wing_in_l_mat = self.wing_in_l.compute_base_matrix();
let wing_in_r_mat = self.wing_in_r.compute_base_matrix();
@ -74,6 +74,7 @@ impl Skeleton for DragonSkeleton {
FigureBoneData::default(),
FigureBoneData::default(),
FigureBoneData::default(),
FigureBoneData::default(),
]
}

View File

@ -35,7 +35,7 @@ impl FishMediumSkeleton {
impl Skeleton for FishMediumSkeleton {
type Attr = SkeletonAttr;
fn compute_matrices(&self) -> [FigureBoneData; 18] {
fn compute_matrices(&self) -> [FigureBoneData; 19] {
let torso_mat = self.torso.compute_base_matrix();
let rear_mat = self.rear.compute_base_matrix();
@ -58,6 +58,7 @@ impl Skeleton for FishMediumSkeleton {
FigureBoneData::default(),
FigureBoneData::default(),
FigureBoneData::default(),
FigureBoneData::default(),
]
}

View File

@ -27,7 +27,7 @@ impl FishSmallSkeleton {
impl Skeleton for FishSmallSkeleton {
type Attr = SkeletonAttr;
fn compute_matrices(&self) -> [FigureBoneData; 18] {
fn compute_matrices(&self) -> [FigureBoneData; 19] {
let torso_mat = self.torso.compute_base_matrix();
[
@ -49,6 +49,7 @@ impl Skeleton for FishSmallSkeleton {
FigureBoneData::default(),
FigureBoneData::default(),
FigureBoneData::default(),
FigureBoneData::default(),
]
}

View File

@ -13,7 +13,7 @@ impl FixtureSkeleton {
impl Skeleton for FixtureSkeleton {
type Attr = SkeletonAttr;
fn compute_matrices(&self) -> [FigureBoneData; 18] {
fn compute_matrices(&self) -> [FigureBoneData; 19] {
[
FigureBoneData::new(vek::Mat4::identity()),
FigureBoneData::new(vek::Mat4::identity()),
@ -33,6 +33,7 @@ impl Skeleton for FixtureSkeleton {
FigureBoneData::new(vek::Mat4::identity()),
FigureBoneData::new(vek::Mat4::identity()),
FigureBoneData::new(vek::Mat4::identity()),
FigureBoneData::new(vek::Mat4::identity()),
]
}

View File

@ -52,7 +52,7 @@ impl Bone {
pub trait Skeleton: Send + Sync + 'static {
type Attr;
fn compute_matrices(&self) -> [FigureBoneData; 18];
fn compute_matrices(&self) -> [FigureBoneData; 19];
/// Change the current skeleton to be more like `target`.
fn interpolate(&mut self, target: &Self, dt: f32);

View File

@ -15,7 +15,7 @@ const SCALE: f32 = 1.0 / 11.0;
impl Skeleton for ObjectSkeleton {
type Attr = SkeletonAttr;
fn compute_matrices(&self) -> [FigureBoneData; 18] {
fn compute_matrices(&self) -> [FigureBoneData; 19] {
[
FigureBoneData::new(Mat4::scaling_3d(Vec3::broadcast(SCALE))),
FigureBoneData::new(Mat4::scaling_3d(Vec3::broadcast(SCALE))),
@ -35,6 +35,7 @@ impl Skeleton for ObjectSkeleton {
FigureBoneData::new(Mat4::scaling_3d(Vec3::broadcast(SCALE))),
FigureBoneData::new(Mat4::scaling_3d(Vec3::broadcast(SCALE))),
FigureBoneData::new(Mat4::scaling_3d(Vec3::broadcast(SCALE))),
FigureBoneData::new(Mat4::scaling_3d(Vec3::broadcast(SCALE))),
]
}

View File

@ -31,7 +31,7 @@ impl QuadrupedMediumSkeleton {
impl Skeleton for QuadrupedMediumSkeleton {
type Attr = SkeletonAttr;
fn compute_matrices(&self) -> [FigureBoneData; 18] {
fn compute_matrices(&self) -> [FigureBoneData; 19] {
let ears_mat = self.ears.compute_base_matrix();
let head_upper_mat = self.head_upper.compute_base_matrix();
let head_lower_mat = self.head_lower.compute_base_matrix();
@ -55,6 +55,7 @@ impl Skeleton for QuadrupedMediumSkeleton {
FigureBoneData::default(),
FigureBoneData::default(),
FigureBoneData::default(),
FigureBoneData::default(),
]
}

View File

@ -26,7 +26,7 @@ impl QuadrupedSmallSkeleton {
impl Skeleton for QuadrupedSmallSkeleton {
type Attr = SkeletonAttr;
fn compute_matrices(&self) -> [FigureBoneData; 18] {
fn compute_matrices(&self) -> [FigureBoneData; 19] {
[
FigureBoneData::new(self.head.compute_base_matrix()),
FigureBoneData::new(self.chest.compute_base_matrix()),
@ -46,6 +46,7 @@ impl Skeleton for QuadrupedSmallSkeleton {
FigureBoneData::default(),
FigureBoneData::default(),
FigureBoneData::default(),
FigureBoneData::default(),
]
}

View File

@ -30,6 +30,7 @@ struct CharacterCacheKey {
shoulder: Option<Item>,
chest: Option<Item>,
belt: Option<Item>,
back: Option<Item>,
hand: Option<Item>,
pants: Option<Item>,
foot: Option<Item>,
@ -49,6 +50,7 @@ impl CharacterCacheKey {
shoulder: loadout.shoulder.clone(),
chest: loadout.chest.clone(),
belt: loadout.belt.clone(),
back: loadout.back.clone(),
hand: loadout.hand.clone(),
pants: loadout.pants.clone(),
foot: loadout.foot.clone(),
@ -118,6 +120,8 @@ impl<Skel: Skeleton> FigureModelCache<Skel> {
HumArmorHandSpec::load_watched(&mut self.manifest_indicator);
let humanoid_armor_belt_spec =
HumArmorBeltSpec::load_watched(&mut self.manifest_indicator);
let humanoid_armor_back_spec =
HumArmorBackSpec::load_watched(&mut self.manifest_indicator);
let humanoid_armor_pants_spec =
HumArmorPantsSpec::load_watched(&mut self.manifest_indicator);
let humanoid_armor_foot_spec =
@ -158,6 +162,12 @@ impl<Skel: Skeleton> FigureModelCache<Skel> {
},
CameraMode::FirstPerson => None,
},
match camera_mode {
CameraMode::ThirdPerson => {
Some(humanoid_armor_back_spec.mesh_back(&body, loadout))
},
CameraMode::FirstPerson => None,
},
match camera_mode {
CameraMode::ThirdPerson => Some(
humanoid_armor_pants_spec.mesh_pants(&body, loadout),
@ -227,7 +237,6 @@ impl<Skel: Skeleton> FigureModelCache<Skel> {
Some(mesh_lantern()),
None,
None,
None,
]
},
Body::QuadrupedSmall(body) => {

View File

@ -251,14 +251,14 @@ pub struct HumArmorHandSpec(ArmorVoxSpecMap<Hand, SidedArmorVoxSpec>);
#[derive(Serialize, Deserialize)]
pub struct HumArmorBeltSpec(ArmorVoxSpecMap<Belt, ArmorVoxSpec>);
#[derive(Serialize, Deserialize)]
pub struct HumArmorBackSpec(ArmorVoxSpecMap<Back, ArmorVoxSpec>);
#[derive(Serialize, Deserialize)]
pub struct HumArmorPantsSpec(ArmorVoxSpecMap<Pants, ArmorVoxSpec>);
#[derive(Serialize, Deserialize)]
pub struct HumArmorFootSpec(ArmorVoxSpecMap<Foot, ArmorVoxSpec>);
#[derive(Serialize, Deserialize)]
pub struct HumMainWeaponSpec(HashMap<ToolKind, ArmorVoxSpec>);
#[derive(Serialize, Deserialize)]
pub struct HumArmorBackSpec(ArmorVoxSpecMap<Back, ArmorVoxSpec>);
#[derive(Serialize, Deserialize)]
pub struct HumArmorLanternSpec(ArmorVoxSpecMap<Lantern, ArmorVoxSpec>);
#[derive(Serialize, Deserialize)]
pub struct HumArmorHeadSpec(ArmorVoxSpecMap<Head, ArmorVoxSpec>);
@ -293,6 +293,13 @@ impl Asset for HumArmorBeltSpec {
ron::de::from_reader(buf_reader).map_err(assets::Error::parse_error)
}
}
impl Asset for HumArmorBackSpec {
const ENDINGS: &'static [&'static str] = &["ron"];
fn parse(buf_reader: BufReader<File>) -> Result<Self, assets::Error> {
ron::de::from_reader(buf_reader).map_err(assets::Error::parse_error)
}
}
impl Asset for HumArmorPantsSpec {
const ENDINGS: &'static [&'static str] = &["ron"];
@ -307,13 +314,6 @@ impl Asset for HumArmorFootSpec {
ron::de::from_reader(buf_reader).map_err(assets::Error::parse_error)
}
}
impl Asset for HumArmorBackSpec {
const ENDINGS: &'static [&'static str] = &["ron"];
fn parse(buf_reader: BufReader<File>) -> Result<Self, assets::Error> {
ron::de::from_reader(buf_reader).map_err(assets::Error::parse_error)
}
}
impl Asset for HumArmorLanternSpec {
const ENDINGS: &'static [&'static str] = &["ron"];
@ -536,6 +536,40 @@ impl HumArmorBeltSpec {
generate_mesh(&belt_segment, Vec3::from(spec.vox_spec.1))
}
}
// Cape
impl HumArmorBackSpec {
pub fn load_watched(indicator: &mut ReloadIndicator) -> Arc<Self> {
assets::load_watched::<Self>("voxygen.voxel.humanoid_armor_back_manifest", indicator)
.unwrap()
}
pub fn mesh_back(&self, body: &Body, loadout: &Loadout) -> Mesh<FigurePipeline> {
let spec = if let Some(ItemKind::Armor {
kind: Armor::Back(back),
..
}) = loadout.back.as_ref().map(|i| &i.kind)
{
match self.0.map.get(&back) {
Some(spec) => spec,
None => {
error!("No back specification exists for {:?}", back);
return load_mesh("not_found", Vec3::new(-4.0, -3.5, 2.0));
},
}
} else {
&self.0.default
};
let back_segment = color_segment(
graceful_load_mat_segment(&spec.vox_spec.0),
body.race.skin_color(body.skin),
body.race.hair_color(body.hair_color),
body.race.eye_color(body.eye_color),
);
generate_mesh(&back_segment, Vec3::from(spec.vox_spec.1))
}
}
// Legs
impl HumArmorPantsSpec {
pub fn load_watched(indicator: &mut ReloadIndicator) -> Arc<Self> {
@ -659,57 +693,6 @@ impl HumMainWeaponSpec {
generate_mesh(&tool_kind_segment, Vec3::from(spec.vox_spec.1))
}
}
// Back
impl HumArmorBackSpec {
pub fn load_watched(indicator: &mut ReloadIndicator) -> Arc<Self> {
assets::load_watched::<Self>("voxygen.voxel.humanoid_armor_back_manifest", indicator)
.unwrap()
}
pub fn mesh_back(&self, body: &Body, loadout: &Loadout) -> Mesh<FigurePipeline> {
let spec = if let Some(ItemKind::Armor {
kind: Armor::Back(back),
..
}) = loadout.back.as_ref().map(|i| &i.kind)
{
match self.0.map.get(&back) {
Some(spec) => spec,
None => {
error!("No back-armor specification exists for {:?}", back);
return load_mesh("not_found", Vec3::new(-5.0, -3.5, 1.0));
},
}
} else {
&self.0.default
};
let color = |mat_segment| {
color_segment(
mat_segment,
body.race.skin_color(body.skin),
body.race.hair_color(body.hair_color),
body.race.eye_color(body.eye_color),
)
};
let bare_back = graceful_load_mat_segment("armor.empty");
let mut back_armor = graceful_load_mat_segment(&spec.vox_spec.0);
if let Some(color) = spec.color {
let back_color = Vec3::from(color);
back_armor = back_armor.map_rgb(|rgb| recolor_grey(rgb, Rgb::from(back_color)));
}
let back = DynaUnionizer::new()
.add(color(bare_back), Vec3::new(0, 0, 0))
.add(color(back_armor), Vec3::new(0, 0, 0))
.unify()
.0;
generate_mesh(&back, Vec3::from(spec.vox_spec.1))
}
}
// Lantern
impl HumArmorLanternSpec {
pub fn load_watched(indicator: &mut ReloadIndicator) -> Arc<Self> {