mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
velocity tilt
Former-commit-id: 362232bff35784828ee8766e77dadc4e83bf3753
This commit is contained in:
parent
56a8a247cc
commit
bc5074a2b8
@ -1,86 +1,97 @@
|
|||||||
// Standard
|
pub mod run;
|
||||||
use std::f32::consts::PI;
|
pub mod idle;
|
||||||
|
|
||||||
// Library
|
// Reexports
|
||||||
use vek::*;
|
pub use self::run::RunAnimation;
|
||||||
|
pub use self::idle::IdleAnimation;
|
||||||
|
|
||||||
|
// Crate
|
||||||
|
use crate::render::FigureBoneData;
|
||||||
|
|
||||||
// Local
|
// Local
|
||||||
use super::{
|
use super::{
|
||||||
CharacterSkeleton,
|
Skeleton,
|
||||||
super::Animation,
|
Bone,
|
||||||
SCALE
|
|
||||||
};
|
};
|
||||||
|
|
||||||
pub struct RunAnimation;
|
const SCALE: f32 = 11.0;
|
||||||
|
|
||||||
impl Animation for RunAnimation {
|
#[derive(Clone)]
|
||||||
type Skeleton = CharacterSkeleton;
|
pub struct CharacterSkeleton {
|
||||||
type Dependency = f64;
|
head: Bone,
|
||||||
|
chest: Bone,
|
||||||
|
belt: Bone,
|
||||||
|
shorts: Bone,
|
||||||
|
l_hand: Bone,
|
||||||
|
r_hand: Bone,
|
||||||
|
l_foot: Bone,
|
||||||
|
r_foot: Bone,
|
||||||
|
weapon: Bone,
|
||||||
|
torso: Bone,
|
||||||
|
l_shoulder: Bone,
|
||||||
|
r_shoulder: Bone,
|
||||||
|
}
|
||||||
|
|
||||||
fn update_skeleton(
|
impl CharacterSkeleton {
|
||||||
skeleton: &Self::Skeleton,
|
pub fn new() -> Self {
|
||||||
time: f64,
|
Self {
|
||||||
) -> Self::Skeleton {
|
head: Bone::default(),
|
||||||
let mut next = (*skeleton).clone();
|
chest: Bone::default(),
|
||||||
|
belt: Bone::default(),
|
||||||
let wave = (time as f32 * 14.0).sin();
|
shorts: Bone::default(),
|
||||||
let wavetest = (wave.cbrt());
|
l_hand: Bone::default(),
|
||||||
let fuzzwave = (time as f32 * 12.0).sin();
|
r_hand: Bone::default(),
|
||||||
let wavecos = (time as f32 * 14.0).cos();
|
l_foot: Bone::default(),
|
||||||
let wave_slow = (time as f32 * 7.0 + PI).sin();
|
r_foot: Bone::default(),
|
||||||
let wavecos_slow = (time as f32 * 8.0 + PI).cos();
|
weapon: Bone::default(),
|
||||||
let wave_dip = (wave_slow.abs() - 0.5).abs();
|
torso: Bone::default(),
|
||||||
|
l_shoulder: Bone::default(),
|
||||||
next.head.offset = Vec3::new(6.0, 0.0, 12.0 + wavecos * 1.3);
|
r_shoulder: Bone::default(),
|
||||||
next.head.ori = Quaternion::rotation_y(-0.15);
|
|
||||||
next.head.scale = Vec3::one();
|
}
|
||||||
|
}
|
||||||
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();
|
impl Skeleton for CharacterSkeleton {
|
||||||
|
fn compute_matrices(&self) -> [FigureBoneData; 16] {
|
||||||
next.belt.offset = Vec3::new(2.5, 0.0, 6.0 + wavecos * 1.1);
|
let chest_mat = self.chest.compute_base_matrix();
|
||||||
next.belt.ori = Quaternion::rotation_z(wave * 0.25);
|
let torso_mat = self.torso.compute_base_matrix();
|
||||||
next.belt.scale = Vec3::one();
|
[
|
||||||
|
FigureBoneData::new(torso_mat * self.head.compute_base_matrix()),
|
||||||
next.shorts.offset = Vec3::new(2.5, 0.0, 3.0 + wavecos * 1.1);
|
FigureBoneData::new(torso_mat * chest_mat),
|
||||||
next.shorts.ori = Quaternion::rotation_z(wave * 0.6);
|
FigureBoneData::new(torso_mat * self.belt.compute_base_matrix()),
|
||||||
next.shorts.scale = Vec3::one();
|
FigureBoneData::new(torso_mat * self.shorts.compute_base_matrix()),
|
||||||
|
FigureBoneData::new(torso_mat * self.l_hand.compute_base_matrix()),
|
||||||
next.l_hand.offset = Vec3::new(2.0 - wavecos * 2.5, 7.5, 12.0 + wave * 1.5);
|
FigureBoneData::new(torso_mat * self.r_hand.compute_base_matrix()),
|
||||||
next.l_hand.ori = Quaternion::rotation_y(wavecos * 0.9);
|
FigureBoneData::new(torso_mat * self.l_foot.compute_base_matrix()),
|
||||||
next.l_hand.scale = Vec3::one();
|
FigureBoneData::new(torso_mat * self.r_foot.compute_base_matrix()),
|
||||||
|
FigureBoneData::new(torso_mat * chest_mat * self.weapon.compute_base_matrix()),
|
||||||
next.r_hand.offset = Vec3::new(2.0 + wavecos * 2.5, -7.5, 12.0 - wave * 1.5);
|
FigureBoneData::new(torso_mat),
|
||||||
next.r_hand.ori = Quaternion::rotation_y(wavecos * -0.9);
|
//FigureBoneData::new(torso_mat * self.l_shoulder.compute_base_matrix()),
|
||||||
next.r_hand.scale = Vec3::one();
|
//FigureBoneData::new(torso_mat * self.r_shoulder.compute_base_matrix()),
|
||||||
|
FigureBoneData::default(),
|
||||||
next.l_foot.offset = Vec3::new(3.5 + wave * 1.0, 3.4, 6.0);
|
FigureBoneData::default(),
|
||||||
next.l_foot.ori = Quaternion::rotation_y(-0.0 - wave * 1.5);
|
FigureBoneData::default(),
|
||||||
next.l_foot.scale = Vec3::one();
|
FigureBoneData::default(),
|
||||||
|
FigureBoneData::default(),
|
||||||
next.r_foot.offset = Vec3::new(3.5 - wave * 1.0, -3.4, 6.0);
|
FigureBoneData::default(),
|
||||||
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);
|
fn interpolate(&mut self, target: &Self) {
|
||||||
next.weapon.scale = Vec3::one();
|
self.head.interpolate(&target.head);
|
||||||
|
self.chest.interpolate(&target.chest);
|
||||||
next.torso.offset = Vec3::new(0.0, 0.0, 0.0);
|
self.belt.interpolate(&target.belt);
|
||||||
next.torso.ori = Quaternion::rotation_y(0.25 + wavecos * 0.1);
|
self.shorts.interpolate(&target.shorts);
|
||||||
next.torso.scale = Vec3::one() / 11.0;
|
self.l_hand.interpolate(&target.l_hand);
|
||||||
|
self.r_hand.interpolate(&target.r_hand);
|
||||||
next.l_shoulder.offset = Vec3::new(3.0, 6.0, 18.0);
|
self.l_foot.interpolate(&target.l_foot);
|
||||||
next.l_shoulder.ori = Quaternion::rotation_y(0.0);
|
self.r_foot.interpolate(&target.r_foot);
|
||||||
next.l_shoulder.scale = Vec3::one();
|
self.weapon.interpolate(&target.weapon);
|
||||||
|
self.torso.interpolate(&target.torso);
|
||||||
next.r_shoulder.offset = Vec3::new(3.0, -6.0, 18.0);
|
self.l_shoulder.interpolate(&target.l_shoulder);
|
||||||
next.r_shoulder.ori = Quaternion::rotation_y(0.0);
|
self.r_shoulder.interpolate(&target.r_shoulder);
|
||||||
next.r_shoulder.scale = Vec3::one();
|
|
||||||
|
|
||||||
|
|
||||||
next
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -91,6 +91,7 @@ impl FigureCache {
|
|||||||
None,
|
None,
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
||||||
let mut mesh = Mesh::new();
|
let mut mesh = Mesh::new();
|
||||||
bone_meshes
|
bone_meshes
|
||||||
.iter()
|
.iter()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user