mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Merge branch 'slipped/animtweaks' into 'master'
look-anims, first experiments (bow, staff, wield) See merge request veloren/veloren!1826
This commit is contained in:
commit
04c698be5e
@ -34,7 +34,7 @@ impl Animation for ShootAnimation {
|
||||
velocity,
|
||||
orientation,
|
||||
last_ori,
|
||||
_look_dir,
|
||||
look_dir,
|
||||
_global_time,
|
||||
stage_section,
|
||||
): Self::Dependency,
|
||||
@ -65,7 +65,7 @@ impl Animation for ShootAnimation {
|
||||
Some(ToolKind::Staff) | Some(ToolKind::Sceptre) => {
|
||||
let (move1, move2, move3) = match stage_section {
|
||||
Some(StageSection::Buildup) => (anim_time as f32, 0.0, 0.0),
|
||||
Some(StageSection::Swing) => (1.0, (anim_time as f32).powf(0.25), 0.0),
|
||||
Some(StageSection::Shoot) => (1.0, (anim_time as f32).powf(0.25), 0.0),
|
||||
Some(StageSection::Recover) => (1.0, 1.0, anim_time as f32),
|
||||
_ => (0.0, 0.0, 0.0),
|
||||
};
|
||||
@ -84,10 +84,10 @@ impl Animation for ShootAnimation {
|
||||
next.control.position = Vec3::new(
|
||||
s_a.stc.0 + (xmove * 3.0 + move1 * -4.0) * (1.0 - move3),
|
||||
s_a.stc.1 + (2.0 + ymove * 3.0 + move2 * 3.0) * (1.0 - move3),
|
||||
s_a.stc.2,
|
||||
s_a.stc.2 + look_dir.z * 4.0,
|
||||
);
|
||||
next.control.orientation =
|
||||
Quaternion::rotation_x(s_a.stc.3 + (move2 * 0.6) * (1.0 - move3))
|
||||
Quaternion::rotation_x(look_dir.z + s_a.stc.3 + (move2 * 0.6) * (1.0 - move3))
|
||||
* Quaternion::rotation_y(s_a.stc.4 + (move1 * 0.5 + move2 * -0.5))
|
||||
* Quaternion::rotation_z(
|
||||
s_a.stc.5 - (0.2 + move1 * -0.5 + move2 * 0.8) * (1.0 - move3),
|
||||
@ -95,9 +95,10 @@ impl Animation for ShootAnimation {
|
||||
next.chest.orientation =
|
||||
Quaternion::rotation_z((move1 * 0.3 + move2 * 0.2) * (1.0 - move3));
|
||||
next.head.position = Vec3::new(0.0, s_a.head.0, s_a.head.1);
|
||||
next.head.orientation = Quaternion::rotation_z(
|
||||
tilt * -2.5 + (move1 * -0.2 + move2 * -0.4) * (1.0 - move3),
|
||||
);
|
||||
next.head.orientation = Quaternion::rotation_x(look_dir.z * 0.7)
|
||||
* Quaternion::rotation_z(
|
||||
tilt * -2.5 + (move1 * -0.2 + move2 * -0.4) * (1.0 - move3),
|
||||
);
|
||||
|
||||
if speed < 0.5 {
|
||||
next.belt.orientation =
|
||||
@ -118,18 +119,19 @@ impl Animation for ShootAnimation {
|
||||
Some(ToolKind::Bow) => {
|
||||
let (_move1, move2, _move3) = match stage_section {
|
||||
Some(StageSection::Buildup) => ((anim_time as f32).powf(0.25), 0.0, 0.0),
|
||||
Some(StageSection::Swing) => (1.0, anim_time as f32, 0.0),
|
||||
Some(StageSection::Shoot) => (1.0, anim_time as f32, 0.0),
|
||||
Some(StageSection::Recover) => (1.0, 1.0, (anim_time as f32).powi(4)),
|
||||
_ => (0.0, 0.0, 0.0),
|
||||
};
|
||||
next.main.position = Vec3::new(0.0, 0.0, 0.0);
|
||||
next.main.orientation = Quaternion::rotation_x(0.0);
|
||||
next.hand_l.position = Vec3::new(
|
||||
s_a.bhl.0 + move2 * -2.0,
|
||||
s_a.bhl.1 + move2 * -6.0,
|
||||
s_a.bhl.2 + move2 * -3.0,
|
||||
s_a.bhl.0 + move2 * -8.0,
|
||||
s_a.bhl.1 + move2 * -10.0,
|
||||
s_a.bhl.2,
|
||||
);
|
||||
next.hand_l.orientation = Quaternion::rotation_x(s_a.bhl.3);
|
||||
next.hand_l.orientation =
|
||||
Quaternion::rotation_x(s_a.bhl.3) * Quaternion::rotation_y(move2 * 0.7);
|
||||
next.hand_r.position = Vec3::new(s_a.bhr.0, s_a.bhr.1, s_a.bhr.2);
|
||||
next.hand_r.orientation = Quaternion::rotation_x(s_a.bhr.3);
|
||||
|
||||
@ -137,25 +139,25 @@ impl Animation for ShootAnimation {
|
||||
next.hold.orientation = Quaternion::rotation_x(-1.57);
|
||||
next.hold.scale = Vec3::one() * 1.0 * (1.0 - move2);
|
||||
|
||||
next.control.position = Vec3::new(s_a.bc.0 + 11.0, s_a.bc.1 + 2.0, s_a.bc.2 + 8.0);
|
||||
next.control.orientation = Quaternion::rotation_x(0.0 + (move2 as f32 * 0.1).sin())
|
||||
* Quaternion::rotation_y(s_a.bc.4 - 1.25)
|
||||
* Quaternion::rotation_z(s_a.bc.5 - 0.2 + (move2 as f32 * -0.2).sin());
|
||||
next.chest.orientation = Quaternion::rotation_z(0.8);
|
||||
next.control.position = Vec3::new(
|
||||
s_a.bc.0 + 11.0 + move2 * 2.0,
|
||||
s_a.bc.1 + 2.0 + (look_dir.z * -5.0).min(-2.0) + move2 * -1.0,
|
||||
s_a.bc.2 + 8.0 + (look_dir.z * 15.0).max(-8.0),
|
||||
);
|
||||
next.control.orientation = Quaternion::rotation_x(look_dir.z + move2 * -0.0)
|
||||
* Quaternion::rotation_y(-look_dir.z + s_a.bc.4 - 1.25 + move2 * -0.0)
|
||||
* Quaternion::rotation_z(s_a.bc.5 - 0.2 + move2 * -0.1);
|
||||
next.chest.orientation = Quaternion::rotation_z(0.8 + move2 * 0.5);
|
||||
next.head.position = Vec3::new(0.0 - 2.0, s_a.head.0, s_a.head.1);
|
||||
|
||||
next.head.orientation =
|
||||
Quaternion::rotation_z(tilt * -2.5 - 0.5 + (move2 as f32 * 0.2).sin());
|
||||
next.head.orientation = Quaternion::rotation_x(look_dir.z * 0.7)
|
||||
* Quaternion::rotation_z(tilt * -2.5 - 0.5 + (move2 as f32 * -0.2).sin());
|
||||
next.chest.orientation = Quaternion::rotation_z(0.8 + move2 * 0.2);
|
||||
next.belt.orientation = Quaternion::rotation_z(move2 * 0.3);
|
||||
next.shorts.orientation = Quaternion::rotation_z(move2 * 0.5);
|
||||
next.shoulder_l.orientation = Quaternion::rotation_x(move2 * 0.5);
|
||||
|
||||
if speed < 0.5 {
|
||||
next.chest.orientation =
|
||||
Quaternion::rotation_z(0.8 + (move2 as f32 * 0.1).sin());
|
||||
|
||||
next.belt.orientation = Quaternion::rotation_x(0.07)
|
||||
* Quaternion::rotation_z((move2 as f32 * -0.1).sin());
|
||||
|
||||
next.shorts.orientation = Quaternion::rotation_x(0.08)
|
||||
* Quaternion::rotation_z((move2 as f32 * -0.15).sin());
|
||||
|
||||
next.foot_l.position = Vec3::new(-s_a.foot.0, s_a.foot.1 - 5.0, s_a.foot.2);
|
||||
next.foot_l.orientation = Quaternion::rotation_x(-0.5);
|
||||
|
||||
|
@ -2,13 +2,13 @@ use super::{
|
||||
super::{vek::*, Animation},
|
||||
CharacterSkeleton, SkeletonAttr,
|
||||
};
|
||||
use common::comp::item::ToolKind;
|
||||
use common::{comp::item::ToolKind, util::Dir};
|
||||
use std::f32::consts::PI;
|
||||
|
||||
pub struct TalkAnimation;
|
||||
|
||||
impl Animation for TalkAnimation {
|
||||
type Dependency = (Option<ToolKind>, Option<ToolKind>, f32, f64);
|
||||
type Dependency = (Option<ToolKind>, Option<ToolKind>, f32, f64, Dir);
|
||||
type Skeleton = CharacterSkeleton;
|
||||
|
||||
#[cfg(feature = "use-dyn-lib")]
|
||||
@ -18,7 +18,7 @@ impl Animation for TalkAnimation {
|
||||
#[allow(clippy::approx_constant)] // TODO: Pending review in #587
|
||||
fn update_skeleton_inner(
|
||||
skeleton: &Self::Skeleton,
|
||||
(_active_tool_kind, _second_tool_kind, _velocity, _global_time): Self::Dependency,
|
||||
(_active_tool_kind, _second_tool_kind, _velocity, _global_time, look_dir): Self::Dependency,
|
||||
anim_time: f64,
|
||||
rate: &mut f32,
|
||||
s_a: &SkeletonAttr,
|
||||
@ -30,7 +30,7 @@ impl Animation for TalkAnimation {
|
||||
let slowb = (anim_time as f32 * 4.0 + PI / 2.0).sin();
|
||||
let slowc = (anim_time as f32 * 12.0 + PI / 2.0).sin();
|
||||
|
||||
next.head.orientation = Quaternion::rotation_x(slowc * 0.035);
|
||||
next.head.orientation = Quaternion::rotation_x(slowc * 0.035 + look_dir.z * 0.7);
|
||||
next.hand_l.position = Vec3::new(
|
||||
-s_a.hand.0 + 0.5 + slowb * 0.5,
|
||||
s_a.hand.1 + 5.0 + slowc * 1.0,
|
||||
|
@ -2,7 +2,7 @@ use super::{
|
||||
super::{vek::*, Animation},
|
||||
CharacterSkeleton, SkeletonAttr,
|
||||
};
|
||||
use common::comp::item::ToolKind;
|
||||
use common::{comp::item::ToolKind, util::Dir};
|
||||
use std::{f32::consts::PI, ops::Mul};
|
||||
|
||||
pub struct WieldAnimation;
|
||||
@ -12,6 +12,7 @@ type WieldAnimationDependency = (
|
||||
Option<ToolKind>,
|
||||
Vec3<f32>,
|
||||
Vec3<f32>,
|
||||
Dir,
|
||||
Vec3<f32>,
|
||||
f64,
|
||||
);
|
||||
@ -26,7 +27,15 @@ impl Animation for WieldAnimation {
|
||||
#[allow(clippy::approx_constant)] // TODO: Pending review in #587
|
||||
fn update_skeleton_inner(
|
||||
skeleton: &Self::Skeleton,
|
||||
(active_tool_kind, _second_tool_kind, orientation, last_ori, velocity, global_time): Self::Dependency,
|
||||
(
|
||||
active_tool_kind,
|
||||
_second_tool_kind,
|
||||
orientation,
|
||||
last_ori,
|
||||
look_dir,
|
||||
velocity,
|
||||
global_time,
|
||||
): Self::Dependency,
|
||||
anim_time: f64,
|
||||
rate: &mut f32,
|
||||
s_a: &SkeletonAttr,
|
||||
@ -94,7 +103,9 @@ impl Animation for WieldAnimation {
|
||||
* Quaternion::rotation_x(((direction * 0.8).min(0.3)) * (1.0 - tilt.abs()));
|
||||
next.head.orientation =
|
||||
Quaternion::rotation_z(tilt * -0.5 + strafe * 0.4 * direction + strafe * -0.7)
|
||||
* Quaternion::rotation_x((0.3 - direction * 0.4) * (1.0 - tilt.abs()));
|
||||
* Quaternion::rotation_x(
|
||||
(0.3 - direction * 0.4) * (1.0 - tilt.abs()) + look_dir.z * 0.7,
|
||||
);
|
||||
|
||||
next.chest.position = Vec3::new(
|
||||
0.0 + short * strafe,
|
||||
@ -103,15 +114,13 @@ impl Animation for WieldAnimation {
|
||||
);
|
||||
} else {
|
||||
next.head.position = Vec3::new(0.0, 0.0 + s_a.head.0, s_a.head.1 + u_slow * 0.1);
|
||||
next.head.orientation =
|
||||
Quaternion::rotation_z(head_look.x) * Quaternion::rotation_x(head_look.y.abs());
|
||||
next.head.orientation = Quaternion::rotation_z(head_look.x + tilt * -0.75)
|
||||
* Quaternion::rotation_x(head_look.y.abs() + look_dir.z * 0.7);
|
||||
|
||||
next.chest.position =
|
||||
Vec3::new(0.0 + slowalt * 0.5, s_a.chest.0, s_a.chest.1 + u_slow * 0.5);
|
||||
next.belt.orientation = Quaternion::rotation_z(0.15 + beltstatic * tilt * 0.1);
|
||||
|
||||
next.head.orientation = Quaternion::rotation_z(tilt * -0.75);
|
||||
|
||||
next.shorts.orientation = Quaternion::rotation_z(0.3 + beltstatic * tilt * 0.2);
|
||||
next.torso.orientation = Quaternion::rotation_z(tilt * 0.4);
|
||||
|
||||
@ -193,7 +202,7 @@ impl Animation for WieldAnimation {
|
||||
next.head.position =
|
||||
Vec3::new(0.0, 0.0 + s_a.head.0, s_a.head.1 + u_slow * 0.1);
|
||||
next.head.orientation = Quaternion::rotation_z(head_look.x)
|
||||
* Quaternion::rotation_x(0.35 + head_look.y.abs());
|
||||
* Quaternion::rotation_x(0.35 + head_look.y.abs() + look_dir.z * 0.7);
|
||||
next.chest.orientation = Quaternion::rotation_x(-0.35)
|
||||
* Quaternion::rotation_y(u_slowalt * 0.04)
|
||||
* Quaternion::rotation_z(0.15);
|
||||
@ -309,7 +318,7 @@ impl Animation for WieldAnimation {
|
||||
Some(ToolKind::Farming) => {
|
||||
if speed < 0.5 {
|
||||
next.head.orientation = Quaternion::rotation_z(head_look.x)
|
||||
* Quaternion::rotation_x(-0.2 + head_look.y.abs());
|
||||
* Quaternion::rotation_x(-0.2 + head_look.y.abs() + look_dir.z * 0.7);
|
||||
}
|
||||
next.hand_l.position = Vec3::new(9.0, 1.0, 1.0);
|
||||
next.hand_l.orientation = Quaternion::rotation_x(1.57);
|
||||
|
@ -1338,7 +1338,13 @@ impl FigureMgr {
|
||||
},
|
||||
CharacterState::Talk => anim::character::TalkAnimation::update_skeleton(
|
||||
&target_base,
|
||||
(active_tool_kind, second_tool_kind, vel.0.magnitude(), time),
|
||||
(
|
||||
active_tool_kind,
|
||||
second_tool_kind,
|
||||
vel.0.magnitude(),
|
||||
time,
|
||||
look_dir,
|
||||
),
|
||||
state.state_time,
|
||||
&mut state_animation_rate,
|
||||
skeleton_attr,
|
||||
@ -1361,6 +1367,7 @@ impl FigureMgr {
|
||||
// TODO: Update to use the quaternion.
|
||||
ori * anim::vek::Vec3::<f32>::unit_y(),
|
||||
state.last_ori * anim::vek::Vec3::<f32>::unit_y(),
|
||||
look_dir,
|
||||
vel.0,
|
||||
time,
|
||||
),
|
||||
|
Loading…
Reference in New Issue
Block a user