diff --git a/voxygen/src/anim/quadruped_small/idle.rs b/voxygen/src/anim/quadruped_small/idle.rs index 96f8754855..a8410db858 100644 --- a/voxygen/src/anim/quadruped_small/idle.rs +++ b/voxygen/src/anim/quadruped_small/idle.rs @@ -37,30 +37,30 @@ impl Animation for IdleAnimation { * 0.25, ); - next.pig_head.offset = Vec3::new(0.0, -2.0, -1.5 + wave * 0.2) / 11.0; - next.pig_head.ori = Quaternion::rotation_z(pig_head_look.x) + next.head.offset = Vec3::new(0.0, -2.0, -1.5 + wave * 0.2) / 11.0; + next.head.ori = Quaternion::rotation_z(pig_head_look.x) * Quaternion::rotation_x(pig_head_look.y + wave_slow_cos * 0.03); - next.pig_head.scale = Vec3::one() / 10.5; + next.head.scale = Vec3::one() / 10.5; - next.pig_chest.offset = Vec3::new(wave_slow * 0.05, -9.0, 1.5 + wave_slow_cos * 0.4) / 11.0; - next.pig_chest.ori = Quaternion::rotation_y(wave_slow * 0.05); - next.pig_chest.scale = Vec3::one() / 11.0; + next.chest.offset = Vec3::new(wave_slow * 0.05, -9.0, 1.5 + wave_slow_cos * 0.4) / 11.0; + next.chest.ori = Quaternion::rotation_y(wave_slow * 0.05); + next.chest.scale = Vec3::one() / 11.0; - next.pig_leg_lf.offset = Vec3::new(-4.5, 2.0, 1.5) / 11.0; - next.pig_leg_lf.ori = Quaternion::rotation_x(wave_slow * 0.08); - next.pig_leg_lf.scale = Vec3::one() / 11.0; + next.leg_lf.offset = Vec3::new(-4.5, 2.0, 1.5) / 11.0; + next.leg_lf.ori = Quaternion::rotation_x(wave_slow * 0.08); + next.leg_lf.scale = Vec3::one() / 11.0; - next.pig_leg_rf.offset = Vec3::new(2.5, 2.0, 1.5) / 11.0; - next.pig_leg_rf.ori = Quaternion::rotation_x(wave_slow_cos * 0.08); - next.pig_leg_rf.scale = Vec3::one() / 11.0; + next.leg_rf.offset = Vec3::new(2.5, 2.0, 1.5) / 11.0; + next.leg_rf.ori = Quaternion::rotation_x(wave_slow_cos * 0.08); + next.leg_rf.scale = Vec3::one() / 11.0; - next.pig_leg_lb.offset = Vec3::new(-4.5, -3.0, 1.5) / 11.0; - next.pig_leg_lb.ori = Quaternion::rotation_x(wave_slow_cos * 0.08); - next.pig_leg_lb.scale = Vec3::one() / 11.0; + next.leg_lb.offset = Vec3::new(-4.5, -3.0, 1.5) / 11.0; + next.leg_lb.ori = Quaternion::rotation_x(wave_slow_cos * 0.08); + next.leg_lb.scale = Vec3::one() / 11.0; - next.pig_leg_rb.offset = Vec3::new(2.5, -3.0, 1.5) / 11.0; - next.pig_leg_rb.ori = Quaternion::rotation_x(wave_slow * 0.08); - next.pig_leg_rb.scale = Vec3::one() / 11.0; + next.leg_rb.offset = Vec3::new(2.5, -3.0, 1.5) / 11.0; + next.leg_rb.ori = Quaternion::rotation_x(wave_slow * 0.08); + next.leg_rb.scale = Vec3::one() / 11.0; next } diff --git a/voxygen/src/anim/quadruped_small/jump.rs b/voxygen/src/anim/quadruped_small/jump.rs index 62e287ef0e..11d38973b4 100644 --- a/voxygen/src/anim/quadruped_small/jump.rs +++ b/voxygen/src/anim/quadruped_small/jump.rs @@ -23,29 +23,29 @@ impl Animation for JumpAnimation { let wave_slow = (anim_time as f32 * 7.0 + PI).sin(); let wave_stop = (anim_time as f32 * 4.5).min(PI / 2.0).sin(); - next.pig_head.offset = Vec3::new(0.0, 0.0, -1.5) / 11.0; - next.pig_head.ori = Quaternion::rotation_x(wave_stop * 0.4); - next.pig_head.scale = Vec3::one() / 10.5; + next.head.offset = Vec3::new(0.0, 0.0, -1.5) / 11.0; + next.head.ori = Quaternion::rotation_x(wave_stop * 0.4); + next.head.scale = Vec3::one() / 10.5; - next.pig_chest.offset = Vec3::new(0.0, -9.0, 1.5) / 11.0; - next.pig_chest.ori = Quaternion::rotation_x(0.0); - next.pig_chest.scale = Vec3::one() / 11.0; + next.chest.offset = Vec3::new(0.0, -9.0, 1.5) / 11.0; + next.chest.ori = Quaternion::rotation_x(0.0); + next.chest.scale = Vec3::one() / 11.0; - next.pig_leg_lf.offset = Vec3::new(-4.5, 3.0, 1.5) / 11.0; - next.pig_leg_lf.ori = Quaternion::rotation_x(wave_stop * 0.6 - wave_slow * 0.3); - next.pig_leg_lf.scale = Vec3::one() / 11.0; + next.leg_lf.offset = Vec3::new(-4.5, 3.0, 1.5) / 11.0; + next.leg_lf.ori = Quaternion::rotation_x(wave_stop * 0.6 - wave_slow * 0.3); + next.leg_lf.scale = Vec3::one() / 11.0; - next.pig_leg_rf.offset = Vec3::new(2.5, 3.0, 1.5) / 11.0; - next.pig_leg_rf.ori = Quaternion::rotation_x(wave_stop * 0.6 - wave_slow * 0.3); - next.pig_leg_rf.scale = Vec3::one() / 11.0; + next.leg_rf.offset = Vec3::new(2.5, 3.0, 1.5) / 11.0; + next.leg_rf.ori = Quaternion::rotation_x(wave_stop * 0.6 - wave_slow * 0.3); + next.leg_rf.scale = Vec3::one() / 11.0; - next.pig_leg_lb.offset = Vec3::new(-4.5, -4.0, 2.0) / 11.0; - next.pig_leg_lb.ori = Quaternion::rotation_x(wave_stop * -0.6 + wave_slow * 0.3); - next.pig_leg_lb.scale = Vec3::one() / 11.0; + next.leg_lb.offset = Vec3::new(-4.5, -4.0, 2.0) / 11.0; + next.leg_lb.ori = Quaternion::rotation_x(wave_stop * -0.6 + wave_slow * 0.3); + next.leg_lb.scale = Vec3::one() / 11.0; - next.pig_leg_rb.offset = Vec3::new(2.5, -4.0, 2.0) / 11.0; - next.pig_leg_rb.ori = Quaternion::rotation_x(wave_stop * -0.6 + wave_slow * 0.3); - next.pig_leg_rb.scale = Vec3::one() / 11.0; + next.leg_rb.offset = Vec3::new(2.5, -4.0, 2.0) / 11.0; + next.leg_rb.ori = Quaternion::rotation_x(wave_stop * -0.6 + wave_slow * 0.3); + next.leg_rb.scale = Vec3::one() / 11.0; next } diff --git a/voxygen/src/anim/quadruped_small/mod.rs b/voxygen/src/anim/quadruped_small/mod.rs index 5f3c7e64b3..600bb9d2ba 100644 --- a/voxygen/src/anim/quadruped_small/mod.rs +++ b/voxygen/src/anim/quadruped_small/mod.rs @@ -12,23 +12,23 @@ use crate::render::FigureBoneData; #[derive(Clone)] pub struct QuadrupedSmallSkeleton { - pig_head: Bone, - pig_chest: Bone, - pig_leg_lf: Bone, - pig_leg_rf: Bone, - pig_leg_lb: Bone, - pig_leg_rb: Bone, + head: Bone, + chest: Bone, + leg_lf: Bone, + leg_rf: Bone, + leg_lb: Bone, + leg_rb: Bone, } impl QuadrupedSmallSkeleton { pub fn new() -> Self { Self { - pig_head: Bone::default(), - pig_chest: Bone::default(), - pig_leg_lf: Bone::default(), - pig_leg_rf: Bone::default(), - pig_leg_lb: Bone::default(), - pig_leg_rb: Bone::default(), + head: Bone::default(), + chest: Bone::default(), + leg_lf: Bone::default(), + leg_rf: Bone::default(), + leg_lb: Bone::default(), + leg_rb: Bone::default(), } } } @@ -36,12 +36,12 @@ impl QuadrupedSmallSkeleton { impl Skeleton for QuadrupedSmallSkeleton { fn compute_matrices(&self) -> [FigureBoneData; 16] { [ - FigureBoneData::new(self.pig_head.compute_base_matrix()), - FigureBoneData::new(self.pig_chest.compute_base_matrix()), - FigureBoneData::new(self.pig_leg_lf.compute_base_matrix()), - FigureBoneData::new(self.pig_leg_rf.compute_base_matrix()), - FigureBoneData::new(self.pig_leg_lb.compute_base_matrix()), - FigureBoneData::new(self.pig_leg_rb.compute_base_matrix()), + FigureBoneData::new(self.head.compute_base_matrix()), + FigureBoneData::new(self.chest.compute_base_matrix()), + 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()), FigureBoneData::default(), FigureBoneData::default(), FigureBoneData::default(), @@ -56,11 +56,11 @@ impl Skeleton for QuadrupedSmallSkeleton { } fn interpolate(&mut self, target: &Self, dt: f32) { - self.pig_head.interpolate(&target.pig_head, dt); - self.pig_chest.interpolate(&target.pig_chest, dt); - self.pig_leg_lf.interpolate(&target.pig_leg_lf, dt); - self.pig_leg_rf.interpolate(&target.pig_leg_rf, dt); - self.pig_leg_lb.interpolate(&target.pig_leg_lb, dt); - self.pig_leg_rb.interpolate(&target.pig_leg_rb, dt); + 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); } } diff --git a/voxygen/src/anim/quadruped_small/run.rs b/voxygen/src/anim/quadruped_small/run.rs index a6f9b877a7..c5af0a7af8 100644 --- a/voxygen/src/anim/quadruped_small/run.rs +++ b/voxygen/src/anim/quadruped_small/run.rs @@ -24,34 +24,34 @@ impl Animation for RunAnimation { let wave_quick_cos = (anim_time as f32 * 20.0).cos(); let wave_cos = (anim_time as f32 * 14.0).cos(); - next.pig_head.offset = Vec3::new(0.0, 0.0, -1.5 + wave * 1.5) / 11.0; - next.pig_head.ori = + next.head.offset = Vec3::new(0.0, 0.0, -1.5 + wave * 1.5) / 11.0; + next.head.ori = Quaternion::rotation_x(0.2 + wave * 0.05) * Quaternion::rotation_y(wave_cos * 0.03); - next.pig_head.scale = Vec3::one() / 10.5; + next.head.scale = Vec3::one() / 10.5; - next.pig_chest.offset = Vec3::new(0.0, -9.0, 1.5 + wave_cos * 1.2) / 11.0; - next.pig_chest.ori = Quaternion::rotation_x(wave * 0.1); - next.pig_chest.scale = Vec3::one() / 11.0; + next.chest.offset = Vec3::new(0.0, -9.0, 1.5 + wave_cos * 1.2) / 11.0; + next.chest.ori = Quaternion::rotation_x(wave * 0.1); + next.chest.scale = Vec3::one() / 11.0; - next.pig_leg_lf.offset = + next.leg_lf.offset = Vec3::new(-4.5, 2.0 + wave_quick * 0.8, 2.5 + wave_quick_cos * 1.5) / 11.0; - next.pig_leg_lf.ori = Quaternion::rotation_x(wave_quick * 0.3); - next.pig_leg_lf.scale = Vec3::one() / 11.0; + next.leg_lf.ori = Quaternion::rotation_x(wave_quick * 0.3); + next.leg_lf.scale = Vec3::one() / 11.0; - next.pig_leg_rf.offset = + next.leg_rf.offset = Vec3::new(2.5, 2.0 - wave_quick_cos * 0.8, 2.5 + wave_quick * 1.5) / 11.0; - next.pig_leg_rf.ori = Quaternion::rotation_x(wave_quick_cos * -0.3); - next.pig_leg_rf.scale = Vec3::one() / 11.0; + next.leg_rf.ori = Quaternion::rotation_x(wave_quick_cos * -0.3); + next.leg_rf.scale = Vec3::one() / 11.0; - next.pig_leg_lb.offset = + next.leg_lb.offset = Vec3::new(-4.5, -3.0 - wave_quick_cos * 0.8, 2.5 + wave_quick * 1.5) / 11.0; - next.pig_leg_lb.ori = Quaternion::rotation_x(wave_quick_cos * -0.3); - next.pig_leg_lb.scale = Vec3::one() / 11.0; + next.leg_lb.ori = Quaternion::rotation_x(wave_quick_cos * -0.3); + next.leg_lb.scale = Vec3::one() / 11.0; - next.pig_leg_rb.offset = + next.leg_rb.offset = Vec3::new(2.5, -3.0 + wave_quick * 0.8, 2.5 + wave_quick_cos * 1.5) / 11.0; - next.pig_leg_rb.ori = Quaternion::rotation_x(wave_quick * 0.3); - next.pig_leg_rb.scale = Vec3::one() / 11.0; + next.leg_rb.ori = Quaternion::rotation_x(wave_quick * 0.3); + next.leg_rb.scale = Vec3::one() / 11.0; next } diff --git a/voxygen/src/scene/figure/load.rs b/voxygen/src/scene/figure/load.rs index 0dd187b117..18a0656ea4 100644 --- a/voxygen/src/scene/figure/load.rs +++ b/voxygen/src/scene/figure/load.rs @@ -11,10 +11,7 @@ use common::{ Belt, BodyType, Chest, EyeColor, Eyebrows, Foot, Hand, Pants, Race, Shoulder, Skin, }, item::Tool, - - object, quadruped_small, quadruped_medium, bird_medium, fish_medium, dragon, bird_small, fish_small, biped_large, Item, Itemkind - - + object, quadruped_medium, quadruped_small, Item, ItemKind, }, figure::{DynaUnionizer, MatSegment, Material, Segment}, }; diff --git a/voxygen/src/scene/figure/mod.rs b/voxygen/src/scene/figure/mod.rs index 664d6ab937..028f15cc0f 100644 --- a/voxygen/src/scene/figure/mod.rs +++ b/voxygen/src/scene/figure/mod.rs @@ -6,8 +6,11 @@ pub use load::load_mesh; // TODO: Don't make this public. use crate::{ anim::{ - self, character::CharacterSkeleton, object::ObjectSkeleton, quadruped::QuadrupedSkeleton, - quadrupedmedium::QuadrupedMediumSkeleton, birdmedium::BirdMediumSkeleton, fishmedium::FishMediumSkeleton, dragon::DragonSkeleton, bird_small::BirdSmallSkeleton, fish_small::FishSmallSkeleton, biped_large::BipedLargeSkeleton, Animation, Skeleton, + self, biped_large::BipedLargeSkeleton, bird_medium::BirdMediumSkeleton, + bird_small::BirdSmallSkeleton, character::CharacterSkeleton, dragon::DragonSkeleton, + fish_medium::FishMediumSkeleton, fish_small::FishSmallSkeleton, object::ObjectSkeleton, + quadruped_medium::QuadrupedMediumSkeleton, quadruped_small::QuadrupedSmallSkeleton, + Animation, Skeleton, }, render::{Consts, FigureBoneData, FigureLocals, Globals, Light, Renderer, Shadow}, scene::camera::{Camera, CameraMode}, @@ -30,7 +33,7 @@ const DAMAGE_FADE_COEFFICIENT: f64 = 5.0; pub struct FigureMgr { model_cache: FigureModelCache, character_states: HashMap>, - quadruped_states: HashMap>, + quadruped_small_states: HashMap>, quadruped_medium_states: HashMap>, bird_medium_states: HashMap>, fish_medium_states: HashMap>, @@ -46,7 +49,7 @@ impl FigureMgr { Self { model_cache: FigureModelCache::new(), character_states: HashMap::new(), - quadruped_states: HashMap::new(), + quadruped_small_states: HashMap::new(), quadruped_medium_states: HashMap::new(), bird_medium_states: HashMap::new(), fish_medium_states: HashMap::new(), @@ -99,8 +102,8 @@ impl FigureMgr { Body::Humanoid(_) => { self.character_states.remove(&entity); } - Body::Quadruped(_) => { - self.quadruped_states.remove(&entity); + Body::QuadrupedSmall(_) => { + self.quadruped_small_states.remove(&entity); } Body::QuadrupedMedium(_) => { self.quadruped_medium_states.remove(&entity); @@ -296,11 +299,13 @@ impl FigureMgr { action_animation_rate, ); } - Body::Quadruped(_) => { + Body::QuadrupedSmall(_) => { let state = self - .quadruped_states + .quadruped_small_states .entry(entity) - .or_insert_with(|| FigureState::new(renderer, QuadrupedSkeleton::new())); + .or_insert_with(|| { + FigureState::new(renderer, QuadrupedSmallSkeleton::new()) + }); let (character, last_character) = match (character, last_character) { (Some(c), Some(l)) => (c, l), @@ -312,22 +317,22 @@ impl FigureMgr { } let target_base = match character.movement { - Stand => anim::quadruped::IdleAnimation::update_skeleton( - &QuadrupedSkeleton::new(), + Stand => anim::quadruped_small::IdleAnimation::update_skeleton( + &QuadrupedSmallSkeleton::new(), time, state.movement_time, &mut movement_animation_rate, skeleton_attr, ), - Run => anim::quadruped::RunAnimation::update_skeleton( - &QuadrupedSkeleton::new(), + Run => anim::quadruped_small::RunAnimation::update_skeleton( + &QuadrupedSmallSkeleton::new(), (vel.0.magnitude(), time), state.movement_time, &mut movement_animation_rate, skeleton_attr, ), - Jump => anim::quadruped::JumpAnimation::update_skeleton( - &QuadrupedSkeleton::new(), + Jump => anim::quadruped_small::JumpAnimation::update_skeleton( + &QuadrupedSmallSkeleton::new(), (vel.0.magnitude(), time), state.movement_time, &mut movement_animation_rate, @@ -369,21 +374,21 @@ impl FigureMgr { } let target_base = match character.movement { - Stand => anim::quadrupedmedium::IdleAnimation::update_skeleton( + Stand => anim::quadruped_medium::IdleAnimation::update_skeleton( &QuadrupedMediumSkeleton::new(), time, state.movement_time, &mut movement_animation_rate, skeleton_attr, ), - Run => anim::quadrupedmedium::RunAnimation::update_skeleton( + Run => anim::quadruped_medium::RunAnimation::update_skeleton( &QuadrupedMediumSkeleton::new(), (vel.0.magnitude(), time), state.movement_time, &mut movement_animation_rate, skeleton_attr, ), - Jump => anim::quadrupedmedium::JumpAnimation::update_skeleton( + Jump => anim::quadruped_medium::JumpAnimation::update_skeleton( &QuadrupedMediumSkeleton::new(), (vel.0.magnitude(), time), state.movement_time, @@ -412,9 +417,7 @@ impl FigureMgr { let state = self .bird_medium_states .entry(entity) - .or_insert_with(|| { - FigureState::new(renderer, BirdMediumSkeleton::new()) - }); + .or_insert_with(|| FigureState::new(renderer, BirdMediumSkeleton::new())); let (character, last_character) = match (character, last_character) { (Some(c), Some(l)) => (c, l), @@ -426,21 +429,21 @@ impl FigureMgr { } let target_base = match character.movement { - Stand => anim::birdmedium::IdleAnimation::update_skeleton( + Stand => anim::bird_medium::IdleAnimation::update_skeleton( &BirdMediumSkeleton::new(), time, state.movement_time, &mut movement_animation_rate, skeleton_attr, ), - Run => anim::birdmedium::RunAnimation::update_skeleton( + Run => anim::bird_medium::RunAnimation::update_skeleton( &BirdMediumSkeleton::new(), (vel.0.magnitude(), time), state.movement_time, &mut movement_animation_rate, skeleton_attr, ), - Jump => anim::birdmedium::JumpAnimation::update_skeleton( + Jump => anim::bird_medium::JumpAnimation::update_skeleton( &BirdMediumSkeleton::new(), (vel.0.magnitude(), time), state.movement_time, @@ -469,9 +472,7 @@ impl FigureMgr { let state = self .fish_medium_states .entry(entity) - .or_insert_with(|| { - FigureState::new(renderer, FishMediumSkeleton::new()) - }); + .or_insert_with(|| FigureState::new(renderer, FishMediumSkeleton::new())); let (character, last_character) = match (character, last_character) { (Some(c), Some(l)) => (c, l), @@ -483,21 +484,21 @@ impl FigureMgr { } let target_base = match character.movement { - Stand => anim::fishmedium::IdleAnimation::update_skeleton( + Stand => anim::fish_medium::IdleAnimation::update_skeleton( &FishMediumSkeleton::new(), time, state.movement_time, &mut movement_animation_rate, skeleton_attr, ), - Run => anim::fishmedium::RunAnimation::update_skeleton( + Run => anim::fish_medium::RunAnimation::update_skeleton( &FishMediumSkeleton::new(), (vel.0.magnitude(), time), state.movement_time, &mut movement_animation_rate, skeleton_attr, ), - Jump => anim::fishmedium::JumpAnimation::update_skeleton( + Jump => anim::fish_medium::JumpAnimation::update_skeleton( &FishMediumSkeleton::new(), (vel.0.magnitude(), time), state.movement_time, @@ -526,9 +527,7 @@ impl FigureMgr { let state = self .dragon_states .entry(entity) - .or_insert_with(|| { - FigureState::new(renderer, DragonSkeleton::new()) - }); + .or_insert_with(|| FigureState::new(renderer, DragonSkeleton::new())); let (character, last_character) = match (character, last_character) { (Some(c), Some(l)) => (c, l), @@ -583,9 +582,7 @@ impl FigureMgr { let state = self .bird_small_states .entry(entity) - .or_insert_with(|| { - FigureState::new(renderer, BirdSmallSkeleton::new()) - }); + .or_insert_with(|| FigureState::new(renderer, BirdSmallSkeleton::new())); let (character, last_character) = match (character, last_character) { (Some(c), Some(l)) => (c, l), @@ -640,9 +637,7 @@ impl FigureMgr { let state = self .fish_small_states .entry(entity) - .or_insert_with(|| { - FigureState::new(renderer,FishSmallSkeleton::new()) - }); + .or_insert_with(|| FigureState::new(renderer, FishSmallSkeleton::new())); let (character, last_character) = match (character, last_character) { (Some(c), Some(l)) => (c, l), @@ -697,9 +692,7 @@ impl FigureMgr { let state = self .biped_large_states .entry(entity) - .or_insert_with(|| { - FigureState::new(renderer, BipedLargeSkeleton::new()) - }); + .or_insert_with(|| FigureState::new(renderer, BipedLargeSkeleton::new())); let (character, last_character) = match (character, last_character) { (Some(c), Some(l)) => (c, l), @@ -775,7 +768,7 @@ impl FigureMgr { // Clear states that have dead entities. self.character_states .retain(|entity, _| ecs.entities().is_alive(*entity)); - self.quadruped_states + self.quadruped_small_states .retain(|entity, _| ecs.entities().is_alive(*entity)); self.quadruped_medium_states .retain(|entity, _| ecs.entities().is_alive(*entity)); @@ -840,8 +833,8 @@ impl FigureMgr { .character_states .get(&entity) .map(|state| (state.locals(), state.bone_consts())), - Body::Quadruped(_) => self - .quadruped_states + Body::QuadrupedSmall(_) => self + .quadruped_small_states .get(&entity) .map(|state| (state.locals(), state.bone_consts())), Body::QuadrupedMedium(_) => self