Add bipedlarge spin and beta anims

This commit is contained in:
Snowram 2020-09-28 02:17:41 +02:00 committed by Robin Gilh
parent 94cbe3faf4
commit c1c2c9dc07
9 changed files with 849 additions and 6 deletions

View File

@ -2,12 +2,22 @@ use super::{
super::{vek::*, Animation},
BipedLargeSkeleton, SkeletonAttr,
};
use common::{
comp::item::{Hands, ToolKind},
states::utils::StageSection,
};
use std::f32::consts::PI;
pub struct AlphaAnimation;
impl Animation for AlphaAnimation {
type Dependency = (f32, f64);
type Dependency = (
Option<ToolKind>,
Option<ToolKind>,
f32,
f64,
Option<StageSection>,
);
type Skeleton = BipedLargeSkeleton;
#[cfg(feature = "use-dyn-lib")]
@ -16,7 +26,7 @@ impl Animation for AlphaAnimation {
#[cfg_attr(feature = "be-dyn-lib", export_name = "biped_large_alpha")]
fn update_skeleton_inner(
skeleton: &Self::Skeleton,
(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,

View File

@ -0,0 +1,242 @@
use super::{
super::{vek::*, Animation},
BipedLargeSkeleton, SkeletonAttr,
};
use common::{
comp::item::{Hands, ToolKind},
states::utils::StageSection,
};
pub struct BetaAnimation;
impl Animation for BetaAnimation {
type Dependency = (
Option<ToolKind>,
Option<ToolKind>,
f32,
f64,
Option<StageSection>,
);
type Skeleton = BipedLargeSkeleton;
#[cfg(feature = "use-dyn-lib")]
const UPDATE_FN: &'static [u8] = b"biped_large_beta\0";
#[cfg_attr(feature = "be-dyn-lib", export_name = "biped_large_beta")]
fn update_skeleton_inner(
skeleton: &Self::Skeleton,
(active_tool_kind, second_tool_kind, _velocity, _global_time, stage_section): 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 fast = (((5.0)
/ (1.1 + 3.9 * ((anim_time as f32 * lab as f32 * 28.0).sin()).powf(2.0 as f32)))
.sqrt())
* ((anim_time as f32 * lab as f32 * 28.0).sin());
let footquick = (((5.0)
/ (0.4 + 4.6 * ((anim_time as f32 * lab as f32 * 14.0).sin()).powf(2.0 as f32)))
.sqrt())
* ((anim_time as f32 * lab as f32 * 14.0).sin());
let foot = (((5.0)
/ (1.1 + 3.9 * ((anim_time as f32 * lab as f32 * 14.0).sin()).powf(2.0 as f32)))
.sqrt())
* ((anim_time as f32 * lab as f32 * 14.0).sin());
let slow = (((5.0)
/ (0.6 + 4.4 * ((anim_time as f32 * lab as f32 * 14.0).sin()).powf(2.0 as f32)))
.sqrt())
* ((anim_time as f32 * lab as f32 * 14.0).sin());
let recover = (anim_time as f32 * 8.0).sin();
let movement = anim_time as f32 * 1.0;
let stab = (anim_time as f32 * 2.5).sin();
if let Some(ToolKind::Sword(_)) = active_tool_kind {
next.hand_l.position = Vec3::new(-0.75, -1.0, 2.5);
next.hand_l.orientation = Quaternion::rotation_x(1.47) * Quaternion::rotation_y(-0.2);
next.hand_l.scale = Vec3::one() * 1.04;
next.hand_r.position = Vec3::new(0.75, -1.5, -0.5);
next.hand_r.orientation = Quaternion::rotation_x(1.47) * Quaternion::rotation_y(0.3);
next.hand_r.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);
next.head.position = Vec3::new(0.0, skeleton_attr.head.0, skeleton_attr.head.1);
if let Some(stage_section) = stage_section {
match stage_section {
StageSection::Buildup => {
//println!("{:.3} recover", anim_time);
next.control.position = Vec3::new(
-8.0 + movement * -5.0,
1.0 - recover * 0.8 + movement * 2.0,
2.0 - recover * 0.4,
);
next.control.orientation = Quaternion::rotation_x(-1.57)
* Quaternion::rotation_y(0.0 + movement * 1.5)
* Quaternion::rotation_z(1.0);
next.upper_torso.orientation = Quaternion::rotation_y(-0.1)
* Quaternion::rotation_z(0.4 + movement * 1.5);
next.head.orientation = Quaternion::rotation_y(0.1)
* Quaternion::rotation_z(-0.1 + movement * -1.1);
},
StageSection::Swing => {
//println!("{:.3} swing", anim_time);
next.control.position =
Vec3::new(-8.0 + stab * 30.0, 6.0 + movement * 2.0, 6.0);
next.control.orientation = Quaternion::rotation_x(-1.57)
* Quaternion::rotation_y(1.5 + stab * 0.5)
* Quaternion::rotation_z(1.0 + stab * 1.0);
next.upper_torso.orientation = Quaternion::rotation_y(-0.1)
* Quaternion::rotation_z(1.9 + stab * -0.5);
next.head.orientation = Quaternion::rotation_y(0.1)
* Quaternion::rotation_z(-1.2 + stab * -0.5);
},
StageSection::Recover => {
next.control.position = Vec3::new(10.0 + movement * -5.0, 8.0, 6.0);
next.control.orientation = Quaternion::rotation_x(-1.57)
* Quaternion::rotation_y(2.0)
* Quaternion::rotation_z(2.0);
next.upper_torso.orientation = Quaternion::rotation_y(-0.1)
* Quaternion::rotation_z(1.4 + movement * 1.0);
next.head.orientation =
Quaternion::rotation_y(0.1) * Quaternion::rotation_z(-1.5);
},
_ => {},
}
}
}
match active_tool_kind {
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() * 1.01;
next.upper_torso.position = Vec3::new(0.0 + foot * 2.0, 0.0, 7.0);
next.upper_torso.orientation = Quaternion::rotation_z(slow * 0.2)
* Quaternion::rotation_x(slow * 0.2)
* Quaternion::rotation_y(slow * -0.1);
next.lower_torso.position = Vec3::new(0.0, 0.0, -5.0);
next.lower_torso.orientation = Quaternion::rotation_z(slow * 0.1)
* Quaternion::rotation_x(slow * 0.1)
* Quaternion::rotation_y(slow * -0.05);
next.hand_l.position = Vec3::new(-0.75, -1.0, -2.5);
next.hand_l.orientation = Quaternion::rotation_x(1.27);
next.hand_l.scale = Vec3::one() * 1.04;
next.hand_r.position = Vec3::new(0.75, -1.5, -5.5);
next.hand_r.orientation = Quaternion::rotation_x(1.27);
next.hand_r.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.foot_l.position = Vec3::new(
-skeleton_attr.foot.0,
footquick * -9.5,
skeleton_attr.foot.2,
);
next.foot_l.orientation = Quaternion::rotation_x(footquick * 0.3)
* Quaternion::rotation_y(footquick * -0.6);
next.foot_r.position =
Vec3::new(skeleton_attr.foot.0, footquick * 9.5, skeleton_attr.foot.2);
next.foot_r.orientation = Quaternion::rotation_x(footquick * -0.3)
* Quaternion::rotation_y(footquick * 0.2);
next.torso.position = Vec3::new(0.0, 0.0, 0.1) * 1.01;
next.torso.scale = Vec3::one() / 11.0 * 1.01;
},
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() * 1.01;
next.upper_torso.position = Vec3::new(0.0 + foot * 2.0, 0.0, 7.0);
next.upper_torso.orientation = Quaternion::rotation_z(slow * 0.2)
* Quaternion::rotation_x(slow * 0.2)
* Quaternion::rotation_y(slow * -0.1);
next.lower_torso.position = Vec3::new(0.0, 0.0, -5.0);
next.lower_torso.orientation = Quaternion::rotation_z(slow * 0.1)
* Quaternion::rotation_x(slow * 0.1)
* Quaternion::rotation_y(slow * -0.05);
next.hand_l.position = Vec3::new(-0.75, -1.0, -2.5);
next.hand_l.orientation = Quaternion::rotation_x(1.27);
next.hand_l.scale = Vec3::one() * 1.04;
next.hand_r.position = Vec3::new(0.75, -1.5, -5.5);
next.hand_r.orientation = Quaternion::rotation_x(1.27);
next.hand_r.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.foot_l.position = Vec3::new(
-skeleton_attr.foot.0,
footquick * -9.5,
skeleton_attr.foot.2,
);
next.foot_l.orientation = Quaternion::rotation_x(footquick * 0.3)
* Quaternion::rotation_y(footquick * -0.6);
next.foot_r.position =
Vec3::new(skeleton_attr.foot.0, footquick * 9.5, skeleton_attr.foot.2);
next.foot_r.orientation = Quaternion::rotation_x(footquick * -0.3)
* Quaternion::rotation_y(footquick * 0.2);
next.torso.position = Vec3::new(0.0, 0.0, 0.1) * 1.01;
next.torso.scale = Vec3::one() / 11.0 * 1.01;
},
_ => {},
}
next.shoulder_l.position = Vec3::new(
-skeleton_attr.shoulder.0,
skeleton_attr.shoulder.1,
skeleton_attr.shoulder.2,
);
next.shoulder_l.orientation = Quaternion::rotation_x(0.0);
next.shoulder_l.scale = Vec3::one() * 1.1;
next.shoulder_r.position = Vec3::new(
skeleton_attr.shoulder.0,
skeleton_attr.shoulder.1,
skeleton_attr.shoulder.2,
);
next.shoulder_r.orientation = Quaternion::rotation_x(0.0);
next.shoulder_r.scale = Vec3::one() * 1.1;
next.second.scale = match (
active_tool_kind.map(|tk| tk.hands()),
second_tool_kind.map(|tk| tk.hands()),
) {
(Some(Hands::OneHand), Some(Hands::OneHand)) => Vec3::one(),
(_, _) => Vec3::zero(),
};
next
}
}

View File

@ -0,0 +1,285 @@
use super::{
super::{vek::*, Animation},
BipedLargeSkeleton, SkeletonAttr,
};
use common::{
comp::item::{Hands, ToolKind},
states::utils::StageSection,
};
use std::f32::consts::PI;
pub struct Input {
pub attack: bool,
}
pub struct DashAnimation;
impl Animation for DashAnimation {
type Dependency = (
Option<ToolKind>,
Option<ToolKind>,
f64,
Option<StageSection>,
);
type Skeleton = BipedLargeSkeleton;
#[cfg(feature = "use-dyn-lib")]
const UPDATE_FN: &'static [u8] = b"biped_large_dash\0";
#[cfg_attr(feature = "be-dyn-lib", export_name = "biped_large_dash")]
#[allow(clippy::single_match)] // TODO: Pending review in #587
fn update_skeleton_inner(
skeleton: &Self::Skeleton,
(active_tool_kind, second_tool_kind, _global_time, stage_section): 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 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 short = (((5.0)
/ (1.5 + 3.5 * ((anim_time as f32 * lab as f32 * 5.0).sin()).powf(2.0 as f32)))
.sqrt())
* ((anim_time as f32 * lab as f32 * 5.0).sin());
let foothoril = (anim_time as f32 * 5.0 * lab as f32 + PI * 1.45).sin();
let foothorir = (anim_time as f32 * 5.0 * lab as f32 + PI * (0.45)).sin();
let footvertl = (anim_time as f32 * 5.0 * lab as f32).sin();
let footvertr = (anim_time as f32 * 5.0 * lab as f32 + PI).sin();
let footrotl = (((1.0)
/ (0.05
+ (0.95)
* ((anim_time as f32 * 5.0 * lab as f32 + PI * 1.4).sin()).powf(2.0 as f32)))
.sqrt())
* ((anim_time as f32 * 5.0 * lab as f32 + PI * 1.4).sin());
let footrotr = (((1.0)
/ (0.05
+ (0.95)
* ((anim_time as f32 * 5.0 * lab as f32 + PI * 0.4).sin()).powf(2.0 as f32)))
.sqrt())
* ((anim_time as f32 * 5.0 * lab as f32 + PI * 0.4).sin());
let shortalt = (anim_time as f32 * lab as f32 * 5.0 + PI / 2.0).sin();
let movement = (anim_time as f32 * 1.0).min(1.0);
next.head.position = Vec3::new(0.0, -2.0 + skeleton_attr.head.0, skeleton_attr.head.1);
next.hand_l.position = Vec3::new(-0.75, -1.0, 2.5);
next.hand_l.orientation = Quaternion::rotation_x(1.47) * Quaternion::rotation_y(-0.2);
next.hand_l.scale = Vec3::one() * 1.04;
next.hand_r.position = Vec3::new(0.75, -1.5, -0.5);
next.hand_r.orientation = Quaternion::rotation_x(1.47) * Quaternion::rotation_y(0.3);
next.hand_r.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 active_tool_kind {
//TODO: Inventory
Some(ToolKind::Sword(_)) => {
if let Some(stage_section) = stage_section {
match stage_section {
StageSection::Buildup => {
next.head.orientation = Quaternion::rotation_z(movement * -0.9);
next.upper_torso.orientation = Quaternion::rotation_z(movement * 1.1);
next.control.position = Vec3::new(-7.0 + movement * -5.0, 7.0, 2.0);
next.control.orientation = Quaternion::rotation_x(movement * -1.0)
* Quaternion::rotation_y(movement * 1.5)
* Quaternion::rotation_z(0.0);
next.control.scale = Vec3::one();
next.foot_l.position = Vec3::new(
-skeleton_attr.foot.0,
skeleton_attr.foot.1 + movement * -12.0,
skeleton_attr.foot.2,
);
next.foot_l.orientation = Quaternion::rotation_x(movement * -1.0);
next.foot_r.position = Vec3::new(
skeleton_attr.foot.0,
skeleton_attr.foot.1,
skeleton_attr.foot.2,
);
},
StageSection::Charge => {
next.head.position = Vec3::new(
0.0,
-2.0 + skeleton_attr.head.0,
skeleton_attr.head.1 + movement * 1.0,
);
next.head.orientation = Quaternion::rotation_x(0.0)
* Quaternion::rotation_y(movement * -0.3)
* Quaternion::rotation_z(-0.9 + movement * -0.2 + short * -0.05);
next.upper_torso.position = Vec3::new(
0.0,
skeleton_attr.upper_torso.0,
skeleton_attr.upper_torso.1 + 2.0 + shortalt * -2.5,
);
next.upper_torso.orientation = Quaternion::rotation_x(movement * -0.4)
* Quaternion::rotation_y(movement * -0.2)
* Quaternion::rotation_z(1.1);
next.control.position =
Vec3::new(-13.0, 7.0 + movement * -2.0, 2.0 + movement * 2.0);
next.control.orientation =
Quaternion::rotation_x(-1.0) * Quaternion::rotation_y(1.5);
next.control.scale = Vec3::one();
next.upper_torso.orientation = Quaternion::rotation_z(short * 0.25);
next.foot_l.position = Vec3::new(
2.0 - skeleton_attr.foot.0,
skeleton_attr.foot.1 + foothoril * -7.5,
2.0 + skeleton_attr.foot.2 + ((footvertl * -4.0).max(-1.0)),
);
next.foot_l.orientation =
Quaternion::rotation_x(-0.6 + footrotl * -0.6)
* Quaternion::rotation_z(-0.2);
next.foot_r.position = Vec3::new(
2.0 + skeleton_attr.foot.0,
skeleton_attr.foot.1 + foothorir * -7.5,
2.0 + skeleton_attr.foot.2 + ((footvertr * -4.0).max(-1.0)),
);
next.foot_r.orientation =
Quaternion::rotation_x(-0.6 + footrotr * -0.6)
* Quaternion::rotation_z(-0.2);
},
StageSection::Swing => {
next.head.orientation = Quaternion::rotation_y(0.2 + movement * -0.2)
* Quaternion::rotation_z(-1.1 + movement * 1.8);
next.upper_torso.orientation = Quaternion::rotation_y(-0.2 + movement * 0.3)
* Quaternion::rotation_z(1.1 + movement * -2.2);
next.control.position = Vec3::new(-13.0 + movement * -2.0, 5.0, 4.0);
next.control.orientation =
Quaternion::rotation_x(-1.0 + movement * -0.5)
* Quaternion::rotation_y(1.5 + movement * -2.5);
next.control.scale = Vec3::one();
},
StageSection::Recover => {
next.head.orientation = Quaternion::rotation_z(0.7);
next.upper_torso.orientation = Quaternion::rotation_z(-1.1);
next.control.position = Vec3::new(-15.0, 5.0, 2.0);
next.control.orientation =
Quaternion::rotation_x(-1.5) * Quaternion::rotation_y(-1.0);
next.control.scale = Vec3::one();
},
}
}
},
Some(ToolKind::Dagger(_)) => {
next.head.position = Vec3::new(
0.0,
-2.0 + skeleton_attr.head.0,
-2.0 + skeleton_attr.head.1,
);
next.head.orientation = Quaternion::rotation_z(0.0)
* Quaternion::rotation_x(0.0)
* Quaternion::rotation_y(0.0);
next.head.scale = Vec3::one() * 1.01;
next.upper_torso.position = Vec3::new(0.0, 0.0, 7.0 + slow * 2.0);
next.upper_torso.orientation =
Quaternion::rotation_x(-0.5) * Quaternion::rotation_z(-0.7);
next.upper_torso.position = Vec3::new(0.0, 3.0, -3.0);
next.upper_torso.orientation = Quaternion::rotation_x(0.4) * Quaternion::rotation_z(0.3);
next.hand_l.position = Vec3::new(-0.75, -1.0, -2.5);
next.hand_l.orientation = Quaternion::rotation_x(1.27);
next.hand_l.scale = Vec3::one() * 1.04;
next.hand_r.position = Vec3::new(0.75, -1.5, -5.5);
next.hand_r.orientation = Quaternion::rotation_x(1.27);
next.hand_r.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.main.scale = Vec3::one();
next.control.position = Vec3::new(-8.0 - slow * 0.5, 3.0, 3.0);
next.control.orientation =
Quaternion::rotation_x(-0.3) * Quaternion::rotation_z(1.1 + slow * 0.2);
next.control.scale = Vec3::one();
next.foot_l.position = Vec3::new(-1.4, 2.0, skeleton_attr.foot.2);
next.foot_l.orientation = Quaternion::rotation_x(-0.8);
next.foot_r.position = Vec3::new(5.4, -1.0, skeleton_attr.foot.2);
next.foot_r.orientation = Quaternion::rotation_x(-0.8);
},
_ => {},
}
match second_tool_kind {
//TODO: Inventory
Some(ToolKind::Dagger(_)) => {
next.head.position = Vec3::new(
0.0,
-2.0 + skeleton_attr.head.0,
-2.0 + skeleton_attr.head.1,
);
next.head.orientation = Quaternion::rotation_z(0.0)
* Quaternion::rotation_x(0.0)
* Quaternion::rotation_y(0.0);
next.head.scale = Vec3::one() * 1.01;
next.upper_torso.position = Vec3::new(0.0, 0.0, 7.0 + slow * 2.0);
next.upper_torso.orientation = Quaternion::rotation_x(0.0);
next.upper_torso.position = Vec3::new(0.0, 3.0, -3.0);
next.upper_torso.orientation = Quaternion::rotation_x(0.0);
next.control.position = Vec3::new(0.0, 0.0, 0.0);
next.control.orientation = Quaternion::rotation_x(0.0);
next.control.scale = Vec3::one();
next.hand_l.position = Vec3::new(0.0, 0.0, 0.0);
next.hand_l.orientation = Quaternion::rotation_x(0.0);
next.hand_l.scale = Vec3::one() * 1.04;
next.main.position = Vec3::new(0.0, 0.0, 0.0);
next.main.orientation = Quaternion::rotation_x(0.0);
next.main.scale = Vec3::one();
next.hand_r.position = Vec3::new(0.0, 0.0, 0.0);
next.hand_r.orientation = Quaternion::rotation_x(0.0);
next.hand_r.scale = Vec3::one() * 1.05;
next.second.position = Vec3::new(0.0, 6.0, -1.0);
next.second.orientation = Quaternion::rotation_x(-0.3);
next.second.scale = Vec3::one();
next.foot_l.position = Vec3::new(-1.4, 2.0, skeleton_attr.foot.2);
next.foot_l.orientation = Quaternion::rotation_x(-0.8);
next.foot_r.position = Vec3::new(5.4, -1.0, skeleton_attr.foot.2);
next.foot_r.orientation = Quaternion::rotation_x(-0.8);
},
_ => {},
}
next.second.scale = match (
active_tool_kind.map(|tk| tk.hands()),
second_tool_kind.map(|tk| tk.hands()),
) {
(Some(Hands::OneHand), Some(Hands::OneHand)) => Vec3::one(),
(_, _) => Vec3::zero(),
};
next
}
}

View File

@ -194,6 +194,8 @@ impl Animation for IdleAnimation {
next.torso.orientation = Quaternion::rotation_z(0.0) * Quaternion::rotation_x(0.0);
next.torso.scale = Vec3::one() / 8.0;
next.hold.scale = Vec3::one() * 0.0;
next
}
}

View File

@ -1,15 +1,18 @@
pub mod alpha;
pub mod beta;
pub mod idle;
pub mod jump;
pub mod run;
pub mod wield;
pub mod shoot;
pub mod charge;
pub mod dash;
pub mod spin;
// Reexports
pub use self::{
alpha::AlphaAnimation, idle::IdleAnimation, jump::JumpAnimation, run::RunAnimation,
wield::WieldAnimation, charge::ChargeAnimation, shoot::ShootAnimation,
alpha::AlphaAnimation, beta::BetaAnimation, idle::IdleAnimation, jump::JumpAnimation, run::RunAnimation,
wield::WieldAnimation, charge::ChargeAnimation, shoot::ShootAnimation, dash::DashAnimation, spin::SpinAnimation,
};
use super::{make_bone, vek::*, FigureBoneData, Skeleton};

View File

@ -92,6 +92,8 @@ impl Animation for ShootAnimation {
let short = (anim_time as f32 * lab as f32 * 16.0).sin();
let shortalt = (anim_time as f32 * lab as f32 * 16.0 + PI / 2.0).sin();
next.hold.scale = Vec3::one() * 0.0;
if velocity < 0.5 {
next.head.position = Vec3::new(
0.0,

View File

@ -0,0 +1,199 @@
use super::{
super::{vek::*, Animation},
BipedLargeSkeleton, SkeletonAttr,
};
use common::{
comp::item::{Hands, ToolKind},
states::utils::StageSection,
};
use std::f32::consts::PI;
pub struct Input {
pub attack: bool,
}
pub struct SpinAnimation;
impl Animation for SpinAnimation {
type Dependency = (
Option<ToolKind>,
Option<ToolKind>,
f64,
Option<StageSection>,
);
type Skeleton = BipedLargeSkeleton;
#[cfg(feature = "use-dyn-lib")]
const UPDATE_FN: &'static [u8] = b"biped_large_spin\0";
#[cfg_attr(feature = "be-dyn-lib", export_name = "biped_large_spin")]
fn update_skeleton_inner(
skeleton: &Self::Skeleton,
(active_tool_kind, second_tool_kind, _global_time, stage_section): 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 foot = (((5.0)
/ (1.1 + 3.9 * ((anim_time as f32 * lab as f32 * 10.32).sin()).powf(2.0 as f32)))
.sqrt())
* ((anim_time as f32 * lab as f32 * 10.32).sin());
let decel = (anim_time as f32 * 16.0 * lab as f32).min(PI / 2.0).sin();
let spin = (anim_time as f32 * 2.8 * lab as f32).sin();
let spinhalf = (anim_time as f32 * 1.4 * lab as f32).sin();
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 stab = (anim_time as f32 * 8.0).sin();
let rotate = (anim_time as f32 * 1.0).sin();
next.head.position = Vec3::new(0.0, skeleton_attr.head.0, skeleton_attr.head.1);
if let Some(ToolKind::Sword(_)) = active_tool_kind {
next.hand_l.position = Vec3::new(-0.75, -1.0, 2.5);
next.hand_l.orientation = Quaternion::rotation_x(1.47) * Quaternion::rotation_y(-0.2);
next.hand_l.scale = Vec3::one() * 1.04;
next.hand_r.position = Vec3::new(0.75, -1.5, -0.5);
next.hand_r.orientation = Quaternion::rotation_x(1.47) * Quaternion::rotation_y(0.3);
next.hand_r.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);
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(0.0)
* Quaternion::rotation_y(-0.57 + movement * 2.0)
* Quaternion::rotation_z(0.0);
next.upper_torso.orientation = Quaternion::rotation_y(movement * -0.1)
* Quaternion::rotation_z(-1.07 + movement * -0.6);
next.lower_torso.orientation = Quaternion::rotation_x(movement * 0.1);
next.head.orientation = Quaternion::rotation_y(movement * 0.1)
* Quaternion::rotation_z(1.07 + movement * 0.4);
},
StageSection::Swing => {
//println!("{:.3} swing", anim_time);
next.control.position = Vec3::new(
7.0 + movement * -8.0,
11.0 + stab * 3.0,
2.0 + stab * 3.5 + movement * 3.0,
);
next.control.orientation =
Quaternion::rotation_x(-1.57 + movement * -0.6 + stab * -0.25)
* Quaternion::rotation_y(2.8 + movement * -2.0)
* Quaternion::rotation_z(1.0 + movement * 1.0);
next.head.orientation = Quaternion::rotation_z(-stab * 0.8);
next.upper_torso.orientation = Quaternion::rotation_x(stab * 0.15)
* Quaternion::rotation_y(movement * 0.3)
* Quaternion::rotation_z(movement * 1.5);
next.lower_torso.orientation = Quaternion::rotation_z(rotate * 1.5);
next.torso.orientation = Quaternion::rotation_z(rotate * 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.upper_torso.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);
},
_ => {},
}
}
}
// println!("{:?}", stage_progress),
if let Some(ToolKind::Axe(_) | ToolKind::Hammer(_) | ToolKind::Dagger(_)) = active_tool_kind
{
//INTENTION: SWORD
next.hand_l.position = Vec3::new(-0.75, -1.0, -2.5);
next.hand_l.orientation = Quaternion::rotation_x(1.27);
next.hand_l.scale = Vec3::one() * 1.04;
next.hand_r.position = Vec3::new(0.75, -1.5, -5.5);
next.hand_r.orientation = Quaternion::rotation_x(1.27);
next.hand_r.scale = Vec3::one() * 1.05;
next.main.position = Vec3::new(0.0, 6.0, -1.0);
next.main.orientation = Quaternion::rotation_x(-0.3)
* Quaternion::rotation_y(0.0)
* Quaternion::rotation_z(0.0);
next.main.scale = Vec3::one();
next.control.position = Vec3::new(-4.5 + spinhalf * 4.0, 11.0, 8.0);
next.control.orientation = Quaternion::rotation_x(-1.7)
* Quaternion::rotation_y(0.2 + spin * -2.0)
* Quaternion::rotation_z(1.4 + spin * 0.1);
next.control.scale = Vec3::one();
next.head.position = Vec3::new(
0.0,
-2.0 + skeleton_attr.head.0 + spin * -0.8,
skeleton_attr.head.1,
);
next.head.orientation = Quaternion::rotation_z(spin * -0.25)
* Quaternion::rotation_x(0.0 + spin * -0.1)
* Quaternion::rotation_y(spin * -0.2);
next.upper_torso.position = Vec3::new(0.0, skeleton_attr.upper_torso.0, skeleton_attr.upper_torso.1);
next.upper_torso.orientation = Quaternion::rotation_z(spin * 0.1)
* Quaternion::rotation_x(0.0 + spin * 0.1)
* Quaternion::rotation_y(decel * -0.2);
next.upper_torso.scale = Vec3::one();
next.lower_torso.position = Vec3::new(0.0, 0.0, -5.0);
next.lower_torso.scale = Vec3::one();
next.torso.position = Vec3::new(0.0, 0.0, 0.1) * 1.01;
next.torso.orientation = Quaternion::rotation_z((spin * 7.0).max(0.3))
* Quaternion::rotation_x(0.0)
* Quaternion::rotation_y(0.0);
next.torso.scale = Vec3::one() / 11.0 * 1.01;
next.foot_l.position =
Vec3::new(-skeleton_attr.foot.0, foot * 1.0, skeleton_attr.foot.2);
next.foot_l.orientation = Quaternion::rotation_x(foot * -1.2);
next.foot_l.scale = Vec3::one();
next.foot_r.position =
Vec3::new(skeleton_attr.foot.0, foot * -1.0, skeleton_attr.foot.2);
next.foot_r.orientation = Quaternion::rotation_x(foot * 1.2);
next.foot_r.scale = Vec3::one();
next.shoulder_l.position = Vec3::new(-5.0, 0.0, 4.7);
next.shoulder_l.orientation = Quaternion::rotation_x(0.0);
next.shoulder_l.scale = Vec3::one() * 1.1;
next.shoulder_r.position = Vec3::new(5.0, 0.0, 4.7);
next.shoulder_r.orientation = Quaternion::rotation_x(0.0);
next.shoulder_r.scale = Vec3::one() * 1.1;
}
next.second.scale = match (
active_tool_kind.map(|tk| tk.hands()),
second_tool_kind.map(|tk| tk.hands()),
) {
(Some(Hands::OneHand), Some(Hands::OneHand)) => Vec3::one(),
(_, _) => Vec3::zero(),
};
next
}
}

View File

@ -2735,7 +2735,7 @@ make_vox_spec!(
body.species,
body.body_type,
)),
None,
Some(mesh_hold()),
]
},
);

View File

@ -2259,7 +2259,13 @@ impl FigureMgr {
CharacterState::BasicMelee(_) => {
anim::biped_large::AlphaAnimation::update_skeleton(
&target_base,
(vel.0.magnitude(), time),
(
active_tool_kind,
second_tool_kind,
vel.0.magnitude(),
time,
None,
),
state.state_time,
&mut state_animation_rate,
skeleton_attr,
@ -2317,6 +2323,100 @@ impl FigureMgr {
)
}
},
CharacterState::DashMelee(s) => {
let stage_time = s.timer.as_secs_f64();
let stage_progress = match s.stage_section {
StageSection::Buildup => {
stage_time / s.static_data.buildup_duration.as_secs_f64()
},
StageSection::Charge => {
stage_time / s.static_data.charge_duration.as_secs_f64()
},
StageSection::Swing => {
stage_time / s.static_data.swing_duration.as_secs_f64()
},
StageSection::Recover => {
stage_time / s.static_data.recover_duration.as_secs_f64()
},
};
anim::biped_large::DashAnimation::update_skeleton(
&target_base,
(
active_tool_kind,
second_tool_kind,
time,
Some(s.stage_section),
),
stage_progress,
&mut state_animation_rate,
skeleton_attr,
)
},
CharacterState::ComboMelee(s) => {
let stage_index = (s.stage - 1) as usize;
let stage_time = s.timer.as_secs_f64();
let stage_progress = match s.stage_section {
StageSection::Buildup => {
stage_time
/ s.static_data.stage_data[stage_index]
.base_buildup_duration
.as_secs_f64()
},
StageSection::Swing => {
stage_time
/ s.static_data.stage_data[stage_index]
.base_swing_duration
.as_secs_f64()
},
StageSection::Recover => {
stage_time
/ s.static_data.stage_data[stage_index]
.base_recover_duration
.as_secs_f64()
},
_ => 0.0,
};
match s.stage {
1 => anim::biped_large::AlphaAnimation::update_skeleton(
&target_base,
(
active_tool_kind,
second_tool_kind,
vel.0.magnitude(),
time,
Some(s.stage_section),
),
stage_progress,
&mut state_animation_rate,
skeleton_attr,
),
2 => anim::biped_large::SpinAnimation::update_skeleton(
&target_base,
(
active_tool_kind,
second_tool_kind,
time,
Some(s.stage_section),
),
stage_progress,
&mut state_animation_rate,
skeleton_attr,
),
_ => anim::biped_large::BetaAnimation::update_skeleton(
&target_base,
(
active_tool_kind,
second_tool_kind,
vel.0.magnitude(),
time,
Some(s.stage_section),
),
stage_progress,
&mut state_animation_rate,
skeleton_attr,
),
}
},
// TODO!
_ => target_base,
};