mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
glide anim
Former-commit-id: b614a672b0a94f2b8803c0c1c22468b889242cc6
This commit is contained in:
parent
5092df0e7f
commit
50fa3cf098
BIN
assets/voxygen/voxel/glider.vox
(Stored with Git LFS)
Normal file
BIN
assets/voxygen/voxel/glider.vox
(Stored with Git LFS)
Normal file
Binary file not shown.
@ -223,6 +223,7 @@ pub enum Animation {
|
|||||||
Idle,
|
Idle,
|
||||||
Run,
|
Run,
|
||||||
Jump,
|
Jump,
|
||||||
|
Gliding,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Component for AnimationHistory {
|
impl Component for AnimationHistory {
|
||||||
|
@ -81,7 +81,7 @@ impl<'a> System<'a> for Sys {
|
|||||||
Animation::Idle
|
Animation::Idle
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Animation::Jump
|
Animation::Gliding
|
||||||
};
|
};
|
||||||
|
|
||||||
let last_history = anims.get_mut(entity).cloned();
|
let last_history = anims.get_mut(entity).cloned();
|
||||||
|
105
voxygen/src/anim/character/gliding.rs
Normal file
105
voxygen/src/anim/character/gliding.rs
Normal file
@ -0,0 +1,105 @@
|
|||||||
|
// Standard
|
||||||
|
use std::{f32::consts::PI, ops::Mul};
|
||||||
|
|
||||||
|
// Library
|
||||||
|
use vek::*;
|
||||||
|
|
||||||
|
// Local
|
||||||
|
use super::{super::Animation, CharacterSkeleton, SCALE};
|
||||||
|
//
|
||||||
|
|
||||||
|
pub struct GlidingAnimation;
|
||||||
|
|
||||||
|
impl Animation for GlidingAnimation {
|
||||||
|
type Skeleton = CharacterSkeleton;
|
||||||
|
type Dependency = f64;
|
||||||
|
|
||||||
|
fn update_skeleton(
|
||||||
|
skeleton: &Self::Skeleton,
|
||||||
|
global_time: f64,
|
||||||
|
anim_time: f64,
|
||||||
|
) -> Self::Skeleton {
|
||||||
|
let mut next = (*skeleton).clone();
|
||||||
|
let wave = (anim_time as f32 * 14.0).sin();
|
||||||
|
let waveslow = (anim_time as f32 * 7.0).sin();
|
||||||
|
let wavecos_slow = (anim_time as f32 * 7.0).cos();
|
||||||
|
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_stop = (anim_time as f32 * 1.5).min(PI / 2.0).sin();
|
||||||
|
let wave_stopalt = (anim_time as f32 * 5.0).min(PI / 2.0).sin();
|
||||||
|
let waveveryslow = (anim_time as f32 * 3.0).sin();
|
||||||
|
let waveveryslowalt = (anim_time as f32 * 2.5).sin();
|
||||||
|
let waveveryslowcos = (anim_time as f32 * 3.0).cos();
|
||||||
|
|
||||||
|
|
||||||
|
let wave_slowtest = (anim_time as f32).min(PI / 2.0).sin();
|
||||||
|
|
||||||
|
let head_look = Vec2::new(
|
||||||
|
((global_time + anim_time) as f32 / 4.0)
|
||||||
|
.floor()
|
||||||
|
.mul(7331.0)
|
||||||
|
.sin()
|
||||||
|
* 0.5,
|
||||||
|
((global_time + anim_time) as f32 / 4.0)
|
||||||
|
.floor()
|
||||||
|
.mul(1337.0)
|
||||||
|
.sin()
|
||||||
|
* 0.25,
|
||||||
|
);
|
||||||
|
next.head.offset = Vec3::new(5.5, 2.0, 12.0);
|
||||||
|
next.head.ori = Quaternion::rotation_x(0.35 - waveveryslow * 0.10 + head_look.y) * Quaternion::rotation_z(head_look.x + waveveryslowcos * 0.15);
|
||||||
|
next.head.scale = Vec3::one();
|
||||||
|
|
||||||
|
next.chest.offset = Vec3::new(5.5, 0.0, 8.0);
|
||||||
|
next.chest.ori = Quaternion::rotation_z(waveveryslowcos * 0.15);
|
||||||
|
next.chest.scale = Vec3::one();
|
||||||
|
|
||||||
|
next.belt.offset = Vec3::new(5.5, 0.0, 6.0);
|
||||||
|
next.belt.ori = Quaternion::rotation_z(waveveryslowcos * 0.20);
|
||||||
|
next.belt.scale = Vec3::one();
|
||||||
|
|
||||||
|
next.shorts.offset = Vec3::new(5.5, 0.0, 3.0);
|
||||||
|
next.shorts.ori = Quaternion::rotation_z(waveveryslowcos * 0.25);
|
||||||
|
next.shorts.scale = Vec3::one();
|
||||||
|
|
||||||
|
next.l_hand.offset = Vec3::new(-8.0, -10.0 + waveveryslow * 2.5, 18.5 + waveveryslow * 1.0);
|
||||||
|
next.l_hand.ori = Quaternion::rotation_x(0.9 - waveveryslow * 0.10);
|
||||||
|
next.l_hand.scale = Vec3::one();
|
||||||
|
|
||||||
|
next.r_hand.offset = Vec3::new(11.0, -10.0 + waveveryslow * 2.5, 18.5 + waveveryslow * 1.0);
|
||||||
|
next.r_hand.ori = Quaternion::rotation_x(0.9 - waveveryslow * 0.10);
|
||||||
|
next.r_hand.scale = Vec3::one();
|
||||||
|
|
||||||
|
next.l_foot.offset = Vec3::new(-3.4, 1.0, 8.0);
|
||||||
|
next.l_foot.ori = Quaternion::rotation_x(wave_stop * -0.7 - wavecos_slow * -0.21 + waveveryslow * 0.19);
|
||||||
|
next.l_foot.scale = Vec3::one();
|
||||||
|
|
||||||
|
next.r_foot.offset = Vec3::new(3.4, 1.0, 8.0);
|
||||||
|
next.r_foot.ori = Quaternion::rotation_x(wave_stop * -0.8 + waveslow * -0.25 + waveveryslowalt * 0.13);
|
||||||
|
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.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.0);
|
||||||
|
next.torso.ori = Quaternion::rotation_x(-0.8 + waveveryslow * 0.10);
|
||||||
|
next.torso.scale = Vec3::one() / 11.0;
|
||||||
|
|
||||||
|
next.draw.offset = Vec3::new(13.5, 3.0, -1.0);
|
||||||
|
next.draw.ori = Quaternion::rotation_y(waveveryslowcos * 0.05);
|
||||||
|
next.draw.scale = Vec3::one();
|
||||||
|
|
||||||
|
next
|
||||||
|
}
|
||||||
|
}
|
@ -100,9 +100,9 @@ impl Animation for IdleAnimation {
|
|||||||
next.torso.ori = Quaternion::rotation_x(0.0);
|
next.torso.ori = Quaternion::rotation_x(0.0);
|
||||||
next.torso.scale = Vec3::one() / 11.0;
|
next.torso.scale = Vec3::one() / 11.0;
|
||||||
|
|
||||||
next.draw.offset = Vec3::new(0.0, 1.0, -8.0);
|
next.draw.offset = Vec3::new(0.0, 0.0, 0.0);
|
||||||
next.draw.ori = Quaternion::rotation_y(-0.2);
|
next.draw.ori = Quaternion::rotation_y(0.0);
|
||||||
next.draw.scale = Vec3::one();
|
next.draw.scale = Vec3::one() * 0.0;
|
||||||
next
|
next
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -80,6 +80,9 @@ impl Animation for JumpAnimation {
|
|||||||
next.torso.ori = Quaternion::rotation_x(-0.2);
|
next.torso.ori = Quaternion::rotation_x(-0.2);
|
||||||
next.torso.scale = Vec3::one() / 11.0;
|
next.torso.scale = Vec3::one() / 11.0;
|
||||||
|
|
||||||
|
next.draw.offset = Vec3::new(0.0, 0.0, 0.0);
|
||||||
|
next.draw.ori = Quaternion::rotation_y(0.0);
|
||||||
|
next.draw.scale = Vec3::one() * 0.0;
|
||||||
next
|
next
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,11 +1,14 @@
|
|||||||
pub mod idle;
|
pub mod idle;
|
||||||
pub mod jump;
|
pub mod jump;
|
||||||
pub mod run;
|
pub mod run;
|
||||||
|
pub mod gliding;
|
||||||
|
|
||||||
|
|
||||||
// Reexports
|
// Reexports
|
||||||
pub use self::idle::IdleAnimation;
|
pub use self::idle::IdleAnimation;
|
||||||
pub use self::jump::JumpAnimation;
|
pub use self::jump::JumpAnimation;
|
||||||
pub use self::run::RunAnimation;
|
pub use self::run::RunAnimation;
|
||||||
|
pub use self::gliding::GlidingAnimation;
|
||||||
// Crate
|
// Crate
|
||||||
use crate::render::FigureBoneData;
|
use crate::render::FigureBoneData;
|
||||||
|
|
||||||
@ -27,8 +30,8 @@ pub struct CharacterSkeleton {
|
|||||||
weapon: Bone,
|
weapon: Bone,
|
||||||
l_shoulder: Bone,
|
l_shoulder: Bone,
|
||||||
r_shoulder: Bone,
|
r_shoulder: Bone,
|
||||||
torso: Bone,
|
|
||||||
draw: Bone,
|
draw: Bone,
|
||||||
|
torso: Bone,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl CharacterSkeleton {
|
impl CharacterSkeleton {
|
||||||
@ -45,8 +48,8 @@ impl CharacterSkeleton {
|
|||||||
weapon: Bone::default(),
|
weapon: Bone::default(),
|
||||||
l_shoulder: Bone::default(),
|
l_shoulder: Bone::default(),
|
||||||
r_shoulder: Bone::default(),
|
r_shoulder: Bone::default(),
|
||||||
torso: Bone::default(),
|
|
||||||
draw: Bone::default(),
|
draw: Bone::default(),
|
||||||
|
torso: Bone::default(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -68,8 +71,8 @@ impl Skeleton for CharacterSkeleton {
|
|||||||
FigureBoneData::new(torso_mat * chest_mat * self.weapon.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.l_shoulder.compute_base_matrix()),
|
||||||
FigureBoneData::new(torso_mat * chest_mat * self.r_shoulder.compute_base_matrix()),
|
FigureBoneData::new(torso_mat * chest_mat * self.r_shoulder.compute_base_matrix()),
|
||||||
FigureBoneData::new(torso_mat),
|
|
||||||
FigureBoneData::new(torso_mat * l_hand_mat * self.draw.compute_base_matrix()),
|
FigureBoneData::new(torso_mat * l_hand_mat * self.draw.compute_base_matrix()),
|
||||||
|
FigureBoneData::new(torso_mat),
|
||||||
FigureBoneData::default(),
|
FigureBoneData::default(),
|
||||||
FigureBoneData::default(),
|
FigureBoneData::default(),
|
||||||
FigureBoneData::default(),
|
FigureBoneData::default(),
|
||||||
@ -88,7 +91,7 @@ impl Skeleton for CharacterSkeleton {
|
|||||||
self.weapon.interpolate(&target.weapon);
|
self.weapon.interpolate(&target.weapon);
|
||||||
self.l_shoulder.interpolate(&target.l_shoulder);
|
self.l_shoulder.interpolate(&target.l_shoulder);
|
||||||
self.r_shoulder.interpolate(&target.r_shoulder);
|
self.r_shoulder.interpolate(&target.r_shoulder);
|
||||||
self.torso.interpolate(&target.torso);
|
|
||||||
self.draw.interpolate(&target.draw);
|
self.draw.interpolate(&target.draw);
|
||||||
|
self.torso.interpolate(&target.torso);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -76,9 +76,9 @@ impl Animation for RunAnimation {
|
|||||||
next.torso.ori = Quaternion::rotation_x(-velocity * 0.05 - wavecos * 0.1);
|
next.torso.ori = Quaternion::rotation_x(-velocity * 0.05 - wavecos * 0.1);
|
||||||
next.torso.scale = Vec3::one() / 11.0;
|
next.torso.scale = Vec3::one() / 11.0;
|
||||||
|
|
||||||
next.draw.offset = Vec3::new(0.0, 1.0, -8.0);
|
next.draw.offset = Vec3::new(0.0, 0.0, 0.0);
|
||||||
next.draw.ori = Quaternion::rotation_y(-0.2);
|
next.draw.ori = Quaternion::rotation_y(0.0);
|
||||||
next.draw.scale = Vec3::one();
|
next.draw.scale = Vec3::one() * 0.0;
|
||||||
|
|
||||||
next
|
next
|
||||||
}
|
}
|
||||||
|
@ -39,7 +39,7 @@ impl Animation for JumpAnimation {
|
|||||||
next.pigchest.scale = Vec3::one() / 11.0;
|
next.pigchest.scale = Vec3::one() / 11.0;
|
||||||
|
|
||||||
next.piglf_leg.offset = Vec3::new(-4.5, 3.0, 1.5) / 11.0;
|
next.piglf_leg.offset = Vec3::new(-4.5, 3.0, 1.5) / 11.0;
|
||||||
next.piglf_leg.ori = Quaternion::rotation_x(wave_stop * 0.6);
|
next.piglf_leg.ori = Quaternion::rotation_x(wave_stop * 0.6 - wave_slow * 0.3);
|
||||||
next.piglf_leg.scale = Vec3::one() / 11.0;
|
next.piglf_leg.scale = Vec3::one() / 11.0;
|
||||||
|
|
||||||
next.pigrf_leg.offset = Vec3::new(2.5, 3.0, 1.5) / 11.0;
|
next.pigrf_leg.offset = Vec3::new(2.5, 3.0, 1.5) / 11.0;
|
||||||
|
@ -82,7 +82,7 @@ impl PlayState for CharSelectionState {
|
|||||||
.postbox
|
.postbox
|
||||||
.send_message(ClientMsg::Character {
|
.send_message(ClientMsg::Character {
|
||||||
name: self.char_selection_ui.character_name.clone(),
|
name: self.char_selection_ui.character_name.clone(),
|
||||||
body: comp::Body::Quadruped(comp::QuadrupedBody::random()), // comp::Body::Humanoid(self.char_selection_ui.character_body),
|
body: comp::Body::Humanoid(self.char_selection_ui.character_body), //body: comp::Body::Quadruped(comp::QuadrupedBody::random()),
|
||||||
});
|
});
|
||||||
return PlayStateResult::Switch(Box::new(SessionState::new(
|
return PlayStateResult::Switch(Box::new(SessionState::new(
|
||||||
&mut global_state.window,
|
&mut global_state.window,
|
||||||
|
@ -15,7 +15,7 @@ use common::{
|
|||||||
assets,
|
assets,
|
||||||
comp::{
|
comp::{
|
||||||
self,
|
self,
|
||||||
actor::{Belt, Chest, Foot, Hand, Head, Pants, Shoulder, Weapon, Pighead, Pigchest, Pigleg_l, Pigleg_r},
|
actor::{Belt, Chest, Foot, Hand, Head, Pants, Shoulder, Weapon, Draw, Pighead, Pigchest, Pigleg_l, Pigleg_r},
|
||||||
Body, HumanoidBody, QuadrupedBody
|
Body, HumanoidBody, QuadrupedBody
|
||||||
},
|
},
|
||||||
figure::Segment,
|
figure::Segment,
|
||||||
@ -65,7 +65,7 @@ impl FigureModelCache {
|
|||||||
Some(Self::load_weapon(body.weapon)),
|
Some(Self::load_weapon(body.weapon)),
|
||||||
Some(Self::load_left_shoulder(body.shoulder)),
|
Some(Self::load_left_shoulder(body.shoulder)),
|
||||||
Some(Self::load_right_shoulder(body.shoulder)),
|
Some(Self::load_right_shoulder(body.shoulder)),
|
||||||
None,
|
Some(Self::load_draw(body.draw)),
|
||||||
None,
|
None,
|
||||||
None,
|
None,
|
||||||
None,
|
None,
|
||||||
@ -226,17 +226,17 @@ impl FigureModelCache {
|
|||||||
Vec3::new(2.5, 0.0, 0.0),
|
Vec3::new(2.5, 0.0, 0.0),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
// fn load_draw(draw: Draw) -> Mesh<FigurePipeline> {
|
fn load_draw(draw: Draw) -> Mesh<FigurePipeline> {
|
||||||
// Self::load_mesh(
|
Self::load_mesh(
|
||||||
// match draw {
|
match draw {
|
||||||
// //Draw::DefaultDraw => "sword.vox",
|
Draw::Default => "glider.vox",
|
||||||
//
|
|
||||||
// },
|
},
|
||||||
// Vec3::new(0.0, 0.0, -2.0)
|
Vec3::new(-26.0, -26.0, -5.0)
|
||||||
//
|
|
||||||
//
|
|
||||||
// )
|
)
|
||||||
// }
|
}
|
||||||
|
|
||||||
fn load_pighead(pighead: Pighead) -> Mesh<FigurePipeline> {
|
fn load_pighead(pighead: Pighead) -> Mesh<FigurePipeline> {
|
||||||
Self::load_mesh(
|
Self::load_mesh(
|
||||||
@ -350,6 +350,11 @@ impl FigureMgr {
|
|||||||
time,
|
time,
|
||||||
animation_history.time,
|
animation_history.time,
|
||||||
),
|
),
|
||||||
|
comp::Animation::Gliding => character::GlidingAnimation::update_skeleton(
|
||||||
|
state.skeleton_mut(),
|
||||||
|
time,
|
||||||
|
animation_history.time,
|
||||||
|
),
|
||||||
};
|
};
|
||||||
|
|
||||||
state.skeleton.interpolate(&target_skeleton);
|
state.skeleton.interpolate(&target_skeleton);
|
||||||
@ -377,6 +382,7 @@ impl FigureMgr {
|
|||||||
(vel.0.magnitude(), time),
|
(vel.0.magnitude(), time),
|
||||||
animation_history.time,
|
animation_history.time,
|
||||||
),
|
),
|
||||||
|
|
||||||
// TODO!
|
// TODO!
|
||||||
_ => state.skeleton_mut().clone(),
|
_ => state.skeleton_mut().clone(),
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user