animation adjustments

Former-commit-id: 8752caf0bdcac1c2938f048878a008e8f5cd18e0
This commit is contained in:
jshipsey 2019-05-12 20:52:30 -04:00
parent 4dac3e9a8b
commit 6578fd09c3
10 changed files with 146 additions and 71 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -60,6 +60,17 @@ pub enum Weapon {
Staff,
}
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub enum Shoulder {
DefaultShoulder
}
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub enum Draw {
DefaultDraw
}
use Belt::*;
use Chest::*;
use Foot::*;
@ -69,6 +80,9 @@ use Head::*;
use Pants::*;
use Race::*;
use Weapon::*;
use Shoulder::*;
use Draw::*;
const ALL_RACES: [Race; 6] = [Danari, Dwarf, Elf, Human, Orc, Undead];
const ALL_GENDERS: [Gender; 3] = [Female, Male, Unspecified];
@ -79,6 +93,10 @@ const ALL_PANTS: [Pants; 1] = [DefaultPants];
const ALL_HANDS: [Hand; 1] = [DefaultHand];
const ALL_FEET: [Foot; 1] = [DefaultFoot];
const ALL_WEAPONS: [Weapon; 7] = [Daggers, SwordShield, Sword, Axe, Hammer, Bow, Staff];
const ALL_SHOULDERS: [Shoulder; 1] = [DefaultShoulder];
const ALL_DRAW: [Draw; 1] = [DefaultDraw];
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub struct Character {
@ -91,6 +109,9 @@ pub struct Character {
pub hand: Hand,
pub foot: Foot,
pub weapon: Weapon,
pub shoulder: Shoulder,
pub draw: Draw,
}
impl Character {
@ -105,6 +126,9 @@ impl Character {
hand: *thread_rng().choose(&ALL_HANDS).unwrap(),
foot: *thread_rng().choose(&ALL_FEET).unwrap(),
weapon: *thread_rng().choose(&ALL_WEAPONS).unwrap(),
shoulder: *thread_rng().choose(&ALL_SHOULDERS).unwrap(),
draw: *thread_rng().choose(&ALL_DRAW).unwrap(),
}
}
}

View File

@ -7,6 +7,9 @@ use vek::*;
// Local
use super::{super::Animation, CharacterSkeleton, SCALE};
pub struct Input {
pub attack: bool,
}
pub struct IdleAnimation;
impl Animation for IdleAnimation {
@ -40,62 +43,66 @@ impl Animation for IdleAnimation {
.sin()
* 0.25,
);
next.head.offset = Vec3::new(5.5, 2.0, 11.5 + waveultra_slow * 0.4);
next.head.offset = Vec3::new(5.5, 2.0, 11.0 + waveultra_slow * 0.3);
next.head.ori = Quaternion::rotation_z(head_look.x) * Quaternion::rotation_x(head_look.y);
next.head.scale = Vec3::one();
next.chest.offset = Vec3::new(5.5, 0.0, 7.5 + waveultra_slow * 0.4);
next.chest.offset = Vec3::new(5.5, 0.0, 7.0 + waveultra_slow * 0.3);
next.chest.ori = Quaternion::rotation_x(0.0);
next.chest.scale = Vec3::one();
next.belt.offset = Vec3::new(5.5, 0.0, 5.5 + waveultra_slow * 0.4);
next.belt.offset = Vec3::new(5.5, 0.0, 5.0 + waveultra_slow * 0.3);
next.belt.ori = Quaternion::rotation_x(0.0);
next.belt.scale = Vec3::one();
next.shorts.offset = Vec3::new(5.5, 0.0, 2.5 + waveultra_slow * 0.4);
next.shorts.offset = Vec3::new(5.5, 0.0, 2.0 + waveultra_slow * 0.3);
next.shorts.ori = Quaternion::rotation_x(0.0);
next.shorts.scale = Vec3::one();
next.l_hand.offset = Vec3::new(
-7.5,
-2.0 + waveultracos_slow * 0.3,
12.0 + waveultra_slow * 1.1,
-6.0,
-2.0 + waveultracos_slow * 0.15,
11.5 + waveultra_slow * 0.5,
);
next.l_hand.ori = Quaternion::rotation_x(0.0 + waveultra_slow * 0.06);
next.l_hand.scale = Vec3::one();
next.r_hand.offset = Vec3::new(
7.5,
-2.0 + waveultracos_slow * 0.3,
12.0 + waveultra_slow * 1.1,
9.0,
-2.0 + waveultracos_slow * 0.15,
11.5 + waveultra_slow * 0.5,
);
next.r_hand.ori = Quaternion::rotation_x(0.0 + waveultra_slow * 0.06);
next.r_hand.scale = Vec3::one();
next.l_foot.offset = Vec3::new(-3.4, 0.0, 8.0);
next.l_foot.offset = Vec3::new(-3.3, -0.1, 8.0);
next.l_foot.ori = Quaternion::identity();
next.l_foot.scale = Vec3::one();
next.r_foot.offset = Vec3::new(3.4, 0.0, 8.0);
next.r_foot.offset = Vec3::new(4.1, -0.1, 8.0);
next.r_foot.ori = Quaternion::identity();
next.r_foot.scale = Vec3::one();
next.r_foot.scale = Vec3::one();
next.weapon.offset = Vec3::new(-5.0, -6.0, 18.5);
next.weapon.offset = Vec3::new(-5.0, -6.0, 18.0);
next.weapon.ori = Quaternion::rotation_y(2.5);
next.weapon.scale = Vec3::one();
next.l_shoulder.offset = Vec3::new(-10.0, -3.0, 2.5);
next.l_shoulder.ori = Quaternion::rotation_x(0.0);
next.l_shoulder.scale = Vec3::one();
next.r_shoulder.offset = Vec3::new(0.0, -3.0, 2.5);
next.r_shoulder.ori = Quaternion::rotation_x(0.0);
next.r_shoulder.scale = Vec3::one();
next.torso.offset = Vec3::new(-0.5, -0.2, 0.1);
next.torso.ori = Quaternion::rotation_x(0.0);
next.torso.scale = Vec3::one() / 11.0;
next.l_shoulder.offset = Vec3::new(2.9, 6.0, 18.0);
next.l_shoulder.ori = Quaternion::rotation_x(0.0);
next.l_shoulder.scale = Vec3::one();
next.r_shoulder.offset = Vec3::new(2.9, -6.0, 18.0);
next.r_shoulder.ori = Quaternion::rotation_x(0.0);
next.r_shoulder.scale = Vec3::one();
next.draw.offset = Vec3::new(0.0, 1.0, -8.0);
next.draw.ori = Quaternion::rotation_y(-0.2);
next.draw.scale = Vec3::one();
next
}
}

View File

@ -21,18 +21,19 @@ impl Animation for JumpAnimation {
) -> Self::Skeleton {
let mut next = (*skeleton).clone();
let wave = (anim_time as f32 * 14.0).sin();
let arcwave = (1.0f32.ln_1p() - 1.0).abs();
let waveslow = (anim_time as f32 * 7.0).sin();
let arcwave = (1.0f32.ln_1p() - 1.5).abs();
let wavetest = (wave.cbrt());
let fuzzwave = (anim_time as f32 * 12.0).sin();
let wavecos = (anim_time as f32 * 14.0).cos();
let wave_slow = (anim_time as f32 * 5.0 + PI).min(PI / 2.0).sin();
let wave_stop = (anim_time as f32 * 4.5).min(PI / 2.0).sin();
let wave_stopalt = (anim_time as f32 * 5.0).min(PI / 2.0).sin();
let wave_slowtest = (anim_time as f32).min(PI / 2.0).sin();
let wavecos_slow = (anim_time as f32 * 8.0 + PI).cos();
let wave_dip = (wave_slow.abs() - 0.5).abs();
let mult = wave_slow / (wave_slow.abs());
next.head.offset = Vec3::new(5.5, 2.0, 12.0);
next.head.ori = Quaternion::rotation_x(0.15);
next.head.ori = Quaternion::rotation_x(0.25);
next.head.scale = Vec3::one();
next.chest.offset = Vec3::new(5.5, 0.0, 8.0);
@ -47,38 +48,38 @@ impl Animation for JumpAnimation {
next.shorts.ori = Quaternion::rotation_z(0.0);
next.shorts.scale = Vec3::one();
next.l_hand.offset = Vec3::new(-7.5, -2.0, 12.0);
next.l_hand.ori = Quaternion::rotation_x(0.8);
next.l_hand.offset = Vec3::new(-7.5, 0.0, 12.0);
next.l_hand.ori = Quaternion::rotation_x(wave_stopalt * 1.2 - waveslow * 0.15);
next.l_hand.scale = Vec3::one();
next.r_hand.offset = Vec3::new(7.5, -2.0, 12.0);
next.r_hand.ori = Quaternion::rotation_x(-0.8);
next.r_hand.offset = Vec3::new(7.5, 0.0, 12.0);
next.r_hand.ori = Quaternion::rotation_x(wave_stopalt * -1.2 + waveslow * 0.15);
next.r_hand.scale = Vec3::one();
next.l_foot.offset = Vec3::new(-3.4, 1.0, 6.0);
next.l_foot.ori = Quaternion::rotation_x(wave_slow * -1.2);
next.l_foot.ori = Quaternion::rotation_x(wave_stop * -1.2 - waveslow * 0.2);
next.l_foot.scale = Vec3::one();
next.r_foot.offset = Vec3::new(3.4, -1.0, 6.0);
next.r_foot.ori = Quaternion::rotation_x(wave_slow * 1.2);
next.r_foot.ori = Quaternion::rotation_x(wave_stop * 1.2 + waveslow * 0.2);
next.r_foot.scale = Vec3::one();
next.weapon.offset = Vec3::new(-5.0, -6.0, 19.0);
next.weapon.ori = Quaternion::rotation_y(2.5);
next.weapon.scale = Vec3::one();
next.torso.offset = Vec3::new(-0.5, 0.0, 0.2);
next.torso.ori = Quaternion::rotation_x(0.0);
next.torso.scale = Vec3::one() / 11.0;
next.l_shoulder.offset = Vec3::new(3.0, 6.0, 18.0);
next.l_shoulder.ori = Quaternion::rotation_y(0.0);
next.l_shoulder.offset = Vec3::new(-10.0, -3.0, 2.5);
next.l_shoulder.ori = Quaternion::rotation_x(0.0);
next.l_shoulder.scale = Vec3::one();
next.r_shoulder.offset = Vec3::new(3.0, -6.0, 18.0);
next.r_shoulder.ori = Quaternion::rotation_y(0.0);
next.r_shoulder.offset = Vec3::new(0.0, -3.0, 2.5);
next.r_shoulder.ori = Quaternion::rotation_x(0.0);
next.r_shoulder.scale = Vec3::one();
next.torso.offset = Vec3::new(-0.5, -0.2, 0.0);
next.torso.ori = Quaternion::rotation_x(-0.2);
next.torso.scale = Vec3::one() / 11.0;
next
}
}

View File

@ -25,9 +25,11 @@ pub struct CharacterSkeleton {
l_foot: Bone,
r_foot: Bone,
weapon: Bone,
torso: Bone,
l_shoulder: Bone,
r_shoulder: Bone,
torso: Bone,
draw: Bone,
}
impl CharacterSkeleton {
@ -42,9 +44,11 @@ impl CharacterSkeleton {
l_foot: Bone::default(),
r_foot: Bone::default(),
weapon: Bone::default(),
torso: Bone::default(),
l_shoulder: Bone::default(),
r_shoulder: Bone::default(),
torso: Bone::default(),
draw: Bone::default(),
}
}
}
@ -53,22 +57,21 @@ 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();
let l_hand_mat = self.l_hand.compute_base_matrix();
[
FigureBoneData::new(torso_mat * self.head.compute_base_matrix()),
FigureBoneData::new(torso_mat * chest_mat),
FigureBoneData::new(torso_mat * self.belt.compute_base_matrix()),
FigureBoneData::new(torso_mat * self.shorts.compute_base_matrix()),
FigureBoneData::new(torso_mat * self.l_hand.compute_base_matrix()),
FigureBoneData::new(torso_mat * l_hand_mat),
FigureBoneData::new(torso_mat * self.r_hand.compute_base_matrix()),
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.weapon.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),
//FigureBoneData::new(torso_mat * self.l_shoulder.compute_base_matrix()),
//FigureBoneData::new(torso_mat * self.r_shoulder.compute_base_matrix()),
FigureBoneData::default(),
FigureBoneData::default(),
FigureBoneData::default(),
FigureBoneData::new(torso_mat * l_hand_mat * self.draw.compute_base_matrix()),
FigureBoneData::default(),
FigureBoneData::default(),
FigureBoneData::default(),
@ -85,8 +88,12 @@ impl Skeleton for CharacterSkeleton {
self.l_foot.interpolate(&target.l_foot);
self.r_foot.interpolate(&target.r_foot);
self.weapon.interpolate(&target.weapon);
self.torso.interpolate(&target.torso);
self.l_shoulder.interpolate(&target.l_shoulder);
self.r_shoulder.interpolate(&target.r_shoulder);
self.torso.interpolate(&target.torso);
self.draw.interpolate(&target.draw);
}
}

View File

@ -28,27 +28,27 @@ impl Animation for RunAnimation {
let wavecos_slow = (anim_time as f32 * 8.0 + PI).cos();
let wave_dip = (wave_slow.abs() - 0.5).abs();
next.head.offset = Vec3::new(5.5, 2.0, 12.0 + wavecos * 1.3);
next.head.offset = Vec3::new(5.5, 2.0, 11.0 + wavecos * 1.3);
next.head.ori = Quaternion::rotation_x(0.15);
next.head.scale = Vec3::one();
next.chest.offset = Vec3::new(5.5, 0.0, 8.0 + wavecos * 1.1);
next.chest.offset = Vec3::new(5.5, 0.0, 7.0 + wavecos * 1.1);
next.chest.ori = Quaternion::rotation_z(wave * 0.1);
next.chest.scale = Vec3::one();
next.belt.offset = Vec3::new(5.5, 0.0, 6.0 + wavecos * 1.1);
next.belt.offset = Vec3::new(5.5, 0.0, 5.0 + wavecos * 1.1);
next.belt.ori = Quaternion::rotation_z(wave * 0.25);
next.belt.scale = Vec3::one();
next.shorts.offset = Vec3::new(5.5, 0.0, 3.0 + wavecos * 1.1);
next.shorts.offset = Vec3::new(5.5, 0.0, 2.0 + wavecos * 1.1);
next.shorts.ori = Quaternion::rotation_z(wave * 0.6);
next.shorts.scale = Vec3::one();
next.l_hand.offset = Vec3::new(-7.5, -2.0 + wavecos * 2.5, 12.0 - wave * 1.5);
next.l_hand.offset = Vec3::new(-7.5, 0.0 + wavecos * 2.5, 11.0 - wave * 1.5);
next.l_hand.ori = Quaternion::rotation_x(wavecos * 0.9);
next.l_hand.scale = Vec3::one();
next.r_hand.offset = Vec3::new(7.5, -2.0 - wavecos * 2.5, 12.0 + wave * 1.5);
next.r_hand.offset = Vec3::new(7.5, 0.0 - wavecos * 2.5, 11.0 + wave * 1.5);
next.r_hand.ori = Quaternion::rotation_x(wavecos * -0.9);
next.r_hand.scale = Vec3::one();
@ -60,21 +60,27 @@ impl Animation for RunAnimation {
next.r_foot.ori = Quaternion::rotation_x(-0.0 + wave * 1.5);
next.r_foot.scale = Vec3::one();
next.weapon.offset = Vec3::new(-5.0, -6.0, 19.0);
next.weapon.offset = Vec3::new(-5.0, -6.0, 18.0);
next.weapon.ori = Quaternion::rotation_y(2.5);
next.weapon.scale = Vec3::one();
next.l_shoulder.offset = Vec3::new(-10.0, -3.0, 2.5);
next.l_shoulder.ori = Quaternion::rotation_x(0.0);
next.l_shoulder.scale = Vec3::one();
next.torso.offset = Vec3::new(-0.5, -0.2, 0.2);
next.r_shoulder.offset = Vec3::new(0.0, -3.0, 2.5);
next.r_shoulder.ori = Quaternion::rotation_x(0.0);
next.r_shoulder.scale = Vec3::one();
next.torso.offset = Vec3::new(-0.5, -0.2, 0.4);
next.torso.ori = Quaternion::rotation_x(-velocity * 0.05 - wavecos * 0.1);
next.torso.scale = Vec3::one() / 11.0;
next.l_shoulder.offset = Vec3::new(3.0, 6.0, 18.0);
next.l_shoulder.ori = Quaternion::rotation_y(0.0);
next.l_shoulder.scale = Vec3::one();
next.draw.offset = Vec3::new(0.0, 1.0, -8.0);
next.draw.ori = Quaternion::rotation_y(-0.2);
next.draw.scale = Vec3::one();
next.r_shoulder.offset = Vec3::new(3.0, -6.0, 18.0);
next.r_shoulder.ori = Quaternion::rotation_y(0.0);
next.r_shoulder.scale = Vec3::one();
next
}

View File

@ -14,7 +14,7 @@ use common::{
assets,
comp::{
self,
character::{Belt, Character, Chest, Foot, Hand, Head, Pants, Weapon},
character::{Belt, Character, Chest, Foot, Hand, Head, Pants, Weapon, Shoulder, Draw},
},
figure::Segment,
msg,
@ -62,8 +62,9 @@ impl FigureCache {
Some(Self::load_left_foot(character.foot)),
Some(Self::load_right_foot(character.foot)),
Some(Self::load_weapon(character.weapon)),
None,
None,
Some(Self::load_left_shoulder(character.shoulder)),
Some(Self::load_right_shoulder(character.shoulder)),
//Some(Self::load_draw(character.draw)),
None,
None,
None,
@ -146,7 +147,7 @@ impl FigureCache {
match hand {
Hand::DefaultHand => "hand.vox",
},
Vec3::new(3.5, 0.0, -7.0),
Vec3::new(2.0, 0.0, -7.0),
)
}
@ -155,7 +156,7 @@ impl FigureCache {
match hand {
Hand::DefaultHand => "hand.vox",
},
Vec3::new(3.5, 0.0, -7.0),
Vec3::new(2.0, 0.0, -7.0),
)
}
@ -188,6 +189,35 @@ impl FigureCache {
)
}
fn load_left_shoulder(shoulder: Shoulder) -> Mesh<FigurePipeline> {
Self::load_mesh(
match shoulder {
Shoulder::DefaultShoulder => "shoulder_l.vox",
},
Vec3::new(2.5, 0.0, 0.0),
)
}
fn load_right_shoulder(shoulder: Shoulder) -> Mesh<FigurePipeline> {
Self::load_mesh(
match shoulder {
Shoulder::DefaultShoulder => "shoulder_r.vox",
},
Vec3::new(2.5, 0.0, 0.0),
)
}
// fn load_draw(draw: Draw) -> Mesh<FigurePipeline> {
// Self::load_mesh(
// match draw {
// //Draw::DefaultDraw => "sword.vox",
//
// },
// Vec3::new(0.0, 0.0, -2.0)
//
//
// )
// }
pub fn maintain(&mut self, renderer: &mut Renderer, client: &mut Client) {
let time = client.state().get_time();
let ecs = client.state_mut().ecs_mut();