Improved wielding animation

This commit is contained in:
Joshua Barretto 2023-10-12 14:18:54 +01:00
parent d52f3af727
commit 1c6aa4a53e
5 changed files with 58 additions and 54 deletions

View File

@ -69,6 +69,7 @@ impl Animation for ChargeswingAnimation {
Quaternion::rotation_x(s_a.shl.3) * Quaternion::rotation_y(s_a.shl.4);
next.hand_r.position =
Vec3::new(-s_a.sc.0 + 6.0 + move1 * -12.0, -4.0 + move1 * 3.0, -2.0);
next.hand_r.orientation = Quaternion::rotation_x(PI * 0.5);
next.control.position = Vec3::new(s_a.sc.0, s_a.sc.1, s_a.sc.2 + move2 * 5.0);
next.control.orientation = Quaternion::rotation_x(s_a.sc.3 + move1 * -0.9)
* Quaternion::rotation_y(move1 * 1.0 + move2 * -1.0)

View File

@ -230,7 +230,7 @@ impl Animation for FinisherMeleeAnimation {
let move2_reset = ((move2 - 0.5).abs() - 0.5).abs() * 2.0;
let move2 = move2 * pullback;
next.hand_l.position = Vec3::new(s_a.ahl.0, s_a.ahl.1, s_a.ahl.2);
next.hand_l.position = Vec3::new(s_a.ahl.0, s_a.ahl.1, s_a.ahl.2 + 10.0);
next.hand_l.orientation =
Quaternion::rotation_x(s_a.ahl.3) * Quaternion::rotation_y(s_a.ahl.4);
next.hand_r.position = Vec3::new(s_a.ahr.0, s_a.ahr.1, s_a.ahr.2);

View File

@ -120,11 +120,10 @@ impl Animation for RunAnimation {
s_a.chest.0,
s_a.chest.1 + 1.0 * speednorm + shortalt * 1.1,
);
next.chest.orientation = Quaternion::rotation_z(short * 0.4 + tilt * -0.6)
* Quaternion::rotation_y(tilt * 1.6 + short * 0.2)
* Quaternion::rotation_x(
impact * 0.06 + shortalt2 * 0.03 + speednorm * -0.5 + (tilt.abs()),
);
next.chest.orientation = Quaternion::rotation_x(impact * 0.07)
* Quaternion::rotation_z(short * 0.4 + tilt * -0.6)
* Quaternion::rotation_y(tilt * 2.0 + short * 0.2)
* Quaternion::rotation_x(shortalt2 * 0.03 + speednorm * -0.5 + tilt.abs());
next.belt.position = Vec3::new(0.0, 0.25 + s_a.belt.0, 0.25 + s_a.belt.1);
next.belt.orientation = Quaternion::rotation_x(0.1 * speednorm)

View File

@ -60,18 +60,20 @@ impl Animation for SitAnimation {
next.shorts.orientation = Quaternion::rotation_x(stop * 0.6);
next.hand_l.position = Vec3::new(
-s_a.hand.0,
-s_a.hand.0 - 1.0,
s_a.hand.1 + slowa * 0.15,
s_a.hand.2 + slow * 0.7 + stop * -2.0,
s_a.hand.2 + slow * 0.7 + stop * -2.0 - 1.0,
);
next.hand_l.orientation = Quaternion::rotation_x(slowa * -0.1 + slow * 0.1);
next.hand_l.orientation =
Quaternion::rotation_x(slowa * -0.1 + slow * 0.1) * Quaternion::rotation_y(PI * 0.15);
next.hand_r.position = Vec3::new(
s_a.hand.0,
s_a.hand.0 + 1.0,
s_a.hand.1 + slowa * 0.15,
s_a.hand.2 + slow * 0.7 + stop * -2.0,
s_a.hand.2 + slow * 0.7 + stop * -2.0 - 1.0,
);
next.hand_r.orientation = Quaternion::rotation_x(slow * -0.1 + slowa * 0.1);
next.hand_r.orientation =
Quaternion::rotation_x(slow * -0.1 + slowa * 0.1) * Quaternion::rotation_y(PI * -0.15);
next.foot_l.position = Vec3::new(-s_a.foot.0, 4.0 + s_a.foot.1, 3.0 + s_a.foot.2);
next.foot_l.orientation = Quaternion::rotation_x(slow * 0.1 + stop * 1.2 + slow * 0.1);

View File

@ -71,7 +71,7 @@ impl Animation for WieldAnimation {
let u_slowalt = (anim_time * 5.0 + PI).cos();
let short = ((5.0 / (1.5 + 3.5 * ((anim_time * lab * 16.0).sin()).powi(2))).sqrt())
* ((anim_time * lab * 16.0).sin());
* ((anim_time * lab * 16.0 + PI * 0.5).sin());
let direction = velocity.y * -0.098 * orientation.y + velocity.x * -0.098 * orientation.x;
let side = velocity.x * -0.098 * orientation.y + velocity.y * 0.098 * orientation.x;
let strafe = -((1.0 / (direction).abs() - 1.0).min(1.0)).copysign(side);
@ -100,24 +100,16 @@ impl Animation for WieldAnimation {
next.main.orientation = Quaternion::rotation_z(0.0);
next.second.position = Vec3::new(0.0, 0.0, 0.0);
next.second.orientation = Quaternion::rotation_z(0.0);
if speed > 0.2 && velocity.z == 0.0 {
next.chest.orientation = Quaternion::rotation_z(short * 0.1 + strafe * 0.7 * speednorm)
* Quaternion::rotation_y(strafe * 0.2)
* Quaternion::rotation_x(((direction * 0.4).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.1) * (1.0 - tilt.abs()) + look_dir.z * 0.7,
);
next.chest.position =
Vec3::new(short * strafe, s_a.chest.0, s_a.chest.1 + shortalt * -1.5);
} else {
let is_moving = speed > 0.2 && velocity.z == 0.0;
if !is_moving {
next.head.position = Vec3::new(0.0, s_a.head.0, s_a.head.1 + u_slow * 0.1);
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(slowalt * 0.5, s_a.chest.0, s_a.chest.1 + u_slow * 0.5);
next.chest.position =
Vec3::new(slowalt * 0.2, s_a.chest.0, s_a.chest.1 + u_slow * 0.35);
next.belt.orientation = Quaternion::rotation_z(0.15 + beltstatic * tilt * 0.1);
next.shorts.orientation = Quaternion::rotation_z(0.3 + beltstatic * tilt * 0.2);
@ -147,29 +139,30 @@ impl Animation for WieldAnimation {
next.belt.position = Vec3::new(0.0, s_a.belt.0, s_a.belt.1);
next.back.orientation = Quaternion::rotation_x(-0.2);
// next.back.orientation = Quaternion::rotation_x(-0.2);
next.shorts.position = Vec3::new(0.0, s_a.shorts.0, s_a.shorts.1);
}
match (hands, active_tool_kind, second_tool_kind) {
((Some(Hands::Two), _), tool, _) | ((None, Some(Hands::Two)), _, tool) => match tool {
Some(ToolKind::Sword) => {
next.hand_l.position = Vec3::new(s_a.shl.0, s_a.shl.1, s_a.shl.2);
next.control_l.position = next.hand_l.position * 0.2
+ Vec3::new(
s_a.sc.0,
s_a.sc.1 - slow * 2.0 * speednorm,
s_a.sc.2 + direction * -5.0 - slow * 2.0 * speednorm,
);
next.control_r.position = next.control_l.position;
next.hand_l.position = Vec3::new(s_a.shl.0 - 0.5, s_a.shl.1, s_a.shl.2);
next.hand_l.orientation =
Quaternion::rotation_x(s_a.shl.3) * Quaternion::rotation_y(s_a.shl.4);
next.hand_r.position = Vec3::new(
foothoril * 1.3 * speednorm - s_a.sc.0 + 6.0,
speednorm + foothoril * -3.0 * speednorm - 4.0,
-1.0 * speednorm - foothoril * 5.5 * speednorm - 2.0,
);
next.hand_r.orientation =
Quaternion::rotation_x(
0.6 * speednorm + (footrotl * -1.2) * speednorm + 0.9,
) * Quaternion::rotation_y(footrotl * -0.4 * speednorm);
next.control.position =
Vec3::new(s_a.sc.0, s_a.sc.1, s_a.sc.2 + direction * -5.0);
next.control.orientation = Quaternion::rotation_x(s_a.sc.3 + u_slow * 0.15)
next.control_l.orientation = Quaternion::rotation_x(s_a.sc.3 + u_slow * 0.05)
* Quaternion::rotation_z(u_slowalt * 0.04);
next.control_r.orientation = Quaternion::rotation_x(s_a.sc.3 + u_slow * 0.15)
* Quaternion::rotation_z(u_slowalt * 0.08);
next.hand_r.position = Vec3::zero();
next.hand_r.orientation =
next.hand_l.orientation * Quaternion::rotation_y(PI * 0.3);
//carried position
/*
next.hand_l.position = Vec3::new(s_a.shl.0, s_a.shl.1, s_a.shl.2);
@ -542,21 +535,29 @@ impl Animation for WieldAnimation {
};
match hands {
(Some(Hands::One), _) => {
next.control_l.position = Vec3::new(-7.0, 8.0, 2.0);
next.control_l.orientation =
Quaternion::rotation_x(-0.3) * Quaternion::rotation_y(0.2);
next.hand_l.position = Vec3::new(0.0, -0.5, 0.0);
next.hand_l.orientation = Quaternion::rotation_x(PI / 2.0)
next.control_l.position =
next.hand_l.position * Vec3::new(0.5, 0.5, 0.3) + Vec3::new(-4.0, 0.0, 0.0);
next.control_l.orientation = Quaternion::lerp(
next.hand_l.orientation,
Quaternion::rotation_x(PI * -0.5),
0.65,
);
next.hand_l.position = Vec3::new(0.0, -2.0, 0.0);
next.hand_l.orientation = Quaternion::rotation_x(PI * 0.5);
},
(_, _) => {},
};
match hands {
(None | Some(Hands::One), Some(Hands::One)) => {
next.control_r.position = Vec3::new(7.0, 8.0, 2.0);
next.control_r.orientation =
Quaternion::rotation_x(-0.3) * Quaternion::rotation_y(-0.2);
next.hand_r.position = Vec3::new(0.0, -0.5, 0.0);
next.hand_r.orientation = Quaternion::rotation_x(PI / 2.0)
next.control_r.position =
next.hand_r.position * Vec3::new(0.5, 0.5, 0.3) + Vec3::new(4.0, 0.0, 0.0);
next.control_r.orientation = Quaternion::lerp(
next.hand_r.orientation,
Quaternion::rotation_x(PI * -0.5),
0.65,
);
next.hand_r.position = Vec3::new(0.0, -2.0, 0.0);
next.hand_r.orientation = Quaternion::rotation_x(PI * 0.5);
},
(_, _) => {},
};
@ -570,9 +571,10 @@ impl Animation for WieldAnimation {
};
match hands {
(None, None) | (Some(Hands::One), None) => {
next.hand_r.position = Vec3::new(8.0, 2.0, 1.0);
next.hand_r.orientation =
Quaternion::rotation_x(0.5) * Quaternion::rotation_y(-0.25);
// next.hand_r.position = Vec3::new(8.0, 2.0, 1.0);
// next.hand_r.orientation =
// Quaternion::rotation_x(0.5) *
// Quaternion::rotation_y(-0.25);
},
(_, _) => {},
};