2020-01-26 00:22:48 +00:00
|
|
|
use super::{super::Animation, CharacterSkeleton, SkeletonAttr};
|
2019-12-29 23:47:42 +00:00
|
|
|
use common::comp::item::ToolKind;
|
2019-07-04 14:58:59 +00:00
|
|
|
use std::f32::consts::PI;
|
2019-05-19 17:36:55 +00:00
|
|
|
use vek::*;
|
|
|
|
|
|
|
|
pub struct Input {
|
|
|
|
pub attack: bool,
|
|
|
|
}
|
|
|
|
pub struct AttackAnimation;
|
|
|
|
|
|
|
|
impl Animation for AttackAnimation {
|
2019-12-29 23:47:42 +00:00
|
|
|
type Dependency = (Option<ToolKind>, f64);
|
2020-02-01 20:39:39 +00:00
|
|
|
type Skeleton = CharacterSkeleton;
|
2019-05-19 17:36:55 +00:00
|
|
|
|
|
|
|
fn update_skeleton(
|
|
|
|
skeleton: &Self::Skeleton,
|
2020-01-29 06:38:08 +00:00
|
|
|
(active_tool_kind, _global_time): Self::Dependency,
|
2019-05-19 17:36:55 +00:00
|
|
|
anim_time: f64,
|
2020-03-08 21:02:25 +00:00
|
|
|
rate: &mut f32,
|
2019-06-28 08:24:13 +00:00
|
|
|
skeleton_attr: &SkeletonAttr,
|
2019-05-19 17:36:55 +00:00
|
|
|
) -> Self::Skeleton {
|
2020-03-08 21:02:25 +00:00
|
|
|
*rate = 1.0;
|
2019-05-19 17:36:55 +00:00
|
|
|
let mut next = (*skeleton).clone();
|
|
|
|
|
2020-03-05 14:02:11 +00:00
|
|
|
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 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());
|
2019-05-19 17:36:55 +00:00
|
|
|
|
2019-06-28 08:24:13 +00:00
|
|
|
next.head.offset = Vec3::new(
|
2019-06-28 14:45:02 +00:00
|
|
|
0.0 + skeleton_attr.neck_right,
|
2020-03-05 14:02:11 +00:00
|
|
|
-2.0 + skeleton_attr.neck_forward + decel * 0.8,
|
2019-10-02 10:05:17 +00:00
|
|
|
skeleton_attr.neck_height + 21.0,
|
2019-06-28 08:24:13 +00:00
|
|
|
);
|
2020-03-05 14:02:11 +00:00
|
|
|
next.head.ori = Quaternion::rotation_z(decel * 0.25)
|
|
|
|
* Quaternion::rotation_x(0.0 + decel * 0.1)
|
|
|
|
* Quaternion::rotation_y(decel * -0.1);
|
2019-06-28 08:24:13 +00:00
|
|
|
next.head.scale = Vec3::one() * skeleton_attr.head_scale;
|
2019-05-19 17:36:55 +00:00
|
|
|
|
2019-05-19 17:36:55 +00:00
|
|
|
next.chest.offset = Vec3::new(0.0, 0.0, 7.0);
|
2020-03-05 14:02:11 +00:00
|
|
|
next.chest.ori = Quaternion::rotation_z(decel * -0.2)
|
|
|
|
* Quaternion::rotation_x(0.0 + decel * -0.2)
|
|
|
|
* Quaternion::rotation_y(decel * 0.2);
|
2019-05-19 17:36:55 +00:00
|
|
|
next.chest.scale = Vec3::one();
|
|
|
|
|
2019-05-19 17:36:55 +00:00
|
|
|
next.belt.offset = Vec3::new(0.0, 0.0, 5.0);
|
2020-03-05 14:02:11 +00:00
|
|
|
next.belt.ori = Quaternion::rotation_z(decel * -0.1)
|
|
|
|
* Quaternion::rotation_x(0.0 + decel * -0.1)
|
|
|
|
* Quaternion::rotation_y(decel * 0.1);
|
2019-05-19 17:36:55 +00:00
|
|
|
next.belt.scale = Vec3::one();
|
|
|
|
|
2019-05-19 17:36:55 +00:00
|
|
|
next.shorts.offset = Vec3::new(0.0, 0.0, 2.0);
|
2020-03-05 14:02:11 +00:00
|
|
|
next.belt.ori = Quaternion::rotation_z(decel * -0.08)
|
|
|
|
* Quaternion::rotation_x(0.0 + decel * -0.08)
|
|
|
|
* Quaternion::rotation_y(decel * 0.08);
|
2019-05-19 17:36:55 +00:00
|
|
|
next.shorts.scale = Vec3::one();
|
|
|
|
|
2020-03-20 05:27:54 +00:00
|
|
|
|
2020-01-29 06:38:08 +00:00
|
|
|
match active_tool_kind {
|
|
|
|
//TODO: Inventory
|
2020-03-07 20:49:48 +00:00
|
|
|
Some(ToolKind::Sword(_)) => {
|
2020-03-05 14:02:11 +00:00
|
|
|
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);
|
2020-01-29 06:38:08 +00:00
|
|
|
next.main.scale = Vec3::one();
|
2020-03-05 14:02:11 +00:00
|
|
|
|
|
|
|
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();
|
2020-02-01 20:39:39 +00:00
|
|
|
},
|
2020-03-17 17:27:52 +00:00
|
|
|
Some(ToolKind::Axe(_)) => {
|
2020-01-29 06:38:08 +00:00
|
|
|
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();
|
2020-02-01 20:39:39 +00:00
|
|
|
},
|
2020-03-17 17:27:52 +00:00
|
|
|
Some(ToolKind::Hammer(_)) => {
|
2020-01-29 06:38:08 +00:00
|
|
|
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();
|
2020-02-01 20:39:39 +00:00
|
|
|
},
|
2020-03-17 17:27:52 +00:00
|
|
|
Some(ToolKind::Staff(_)) => {
|
2020-01-29 06:38:08 +00:00
|
|
|
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();
|
2020-02-01 20:39:39 +00:00
|
|
|
},
|
2020-03-17 17:27:52 +00:00
|
|
|
Some(ToolKind::Shield(_)) => {
|
2020-01-29 06:38:08 +00:00
|
|
|
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();
|
2020-02-01 20:39:39 +00:00
|
|
|
},
|
2020-03-17 17:27:52 +00:00
|
|
|
Some(ToolKind::Bow(_)) => {
|
2020-01-29 06:38:08 +00:00
|
|
|
next.l_hand.offset = Vec3::new(-7.0, -2.0 + slow * 5.0, -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, 8.0, 2.5);
|
|
|
|
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,
|
|
|
|
15.0 + skeleton_attr.weapon_y,
|
|
|
|
-4.0,
|
|
|
|
);
|
|
|
|
next.main.ori = Quaternion::rotation_x(0.0)
|
|
|
|
* Quaternion::rotation_y(0.4)
|
|
|
|
* Quaternion::rotation_z(0.0);
|
|
|
|
next.main.scale = Vec3::one();
|
2020-02-01 20:39:39 +00:00
|
|
|
},
|
2020-03-17 17:27:52 +00:00
|
|
|
Some(ToolKind::Dagger(_)) => {
|
2020-01-29 06:38:08 +00:00
|
|
|
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();
|
2020-02-01 20:39:39 +00:00
|
|
|
},
|
2020-02-03 21:02:32 +00:00
|
|
|
Some(ToolKind::Debug(_)) => {
|
2020-01-29 06:38:08 +00:00
|
|
|
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;
|
2019-05-19 17:36:55 +00:00
|
|
|
|
2020-01-29 06:38:08 +00:00
|
|
|
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();
|
2020-02-01 20:39:39 +00:00
|
|
|
},
|
|
|
|
_ => {},
|
2020-01-29 06:38:08 +00:00
|
|
|
}
|
2019-08-18 06:35:27 +00:00
|
|
|
next.l_shoulder.offset = Vec3::new(-5.0, 0.0, 4.7);
|
2019-05-19 17:36:55 +00:00
|
|
|
next.l_shoulder.ori = Quaternion::rotation_x(0.0);
|
2019-08-18 06:35:27 +00:00
|
|
|
next.l_shoulder.scale = Vec3::one() * 1.1;
|
2019-05-19 17:36:55 +00:00
|
|
|
|
2019-08-18 06:35:27 +00:00
|
|
|
next.r_shoulder.offset = Vec3::new(5.0, 0.0, 4.7);
|
2019-05-19 17:36:55 +00:00
|
|
|
next.r_shoulder.ori = Quaternion::rotation_x(0.0);
|
2019-08-18 06:35:27 +00:00
|
|
|
next.r_shoulder.scale = Vec3::one() * 1.1;
|
2019-05-19 17:36:55 +00:00
|
|
|
|
2019-12-03 06:30:08 +00:00
|
|
|
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;
|
2019-05-19 17:36:55 +00:00
|
|
|
|
2020-03-08 21:02:25 +00:00
|
|
|
next.torso.offset = Vec3::new(0.0, 0.0, 0.1) * skeleton_attr.scaler;
|
2020-03-05 14:02:11 +00:00
|
|
|
next.torso.ori =
|
|
|
|
Quaternion::rotation_z(0.0) * Quaternion::rotation_x(0.0) * Quaternion::rotation_y(0.0);
|
2019-06-28 08:24:13 +00:00
|
|
|
next.torso.scale = Vec3::one() / 11.0 * skeleton_attr.scaler;
|
2020-03-05 14:02:11 +00:00
|
|
|
|
|
|
|
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();
|
2019-05-19 17:36:55 +00:00
|
|
|
next
|
|
|
|
}
|
|
|
|
}
|