anim tweaks

This commit is contained in:
jshipsey 2022-01-17 04:52:28 -05:00
parent c9762568d6
commit 1d76d484bb
6 changed files with 94 additions and 130 deletions

View File

@ -43,10 +43,6 @@ impl Animation for MountAnimation {
) -> Self::Skeleton {
let mut next = (*skeleton).clone();
let slow = (anim_time * 1.0).sin();
let slowa = (anim_time * 1.0 + PI / 2.0).sin();
let stop = (anim_time * 3.0).min(PI / 2.0).sin();
let head_look = Vec2::new(
(global_time * 0.05 + anim_time / 15.0)
.floor()
@ -82,66 +78,41 @@ impl Animation for MountAnimation {
next.hand_l.scale = Vec3::one() * 1.04;
next.hand_r.scale = Vec3::one() * 1.04;
next.back.scale = Vec3::one() * 1.02;
next.belt.scale = Vec3::one() * 1.02;
next.hold.scale = Vec3::one() * 0.0;
next.lantern.scale = Vec3::one() * 0.65;
next.shoulder_l.scale = Vec3::one() * 1.1;
next.shoulder_r.scale = Vec3::one() * 1.1;
next.head.position = Vec3::new(0.0, s_a.head.0, s_a.head.1 + slow * 0.1 + stop * -0.8);
next.head.orientation =
Quaternion::rotation_z(head_look.x + slow * 0.2 - slow * 0.1 + tilt * -2.0)
* Quaternion::rotation_x(
(canceler * 0.3
+ 0.4
+ slowa * -0.1
+ slow * 0.1
+ head_look.y
+ tilt.abs() * 1.2)
.abs(),
);
next.head.position = Vec3::new(0.0, s_a.head.0, s_a.head.1);
next.head.orientation = Quaternion::rotation_z(head_look.x + tilt * -2.0)
* Quaternion::rotation_x((0.35 + head_look.y + tilt.abs() * 1.2).abs());
next.chest.position = Vec3::new(0.0, s_a.chest.0, s_a.chest.1);
next.chest.orientation =
Quaternion::rotation_x(-0.6 + stop * 0.15 + canceler * -0.3 + tilt.abs() * -1.5)
* Quaternion::rotation_y(tilt * 2.0);
Quaternion::rotation_x(-0.4 + tilt.abs() * -1.5) * Quaternion::rotation_y(tilt * 2.0);
next.belt.position = Vec3::new(0.0, s_a.belt.0 + stop * 1.2, s_a.belt.1 + 1.0);
next.belt.orientation =
Quaternion::rotation_x(stop * 0.3) * Quaternion::rotation_y(tilt * -0.5);
next.belt.position = Vec3::new(0.0, s_a.belt.0 + 0.5, s_a.belt.1 + 0.5);
next.belt.orientation = Quaternion::rotation_x(0.2) * Quaternion::rotation_y(tilt * -0.5);
next.back.position = Vec3::new(0.0, s_a.back.0, s_a.back.1);
next.shorts.position = Vec3::new(
0.0,
s_a.shorts.0 + stop * 2.5 + 1.0,
s_a.shorts.1 + stop * 0.6 + 2.0,
);
next.shorts.orientation =
Quaternion::rotation_x(stop * 0.6) * Quaternion::rotation_y(tilt * -1.0);
next.shorts.position = Vec3::new(0.0, s_a.shorts.0 + 1.0, s_a.shorts.1 + 1.0);
next.shorts.orientation = Quaternion::rotation_x(0.3) * Quaternion::rotation_y(tilt * -1.0);
next.hand_l.position = Vec3::new(
-s_a.hand.0 + 4.0,
s_a.hand.1 + slowa * 0.15 + stop * 8.0,
s_a.hand.2 + slow * 0.7 + stop * 4.0,
);
next.hand_l.position = Vec3::new(-s_a.hand.0 + 3.0, s_a.hand.1 + 9.0, s_a.hand.2 + 4.0);
next.hand_l.orientation =
Quaternion::rotation_x(PI / 2.0) * Quaternion::rotation_z(-PI / 2.0);
Quaternion::rotation_x(PI / 2.0) * Quaternion::rotation_z(-PI / 2.0 + 0.5);
next.hand_r.position = Vec3::new(
s_a.hand.0 - 4.0,
s_a.hand.1 + slowa * 0.15 + stop * 8.0,
s_a.hand.2 + slow * 0.7 + stop * 4.0,
);
next.hand_r.position = Vec3::new(s_a.hand.0 - 3.0, s_a.hand.1 + 9.0, s_a.hand.2 + 4.0);
next.hand_r.orientation =
Quaternion::rotation_x(PI / 2.0) * Quaternion::rotation_z(PI / 2.0);
Quaternion::rotation_x(PI / 2.0) * Quaternion::rotation_z(PI / 2.0 - 0.5);
next.foot_l.position = Vec3::new(-s_a.foot.0 - 2.0, 4.0 + s_a.foot.1, s_a.foot.2);
next.foot_l.orientation = Quaternion::rotation_x(slow * 0.1 + stop * 0.4 + slow * 0.1)
* Quaternion::rotation_y(0.5);
next.foot_l.orientation = Quaternion::rotation_x(0.5) * Quaternion::rotation_y(0.5);
next.foot_r.position = Vec3::new(s_a.foot.0 + 2.0, 4.0 + s_a.foot.1, s_a.foot.2);
next.foot_r.orientation = Quaternion::rotation_x(slowa * 0.1 + stop * 0.4 + slowa * 0.1)
* Quaternion::rotation_y(-0.5);
next.foot_r.orientation = Quaternion::rotation_x(0.5) * Quaternion::rotation_y(-0.5);
next.shoulder_l.position = Vec3::new(-s_a.shoulder.0, s_a.shoulder.1, s_a.shoulder.2);
next.shoulder_l.orientation = Quaternion::rotation_x(0.0);
@ -149,8 +120,6 @@ impl Animation for MountAnimation {
next.shoulder_r.position = Vec3::new(s_a.shoulder.0, s_a.shoulder.1, s_a.shoulder.2);
next.shoulder_r.orientation = Quaternion::rotation_x(0.0);
next.torso.position = Vec3::new(0.0, 0.0, 0.0);
if skeleton.holding_lantern {
next.hand_r.position = Vec3::new(
s_a.hand.0 + 1.0 - head_look.x * 8.0,

View File

@ -5,6 +5,7 @@ use super::{
use common::{
comp::item::{Hands, ToolKind},
states::utils::{AbilityInfo, StageSection},
util::Dir,
};
use core::f32::consts::PI;
@ -16,6 +17,8 @@ impl Animation for RepeaterAnimation {
Option<AbilityInfo>,
(Option<Hands>, Option<Hands>),
Vec3<f32>,
Dir,
Vec3<f32>,
f32,
Option<StageSection>,
);
@ -27,7 +30,7 @@ impl Animation for RepeaterAnimation {
#[cfg_attr(feature = "be-dyn-lib", export_name = "character_repeater")]
fn update_skeleton_inner<'a>(
skeleton: &Self::Skeleton,
(ability_info, hands, velocity, _global_time, stage_section): Self::Dependency<'a>,
(ability_info, hands, orientation,look_dir, velocity, _global_time, stage_section): Self::Dependency<'a>,
anim_time: f32,
rate: &mut f32,
s_a: &SkeletonAttr,
@ -35,7 +38,9 @@ impl Animation for RepeaterAnimation {
*rate = 1.0;
let mut next = (*skeleton).clone();
let speed = Vec2::<f32>::from(velocity).magnitude();
let ori_angle = orientation.y.atan2(orientation.x);
let lookdir_angle = look_dir.y.atan2(look_dir.x);
let swivel = lookdir_angle - ori_angle;
let (move1base, move2base, move3base, move4) = match stage_section {
Some(StageSection::Movement) => (anim_time, 0.0, 0.0, 0.0),
Some(StageSection::Buildup) => (1.0, anim_time, 0.0, 0.0),
@ -60,6 +65,10 @@ impl Animation for RepeaterAnimation {
next.hold.position = Vec3::new(0.0, -1.0 + move3 * 2.0, -5.2);
next.hold.orientation = Quaternion::rotation_x(-PI / 2.0) * Quaternion::rotation_z(0.0);
next.hold.scale = Vec3::one() * (1.0);
next.chest.orientation = Quaternion::rotation_z(swivel * 0.8);
next.torso.orientation = Quaternion::rotation_z(swivel * 0.2);
if speed < 0.5 {
next.foot_l.position = Vec3::new(
-s_a.foot.0 + move1 * -0.75,

View File

@ -46,7 +46,7 @@ impl Animation for ShootAnimation {
s_a: &SkeletonAttr,
) -> Self::Skeleton {
*rate = 1.0;
let speed = Vec2::<f32>::from(velocity).magnitude();
let _speed = Vec2::<f32>::from(velocity).magnitude();
let mut next = (*skeleton).clone();
@ -106,21 +106,6 @@ impl Animation for ShootAnimation {
);
next.chest.orientation = Quaternion::rotation_z(swivel * 0.8);
next.torso.orientation = Quaternion::rotation_z(swivel * 0.2);
if speed < 0.5 {
next.belt.orientation =
Quaternion::rotation_x(0.07) * Quaternion::rotation_z(0.0);
next.shorts.orientation =
Quaternion::rotation_x(0.08) * Quaternion::rotation_z(0.0);
next.foot_l.position = Vec3::new(-s_a.foot.0, s_a.foot.1 - 5.0, s_a.foot.2);
next.foot_l.orientation = Quaternion::rotation_x(-0.5);
next.foot_r.position = Vec3::new(s_a.foot.0, s_a.foot.1 + 3.0, s_a.foot.2);
next.foot_r.orientation =
Quaternion::rotation_x(0.5) * Quaternion::rotation_z(0.3);
} else {
};
},
Some(ToolKind::Bow) => {
let (_move1, move2, _move3) = match stage_section {
@ -151,26 +136,17 @@ impl Animation for ShootAnimation {
s_a.bc.2 + 8.0 + (look_dir.z * 15.0).max(-8.0),
);
next.control.orientation = Quaternion::rotation_x(look_dir.z)
* Quaternion::rotation_y(-look_dir.z + s_a.bc.4 - 1.25);
* Quaternion::rotation_y(-look_dir.z + s_a.bc.4 - 1.25)
* Quaternion::rotation_z(s_a.bc.5 - 0.2 + move2 * -0.1);
next.head.position = Vec3::new(0.0, s_a.head.0, s_a.head.1);
next.head.orientation =
Quaternion::rotation_x(look_dir.z * 0.7) * Quaternion::rotation_z(tilt * -0.0);
next.chest.orientation = Quaternion::rotation_z(swivel * 0.8);
next.chest.orientation = Quaternion::rotation_z(swivel * 0.8 + 0.8 + move2 * 0.5);
next.torso.orientation = Quaternion::rotation_z(swivel * 0.2);
next.shoulder_l.orientation = Quaternion::rotation_x(move2 * 0.5);
if speed < 0.5 {
next.foot_l.position = Vec3::new(-s_a.foot.0, s_a.foot.1 - 5.0, s_a.foot.2);
next.foot_l.orientation = Quaternion::rotation_x(-0.5);
next.foot_r.position = Vec3::new(s_a.foot.0, s_a.foot.1 + 3.0, s_a.foot.2);
next.foot_r.orientation =
Quaternion::rotation_x(0.5) * Quaternion::rotation_z(0.3);
} else {
};
},
_ => {},
}

View File

@ -332,22 +332,22 @@ impl<'a> From<&'a Body> for SkeletonAttr {
fn mount_point(body: &Body) -> Vec3<f32> {
use comp::quadruped_low::{BodyType::*, Species::*};
match (body.species, body.body_type) {
(Crocodile, _) => (0.0, 4.5, 0.0),
(Alligator, _) => (0.0, 4.25, 0.0),
(Salamander, Male) => (0.0, 5.0, 1.0),
(Salamander, Female) => (0.0, 5.0, 1.0),
(Monitor, _) => (0.0, 2.0, 0.0),
(Asp, _) => (0.0, 2.0, 2.0),
(Tortoise, _) => (0.0, -7.0, 1.0),
(Rocksnapper, _) => (0.0, -7.0, 6.5),
(Pangolin, _) => (0.0, -6.5, 0.0),
(Maneater, _) => (0.0, 4.0, -9.5),
(Sandshark, _) => (0.0, -4.0, 0.0),
(Hakulaq, _) => (0.0, 4.0, -2.5),
(Lavadrake, _) => (0.0, 2.0, 0.5),
(Icedrake, _) => (0.0, -8.0, 4.5),
(Basilisk, _) => (0.0, -2.0, 4.0),
(Deadwood, _) => (0.0, -2.0, -1.0),
(Crocodile, _) => (0.0, 4.5, -2.0),
(Alligator, _) => (0.0, 4.25, -2.0),
(Salamander, Male) => (0.0, 5.0, -1.0),
(Salamander, Female) => (0.0, 5.0, -1.0),
(Monitor, _) => (0.0, 2.0, -2.0),
(Asp, _) => (0.0, 2.0, 0.0),
(Tortoise, _) => (0.0, -7.0, -1.0),
(Rocksnapper, _) => (0.0, -7.0, 4.5),
(Pangolin, _) => (0.0, -6.5, -2.0),
(Maneater, _) => (0.0, 4.0, -11.5),
(Sandshark, _) => (0.0, -4.0, -2.0),
(Hakulaq, _) => (0.0, 4.0, -4.5),
(Lavadrake, _) => (0.0, 2.0, -2.5),
(Icedrake, _) => (0.0, -8.0, 2.5),
(Basilisk, _) => (0.0, -2.0, 2.0),
(Deadwood, _) => (0.0, -2.0, -3.0),
}
.into()
}

View File

@ -701,42 +701,42 @@ impl<'a> From<&'a Body> for SkeletonAttr {
fn mount_point(body: &Body) -> Vec3<f32> {
use comp::quadruped_medium::{BodyType::*, Species::*};
match (body.species, body.body_type) {
(Grolgar, _) => (0.0, -6.0, 6.0),
(Saber, _) => (0.0, -12.0, 4.0),
(Tuskram, _) => (0.0, -17.0, 2.0),
(Lion, _) => (0.0, -8.0, 4.0),
(Tarasque, _) => (0.0, -6.0, 4.0),
(Tiger, _) => (0.0, -8.0, 4.0),
(Wolf, _) => (0.0, -7.0, 3.0),
(Frostfang, _) => (0.0, -3.0, 4.0),
(Mouflon, _) => (0.0, -8.0, 2.0),
(Catoblepas, _) => (0.0, -8.0, 2.0),
(Bonerattler, _) => (0.0, -1.0, 4.0),
(Deer, _) => (0.0, -9.0, 3.0),
(Hirdrasil, _) => (0.0, -11.0, 3.0),
(Roshwalr, _) => (0.0, -1.0, 7.0),
(Donkey, _) => (0.0, -5.0, 2.0),
(Camel, _) => (0.0, -13.0, 5.0),
(Zebra, _) => (0.0, -6.0, 3.0),
(Antelope, _) => (0.0, -8.0, 3.0),
(Kelpie, _) => (0.0, -6.0, 3.0),
(Horse, _) => (0.0, -8.0, 3.0),
(Barghest, _) => (0.0, -8.0, 5.0),
(Cattle, Male) => (0.0, -3.0, 8.0),
(Cattle, Female) => (0.0, -2.0, 6.0),
(Darkhound, _) => (0.0, -2.0, 3.0),
(Highland, _) => (0.0, -3.0, 8.0),
(Yak, _) => (0.0, -8.0, 9.0),
(Panda, _) => (0.0, -10.0, 5.0),
(Bear, _) => (0.0, -11.0, 6.0),
(Dreadhorn, _) => (0.0, 0.0, 10.0),
(Moose, _) => (0.0, -9.0, 6.0),
(Snowleopard, _) => (0.0, -9.0, 4.0),
(Mammoth, _) => (0.0, 5.0, 8.0),
(Ngoubou, _) => (0.0, -7.0, 6.0),
(Llama, _) => (0.0, -6.0, 5.0),
(Alpaca, _) => (0.0, -9.0, 3.0),
(Akhlut, _) => (0.0, -6.0, 4.0),
(Grolgar, _) => (0.0, -6.0, 3.0),
(Saber, _) => (0.0, -12.0, 1.0),
(Tuskram, _) => (0.0, -17.0, -1.0),
(Lion, _) => (0.0, -8.0, 1.0),
(Tarasque, _) => (0.0, -6.0, 1.0),
(Tiger, _) => (0.0, -8.0, 1.0),
(Wolf, _) => (0.0, -9.0, 0.0),
(Frostfang, _) => (0.0, -6.0, -1.0),
(Mouflon, _) => (0.0, -8.0, -1.0),
(Catoblepas, _) => (0.0, -8.0, -1.0),
(Bonerattler, _) => (0.0, -1.0, 1.0),
(Deer, _) => (0.0, -9.0, 0.0),
(Hirdrasil, _) => (0.0, -11.0, 0.0),
(Roshwalr, _) => (0.0, -1.0, 4.0),
(Donkey, _) => (0.0, -5.0, -1.0),
(Camel, _) => (0.0, -13.0, 2.0),
(Zebra, _) => (0.0, -6.0, 0.0),
(Antelope, _) => (0.0, -8.0, 0.0),
(Kelpie, _) => (0.0, -6.0, 0.0),
(Horse, _) => (0.0, -8.0, 0.0),
(Barghest, _) => (0.0, -8.0, 2.0),
(Cattle, Male) => (0.0, -3.0, 5.0),
(Cattle, Female) => (0.0, -2.0, 3.0),
(Darkhound, _) => (0.0, -2.0, 0.0),
(Highland, _) => (0.0, -3.0, 5.0),
(Yak, _) => (0.0, -8.0, 6.0),
(Panda, _) => (0.0, -10.0, 2.0),
(Bear, _) => (0.0, -11.0, 3.0),
(Dreadhorn, _) => (0.0, 0.0, 7.0),
(Moose, _) => (0.0, -9.0, 3.0),
(Snowleopard, _) => (0.0, -9.0, 1.0),
(Mammoth, _) => (0.0, 5.0, 5.0),
(Ngoubou, _) => (0.0, -7.0, 3.0),
(Llama, _) => (0.0, -6.0, 2.0),
(Alpaca, _) => (0.0, -9.0, 0.0),
(Akhlut, _) => (0.0, -6.0, 1.0),
}
.into()
}

View File

@ -1157,6 +1157,8 @@ impl FigureMgr {
(
Some(s.static_data.ability_info),
hands,
ori * anim::vek::Vec3::<f32>::unit_y(),
look_dir,
rel_vel,
time,
Some(s.stage_section),
@ -1796,9 +1798,17 @@ impl FigureMgr {
skeleton_attr,
),
// In air
(false, _, false) => anim::quadruped_small::JumpAnimation::update_skeleton(
(false, _, false) => anim::quadruped_small::RunAnimation::update_skeleton(
&QuadrupedSmallSkeleton::default(),
(rel_vel.magnitude(), time),
(
rel_vel.magnitude(),
// TODO: Update to use the quaternion.
ori * anim::vek::Vec3::<f32>::unit_y(),
state.last_ori * anim::vek::Vec3::<f32>::unit_y(),
time,
rel_avg_vel,
state.acc_vel,
),
state.state_time,
&mut state_animation_rate,
skeleton_attr,