werewolf work

This commit is contained in:
jshipsey 2020-10-08 17:14:49 -04:00 committed by Robin Gilh
parent 50aac17d94
commit 65df398672
23 changed files with 438 additions and 328 deletions

View File

@ -301,7 +301,7 @@
),
(Werewolf, Male): (
head: (
offset: (-5.0, -7.5, -6.5),
offset: (-5.0, 0.0, -6.5),
central: ("npc.werewolf.male.head"),
),
torso_upper: (
@ -331,7 +331,7 @@
),
(Werewolf, Female): (
head: (
offset: (-5.0, -7.5, -6.5),
offset: (-5.0, 0.0, -6.5),
central: ("npc.werewolf.male.head"),
),
torso_upper: (

View File

@ -341,11 +341,11 @@
),
(Werewolf, Male): (
shoulder_l: (
offset: (-4.0, -4.5, -5.0),
offset: (-4.0, -6.0, -8.0),
lateral: ("npc.werewolf.male.shoulder_l"),
),
shoulder_r: (
offset: (-4.0, -4.5, -5.0),
offset: (-4.0, -6.0, -8.0),
lateral: ("npc.werewolf.male.shoulder_r"),
),
hand_l: (
@ -357,29 +357,29 @@
lateral: ("npc.werewolf.male.hand_r"),
),
leg_l: (
offset: (-2.5, -4.0, -3.5),
offset: (-2.5, -4.0, -4.5),
lateral: ("npc.werewolf.male.leg_l"),
),
leg_r: (
offset: (-2.5, -4.0, -3.5),
offset: (-2.5, -4.0, -4.5),
lateral: ("npc.werewolf.male.leg_r"),
),
foot_l: (
offset: (-3.5, -6.0, -5.5),
offset: (-3.5, -6.0, -9.0),
lateral: ("npc.werewolf.male.foot_l"),
),
foot_r: (
offset: (-3.5, -6.0, -5.5),
offset: (-3.5, -6.0, -9.0),
lateral: ("npc.werewolf.male.foot_r"),
),
),
(Werewolf, Female): (
shoulder_l: (
offset: (-4.0, -4.5, -5.0),
offset: (-4.0, -6.0, -8.0),
lateral: ("npc.werewolf.male.shoulder_l"),
),
shoulder_r: (
offset: (-4.0, -4.5, -5.0),
offset: (-4.0, -6.0, -8.0),
lateral: ("npc.werewolf.male.shoulder_r"),
),
hand_l: (
@ -391,19 +391,19 @@
lateral: ("npc.werewolf.male.hand_r"),
),
leg_l: (
offset: (-2.5, -4.0, -3.5),
offset: (-2.5, -4.0, -4.5),
lateral: ("npc.werewolf.male.leg_l"),
),
leg_r: (
offset: (-2.5, -4.0, -3.5),
offset: (-2.5, -4.0, -4.5),
lateral: ("npc.werewolf.male.leg_r"),
),
foot_l: (
offset: (-3.5, -6.0, -5.5),
offset: (-3.5, -6.0, -9.0),
lateral: ("npc.werewolf.male.foot_l"),
),
foot_r: (
offset: (-3.5, -6.0, -5.5),
offset: (-3.5, -6.0, -9.0),
lateral: ("npc.werewolf.male.foot_r"),
),
),

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -60,10 +60,7 @@ impl<'a, SpeciesMeta> core::ops::Index<&'a Species> for AllSpecies<SpeciesMeta>
}
}
pub const ALL_SPECIES: [Species; 2] = [
Species::StoneGolem,
Species::Treant,
];
pub const ALL_SPECIES: [Species; 2] = [Species::StoneGolem, Species::Treant];
impl<'a, SpeciesMeta: 'a> IntoIterator for &'a AllSpecies<SpeciesMeta> {
type IntoIter = std::iter::Copied<std::slice::Iter<'static, Self::Item>>;

View File

@ -1,6 +1,5 @@
use crate::comp::{
golem,
biped_large,
biped_large, golem,
item::{Item, ItemKind},
Alignment, Body, CharacterAbility, ItemConfig, Loadout,
};

View File

@ -39,7 +39,7 @@ impl Body {
Body::Dragon(_) => 250.0,
Body::BirdSmall(_) => 75.0,
Body::FishSmall(_) => 40.0,
Body::BipedLarge(_) => 75.0,
Body::BipedLarge(_) => 160.0,
Body::Object(_) => 40.0,
Body::Golem(_) => 60.0,
Body::Theropod(_) => 135.0,

View File

@ -149,14 +149,21 @@ impl Animation for AlphaAnimation {
* Quaternion::rotation_y(slow * -0.15);
next.head.scale = Vec3::one() * 1.01;
next.upper_torso.position = Vec3::new(0.0, skeleton_attr.upper_torso.0, skeleton_attr.upper_torso.1);
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(slow * 0.4)
* Quaternion::rotation_x(0.0 + slow * -0.2)
* Quaternion::rotation_y(slow * 0.2);
next.upper_torso.scale = Vec3::one();
next.lower_torso.position =
Vec3::new(0.0, skeleton_attr.lower_torso.0, skeleton_attr.lower_torso.1);
next.lower_torso.position = Vec3::new(
0.0,
skeleton_attr.lower_torso.0,
skeleton_attr.lower_torso.1,
);
next.lower_torso.orientation = next.upper_torso.orientation * -0.45;
// TODO: Fix animation
@ -258,10 +265,9 @@ impl Animation for AlphaAnimation {
},
Some(ToolKind::Hammer(_)) => {
next.hand_l.position = Vec3::new(-15.0, 0.0, 0.0);
next.hand_l.orientation =
Quaternion::rotation_x(-0.0)
next.hand_l.orientation = Quaternion::rotation_x(-0.0)
* Quaternion::rotation_y(0.0)
* Quaternion::rotation_z(-PI / 2.0);;
* Quaternion::rotation_z(-PI / 2.0);
next.hand_l.scale = Vec3::one() * 1.08;
next.hand_r.position = Vec3::new(3.0, 0.0, 0.0);
next.hand_r.orientation = Quaternion::rotation_x(0.0)
@ -303,17 +309,17 @@ impl Animation for AlphaAnimation {
if velocity > 0.5 {
next.foot_l.position =
Vec3::new(-skeleton_attr.foot.0, foot * -6.0, skeleton_attr.foot.2) / 8.0;
Vec3::new(-skeleton_attr.foot.0, foot * -6.0, skeleton_attr.foot.2);
next.foot_l.orientation = Quaternion::rotation_x(foot * -0.4)
* Quaternion::rotation_z((slower * 0.3).max(0.0));
next.foot_l.scale = Vec3::one() / 8.0;
next.foot_l.scale = Vec3::one();
next.foot_r.position =
Vec3::new(skeleton_attr.foot.0, foot * 6.0, skeleton_attr.foot.2) / 8.0;
Vec3::new(skeleton_attr.foot.0, foot * 6.0, skeleton_attr.foot.2);
next.foot_r.orientation = Quaternion::rotation_x(foot * 0.4)
* Quaternion::rotation_z((slower * 0.3).max(0.0));
next.foot_r.scale = Vec3::one() / 8.0;
next.torso.position = Vec3::new(0.0, 0.0, 0.1) * 1.01;
next.foot_r.scale = Vec3::one();
next.torso.position = Vec3::new(0.0, 0.0, 0.) * 1.01;
next.torso.orientation =
Quaternion::rotation_z(0.0) * Quaternion::rotation_x(-0.15);
next.torso.scale = Vec3::one() / 8.0 * 1.01;
@ -391,7 +397,7 @@ impl Animation for AlphaAnimation {
* Quaternion::rotation_x(0.0 + decel * -0.2)
* Quaternion::rotation_y(decel * 0.2);
next.torso.position = Vec3::new(0.0, 0.0, 0.1) * 1.01;
next.torso.position = Vec3::new(0.0, 0.0, 0.0) * 1.01;
next.torso.scale = Vec3::one() / 8.0 * 1.01;
next.lower_torso.position = Vec3::new(0.0, 0.0, 0.0);

View File

@ -24,7 +24,7 @@ impl Animation for ChargeAnimation {
#[cfg_attr(feature = "be-dyn-lib", export_name = "biped_large_charge")]
fn update_skeleton_inner(
skeleton: &Self::Skeleton,
(active_tool_kind, second_tool_kind, velocity, orientation, last_ori, global_time): Self::Dependency,
(active_tool_kind, _second_tool_kind, velocity, orientation, last_ori, global_time): Self::Dependency,
anim_time: f64,
_rate: &mut f32,
skeleton_attr: &SkeletonAttr,
@ -37,7 +37,7 @@ impl Animation for ChargeAnimation {
let slower = (anim_time as f32 * 1.0 + PI).sin();
let slow = (anim_time as f32 * 3.5 + PI).sin();
let tailmove = Vec2::new(
((global_time + anim_time) as f32 / 2.0)
.floor()
@ -104,7 +104,7 @@ impl Animation for ChargeAnimation {
* ((anim_time as f32 * lab as f32 * 8.0 + PI / 2.0).sin()).powf(2.0 as f32)))
.sqrt())
* ((anim_time as f32 * lab as f32 * 8.0 + PI / 2.0).sin());
let stress = (((5.0)
let stress = (((5.0)
/ (0.5 + 4.5 * ((anim_time as f32 * lab as f32 * 20.0).cos()).powf(2.0 as f32)))
.sqrt())
* ((anim_time as f32 * lab as f32 * 20.0).cos());
@ -137,12 +137,19 @@ impl Animation for ChargeAnimation {
Quaternion::rotation_z(stop * -1.0 + tilt * -2.0) * Quaternion::rotation_y(stop * -0.3);
next.head.scale = Vec3::one() * 1.02;
next.upper_torso.position = Vec3::new(0.0, skeleton_attr.upper_torso.0, skeleton_attr.upper_torso.1);
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(stop * 1.2 + stress * stop * 0.02 + tilt * -2.0);
next.lower_torso.position = Vec3::new(0.0, skeleton_attr.lower_torso.0, skeleton_attr.lower_torso.1);
next.lower_torso.position = Vec3::new(
0.0,
skeleton_attr.lower_torso.0,
skeleton_attr.lower_torso.1,
);
next.lower_torso.orientation = Quaternion::rotation_z(stop * -0.7 + tilt * 4.0);
if velocity < 0.5 {
@ -153,7 +160,7 @@ impl Animation for ChargeAnimation {
);
next.jaw.orientation = Quaternion::rotation_x(slow * 0.05);
next.jaw.scale = Vec3::one() * 0.98;
next.tail.position = Vec3::new(0.0, skeleton_attr.tail.0, skeleton_attr.tail.1);
next.tail.orientation =
Quaternion::rotation_z(0.0 + slow * 0.2 + tailmove.x) * Quaternion::rotation_x(0.0);
@ -224,7 +231,7 @@ impl Animation for ChargeAnimation {
);
next.jaw.orientation = Quaternion::rotation_x(slow * 0.05);
next.jaw.scale = Vec3::one() * 0.98;
next.tail.position = Vec3::new(0.0, skeleton_attr.tail.0, skeleton_attr.tail.1);
next.tail.orientation =
Quaternion::rotation_z(0.0 + slow * 0.2 + tailmove.x) * Quaternion::rotation_x(0.0);
@ -242,17 +249,17 @@ impl Animation for ChargeAnimation {
next.leg_l.orientation =
Quaternion::rotation_z(short * 0.18) * Quaternion::rotation_x(foothoril * 0.3);
next.leg_l.scale = Vec3::one() * 0.98;
next.leg_r.position = Vec3::new(
skeleton_attr.leg.0,
skeleton_attr.leg.1,
skeleton_attr.leg.2,
) * 0.98;
next.leg_r.orientation =
Quaternion::rotation_z(short * 0.18) * Quaternion::rotation_x(foothorir * 0.3);
next.leg_r.scale = Vec3::one() * 0.98;
next.foot_l.position = Vec3::new(
-skeleton_attr.foot.0,
4.0 + skeleton_attr.foot.1 + foothoril * 8.5,
@ -261,7 +268,7 @@ impl Animation for ChargeAnimation {
next.foot_l.orientation =
Quaternion::rotation_x(-0.5 + footrotl * 0.85) * Quaternion::rotation_y(0.0);
next.foot_l.scale = Vec3::one() / 8.0;
next.foot_r.position = Vec3::new(
skeleton_attr.foot.0,
4.0 + skeleton_attr.foot.1 + foothorir * 8.5,
@ -270,7 +277,6 @@ impl Animation for ChargeAnimation {
next.foot_r.orientation =
Quaternion::rotation_x(-0.5 + footrotr * 0.85) * Quaternion::rotation_y(0.0);
next.foot_r.scale = Vec3::one() / 8.0;
}
match active_tool_kind {
Some(ToolKind::Bow(_)) => {
@ -279,7 +285,7 @@ impl Animation for ChargeAnimation {
* Quaternion::rotation_y(-0.6)
* Quaternion::rotation_z(-0.3);
next.hand_l.scale = Vec3::one() * 1.05;
next.hand_r.position = Vec3::new(5.9, 0.0, -5.0);
next.hand_r.orientation = Quaternion::rotation_x(1.20)
* Quaternion::rotation_y(-0.6)
@ -306,16 +312,12 @@ impl Animation for ChargeAnimation {
* Quaternion::rotation_z(footrotr * -0.05);
next.shoulder_r.scale = Vec3::one();
next.jaw.position = Vec3::new(
0.0,
skeleton_attr.jaw.0,
skeleton_attr.jaw.1,
);
next.jaw.position = Vec3::new(0.0, skeleton_attr.jaw.0, skeleton_attr.jaw.1);
next.jaw.orientation = Quaternion::rotation_x(stop * 0.05);
next.tail.position = Vec3::new(0.0, skeleton_attr.tail.0, skeleton_attr.tail.1);
next.tail.orientation =
Quaternion::rotation_z(0.02 * stress * stop + tilt * 2.0) * Quaternion::rotation_x(-0.2 * stop);
next.tail.orientation = Quaternion::rotation_z(0.02 * stress * stop + tilt * 2.0)
* Quaternion::rotation_x(-0.2 * stop);
next.tail.scale = Vec3::one();
next.main.position = Vec3::new(7.0, 2.0, -13.0);
@ -354,7 +356,7 @@ impl Animation for ChargeAnimation {
* Quaternion::rotation_y(0.1)
* Quaternion::rotation_z(footrotl * 0.1);
next.shoulder_l.scale = Vec3::one();
next.shoulder_r.position = Vec3::new(
skeleton_attr.shoulder.0,
skeleton_attr.shoulder.1 + foothorir * -1.0,
@ -366,8 +368,8 @@ impl Animation for ChargeAnimation {
next.shoulder_r.scale = Vec3::one();
next.tail.position = Vec3::new(0.0, skeleton_attr.tail.0, skeleton_attr.tail.1);
next.tail.orientation =
Quaternion::rotation_z(0.02 * stress * stop + tilt * 2.0) * Quaternion::rotation_x(-0.2 * stop);
next.tail.orientation = Quaternion::rotation_z(0.02 * stress * stop + tilt * 2.0)
* Quaternion::rotation_x(-0.2 * stop);
next.tail.scale = Vec3::one();
next.main.position = Vec3::new(8.0, 8.5, 13.2);
@ -389,4 +391,4 @@ impl Animation for ChargeAnimation {
next
}
}
}

View File

@ -138,7 +138,7 @@ impl Animation for DashAnimation {
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,
@ -161,8 +161,9 @@ impl Animation for DashAnimation {
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.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 =
@ -200,7 +201,8 @@ impl Animation for DashAnimation {
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.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);

View File

@ -28,7 +28,7 @@ impl Animation for IdleAnimation {
let slower = (anim_time as f32 * 1.0 + PI).sin();
let slow = (anim_time as f32 * 3.5 + PI).sin();
let look = Vec2::new(
((global_time + anim_time) as f32 / 8.0)
.floor()
@ -54,15 +54,17 @@ impl Animation for IdleAnimation {
* 0.125,
);
let breathe = if skeleton_attr.beast {
// Controls for the beast breathing
let intensity = 0.04;
let lenght = 1.5;
let chop = 0.2;
let chop_freq = 60.0;
intensity * (lenght * anim_time as f32).sin() + 0.05 * chop * (anim_time as f32 * chop_freq).sin() * (anim_time as f32 * lenght).cos()
intensity * (lenght * anim_time as f32).sin()
+ 0.05
* chop
* (anim_time as f32 * chop_freq).sin()
* (anim_time as f32 * lenght).cos()
} else {
0.0
};
@ -72,7 +74,8 @@ impl Animation for IdleAnimation {
skeleton_attr.head.0,
skeleton_attr.head.1 + torso * 0.2,
) * 1.02;
next.head.orientation = Quaternion::rotation_z(look.x * 0.6) * Quaternion::rotation_x(look.y * 0.6 + breathe);
next.head.orientation =
Quaternion::rotation_z(look.x * 0.6) * Quaternion::rotation_x(look.y * 0.6 + breathe);
next.head.scale = Vec3::one() * 1.02 + breathe * 0.4;
next.upper_torso.position = Vec3::new(
@ -80,7 +83,8 @@ impl Animation for IdleAnimation {
skeleton_attr.upper_torso.0,
skeleton_attr.upper_torso.1 + torso * 0.5,
);
next.upper_torso.orientation = Quaternion::rotation_z(0.0) * Quaternion::rotation_x(- breathe);
next.upper_torso.orientation =
Quaternion::rotation_z(0.0) * Quaternion::rotation_x(-breathe);
next.upper_torso.scale = Vec3::one() - breathe * 0.4;
next.lower_torso.position = Vec3::new(
@ -88,15 +92,12 @@ impl Animation for IdleAnimation {
skeleton_attr.lower_torso.0,
skeleton_attr.lower_torso.1 + torso * 0.15,
);
next.lower_torso.orientation = Quaternion::rotation_z(0.0) * Quaternion::rotation_x(breathe);
next.lower_torso.orientation =
Quaternion::rotation_z(0.0) * Quaternion::rotation_x(breathe);
next.lower_torso.scale = Vec3::one() * 1.02 + breathe * 0.4;
if skeleton_attr.beast {
next.jaw.position = Vec3::new(
0.0,
skeleton_attr.jaw.0,
skeleton_attr.jaw.1,
);
next.jaw.position = Vec3::new(0.0, skeleton_attr.jaw.0, skeleton_attr.jaw.1);
} else {
next.jaw.position = Vec3::new(
0.0,
@ -158,42 +159,52 @@ impl Animation for IdleAnimation {
next.hand_r.orientation = Quaternion::rotation_z(0.0) * Quaternion::rotation_x(0.0);
next.hand_r.scale = Vec3::one() * 1.02;
next.arm_control_l.scale = Vec3::one() * 1.0;
next.arm_control_r.scale = Vec3::one() * 1.0;
next.leg_control_l.scale = Vec3::one() * 1.0;
next.leg_l.position = Vec3::new(
-skeleton_attr.leg.0,
skeleton_attr.leg.1,
skeleton_attr.leg.2 + torso * 0.2,
) * 1.02;
);
next.leg_l.orientation = Quaternion::rotation_z(0.0) * Quaternion::rotation_x(0.0);
next.leg_l.scale = Vec3::one() * 1.02;
next.leg_l.scale = Vec3::one();
next.leg_r.position = Vec3::new(
skeleton_attr.leg.0,
skeleton_attr.leg.1,
skeleton_attr.leg.2 + torso * 0.2,
) * 1.02;
);
next.leg_r.orientation = Quaternion::rotation_z(0.0) * Quaternion::rotation_x(0.0);
next.leg_r.scale = Vec3::one() * 1.02;
next.leg_r.scale = Vec3::one();
next.foot_l.position = Vec3::new(
-skeleton_attr.foot.0,
skeleton_attr.foot.1,
skeleton_attr.foot.2,
) / 8.0;
);
next.foot_l.orientation = Quaternion::rotation_z(0.0) * Quaternion::rotation_x(0.0);
next.foot_l.scale = Vec3::one() / 8.0;
next.foot_l.scale = Vec3::one();
next.foot_r.position = Vec3::new(
skeleton_attr.foot.0,
skeleton_attr.foot.1,
skeleton_attr.foot.2,
) / 8.0;
);
next.foot_r.orientation = Quaternion::rotation_z(0.0) * Quaternion::rotation_x(0.0);
next.foot_r.scale = Vec3::one() / 8.0;
next.foot_r.scale = Vec3::one();
next.torso.position = Vec3::new(0.0, 0.0, 0.0) / 8.0;
next.torso.orientation = Quaternion::rotation_z(0.0) * Quaternion::rotation_x(0.0);
next.torso.scale = Vec3::one() / 8.0;
next.leg_control_l.scale = Vec3::one() * 1.0;
next.leg_control_r.scale = Vec3::one() * 1.0;
next.arm_control_l.scale = Vec3::one() * 1.0;
next.arm_control_r.scale = Vec3::one() * 1.0;
next.hold.scale = Vec3::one() * 0.0;
next

View File

@ -1,20 +1,20 @@
pub mod alpha;
pub mod beta;
pub mod charge;
pub mod dash;
pub mod idle;
pub mod jump;
pub mod run;
pub mod wield;
pub mod shoot;
pub mod charge;
pub mod dash;
pub mod spin;
pub mod spinmelee;
pub mod wield;
// Reexports
pub use self::{
alpha::AlphaAnimation, beta::BetaAnimation, idle::IdleAnimation, jump::JumpAnimation, run::RunAnimation,
wield::WieldAnimation, charge::ChargeAnimation, shoot::ShootAnimation, dash::DashAnimation, spin::SpinAnimation,
spinmelee::SpinMeleeAnimation,
alpha::AlphaAnimation, beta::BetaAnimation, charge::ChargeAnimation, dash::DashAnimation,
idle::IdleAnimation, jump::JumpAnimation, run::RunAnimation, shoot::ShootAnimation,
spin::SpinAnimation, spinmelee::SpinMeleeAnimation, wield::WieldAnimation,
};
use super::{make_bone, vek::*, FigureBoneData, Skeleton};
@ -42,6 +42,10 @@ skeleton_impls!(struct BipedLargeSkeleton {
+ hold,
torso,
control,
leg_control_l,
leg_control_r,
arm_control_l,
arm_control_r,
});
impl Skeleton for BipedLargeSkeleton {
@ -62,9 +66,20 @@ impl Skeleton for BipedLargeSkeleton {
let torso_mat = base_mat * Mat4::<f32>::from(self.torso);
let upper_torso_mat = torso_mat * upper_torso;
let lower_torso_mat = upper_torso_mat * Mat4::<f32>::from(self.lower_torso);
let leg_l = Mat4::<f32>::from(self.leg_l);
let leg_r = Mat4::<f32>::from(self.leg_r);
let leg_control_l = lower_torso_mat * Mat4::<f32>::from(self.leg_control_l);
let leg_control_r = lower_torso_mat * Mat4::<f32>::from(self.leg_control_r);
let arm_control_l = upper_torso_mat * Mat4::<f32>::from(self.arm_control_l);
let arm_control_r = upper_torso_mat * Mat4::<f32>::from(self.arm_control_r);
let head_mat = upper_torso_mat * Mat4::<f32>::from(self.head);
let control_mat = upper_torso_mat * Mat4::<f32>::from(self.control);
let control_mat = Mat4::<f32>::from(self.control);
let hand_l_mat = Mat4::<f32>::from(self.hand_l);
*(<&mut [_; Self::BONE_COUNT]>::try_from(&mut buf[0..Self::BONE_COUNT]).unwrap()) = [
@ -73,16 +88,16 @@ impl Skeleton for BipedLargeSkeleton {
make_bone(upper_torso_mat),
make_bone(lower_torso_mat),
make_bone(lower_torso_mat * Mat4::<f32>::from(self.tail)),
make_bone(control_mat * Mat4::<f32>::from(self.main)),
make_bone(control_mat * Mat4::<f32>::from(self.second)),
make_bone(upper_torso_mat * Mat4::<f32>::from(self.shoulder_l)),
make_bone(upper_torso_mat * Mat4::<f32>::from(self.shoulder_r)),
make_bone(control_mat * Mat4::<f32>::from(self.hand_l)),
make_bone(control_mat * Mat4::<f32>::from(self.hand_r)),
make_bone(lower_torso_mat * Mat4::<f32>::from(self.leg_l)),
make_bone(lower_torso_mat * Mat4::<f32>::from(self.leg_r)),
make_bone(base_mat * Mat4::<f32>::from(self.foot_l)),
make_bone(base_mat * Mat4::<f32>::from(self.foot_r)),
make_bone(upper_torso_mat * control_mat * Mat4::<f32>::from(self.main)),
make_bone(upper_torso_mat * control_mat * Mat4::<f32>::from(self.second)),
make_bone(arm_control_l * Mat4::<f32>::from(self.shoulder_l)),
make_bone(arm_control_r * Mat4::<f32>::from(self.shoulder_r)),
make_bone(arm_control_l * control_mat * Mat4::<f32>::from(self.hand_l)),
make_bone(arm_control_r * control_mat * Mat4::<f32>::from(self.hand_r)),
make_bone(leg_control_l * leg_l),
make_bone(leg_control_r * leg_r),
make_bone(leg_control_l * Mat4::<f32>::from(self.foot_l)),
make_bone(leg_control_r * Mat4::<f32>::from(self.foot_r)),
// FIXME: Should this be control_l_mat?
make_bone(control_mat * hand_l_mat * Mat4::<f32>::from(self.hold)),
];
@ -101,10 +116,6 @@ pub struct SkeletonAttr {
leg: (f32, f32, f32),
foot: (f32, f32, f32),
beast: bool,
beast_ori: f32,
beast_head: (f32, f32),
beast_foot: (f32, f32, f32),
beast_hand: (f32, f32, f32),
}
impl<'a> std::convert::TryFrom<&'a comp::Body> for SkeletonAttr {
@ -131,10 +142,6 @@ impl Default for SkeletonAttr {
leg: (0.0, 0.0, 0.0),
foot: (0.0, 0.0, 0.0),
beast: false,
beast_ori: 0.0,
beast_head: (0.0, 0.0),
beast_foot: (0.0, 0.0, 0.0),
beast_hand: (0.0, 0.0, 0.0),
}
}
}
@ -150,7 +157,7 @@ impl<'a> From<&'a Body> for SkeletonAttr {
(Wendigo, _) => (3.0, 13.5),
(Troll, _) => (6.0, 10.0),
(Dullahan, _) => (3.0, 6.0),
(Werewolf, _) => (19.0, 1.0),
(Werewolf, _) => (11.5, 1.0),
(Occultlizardman, _) => (6.0, 3.5),
(Mightylizardman, _) => (6.0, 3.5),
(Slylizardman, _) => (6.0, 3.5),
@ -161,7 +168,7 @@ impl<'a> From<&'a Body> for SkeletonAttr {
(Wendigo, _) => (0.0, 0.0),
(Troll, _) => (2.0, -4.0),
(Dullahan, _) => (0.0, 0.0),
(Werewolf, _) => (-2.5, -4.5),
(Werewolf, _) => (5.0, -4.5),
(Occultlizardman, _) => (1.0, -2.5),
(Mightylizardman, _) => (1.0, -2.5),
(Slylizardman, _) => (1.0, -2.5),
@ -173,7 +180,7 @@ impl<'a> From<&'a Body> for SkeletonAttr {
(Wendigo, _) => (-1.0, 29.0),
(Troll, _) => (-1.0, 27.5),
(Dullahan, _) => (0.0, 29.0),
(Werewolf, _) => (3.0, 26.5),
(Werewolf, _) => (3.0, 27.5),
(Occultlizardman, _) => (3.0, 23.0),
(Mightylizardman, _) => (3.0, 23.0),
(Slylizardman, _) => (3.0, 23.0),
@ -208,7 +215,7 @@ impl<'a> From<&'a Body> for SkeletonAttr {
(Wendigo, _) => (9.0, 0.5, -0.5),
(Troll, _) => (11.0, 0.5, -1.5),
(Dullahan, _) => (14.0, 0.5, 4.5),
(Werewolf, _) => (9.0, 4.0, -6.5),
(Werewolf, _) => (9.0, 4.0, -3.0),
(Occultlizardman, _) => (7.5, 1.0, -1.5),
(Mightylizardman, _) => (7.5, 1.0, -1.5),
(Slylizardman, _) => (7.5, 1.0, -1.5),
@ -232,43 +239,27 @@ impl<'a> From<&'a Body> for SkeletonAttr {
(Wendigo, _) => (2.0, 2.0, -2.5),
(Troll, _) => (5.0, 0.0, -6.0),
(Dullahan, _) => (0.0, 0.0, -5.0),
(Werewolf, _) => (4.5, 0.5, -3.0),
(Werewolf, _) => (4.5, 1.0, -5.0),
(Occultlizardman, _) => (3.0, 0.5, -6.0),
(Mightylizardman, _) => (3.0, 0.5, -6.0),
(Slylizardman, _) => (3.0, 0.5, -6.0),
},
foot: match (body.species, body.body_type) {
(Ogre, Male) => (4.0, 2.5, 8.0),
(Ogre, Female) => (4.0, 0.5, 8.0),
(Cyclops, _) => (4.0, 0.5, 5.0),
(Wendigo, _) => (5.0, 0.5, 6.0),
(Troll, _) => (6.0, 0.5, 4.0),
(Dullahan, _) => (4.0, 2.5, 8.0),
(Werewolf, _) => (5.5, 6.5, 6.0),
(Occultlizardman, _) => (3.5, 4.0, 5.0),
(Mightylizardman, _) => (3.5, 4.0, 5.0),
(Slylizardman, _) => (3.5, 4.0, 5.0),
(Ogre, Male) => (4.0, 2.5, -14.0),
(Ogre, Female) => (4.0, 0.5, -14.0),
(Cyclops, _) => (4.0, 0.5, -17.0),
(Wendigo, _) => (5.0, 2.5, -17.0),
(Troll, _) => (6.0, 1.5, -13.0),
(Dullahan, _) => (4.0, 2.5, -14.0),
(Werewolf, _) => (4.0, 2.5, -8.5),
(Occultlizardman, _) => (3.5, 2.0, -12.0),
(Mightylizardman, _) => (3.5, 2.0, -12.0),
(Slylizardman, _) => (3.5, 2.0, -12.0),
},
beast: match (body.species, body.body_type) {
(Werewolf, _) => (true),
_ => (false),
},
beast_ori: match (body.species, body.body_type) {
(Werewolf, _) => (0.45),
_ => (0.0),
},
beast_head: match (body.species, body.body_type) {
(Werewolf, _) => (-3.0, 4.0),
_ => (0.0, 0.0),
},
beast_foot: match (body.species, body.body_type) {
(Werewolf, _) => (0.0, -11.0, 0.0),
_ => (0.0, 0.0, 0.0),
},
beast_hand: match (body.species, body.body_type) {
(Werewolf, _) => (0.0, 2.0, 1.0),
_ => (0.0, 0.0, 0.0),
},
}
}
}

View File

@ -2,12 +2,12 @@ use super::{
super::{vek::*, Animation},
BipedLargeSkeleton, SkeletonAttr,
};
use std::f32::consts::PI;
use std::{f32::consts::PI, ops::Mul};
pub struct RunAnimation;
impl Animation for RunAnimation {
type Dependency = (f32, f64);
type Dependency = (f32, Vec3<f32>, Vec3<f32>, f64, Vec3<f32>);
type Skeleton = BipedLargeSkeleton;
#[cfg(feature = "use-dyn-lib")]
@ -16,12 +16,14 @@ impl Animation for RunAnimation {
#[cfg_attr(feature = "be-dyn-lib", export_name = "biped_large_run")]
fn update_skeleton_inner(
skeleton: &Self::Skeleton,
(_velocity, _global_time): Self::Dependency,
(velocity, orientation, last_ori, global_time, avg_vel): Self::Dependency,
anim_time: f64,
_rate: &mut f32,
rate: &mut f32,
skeleton_attr: &SkeletonAttr,
) -> Self::Skeleton {
let mut next = (*skeleton).clone();
let speed = Vec2::<f32>::from(velocity).magnitude();
*rate = 1.0;
let lab = 0.55; //.65
let foothoril = (((1.0)
@ -69,49 +71,86 @@ impl Animation for RunAnimation {
.sqrt())
* ((anim_time as f32 * 16.0 * lab as f32 + PI * 0.5).sin());
let footvertl2 = (anim_time as f32 * 16.0 * lab as f32 + 0.5 * PI).sin();
let footvertr2 = (anim_time as f32 * 16.0 * lab as f32 + 1.5 * PI).sin();
let handhoril2 = (anim_time as f32 * 16.0 * lab as f32 + 0.5 * PI).sin();
let handhorir2 = (anim_time as f32 * 16.0 * lab as f32 + 1.5 * PI).sin();
//let short = (anim_time as f32 * lab as f32 * 16.0).sin();
let footrotl2 = (((5.0)
/ (2.5
+ (2.5)
* ((anim_time as f32 * 16.0 * lab as f32 + PI * 1.5).sin()).powf(2.0 as f32)))
.sqrt())
* ((anim_time as f32 * 16.0 * lab as f32 + PI * 1.5).sin());
//let shortalt = (anim_time as f32 * lab as f32 * 16.0 + PI / 2.0).sin();
let footrotr2 = (((5.0)
/ (2.5
+ (2.5)
* ((anim_time as f32 * 16.0 * lab as f32 + PI * 0.5).sin()).powf(2.0 as f32)))
.sqrt())
* ((anim_time as f32 * 16.0 * lab as f32 + PI * 0.5).sin());
let short = (anim_time as f32 * lab as f32 * 16.0).sin();
let lab = 0.65; //0.72
let amplitude = (speed / 21.0).max(0.25);
let amplitude2 = (speed * 1.4 / 21.0).powf(0.5).max(0.6);
let amplitude3 = (speed / 21.0).powf(0.5).max(0.35);
let speedmult = 1.0;
let canceler = (speed / 21.0).powf(0.5);
let shortalt = (anim_time as f32 * lab as f32 * 16.0 + PI / 2.0).sin();
let short = (anim_time as f32 * (16.0) * lab as f32 * speedmult + PI * -0.15).sin();
//
let shortalt =
(anim_time as f32 * (16.0) * lab as f32 * speedmult + PI * 3.0 / 8.0 + 0.7).sin();
let look = Vec2::new(
((global_time + anim_time) as f32 / 2.0)
.floor()
.mul(7331.0)
.sin()
* 0.5,
((global_time + anim_time) as f32 / 2.0)
.floor()
.mul(1337.0)
.sin()
* 0.25,
);
let speedadjust = if speed < 5.0 { 0.0 } else { speed / 21.0 };
let shift1 = speedadjust - PI / 2.0 - speedadjust * PI * 3.0 / 4.0;
let shift2 = speedadjust + PI / 2.0 + speedadjust * PI / 2.0;
let shift3 = speedadjust + PI / 4.0 - speedadjust * PI / 4.0;
let shift4 = speedadjust - PI * 3.0 / 4.0 + speedadjust * PI / 2.0;
//FL
let foot1a =
(anim_time as f32 * (16.0) * lab as f32 * speedmult + 0.0 + canceler * 0.05 + shift1)
.sin(); //1.5
let foot1b =
(anim_time as f32 * (16.0) * lab as f32 * speedmult + 1.1 + canceler * 0.05 + shift1)
.sin(); //1.9
//FR
let foot2a = (anim_time as f32 * (16.0) * lab as f32 * speedmult + shift2).sin(); //1.2
let foot2b = (anim_time as f32 * (16.0) * lab as f32 * speedmult + 1.1 + shift2).sin(); //1.6
//BL
let foot3a = (anim_time as f32 * (16.0) * lab as f32 * speedmult + shift3).sin(); //0.0
let foot3b = (anim_time as f32 * (16.0) * lab as f32 * speedmult + 1.57 + shift3).sin(); //0.4
//BR
let foot4a =
(anim_time as f32 * (16.0) * lab as f32 * speedmult + 0.0 + canceler * 0.05 + shift4)
.sin(); //0.3
let foot4b =
(anim_time as f32 * (16.0) * lab as f32 * speedmult + 1.57 + canceler * 0.05 + shift4)
.sin(); //0.7
//
let ori: Vec2<f32> = Vec2::from(orientation);
let last_ori = Vec2::from(last_ori);
let tilt = if ::vek::Vec2::new(ori, last_ori)
.map(|o| o.magnitude_squared())
.map(|m| m > 0.001 && m.is_finite())
.reduce_and()
&& ori.angle_between(last_ori).is_finite()
{
ori.angle_between(last_ori).min(0.2)
* last_ori.determine_side(Vec2::zero(), ori).signum()
} else {
0.0
} * 1.3;
let x_tilt = avg_vel.z.atan2(avg_vel.xy().magnitude());
if skeleton_attr.beast {
next.head.position = Vec3::new(0.0, skeleton_attr.head.0 + skeleton_attr.beast_head.0, skeleton_attr.head.1 + skeleton_attr.beast_head.1) * 1.02;
next.head.orientation = Quaternion::rotation_z(shortalt * -0.18) * Quaternion::rotation_x(skeleton_attr.beast_ori - short * 0.05);
next.head.scale = Vec3::one() * 1.02;
next.upper_torso.position = Vec3::new(
0.0,
skeleton_attr.upper_torso.0,
skeleton_attr.upper_torso.1 + short * -1.5,
);
next.upper_torso.orientation = Quaternion::rotation_x(-skeleton_attr.beast_ori) * Quaternion::rotation_z(shortalt * 0.18);
next.upper_torso.scale = Vec3::one();
next.lower_torso.position = Vec3::new(
0.0,
skeleton_attr.lower_torso.0,
skeleton_attr.lower_torso.1,
);
next.lower_torso.orientation = Quaternion::rotation_z(short * 0.15) * Quaternion::rotation_x(0.14);
next.lower_torso.scale = Vec3::one() * 1.02;
next.head.position = Vec3::new(0.0, skeleton_attr.head.0, 3.0 + skeleton_attr.head.1);
next.head.orientation = Quaternion::rotation_x(
look.y * 0.3 / ((canceler).max(0.5)) + amplitude * short * -0.18 + 0.6,
) * Quaternion::rotation_z(
look.x * 0.3 / ((canceler).max(0.5)) + tilt * -1.2,
) * Quaternion::rotation_y(tilt * 0.8);
next.head.scale = Vec3::one();
next.jaw.position = Vec3::new(0.0, skeleton_attr.jaw.0, skeleton_attr.jaw.1);
next.jaw.orientation = Quaternion::rotation_x(0.0);
@ -119,107 +158,158 @@ impl Animation for RunAnimation {
next.tail.position = Vec3::new(0.0, skeleton_attr.tail.0, skeleton_attr.tail.1);
next.tail.orientation =
Quaternion::rotation_x(shortalt * 0.1 + skeleton_attr.beast_ori);
Quaternion::rotation_x(canceler * 1.0 + amplitude * shortalt * 0.3)
* Quaternion::rotation_z(tilt * 1.5);
next.tail.scale = Vec3::one();
next.second.position = Vec3::new(0.0, 0.0, 0.0);
next.second.orientation =
Quaternion::rotation_x(PI) * Quaternion::rotation_y(0.0) * Quaternion::rotation_z(0.0);
next.second.scale = Vec3::one() * 0.0;
next.upper_torso.position = Vec3::new(
0.0,
skeleton_attr.upper_torso.0,
skeleton_attr.upper_torso.1, //xtilt
);
next.upper_torso.orientation = Quaternion::rotation_x(
(amplitude * (short * -0.0).max(-0.2)) + 0.0 * (canceler * 6.0).min(1.0), //x_tilt
) * Quaternion::rotation_y(tilt * 0.8)
* Quaternion::rotation_z(tilt * -1.5);
next.upper_torso.scale = Vec3::one();
next.control.position = Vec3::new(0.0, 0.0, 0.0);
next.control.orientation = Quaternion::rotation_z(0.0);
next.control.scale = Vec3::one();
next.lower_torso.position = Vec3::new(
0.0,
skeleton_attr.lower_torso.0,
skeleton_attr.lower_torso.1,
);
next.lower_torso.orientation =
Quaternion::rotation_x(amplitude * short * -0.25 + canceler * -0.4)
* Quaternion::rotation_z(tilt * 1.8)
* Quaternion::rotation_y(tilt * 0.6);
next.lower_torso.scale = Vec3::one();
next.main.position = Vec3::new(-5.0, -7.0, 7.0);
next.main.orientation =
Quaternion::rotation_x(PI) * Quaternion::rotation_y(0.6) * Quaternion::rotation_z(1.57);
next.main.scale = Vec3::one() * 1.02;
next.arm_control_l.position = Vec3::new(
0.0,
0.0 + amplitude3 * foot1b * -1.5 + canceler * -2.0,
0.0 + amplitude3 * foot1a * 1.5,
);
next.arm_control_l.orientation =
Quaternion::rotation_x(0.3 * canceler + amplitude3 * foot1a * 0.4)
* Quaternion::rotation_z(tilt * -0.5)
* Quaternion::rotation_y(tilt * 1.5);
next.arm_control_l.scale = Vec3::one() * 1.02;
next.arm_control_r.position = Vec3::new(
0.0,
0.0 + amplitude3 * foot2b * -1.5 + canceler * -2.0,
0.0 + amplitude3 * foot2a * 1.5,
);
next.arm_control_r.orientation =
Quaternion::rotation_x(0.3 * canceler + amplitude3 * foot2a * 0.4)
* Quaternion::rotation_z(tilt * -0.5)
* Quaternion::rotation_y(tilt * 1.5);
next.arm_control_r.scale = Vec3::one() * 1.02;
next.shoulder_l.position = Vec3::new(
-skeleton_attr.shoulder.0,
skeleton_attr.shoulder.1 + foothoril2 * -3.0,
skeleton_attr.shoulder.1,
skeleton_attr.shoulder.2,
);
next.shoulder_l.orientation = Quaternion::rotation_x(footrotl2 * -0.36 + skeleton_attr.beast_ori)
* Quaternion::rotation_y(0.1)
* Quaternion::rotation_z(footrotl2 * -0.3);
next.shoulder_l.scale = Vec3::one();
next.shoulder_l.scale = Vec3::one() * 1.02;
next.shoulder_r.position = Vec3::new(
skeleton_attr.shoulder.0,
skeleton_attr.shoulder.1 + foothorir2 * -3.0,
skeleton_attr.shoulder.1,
skeleton_attr.shoulder.2,
);
next.shoulder_r.orientation = Quaternion::rotation_x(footrotr2 * -0.36 + skeleton_attr.beast_ori)
* Quaternion::rotation_y(-0.1)
* Quaternion::rotation_z(footrotr2 * -0.3);
next.shoulder_r.scale = Vec3::one();
next.shoulder_r.scale = Vec3::one() * 1.02;
next.hand_l.position = Vec3::new(
-skeleton_attr.hand.0,
skeleton_attr.hand.1 + foothoril2 * -4.0 + skeleton_attr.beast_hand.1,
skeleton_attr.hand.2 + foothoril2 * 0.5 + skeleton_attr.beast_hand.2,
skeleton_attr.hand.1 + foot1a * 1.0,
skeleton_attr.hand.2 + (foot1a * -3.0).max(1.0) * amplitude2,
);
next.hand_l.orientation = Quaternion::rotation_x(0.15 + (handhorir2 * -1.2).max(-0.3) + skeleton_attr.beast_ori)
* Quaternion::rotation_y(handhorir2 * 0.1);
next.hand_l.scale = Vec3::one() * 1.02;
next.hand_l.orientation =
Quaternion::rotation_x((amplitude2 * foot1b * 0.9 + canceler * 0.9).max(0.5))
* Quaternion::rotation_y(tilt * -1.0);
next.hand_l.scale = Vec3::one() * 0.96;
next.hand_r.position = Vec3::new(
skeleton_attr.hand.0,
skeleton_attr.hand.1 + foothorir2 * -4.0 + skeleton_attr.beast_hand.1,
skeleton_attr.hand.2 + foothorir2 * 0.5 + skeleton_attr.beast_hand.2,
skeleton_attr.hand.1 + foot2a * 1.0,
skeleton_attr.hand.2 + (foot2a * -3.0).max(1.0) * amplitude2,
);
next.hand_r.orientation = Quaternion::rotation_x(0.15 + (handhoril2 * -1.2).max(-0.3) + skeleton_attr.beast_ori)
* Quaternion::rotation_y(handhoril2 * -0.1);
next.hand_r.scale = Vec3::one() * 1.02;
next.hand_r.orientation =
Quaternion::rotation_x((amplitude2 * foot2b * 0.9 + canceler * 0.7).max(0.5))
* Quaternion::rotation_y(tilt * -1.0);
next.hand_r.scale = Vec3::one() * 0.96;
next.leg_control_l.position = Vec3::new(
0.0,
0.0 + amplitude3 * foot3b * -1.0 + canceler * -2.0,
0.0 + amplitude3 * foot3a * -2.5,
);
next.leg_control_l.orientation =
Quaternion::rotation_x(canceler * -0.4 + amplitude3 * foot3b * 0.3)
* Quaternion::rotation_y(tilt * 1.5)
* Quaternion::rotation_z(tilt * -1.5);
next.leg_control_l.scale = Vec3::one() * 1.02;
next.leg_control_r.position = Vec3::new(
0.0,
0.0 + amplitude3 * foot4b * -1.0 + canceler * -2.0,
0.0 + amplitude3 * foot4a * -2.5,
);
next.leg_control_r.orientation =
Quaternion::rotation_x(canceler * -0.4 + amplitude3 * foot4b * 0.3)
* Quaternion::rotation_y(tilt * 1.5)
* Quaternion::rotation_z(tilt * -1.5);
next.leg_control_r.scale = Vec3::one() * 1.02;
next.leg_l.position = Vec3::new(
-skeleton_attr.leg.0,
skeleton_attr.leg.1,
skeleton_attr.leg.2,
) * 0.98;
next.leg_l.orientation =
Quaternion::rotation_z(short * 0.18) * Quaternion::rotation_x(foothoril2 * 0.6 - skeleton_attr.beast_ori);
next.leg_l.scale = Vec3::one() * 0.98;
);
next.leg_l.scale = Vec3::one() * 1.0;
next.leg_r.position = Vec3::new(
skeleton_attr.leg.0,
skeleton_attr.leg.1,
skeleton_attr.leg.2,
) * 0.98;
next.leg_r.orientation =
Quaternion::rotation_z(short * 0.18) * Quaternion::rotation_x(foothorir2 * 0.6 - skeleton_attr.beast_ori);
next.leg_r.scale = Vec3::one() * 0.98;
);
next.leg_r.scale = Vec3::one() * 1.0;
next.foot_l.position = Vec3::new(
-skeleton_attr.foot.0,
4.0 + skeleton_attr.foot.1 + foothoril2 * 4.0 + skeleton_attr.beast_foot.1,
skeleton_attr.foot.2 + ((footvertl2 * 6.0).max(0.0)),
) / 8.0;
next.foot_l.orientation =
Quaternion::rotation_x(-0.5 + footrotl2 * 0.85);
next.foot_l.scale = Vec3::one() / 8.0;
skeleton_attr.foot.1 + foot3a * 2.0,
skeleton_attr.foot.2 + (foot3b * 4.0 * amplitude2).max(-1.0),
);
next.foot_l.orientation = Quaternion::rotation_x(amplitude2 * foot3b * 0.45 + 0.5)
* Quaternion::rotation_y(tilt * -1.0);
next.foot_l.scale = Vec3::one() * 0.96;
next.foot_r.position = Vec3::new(
skeleton_attr.foot.0,
4.0 + skeleton_attr.foot.1 + foothorir2 * 4.0 + skeleton_attr.beast_foot.1,
skeleton_attr.foot.2 + ((footvertr2 * 6.0).max(0.0)),
) / 8.0;
next.foot_r.orientation =
Quaternion::rotation_x(-0.5 + footrotr2 * 0.85);
next.foot_r.scale = Vec3::one() / 8.0;
skeleton_attr.foot.1 + foot4a * 2.0,
skeleton_attr.foot.2 + (foot4b * 4.0 * amplitude2).max(-1.0),
);
next.foot_r.orientation = Quaternion::rotation_x(amplitude2 * foot4b * 0.45 + 0.5)
* Quaternion::rotation_y(tilt * -1.0);
next.foot_r.scale = Vec3::one() * 0.96;
next.torso.position = Vec3::new(0.0, 0.0, 0.0) / 8.0;
next.torso.orientation = Quaternion::rotation_z(0.0) * Quaternion::rotation_x(-0.25);
next.torso.position = Vec3::new(
0.0,
0.0 + (short * 0.75).max(-2.0),
canceler * 2.0 + (short * 0.75).max(-2.0),
) / 8.0;
next.torso.orientation =
Quaternion::rotation_x(x_tilt + amplitude * short * 0.1 + canceler * -0.7);
next.torso.scale = Vec3::one() / 8.0;
next.hold.scale = Vec3::one() * 0.0;
} else {
next.head.position = Vec3::new(0.0, skeleton_attr.head.0, skeleton_attr.head.1) * 1.02;
next.head.orientation = Quaternion::rotation_z(short * -0.18) * Quaternion::rotation_x(-0.05);
next.head.orientation =
Quaternion::rotation_z(short * -0.18) * Quaternion::rotation_x(-0.05);
next.head.scale = Vec3::one() * 1.02;
next.upper_torso.position = Vec3::new(
0.0,
skeleton_attr.upper_torso.0,
@ -227,38 +317,40 @@ impl Animation for RunAnimation {
);
next.upper_torso.orientation = Quaternion::rotation_z(short * 0.18);
next.upper_torso.scale = Vec3::one();
next.lower_torso.position = Vec3::new(
0.0,
skeleton_attr.lower_torso.0,
skeleton_attr.lower_torso.1,
);
next.lower_torso.orientation = Quaternion::rotation_z(short * 0.15) * Quaternion::rotation_x(0.14);
next.lower_torso.orientation =
Quaternion::rotation_z(short * 0.15) * Quaternion::rotation_x(0.14);
next.lower_torso.scale = Vec3::one() * 1.02;
next.jaw.position = Vec3::new(0.0, skeleton_attr.jaw.0, skeleton_attr.jaw.1);
next.jaw.orientation = Quaternion::rotation_x(0.0);
next.jaw.scale = Vec3::one() * 1.02;
next.tail.position = Vec3::new(0.0, skeleton_attr.tail.0, skeleton_attr.tail.1);
next.tail.orientation =
Quaternion::rotation_x(shortalt * 0.3);
next.tail.orientation = Quaternion::rotation_x(shortalt * 0.3);
next.tail.scale = Vec3::one();
next.second.position = Vec3::new(0.0, 0.0, 0.0);
next.second.orientation =
Quaternion::rotation_x(PI) * Quaternion::rotation_y(0.0) * Quaternion::rotation_z(0.0);
next.second.orientation = Quaternion::rotation_x(PI)
* Quaternion::rotation_y(0.0)
* Quaternion::rotation_z(0.0);
next.second.scale = Vec3::one() * 0.0;
next.control.position = Vec3::new(0.0, 0.0, 0.0);
next.control.orientation = Quaternion::rotation_z(0.0);
next.control.scale = Vec3::one();
next.main.position = Vec3::new(-5.0, -7.0, 7.0);
next.main.orientation =
Quaternion::rotation_x(PI) * Quaternion::rotation_y(0.6) * Quaternion::rotation_z(1.57);
next.main.orientation = Quaternion::rotation_x(PI)
* Quaternion::rotation_y(0.6)
* Quaternion::rotation_z(1.57);
next.main.scale = Vec3::one() * 1.02;
next.shoulder_l.position = Vec3::new(
-skeleton_attr.shoulder.0,
skeleton_attr.shoulder.1 + foothoril * -3.0,
@ -268,7 +360,7 @@ impl Animation for RunAnimation {
* Quaternion::rotation_y(0.1)
* Quaternion::rotation_z(footrotl * 0.3);
next.shoulder_l.scale = Vec3::one();
next.shoulder_r.position = Vec3::new(
skeleton_attr.shoulder.0,
skeleton_attr.shoulder.1 + foothorir * -3.0,
@ -278,7 +370,7 @@ impl Animation for RunAnimation {
* Quaternion::rotation_y(-0.1)
* Quaternion::rotation_z(footrotr * -0.3);
next.shoulder_r.scale = Vec3::one();
next.hand_l.position = Vec3::new(
-1.0 + -skeleton_attr.hand.0,
skeleton_attr.hand.1 + foothoril * -4.0,
@ -287,7 +379,7 @@ impl Animation for RunAnimation {
next.hand_l.orientation = Quaternion::rotation_x(0.15 + (handhoril * -1.2).max(-0.3))
* Quaternion::rotation_y(handhoril * -0.1);
next.hand_l.scale = Vec3::one() * 1.02;
next.hand_r.position = Vec3::new(
1.0 + skeleton_attr.hand.0,
skeleton_attr.hand.1 + foothorir * -4.0,
@ -296,7 +388,7 @@ impl Animation for RunAnimation {
next.hand_r.orientation = Quaternion::rotation_x(0.15 + (handhorir * -1.2).max(-0.3))
* Quaternion::rotation_y(handhorir * 0.1);
next.hand_r.scale = Vec3::one() * 1.02;
next.leg_l.position = Vec3::new(
-skeleton_attr.leg.0,
skeleton_attr.leg.1,
@ -305,39 +397,44 @@ impl Animation for RunAnimation {
next.leg_l.orientation =
Quaternion::rotation_z(short * 0.18) * Quaternion::rotation_x(foothoril * 0.3);
next.leg_l.scale = Vec3::one() * 0.98;
next.leg_r.position = Vec3::new(
skeleton_attr.leg.0,
skeleton_attr.leg.1,
skeleton_attr.leg.2,
) * 0.98;
next.leg_r.orientation =
Quaternion::rotation_z(short * 0.18) * Quaternion::rotation_x(foothorir * 0.3);
next.leg_r.scale = Vec3::one() * 0.98;
next.foot_l.position = Vec3::new(
-skeleton_attr.foot.0,
4.0 + skeleton_attr.foot.1 + foothoril * 8.5,
skeleton_attr.foot.1 + foothoril * 8.5,
skeleton_attr.foot.2 + ((footvertl * 6.5).max(0.0)),
) / 8.0;
);
next.foot_l.orientation =
Quaternion::rotation_x(-0.5 + footrotl * 0.85) * Quaternion::rotation_y(0.0);
next.foot_l.scale = Vec3::one() / 8.0;
next.foot_l.scale = Vec3::one();
next.foot_r.position = Vec3::new(
skeleton_attr.foot.0,
4.0 + skeleton_attr.foot.1 + foothorir * 8.5,
skeleton_attr.foot.1 + foothorir * 8.5,
skeleton_attr.foot.2 + ((footvertr * 6.5).max(0.0)),
) / 8.0;
);
next.foot_r.orientation =
Quaternion::rotation_x(-0.5 + footrotr * 0.85) * Quaternion::rotation_y(0.0);
next.foot_r.scale = Vec3::one() / 8.0;
next.foot_r.scale = Vec3::one();
next.torso.position = Vec3::new(0.0, 0.0, 0.0) / 8.0;
next.torso.orientation = Quaternion::rotation_z(0.0) * Quaternion::rotation_x(-0.25);
next.torso.scale = Vec3::one() / 8.0;
next.leg_control_l.scale = Vec3::one() * 1.0;
next.leg_control_r.scale = Vec3::one() * 1.0;
next.arm_control_l.scale = Vec3::one() * 1.0;
next.arm_control_r.scale = Vec3::one() * 1.0;
next.hold.scale = Vec3::one() * 0.0;
}
next

View File

@ -32,7 +32,7 @@ impl Animation for ShootAnimation {
let slow = (anim_time as f32 * 3.5 + PI).sin();
let exp = ((anim_time as f32).powf(0.3 as f32)).min(1.2);
let tailmove = Vec2::new(
((global_time + anim_time) as f32 / 2.0)
.floor()
@ -129,7 +129,7 @@ impl Animation for ShootAnimation {
);
next.jaw.orientation = Quaternion::rotation_x(slow * 0.05);
next.jaw.scale = Vec3::one() * 0.98;
next.tail.position = Vec3::new(0.0, skeleton_attr.tail.0, skeleton_attr.tail.1);
next.tail.orientation =
Quaternion::rotation_z(0.0 + slow * 0.2 + tailmove.x) * Quaternion::rotation_x(0.0);
@ -222,7 +222,7 @@ impl Animation for ShootAnimation {
);
next.jaw.orientation = Quaternion::rotation_x(slow * 0.05);
next.jaw.scale = Vec3::one() * 1.02;
next.tail.position = Vec3::new(0.0, skeleton_attr.tail.0, skeleton_attr.tail.1);
next.tail.orientation =
Quaternion::rotation_z(0.0 + slow * 0.2 + tailmove.x) * Quaternion::rotation_x(0.0);
@ -260,17 +260,17 @@ impl Animation for ShootAnimation {
next.leg_l.orientation =
Quaternion::rotation_z(short * 0.18) * Quaternion::rotation_x(foothoril * 0.3);
next.leg_l.scale = Vec3::one() * 0.98;
next.leg_r.position = Vec3::new(
skeleton_attr.leg.0,
skeleton_attr.leg.1,
skeleton_attr.leg.2,
) * 0.98;
next.leg_r.orientation =
Quaternion::rotation_z(short * 0.18) * Quaternion::rotation_x(foothorir * 0.3);
next.leg_r.scale = Vec3::one() * 0.98;
next.foot_l.position = Vec3::new(
-skeleton_attr.foot.0,
4.0 + skeleton_attr.foot.1 + foothoril * 8.5,
@ -279,7 +279,7 @@ impl Animation for ShootAnimation {
next.foot_l.orientation =
Quaternion::rotation_x(-0.5 + footrotl * 0.85) * Quaternion::rotation_y(0.0);
next.foot_l.scale = Vec3::one() / 8.0;
next.foot_r.position = Vec3::new(
skeleton_attr.foot.0,
4.0 + skeleton_attr.foot.1 + foothorir * 8.5,
@ -288,7 +288,6 @@ impl Animation for ShootAnimation {
next.foot_r.orientation =
Quaternion::rotation_x(-0.5 + footrotr * 0.85) * Quaternion::rotation_y(0.0);
next.foot_r.scale = Vec3::one() / 8.0;
}
match active_tool_kind {
Some(ToolKind::Bow(_)) => {
@ -325,11 +324,7 @@ impl Animation for ShootAnimation {
* Quaternion::rotation_z(footrotr * -0.05);
next.shoulder_r.scale = Vec3::one();
next.jaw.position = Vec3::new(
0.0,
skeleton_attr.jaw.0,
skeleton_attr.jaw.1,
);
next.jaw.position = Vec3::new(0.0, skeleton_attr.jaw.0, skeleton_attr.jaw.1);
next.jaw.orientation = Quaternion::rotation_x(-0.2);
next.main.position = Vec3::new(7.0, 5.0, -13.0);
@ -354,26 +349,24 @@ impl Animation for ShootAnimation {
Quaternion::rotation_x(1.57) * Quaternion::rotation_y(0.2);
next.hand_r.scale = Vec3::one() * 1.02;
next.jaw.position = Vec3::new(
0.0,
skeleton_attr.jaw.0,
skeleton_attr.jaw.1,
);
next.jaw.position = Vec3::new(0.0, skeleton_attr.jaw.0, skeleton_attr.jaw.1);
next.shoulder_l.position = Vec3::new(
-skeleton_attr.shoulder.0,
skeleton_attr.shoulder.1,
skeleton_attr.shoulder.2,
);
next.shoulder_l.orientation = Quaternion::rotation_z(0.0) * Quaternion::rotation_x(2.0);
next.shoulder_l.orientation =
Quaternion::rotation_z(0.0) * Quaternion::rotation_x(2.0);
next.shoulder_l.scale = Vec3::one();
next.shoulder_r.position = Vec3::new(
skeleton_attr.shoulder.0,
skeleton_attr.shoulder.1,
skeleton_attr.shoulder.2,
);
next.shoulder_r.orientation = Quaternion::rotation_z(0.4) * Quaternion::rotation_x(2.0);
next.shoulder_r.orientation =
Quaternion::rotation_z(0.4) * Quaternion::rotation_x(2.0);
next.shoulder_r.scale = Vec3::one();
next.jaw.orientation = Quaternion::rotation_x(-0.2);
@ -394,4 +387,4 @@ impl Animation for ShootAnimation {
next
}
}
}

View File

@ -153,7 +153,11 @@ impl Animation for SpinAnimation {
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.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);
@ -184,7 +188,6 @@ impl Animation for SpinAnimation {
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()),

View File

@ -124,8 +124,11 @@ impl Animation for SpinMeleeAnimation {
* Quaternion::rotation_z(-PI / 2.0);
next.torso.orientation = Quaternion::rotation_z(movement * PI * 2.0);
next.upper_torso.position =
Vec3::new(0.0, skeleton_attr.upper_torso.0, skeleton_attr.upper_torso.1);
next.upper_torso.position = Vec3::new(
0.0,
skeleton_attr.upper_torso.0,
skeleton_attr.upper_torso.1,
);
next.upper_torso.orientation = Quaternion::rotation_y(0.3);
next.head.position =
Vec3::new(0.0, skeleton_attr.head.0 - 2.0, skeleton_attr.head.1);
@ -140,7 +143,8 @@ impl Animation for SpinMeleeAnimation {
Quaternion::rotation_x(-PI / 2.0 + movement * PI / 2.0)
* Quaternion::rotation_z(-PI / 2.0 + movement * PI / 2.0);
next.head.orientation = Quaternion::rotation_x(-0.15 + movement * 0.15);
next.upper_torso.orientation = Quaternion::rotation_y(0.3 + movement * -0.3)
next.upper_torso.orientation =
Quaternion::rotation_y(0.3 + movement * -0.3)
},
_ => {},
}

View File

@ -44,7 +44,7 @@ impl Animation for WieldAnimation {
let slow = (anim_time as f32 * 3.5 + PI).sin();
let u_slow = (anim_time as f32 * 1.0 + PI).sin();
let u_slowalt = (anim_time as f32 * 3.0 + PI).cos();
let tailmove = Vec2::new(
((global_time + anim_time) as f32 / 2.0)
.floor()
@ -122,7 +122,7 @@ impl Animation for WieldAnimation {
next.hand_r.scale = Vec3::one() * 1.02;
next.hand_r.orientation = Quaternion::rotation_x(0.57) * Quaternion::rotation_z(1.57);
next.hand_r.scale = Vec3::one() * 1.02;
next.control.position = Vec3::new(7.0, 9.0, -10.0);
next.control.orientation = Quaternion::rotation_x(test * 0.02)
* Quaternion::rotation_y(test * 0.02)
@ -165,7 +165,7 @@ impl Animation for WieldAnimation {
);
next.jaw.orientation = Quaternion::rotation_x(slow * 0.05);
next.jaw.scale = Vec3::one() * 0.98;
next.tail.position = Vec3::new(0.0, skeleton_attr.tail.0, skeleton_attr.tail.1);
next.tail.orientation =
Quaternion::rotation_z(0.0 + slow * 0.2 + tailmove.x) * Quaternion::rotation_x(0.0);
@ -229,7 +229,7 @@ impl Animation for WieldAnimation {
);
next.jaw.orientation = Quaternion::rotation_x(slow * 0.05);
next.jaw.scale = Vec3::one() * 0.98;
next.tail.position = Vec3::new(0.0, skeleton_attr.tail.0, skeleton_attr.tail.1);
next.tail.orientation =
Quaternion::rotation_z(0.0 + slow * 0.2 + tailmove.x) * Quaternion::rotation_x(0.0);
@ -271,17 +271,17 @@ impl Animation for WieldAnimation {
-skeleton_attr.foot.0,
skeleton_attr.foot.1,
skeleton_attr.foot.2,
) / 8.0;
);
next.foot_l.orientation = Quaternion::rotation_z(0.0);
next.foot_l.scale = Vec3::one() / 8.0;
next.foot_l.scale = Vec3::one();
next.foot_r.position = Vec3::new(
skeleton_attr.foot.0,
skeleton_attr.foot.1,
skeleton_attr.foot.2,
) / 8.0;
);
next.foot_r.orientation = Quaternion::rotation_z(0.0);
next.foot_r.scale = Vec3::one() / 8.0;
next.foot_r.scale = Vec3::one();
next.torso.position = Vec3::new(0.0, 0.0, 0.0) / 8.0;
next.torso.orientation = Quaternion::rotation_z(test * 0.0);
@ -356,8 +356,11 @@ impl Animation for WieldAnimation {
next.upper_torso.orientation = Quaternion::rotation_x(-0.35)
* Quaternion::rotation_y(u_slowalt * 0.04)
* Quaternion::rotation_z(0.15);
next.lower_torso.position =
Vec3::new(0.0, 1.0 + skeleton_attr.lower_torso.0, skeleton_attr.lower_torso.1);
next.lower_torso.position = Vec3::new(
0.0,
1.0 + skeleton_attr.lower_torso.0,
skeleton_attr.lower_torso.1,
);
next.lower_torso.orientation =
Quaternion::rotation_x(0.15) * Quaternion::rotation_z(0.25);
next.control.orientation = Quaternion::rotation_x(1.8)
@ -420,17 +423,19 @@ impl Animation for WieldAnimation {
skeleton_attr.hand.1 - 7.0,
skeleton_attr.hand.2 + 10.0,
);
next.hand_l.orientation = Quaternion::rotation_x(0.57) * Quaternion::rotation_z(1.57);
next.hand_l.orientation =
Quaternion::rotation_x(0.57) * Quaternion::rotation_z(1.57);
next.hand_l.scale = Vec3::one() * 1.02;
next.hand_r.position = Vec3::new(
skeleton_attr.hand.0 - 7.0,
skeleton_attr.hand.1 - 7.0,
skeleton_attr.hand.2 + 10.0,
);
next.hand_r.orientation = Quaternion::rotation_x(0.57) * Quaternion::rotation_z(1.57);
next.hand_r.orientation =
Quaternion::rotation_x(0.57) * Quaternion::rotation_z(1.57);
next.hand_r.scale = Vec3::one() * 1.02;
next.control.position = Vec3::new(7.0, 9.0, -10.0);
next.control.orientation = Quaternion::rotation_x(test * 0.02)
* Quaternion::rotation_y(test * 0.02)
@ -458,15 +463,17 @@ impl Animation for WieldAnimation {
skeleton_attr.shoulder.1,
skeleton_attr.shoulder.2,
);
next.shoulder_l.orientation = Quaternion::rotation_z(0.0) * Quaternion::rotation_x(0.0);
next.shoulder_l.orientation =
Quaternion::rotation_z(0.0) * Quaternion::rotation_x(0.0);
next.shoulder_l.scale = Vec3::one();
next.shoulder_r.position = Vec3::new(
skeleton_attr.shoulder.0,
skeleton_attr.shoulder.1,
skeleton_attr.shoulder.2,
);
next.shoulder_r.orientation = Quaternion::rotation_z(0.4) * Quaternion::rotation_x(1.0);
next.shoulder_r.orientation =
Quaternion::rotation_z(0.4) * Quaternion::rotation_x(1.0);
next.shoulder_r.scale = Vec3::one();
next.main.position = Vec3::new(10.0, 12.5, 13.2);
@ -483,4 +490,4 @@ impl Animation for WieldAnimation {
next
}
}
}

View File

@ -57,7 +57,6 @@ impl Animation for IdleAnimation {
next.jaw.orientation = Quaternion::rotation_x(-0.1 + breathe * 0.1);
next.jaw.scale = Vec3::one() * 1.02;
next.upper_torso.position = Vec3::new(
0.0,
skeleton_attr.upper_torso.0,

View File

@ -73,11 +73,7 @@ impl Animation for RunAnimation {
next.head.orientation = Quaternion::rotation_z(short * -0.3) * Quaternion::rotation_x(-0.2);
next.head.scale = Vec3::one() * 1.02;
next.jaw.position = Vec3::new(
0.0,
skeleton_attr.jaw.0,
skeleton_attr.jaw.1,
) * 1.02;
next.jaw.position = Vec3::new(0.0, skeleton_attr.jaw.0, skeleton_attr.jaw.1) * 1.02;
next.jaw.scale = Vec3::one() * 1.02;
next.upper_torso.position = Vec3::new(

View File

@ -75,8 +75,11 @@ impl Animation for IdleAnimation {
next.tail_front.orientation = Quaternion::rotation_x(0.1);
next.tail_front.scale = Vec3::one();
next.tail_back.position =
Vec3::new(0.0, skeleton_attr.tail_back.0, skeleton_attr.tail_back.1 - 0.5);
next.tail_back.position = Vec3::new(
0.0,
skeleton_attr.tail_back.0,
skeleton_attr.tail_back.1 - 0.5,
);
next.tail_back.orientation = Quaternion::rotation_x(0.1);
next.tail_back.scale = Vec3::one();

View File

@ -2225,7 +2225,7 @@ impl FigureMgr {
// Running
(true, true, false) => anim::biped_large::RunAnimation::update_skeleton(
&BipedLargeSkeleton::default(),
(vel.0.magnitude(), time),
(vel.0.magnitude(), ori, state.last_ori, time, state.avg_vel),
state.state_time,
&mut state_animation_rate,
skeleton_attr,