stage 2 animation

This commit is contained in:
jshipsey 2020-09-07 01:14:39 -04:00 committed by Sam
parent 0ba5740265
commit 2451a64b97
7 changed files with 156 additions and 67 deletions

View File

@ -127,8 +127,8 @@ impl Tool {
knockback: 5.0,
range: 3.5,
angle: 45.0,
base_buildup_duration: Duration::from_millis(150),
base_recover_duration: Duration::from_millis(100),
base_buildup_duration: Duration::from_millis(10),
base_recover_duration: Duration::from_millis(10),
},
combo_melee::Stage {
stage: 2,
@ -138,8 +138,8 @@ impl Tool {
knockback: 5.0,
range: 3.5,
angle: 45.0,
base_buildup_duration: Duration::from_millis(150),
base_recover_duration: Duration::from_millis(100),
base_buildup_duration: Duration::from_millis(1000),
base_recover_duration: Duration::from_millis(400),
},
combo_melee::Stage {
stage: 3,
@ -149,14 +149,14 @@ impl Tool {
knockback: 5.0,
range: 3.5,
angle: 45.0,
base_buildup_duration: Duration::from_millis(150),
base_recover_duration: Duration::from_millis(100),
base_buildup_duration: Duration::from_millis(10),
base_recover_duration: Duration::from_millis(10),
},
],
initial_energy_gain: 0,
max_energy_gain: 100,
energy_increase: 20,
combo_duration: Duration::from_millis(250),
combo_duration: Duration::from_millis(10),
},
DashMelee {
energy_cost: 700,

View File

@ -72,7 +72,9 @@ impl CharacterBehavior for Data {
let stage_index = (self.stage - 1) as usize;
if self.stage_section == StageSection::Buildup && self.timer < self.stage_data[stage_index].base_buildup_duration {
if self.stage_section == StageSection::Buildup
&& self.timer < self.stage_data[stage_index].base_buildup_duration
{
// Build up
update.character = CharacterState::ComboMelee(Data {
stage: self.stage,
@ -116,7 +118,9 @@ impl CharacterBehavior for Data {
timer: Duration::default(),
stage_section: StageSection::Recover,
});
} else if self.stage_section == StageSection::Recover && self.timer < self.stage_data[stage_index].base_recover_duration {
} else if self.stage_section == StageSection::Recover
&& self.timer < self.stage_data[stage_index].base_recover_duration
{
update.character = CharacterState::ComboMelee(Data {
stage: self.stage,
num_stages: self.num_stages,
@ -173,7 +177,7 @@ impl CharacterBehavior for Data {
.timer
.checked_add(Duration::from_secs_f32(data.dt.0))
.unwrap_or_default(),
stage_section: self.stage_section,
stage_section: self.stage_section,
});
}
} else {

View File

@ -8,7 +8,7 @@ version = "0.7.0"
name = "voxygen_anim"
# Uncomment to use animation hot reloading
# Note: this breaks `cargo test`
# crate-type = ["lib", "cdylib"]
crate-type = ["lib", "cdylib"]
[features]
be-dyn-lib = []

View File

@ -2,7 +2,10 @@ use super::{
super::{vek::*, Animation},
CharacterSkeleton, SkeletonAttr,
};
use common::comp::item::{Hands, ToolKind};
use common::{
comp::item::{Hands, ToolKind},
states::combo_melee::StageSection,
};
use std::f32::consts::PI;
pub struct AlphaAnimation;

View File

@ -2,7 +2,10 @@ use super::{
super::{vek::*, Animation},
CharacterSkeleton, SkeletonAttr,
};
use common::comp::item::{Hands, ToolKind};
use common::{
comp::item::{Hands, ToolKind},
states::combo_melee::StageSection,
};
use std::f32::consts::PI;
pub struct Input {
@ -11,7 +14,7 @@ pub struct Input {
pub struct SpinAnimation;
impl Animation for SpinAnimation {
type Dependency = (Option<ToolKind>, Option<ToolKind>, f64);
type Dependency = (Option<ToolKind>, Option<ToolKind>, f64, StageSection);
type Skeleton = CharacterSkeleton;
#[cfg(feature = "use-dyn-lib")]
@ -20,7 +23,7 @@ impl Animation for SpinAnimation {
#[cfg_attr(feature = "be-dyn-lib", export_name = "character_spin")]
fn update_skeleton_inner(
skeleton: &Self::Skeleton,
(active_tool_kind, second_tool_kind, _global_time): Self::Dependency,
(active_tool_kind, second_tool_kind, _global_time, stage_section): Self::Dependency,
anim_time: f64,
rate: &mut f32,
skeleton_attr: &SkeletonAttr,
@ -40,9 +43,83 @@ impl Animation for SpinAnimation {
let spin = (anim_time as f32 * 2.8 * lab as f32).sin();
let spinhalf = (anim_time as f32 * 1.4 * lab as f32).sin();
if let Some(
ToolKind::Axe(_) | ToolKind::Hammer(_) | ToolKind::Sword(_) | ToolKind::Dagger(_),
) = active_tool_kind
let build = (anim_time as f32 * 8.0).sin();
let recover = (anim_time as f32 * 8.0).sin();
let movement = anim_time as f32 * 1.0;
let test = (anim_time as f32 * 8.0).sin();
let test2 = (anim_time as f32 * 1.0).sin();
if let Some(ToolKind::Sword(_)) = active_tool_kind {
next.l_hand.position = Vec3::new(-0.75, -1.0, 2.5);
next.l_hand.orientation = Quaternion::rotation_x(1.47) * Quaternion::rotation_y(-0.2);
next.l_hand.scale = Vec3::one() * 1.04;
next.r_hand.position = Vec3::new(0.75, -1.5, -0.5);
next.r_hand.orientation = Quaternion::rotation_x(1.47) * Quaternion::rotation_y(0.3);
next.r_hand.scale = Vec3::one() * 1.05;
next.main.position = Vec3::new(0.0, 0.0, 2.0);
next.main.orientation = Quaternion::rotation_x(-0.1)
* 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);
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);
},
}
}
// println!("{:?}", stage_progress),
if let Some(ToolKind::Axe(_) | ToolKind::Hammer(_) | ToolKind::Dagger(_)) = active_tool_kind
{
//INTENTION: SWORD
next.l_hand.position = Vec3::new(-0.75, -1.0, -2.5);
@ -88,46 +165,47 @@ impl Animation for SpinAnimation {
* Quaternion::rotation_x(0.0)
* Quaternion::rotation_y(0.0);
next.torso.scale = Vec3::one() / 11.0 * skeleton_attr.scaler;
next.l_foot.position =
Vec3::new(-skeleton_attr.foot.0, foot * 1.0, skeleton_attr.foot.2);
next.l_foot.orientation = Quaternion::rotation_x(foot * -1.2);
next.l_foot.scale = Vec3::one();
next.r_foot.position =
Vec3::new(skeleton_attr.foot.0, foot * -1.0, skeleton_attr.foot.2);
next.r_foot.orientation = Quaternion::rotation_x(foot * 1.2);
next.r_foot.scale = Vec3::one();
next.l_shoulder.position = Vec3::new(-5.0, 0.0, 4.7);
next.l_shoulder.orientation = Quaternion::rotation_x(0.0);
next.l_shoulder.scale = Vec3::one() * 1.1;
next.r_shoulder.position = Vec3::new(5.0, 0.0, 4.7);
next.r_shoulder.orientation = Quaternion::rotation_x(0.0);
next.r_shoulder.scale = Vec3::one() * 1.1;
next.glider.position = Vec3::new(0.0, 5.0, 0.0);
next.glider.orientation = Quaternion::rotation_y(0.0);
next.glider.scale = Vec3::one() * 0.0;
next.lantern.position = Vec3::new(
skeleton_attr.lantern.0,
skeleton_attr.lantern.1,
skeleton_attr.lantern.2,
);
next.lantern.orientation =
Quaternion::rotation_x(spin * -0.7 + 0.4) * Quaternion::rotation_y(spin * 0.4);
next.lantern.scale = Vec3::one() * 0.65;
next.hold.scale = Vec3::one() * 0.0;
next.l_control.position = Vec3::new(0.0, 0.0, 0.0);
next.l_control.orientation = Quaternion::rotation_x(0.0);
next.l_control.scale = Vec3::one();
next.r_control.position = Vec3::new(0.0, 0.0, 0.0);
next.r_control.orientation = Quaternion::rotation_x(0.0);
next.r_control.scale = Vec3::one();
}
next.l_foot.position = Vec3::new(-skeleton_attr.foot.0, foot * 1.0, skeleton_attr.foot.2);
next.l_foot.orientation = Quaternion::rotation_x(foot * -1.2);
next.l_foot.scale = Vec3::one();
next.r_foot.position = Vec3::new(skeleton_attr.foot.0, foot * -1.0, skeleton_attr.foot.2);
next.r_foot.orientation = Quaternion::rotation_x(foot * 1.2);
next.r_foot.scale = Vec3::one();
next.l_shoulder.position = Vec3::new(-5.0, 0.0, 4.7);
next.l_shoulder.orientation = Quaternion::rotation_x(0.0);
next.l_shoulder.scale = Vec3::one() * 1.1;
next.r_shoulder.position = Vec3::new(5.0, 0.0, 4.7);
next.r_shoulder.orientation = Quaternion::rotation_x(0.0);
next.r_shoulder.scale = Vec3::one() * 1.1;
next.glider.position = Vec3::new(0.0, 5.0, 0.0);
next.glider.orientation = Quaternion::rotation_y(0.0);
next.glider.scale = Vec3::one() * 0.0;
next.lantern.position = Vec3::new(
skeleton_attr.lantern.0,
skeleton_attr.lantern.1,
skeleton_attr.lantern.2,
);
next.lantern.orientation =
Quaternion::rotation_x(spin * -0.7 + 0.4) * Quaternion::rotation_y(spin * 0.4);
next.lantern.scale = Vec3::one() * 0.65;
next.hold.scale = Vec3::one() * 0.0;
next.l_control.position = Vec3::new(0.0, 0.0, 0.0);
next.l_control.orientation = Quaternion::rotation_x(0.0);
next.l_control.scale = Vec3::one();
next.r_control.position = Vec3::new(0.0, 0.0, 0.0);
next.r_control.orientation = Quaternion::rotation_x(0.0);
next.r_control.scale = Vec3::one();
next.second.scale = match (
active_tool_kind.map(|tk| tk.hands()),
second_tool_kind.map(|tk| tk.hands()),

View File

@ -111,18 +111,18 @@ impl Animation for WieldAnimation {
match active_tool_kind {
//TODO: Inventory
Some(ToolKind::Sword(_)) => {
next.l_hand.position = Vec3::new(-0.75, -1.0, -2.5);
next.l_hand.position = Vec3::new(-0.75, -1.0, 2.5);
next.l_hand.orientation =
Quaternion::rotation_x(1.47) * Quaternion::rotation_y(-0.2);
next.l_hand.scale = Vec3::one() * 1.04;
next.r_hand.position = Vec3::new(0.75, -1.5, -5.5);
next.r_hand.position = Vec3::new(0.75, -1.5, -0.5);
next.r_hand.orientation =
Quaternion::rotation_x(1.47) * Quaternion::rotation_y(0.3);
next.r_hand.scale = Vec3::one() * 1.05;
next.main.position = Vec3::new(0.0, 0.0, -3.0);
next.main.orientation = Quaternion::rotation_x(-0.1);
next.control.position = Vec3::new(-7.0, 6.0, 6.0);
next.control.position = Vec3::new(-7.0, 7.0, 2.0);
next.control.orientation = Quaternion::rotation_x(u_slow * 0.15)
* Quaternion::rotation_z(u_slowalt * 0.08);
next.control.scale = Vec3::one();

View File

@ -915,11 +915,14 @@ 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.5; // What percentage of buildup is swing animation
let swing_frac = 0.6; // What percentage of buildup is swing animation
let mut stage_section = 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();
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)
} else {
@ -928,11 +931,12 @@ impl FigureMgr {
}
},
StageSection::Recover => {
stage_time / s.stage_data[stage_index].base_recover_duration.as_secs_f64()
},
StageSection::Combo => {
stage_time / s.combo_duration.as_secs_f64()
stage_time
/ s.stage_data[stage_index]
.base_recover_duration
.as_secs_f64()
},
StageSection::Combo => stage_time / s.combo_duration.as_secs_f64(),
_ => 0.0,
};
match s.stage {
@ -945,7 +949,7 @@ impl FigureMgr {
),
2 => anim::character::SpinAnimation::update_skeleton(
&target_base,
(active_tool_kind, second_tool_kind, time),
(active_tool_kind, second_tool_kind, time, stage_section),
stage_progress,
&mut state_animation_rate,
skeleton_attr,