axe attack

This commit is contained in:
jshipsey 2020-03-22 00:11:24 -04:00
parent b96d71a8c7
commit 32c85d1bab
2 changed files with 63 additions and 41 deletions

View File

@ -42,6 +42,10 @@ impl Animation for AttackAnimation {
/ (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());
match active_tool_kind {
//TODO: Inventory
@ -100,55 +104,54 @@ impl Animation for AttackAnimation {
},
Some(ToolKind::Axe(_)) => {
next.head.offset = Vec3::new(
0.0 + skeleton_attr.neck_right,
-2.0 + skeleton_attr.neck_forward,
skeleton_attr.neck_height + 21.0,
0.0 + skeleton_attr.neck_right + slowax * 2.0,
-2.0 + skeleton_attr.neck_forward + slowax * -2.0,
skeleton_attr.neck_height + 19.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_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(decel * -0.2)
* Quaternion::rotation_x(0.0 + decel * -0.2)
* Quaternion::rotation_y(decel * 0.2);
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(decel * -0.1)
* Quaternion::rotation_x(0.0 + decel * -0.1)
* Quaternion::rotation_y(decel * 0.1);
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(decel * -0.08)
* Quaternion::rotation_x(0.0 + decel * -0.08)
* Quaternion::rotation_y(decel * 0.08);
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(-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.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);

View File

@ -1,6 +1,6 @@
use super::{super::Animation, CharacterSkeleton, SkeletonAttr};
use common::comp::item::ToolKind;
use std::f32::consts::PI;
use std::{f32::consts::PI, ops::Mul};
use vek::*;
@ -12,16 +12,20 @@ impl Animation for WieldAnimation {
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,
skeleton_attr: &SkeletonAttr,
) -> Self::Skeleton {
let mut next = (*skeleton).clone();
let lab = 1.0;
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 long = (((5.0)
/ (1.5 + 3.5 * ((anim_time as f32 * lab as f32 * 0.66).sin()).powf(2.0 as f32)))
.sqrt())
* ((anim_time as f32 * lab as f32 * 0.66).sin());
let wave = (anim_time as f32 * 1.0).sin();
match active_tool_kind {
//TODO: Inventory
@ -61,10 +65,10 @@ impl Animation for WieldAnimation {
* Quaternion::rotation_z(-0.8);
next.main.scale = Vec3::one();
next.control.offset = Vec3::new(0.0, 0.0, -2.0);
next.control.offset = Vec3::new(0.0, 0.0, 0.0);
next.control.ori = Quaternion::rotation_x(wave_ultra_slow_cos * 0.1 + 0.2)
* Quaternion::rotation_y(-0.3)
* Quaternion::rotation_z(wave_ultra_slow * 0.1 - 0.5);
* Quaternion::rotation_z(wave_ultra_slow * 0.1 + 0.0);
next.control.scale = Vec3::one();
},
Some(ToolKind::Hammer(_)) => {
@ -187,6 +191,21 @@ impl Animation for WieldAnimation {
},
_ => {},
}
let head_look = Vec2::new(
((global_time + anim_time) as f32 / 18.0)
.floor()
.mul(7331.0)
.sin()
* 0.2,
((global_time + anim_time) as f32 / 18.0)
.floor()
.mul(1337.0)
.sin()
* 0.1,
);
next.head.ori = Quaternion::rotation_z(head_look.x + long * 0.1)
* Quaternion::rotation_x(head_look.y + 0.0);
next.head.scale = Vec3::one() * skeleton_attr.head_scale;
next.torso.offset = Vec3::new(0.0, 0.0, 0.1) * skeleton_attr.scaler;
next.torso.ori = Quaternion::rotation_x(0.0);