Added support for different swings in the combo melee having differnt fractions of time buildup duration is split.

This commit is contained in:
Sam 2020-09-07 11:58:52 -05:00
parent 2451a64b97
commit 2ba9d1e54f
6 changed files with 338 additions and 171 deletions

View File

@ -129,6 +129,7 @@ impl Tool {
angle: 45.0,
base_buildup_duration: Duration::from_millis(10),
base_recover_duration: Duration::from_millis(10),
swing_frac: 0.5,
},
combo_melee::Stage {
stage: 2,
@ -140,6 +141,7 @@ impl Tool {
angle: 45.0,
base_buildup_duration: Duration::from_millis(1000),
base_recover_duration: Duration::from_millis(400),
swing_frac: 0.6,
},
combo_melee::Stage {
stage: 3,
@ -151,6 +153,7 @@ impl Tool {
angle: 45.0,
base_buildup_duration: Duration::from_millis(10),
base_recover_duration: Duration::from_millis(10),
swing_frac: 0.5,
},
],
initial_energy_gain: 0,
@ -178,6 +181,7 @@ impl Tool {
angle: 45.0,
base_buildup_duration: Duration::from_millis(150),
base_recover_duration: Duration::from_millis(100),
swing_frac: 0.5,
},
combo_melee::Stage {
stage: 2,
@ -189,6 +193,7 @@ impl Tool {
angle: 45.0,
base_buildup_duration: Duration::from_millis(150),
base_recover_duration: Duration::from_millis(100),
swing_frac: 0.6,
},
combo_melee::Stage {
stage: 3,
@ -200,6 +205,7 @@ impl Tool {
angle: 45.0,
base_buildup_duration: Duration::from_millis(150),
base_recover_duration: Duration::from_millis(100),
swing_frac: 0.5,
},
],
initial_energy_gain: 0,

View File

@ -26,6 +26,8 @@ pub struct Stage {
pub base_buildup_duration: Duration,
/// Initial recover duration of stage (how long until character exits state)
pub base_recover_duration: Duration,
/// Determines what portion of the buildup duration is a swing. Used for animation purposes.
pub swing_frac: f64,
}
/// Determines whether state is in buildup, swing, recover, or combo

View File

@ -11,7 +11,7 @@ use std::f32::consts::PI;
pub struct AlphaAnimation;
impl Animation for AlphaAnimation {
type Dependency = (Option<ToolKind>, Option<ToolKind>, f32, f64);
type Dependency = (Option<ToolKind>, Option<ToolKind>, f32, f64, Option<StageSection>);
type Skeleton = CharacterSkeleton;
#[cfg(feature = "use-dyn-lib")]
@ -21,7 +21,7 @@ impl Animation for AlphaAnimation {
#[allow(clippy::approx_constant)] // TODO: Pending review in #587
fn update_skeleton_inner(
skeleton: &Self::Skeleton,
(active_tool_kind, second_tool_kind, velocity, _global_time): Self::Dependency,
(active_tool_kind, second_tool_kind, velocity, _global_time, stage_section): Self::Dependency,
anim_time: f64,
rate: &mut f32,
skeleton_attr: &SkeletonAttr,
@ -67,70 +67,72 @@ impl Animation for AlphaAnimation {
match active_tool_kind {
//TODO: Inventory
Some(ToolKind::Sword(_)) => {
next.head.position =
Vec3::new(0.0, -2.0 + skeleton_attr.head.0, skeleton_attr.head.1);
next.head.orientation = Quaternion::rotation_z(slow * -0.25)
* Quaternion::rotation_x(0.0 + slow * 0.15)
* Quaternion::rotation_y(slow * -0.15);
next.head.scale = Vec3::one() * skeleton_attr.head_scale;
if let Some(stage_section) = stage_section {
next.head.position =
Vec3::new(0.0, -2.0 + skeleton_attr.head.0, skeleton_attr.head.1);
next.head.orientation = Quaternion::rotation_z(slow * -0.25)
* Quaternion::rotation_x(0.0 + slow * 0.15)
* Quaternion::rotation_y(slow * -0.15);
next.head.scale = Vec3::one() * skeleton_attr.head_scale;
next.chest.position = Vec3::new(0.0, skeleton_attr.chest.0, skeleton_attr.chest.1);
next.chest.orientation = Quaternion::rotation_z(slow * 0.4)
* Quaternion::rotation_x(0.0 + slow * -0.2)
* Quaternion::rotation_y(slow * 0.2);
next.chest.scale = Vec3::one();
next.chest.position = Vec3::new(0.0, skeleton_attr.chest.0, skeleton_attr.chest.1);
next.chest.orientation = Quaternion::rotation_z(slow * 0.4)
* Quaternion::rotation_x(0.0 + slow * -0.2)
* Quaternion::rotation_y(slow * 0.2);
next.chest.scale = Vec3::one();
next.belt.position = Vec3::new(0.0, skeleton_attr.belt.0, skeleton_attr.belt.1);
next.belt.orientation = next.chest.orientation * -0.3;
next.belt.position = Vec3::new(0.0, skeleton_attr.belt.0, skeleton_attr.belt.1);
next.belt.orientation = next.chest.orientation * -0.3;
next.shorts.position =
Vec3::new(0.0, skeleton_attr.shorts.0, skeleton_attr.shorts.1);
next.shorts.orientation = next.chest.orientation * -0.45;
next.shorts.position =
Vec3::new(0.0, skeleton_attr.shorts.0, skeleton_attr.shorts.1);
next.shorts.orientation = next.chest.orientation * -0.45;
next.l_hand.position = Vec3::new(-0.75, -1.0, -2.5);
next.l_hand.orientation = Quaternion::rotation_x(1.27);
next.l_hand.scale = Vec3::one() * 1.05;
next.r_hand.position = Vec3::new(0.75, -1.5, -5.5);
next.r_hand.orientation = Quaternion::rotation_x(1.27);
next.r_hand.scale = Vec3::one() * 1.05;
next.main.position = Vec3::new(0.0, 0.0, 0.0);
next.main.orientation = Quaternion::rotation_x(-0.3)
* Quaternion::rotation_y(0.0)
* Quaternion::rotation_z(0.0);
next.l_hand.position = Vec3::new(-0.75, -1.0, -2.5);
next.l_hand.orientation = Quaternion::rotation_x(1.27);
next.l_hand.scale = Vec3::one() * 1.05;
next.r_hand.position = Vec3::new(0.75, -1.5, -5.5);
next.r_hand.orientation = Quaternion::rotation_x(1.27);
next.r_hand.scale = Vec3::one() * 1.05;
next.main.position = Vec3::new(0.0, 0.0, 0.0);
next.main.orientation = Quaternion::rotation_x(-0.3)
* Quaternion::rotation_y(0.0)
* Quaternion::rotation_z(0.0);
next.control.position = Vec3::new(-10.0 + push * 5.0, 6.0 + push * 5.0, 2.0);
next.control.orientation = Quaternion::rotation_x(-1.4 + slow * 0.4)
* Quaternion::rotation_y(slow * -1.3)
* Quaternion::rotation_z(1.4 + slow * -0.5);
next.control.scale = Vec3::one();
next.control.position = Vec3::new(-10.0 + push * 5.0, 6.0 + push * 5.0, 2.0);
next.control.orientation = Quaternion::rotation_x(-1.4 + slow * 0.4)
* Quaternion::rotation_y(slow * -1.3)
* Quaternion::rotation_z(1.4 + slow * -0.5);
next.control.scale = Vec3::one();
next.l_foot.position = Vec3::new(
-skeleton_attr.foot.0,
slow * -3.0 + quick * 3.0 - 4.0,
skeleton_attr.foot.2,
);
next.l_foot.orientation = Quaternion::rotation_x(slow * 0.6)
* Quaternion::rotation_y((slow * -0.2).max(0.0));
next.l_foot.scale = Vec3::one();
next.l_foot.position = Vec3::new(
-skeleton_attr.foot.0,
slow * -3.0 + quick * 3.0 - 4.0,
skeleton_attr.foot.2,
);
next.l_foot.orientation = Quaternion::rotation_x(slow * 0.6)
* Quaternion::rotation_y((slow * -0.2).max(0.0));
next.l_foot.scale = Vec3::one();
next.r_foot.position = Vec3::new(
skeleton_attr.foot.0,
slow * 3.0 + quick * -3.0 + 5.0,
skeleton_attr.foot.2,
);
next.r_foot.orientation = Quaternion::rotation_x(slow * -0.6)
* Quaternion::rotation_y((slow * 0.2).min(0.0));
next.r_foot.scale = Vec3::one();
next.r_foot.position = Vec3::new(
skeleton_attr.foot.0,
slow * 3.0 + quick * -3.0 + 5.0,
skeleton_attr.foot.2,
);
next.r_foot.orientation = Quaternion::rotation_x(slow * -0.6)
* Quaternion::rotation_y((slow * 0.2).min(0.0));
next.r_foot.scale = Vec3::one();
next.lantern.orientation =
Quaternion::rotation_x(slow * -0.7 + 0.4) * Quaternion::rotation_y(slow * 0.4);
next.hold.scale = Vec3::one() * 0.0;
next.lantern.orientation =
Quaternion::rotation_x(slow * -0.7 + 0.4) * Quaternion::rotation_y(slow * 0.4);
next.hold.scale = Vec3::one() * 0.0;
next.torso.position = Vec3::new(0.0, 0.0, 0.1) * skeleton_attr.scaler;
next.torso.orientation = 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.torso.position = Vec3::new(0.0, 0.0, 0.1) * skeleton_attr.scaler;
next.torso.orientation = 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.position =

View File

@ -2,12 +2,15 @@ use super::{
super::{vek::*, Animation},
CharacterSkeleton, SkeletonAttr,
};
use common::comp::item::{Hands, ToolKind};
use common::{
comp::item::{Hands, ToolKind},
states::combo_melee::StageSection,
};
pub struct BetaAnimation;
impl Animation for BetaAnimation {
type Dependency = (Option<ToolKind>, Option<ToolKind>, f32, f64);
type Dependency = (Option<ToolKind>, Option<ToolKind>, f32, f64, Option<StageSection>);
type Skeleton = CharacterSkeleton;
#[cfg(feature = "use-dyn-lib")]
@ -16,7 +19,7 @@ impl Animation for BetaAnimation {
#[cfg_attr(feature = "be-dyn-lib", export_name = "character_beta")]
fn update_skeleton_inner(
skeleton: &Self::Skeleton,
(active_tool_kind, second_tool_kind, _velocity, _global_time): Self::Dependency,
(active_tool_kind, second_tool_kind, _velocity, _global_time, stage_section): Self::Dependency,
anim_time: f64,
rate: &mut f32,
skeleton_attr: &SkeletonAttr,
@ -43,62 +46,215 @@ impl Animation for BetaAnimation {
.sqrt())
* ((anim_time as f32 * lab as f32 * 14.0).sin());
if let Some(
ToolKind::Axe(_) | ToolKind::Hammer(_) | ToolKind::Sword(_) | ToolKind::Dagger(_),
) = active_tool_kind
{
//INTENTION: SWORD
next.head.position = Vec3::new(0.0, -2.0 + skeleton_attr.head.0, skeleton_attr.head.1);
next.head.orientation = Quaternion::rotation_z(slow * -0.18)
* Quaternion::rotation_x(-0.1 + slow * -0.28)
* Quaternion::rotation_y(0.2 + slow * 0.18);
next.head.scale = Vec3::one() * skeleton_attr.head_scale;
match active_tool_kind {
Some(ToolKind::Sword(_)) => {
if let Some(stage_section) = stage_section {
next.head.position = Vec3::new(0.0, -2.0 + skeleton_attr.head.0, skeleton_attr.head.1);
next.head.orientation = Quaternion::rotation_z(slow * -0.18)
* Quaternion::rotation_x(-0.1 + slow * -0.28)
* Quaternion::rotation_y(0.2 + slow * 0.18);
next.head.scale = Vec3::one() * skeleton_attr.head_scale;
next.chest.position = Vec3::new(0.0 + foot * 2.0, 0.0, 7.0);
next.chest.orientation = Quaternion::rotation_z(slow * 0.2)
* Quaternion::rotation_x(slow * 0.2)
* Quaternion::rotation_y(slow * -0.1);
next.chest.position = Vec3::new(0.0 + foot * 2.0, 0.0, 7.0);
next.chest.orientation = Quaternion::rotation_z(slow * 0.2)
* Quaternion::rotation_x(slow * 0.2)
* Quaternion::rotation_y(slow * -0.1);
next.belt.position = Vec3::new(0.0, 0.0, -2.0);
next.belt.orientation = Quaternion::rotation_z(slow * 0.1)
* Quaternion::rotation_x(slow * 0.1)
* Quaternion::rotation_y(slow * -0.04);
next.belt.position = Vec3::new(0.0, 0.0, -2.0);
next.belt.orientation = Quaternion::rotation_z(slow * 0.1)
* Quaternion::rotation_x(slow * 0.1)
* Quaternion::rotation_y(slow * -0.04);
next.shorts.position = Vec3::new(0.0, 0.0, -5.0);
next.shorts.orientation = Quaternion::rotation_z(slow * 0.1)
* Quaternion::rotation_x(slow * 0.1)
* Quaternion::rotation_y(slow * -0.05);
next.shorts.position = Vec3::new(0.0, 0.0, -5.0);
next.shorts.orientation = Quaternion::rotation_z(slow * 0.1)
* Quaternion::rotation_x(slow * 0.1)
* Quaternion::rotation_y(slow * -0.05);
next.l_hand.position = Vec3::new(-0.75, -1.0, -2.5);
next.l_hand.orientation = Quaternion::rotation_x(1.27);
next.l_hand.scale = Vec3::one() * 1.04;
next.r_hand.position = Vec3::new(0.75, -1.5, -5.5);
next.r_hand.orientation = Quaternion::rotation_x(1.27);
next.r_hand.scale = Vec3::one() * 1.05;
next.main.position = Vec3::new(0.0, 6.0, -1.0);
next.main.orientation = Quaternion::rotation_x(-0.3);
next.l_hand.position = Vec3::new(-0.75, -1.0, -2.5);
next.l_hand.orientation = Quaternion::rotation_x(1.27);
next.l_hand.scale = Vec3::one() * 1.04;
next.r_hand.position = Vec3::new(0.75, -1.5, -5.5);
next.r_hand.orientation = Quaternion::rotation_x(1.27);
next.r_hand.scale = Vec3::one() * 1.05;
next.main.position = Vec3::new(0.0, 6.0, -1.0);
next.main.orientation = Quaternion::rotation_x(-0.3);
next.control.position = Vec3::new(-8.0 + slow * 1.5, 1.5 + slow * 1.0, 0.0);
next.control.orientation = Quaternion::rotation_x(-1.4)
* Quaternion::rotation_y(slow * 2.0 + 0.7)
* Quaternion::rotation_z(1.7 - slow * 0.4 + fast * 0.6);
next.control.scale = Vec3::one();
next.l_foot.position = Vec3::new(
-skeleton_attr.foot.0,
footquick * -9.5,
skeleton_attr.foot.2,
);
next.l_foot.orientation =
Quaternion::rotation_x(footquick * 0.3) * Quaternion::rotation_y(footquick * -0.6);
next.control.position = Vec3::new(-8.0 + slow * 1.5, 1.5 + slow * 1.0, 0.0);
next.control.orientation = Quaternion::rotation_x(-1.4)
* Quaternion::rotation_y(slow * 2.0 + 0.7)
* Quaternion::rotation_z(1.7 - slow * 0.4 + fast * 0.6);
next.control.scale = Vec3::one();
next.l_foot.position = Vec3::new(
-skeleton_attr.foot.0,
footquick * -9.5,
skeleton_attr.foot.2,
);
next.l_foot.orientation =
Quaternion::rotation_x(footquick * 0.3) * Quaternion::rotation_y(footquick * -0.6);
next.r_foot.position =
Vec3::new(skeleton_attr.foot.0, footquick * 9.5, skeleton_attr.foot.2);
next.r_foot.orientation =
Quaternion::rotation_x(footquick * -0.3) * Quaternion::rotation_y(footquick * 0.2);
next.torso.position = Vec3::new(0.0, 0.0, 0.1) * skeleton_attr.scaler;
next.torso.scale = Vec3::one() / 11.0 * skeleton_attr.scaler;
next.r_foot.position =
Vec3::new(skeleton_attr.foot.0, footquick * 9.5, skeleton_attr.foot.2);
next.r_foot.orientation =
Quaternion::rotation_x(footquick * -0.3) * Quaternion::rotation_y(footquick * 0.2);
next.torso.position = Vec3::new(0.0, 0.0, 0.1) * skeleton_attr.scaler;
next.torso.scale = Vec3::one() / 11.0 * skeleton_attr.scaler;
}
},
Some(ToolKind::Hammer(_)) => {
next.head.position = Vec3::new(0.0, -2.0 + skeleton_attr.head.0, skeleton_attr.head.1);
next.head.orientation = Quaternion::rotation_z(slow * -0.18)
* Quaternion::rotation_x(-0.1 + slow * -0.28)
* Quaternion::rotation_y(0.2 + slow * 0.18);
next.head.scale = Vec3::one() * skeleton_attr.head_scale;
next.chest.position = Vec3::new(0.0 + foot * 2.0, 0.0, 7.0);
next.chest.orientation = Quaternion::rotation_z(slow * 0.2)
* Quaternion::rotation_x(slow * 0.2)
* Quaternion::rotation_y(slow * -0.1);
next.belt.position = Vec3::new(0.0, 0.0, -2.0);
next.belt.orientation = Quaternion::rotation_z(slow * 0.1)
* Quaternion::rotation_x(slow * 0.1)
* Quaternion::rotation_y(slow * -0.04);
next.shorts.position = Vec3::new(0.0, 0.0, -5.0);
next.shorts.orientation = Quaternion::rotation_z(slow * 0.1)
* Quaternion::rotation_x(slow * 0.1)
* Quaternion::rotation_y(slow * -0.05);
next.l_hand.position = Vec3::new(-0.75, -1.0, -2.5);
next.l_hand.orientation = Quaternion::rotation_x(1.27);
next.l_hand.scale = Vec3::one() * 1.04;
next.r_hand.position = Vec3::new(0.75, -1.5, -5.5);
next.r_hand.orientation = Quaternion::rotation_x(1.27);
next.r_hand.scale = Vec3::one() * 1.05;
next.main.position = Vec3::new(0.0, 6.0, -1.0);
next.main.orientation = Quaternion::rotation_x(-0.3);
next.control.position = Vec3::new(-8.0 + slow * 1.5, 1.5 + slow * 1.0, 0.0);
next.control.orientation = Quaternion::rotation_x(-1.4)
* Quaternion::rotation_y(slow * 2.0 + 0.7)
* Quaternion::rotation_z(1.7 - slow * 0.4 + fast * 0.6);
next.control.scale = Vec3::one();
next.l_foot.position = Vec3::new(
-skeleton_attr.foot.0,
footquick * -9.5,
skeleton_attr.foot.2,
);
next.l_foot.orientation =
Quaternion::rotation_x(footquick * 0.3) * Quaternion::rotation_y(footquick * -0.6);
next.r_foot.position =
Vec3::new(skeleton_attr.foot.0, footquick * 9.5, skeleton_attr.foot.2);
next.r_foot.orientation =
Quaternion::rotation_x(footquick * -0.3) * Quaternion::rotation_y(footquick * 0.2);
next.torso.position = Vec3::new(0.0, 0.0, 0.1) * skeleton_attr.scaler;
next.torso.scale = Vec3::one() / 11.0 * skeleton_attr.scaler;
},
Some(ToolKind::Axe(_)) => {
next.head.position = Vec3::new(0.0, -2.0 + skeleton_attr.head.0, skeleton_attr.head.1);
next.head.orientation = Quaternion::rotation_z(slow * -0.18)
* Quaternion::rotation_x(-0.1 + slow * -0.28)
* Quaternion::rotation_y(0.2 + slow * 0.18);
next.head.scale = Vec3::one() * skeleton_attr.head_scale;
next.chest.position = Vec3::new(0.0 + foot * 2.0, 0.0, 7.0);
next.chest.orientation = Quaternion::rotation_z(slow * 0.2)
* Quaternion::rotation_x(slow * 0.2)
* Quaternion::rotation_y(slow * -0.1);
next.belt.position = Vec3::new(0.0, 0.0, -2.0);
next.belt.orientation = Quaternion::rotation_z(slow * 0.1)
* Quaternion::rotation_x(slow * 0.1)
* Quaternion::rotation_y(slow * -0.04);
next.shorts.position = Vec3::new(0.0, 0.0, -5.0);
next.shorts.orientation = Quaternion::rotation_z(slow * 0.1)
* Quaternion::rotation_x(slow * 0.1)
* Quaternion::rotation_y(slow * -0.05);
next.l_hand.position = Vec3::new(-0.75, -1.0, -2.5);
next.l_hand.orientation = Quaternion::rotation_x(1.27);
next.l_hand.scale = Vec3::one() * 1.04;
next.r_hand.position = Vec3::new(0.75, -1.5, -5.5);
next.r_hand.orientation = Quaternion::rotation_x(1.27);
next.r_hand.scale = Vec3::one() * 1.05;
next.main.position = Vec3::new(0.0, 6.0, -1.0);
next.main.orientation = Quaternion::rotation_x(-0.3);
next.control.position = Vec3::new(-8.0 + slow * 1.5, 1.5 + slow * 1.0, 0.0);
next.control.orientation = Quaternion::rotation_x(-1.4)
* Quaternion::rotation_y(slow * 2.0 + 0.7)
* Quaternion::rotation_z(1.7 - slow * 0.4 + fast * 0.6);
next.control.scale = Vec3::one();
next.l_foot.position = Vec3::new(
-skeleton_attr.foot.0,
footquick * -9.5,
skeleton_attr.foot.2,
);
next.l_foot.orientation =
Quaternion::rotation_x(footquick * 0.3) * Quaternion::rotation_y(footquick * -0.6);
next.r_foot.position =
Vec3::new(skeleton_attr.foot.0, footquick * 9.5, skeleton_attr.foot.2);
next.r_foot.orientation =
Quaternion::rotation_x(footquick * -0.3) * Quaternion::rotation_y(footquick * 0.2);
next.torso.position = Vec3::new(0.0, 0.0, 0.1) * skeleton_attr.scaler;
next.torso.scale = Vec3::one() / 11.0 * skeleton_attr.scaler;
},
_ => {
next.head.position = Vec3::new(0.0, -2.0 + skeleton_attr.head.0, skeleton_attr.head.1);
next.head.orientation = Quaternion::rotation_z(slow * -0.18)
* Quaternion::rotation_x(-0.1 + slow * -0.28)
* Quaternion::rotation_y(0.2 + slow * 0.18);
next.head.scale = Vec3::one() * skeleton_attr.head_scale;
next.chest.position = Vec3::new(0.0 + foot * 2.0, 0.0, 7.0);
next.chest.orientation = Quaternion::rotation_z(slow * 0.2)
* Quaternion::rotation_x(slow * 0.2)
* Quaternion::rotation_y(slow * -0.1);
next.belt.position = Vec3::new(0.0, 0.0, -2.0);
next.belt.orientation = Quaternion::rotation_z(slow * 0.1)
* Quaternion::rotation_x(slow * 0.1)
* Quaternion::rotation_y(slow * -0.04);
next.shorts.position = Vec3::new(0.0, 0.0, -5.0);
next.shorts.orientation = Quaternion::rotation_z(slow * 0.1)
* Quaternion::rotation_x(slow * 0.1)
* Quaternion::rotation_y(slow * -0.05);
next.l_hand.position = Vec3::new(-0.75, -1.0, -2.5);
next.l_hand.orientation = Quaternion::rotation_x(1.27);
next.l_hand.scale = Vec3::one() * 1.04;
next.r_hand.position = Vec3::new(0.75, -1.5, -5.5);
next.r_hand.orientation = Quaternion::rotation_x(1.27);
next.r_hand.scale = Vec3::one() * 1.05;
next.main.position = Vec3::new(0.0, 6.0, -1.0);
next.main.orientation = Quaternion::rotation_x(-0.3);
next.control.position = Vec3::new(-8.0 + slow * 1.5, 1.5 + slow * 1.0, 0.0);
next.control.orientation = Quaternion::rotation_x(-1.4)
* Quaternion::rotation_y(slow * 2.0 + 0.7)
* Quaternion::rotation_z(1.7 - slow * 0.4 + fast * 0.6);
next.control.scale = Vec3::one();
next.l_foot.position = Vec3::new(
-skeleton_attr.foot.0,
footquick * -9.5,
skeleton_attr.foot.2,
);
next.l_foot.orientation =
Quaternion::rotation_x(footquick * 0.3) * Quaternion::rotation_y(footquick * -0.6);
next.r_foot.position =
Vec3::new(skeleton_attr.foot.0, footquick * 9.5, skeleton_attr.foot.2);
next.r_foot.orientation =
Quaternion::rotation_x(footquick * -0.3) * Quaternion::rotation_y(footquick * 0.2);
next.torso.position = Vec3::new(0.0, 0.0, 0.1) * skeleton_attr.scaler;
next.torso.scale = Vec3::one() / 11.0 * skeleton_attr.scaler;
},
}
next.l_shoulder.position = Vec3::new(
-skeleton_attr.shoulder.0,
skeleton_attr.shoulder.1,

View File

@ -14,7 +14,7 @@ pub struct Input {
pub struct SpinAnimation;
impl Animation for SpinAnimation {
type Dependency = (Option<ToolKind>, Option<ToolKind>, f64, StageSection);
type Dependency = (Option<ToolKind>, Option<ToolKind>, f64, Option<StageSection>);
type Skeleton = CharacterSkeleton;
#[cfg(feature = "use-dyn-lib")]
@ -62,59 +62,61 @@ impl Animation for SpinAnimation {
* Quaternion::rotation_y(0.0)
* Quaternion::rotation_z(0.0);
match stage_section {
StageSection::Buildup => {
//println!("{:.3} build", anim_time);
next.control.position = Vec3::new(5.0, 11.0 + build * 0.6, 2.0 + build * 0.6);
next.control.orientation = Quaternion::rotation_x(-1.57)
* Quaternion::rotation_y(2.8)
* Quaternion::rotation_z(1.0);
next.chest.orientation = Quaternion::rotation_y(movement * -0.1)
* Quaternion::rotation_z(build * 0.05 + movement * -0.6);
next.belt.orientation = Quaternion::rotation_x(movement * 0.1);
if let Some(stage_section) = stage_section {
match stage_section {
StageSection::Buildup => {
//println!("{:.3} build", anim_time);
next.control.position = Vec3::new(5.0, 11.0 + build * 0.6, 2.0 + build * 0.6);
next.control.orientation = Quaternion::rotation_x(-1.57)
* Quaternion::rotation_y(2.8)
* Quaternion::rotation_z(1.0);
next.chest.orientation = Quaternion::rotation_y(movement * -0.1)
* Quaternion::rotation_z(build * 0.05 + movement * -0.6);
next.belt.orientation = Quaternion::rotation_x(movement * 0.1);
next.shorts.orientation = Quaternion::rotation_x(movement * 0.1);
next.shorts.orientation = Quaternion::rotation_x(movement * 0.1);
next.head.orientation = Quaternion::rotation_y(movement * 0.1)
* Quaternion::rotation_z(movement * 0.4);
},
StageSection::Swing => {
//println!("{:.3} swing", anim_time);
next.control.position = Vec3::new(
7.0 + movement * -8.0,
11.0 + test * 3.0,
2.0 + test * 3.5 + movement * 3.0,
);
next.control.orientation =
Quaternion::rotation_x(-1.57 + movement * -0.6 + test * -0.25)
* Quaternion::rotation_y(2.8 + movement * -2.0)
* Quaternion::rotation_z(1.0 + movement * 1.0);
next.head.orientation = Quaternion::rotation_z(-test * 0.8);
next.chest.orientation = Quaternion::rotation_x(test * 0.15)
* Quaternion::rotation_y(movement * 0.3)
* Quaternion::rotation_z(movement * 1.5);
next.belt.orientation = Quaternion::rotation_z(test2 * 0.5);
next.shorts.orientation = Quaternion::rotation_z(test2 * 1.5);
next.torso.orientation = Quaternion::rotation_z(test2 * 7.2);
},
StageSection::Recover => {
//println!("{:.3} recover", anim_time);
next.control.position = Vec3::new(
-8.0,
11.0 - recover * 0.8 + movement * -10.0,
6.0 - recover * 0.4 + movement * -4.0,
);
next.control.orientation = Quaternion::rotation_x(-1.57)
* Quaternion::rotation_y(0.0)
* Quaternion::rotation_z(1.0);
next.chest.orientation = Quaternion::rotation_y(movement * -0.1)
* Quaternion::rotation_z(movement * 0.4);
next.head.orientation = Quaternion::rotation_y(movement * 0.1)
* Quaternion::rotation_z(movement * -0.1);
},
StageSection::Combo => {
//println!("{:.3} combo", anim_time);
},
next.head.orientation = Quaternion::rotation_y(movement * 0.1)
* Quaternion::rotation_z(movement * 0.4);
},
StageSection::Swing => {
//println!("{:.3} swing", anim_time);
next.control.position = Vec3::new(
7.0 + movement * -8.0,
11.0 + test * 3.0,
2.0 + test * 3.5 + movement * 3.0,
);
next.control.orientation =
Quaternion::rotation_x(-1.57 + movement * -0.6 + test * -0.25)
* Quaternion::rotation_y(2.8 + movement * -2.0)
* Quaternion::rotation_z(1.0 + movement * 1.0);
next.head.orientation = Quaternion::rotation_z(-test * 0.8);
next.chest.orientation = Quaternion::rotation_x(test * 0.15)
* Quaternion::rotation_y(movement * 0.3)
* Quaternion::rotation_z(movement * 1.5);
next.belt.orientation = Quaternion::rotation_z(test2 * 0.5);
next.shorts.orientation = Quaternion::rotation_z(test2 * 1.5);
next.torso.orientation = Quaternion::rotation_z(test2 * 7.2);
},
StageSection::Recover => {
//println!("{:.3} recover", anim_time);
next.control.position = Vec3::new(
-8.0,
11.0 - recover * 0.8 + movement * -10.0,
6.0 - recover * 0.4 + movement * -4.0,
);
next.control.orientation = Quaternion::rotation_x(-1.57)
* Quaternion::rotation_y(0.0)
* Quaternion::rotation_z(1.0);
next.chest.orientation = Quaternion::rotation_y(movement * -0.1)
* Quaternion::rotation_z(movement * 0.4);
next.head.orientation = Quaternion::rotation_y(movement * 0.1)
* Quaternion::rotation_z(movement * -0.1);
},
StageSection::Combo => {
//println!("{:.3} combo", anim_time);
},
}
}
}
// println!("{:?}", stage_progress),

View File

@ -809,7 +809,7 @@ impl FigureMgr {
CharacterState::BasicMelee(_) => {
anim::character::AlphaAnimation::update_skeleton(
&target_base,
(active_tool_kind, second_tool_kind, vel.0.magnitude(), time),
(active_tool_kind, second_tool_kind, vel.0.magnitude(), time, None),
state.state_time,
&mut state_animation_rate,
skeleton_attr,
@ -879,7 +879,7 @@ impl FigureMgr {
CharacterState::Boost(_) => {
anim::character::AlphaAnimation::update_skeleton(
&target_base,
(active_tool_kind, second_tool_kind, vel.0.magnitude(), time),
(active_tool_kind, second_tool_kind, vel.0.magnitude(), time, None),
state.state_time,
&mut state_animation_rate,
skeleton_attr,
@ -915,19 +915,18 @@ impl FigureMgr {
CharacterState::ComboMelee(s) => {
let stage_index = (s.stage - 1) as usize;
let stage_time = s.timer.as_secs_f64();
let swing_frac = 0.6; // What percentage of buildup is swing animation
let mut stage_section = s.stage_section;
let mut stage_section = Some(s.stage_section);
let stage_progress = match s.stage_section {
StageSection::Buildup => {
let buildup_progress = stage_time
/ s.stage_data[stage_index]
.base_buildup_duration
.as_secs_f64();
if buildup_progress < swing_frac {
buildup_progress / (1.0 - swing_frac)
if buildup_progress < s.stage_data[stage_index].swing_frac {
buildup_progress / (1.0 - s.stage_data[stage_index].swing_frac)
} else {
stage_section = StageSection::Swing;
(buildup_progress - (1.0 - swing_frac)) / swing_frac
stage_section = Some(StageSection::Swing);
(buildup_progress - (1.0 - s.stage_data[stage_index].swing_frac)) / s.stage_data[stage_index].swing_frac
}
},
StageSection::Recover => {
@ -942,7 +941,7 @@ impl FigureMgr {
match s.stage {
1 => anim::character::AlphaAnimation::update_skeleton(
&target_base,
(active_tool_kind, second_tool_kind, vel.0.magnitude(), time),
(active_tool_kind, second_tool_kind, vel.0.magnitude(), time, stage_section),
stage_progress,
&mut state_animation_rate,
skeleton_attr,
@ -956,7 +955,7 @@ impl FigureMgr {
),
_ => anim::character::BetaAnimation::update_skeleton(
&target_base,
(active_tool_kind, second_tool_kind, vel.0.magnitude(), time),
(active_tool_kind, second_tool_kind, vel.0.magnitude(), time, stage_section),
stage_progress,
&mut state_animation_rate,
skeleton_attr,