fixed swimming, better charge

This commit is contained in:
jshipsey 2020-03-25 01:22:07 -04:00
parent a6537ed69b
commit 047f6b8a01
10 changed files with 134 additions and 345 deletions

View File

@ -34,9 +34,9 @@ impl Animation for AttackAnimation {
let decel = (anim_time as f32 * 16.0 * lab as f32).min(PI / 2.0).sin();
let slow = (((5.0)
/ (1.1 + 3.9 * ((anim_time as f32 * lab as f32 * 12.4).sin()).powf(2.0 as f32)))
/ (0.6 + 4.4 * ((anim_time as f32 * lab as f32 * 11.0).sin()).powf(2.0 as f32)))
.sqrt())
* ((anim_time as f32 * lab as f32 * 12.4).sin());
* ((anim_time as f32 * lab as f32 * 11.0).sin());
let slower = (((5.0)
/ (0.1 + 4.9 * ((anim_time as f32 * lab as f32 * 4.0).sin()).powf(2.0 as f32)))
.sqrt())
@ -462,11 +462,9 @@ impl Animation for AttackAnimation {
next.head.offset = Vec3::new(
0.0 + skeleton_attr.neck_right,
-2.0 + skeleton_attr.neck_forward + decel * 0.8,
skeleton_attr.neck_height + 21.0,
skeleton_attr.neck_height + 14.0,
);
next.head.ori = Quaternion::rotation_z(decel * 0.25)
* Quaternion::rotation_x(0.0 + decel * 0.1)
* Quaternion::rotation_y(decel * -0.1);
next.head.ori = Quaternion::rotation_x(0.0);
next.head.scale = Vec3::one() * skeleton_attr.head_scale;
next.chest.offset = Vec3::new(0.0, 0.0, 7.0);
@ -475,17 +473,14 @@ impl Animation for AttackAnimation {
* Quaternion::rotation_y(decel * 0.2);
next.chest.scale = Vec3::one();
next.belt.offset = Vec3::new(0.0, 0.0, 5.0);
next.belt.ori = Quaternion::rotation_z(decel * -0.1)
* Quaternion::rotation_x(0.0 + decel * -0.1)
* Quaternion::rotation_y(decel * 0.1);
next.belt.offset = Vec3::new(0.0, 0.0, -2.0);
next.belt.ori = Quaternion::rotation_x(0.0);
next.belt.scale = Vec3::one();
next.shorts.offset = Vec3::new(0.0, 0.0, 2.0);
next.belt.ori = Quaternion::rotation_z(decel * -0.08)
* Quaternion::rotation_x(0.0 + decel * -0.08)
* Quaternion::rotation_y(decel * 0.08);
next.shorts.offset = Vec3::new(0.0, 0.0, -5.0);
next.belt.ori = Quaternion::rotation_x(0.0);
next.shorts.scale = Vec3::one();
next.l_hand.offset =
Vec3::new(-8.0 + accel_slow * 10.0, 8.0 + accel_fast * 3.0, 0.0);
next.l_hand.ori = Quaternion::rotation_z(-0.8)

View File

@ -24,23 +24,20 @@ impl Animation for ChargeAnimation {
let lab = 1.0;
let foot = (((5.0)
/ (1.1 + 3.9 * ((anim_time as f32 * lab as f32 * 15.0).sin()).powf(2.0 as f32)))
/ (1.1 + 3.9 * ((anim_time as f32 * lab as f32 * 25.0).sin()).powf(2.0 as f32)))
.sqrt())
* ((anim_time as f32 * lab as f32 * 15.0).sin());
* ((anim_time as f32 * lab as f32 * 25.0).sin());
let slow = (((5.0)
/ (1.1 + 3.9 * ((anim_time as f32 * lab as f32 * 12.4).sin()).powf(2.0 as f32)))
.sqrt())
* ((anim_time as f32 * lab as f32 * 12.4).sin());
let wave_cos = (((5.0)
/ (1.1 + 3.9 * ((anim_time as f32 * constant as f32 * 2.4).sin()).powf(2.0 as f32)))
.sqrt())
* ((anim_time as f32 * constant as f32 * 1.5).sin());
match active_tool_kind {
//TODO: Inventory
Some(ToolKind::Sword(_)) => {
@ -58,12 +55,12 @@ impl Animation for ChargeAnimation {
next.chest.ori = Quaternion::rotation_x(-0.7) * Quaternion::rotation_z(-0.9);
next.chest.scale = Vec3::one();
next.belt.offset = Vec3::new(0.0, 0.0, -2.0);
next.belt.ori = Quaternion::rotation_x(0.1) * Quaternion::rotation_z(0.0);
next.belt.offset = Vec3::new(0.0, 1.0, -1.0);
next.belt.ori = Quaternion::rotation_x(0.2) * Quaternion::rotation_z(0.2);
next.belt.scale = Vec3::one();
next.shorts.offset = Vec3::new(0.0, 0.0, -5.0);
next.shorts.ori = Quaternion::rotation_x(0.2) * Quaternion::rotation_z(0.0);
next.shorts.offset = Vec3::new(0.0, 3.0, -3.0);
next.shorts.ori = Quaternion::rotation_x(0.4) * Quaternion::rotation_z(0.3);
next.shorts.scale = Vec3::one();
next.l_hand.offset = Vec3::new(0.0, 1.0, 0.0);
@ -78,19 +75,18 @@ impl Animation for ChargeAnimation {
* Quaternion::rotation_z(0.0);
next.main.scale = Vec3::one();
next.control.offset = Vec3::new(-8.0 - slow * 1.0, 3.0 - slow * 5.0, 3.0);
next.control.offset = Vec3::new(-8.0 - slow * 0.5, 3.0 - foot * 0.6, 3.0);
next.control.ori = Quaternion::rotation_x(0.0)
* Quaternion::rotation_y(0.0)
* Quaternion::rotation_z(1.4 + slow * 0.1);
* Quaternion::rotation_z(1.4 + slow * 0.2);
next.control.scale = Vec3::one();
next.l_foot.offset = Vec3::new(-3.4, foot * 3.0, 8.0);
next.l_foot.ori = Quaternion::rotation_x(foot * -0.6);
next.l_foot.offset = Vec3::new(-1.4, foot * 3.0, 8.0);
next.l_foot.ori = Quaternion::rotation_x(foot * -0.4 - 0.8);
next.l_foot.scale = Vec3::one();
next.r_foot.offset = Vec3::new(3.4, foot * -3.0, 8.0);
next.r_foot.ori = Quaternion::rotation_x(foot * 0.6);
next.r_foot.offset = Vec3::new(5.4, foot * -3.0 - 3.0, 8.0);
next.r_foot.ori = Quaternion::rotation_x(foot * 0.4 - 0.8);
next.r_foot.scale = Vec3::one();
},
_ => {},
}

View File

@ -216,17 +216,15 @@ impl Animation for EquipAnimation {
* 0.1,
);
if velocity > 0.5 {
next.head.offset = Vec3::new(
0.0,
-3.0 + skeleton_attr.neck_forward,
skeleton_attr.neck_height + 13.0 + short * 0.2,
);
next.head.ori = Quaternion::rotation_z(head_look.x- short * 0.2)
* Quaternion::rotation_x(head_look.y + 0.35);
next.head.scale = Vec3::one() * skeleton_attr.head_scale;
next.head.offset = Vec3::new(
0.0,
-3.0 + skeleton_attr.neck_forward,
skeleton_attr.neck_height + 13.0 + short * 0.2,
);
next.head.ori = Quaternion::rotation_z(head_look.x - short * 0.2)
* Quaternion::rotation_x(head_look.y + 0.35);
next.head.scale = Vec3::one() * skeleton_attr.head_scale;
next.l_foot.offset = Vec3::new(-3.4, foot * 1.0, 9.0);
next.l_foot.ori = Quaternion::rotation_x(foot * -1.2);
next.l_foot.scale = Vec3::one();
@ -234,32 +232,30 @@ impl Animation for EquipAnimation {
next.r_foot.offset = Vec3::new(3.4, foot * -1.0, 9.0);
next.r_foot.ori = Quaternion::rotation_x(foot * 1.2);
next.r_foot.scale = Vec3::one();
next.chest.offset = Vec3::new(0.0, 0.0, 9.0 + short * 1.1);
next.chest.ori = Quaternion::rotation_z(short * 0.2);
next.chest.scale = Vec3::one();
next.chest.offset = Vec3::new(0.0, 0.0, 9.0 + short * 1.1);
next.chest.ori = Quaternion::rotation_z(short * 0.2);
next.chest.scale = Vec3::one();
next.belt.offset = Vec3::new(0.0, 0.0, -2.0);
next.belt.ori = Quaternion::rotation_z(short * 0.15);
next.belt.scale = Vec3::one();
next.belt.offset = Vec3::new(0.0, 0.0, -2.0);
next.belt.ori = Quaternion::rotation_z(short * 0.15);
next.belt.scale = Vec3::one();
next.shorts.offset = Vec3::new(0.0, 0.0, -5.0);
next.shorts.ori = Quaternion::rotation_z(short * 0.4);
next.shorts.scale = Vec3::one();
next.shorts.offset = Vec3::new(0.0, 0.0, -5.0);
next.shorts.ori = Quaternion::rotation_z(short * 0.4);
next.shorts.scale = Vec3::one();
next.torso.offset = Vec3::new(0.0, 0.0, 0.0) * skeleton_attr.scaler;
next.torso.ori = Quaternion::rotation_x(-0.2);
next.torso.scale = Vec3::one() / 11.0 * skeleton_attr.scaler;
} else {
next.head.offset = Vec3::new(
0.0,
-3.0 + skeleton_attr.neck_forward,
skeleton_attr.neck_height + 13.0 + short * 0.2,
);
next.head.ori = Quaternion::rotation_z(head_look.x)
* Quaternion::rotation_x(head_look.y);
next.head.scale = Vec3::one() * skeleton_attr.head_scale;
next.head.offset = Vec3::new(
0.0,
-3.0 + skeleton_attr.neck_forward,
skeleton_attr.neck_height + 13.0 + short * 0.2,
);
next.head.ori =
Quaternion::rotation_z(head_look.x) * Quaternion::rotation_x(head_look.y);
next.head.scale = Vec3::one() * skeleton_attr.head_scale;
next.l_foot.offset = Vec3::new(-3.4, -2.5, 8.0);
next.l_foot.ori = Quaternion::rotation_x(wave_ultra_slow_cos * 0.035 - 0.2);
next.l_foot.scale = Vec3::one();
@ -268,23 +264,21 @@ impl Animation for EquipAnimation {
next.r_foot.ori = Quaternion::rotation_x(wave_ultra_slow * 0.035);
next.r_foot.scale = Vec3::one();
next.chest.offset = Vec3::new(0.0, 0.0, 7.0);
next.chest.ori = Quaternion::rotation_z(0.0);
next.chest.scale = Vec3::one();
next.chest.offset = Vec3::new(0.0, 0.0, 7.0);
next.chest.ori = Quaternion::rotation_z(0.0);
next.chest.scale = Vec3::one();
next.belt.offset = Vec3::new(0.0, 0.0, -2.0);
next.belt.ori = Quaternion::rotation_z(0.0);
next.belt.scale = Vec3::one();
next.belt.offset = Vec3::new(0.0, 0.0, -2.0);
next.belt.ori = Quaternion::rotation_z(0.0);
next.belt.scale = Vec3::one();
next.shorts.offset = Vec3::new(0.0, 0.0, -5.0);
next.shorts.ori = Quaternion::rotation_z(0.0);
next.shorts.scale = Vec3::one();
next.shorts.offset = Vec3::new(0.0, 0.0, -5.0);
next.shorts.ori = Quaternion::rotation_z(0.0);
next.shorts.scale = Vec3::one();
next.torso.offset = Vec3::new(0.0, 0.0, 0.1) * skeleton_attr.scaler;
next.torso.ori = Quaternion::rotation_x(0.0);
next.torso.scale = Vec3::one() / 11.0 * skeleton_attr.scaler;
}
next
next
}
}

View File

@ -76,7 +76,7 @@ impl Animation for JumpAnimation {
next.r_shoulder.ori = Quaternion::rotation_x(-wave_stop_alt * 0.3);
next.r_shoulder.scale = Vec3::one() * 1.1;
next.glider.offset = Vec3::new(0.0, 5.0, 0.0);
next.glider.offset = Vec3::new(0.0, 0.0, 10.0);
next.glider.ori = Quaternion::rotation_y(0.0);
next.glider.scale = Vec3::one() * 0.0;

View File

@ -21,10 +21,10 @@ pub mod wield;
pub use self::{
attack::AttackAnimation, block::BlockAnimation, blockidle::BlockIdleAnimation,
charge::ChargeAnimation, climb::ClimbAnimation, equip::EquipAnimation,
gliding::GlidingAnimation, idle::IdleAnimation,
idlewield::IdleWieldAnimation, jump::JumpAnimation, roll::RollAnimation, run::RunAnimation,
shoot::ShootAnimation, sit::SitAnimation, spin::SpinAnimation, stand::StandAnimation,
swim::SwimAnimation, wield::WieldAnimation,
gliding::GlidingAnimation, idle::IdleAnimation, idlewield::IdleWieldAnimation,
jump::JumpAnimation, roll::RollAnimation, run::RunAnimation, shoot::ShootAnimation,
sit::SitAnimation, spin::SpinAnimation, stand::StandAnimation, swim::SwimAnimation,
wield::WieldAnimation,
};
use super::{Bone, Skeleton};

View File

@ -128,7 +128,7 @@ impl Animation for RunAnimation {
next.r_shoulder.ori = Quaternion::rotation_x(short * -0.15);
next.r_shoulder.scale = Vec3::one() * 1.1;
next.glider.offset = Vec3::new(0.0, 5.0, 0.0);
next.glider.offset = Vec3::new(0.0, 0.0, 10.0);
next.glider.ori = Quaternion::rotation_y(0.0);
next.glider.scale = Vec3::one() * 0.0;

View File

@ -94,214 +94,7 @@ impl Animation for SpinAnimation {
* Quaternion::rotation_y(0.0);
next.torso.scale = Vec3::one() / 11.0 * skeleton_attr.scaler;
},
Some(ToolKind::Axe(_)) => {
next.l_hand.offset =
Vec3::new(-8.0 + accel_slow * 10.0, 8.0 + accel_fast * 3.0, 0.0);
next.l_hand.ori = Quaternion::rotation_z(-0.8)
* Quaternion::rotation_x(0.0 + accel_med * -0.8)
* Quaternion::rotation_y(0.0 + accel_med * -0.4);
next.l_hand.scale = Vec3::one() * 1.01;
next.r_hand.offset =
Vec3::new(-8.0 + accel_slow * 10.0, 8.0 + accel_fast * 3.0, -2.0);
next.r_hand.ori = Quaternion::rotation_z(-0.8)
* Quaternion::rotation_x(0.0 + accel_med * -0.8)
* Quaternion::rotation_y(0.0 + accel_med * -0.4);
next.r_hand.scale = Vec3::one() * 1.01;
next.main.offset = Vec3::new(
-8.0 + accel_slow * 10.0 + skeleton_attr.weapon_x,
8.0 + accel_fast * 3.0,
0.0,
);
next.main.ori = Quaternion::rotation_z(-0.8)
* Quaternion::rotation_x(0.0 + accel_med * -0.8)
* Quaternion::rotation_y(0.0 + accel_med * -0.4);
next.main.scale = Vec3::one();
next.chest.offset = Vec3::new(0.0, 0.0, 7.0);
next.chest.ori = Quaternion::rotation_z(decel * -0.2)
* Quaternion::rotation_x(0.0 + decel * -0.2)
* Quaternion::rotation_y(decel * 0.2);
next.chest.scale = Vec3::one();
next.torso.offset = Vec3::new(0.0, 0.0, 0.1) * skeleton_attr.scaler;
next.torso.ori = Quaternion::rotation_z(0.0)
* Quaternion::rotation_x(0.0)
* Quaternion::rotation_y(0.0);
next.torso.scale = Vec3::one() / 11.0 * skeleton_attr.scaler;
},
Some(ToolKind::Hammer(_)) => {
next.l_hand.offset = Vec3::new(0.0, 3.0, 8.0);
//0,1,5
next.l_hand.ori = Quaternion::rotation_x(1.27);
next.l_hand.scale = Vec3::one() * 1.05;
next.r_hand.offset = Vec3::new(0.0, 0.0, -3.0);
next.r_hand.ori = Quaternion::rotation_x(1.27);
next.r_hand.scale = Vec3::one() * 1.05;
next.main.offset = Vec3::new(0.0, 6.0, -1.0);
next.main.ori = Quaternion::rotation_x(-0.3)
* Quaternion::rotation_y(0.0)
* Quaternion::rotation_z(0.0);
next.main.scale = Vec3::one();
next.control.offset = Vec3::new(-6.0, 3.0, 5.0 + slower * 5.0);
next.control.ori = Quaternion::rotation_x(-0.2 + slower * 2.0)
* Quaternion::rotation_y(0.0)
* Quaternion::rotation_z(1.4 + 1.57);
next.control.scale = Vec3::one();
next.chest.offset = Vec3::new(0.0, 0.0, 7.0);
next.chest.ori = Quaternion::rotation_z(decel * -0.2)
* Quaternion::rotation_x(0.0 + decel * -0.2)
* Quaternion::rotation_y(decel * 0.2);
next.chest.scale = Vec3::one();
next.torso.offset = Vec3::new(0.0, 0.0, 0.1) * skeleton_attr.scaler;
next.torso.ori = Quaternion::rotation_z(0.0)
* Quaternion::rotation_x(0.0)
* Quaternion::rotation_y(0.0);
next.torso.scale = Vec3::one() / 11.0 * skeleton_attr.scaler;
},
Some(ToolKind::Staff(_)) => {
next.l_hand.offset = Vec3::new(0.0, 1.0, 0.0);
next.l_hand.ori = Quaternion::rotation_x(1.27);
next.l_hand.scale = Vec3::one() * 1.05;
next.r_hand.offset = Vec3::new(0.0, 0.0, 10.0);
next.r_hand.ori = Quaternion::rotation_x(1.27);
next.r_hand.scale = Vec3::one() * 1.05;
next.main.offset = Vec3::new(0.0, 6.0, -4.0);
next.main.ori = Quaternion::rotation_x(-0.3)
* Quaternion::rotation_y(0.0)
* Quaternion::rotation_z(0.0);
next.main.scale = Vec3::one();
next.control.offset = Vec3::new(-8.0 - slow * 1.0, 3.0 - slow * 5.0, 0.0);
next.control.ori = Quaternion::rotation_x(-1.2)
* Quaternion::rotation_y(slow * 1.5)
* Quaternion::rotation_z(1.4 + slow * 0.5);
next.control.scale = Vec3::one();
next.torso.offset = Vec3::new(0.0, 0.0, 0.1) * skeleton_attr.scaler;
next.torso.ori = Quaternion::rotation_z(0.0)
* Quaternion::rotation_x(0.0)
* Quaternion::rotation_y(0.0);
next.torso.scale = Vec3::one() / 11.0 * skeleton_attr.scaler;
},
Some(ToolKind::Shield(_)) => {
next.l_hand.offset =
Vec3::new(-8.0 + accel_slow * 10.0, 8.0 + accel_fast * 3.0, 0.0);
next.l_hand.ori = Quaternion::rotation_z(-0.8)
* Quaternion::rotation_x(0.0 + accel_med * -0.8)
* Quaternion::rotation_y(0.0 + accel_med * -0.4);
next.l_hand.scale = Vec3::one() * 1.01;
next.r_hand.offset =
Vec3::new(-8.0 + accel_slow * 10.0, 8.0 + accel_fast * 3.0, -2.0);
next.r_hand.ori = Quaternion::rotation_z(-0.8)
* Quaternion::rotation_x(0.0 + accel_med * -0.8)
* Quaternion::rotation_y(0.0 + accel_med * -0.4);
next.r_hand.scale = Vec3::one() * 1.01;
next.main.offset = Vec3::new(
-8.0 + accel_slow * 10.0 + skeleton_attr.weapon_x,
8.0 + accel_fast * 3.0,
0.0,
);
next.main.ori = Quaternion::rotation_z(-0.8)
* Quaternion::rotation_x(0.0 + accel_med * -0.8)
* Quaternion::rotation_y(0.0 + accel_med * -0.4);
next.main.scale = Vec3::one();
next.torso.offset = Vec3::new(0.0, 0.0, 0.1) * skeleton_attr.scaler;
next.torso.ori = Quaternion::rotation_z(0.0)
* Quaternion::rotation_x(0.0)
* Quaternion::rotation_y(0.0);
next.torso.scale = Vec3::one() / 11.0 * skeleton_attr.scaler;
},
Some(ToolKind::Bow(_)) => {
next.l_hand.offset = Vec3::new(1.0, -4.0, -1.0);
next.l_hand.ori = Quaternion::rotation_x(1.27)
* Quaternion::rotation_y(-0.6)
* Quaternion::rotation_z(-0.3);
next.l_hand.scale = Vec3::one() * 1.05;
next.r_hand.offset = Vec3::new(3.0, -1.0, -6.0);
next.r_hand.ori = Quaternion::rotation_x(1.27)
* Quaternion::rotation_y(-0.6)
* Quaternion::rotation_z(-0.3);
next.r_hand.scale = Vec3::one() * 1.05;
next.main.offset = Vec3::new(3.0, 2.0, -13.0);
next.main.ori = Quaternion::rotation_x(-0.3)
* Quaternion::rotation_y(0.3)
* Quaternion::rotation_z(-0.6);
next.main.scale = Vec3::one();
next.control.offset = Vec3::new(-7.0, 6.0, 6.0);
next.control.ori = Quaternion::rotation_x(0.0)
* Quaternion::rotation_y(0.0)
* Quaternion::rotation_z(0.0);
next.control.scale = Vec3::one();
next.torso.offset = Vec3::new(0.0, 0.0, 0.1) * skeleton_attr.scaler;
next.torso.ori = Quaternion::rotation_z(0.0)
* Quaternion::rotation_x(0.0)
* Quaternion::rotation_y(0.0);
next.torso.scale = Vec3::one() / 11.0 * skeleton_attr.scaler;
},
Some(ToolKind::Dagger(_)) => {
next.l_hand.offset =
Vec3::new(-8.0 + accel_slow * 10.0, 8.0 + accel_fast * 3.0, 0.0);
next.l_hand.ori = Quaternion::rotation_z(-0.8)
* Quaternion::rotation_x(0.0 + accel_med * -0.8)
* Quaternion::rotation_y(0.0 + accel_med * -0.4);
next.l_hand.scale = Vec3::one() * 1.01;
next.r_hand.offset =
Vec3::new(-8.0 + accel_slow * 10.0, 8.0 + accel_fast * 3.0, -2.0);
next.r_hand.ori = Quaternion::rotation_z(-0.8)
* Quaternion::rotation_x(0.0 + accel_med * -0.8)
* Quaternion::rotation_y(0.0 + accel_med * -0.4);
next.r_hand.scale = Vec3::one() * 1.01;
next.main.offset = Vec3::new(
-8.0 + accel_slow * 10.0 + skeleton_attr.weapon_x,
8.0 + accel_fast * 3.0,
0.0,
);
next.main.ori = Quaternion::rotation_z(-0.8)
* Quaternion::rotation_x(0.0 + accel_med * -0.8)
* Quaternion::rotation_y(0.0 + accel_med * -0.4);
next.main.scale = Vec3::one();
next.torso.offset = Vec3::new(0.0, 0.0, 0.1) * skeleton_attr.scaler;
next.torso.ori = Quaternion::rotation_z(0.0)
* Quaternion::rotation_x(0.0)
* Quaternion::rotation_y(0.0);
next.torso.scale = Vec3::one() / 11.0 * skeleton_attr.scaler;
},
Some(ToolKind::Debug(_)) => {
next.l_hand.offset =
Vec3::new(-8.0 + accel_slow * 10.0, 8.0 + accel_fast * 3.0, 0.0);
next.l_hand.ori = Quaternion::rotation_z(-0.8)
* Quaternion::rotation_x(0.0 + accel_med * -0.8)
* Quaternion::rotation_y(0.0 + accel_med * -0.4);
next.l_hand.scale = Vec3::one() * 1.01;
next.r_hand.offset =
Vec3::new(-8.0 + accel_slow * 10.0, 8.0 + accel_fast * 3.0, -2.0);
next.r_hand.ori = Quaternion::rotation_z(-0.8)
* Quaternion::rotation_x(0.0 + accel_med * -0.8)
* Quaternion::rotation_y(0.0 + accel_med * -0.4);
next.r_hand.scale = Vec3::one() * 1.01;
next.main.offset = Vec3::new(
-8.0 + accel_slow * 10.0 + skeleton_attr.weapon_x,
8.0 + accel_fast * 3.0,
0.0,
);
next.main.ori = Quaternion::rotation_z(-0.8)
* Quaternion::rotation_x(0.0 + accel_med * -0.8)
* Quaternion::rotation_y(0.0 + accel_med * -0.4);
next.main.scale = Vec3::one();
next.torso.offset = Vec3::new(0.0, 0.0, 0.1) * skeleton_attr.scaler;
next.torso.ori = Quaternion::rotation_z(0.0)
* Quaternion::rotation_x(0.0)
* Quaternion::rotation_y(0.0);
next.torso.scale = Vec3::one() / 11.0 * skeleton_attr.scaler;
},
_ => {},
}
next.l_foot.offset = Vec3::new(-3.4, foot * 1.0, 8.0);

View File

@ -79,7 +79,7 @@ impl Animation for StandAnimation {
next.r_shoulder.ori = Quaternion::rotation_x(0.0);
next.r_shoulder.scale = (Vec3::one() + breathe * -0.05) * 1.15;
next.glider.offset = Vec3::new(0.0, 5.0, 0.0);
next.glider.offset = Vec3::new(0.0, 0.0, 10.0);
next.glider.ori = Quaternion::rotation_y(0.0);
next.glider.scale = Vec3::one() * 0.0;

View File

@ -6,101 +6,112 @@ use vek::*;
pub struct SwimAnimation;
impl Animation for SwimAnimation {
type Dependency = (Option<ToolKind>, f32, f32, f64);
type Dependency = (Option<ToolKind>, Vec3<f32>, f32, f64);
type Skeleton = CharacterSkeleton;
fn update_skeleton(
skeleton: &Self::Skeleton,
(_active_tool_kind, velocity, orientation, global_time): Self::Dependency,
(_active_tool_kind, velocity, _orientation, global_time): Self::Dependency,
anim_time: f64,
_rate: &mut f32,
rate: &mut f32,
skeleton_attr: &SkeletonAttr,
) -> Self::Skeleton {
let mut next = (*skeleton).clone();
let wave = (anim_time as f32 * velocity * 1.2).sin();
let wave_cos = (anim_time as f32 * velocity * 1.2).cos();
let speed = Vec2::<f32>::from(velocity).magnitude();
*rate = speed;
let lab = 1.0;
let long = (((5.0)
/ (1.5 + 3.5 * ((anim_time as f32 * lab as f32 * 0.8).sin()).powf(2.0 as f32)))
.sqrt())
* ((anim_time as f32 * lab as f32 * 0.8).sin());
let short = (((5.0)
/ (1.5 + 3.5 * ((anim_time as f32 * lab as f32 * 1.6).sin()).powf(2.0 as f32)))
.sqrt())
* ((anim_time as f32 * lab as f32 * 1.6).sin());
let shortalt = (((5.0)
/ (1.5
+ 3.5
* ((anim_time as f32 * lab as f32 * 1.6 + PI / 2.0).sin()).powf(2.0 as f32)))
.sqrt())
* ((anim_time as f32 * lab as f32 * 1.6 + PI / 2.0).sin());
let foot = (((5.0)
/ (1.1 + 3.9 * ((anim_time as f32 * lab as f32 * 1.6).sin()).powf(2.0 as f32)))
.sqrt())
* ((anim_time as f32 * lab as f32 * 1.6).sin());
let wave_stop = (anim_time as f32 * 2.6).min(PI / 2.0 / 2.0).sin();
let wave_diff = (anim_time as f32 * velocity * 0.6).sin();
let wave_cos_dub = (anim_time as f32 * velocity * 2.4).cos();
let wave_stop = (anim_time as f32 * 2.6).min(PI / 2.0).sin();
let head_look = Vec2::new(
((global_time + anim_time) as f32 / 2.0)
((global_time + anim_time) as f32 / 18.0)
.floor()
.mul(7331.0)
.sin()
* 0.2,
((global_time + anim_time) as f32 / 2.0)
((global_time + anim_time) as f32 / 18.0)
.floor()
.mul(1337.0)
.sin()
* 0.1,
);
let vel = Vec2::from(velocity);
let ori = (Vec2::from(orientation)).normalized();
let _tilt = if Vec2::new(ori, vel)
.map(|v| Vec2::<f32>::from(v).magnitude_squared())
.reduce_partial_min()
> 0.001
{
vel.normalized().dot(ori.normalized()).min(1.0).acos()
} else {
0.0
};
next.head.offset = Vec3::new(
0.0,
-3.0 + skeleton_attr.neck_forward,
skeleton_attr.neck_height + 14.0 + wave_cos * 1.3,
skeleton_attr.neck_height + 13.0 + short * 0.3,
);
next.head.ori = Quaternion::rotation_z(head_look.x + wave * 0.1)
next.head.ori = Quaternion::rotation_z(head_look.x + long * -0.1 - short * 0.3)
* Quaternion::rotation_x(head_look.y + 0.35);
next.head.scale = Vec3::one() * skeleton_attr.head_scale;
next.chest.offset = Vec3::new(0.0, 0.0, 7.0 + wave_cos * 1.1);
next.chest.ori = Quaternion::rotation_z(wave * 0.2);
next.chest.offset = Vec3::new(0.0, 0.0, 7.0 + short * 1.1);
next.chest.ori = Quaternion::rotation_z(short * 0.3);
next.chest.scale = Vec3::one();
next.belt.offset = Vec3::new(0.0, 0.0, -2.0 + wave_cos * 1.1);
next.belt.ori = Quaternion::rotation_z(wave * 0.35);
next.belt.offset = Vec3::new(0.0, 0.0, -2.0);
next.belt.ori = Quaternion::rotation_z(short * 0.25);
next.belt.scale = Vec3::one();
next.shorts.offset = Vec3::new(0.0, 0.0, -5.0 + wave_cos * 1.1);
next.shorts.ori = Quaternion::rotation_z(wave * 0.6);
next.shorts.offset = Vec3::new(0.0, 0.0, -5.0);
next.shorts.ori = Quaternion::rotation_z(short * 0.4);
next.shorts.scale = Vec3::one();
next.l_hand.offset = Vec3::new(
-6.0 + wave_cos_dub * 1.0,
-0.25 + wave_cos * 5.0,
5.0 - wave * 1.5,
-6.0 + wave_stop * -1.0,
-0.25 + short * 3.0,
4.0 + short * -1.5,
);
next.l_hand.ori = Quaternion::rotation_x(wave_cos * 0.8);
next.l_hand.ori =
Quaternion::rotation_x(0.8 + short * 1.2) * Quaternion::rotation_y(wave_stop * 0.1);
next.l_hand.scale = Vec3::one();
next.r_hand.offset = Vec3::new(
6.0 - wave_cos_dub * 1.0,
-0.25 - wave_cos * 5.0,
5.0 + wave * 1.5,
6.0 + wave_stop * 1.0,
-0.25 + short * -3.0,
4.0 + short * 1.5,
);
next.r_hand.ori = Quaternion::rotation_x(wave_cos * -0.8);
next.r_hand.ori =
Quaternion::rotation_x(0.8 + short * -1.2) * Quaternion::rotation_y(wave_stop * -0.1);
next.r_hand.scale = Vec3::one();
next.l_foot.offset = Vec3::new(-3.4, 0.0 + wave_cos * 1.0, 6.0 - wave_cos_dub * 0.7);
next.l_foot.ori = Quaternion::rotation_x(-0.0 - wave_cos * 1.5);
next.l_foot.offset = Vec3::new(-3.4, foot * 1.0, 6.0);
next.l_foot.ori = Quaternion::rotation_x(foot * -1.2);
next.l_foot.scale = Vec3::one();
next.r_foot.offset = Vec3::new(3.4, 0.0 - wave_cos * 1.0, 6.0 - wave_cos_dub * 0.7);
next.r_foot.ori = Quaternion::rotation_x(-0.0 + wave_cos * 1.5);
next.r_foot.offset = Vec3::new(3.4, foot * -1.0, 6.0);
next.r_foot.ori = Quaternion::rotation_x(foot * 1.2);
next.r_foot.scale = Vec3::one();
next.l_shoulder.offset = Vec3::new(-5.0, 0.0, 4.7);
next.l_shoulder.ori = Quaternion::rotation_x(wave_cos * 0.15);
next.l_shoulder.offset = Vec3::new(-5.0, -1.0, 4.7);
next.l_shoulder.ori = Quaternion::rotation_x(short * 0.15);
next.l_shoulder.scale = Vec3::one() * 1.1;
next.r_shoulder.offset = Vec3::new(5.0, 0.0, 4.7);
next.r_shoulder.ori = Quaternion::rotation_x(wave * 0.15);
next.r_shoulder.offset = Vec3::new(5.0, -1.0, 4.7);
next.r_shoulder.ori = Quaternion::rotation_x(short * -0.15);
next.r_shoulder.scale = Vec3::one() * 1.1;
next.glider.offset = Vec3::new(0.0, 5.0, 0.0);
@ -110,10 +121,9 @@ impl Animation for SwimAnimation {
next.main.offset = Vec3::new(
-7.0 + skeleton_attr.weapon_x,
-5.0 + skeleton_attr.weapon_y,
18.0,
15.0,
);
next.main.ori =
Quaternion::rotation_y(2.5) * Quaternion::rotation_z(1.57 + wave_cos * 0.25);
next.main.ori = Quaternion::rotation_y(2.5) * Quaternion::rotation_z(1.57 + short * 0.25);
next.main.scale = Vec3::one();
next.second.offset = Vec3::new(
@ -128,9 +138,9 @@ impl Animation for SwimAnimation {
next.lantern.ori = Quaternion::rotation_y(0.0);
next.lantern.scale = Vec3::one() * 0.0;
next.torso.offset = Vec3::new(0.0, -0.2 + wave * -0.08, 0.4) * skeleton_attr.scaler;
next.torso.offset = Vec3::new(0.0, -0.3 + shortalt * -0.065, 0.4) * skeleton_attr.scaler;
next.torso.ori =
Quaternion::rotation_x(wave_stop * velocity * -0.06 + wave_diff * velocity * -0.005)
Quaternion::rotation_x(wave_stop * speed * -0.05 + wave_stop * speed * -0.005)
* Quaternion::rotation_y(0.0);
next.torso.scale = Vec3::one() / 11.0 * skeleton_attr.scaler;
@ -145,6 +155,7 @@ impl Animation for SwimAnimation {
next.r_control.offset = Vec3::new(0.0, 0.0, 0.0);
next.r_control.ori = Quaternion::rotation_x(0.0);
next.r_control.scale = Vec3::one();
next
}
}

View File

@ -454,7 +454,7 @@ impl FigureMgr {
// Swim
(_, _, true) => anim::character::SwimAnimation::update_skeleton(
&CharacterSkeleton::new(),
(active_tool_kind, vel.0.magnitude(), ori.0.magnitude(), time),
(active_tool_kind, vel.0, ori.0.magnitude(), time),
state.state_time,
&mut state_animation_rate,
skeleton_attr,
@ -565,13 +565,13 @@ impl FigureMgr {
)
}*/
CharacterState::Equipping { .. } => {
anim::character::EquipAnimation::update_skeleton(
&target_base,
(active_tool_kind, vel.0.magnitude(), time),
state.state_time,
&mut state_animation_rate,
skeleton_attr,
)
anim::character::EquipAnimation::update_skeleton(
&target_base,
(active_tool_kind, vel.0.magnitude(), time),
state.state_time,
&mut state_animation_rate,
skeleton_attr,
)
},
CharacterState::Wielding { .. } => {
if vel.0.magnitude_squared() > 0.5 {