Better bipedlarge weild, charge and shoot anims

This commit is contained in:
unknown 2020-09-27 18:03:00 +02:00 committed by Robin Gilh
parent d2f91bc3a0
commit 94cbe3faf4
6 changed files with 856 additions and 144 deletions

View File

@ -505,7 +505,7 @@
central: ("armor.empty"),
),
main: (
offset: (-1.5, -9.0, -10.0),
offset: (-2.5, -4.0, -7.0),
central: ("weapon.bow.longbow_lizardman"),
)
),
@ -535,7 +535,7 @@
central: ("armor.empty"),
),
main: (
offset: (-1.5, -9.0, -10.0),
offset: (-2.5, -4.0, -7.0),
central: ("weapon.bow.longbow_lizardman"),
)
),

View File

@ -0,0 +1,351 @@
use super::{
super::{vek::*, Animation},
BipedLargeSkeleton, SkeletonAttr,
};
use common::comp::item::{Hands, ToolKind};
use std::{f32::consts::PI, ops::Mul};
pub struct ChargeAnimation;
impl Animation for ChargeAnimation {
type Dependency = (
Option<ToolKind>,
Option<ToolKind>,
f32,
Vec3<f32>,
Vec3<f32>,
f64,
);
type Skeleton = BipedLargeSkeleton;
#[cfg(feature = "use-dyn-lib")]
const UPDATE_FN: &'static [u8] = b"biped_large_charge\0";
#[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,
anim_time: f64,
_rate: &mut f32,
skeleton_attr: &SkeletonAttr,
) -> Self::Skeleton {
let mut next = (*skeleton).clone();
let lab = 0.55;
let breathe = (anim_time as f32 + 1.5 * PI).sin();
let test = (anim_time as f32 + 36.0 * PI).sin();
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()
.mul(7331.0)
.sin()
* 0.25,
((global_time + anim_time) as f32 / 2.0)
.floor()
.mul(1337.0)
.sin()
* 0.125,
);
let look = Vec2::new(
((global_time + anim_time) as f32 / 8.0)
.floor()
.mul(7331.0)
.sin()
* 0.5,
((global_time + anim_time) as f32 / 8.0)
.floor()
.mul(1337.0)
.sin()
* 0.25,
);
let foothoril = (((1.0)
/ (0.4
+ (0.6)
* ((anim_time as f32 * 16.0 * lab as f32 + PI * 1.4).sin()).powf(2.0 as f32)))
.sqrt())
* ((anim_time as f32 * 16.0 * lab as f32 + PI * 1.4).sin());
let foothorir = (((1.0)
/ (0.4
+ (0.6)
* ((anim_time as f32 * 16.0 * lab as f32 + PI * 0.4).sin()).powf(2.0 as f32)))
.sqrt())
* ((anim_time as f32 * 16.0 * lab as f32 + PI * 0.4).sin());
let footvertl = (anim_time as f32 * 16.0 * lab as f32).sin();
let footvertr = (anim_time as f32 * 16.0 * lab as f32 + PI).sin();
let footrotl = (((5.0)
/ (2.5
+ (2.5)
* ((anim_time as f32 * 16.0 * lab as f32 + PI * 1.4).sin()).powf(2.0 as f32)))
.sqrt())
* ((anim_time as f32 * 16.0 * lab as f32 + PI * 1.4).sin());
let footrotr = (((5.0)
/ (1.0
+ (4.0)
* ((anim_time as f32 * 16.0 * lab as f32 + PI * 0.4).sin()).powf(2.0 as f32)))
.sqrt())
* ((anim_time as f32 * 16.0 * lab as f32 + PI * 0.4).sin());
let quick = (((5.0)
/ (3.5 + 1.5 * ((anim_time as f32 * lab as f32 * 8.0).sin()).powf(2.0 as f32)))
.sqrt())
* ((anim_time as f32 * lab as f32 * 8.0).sin());
let quicka = (((5.0)
/ (3.5
+ 1.5
* ((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)
/ (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());
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();
let stop = ((anim_time as f32).powf(0.3 as f32)).min(1.2);
let stopa = ((anim_time as f32).powf(0.9 as f32)).min(5.0);
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;
next.head.position = Vec3::new(
stop * -2.0,
-3.5 + stop * 2.5 + skeleton_attr.head.0,
skeleton_attr.head.1,
);
next.head.orientation =
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.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.orientation = Quaternion::rotation_z(stop * -0.7 + tilt * 4.0);
if velocity < 0.5 {
next.jaw.position = Vec3::new(
0.0,
skeleton_attr.jaw.0 - slower * 0.12,
skeleton_attr.jaw.1 + slow * 0.2,
);
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);
next.tail.scale = Vec3::one();
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(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.0) * Quaternion::rotation_x(0.0);
next.shoulder_r.scale = Vec3::one();
next.leg_l.position = Vec3::new(
-skeleton_attr.leg.0,
skeleton_attr.leg.1,
skeleton_attr.leg.2 + breathe * 0.2,
) * 1.02;
next.leg_l.orientation = Quaternion::rotation_z(0.0);
next.leg_l.scale = Vec3::one() * 1.02;
next.leg_r.position = Vec3::new(
skeleton_attr.leg.0,
skeleton_attr.leg.1,
skeleton_attr.leg.2 + breathe * 0.2,
) * 1.02;
next.leg_r.orientation = Quaternion::rotation_z(0.0);
next.leg_r.scale = Vec3::one() * 1.02;
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);
next.foot_l.scale = Vec3::one() / 8.0;
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.torso.position = Vec3::new(0.0, 0.0, 0.0) / 8.0;
next.torso.orientation = Quaternion::rotation_z(test * 0.0);
next.torso.scale = Vec3::one() / 8.0;
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)
* Quaternion::rotation_z(test * 0.02);
next.control.scale = Vec3::one();
} else {
next.jaw.position = Vec3::new(
0.0,
skeleton_attr.jaw.0 - slower * 0.12,
skeleton_attr.jaw.1 + slow * 0.2,
);
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);
next.tail.scale = Vec3::one();
next.shoulder_l.position = Vec3::new(
-skeleton_attr.shoulder.0,
skeleton_attr.shoulder.1 + foothoril * -1.0,
skeleton_attr.shoulder.2,
);
next.shoulder_l.orientation = Quaternion::rotation_x(0.5 + footrotl * -0.16)
* 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,
skeleton_attr.shoulder.2,
);
next.shoulder_r.orientation = Quaternion::rotation_x(0.5 + footrotr * -0.16)
* Quaternion::rotation_y(-0.1)
* Quaternion::rotation_z(footrotr * -0.1);
next.shoulder_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_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(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.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_r.position = Vec3::new(
skeleton_attr.foot.0,
4.0 + 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;
}
match active_tool_kind {
Some(ToolKind::Bow(_)) => {
next.hand_l.position = Vec3::new(1.0, -2.0 + stop * -1.0, 0.0);
next.hand_l.orientation = Quaternion::rotation_x(1.20)
* Quaternion::rotation_y(-0.6)
* Quaternion::rotation_z(-0.3);
next.hand_l.scale = Vec3::one() * 1.05;
next.hand_r.position = Vec3::new(4.9, 1.0, -5.0);
next.hand_r.orientation = Quaternion::rotation_x(1.20)
* Quaternion::rotation_y(-0.6)
* Quaternion::rotation_z(-0.3);
next.hand_r.scale = Vec3::one() * 1.05;
next.main.position = Vec3::new(8.0, 2.0, -14.0);
next.main.orientation = Quaternion::rotation_x(-0.3)
* Quaternion::rotation_y(0.3)
* Quaternion::rotation_z(-0.6);
next.hold.position = Vec3::new(0.4, -0.3, -5.8);
next.hold.orientation = Quaternion::rotation_x(-1.6)
* Quaternion::rotation_y(-0.1)
* Quaternion::rotation_z(0.0);
next.hold.scale = Vec3::one() * 1.0;
next.control.position = Vec3::new(-10.0 + stop * 13.0, 6.0 + stop * 4.0, 4.0);
next.control.orientation = Quaternion::rotation_x(0.0)
* Quaternion::rotation_y(stop * -0.4)
* Quaternion::rotation_z(stop * -0.6);
next.control.scale = Vec3::one();
},
Some(ToolKind::Staff(_)) => {
next.hand_l.position = Vec3::new(11.0, 5.0, -4.0);
next.hand_l.orientation = Quaternion::rotation_x(1.27);
next.hand_l.scale = Vec3::one() * 1.05;
next.hand_r.position = Vec3::new(12.0, 5.5, 2.0);
next.hand_r.orientation =
Quaternion::rotation_x(1.57) * Quaternion::rotation_y(0.2);
next.hand_r.scale = Vec3::one() * 1.05;
next.main.position = Vec3::new(8.0, 8.5, 13.2);
next.main.orientation = Quaternion::rotation_x(0.0)
* Quaternion::rotation_y(3.14)
* Quaternion::rotation_z(0.0);
next.control.position = Vec3::new(
-7.0 + quick * 3.5 * (1.0 / (stopa + 0.1)),
6.0 + quicka * 3.5 * (1.0 / (stopa + 0.1)),
6.0 - stop * 3.0,
);
next.control.orientation =
Quaternion::rotation_x(stop * -0.2) * Quaternion::rotation_z(stop * 0.2);
next.control.scale = Vec3::one();
},
_ => {},
}
next
}
}

View File

@ -3,11 +3,13 @@ pub mod idle;
pub mod jump;
pub mod run;
pub mod wield;
pub mod shoot;
pub mod charge;
// Reexports
pub use self::{
alpha::AlphaAnimation, idle::IdleAnimation, jump::JumpAnimation, run::RunAnimation,
wield::WieldAnimation,
wield::WieldAnimation, charge::ChargeAnimation, shoot::ShootAnimation,
};
use super::{make_bone, vek::*, FigureBoneData, Skeleton};
@ -32,6 +34,7 @@ skeleton_impls!(struct BipedLargeSkeleton {
+ leg_r,
+ foot_l,
+ foot_r,
+ hold,
torso,
control,
});
@ -40,7 +43,7 @@ impl Skeleton for BipedLargeSkeleton {
type Attr = SkeletonAttr;
type Body = Body;
const BONE_COUNT: usize = 15;
const BONE_COUNT: usize = 16;
#[cfg(feature = "use-dyn-lib")]
const COMPUTE_FN: &'static [u8] = b"biped_large_compute_mats\0";
@ -57,6 +60,7 @@ impl Skeleton for BipedLargeSkeleton {
let lower_torso_mat = upper_torso_mat * Mat4::<f32>::from(self.lower_torso);
let head_mat = upper_torso_mat * Mat4::<f32>::from(self.head);
let control_mat = upper_torso_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()) = [
make_bone(head_mat),
@ -74,6 +78,8 @@ impl Skeleton for BipedLargeSkeleton {
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)),
// FIXME: Should this be l_control_mat?
make_bone(control_mat * hand_l_mat * Mat4::<f32>::from(self.hold)),
];
Vec3::default()
}
@ -186,9 +192,9 @@ impl<'a> From<&'a Body> for SkeletonAttr {
(Troll, _) => (0.0, 0.0),
(Dullahan, _) => (0.0, 0.0),
(Werewolf, _) => (-5.5, -2.0),
(Occultlizardman, _) => (-5.5, -6.0),
(Mightylizardman, _) => (-5.5, -6.0),
(Slylizardman, _) => (-5.5, -6.0),
(Occultlizardman, _) => (-4.5, -6.0),
(Mightylizardman, _) => (-4.5, -6.0),
(Slylizardman, _) => (-4.5, -6.0),
},
shoulder: match (body.species, body.body_type) {
(Ogre, Male) => (12.0, 0.5, 0.0),

View File

@ -0,0 +1,340 @@
use super::{
super::{vek::*, Animation},
BipedLargeSkeleton, SkeletonAttr,
};
use common::comp::item::{Hands, ToolKind};
use std::{f32::consts::PI, ops::Mul};
pub struct ShootAnimation;
impl Animation for ShootAnimation {
type Dependency = (Option<ToolKind>, Option<ToolKind>, f32, f64);
type Skeleton = BipedLargeSkeleton;
#[cfg(feature = "use-dyn-lib")]
const UPDATE_FN: &'static [u8] = b"biped_large_shoot\0";
#[cfg_attr(feature = "be-dyn-lib", export_name = "biped_large_shoot")]
fn update_skeleton_inner(
skeleton: &Self::Skeleton,
(active_tool_kind, second_tool_kind, velocity, global_time): Self::Dependency,
anim_time: f64,
_rate: &mut f32,
skeleton_attr: &SkeletonAttr,
) -> Self::Skeleton {
let mut next = (*skeleton).clone();
let lab = 0.55;
let breathe = (anim_time as f32 + 1.5 * PI).sin();
let test = (anim_time as f32 + 36.0 * PI).sin();
let slower = (anim_time as f32 * 1.0 + PI).sin();
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()
.mul(7331.0)
.sin()
* 0.25,
((global_time + anim_time) as f32 / 2.0)
.floor()
.mul(1337.0)
.sin()
* 0.125,
);
let look = Vec2::new(
((global_time + anim_time) as f32 / 8.0)
.floor()
.mul(7331.0)
.sin()
* 0.5,
((global_time + anim_time) as f32 / 8.0)
.floor()
.mul(1337.0)
.sin()
* 0.25,
);
let foothoril = (((1.0)
/ (0.4
+ (0.6)
* ((anim_time as f32 * 16.0 * lab as f32 + PI * 1.4).sin()).powf(2.0 as f32)))
.sqrt())
* ((anim_time as f32 * 16.0 * lab as f32 + PI * 1.4).sin());
let foothorir = (((1.0)
/ (0.4
+ (0.6)
* ((anim_time as f32 * 16.0 * lab as f32 + PI * 0.4).sin()).powf(2.0 as f32)))
.sqrt())
* ((anim_time as f32 * 16.0 * lab as f32 + PI * 0.4).sin());
let footvertl = (anim_time as f32 * 16.0 * lab as f32).sin();
let footvertr = (anim_time as f32 * 16.0 * lab as f32 + PI).sin();
let footrotl = (((5.0)
/ (2.5
+ (2.5)
* ((anim_time as f32 * 16.0 * lab as f32 + PI * 1.4).sin()).powf(2.0 as f32)))
.sqrt())
* ((anim_time as f32 * 16.0 * lab as f32 + PI * 1.4).sin());
let footrotr = (((5.0)
/ (1.0
+ (4.0)
* ((anim_time as f32 * 16.0 * lab as f32 + PI * 0.4).sin()).powf(2.0 as f32)))
.sqrt())
* ((anim_time as f32 * 16.0 * lab as f32 + PI * 0.4).sin());
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();
if velocity < 0.5 {
next.head.position = Vec3::new(
0.0,
skeleton_attr.head.0,
skeleton_attr.head.1 + breathe * 0.2,
) * 1.02;
next.head.orientation =
Quaternion::rotation_z(look.x * 0.6) * Quaternion::rotation_x(look.y * 0.6);
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 + breathe * 0.5,
);
next.upper_torso.orientation =
Quaternion::rotation_z(0.0) * Quaternion::rotation_x(0.0);
next.upper_torso.scale = Vec3::one();
next.lower_torso.position = Vec3::new(
0.0,
skeleton_attr.lower_torso.0,
skeleton_attr.lower_torso.1 + breathe * 0.15,
);
next.lower_torso.orientation =
Quaternion::rotation_z(0.0) * Quaternion::rotation_x(0.0);
next.lower_torso.scale = Vec3::one() * 1.02;
next.jaw.position = Vec3::new(
0.0,
skeleton_attr.jaw.0 - slower * 0.12,
skeleton_attr.jaw.1 + slow * 0.2,
);
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);
next.tail.scale = Vec3::one();
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(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.0) * Quaternion::rotation_x(0.0);
next.shoulder_r.scale = Vec3::one();
next.leg_l.position = Vec3::new(
-skeleton_attr.leg.0,
skeleton_attr.leg.1,
skeleton_attr.leg.2 + breathe * 0.2,
) * 1.02;
next.leg_l.orientation = Quaternion::rotation_z(0.0);
next.leg_l.scale = Vec3::one() * 1.02;
next.leg_r.position = Vec3::new(
skeleton_attr.leg.0,
skeleton_attr.leg.1,
skeleton_attr.leg.2 + breathe * 0.2,
) * 1.02;
next.leg_r.orientation = Quaternion::rotation_z(0.0);
next.leg_r.scale = Vec3::one() * 1.02;
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);
next.foot_l.scale = Vec3::one() / 8.0;
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.torso.position = Vec3::new(0.0, 0.0, 0.0) / 8.0;
next.torso.orientation = Quaternion::rotation_z(test * 0.0);
next.torso.scale = Vec3::one() / 8.0;
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)
* Quaternion::rotation_z(test * 0.02);
next.control.scale = Vec3::one();
} 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.scale = Vec3::one() * 1.02;
next.upper_torso.position = Vec3::new(
0.0,
skeleton_attr.upper_torso.0,
skeleton_attr.upper_torso.1 + shortalt * -1.5,
);
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.scale = Vec3::one() * 1.02;
next.jaw.position = Vec3::new(
0.0,
skeleton_attr.jaw.0 - slower * 0.12,
skeleton_attr.jaw.1 + slow * 0.2,
);
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);
next.tail.scale = Vec3::one();
next.shoulder_l.position = Vec3::new(
-skeleton_attr.shoulder.0,
skeleton_attr.shoulder.1 + foothoril * -1.0,
skeleton_attr.shoulder.2,
);
next.shoulder_l.orientation = Quaternion::rotation_x(0.5 + footrotl * -0.16)
* 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,
skeleton_attr.shoulder.2,
);
next.shoulder_r.orientation = Quaternion::rotation_x(0.5 + footrotr * -0.16)
* Quaternion::rotation_y(-0.1)
* Quaternion::rotation_z(footrotr * -0.1);
next.shoulder_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_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(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.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_r.position = Vec3::new(
skeleton_attr.foot.0,
4.0 + 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;
}
match active_tool_kind {
Some(ToolKind::Bow(_)) => {
next.hand_l.position =
Vec3::new(1.0 - exp * 2.0, -4.0 - exp * 4.0, -1.0 + exp * 6.0);
next.hand_l.orientation = Quaternion::rotation_x(1.20)
* Quaternion::rotation_y(-0.6 + exp * 0.8)
* Quaternion::rotation_z(-0.3 + exp * 0.9);
next.hand_l.scale = Vec3::one() * 1.05;
next.hand_r.position = Vec3::new(4.9, 3.0, -4.0);
next.hand_r.orientation = Quaternion::rotation_x(1.20)
* Quaternion::rotation_y(-0.6)
* Quaternion::rotation_z(-0.3);
next.hand_r.scale = Vec3::one() * 1.05;
next.main.position = Vec3::new(3.0, 2.0, -13.0);
next.main.orientation = Quaternion::rotation_x(-0.3)
* Quaternion::rotation_y(0.3)
* Quaternion::rotation_z(-0.6);
next.control.position = Vec3::new(-9.0, 6.0, 8.0);
next.control.orientation = Quaternion::rotation_x(exp * 0.4)
* Quaternion::rotation_y(0.0)
* Quaternion::rotation_z(0.0);
next.control.scale = Vec3::one();
},
Some(ToolKind::Staff(_)) => {
next.hand_l.position = Vec3::new(11.0, 5.0, -4.0);
next.hand_l.orientation =
Quaternion::rotation_x(1.27) * Quaternion::rotation_y(0.0);
next.hand_l.scale = Vec3::one() * 1.05;
next.hand_r.position = Vec3::new(12.0, 5.5, 2.0);
next.hand_r.orientation =
Quaternion::rotation_x(1.57) * Quaternion::rotation_y(0.2);
next.hand_r.scale = Vec3::one() * 1.05;
next.main.position = Vec3::new(8.0, 8.5, 13.2);
next.main.orientation = Quaternion::rotation_x(0.0)
* Quaternion::rotation_y(3.14)
* Quaternion::rotation_z(0.0);
next.control.position = Vec3::new(-7.0, 6.0, 6.0 - exp * 5.0);
next.control.orientation = Quaternion::rotation_x(exp * 1.3)
* Quaternion::rotation_y(0.0)
* Quaternion::rotation_z(exp * 1.5);
next.control.scale = Vec3::one();
},
_ => {},
}
next
}
}

View File

@ -30,6 +30,8 @@ impl Animation for WieldAnimation {
let slower = (anim_time as f32 * 1.0 + PI).sin();
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)
@ -91,17 +93,6 @@ impl Animation for WieldAnimation {
let shortalt = (anim_time as f32 * lab as f32 * 16.0 + PI / 2.0).sin();
next.main.position = Vec3::new(0.0, 0.0, 0.0);
next.main.orientation = Quaternion::rotation_x(0.0)
* Quaternion::rotation_y(-1.57)
* Quaternion::rotation_z(1.0);
next.main.scale = Vec3::one() * 1.02;
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.hand_l.position = Vec3::new(
-skeleton_attr.hand.0 - 7.0,
skeleton_attr.hand.1 - 7.0,
@ -117,8 +108,81 @@ impl Animation for WieldAnimation {
);
next.hand_r.orientation = Quaternion::rotation_x(0.57) * Quaternion::rotation_z(1.57);
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;
if velocity < 0.5 {
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)
* Quaternion::rotation_z(test * 0.02);
next.control.scale = Vec3::one();
next.main.position = Vec3::new(0.0, 0.0, 0.0);
next.main.orientation = Quaternion::rotation_x(0.0)
* Quaternion::rotation_y(-1.57)
* Quaternion::rotation_z(1.0);
next.main.scale = Vec3::one() * 1.02;
if velocity > 0.5 {
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.scale = Vec3::one() * 1.02;
next.upper_torso.position = Vec3::new(
0.0,
skeleton_attr.upper_torso.0,
skeleton_attr.upper_torso.1 + shortalt * -1.5,
);
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.scale = Vec3::one() * 1.02;
next.jaw.position = Vec3::new(
0.0,
skeleton_attr.jaw.0 - slower * 0.12,
skeleton_attr.jaw.1 + slow * 0.2,
);
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);
next.tail.scale = Vec3::one();
next.shoulder_l.position = Vec3::new(
-skeleton_attr.shoulder.0,
skeleton_attr.shoulder.1 + foothoril * -1.0,
skeleton_attr.shoulder.2,
);
next.shoulder_l.orientation = Quaternion::rotation_x(0.5 + footrotl * -0.16)
* 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,
skeleton_attr.shoulder.2,
);
next.shoulder_r.orientation = Quaternion::rotation_x(0.5 + footrotr * -0.16)
* Quaternion::rotation_y(-0.1)
* Quaternion::rotation_z(footrotr * -0.1);
next.shoulder_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;
} else {
next.head.position = Vec3::new(
0.0,
skeleton_attr.head.0,
@ -216,135 +280,34 @@ impl Animation for WieldAnimation {
* Quaternion::rotation_y(test * 0.02)
* Quaternion::rotation_z(test * 0.02);
next.control.scale = Vec3::one();
} 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.scale = Vec3::one() * 1.02;
next.upper_torso.position = Vec3::new(
0.0,
skeleton_attr.upper_torso.0,
skeleton_attr.upper_torso.1 + shortalt * -1.5,
);
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.scale = Vec3::one() * 1.02;
next.jaw.position = Vec3::new(
0.0,
skeleton_attr.jaw.0 - slower * 0.12,
skeleton_attr.jaw.1 + slow * 0.2,
);
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);
next.tail.scale = Vec3::one();
next.shoulder_l.position = Vec3::new(
-skeleton_attr.shoulder.0,
skeleton_attr.shoulder.1 + foothoril * -1.0,
skeleton_attr.shoulder.2,
);
next.shoulder_l.orientation = Quaternion::rotation_x(0.5 + footrotl * -0.16)
* 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,
skeleton_attr.shoulder.2,
);
next.shoulder_r.orientation = Quaternion::rotation_x(0.5 + footrotr * -0.16)
* Quaternion::rotation_y(-0.1)
* Quaternion::rotation_z(footrotr * -0.1);
next.shoulder_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_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(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.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_r.position = Vec3::new(
skeleton_attr.foot.0,
4.0 + 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;
}
match active_tool_kind {
Some(ToolKind::Bow(_)) => {
next.hand_l.position = Vec3::new(
-skeleton_attr.hand.0 - 7.0,
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.scale = Vec3::one() * 1.02;
next.hand_l.position = Vec3::new(2.0, 1.5, 0.0);
next.hand_l.orientation = Quaternion::rotation_x(1.20)
* 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, 4.5, -5.0);
next.hand_r.orientation = Quaternion::rotation_x(1.20)
* Quaternion::rotation_y(-0.6)
* Quaternion::rotation_z(-0.3);
next.hand_r.scale = Vec3::one() * 1.05;
next.main.position = Vec3::new(8.0, 8.0, -13.0);
next.main.orientation = Quaternion::rotation_x(-0.3)
* Quaternion::rotation_y(0.3)
* Quaternion::rotation_z(-0.6);
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.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.hold.position = Vec3::new(1.2, -1.0, -5.2);
next.hold.orientation = Quaternion::rotation_x(-1.7)
* Quaternion::rotation_y(0.0)
* Quaternion::rotation_z(-0.1);
next.hold.scale = Vec3::one() * 1.0;
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)
* Quaternion::rotation_z(test * 0.02);
next.control.position = Vec3::new(-7.0, 3.0, -6.0);
next.control.orientation =
Quaternion::rotation_x(u_slow * 0.2) * Quaternion::rotation_z(u_slowalt * 0.1);
next.control.scale = Vec3::one();
next.main.position = Vec3::new(0.0, 0.0, 0.0);
next.main.orientation = Quaternion::rotation_x(0.0)
* Quaternion::rotation_y(-1.57)
* Quaternion::rotation_z(1.0);
next.main.scale = Vec3::one() * 1.02;
},
Some(ToolKind::Hammer(_)) => {
next.hand_l.position = Vec3::new(

View File

@ -2265,6 +2265,58 @@ impl FigureMgr {
skeleton_attr,
)
},
CharacterState::BasicRanged(data) => {
if data.exhausted {
anim::biped_large::ShootAnimation::update_skeleton(
&target_base,
(active_tool_kind, second_tool_kind, vel.0.magnitude(), time),
state.state_time,
&mut state_animation_rate,
skeleton_attr,
)
} else {
anim::biped_large::ChargeAnimation::update_skeleton(
&target_base,
(
active_tool_kind,
second_tool_kind,
vel.0.magnitude(),
ori,
state.last_ori,
time,
),
state.state_time,
&mut state_animation_rate,
skeleton_attr,
)
}
},
CharacterState::ChargedRanged(data) => {
if data.exhausted {
anim::biped_large::ShootAnimation::update_skeleton(
&target_base,
(active_tool_kind, second_tool_kind, vel.0.magnitude(), time),
state.state_time,
&mut state_animation_rate,
skeleton_attr,
)
} else {
anim::biped_large::ChargeAnimation::update_skeleton(
&target_base,
(
active_tool_kind,
second_tool_kind,
vel.0.magnitude(),
ori,
state.last_ori,
time,
),
state.state_time,
&mut state_animation_rate,
skeleton_attr,
)
}
},
// TODO!
_ => target_base,
};