starting foot movement with attacks, clearing some dead code

This commit is contained in:
jshipsey 2020-03-25 00:15:06 -04:00
parent 550dd144bc
commit a6537ed69b
10 changed files with 208 additions and 1458 deletions

View File

@ -9,12 +9,12 @@ pub struct Input {
pub struct AttackAnimation;
impl Animation for AttackAnimation {
type Dependency = (Option<ToolKind>, f64);
type Dependency = (Option<ToolKind>, f32, f64);
type Skeleton = CharacterSkeleton;
fn update_skeleton(
skeleton: &Self::Skeleton,
(active_tool_kind, _global_time): Self::Dependency,
(active_tool_kind, velocity, _global_time): Self::Dependency,
anim_time: f64,
rate: &mut f32,
skeleton_attr: &SkeletonAttr,
@ -25,10 +25,9 @@ impl Animation for AttackAnimation {
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 * 13.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 * 13.0).sin());
let accel_med = 1.0 - (anim_time as f32 * 16.0 * lab as f32).cos();
let accel_slow = 1.0 - (anim_time as f32 * 12.0 * lab as f32).cos();
let accel_fast = 1.0 - (anim_time as f32 * 24.0 * lab as f32).cos();
@ -52,7 +51,7 @@ impl Animation for AttackAnimation {
Some(ToolKind::Sword(_)) => {
next.head.offset = Vec3::new(
0.0 + skeleton_attr.neck_right,
0.0 + skeleton_attr.neck_forward,
-2.0 + skeleton_attr.neck_forward,
skeleton_attr.neck_height + 14.0,
);
next.head.ori = Quaternion::rotation_z(slow * 0.08)
@ -91,13 +90,18 @@ impl Animation for AttackAnimation {
* Quaternion::rotation_y(slow * 1.5)
* Quaternion::rotation_z(1.4 + slow * 0.5);
next.control.scale = Vec3::one();
next.l_foot.offset = Vec3::new(-3.4, foot * 3.0, 8.0);
next.l_foot.offset = Vec3::new(-3.4, foot * 3.0 + slow * -5.0, 8.0);
next.l_foot.ori = Quaternion::rotation_x(foot * -0.6);
next.l_foot.scale = Vec3::one();
next.r_foot.offset = Vec3::new(3.4, foot * -3.0, 8.0);
next.r_foot.offset = Vec3::new(3.4, foot * -3.0 + slow * 5.0, 8.0);
next.r_foot.ori = Quaternion::rotation_x(foot * 0.6);
next.r_foot.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::Axe(_)) => {
next.head.offset = Vec3::new(
@ -145,6 +149,11 @@ impl Animation for AttackAnimation {
* Quaternion::rotation_y(-0.3)
* Quaternion::rotation_z(-0.7 + slowax * -1.9);
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::Hammer(_)) => {
next.l_hand.offset = Vec3::new(0.0, 3.0, 8.0);
@ -159,13 +168,13 @@ impl Animation for AttackAnimation {
* Quaternion::rotation_z(0.0);
next.main.scale = Vec3::one();
next.head.offset = Vec3::new(
0.0 + skeleton_attr.neck_right + slower * 3.0,
0.0 + skeleton_attr.neck_forward + slower * -3.0,
0.0 + skeleton_attr.neck_right,
-2.0 + skeleton_attr.neck_forward,
skeleton_attr.neck_height + 12.0,
);
next.head.ori = Quaternion::rotation_z(slower * 0.25)
* Quaternion::rotation_x(0.0 + slower * 0.2)
* Quaternion::rotation_y(slower * 0.2);
next.head.ori = Quaternion::rotation_z(slower * 0.05)
* Quaternion::rotation_x(0.0 + slower * 0.05)
* Quaternion::rotation_y(slower * 0.05);
next.head.scale = Vec3::one() * skeleton_attr.head_scale;
next.chest.offset = Vec3::new(0.0, 0.0, 7.0);
@ -181,12 +190,53 @@ impl Animation for AttackAnimation {
next.shorts.offset = Vec3::new(0.0, 0.0, -5.0);
next.shorts.ori = next.chest.ori * -0.15;
next.shorts.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;
if velocity > 0.5 {
next.l_foot.offset = Vec3::new(-3.4, foot * -2.0, 8.0);
next.l_foot.ori = Quaternion::rotation_x(foot * -0.4)
* Quaternion::rotation_z((slower * 0.6).max(0.0));
next.l_foot.scale = Vec3::one();
next.r_foot.offset = Vec3::new(3.4, foot * 2.0, 8.0);
next.r_foot.ori = Quaternion::rotation_x(foot * 0.4)
* Quaternion::rotation_z((slower * 0.6).max(0.0));
next.r_foot.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.15);
next.torso.scale = Vec3::one() / 11.0 * skeleton_attr.scaler;
} else {
next.l_foot.offset = Vec3::new(-3.4, -2.5, 8.0 + (slower * 2.5).max(0.0));
next.l_foot.ori = Quaternion::rotation_x(slower * -0.2 - 0.2)
* Quaternion::rotation_z((slower * 1.0).max(0.0));
next.l_foot.scale = Vec3::one();
next.r_foot.offset = Vec3::new(3.4, 3.5 - slower * 2.0, 8.0);
next.r_foot.ori = Quaternion::rotation_x(slower * 0.1)
* Quaternion::rotation_z((slower * 0.5).max(0.0));
next.r_foot.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.control.offset = Vec3::new(-6.0, 3.0, 8.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.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.head.offset = Vec3::new(
@ -233,6 +283,11 @@ impl Animation for AttackAnimation {
* 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.head.offset = Vec3::new(
@ -285,6 +340,11 @@ impl Animation for AttackAnimation {
* 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.head.offset = Vec3::new(
@ -335,6 +395,11 @@ impl Animation for AttackAnimation {
* 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.head.offset = Vec3::new(
@ -387,6 +452,11 @@ impl Animation for AttackAnimation {
* 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.head.offset = Vec3::new(
@ -439,9 +509,15 @@ impl Animation for AttackAnimation {
* 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_shoulder.offset = Vec3::new(-5.0, 0.0, 4.7);
next.l_shoulder.ori = Quaternion::rotation_x(0.0);
next.l_shoulder.scale = Vec3::one() * 1.1;
@ -458,11 +534,6 @@ impl Animation for AttackAnimation {
next.lantern.ori = Quaternion::rotation_x(0.0);
next.lantern.scale = Vec3::one() * 0.0;
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_control.offset = Vec3::new(0.0, 0.0, 0.0);
next.l_control.ori = Quaternion::rotation_x(0.0);
next.l_control.scale = Vec3::one();

View File

@ -1,6 +1,5 @@
use super::{super::Animation, CharacterSkeleton, SkeletonAttr};
use common::comp::item::ToolKind;
use std::f32::consts::PI;
use vek::*;
pub struct Input {
@ -21,7 +20,7 @@ impl Animation for ChargeAnimation {
) -> Self::Skeleton {
*rate = 1.0;
let mut next = (*skeleton).clone();
let constant = 8.0;
let lab = 1.0;
let foot = (((5.0)
@ -29,36 +28,18 @@ impl Animation for ChargeAnimation {
.sqrt())
* ((anim_time as f32 * lab as f32 * 15.0).sin());
let accel_med = 1.0 - (anim_time as f32 * 16.0 * lab as f32).cos();
let accel_slow = 1.0 - (anim_time as f32 * 12.0 * lab as f32).cos();
let accel_fast = 1.0 - (anim_time as f32 * 24.0 * lab as f32).cos();
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)))
.sqrt())
* ((anim_time as f32 * lab as f32 * 12.4).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())
* ((anim_time as f32 * lab as f32 * 4.0).sin());
let slowax = (((5.0)
/ (0.1 + 4.9 * ((anim_time as f32 * lab as f32 * 4.0 + 1.9).cos()).powf(2.0 as f32)))
.sqrt())
* ((anim_time as f32 * lab as f32 * 4.0 + 1.9).cos());
let constant = 8.0;
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());
next.head.offset = Vec3::new(
0.0 + skeleton_attr.neck_right,
5.0 + skeleton_attr.neck_forward,
skeleton_attr.neck_height + 19.0 + wave_cos * 2.0,
);
match active_tool_kind {
//TODO: Inventory
@ -98,9 +79,9 @@ impl Animation for ChargeAnimation {
next.main.scale = Vec3::one();
next.control.offset = Vec3::new(-8.0 - slow * 1.0, 3.0 - slow * 5.0, 3.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.ori = Quaternion::rotation_x(0.0)
* Quaternion::rotation_y(0.0)
* Quaternion::rotation_z(1.4 + slow * 0.1);
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);
@ -109,360 +90,17 @@ impl Animation for ChargeAnimation {
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.scale = Vec3::one();
},
Some(ToolKind::Axe(_)) => {
next.head.offset = Vec3::new(
0.0 + skeleton_attr.neck_right + slowax * 2.0,
-2.0 + skeleton_attr.neck_forward + slowax * -2.0,
skeleton_attr.neck_height + 20.0,
);
next.head.ori = Quaternion::rotation_z(slowax * 0.25)
* Quaternion::rotation_x(0.0 + slowax * 0.2)
* Quaternion::rotation_y(slowax * 0.2);
next.head.scale = Vec3::one() * skeleton_attr.head_scale;
next.chest.offset = Vec3::new(0.0, 0.0, 7.0);
next.chest.ori = Quaternion::rotation_z(slowax * 0.2)
* Quaternion::rotation_x(0.0 + slowax * 0.2)
* Quaternion::rotation_y(slowax * 0.2);
next.chest.scale = Vec3::one();
next.belt.offset = Vec3::new(0.0, 0.0, 5.0);
next.belt.ori = Quaternion::rotation_z(slowax * 0.1)
* Quaternion::rotation_x(0.0 + slowax * 0.1)
* Quaternion::rotation_y(slowax * 0.1);
next.belt.scale = Vec3::one();
next.shorts.offset = Vec3::new(0.0, 0.0, 2.0);
next.belt.ori = Quaternion::rotation_z(slowax * 0.08)
* Quaternion::rotation_x(0.0 + slowax * 0.08)
* Quaternion::rotation_y(slowax * 0.08);
next.shorts.scale = Vec3::one();
next.l_hand.offset = Vec3::new(-4.0, 3.0, 2.0);
next.l_hand.ori = Quaternion::rotation_x(-0.3)
* Quaternion::rotation_z(3.14 - 0.3)
* Quaternion::rotation_y(-0.8);
next.l_hand.scale = Vec3::one() * 1.08;
next.r_hand.offset = Vec3::new(-2.5, 9.0, 0.0);
next.r_hand.ori = Quaternion::rotation_x(-0.3)
* Quaternion::rotation_z(3.14 - 0.3)
* Quaternion::rotation_y(-0.8);
next.r_hand.scale = Vec3::one() * 1.06;
next.main.offset = Vec3::new(-6.0, 10.0, -5.0);
next.main.ori = Quaternion::rotation_x(1.27)
* Quaternion::rotation_y(-0.3)
* Quaternion::rotation_z(-0.8);
next.main.scale = Vec3::one();
next.control.offset = Vec3::new(0.0, 0.0 + slowax * 8.2, 6.0);
next.control.ori = Quaternion::rotation_x(0.8)
* Quaternion::rotation_y(-0.3)
* Quaternion::rotation_z(-0.7 + slowax * -1.9);
next.control.scale = Vec3::one();
},
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.head.offset = Vec3::new(
0.0 + skeleton_attr.neck_right + slower * 3.0,
-2.0 + skeleton_attr.neck_forward + slower * -3.0,
skeleton_attr.neck_height + 19.0,
);
next.head.ori = Quaternion::rotation_z(slower * 0.25)
* Quaternion::rotation_x(0.0 + slower * 0.2)
* Quaternion::rotation_y(slower * 0.2);
next.head.scale = Vec3::one() * skeleton_attr.head_scale;
next.chest.offset = Vec3::new(0.0, 0.0, 7.0);
next.chest.ori = Quaternion::rotation_z(slower * 0.2)
* Quaternion::rotation_x(0.0 + slower * 0.2)
* Quaternion::rotation_y(slower * 0.2);
next.chest.scale = Vec3::one();
next.belt.offset = Vec3::new(0.0, 0.0, 5.0);
next.belt.ori = Quaternion::rotation_z(slower * 0.1)
* Quaternion::rotation_x(0.0 + slower * 0.1)
* Quaternion::rotation_y(slower * 0.1);
next.belt.scale = Vec3::one();
next.shorts.offset = Vec3::new(0.0, 0.0, 2.0);
next.belt.ori = Quaternion::rotation_z(slower * 0.08)
* Quaternion::rotation_x(0.0 + slower * 0.08)
* Quaternion::rotation_y(slower * 0.08);
next.shorts.scale = Vec3::one();
next.control.offset = Vec3::new(-6.0, 3.0, 8.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();
},
Some(ToolKind::Staff(_)) => {
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,
);
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.scale = Vec3::one() * skeleton_attr.head_scale;
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.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.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.scale = Vec3::one();
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();
},
Some(ToolKind::Shield(_)) => {
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,
);
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.scale = Vec3::one() * skeleton_attr.head_scale;
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.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.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.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)
* 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();
},
Some(ToolKind::Bow(_)) => {
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,
);
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.scale = Vec3::one() * skeleton_attr.head_scale;
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.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.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.scale = Vec3::one();
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();
},
Some(ToolKind::Dagger(_)) => {
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,
);
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.scale = Vec3::one() * skeleton_attr.head_scale;
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.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.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.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)
* 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();
},
Some(ToolKind::Debug(_)) => {
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,
);
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.scale = Vec3::one() * skeleton_attr.head_scale;
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.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.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.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)
* 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.head.offset = Vec3::new(
0.0 + skeleton_attr.neck_right,
-2.0 + skeleton_attr.neck_forward,
skeleton_attr.neck_height + 12.0,
);
next.head.ori = Quaternion::rotation_x(0.5);
next.l_shoulder.offset = Vec3::new(-5.0, 0.0, 4.7);
next.l_shoulder.ori = Quaternion::rotation_x(0.0);
next.l_shoulder.scale = Vec3::one() * 1.1;

View File

@ -1,285 +0,0 @@
use super::{super::Animation, CharacterSkeleton, SkeletonAttr};
use common::comp::item::ToolKind;
use std::{f32::consts::PI, ops::Mul};
use vek::*;
pub struct Input {
pub attack: bool,
}
pub struct CidleAnimation;
impl Animation for CidleAnimation {
type Dependency = (Option<ToolKind>, f64);
type Skeleton = CharacterSkeleton;
fn update_skeleton(
skeleton: &Self::Skeleton,
(active_tool_kind, global_time): Self::Dependency,
anim_time: f64,
_rate: &mut f32,
skeleton_attr: &SkeletonAttr,
) -> Self::Skeleton {
let mut next = (*skeleton).clone();
let wave_ultra_slow = (anim_time as f32 * 0.5 + PI).sin();
let wave_ultra_slow_cos = (anim_time as f32 * 3.0 + PI).cos();
let wave_slow_cos = (anim_time as f32 * 6.0 + PI).cos();
let wave_slow = (anim_time as f32 * 6.0 + PI).sin();
let head_look = Vec2::new(
((global_time + anim_time) as f32 / 1.5)
.floor()
.mul(7331.0)
.sin()
* 0.3,
((global_time + anim_time) as f32 / 1.5)
.floor()
.mul(1337.0)
.sin()
* 0.15,
);
next.head.offset = Vec3::new(
0.0 + skeleton_attr.neck_right + wave_slow_cos * 0.5,
-2.0 + skeleton_attr.neck_forward,
skeleton_attr.neck_height + 21.0 + wave_ultra_slow * 0.6,
);
next.head.ori =
Quaternion::rotation_z(head_look.x) * Quaternion::rotation_x(head_look.y.abs());
next.head.scale = Vec3::one() * skeleton_attr.head_scale;
next.chest.offset = Vec3::new(0.0 + wave_slow_cos * 0.5, 0.0, 7.0 + wave_ultra_slow * 0.5);
next.chest.ori = Quaternion::rotation_y(wave_ultra_slow_cos * 0.04);
next.chest.scale = Vec3::one();
next.belt.offset = Vec3::new(0.0 + wave_slow_cos * 0.5, 0.0, 5.0 + wave_ultra_slow * 0.5);
next.belt.ori = Quaternion::rotation_y(wave_ultra_slow_cos * 0.03);
next.belt.scale = Vec3::one() * 1.02;
next.shorts.offset = Vec3::new(0.0 + wave_slow_cos * 0.5, 0.0, 2.0 + wave_ultra_slow * 0.5);
next.shorts.ori = Quaternion::rotation_x(0.0);
next.shorts.scale = Vec3::one();
match active_tool_kind {
//TODO: Inventory
Some(ToolKind::Sword(_)) => {
next.l_hand.offset = Vec3::new(-0.25, -5.0, -5.0);
next.l_hand.ori = Quaternion::rotation_x(1.47) * Quaternion::rotation_y(-0.2);
next.l_hand.scale = Vec3::one() * 1.04;
next.r_hand.offset = Vec3::new(1.25, -5.5, -8.0);
next.r_hand.ori = Quaternion::rotation_x(1.47) * Quaternion::rotation_y(0.3);
next.r_hand.scale = Vec3::one() * 1.05;
next.main.offset = Vec3::new(0.0, 0.0, -6.0);
next.main.ori = Quaternion::rotation_x(-0.1)
* Quaternion::rotation_y(0.0)
* Quaternion::rotation_z(0.0);
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();
},
Some(ToolKind::Axe(_)) => {
next.l_hand.offset = Vec3::new(
-6.5 + wave_ultra_slow_cos * 1.0,
-0.5 + wave_ultra_slow_cos * 0.5,
6.0 + wave_ultra_slow * 1.0,
);
next.l_hand.ori = Quaternion::rotation_x(0.13) * Quaternion::rotation_z(-0.25);
next.l_hand.scale = Vec3::one() * 1.01;
next.r_hand.offset = Vec3::new(
-3.0 + wave_ultra_slow_cos * 1.0,
6.5 + wave_ultra_slow_cos * 0.5,
6.0 + wave_ultra_slow * 1.0,
);
next.r_hand.ori = Quaternion::rotation_x(0.13)
* Quaternion::rotation_z(2.98)
* Quaternion::rotation_y(-0.50);
next.r_hand.scale = Vec3::one() * 1.01;
next.main.offset = Vec3::new(
-5.0 + skeleton_attr.weapon_x + wave_ultra_slow_cos * 1.0,
8.5 + skeleton_attr.weapon_y + wave_ultra_slow_cos * 0.5,
-0.5 + wave_ultra_slow * 1.0,
);
next.main.ori = Quaternion::rotation_x(1.70)
* Quaternion::rotation_y(-0.25)
* Quaternion::rotation_z(0.0);
next.main.scale = Vec3::one();
},
Some(ToolKind::Hammer(_)) => {
next.l_hand.offset = Vec3::new(-7.0, 4.0, 3.0);
next.l_hand.ori = Quaternion::rotation_x(1.27 + wave_ultra_slow * -0.1)
* Quaternion::rotation_y(0.0)
* Quaternion::rotation_z(-0.3);
next.l_hand.scale = Vec3::one() * 1.01;
next.r_hand.offset = Vec3::new(7.0, 2.5, -1.25);
next.r_hand.ori = Quaternion::rotation_x(1.27 + wave_ultra_slow * -0.1)
* Quaternion::rotation_y(0.0)
* Quaternion::rotation_z(-0.3);
next.r_hand.scale = Vec3::one() * 1.01;
next.main.offset = Vec3::new(
5.0 + skeleton_attr.weapon_x,
8.75 + skeleton_attr.weapon_y,
-2.5,
);
next.main.ori = Quaternion::rotation_x(-0.3)
* Quaternion::rotation_y(-1.27)
* Quaternion::rotation_z(wave_ultra_slow * 0.2);
next.main.scale = Vec3::one();
},
Some(ToolKind::Staff(_)) => {
next.l_hand.offset = Vec3::new(
-6.0 + wave_ultra_slow_cos * 1.0,
1.0 + wave_ultra_slow_cos * 0.5,
5.0 + wave_ultra_slow * 1.0,
);
next.l_hand.ori = Quaternion::rotation_x(1.27);
next.l_hand.scale = Vec3::one() * 1.0;
next.r_hand.offset = Vec3::new(
-6.0 + wave_ultra_slow_cos * 1.0,
-1.5 + wave_ultra_slow_cos * 0.5,
-2.0 + wave_ultra_slow * 1.0,
);
next.r_hand.ori = Quaternion::rotation_x(1.27);
next.r_hand.scale = Vec3::one() * 1.01;
next.main.offset = Vec3::new(
-6.0 + skeleton_attr.weapon_x + wave_ultra_slow_cos * 1.0,
8.5 + skeleton_attr.weapon_y + wave_ultra_slow_cos * 0.5,
17.0 + wave_ultra_slow * 1.0,
);
next.main.ori = Quaternion::rotation_x(-0.3 + PI)
* Quaternion::rotation_y(0.0)
* Quaternion::rotation_z(0.0);
next.main.scale = Vec3::one();
},
Some(ToolKind::Shield(_)) => {
next.l_hand.offset = Vec3::new(
-6.0 + wave_ultra_slow_cos * 1.0,
3.5 + wave_ultra_slow_cos * 0.5,
0.0 + wave_ultra_slow * 1.0,
);
next.l_hand.ori = Quaternion::rotation_x(-0.3);
next.l_hand.scale = Vec3::one() * 1.01;
next.r_hand.offset = Vec3::new(
-6.0 + wave_ultra_slow_cos * 1.0,
3.0 + wave_ultra_slow_cos * 0.5,
-2.0 + wave_ultra_slow * 1.0,
);
next.r_hand.ori = Quaternion::rotation_x(-0.3);
next.r_hand.scale = Vec3::one() * 1.01;
next.main.offset = Vec3::new(
-6.0 + skeleton_attr.weapon_x + wave_ultra_slow_cos * 1.0,
4.5 + skeleton_attr.weapon_y + wave_ultra_slow_cos * 0.5,
0.0 + wave_ultra_slow * 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();
},
Some(ToolKind::Bow(_)) => {
next.l_hand.offset = Vec3::new(
-1.0 + wave_ultra_slow_cos * 1.0,
3.0 + wave_ultra_slow_cos * 0.5,
5.0 + wave_ultra_slow * 1.0,
);
next.l_hand.ori = Quaternion::rotation_x(PI / 2.0)
* Quaternion::rotation_y(-0.3)
* Quaternion::rotation_z(0.3);
next.l_hand.scale = Vec3::one() * 1.01;
next.r_hand.offset = Vec3::new(
1.0 + wave_ultra_slow_cos * 1.0,
8.0 + wave_ultra_slow_cos * 0.5,
2.5 + wave_ultra_slow * 1.0,
);
next.r_hand.ori = Quaternion::rotation_x(PI / 2.0)
* Quaternion::rotation_y(0.3)
* Quaternion::rotation_z(0.3);
next.r_hand.scale = Vec3::one() * 1.01;
next.main.offset = Vec3::new(
-4.0 + skeleton_attr.weapon_x + wave_ultra_slow_cos * 1.0,
15.0 + skeleton_attr.weapon_y + wave_ultra_slow_cos * 0.5,
-4.0 + wave_ultra_slow * 1.0,
);
next.main.ori = Quaternion::rotation_x(0.0)
* Quaternion::rotation_y(0.4)
* Quaternion::rotation_z(0.0);
next.main.scale = Vec3::one();
},
Some(ToolKind::Dagger(_)) => {
next.l_hand.offset = Vec3::new(
-6.0 + wave_ultra_slow_cos * 1.0,
3.5 + wave_ultra_slow_cos * 0.5,
0.0 + wave_ultra_slow * 1.0,
);
next.l_hand.ori = Quaternion::rotation_x(-0.3);
next.l_hand.scale = Vec3::one() * 1.01;
next.r_hand.offset = Vec3::new(-6.0, 3.0, -2.0);
next.r_hand.ori = Quaternion::rotation_x(-0.3);
next.r_hand.scale = Vec3::one() * 1.01;
next.main.offset = Vec3::new(
-6.0 + skeleton_attr.weapon_x,
4.5 + skeleton_attr.weapon_y,
0.0,
);
next.main.ori = Quaternion::rotation_x(-0.3)
* Quaternion::rotation_y(0.0)
* Quaternion::rotation_z(0.0);
next.main.scale = Vec3::one();
},
Some(ToolKind::Debug(_)) => {
next.l_hand.offset = Vec3::new(-7.0, 4.0, 3.0);
next.l_hand.ori = Quaternion::rotation_x(1.27 + wave_ultra_slow * -0.1)
* Quaternion::rotation_y(0.0)
* Quaternion::rotation_z(-0.3);
next.l_hand.scale = Vec3::one() * 1.01;
next.r_hand.offset = Vec3::new(7.0, 2.5, -1.25);
next.r_hand.ori = Quaternion::rotation_x(1.27 + wave_ultra_slow * -0.1)
* Quaternion::rotation_y(0.0)
* Quaternion::rotation_z(-0.3);
next.r_hand.scale = Vec3::one() * 1.01;
next.main.offset = Vec3::new(
5.0 + skeleton_attr.weapon_x,
8.75 + skeleton_attr.weapon_y,
-2.5,
);
next.main.ori = Quaternion::rotation_x(-0.3)
* Quaternion::rotation_y(-1.27)
* Quaternion::rotation_z(wave_ultra_slow * 0.2);
next.main.scale = Vec3::one();
},
_ => {},
}
next.l_foot.offset = Vec3::new(-3.4, -1.5, 8.0 + wave_slow * 0.2);
next.l_foot.ori = Quaternion::rotation_x(wave_ultra_slow_cos * 0.015);
next.l_foot.scale = Vec3::one();
next.r_foot.offset = Vec3::new(3.4, 3.0, 8.0 + wave_slow_cos * 0.2);
next.r_foot.ori = Quaternion::rotation_x(wave_ultra_slow * 0.015);
next.r_foot.scale = Vec3::one();
next.l_shoulder.offset = Vec3::new(-5.0, 0.0, 5.0);
next.l_shoulder.ori = Quaternion::rotation_x(0.0);
next.l_shoulder.scale = Vec3::one() * 1.1;
next.r_shoulder.offset = Vec3::new(5.0, 0.0, 5.0);
next.r_shoulder.ori = Quaternion::rotation_x(0.0);
next.r_shoulder.scale = Vec3::one() * 1.1;
next.glider.offset = Vec3::new(0.0, 5.0, 0.0);
next.glider.ori = Quaternion::rotation_y(0.0);
next.glider.scale = Vec3::one() * 0.0;
next.lantern.offset = Vec3::new(0.0, 0.0, 0.0);
next.lantern.ori = Quaternion::rotation_x(0.0);
next.lantern.scale = Vec3::one() * 0.0;
next.torso.offset = Vec3::new(0.0, -0.2, 0.1) * skeleton_attr.scaler;
next.torso.ori = Quaternion::rotation_x(0.0);
next.torso.scale = Vec3::one() / 11.0 * skeleton_attr.scaler;
next
}
}

View File

@ -1,175 +0,0 @@
use super::{super::Animation, CharacterSkeleton, SkeletonAttr};
use common::comp::item::ToolKind;
use std::{f32::consts::PI, ops::Mul};
use vek::*;
pub struct WieldAnimation;
impl Animation for WieldAnimation {
type Dependency = (f32, f64);
type Skeleton = CharacterSkeleton;
fn update_skeleton(
skeleton: &Self::Skeleton,
(velocity, global_time): Self::Dependency,
anim_time: f64,
rate: &mut f32,
skeleton_attr: &SkeletonAttr,
) -> Self::Skeleton {
let mut next = (*skeleton).clone();
let wave = (anim_time as f32 * 12.0).sin();
let wave_cos = (anim_time as f32 * 12.0).cos();
let wave_diff = (anim_time as f32 * 12.0 + PI / 2.0).sin();
let wave_cos_dub = (anim_time as f32 * 24.0).cos();
let wave_stop = (anim_time as f32 * 5.0).min(PI / 2.0).sin();
let head_look = Vec2::new(
((global_time + anim_time) as f32 / 2.0)
.floor()
.mul(7331.0)
.sin()
* 0.2,
((global_time + anim_time) as f32 / 2.0)
.floor()
.mul(1337.0)
.sin()
* 0.1,
);
match ToolKind::Bow {
//TODO: Inventory
Some(ToolKind::Sword(_)) => {
next.l_hand.offset = Vec3::new(0.0, -5.0, -5.0);
next.l_hand.ori = Quaternion::rotation_x(1.27);
next.l_hand.scale = Vec3::one() * 1.04;
next.r_hand.offset = Vec3::new(0.0, -6.0, -8.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, 0.0, -6.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, 4.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();
},
ToolKind::Axe => {
next.l_hand.offset = Vec3::new(-6.0, 3.5, 0.0);
next.l_hand.ori = Quaternion::rotation_x(-0.3);
next.l_hand.scale = Vec3::one() * 1.01;
next.r_hand.offset = Vec3::new(-6.0, 3.0, -2.0);
next.r_hand.ori = Quaternion::rotation_x(-0.3);
next.r_hand.scale = Vec3::one() * 1.01;
next.weapon.offset = Vec3::new(
-6.0 + skeleton_attr.weapon_x,
4.5 + skeleton_attr.weapon_y,
0.0,
);
next.weapon.ori = Quaternion::rotation_x(-0.3)
* Quaternion::rotation_y(0.0)
* Quaternion::rotation_z(0.0);
next.weapon.scale = Vec3::one();
},
ToolKind::Hammer => {
next.l_hand.offset = Vec3::new(-7.0, 8.25, 3.0);
next.l_hand.ori = Quaternion::rotation_x(-0.3)
* Quaternion::rotation_y(-1.2)
* Quaternion::rotation_z(wave * -0.25);
next.l_hand.scale = Vec3::one() * 1.01;
next.r_hand.offset = Vec3::new(7.0, 7.0, -1.5);
next.r_hand.ori = Quaternion::rotation_x(-0.3)
* Quaternion::rotation_y(-1.2)
* Quaternion::rotation_z(wave * -0.25);
next.r_hand.scale = Vec3::one() * 1.01;
next.weapon.offset = Vec3::new(
5.0 + skeleton_attr.weapon_x,
8.75 + skeleton_attr.weapon_y,
-2.0,
);
next.weapon.ori = Quaternion::rotation_x(-0.3)
* Quaternion::rotation_y(-1.2)
* Quaternion::rotation_z(wave * -0.25);
next.weapon.scale = Vec3::one();
},
ToolKind::Staff => {
next.l_hand.offset = Vec3::new(-6.0, 3.5, 0.0);
next.l_hand.ori = Quaternion::rotation_x(-0.3);
next.l_hand.scale = Vec3::one() * 1.01;
next.r_hand.offset = Vec3::new(-6.0, 3.0, -2.0);
next.r_hand.ori = Quaternion::rotation_x(-0.3);
next.r_hand.scale = Vec3::one() * 1.01;
next.weapon.offset = Vec3::new(
-6.0 + skeleton_attr.weapon_x,
4.5 + skeleton_attr.weapon_y,
0.0,
);
next.weapon.ori = Quaternion::rotation_x(-0.3)
* Quaternion::rotation_y(0.0)
* Quaternion::rotation_z(0.0);
next.weapon.scale = Vec3::one();
},
ToolKind::SwordShield => {
next.l_hand.offset = Vec3::new(-6.0, 3.5, 0.0);
next.l_hand.ori = Quaternion::rotation_x(-0.3);
next.l_hand.scale = Vec3::one() * 1.01;
next.r_hand.offset = Vec3::new(-6.0, 3.0, -2.0);
next.r_hand.ori = Quaternion::rotation_x(-0.3);
next.r_hand.scale = Vec3::one() * 1.01;
next.weapon.offset = Vec3::new(
-6.0 + skeleton_attr.weapon_x,
4.5 + skeleton_attr.weapon_y,
0.0,
);
next.weapon.ori = Quaternion::rotation_x(-0.3)
* Quaternion::rotation_y(0.0)
* Quaternion::rotation_z(0.0);
next.weapon.scale = Vec3::one();
},
ToolKind::Bow => {
next.l_hand.offset = Vec3::new(-4.0, 5.0, 0.0);
next.l_hand.ori = Quaternion::rotation_x(0.0)
* Quaternion::rotation_y(-1.9)
* Quaternion::rotation_z(0.85);
next.l_hand.scale = Vec3::one() * 1.01;
next.r_hand.offset = Vec3::new(2.0, 8.0, -3.5);
next.r_hand.ori = Quaternion::rotation_x(0.0)
* Quaternion::rotation_y(-1.7)
* Quaternion::rotation_z(0.85);
next.r_hand.scale = Vec3::one() * 1.01;
next.weapon.offset = Vec3::new(
9.0 + skeleton_attr.weapon_x,
10.0 + skeleton_attr.weapon_y,
-3.0,
);
next.weapon.ori = Quaternion::rotation_x(0.0)
* Quaternion::rotation_y(-1.7)
* Quaternion::rotation_z(0.85 + 3.14);
next.weapon.scale = Vec3::one();
},
ToolKind::Daggers => {
next.l_hand.offset = Vec3::new(-6.0, 3.5, 0.0);
next.l_hand.ori = Quaternion::rotation_x(-0.3);
next.l_hand.scale = Vec3::one() * 1.01;
next.r_hand.offset = Vec3::new(-6.0, 3.0, -2.0);
next.r_hand.ori = Quaternion::rotation_x(-0.3);
next.r_hand.scale = Vec3::one() * 1.01;
next.weapon.offset = Vec3::new(
-6.0 + skeleton_attr.weapon_x,
4.5 + skeleton_attr.weapon_y,
0.0,
);
next.weapon.ori = Quaternion::rotation_x(-0.3)
* Quaternion::rotation_y(0.0)
* Quaternion::rotation_z(0.0);
next.weapon.scale = Vec3::one();
},
}
next
}
}

View File

@ -12,33 +12,31 @@ impl Animation for EquipAnimation {
fn update_skeleton(
skeleton: &Self::Skeleton,
(active_tool_kind, _velocity, global_time): Self::Dependency,
(active_tool_kind, velocity, global_time): Self::Dependency,
anim_time: f64,
_rate: &mut f32,
rate: &mut f32,
skeleton_attr: &SkeletonAttr,
) -> Self::Skeleton {
*rate = 1.0;
let mut next = (*skeleton).clone();
let lab = 1.0;
let foot = (((5.0)
/ (1.1 + 3.9 * ((anim_time as f32 * lab as f32 * 1.6).sin()).powf(2.0 as f32)))
/ (1.1 + 3.9 * ((anim_time as f32 * lab as f32 * 10.6).sin()).powf(2.0 as f32)))
.sqrt())
* ((anim_time as f32 * lab as f32 * 1.6).sin());
* ((anim_time as f32 * lab as f32 * 10.6).sin());
let short = (((5.0)
/ (1.5 + 3.5 * ((anim_time as f32 * lab as f32 * 1.6).sin()).powf(2.0 as f32)))
/ (1.5 + 3.5 * ((anim_time as f32 * lab as f32 * 10.6).sin()).powf(2.0 as f32)))
.sqrt())
* ((anim_time as f32 * lab as f32 * 1.6).sin());
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());
* ((anim_time as f32 * lab as f32 * 10.6).sin());
let equip_slow = 1.0 + (anim_time as f32 * 1.2 + PI).cos();
let equip_slowa = 1.0 + (anim_time as f32 * 1.2 + PI / 4.0).cos();
let equip_slow = 1.0 + (anim_time as f32 * 12.0 + PI).cos();
let equip_slowa = 1.0 + (anim_time as f32 * 12.0 + PI / 4.0).cos();
let wave_ultra_slow = (anim_time as f32 * 1.0 + PI).sin();
let wave_ultra_slow_cos = (anim_time as f32 * 3.0 + PI).cos();
let wave_ultra_slow = (anim_time as f32 * 10.0 + PI).sin();
let wave_ultra_slow_cos = (anim_time as f32 * 30.0 + PI).cos();
let wave = (anim_time as f32 * 1.0).sin();
let wave = (anim_time as f32 * 10.0).sin();
match active_tool_kind {
//TODO: Inventory
Some(ToolKind::Sword(_)) => {
@ -217,15 +215,25 @@ impl Animation for EquipAnimation {
.sin()
* 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 + long * 0.1 - 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();
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();
@ -238,17 +246,45 @@ impl Animation for EquipAnimation {
next.shorts.ori = Quaternion::rotation_z(short * 0.4);
next.shorts.scale = Vec3::one();
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();
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;
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.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;
next
} 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.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();
next.r_foot.offset = Vec3::new(3.4, 3.5, 8.0);
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.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.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
}
}

View File

@ -1,252 +0,0 @@
use super::{super::Animation, CharacterSkeleton, SkeletonAttr};
use common::comp::item::ToolKind;
use std::{f32::consts::PI, ops::Mul};
use vek::*;
pub struct IdleEquipAnimation;
impl Animation for IdleEquipAnimation {
type Dependency = (Option<ToolKind>, f32, f64);
type Skeleton = CharacterSkeleton;
fn update_skeleton(
skeleton: &Self::Skeleton,
(active_tool_kind, _velocity, global_time): Self::Dependency,
anim_time: f64,
_rate: &mut f32,
skeleton_attr: &SkeletonAttr,
) -> Self::Skeleton {
let mut next = (*skeleton).clone();
let _lab = 1.0;
let wave_slow_cos = (anim_time as f32 * 6.0 + PI).cos();
let equip_slow = 1.0 + (anim_time as f32 * 10.0 + PI).cos();
let equip_slowa = 1.0 + (anim_time as f32 * 10.0 + PI / 4.0).cos();
let wave_ultra_slow = (anim_time as f32 * 1.0 + PI).sin();
let wave_ultra_slow_cos = (anim_time as f32 * 3.0 + PI).cos();
let wave = (anim_time as f32 * 1.0).sin();
match active_tool_kind {
//TODO: Inventory
Some(ToolKind::Sword(_)) => {
next.l_hand.offset = Vec3::new(-0.25, -5.0, -5.0);
next.l_hand.ori = Quaternion::rotation_x(1.57) * Quaternion::rotation_y(-0.2);
next.l_hand.scale = Vec3::one() * 1.04;
next.r_hand.offset = Vec3::new(1.25, -5.5, -8.0);
next.r_hand.ori = Quaternion::rotation_x(1.57) * Quaternion::rotation_y(0.3);
next.r_hand.scale = Vec3::one() * 1.05;
next.main.offset = Vec3::new(0.0, 0.0, -6.0);
next.main.ori = Quaternion::rotation_x(0.0)
* Quaternion::rotation_y(0.0)
* Quaternion::rotation_z(0.0);
next.main.scale = Vec3::one();
next.control.offset =
Vec3::new(-3.0 + equip_slowa * -1.5, -5.0, 12.0 + equip_slow * 1.5);
next.control.ori = Quaternion::rotation_x(0.0)
* Quaternion::rotation_y(2.5)
* Quaternion::rotation_z(1.57);
next.control.scale = Vec3::one();
},
Some(ToolKind::Axe(_)) => {
next.l_hand.offset = Vec3::new(-4.0, 3.0, 6.0);
next.l_hand.ori = Quaternion::rotation_x(-0.3)
* Quaternion::rotation_z(3.14 - 0.3)
* Quaternion::rotation_y(-0.8);
next.l_hand.scale = Vec3::one() * 1.08;
next.r_hand.offset = Vec3::new(-2.5, 9.0, 4.0);
next.r_hand.ori = Quaternion::rotation_x(-0.3)
* Quaternion::rotation_z(3.14 - 0.3)
* Quaternion::rotation_y(-0.8);
next.r_hand.scale = Vec3::one() * 1.06;
next.main.offset = Vec3::new(-6.0, 10.0, -1.0);
next.main.ori = Quaternion::rotation_x(1.27)
* Quaternion::rotation_y(-0.3)
* Quaternion::rotation_z(-0.8);
next.main.scale = Vec3::one();
next.control.offset = Vec3::new(0.0, 0.0, 0.0);
next.control.ori = Quaternion::rotation_x(0.2)
* Quaternion::rotation_y(-0.3)
* Quaternion::rotation_z(0.0);
next.control.scale = Vec3::one();
},
Some(ToolKind::Hammer(_)) => {
next.l_hand.offset = Vec3::new(-7.0 + 9.0, 4.6 + 1.5, 7.5 - 1.6);
next.l_hand.ori = Quaternion::rotation_x(0.0) * Quaternion::rotation_y(0.32);
next.l_hand.scale = Vec3::one() * 1.08;
next.r_hand.offset = Vec3::new(8.0, 5.75, 4.0);
next.r_hand.ori = Quaternion::rotation_x(0.0) * Quaternion::rotation_y(0.22);
next.r_hand.scale = Vec3::one() * 1.06;
next.main.offset = Vec3::new(6.0, 7.0, 0.0);
next.main.ori = Quaternion::rotation_x(0.0)
* Quaternion::rotation_y(-1.35)
* Quaternion::rotation_z(1.57);
next.main.scale = Vec3::one();
next.control.offset =
Vec3::new(-3.0 + equip_slowa * -1.5, -12.0, 12.0 + equip_slow * 1.5);
next.control.ori = Quaternion::rotation_x(0.0)
* Quaternion::rotation_y(1.35 + 2.5)
* Quaternion::rotation_z(0.0);
next.control.scale = Vec3::one();
},
Some(ToolKind::Staff(_)) => {
next.l_hand.offset = Vec3::new(1.0, -2.0, -5.0);
next.l_hand.ori = Quaternion::rotation_x(1.47) * Quaternion::rotation_y(-0.3);
next.l_hand.scale = Vec3::one() * 1.05;
next.r_hand.offset = Vec3::new(9.0, 1.0, 0.0);
next.r_hand.ori = Quaternion::rotation_x(1.8)
* Quaternion::rotation_y(0.5)
* Quaternion::rotation_z(-0.27);
next.r_hand.scale = Vec3::one() * 1.05;
next.main.offset = Vec3::new(11.0, 9.0, 10.0);
next.main.ori = Quaternion::rotation_x(-0.3)
* Quaternion::rotation_y(3.14 + 0.3)
* Quaternion::rotation_z(0.9);
next.main.scale = Vec3::one();
next.control.offset = Vec3::new(-7.0, 6.0, 6.0);
next.control.ori = Quaternion::rotation_x(wave_ultra_slow * 0.2)
* Quaternion::rotation_y(0.0)
* Quaternion::rotation_z(wave_ultra_slow_cos * 0.1);
next.control.scale = Vec3::one();
},
Some(ToolKind::Shield(_)) => {
next.l_hand.offset = Vec3::new(-6.0, 3.5, 0.0);
next.l_hand.ori = Quaternion::rotation_x(-0.3);
next.l_hand.scale = Vec3::one() * 1.01;
next.r_hand.offset = Vec3::new(-6.0, 3.0, -2.0);
next.r_hand.ori = Quaternion::rotation_x(-0.3);
next.r_hand.scale = Vec3::one() * 1.01;
next.main.offset = Vec3::new(
-6.0 + skeleton_attr.weapon_x,
4.5 + skeleton_attr.weapon_y,
0.0,
);
next.main.ori = Quaternion::rotation_x(-0.3)
* Quaternion::rotation_y(0.0)
* Quaternion::rotation_z(0.0);
next.main.scale = Vec3::one();
},
Some(ToolKind::Bow(_)) => {
next.l_hand.offset = Vec3::new(1.0, -4.0, -1.0);
next.l_hand.ori = Quaternion::rotation_x(1.20)
* 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, -5.0);
next.r_hand.ori = Quaternion::rotation_x(1.20)
* 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(wave_ultra_slow * 0.2)
* Quaternion::rotation_y(0.0)
* Quaternion::rotation_z(wave_ultra_slow_cos * 0.1);
next.control.scale = Vec3::one();
},
Some(ToolKind::Dagger(_)) => {
next.l_hand.offset = Vec3::new(-6.0, 3.5, 0.0);
next.l_hand.ori = Quaternion::rotation_x(-0.3);
next.l_hand.scale = Vec3::one() * 1.01;
next.r_hand.offset = Vec3::new(-6.0, 3.0, -2.0);
next.r_hand.ori = Quaternion::rotation_x(-0.3);
next.r_hand.scale = Vec3::one() * 1.01;
next.main.offset = Vec3::new(
-6.0 + skeleton_attr.weapon_x,
4.5 + skeleton_attr.weapon_y,
0.0,
);
next.main.ori = Quaternion::rotation_x(-0.3)
* Quaternion::rotation_y(0.0)
* Quaternion::rotation_z(0.0);
next.main.scale = Vec3::one();
},
Some(ToolKind::Debug(_)) => {
next.l_hand.offset = Vec3::new(-7.0, 4.0, 3.0);
next.l_hand.ori = Quaternion::rotation_x(1.27 + wave * 0.25)
* Quaternion::rotation_y(0.0)
* Quaternion::rotation_z(0.0);
next.l_hand.scale = Vec3::one() * 1.01;
next.r_hand.offset = Vec3::new(7.0, 2.5, -1.25);
next.r_hand.ori = Quaternion::rotation_x(1.27 + wave * 0.25)
* Quaternion::rotation_y(0.0)
* Quaternion::rotation_z(-0.3);
next.r_hand.scale = Vec3::one() * 1.01;
next.main.offset = Vec3::new(
5.0 + skeleton_attr.weapon_x,
8.75 + skeleton_attr.weapon_y,
-2.0,
);
next.main.ori = Quaternion::rotation_x(-0.3)
* Quaternion::rotation_y(-1.27)
* Quaternion::rotation_z(wave * -0.25);
next.main.scale = Vec3::one();
},
_ => {},
}
let head_look = Vec2::new(
((global_time + anim_time) as f32 / 10.0)
.floor()
.mul(7331.0)
.sin()
* 0.2,
((global_time + anim_time) as f32 / 10.0)
.floor()
.mul(1337.0)
.sin()
* 0.1,
);
next.head.offset = Vec3::new(
0.0 + skeleton_attr.neck_right,
-2.0 + skeleton_attr.neck_forward,
skeleton_attr.neck_height + 14.0 + wave_ultra_slow * 0.1,
);
next.head.ori =
Quaternion::rotation_z(head_look.x) * Quaternion::rotation_x(head_look.y.abs());
next.head.scale = Vec3::one() * skeleton_attr.head_scale;
next.chest.offset = Vec3::new(0.0 + wave_slow_cos * 0.5, 0.0, 7.0 + wave_ultra_slow * 0.5);
next.chest.ori =
Quaternion::rotation_y(wave_ultra_slow_cos * 0.04) * Quaternion::rotation_z(0.15);
next.chest.scale = Vec3::one();
next.belt.offset = Vec3::new(0.0, 0.0, -2.0);
next.belt.ori =
Quaternion::rotation_y(wave_ultra_slow_cos * 0.03) * Quaternion::rotation_z(0.22);
next.belt.scale = Vec3::one() * 1.02;
next.shorts.offset = Vec3::new(0.0, 0.0, -5.0);
next.shorts.ori = Quaternion::rotation_z(0.3);
next.shorts.scale = Vec3::one();
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();
next.r_foot.offset = Vec3::new(3.4, 3.5, 8.0);
next.r_foot.ori = Quaternion::rotation_x(wave_ultra_slow * 0.035);
next.r_foot.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.l_control.offset = Vec3::new(0.0, 0.0, 0.0);
next.l_control.ori = Quaternion::rotation_x(0.0);
next.l_control.scale = Vec3::one();
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

@ -2,12 +2,10 @@ pub mod attack;
pub mod block;
pub mod blockidle;
pub mod charge;
pub mod cidle;
pub mod climb;
pub mod equip;
pub mod gliding;
pub mod idle;
pub mod idleequip;
pub mod idlewield;
pub mod jump;
pub mod roll;
@ -22,8 +20,8 @@ pub mod wield;
// Reexports
pub use self::{
attack::AttackAnimation, block::BlockAnimation, blockidle::BlockIdleAnimation,
charge::ChargeAnimation, cidle::CidleAnimation, climb::ClimbAnimation, equip::EquipAnimation,
gliding::GlidingAnimation, idle::IdleAnimation, idleequip::IdleEquipAnimation,
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,

View File

@ -2,43 +2,34 @@ use super::{super::Animation, CharacterSkeleton, SkeletonAttr};
use common::comp::item::ToolKind;
use vek::*;
pub struct Input {
pub attack: bool,
}
pub struct ShootAnimation;
impl Animation for ShootAnimation {
type Dependency = (Option<ToolKind>, f64);
type Dependency = (Option<ToolKind>, f32, f64);
type Skeleton = CharacterSkeleton;
fn update_skeleton(
skeleton: &Self::Skeleton,
(active_tool_kind, _global_time): Self::Dependency,
(active_tool_kind, velocity, _global_time): Self::Dependency,
anim_time: f64,
rate: &mut f32,
skeleton_attr: &SkeletonAttr,
) -> Self::Skeleton {
*rate = 1.0;
let mut next = (*skeleton).clone();
let lab = 1.0;
let accel_med = 1.0 - (anim_time as f32 * 16.0 * lab as f32).cos();
let accel_slow = 1.0 - (anim_time as f32 * 12.0 * lab as f32).cos();
let accel_fast = 1.0 - (anim_time as f32 * 24.0 * lab as f32).cos();
let foot = (((5.0)
/ (1.1 + 3.9 * ((anim_time as f32 * lab as f32 * 15.0).sin()).powf(2.0 as f32)))
.sqrt())
* ((anim_time as f32 * lab as f32 * 15.0).sin());
let quick = (((5.0)
/ (0.5 + 4.5 * ((anim_time as f32 * lab as f32 * 2.0).cos()).powf(2.0 as f32)))
.sqrt())
* ((anim_time as f32 * lab as f32 * 2.0).cos());
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 slower = (((5.0)
/ (0.1 + 4.9 * ((anim_time as f32 * lab as f32 * 4.0).sin()).powf(2.0 as f32)))
.sqrt())
* ((anim_time as f32 * lab as f32 * 4.0).sin());
let sloweralt = (((5.0)
/ (0.1 + 4.9 * ((anim_time as f32 * lab as f32 * 4.0).cos()).powf(2.0 as f32)))
.sqrt())
@ -70,71 +61,6 @@ impl Animation for ShootAnimation {
match active_tool_kind {
//TODO: Inventory
Some(ToolKind::Sword(_)) => {
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.04;
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(-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();
},
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();
},
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();
},
Some(ToolKind::Staff(_)) => {
next.l_hand.offset = Vec3::new(1.0, -2.0, -5.0);
next.l_hand.ori = Quaternion::rotation_x(1.47) * Quaternion::rotation_y(-0.3);
@ -156,31 +82,6 @@ impl Animation for ShootAnimation {
* Quaternion::rotation_z(quick * 1.5);
next.control.scale = Vec3::one();
},
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();
},
Some(ToolKind::Bow(_)) => {
next.l_hand.offset = Vec3::new(
1.0 - sloweralt * 2.0,
@ -208,58 +109,38 @@ impl Animation for ShootAnimation {
* Quaternion::rotation_z(0.0);
next.control.scale = Vec3::one();
},
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();
},
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();
},
_ => {},
}
if velocity > 0.5 {
next.l_foot.offset = Vec3::new(-3.4, foot * -2.0, 8.0);
next.l_foot.ori = Quaternion::rotation_x(foot * -0.4);
next.l_foot.scale = Vec3::one();
next.r_foot.offset = Vec3::new(3.4, foot * 2.0, 8.0);
next.r_foot.ori = Quaternion::rotation_x(foot * 0.4);
next.r_foot.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.15)
* Quaternion::rotation_y(0.0);
next.torso.scale = Vec3::one() / 11.0 * skeleton_attr.scaler;
} else {
next.l_foot.offset = Vec3::new(-3.4, -2.5, 8.0 + (quick * 2.5).max(0.0));
next.l_foot.ori = Quaternion::rotation_x(quick * -0.2 - 0.2)
* Quaternion::rotation_z((quick * 1.0).max(0.0));
next.l_foot.scale = Vec3::one();
next.r_foot.offset = Vec3::new(3.4, 3.5 - quick * 2.0, 8.0);
next.r_foot.ori = Quaternion::rotation_x(quick * 0.1)
* Quaternion::rotation_z((quick * 0.5).max(0.0));
next.r_foot.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_shoulder.offset = Vec3::new(-5.0, 0.0, 4.7);
next.l_shoulder.ori = Quaternion::rotation_x(0.0);
next.l_shoulder.scale = Vec3::one() * 1.1;
@ -276,11 +157,6 @@ impl Animation for ShootAnimation {
next.lantern.ori = Quaternion::rotation_x(0.0);
next.lantern.scale = Vec3::one() * 0.0;
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_control.offset = Vec3::new(0.0, 0.0, 0.0);
next.l_control.ori = Quaternion::rotation_x(0.0);
next.l_control.scale = Vec3::one();

View File

@ -1,147 +0,0 @@
use super::{
super::{Animation, },
CharacterSkeleton,SkeletonAttr
};
use std::f32::consts::PI;
use std::ops::Mul;
use vek::*;
pub struct SneakAnimation;
impl Animation for SneakAnimation {
type Skeleton = CharacterSkeleton;
type Dependency = (Vec3<f32>, Vec3<f32>, Vec3<f32>, f64);
fn update_skeleton(
skeleton: &Self::Skeleton,
(velocity, orientation, last_ori, global_time): Self::Dependency,
anim_time: f64,
rate: &mut f32,
skeleton_attr: &SkeletonAttr,
) -> Self::Skeleton {
let mut next = (*skeleton).clone();
let speed = Vec2::<f32>::from(velocity).magnitude();
*rate = speed;
let constant = 1.0;
let wave = (((5.0)
/ (1.1 + 3.9 * ((anim_time as f32 * constant as f32 * 1.2).sin()).powf(2.0 as f32)))
.sqrt())
* ((anim_time as f32 * constant as f32 * 1.2).sin());
let wavecos = (((5.0)
/ (1.1 + 3.9 * ((anim_time as f32 * constant as f32 * 1.2).sin()).powf(2.0 as f32)))
.sqrt())
* ((anim_time as f32 * constant as f32 * 1.2).cos());
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());
let wave_cos_dub = (((5.0)
/ (1.1 + 3.9 * ((anim_time as f32 * constant as f32 * 4.8).sin()).powf(2.0 as f32)))
.sqrt())
* ((anim_time as f32 * constant as f32 * 1.5).sin());
let wave_slow = (anim_time as f32 * 0.1).sin();
let wave_diff = (anim_time as f32 * 0.6).sin();
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 * 0.25)
.floor()
.mul(7331.0)
.sin()
* 0.4,
((global_time + anim_time) as f32 * 0.25)
.floor()
.mul(1337.0)
.sin()
* 0.2,
);
let ori = Vec2::from(orientation);
let last_ori = Vec2::from(last_ori);
let tilt = if Vec2::new(ori, last_ori)
.map(|o| Vec2::<f32>::from(o).magnitude_squared())
.map(|m| m > 0.001 && m.is_finite())
.reduce_and()
&& ori.angle_between(last_ori).is_finite()
{
ori.angle_between(last_ori).min(0.5)
* last_ori.determine_side(Vec2::zero(), ori).signum()
} else {
0.0
} * 1.3;
next.head.offset = Vec3::new(
0.0,
0.0 + skeleton_attr.neck_forward,
skeleton_attr.neck_height + 16.0,
);
next.head.ori = Quaternion::rotation_z(head_look.x + wave * 0.1)
* Quaternion::rotation_x(head_look.y + 0.05);
next.head.scale = Vec3::one() * skeleton_attr.head_scale;
next.chest.offset = Vec3::new(0.0, -1.5, 3.0 + wave_slow * 2.0);
next.chest.ori = Quaternion::rotation_x(-0.5) * Quaternion::rotation_z(wave * 0.15);
next.chest.scale = Vec3::one();
next.belt.offset = Vec3::new(0.0, 0.0, 1.5 + wave_cos * 0.3);
next.belt.ori = Quaternion::rotation_x(-0.1) * Quaternion::rotation_z(wave * 0.25);
next.belt.scale = Vec3::one();
next.shorts.offset = Vec3::new(0.0, 1.0, -1.0 + wave_cos * 0.3);
next.shorts.ori = Quaternion::rotation_x(0.2) * Quaternion::rotation_z(wave * 0.4);
next.shorts.scale = Vec3::one();
next.l_hand.offset = Vec3::new(-5.0 + wave_stop * -0.5, 2.25, 4.0 - wave * 1.0);
next.l_hand.ori =
Quaternion::rotation_x(1.5 + wave_cos * 0.1) * Quaternion::rotation_y(wave_stop * 0.1);
next.l_hand.scale = Vec3::one();
next.r_hand.offset = Vec3::new(5.0 + wave_stop * 0.5, 2.25, 4.0 + wave * 1.0);
next.r_hand.ori = Quaternion::rotation_x(1.5 + wave_cos * -0.1)
* Quaternion::rotation_y(wave_stop * -0.1);
next.r_hand.scale = Vec3::one();
next.l_foot.offset = Vec3::new(-3.4, 5.0 + wave * -3.0, 4.0);
next.l_foot.ori = Quaternion::rotation_x(-0.8 + wavecos * 0.15);
next.l_foot.scale = Vec3::one();
next.r_foot.offset = Vec3::new(3.4, 5.0 + wave * 3.0, 4.0);
next.r_foot.ori = Quaternion::rotation_x(-0.8 - wavecos * 0.15);
next.r_foot.scale = Vec3::one();
next.main.offset = Vec3::new(
-7.0 + skeleton_attr.weapon_x,
-5.0 + skeleton_attr.weapon_y,
15.0,
);
next.main.ori =
Quaternion::rotation_y(2.5) * Quaternion::rotation_z(1.57 + wave_cos * 0.25);
next.main.scale = Vec3::one();
next.l_shoulder.offset = Vec3::new(-5.0, 0.0, 4.7);
next.l_shoulder.ori = Quaternion::rotation_x(wavecos * 0.05);
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.05);
next.r_shoulder.scale = Vec3::one() * 1.1;
next.glider.offset = Vec3::new(0.0, 5.0, 0.0);
next.glider.ori = Quaternion::rotation_y(0.0);
next.glider.scale = Vec3::one() * 0.0;
next.lantern.offset = Vec3::new(0.0, 5.0, 0.0);
next.lantern.ori = Quaternion::rotation_y(0.0);
next.lantern.scale = Vec3::one() * 0.0;
next.torso.offset = Vec3::new(0.0, 0.3 + wave * -0.08, 0.4) * skeleton_attr.scaler;
next.torso.ori =
Quaternion::rotation_x(wave_stop * speed * -0.03 + wave_diff * speed * -0.005)
* Quaternion::rotation_y(tilt);
next.torso.scale = Vec3::one() / 11.0 * skeleton_attr.scaler;
next
}
}

View File

@ -473,7 +473,7 @@ impl FigureMgr {
CharacterState::BasicMelee(_) => {
anim::character::AttackAnimation::update_skeleton(
&target_base,
(active_tool_kind, time),
(active_tool_kind, vel.0.magnitude(), time),
state.state_time,
&mut state_animation_rate,
skeleton_attr,
@ -482,7 +482,7 @@ impl FigureMgr {
CharacterState::BasicRanged(_) => {
anim::character::ShootAnimation::update_skeleton(
&target_base,
(active_tool_kind, time),
(active_tool_kind, vel.0.magnitude(), time),
state.state_time,
&mut state_animation_rate,
skeleton_attr,
@ -491,7 +491,7 @@ impl FigureMgr {
CharacterState::Boost(_) => {
anim::character::AttackAnimation::update_skeleton(
&target_base,
(active_tool_kind, time),
(active_tool_kind, vel.0.magnitude(), time),
state.state_time,
&mut state_animation_rate,
skeleton_attr,
@ -509,7 +509,7 @@ impl FigureMgr {
CharacterState::TripleStrike(s) => match s.stage {
0 => anim::character::AttackAnimation::update_skeleton(
&target_base,
(active_tool_kind, time),
(active_tool_kind, vel.0.magnitude(), time),
state.state_time,
&mut state_animation_rate,
skeleton_attr,
@ -523,7 +523,7 @@ impl FigureMgr {
),
_ => anim::character::AttackAnimation::update_skeleton(
&target_base,
(active_tool_kind, time),
(active_tool_kind, vel.0.magnitude(), time),
state.state_time,
&mut state_animation_rate,
skeleton_attr,
@ -532,7 +532,7 @@ impl FigureMgr {
CharacterState::TimedCombo(s) => match s.stage {
0 | 2 => anim::character::AttackAnimation::update_skeleton(
&target_base,
(active_tool_kind, time),
(active_tool_kind, vel.0.magnitude(), time),
state.state_time,
&mut state_animation_rate,
skeleton_attr,
@ -565,7 +565,6 @@ impl FigureMgr {
)
}*/
CharacterState::Equipping { .. } => {
if vel.0.magnitude_squared() > 0.5 {
anim::character::EquipAnimation::update_skeleton(
&target_base,
(active_tool_kind, vel.0.magnitude(), time),
@ -573,15 +572,6 @@ impl FigureMgr {
&mut state_animation_rate,
skeleton_attr,
)
} else {
anim::character::IdleEquipAnimation::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 {