mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Merge branch 'master' into 'master'
velocity tilt, run adjustments See merge request veloren/veloren!69 Former-commit-id: 90a449e76431bb11bf748b887876c0e88db9e566
This commit is contained in:
commit
d04db4f6dc
@ -13,7 +13,6 @@ use super::{
|
||||
|
||||
pub struct IdleAnimation;
|
||||
|
||||
//TODO: Make it actually good, possibly add the head rotating slightly, add breathing, etc.
|
||||
impl Animation for IdleAnimation {
|
||||
type Skeleton = CharacterSkeleton;
|
||||
type Dependency = f64;
|
||||
@ -32,31 +31,54 @@ impl Animation for IdleAnimation {
|
||||
let waveultracos_slow = (time as f32 * 1.0 + PI).cos();
|
||||
let wave_dip = (wave_slow.abs() - 0.5).abs();
|
||||
|
||||
next.head.offset = Vec3::new(0.0, 0.0, 12.0 + waveultra_slow * 0.4) / SCALE;
|
||||
next.head.offset = Vec3::new(5.5, 0.0, 12.0 + waveultra_slow * 0.4);
|
||||
next.head.ori = Quaternion::rotation_y(waveultra_slow * 0.05);
|
||||
next.head.scale = Vec3::one();
|
||||
|
||||
next.chest.offset = Vec3::new(0.0, 0.0, 8.0 + waveultra_slow * 0.4) / SCALE;
|
||||
next.chest.offset = Vec3::new(2.5, 0.0, 8.0 + waveultra_slow * 0.4);
|
||||
next.chest.ori = Quaternion::rotation_y(0.0);
|
||||
next.chest.scale = Vec3::one();
|
||||
|
||||
next.belt.offset = Vec3::new(0.0, 0.0, 6.0 + waveultra_slow * 0.4) / SCALE;
|
||||
next.belt.offset = Vec3::new(2.5, 0.0, 6.0 + waveultra_slow * 0.4);
|
||||
next.belt.ori = Quaternion::rotation_y(0.0);
|
||||
next.belt.scale = Vec3::one();
|
||||
|
||||
next.shorts.offset = Vec3::new(0.0, 0.0, 3.0 + waveultra_slow * 0.4) / SCALE;
|
||||
next.shorts.offset = Vec3::new(2.5, 0.0, 3.0 + waveultra_slow * 0.4);
|
||||
next.shorts.ori = Quaternion::rotation_y(0.0);
|
||||
next.shorts.scale = Vec3::one();
|
||||
|
||||
next.l_hand.offset = Vec3::new(0.0 + waveultracos_slow * 0.3, 7.5, 11.0 + waveultra_slow * 1.1) / SCALE;
|
||||
next.l_hand.offset = Vec3::new(2.0 + waveultracos_slow * 0.3, 7.5, 12.5 + waveultra_slow * 1.1);
|
||||
next.l_hand.ori = Quaternion::rotation_y(0.0 + waveultra_slow * 0.06);
|
||||
next.r_hand.offset = Vec3::new(0.0 + waveultracos_slow * 0.3 , - 7.5, 11.0 + waveultra_slow * 1.1) / SCALE;
|
||||
next.l_hand.scale = Vec3::one();
|
||||
|
||||
next.r_hand.offset = Vec3::new(2.0 + waveultracos_slow * 0.3 , - 7.5, 12.5 + waveultra_slow * 1.1);
|
||||
next.r_hand.ori = Quaternion::rotation_y(0.0 + waveultra_slow * 0.06);
|
||||
next.r_hand.scale = Vec3::one();
|
||||
|
||||
next.l_foot.offset = Vec3::new(2.5, 3.4, 6.0) / SCALE;
|
||||
next.l_foot.offset = Vec3::new(5.0, 3.4, 8.0);
|
||||
next.l_foot.ori = Quaternion::rotation_y(0.04 + waveultra_slow * 0.04);
|
||||
next.r_foot.offset = Vec3::new(2.5, -3.4, 6.0) / SCALE;
|
||||
next.r_foot.ori = Quaternion::rotation_y(0.04 + waveultra_slow * 0.04);
|
||||
next.l_foot.scale = Vec3::one();
|
||||
|
||||
next.back.offset = Vec3::new(-6.5, 16.0, 15.0);
|
||||
next.back.ori = Quaternion::rotation_x(2.5);
|
||||
next.back.scale = Vec3::one();
|
||||
next.r_foot.offset = Vec3::new(5.0, -3.4, 8.0);
|
||||
next.r_foot.ori = Quaternion::rotation_y(0.04 + waveultra_slow * 0.04);
|
||||
next.r_foot.scale = Vec3::one();
|
||||
|
||||
next.weapon.offset = Vec3::new(-4.5, 14.0, 13.0);
|
||||
next.weapon.ori = Quaternion::rotation_x(2.5);
|
||||
next.weapon.scale = Vec3::one();
|
||||
|
||||
|
||||
next.torso.offset = Vec3::new(0.0, 0.0, 0.0);
|
||||
next.torso.ori = Quaternion::rotation_y(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_y(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_y(0.0);
|
||||
next.r_shoulder.scale = Vec3::one();
|
||||
|
||||
next
|
||||
}
|
||||
|
@ -26,7 +26,10 @@ pub struct CharacterSkeleton {
|
||||
r_hand: Bone,
|
||||
l_foot: Bone,
|
||||
r_foot: Bone,
|
||||
back: Bone,
|
||||
weapon: Bone,
|
||||
torso: Bone,
|
||||
l_shoulder: Bone,
|
||||
r_shoulder: Bone,
|
||||
}
|
||||
|
||||
impl CharacterSkeleton {
|
||||
@ -40,7 +43,11 @@ impl CharacterSkeleton {
|
||||
r_hand: Bone::default(),
|
||||
l_foot: Bone::default(),
|
||||
r_foot: Bone::default(),
|
||||
back: Bone::default(),
|
||||
weapon: Bone::default(),
|
||||
torso: Bone::default(),
|
||||
l_shoulder: Bone::default(),
|
||||
r_shoulder: Bone::default(),
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -48,24 +55,27 @@ impl CharacterSkeleton {
|
||||
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();
|
||||
[
|
||||
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()),
|
||||
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::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 * 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),
|
||||
//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::default(),
|
||||
FigureBoneData::default(),
|
||||
FigureBoneData::default(),
|
||||
|
||||
]
|
||||
}
|
||||
|
||||
@ -78,6 +88,10 @@ impl Skeleton for CharacterSkeleton {
|
||||
self.r_hand.interpolate(&target.r_hand);
|
||||
self.l_foot.interpolate(&target.l_foot);
|
||||
self.r_foot.interpolate(&target.r_foot);
|
||||
self.back.interpolate(&target.back);
|
||||
self.weapon.interpolate(&target.weapon);
|
||||
self.torso.interpolate(&target.torso);
|
||||
self.l_shoulder.interpolate(&target.l_shoulder);
|
||||
self.r_shoulder.interpolate(&target.r_shoulder);
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -24,37 +24,61 @@ impl Animation for RunAnimation {
|
||||
let mut next = (*skeleton).clone();
|
||||
|
||||
let wave = (time as f32 * 14.0).sin();
|
||||
let wavetest = (wave.cbrt());
|
||||
let fuzzwave = (time as f32 * 12.0).sin();
|
||||
let wavecos = (time as f32 * 14.0).cos();
|
||||
let wave_slow = (time as f32 * 8.0 + PI).sin();
|
||||
let wave_slow = (time as f32 * 7.0 + PI).sin();
|
||||
let wavecos_slow = (time as f32 * 8.0 + PI).cos();
|
||||
let wave_dip = (wave_slow.abs() - 0.5).abs();
|
||||
|
||||
next.head.offset = Vec3::unit_z() * (12.0 + fuzzwave *1.0)/ SCALE;
|
||||
next.head.offset = Vec3::new(6.0, 0.0, 12.0 + wavecos * 1.3);
|
||||
next.head.ori = Quaternion::rotation_y(-0.15);
|
||||
next.head.scale = Vec3::one();
|
||||
|
||||
next.chest.offset = Vec3::unit_z() * (8.0 + fuzzwave * 0.8) / SCALE;
|
||||
next.chest.ori = Quaternion::rotation_z(wave * 0.3);
|
||||
next.chest.offset = Vec3::new(2.5, 0.0, 8.0 + wavecos * 1.1);
|
||||
next.chest.ori = Quaternion::rotation_z(wave * 0.1);
|
||||
next.chest.scale = Vec3::one();
|
||||
|
||||
next.belt.offset = Vec3::unit_z() * (6.0 + fuzzwave * 0.8) / SCALE;
|
||||
next.belt.ori = Quaternion::rotation_z(wave * 0.3);
|
||||
next.belt.offset = Vec3::new(2.5, 0.0, 6.0 + wavecos * 1.1);
|
||||
next.belt.ori = Quaternion::rotation_z(wave * 0.25);
|
||||
next.belt.scale = Vec3::one();
|
||||
|
||||
next.shorts.offset = Vec3::unit_z() * (3.0 + fuzzwave * 0.8) / SCALE;
|
||||
next.shorts.ori = Quaternion::rotation_z(wave * 0.2);
|
||||
next.shorts.offset = Vec3::new(2.5, 0.0, 3.0 + wavecos * 1.1);
|
||||
next.shorts.ori = Quaternion::rotation_z(wave * 0.6);
|
||||
next.shorts.scale = Vec3::one();
|
||||
|
||||
next.l_hand.offset = Vec3::new(0.0 - wavecos * 1.0, 7.5, 11.0 - wave * 1.0) / SCALE;
|
||||
next.l_hand.ori = Quaternion::rotation_y(wave * -1.8);
|
||||
next.r_hand.offset = Vec3::new(0.0 + wavecos * 1.0, -7.5, 11.0 + wave * 1.0) / SCALE;
|
||||
next.r_hand.ori = Quaternion::rotation_y(wave * 1.8);
|
||||
next.l_hand.offset = Vec3::new(2.0 - wavecos * 2.5, 7.5, 12.0 + wave * 1.5);
|
||||
next.l_hand.ori = Quaternion::rotation_y(wavecos * 0.9);
|
||||
next.l_hand.scale = Vec3::one();
|
||||
|
||||
next.l_foot.offset = Vec3::new(2.5 - wavecos * 4.0, 3.4, 6.0 + wave * 2.9) / SCALE;
|
||||
next.l_foot.ori = Quaternion::rotation_y(wave * -1.0);
|
||||
next.r_foot.offset = Vec3::new(2.5 + wavecos * 4.0, -3.4, 6.0 - wave * 2.9) / SCALE;
|
||||
next.r_hand.offset = Vec3::new(2.0 + wavecos * 2.5, -7.5, 12.0 - wave * 1.5);
|
||||
next.r_hand.ori = Quaternion::rotation_y(wavecos * -0.9);
|
||||
next.r_hand.scale = Vec3::one();
|
||||
|
||||
next.r_foot.ori = Quaternion::rotation_y(wave * 1.0);
|
||||
next.l_foot.offset = Vec3::new(3.5 + wave * 1.0, 3.4, 6.0);
|
||||
next.l_foot.ori = Quaternion::rotation_y(-0.0 - wave * 1.5);
|
||||
next.l_foot.scale = Vec3::one();
|
||||
|
||||
next.r_foot.offset = Vec3::new(3.5 - wave * 1.0, -3.4, 6.0);
|
||||
next.r_foot.ori = Quaternion::rotation_y(-0.0 + wave * 1.5);
|
||||
next.r_foot.scale = Vec3::one();
|
||||
|
||||
next.weapon.offset = Vec3::new(-5.0, 14.0, 13.0);
|
||||
next.weapon.ori = Quaternion::rotation_x(2.5);
|
||||
next.weapon.scale = Vec3::one();
|
||||
|
||||
next.torso.offset = Vec3::new(0.0, 0.0, 0.0);
|
||||
next.torso.ori = Quaternion::rotation_y(0.25 + 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.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.back.offset = Vec3::new(-6.0, 16.0, 15.0);
|
||||
next.back.ori = Quaternion::rotation_x(2.5);
|
||||
next.back.scale = Vec3::one();
|
||||
|
||||
next
|
||||
|
||||
|
@ -91,6 +91,16 @@ impl FigureCache {
|
||||
None,
|
||||
];
|
||||
|
||||
|
||||
let mut mesh = Mesh::new();
|
||||
bone_meshes
|
||||
.iter()
|
||||
.enumerate()
|
||||
.filter_map(|(i, bm)| bm.as_ref().map(|bm| (i, bm)))
|
||||
.for_each(|(i, bone_mesh)| {
|
||||
mesh.push_mesh_map(bone_mesh, |vert| vert.with_bone_idx(i as u8))
|
||||
});
|
||||
|
||||
let mut mesh = Mesh::new();
|
||||
bone_meshes
|
||||
.iter()
|
||||
@ -126,49 +136,49 @@ impl FigureCache {
|
||||
fn load_head(head: Head) -> Mesh<FigurePipeline> {
|
||||
Self::load_mesh(match head {
|
||||
Head::DefaultHead => "head.vox",
|
||||
}, Vec3::new(-3.5, -7.0, -6.0))
|
||||
}, Vec3::new(-5.5, -7.0, -6.0))
|
||||
}
|
||||
|
||||
fn load_chest(chest: Chest) -> Mesh<FigurePipeline> {
|
||||
Self::load_mesh(match chest {
|
||||
Chest::DefaultChest => "chest.vox",
|
||||
}, Vec3::new(-3.0, -6.0, 0.0))
|
||||
}, Vec3::new(-2.5, -6.0, 0.0))
|
||||
}
|
||||
|
||||
fn load_belt(belt: Belt) -> Mesh<FigurePipeline> {
|
||||
Self::load_mesh(match belt {
|
||||
Belt::DefaultBelt => "belt.vox",
|
||||
}, Vec3::new(-3.0, -5.0, 0.0))
|
||||
}, Vec3::new(-2.5, -5.0, 0.0))
|
||||
}
|
||||
|
||||
fn load_pants(pants: Pants) -> Mesh<FigurePipeline> {
|
||||
Self::load_mesh(match pants {
|
||||
Pants::DefaultPants => "pants.vox",
|
||||
}, Vec3::new(-3.0, -5.0, 0.0))
|
||||
}, Vec3::new(-2.5, -5.0, 0.0))
|
||||
}
|
||||
|
||||
fn load_left_hand(hand: Hand) -> Mesh<FigurePipeline> {
|
||||
Self::load_mesh(match hand {
|
||||
Hand::DefaultHand => "hand.vox",
|
||||
}, Vec3::new(0.0, -2.0, -6.0))
|
||||
}, Vec3::new(0.0, -2.0, -7.0))
|
||||
}
|
||||
|
||||
fn load_right_hand(hand: Hand) -> Mesh<FigurePipeline> {
|
||||
Self::load_mesh(match hand {
|
||||
Hand::DefaultHand => "hand.vox",
|
||||
}, Vec3::new(0.0, -2.0, -6.0))
|
||||
}, Vec3::new(0.0, -2.0, -7.0))
|
||||
}
|
||||
|
||||
fn load_left_foot(foot: Foot) -> Mesh<FigurePipeline> {
|
||||
Self::load_mesh(match foot {
|
||||
Foot::DefaultFoot => "foot.vox",
|
||||
}, Vec3::new(-4.0, -2.5, -6.0))
|
||||
}, Vec3::new(-3.5, -2.5, -8.0))
|
||||
}
|
||||
|
||||
fn load_right_foot(foot: Foot) -> Mesh<FigurePipeline> {
|
||||
Self::load_mesh(match foot {
|
||||
Foot::DefaultFoot => "foot.vox",
|
||||
}, Vec3::new(-4.0, -2.5, -6.0))
|
||||
}, Vec3::new(-3.5, -2.5, -8.0))
|
||||
}
|
||||
|
||||
fn load_weapon(weapon: Weapon) -> Mesh<FigurePipeline> {
|
||||
@ -176,9 +186,10 @@ impl FigureCache {
|
||||
Weapon::Sword => "sword.vox",
|
||||
// TODO actually match against other weapons and set the right model
|
||||
_ => "sword.vox",
|
||||
}, Vec3::new(0.0, 0.0, 0.0))
|
||||
}, Vec3::new(0.0, 0.0, -4.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();
|
||||
|
Loading…
Reference in New Issue
Block a user