swim alterations to condense the body on strong turns

This commit is contained in:
jshipsey
2020-08-08 13:47:17 -04:00
parent be3ed4b238
commit d7b3e84153
3 changed files with 51 additions and 38 deletions

View File

@ -32,17 +32,19 @@ impl Animation for SwimAnimation {
skeleton_attr: &SkeletonAttr, skeleton_attr: &SkeletonAttr,
) -> Self::Skeleton { ) -> Self::Skeleton {
let mut next = (*skeleton).clone(); let mut next = (*skeleton).clone();
let avgspeed = Vec2::<f32>::from(avg_vel).magnitude();
let avgtotal = Vec3::<f32>::from(avg_vel).magnitude();
let speed = Vec3::<f32>::from(velocity).magnitude(); let speed = Vec3::<f32>::from(velocity).magnitude();
*rate = 1.0; *rate = 1.0;
let tempo = if speed > 0.5 { 1.0 } else { 0.7 }; let tempo = if speed > 0.5 { 1.5 } else { 0.7 };
let intensity = if speed > 0.5 { 1.0 } else { 0.3 }; let intensity = if speed > 0.5 { 1.0 } else { 0.3 };
let lab = 1.0 * tempo; let lab = 1.0 * tempo;
let short = (anim_time as f32 * lab as f32 * 6.0 + PI / 2.0).sin(); let short = (anim_time as f32 * lab as f32 * 6.0 + PI * 0.9).sin();
let foot = (anim_time as f32 * lab as f32 * 6.0).sin(); let foot = (anim_time as f32 * lab as f32 * 6.0 + PI * -0.1).sin();
let footrotl = (((1.0) let footrotl = (((1.0)
/ (0.2 / (0.2
@ -58,8 +60,8 @@ impl Animation for SwimAnimation {
.sqrt()) .sqrt())
* ((anim_time as f32 * 6.0 * lab as f32 + PI * 0.4).sin()); * ((anim_time as f32 * 6.0 * lab as f32 + PI * 0.4).sin());
let foothoril = (anim_time as f32 * 6.0 * lab as f32 + PI * 1.45).sin(); let foothoril = (anim_time as f32 * 6.0 * lab as f32 + PI * 1.4).sin();
let foothorir = (anim_time as f32 * 6.0 * lab as f32 + PI * (0.45)).sin(); let foothorir = (anim_time as f32 * 6.0 * lab as f32 + PI * (0.4)).sin();
let head_look = Vec2::new( let head_look = Vec2::new(
((global_time + anim_time) as f32 / 4.0 * (1.0 / tempo)) ((global_time + anim_time) as f32 / 4.0 * (1.0 / tempo))
.floor() .floor()
@ -85,32 +87,35 @@ impl Animation for SwimAnimation {
} else { } else {
0.0 0.0
} * 1.3; } * 1.3;
let abstilt = tilt.abs();
let adjust = if speed > 0.5 { -1.57 } else { -3.14 * speed }; let squash = if abstilt > 0.2 { 0.35 } else { 1.0 }; //condenses the body at strong turns
next.head.offset = Vec3::new( next.head.offset = Vec3::new(
0.0, 0.0,
-3.0 + skeleton_attr.head.0, -3.0 + skeleton_attr.head.0,
skeleton_attr.head.1 - 1.0 + short * 0.3, skeleton_attr.head.1 - 1.0 + short * 0.3,
); );
next.head.ori = Quaternion::rotation_z(head_look.x * 0.5 + short * -0.2 * intensity) next.head.ori =
* Quaternion::rotation_x( Quaternion::rotation_z(head_look.x * 0.5 + short * -0.2 * intensity + tilt * 3.0)
(0.4 * head_look.y * (1.0 / intensity)).abs() * Quaternion::rotation_x(
+ 0.45 * intensity (0.4 * head_look.y * (1.0 / intensity)).abs()
+ velocity.z * 0.02, + 0.45 * intensity
); + velocity.z * 0.03
- (abstilt * 1.8),
);
next.head.scale = Vec3::one() * skeleton_attr.head_scale; next.head.scale = Vec3::one() * skeleton_attr.head_scale;
next.chest.offset = Vec3::new( next.chest.offset = Vec3::new(
0.0, 0.0,
skeleton_attr.chest.0, skeleton_attr.chest.0,
-13.0 + skeleton_attr.chest.1 + short * 1.3 * intensity, -10.0 + skeleton_attr.chest.1 + short * 0.3 * intensity,
); );
next.chest.ori = Quaternion::rotation_z(short * 0.1 * intensity); next.chest.ori = Quaternion::rotation_z(short * 0.1 * intensity);
next.chest.scale = Vec3::one(); next.chest.scale = Vec3::one();
next.belt.offset = Vec3::new(0.0, skeleton_attr.belt.0, skeleton_attr.belt.1); next.belt.offset = Vec3::new(0.0, skeleton_attr.belt.0, skeleton_attr.belt.1);
next.belt.ori = Quaternion::rotation_x(velocity.z * 0.01) next.belt.ori = Quaternion::rotation_x(velocity.z.abs() * -0.005 + abstilt * 1.0)
* Quaternion::rotation_z(short * 0.2 * intensity); * Quaternion::rotation_z(short * -0.2 * intensity);
next.belt.scale = Vec3::one(); next.belt.scale = Vec3::one();
next.back.offset = Vec3::new(0.0, skeleton_attr.back.0, skeleton_attr.back.1); next.back.offset = Vec3::new(0.0, skeleton_attr.back.0, skeleton_attr.back.1);
@ -118,42 +123,44 @@ impl Animation for SwimAnimation {
next.back.scale = Vec3::one() * 1.02; next.back.scale = Vec3::one() * 1.02;
next.shorts.offset = Vec3::new(0.0, skeleton_attr.shorts.0, skeleton_attr.shorts.1); next.shorts.offset = Vec3::new(0.0, skeleton_attr.shorts.0, skeleton_attr.shorts.1);
next.shorts.ori = Quaternion::rotation_x(velocity.z * 0.02) next.shorts.ori = Quaternion::rotation_x(velocity.z.abs() * -0.005 + abstilt * 1.0)
* Quaternion::rotation_z(short * 0.3 * intensity); * Quaternion::rotation_z(short * -0.3 * intensity);
next.shorts.scale = Vec3::one(); next.shorts.scale = Vec3::one();
next.l_hand.offset = Vec3::new( next.l_hand.offset = Vec3::new(
-1.0 - skeleton_attr.hand.0, -1.0 - skeleton_attr.hand.0,
1.5 + skeleton_attr.hand.1 - foot * 2.0 * intensity, 1.5 + skeleton_attr.hand.1 - foot * 2.0 * intensity * squash,
intensity * 5.0 + skeleton_attr.hand.2 + foot * -5.0 * intensity, intensity * 5.0 + skeleton_attr.hand.2 + foot * -5.0 * intensity * squash,
); );
next.l_hand.ori = Quaternion::rotation_x(1.5 + foot * -1.2 * intensity) next.l_hand.ori = Quaternion::rotation_x(1.5 + foot * -1.2 * intensity * squash)
* Quaternion::rotation_y(0.4 + foot * -0.35); * Quaternion::rotation_y(0.4 + foot * -0.35);
next.l_hand.scale = Vec3::one(); next.l_hand.scale = Vec3::one();
next.r_hand.offset = Vec3::new( next.r_hand.offset = Vec3::new(
1.0 + skeleton_attr.hand.0, 1.0 + skeleton_attr.hand.0,
1.5 + skeleton_attr.hand.1 + foot * 2.0 * intensity, 1.5 + skeleton_attr.hand.1 + foot * 2.0 * intensity * squash,
intensity * 5.0 + skeleton_attr.hand.2 + foot * 5.0 * intensity, intensity * 5.0 + skeleton_attr.hand.2 + foot * 5.0 * intensity * squash,
); );
next.r_hand.ori = Quaternion::rotation_x(1.5 + foot * 1.2 * intensity) next.r_hand.ori = Quaternion::rotation_x(1.5 + foot * 1.2 * intensity * squash)
* Quaternion::rotation_y(-0.4 + foot * -0.35); * Quaternion::rotation_y(-0.4 + foot * -0.35);
next.r_hand.scale = Vec3::one(); next.r_hand.scale = Vec3::one();
next.l_foot.offset = Vec3::new( next.l_foot.offset = Vec3::new(
-skeleton_attr.foot.0, -skeleton_attr.foot.0,
skeleton_attr.foot.1 + foothoril * 1.5 * intensity, skeleton_attr.foot.1 + foothoril * 1.5 * intensity * squash,
-15.0 + skeleton_attr.foot.2 + footrotl * 3.0 * intensity, -10.0 + skeleton_attr.foot.2 + footrotl * 3.0 * intensity * squash,
); );
next.l_foot.ori = Quaternion::rotation_x(-0.8 + footrotl * 0.4 * intensity); next.l_foot.ori =
Quaternion::rotation_x(-0.8 * squash + footrotl * 0.4 * intensity * squash);
next.l_foot.scale = Vec3::one(); next.l_foot.scale = Vec3::one();
next.r_foot.offset = Vec3::new( next.r_foot.offset = Vec3::new(
skeleton_attr.foot.0, skeleton_attr.foot.0,
skeleton_attr.foot.1 + foothorir * 1.5 * intensity, skeleton_attr.foot.1 + foothorir * 1.5 * intensity * squash,
-15.0 + skeleton_attr.foot.2 + footrotr * 3.0 * intensity, -10.0 + skeleton_attr.foot.2 + footrotr * 3.0 * intensity * squash,
); );
next.r_foot.ori = Quaternion::rotation_x(-0.8 + footrotr * 0.4 * intensity); next.r_foot.ori =
Quaternion::rotation_x(-0.8 * squash + footrotr * 0.4 * intensity * squash);
next.r_foot.scale = Vec3::one(); next.r_foot.scale = Vec3::one();
next.l_shoulder.offset = Vec3::new( next.l_shoulder.offset = Vec3::new(
@ -218,13 +225,19 @@ impl Animation for SwimAnimation {
); );
next.lantern.ori = Quaternion::rotation_x(0.0) * Quaternion::rotation_y(0.0); next.lantern.ori = Quaternion::rotation_x(0.0) * Quaternion::rotation_y(0.0);
next.lantern.scale = Vec3::one() * 0.65; next.lantern.scale = Vec3::one() * 0.65;
let switch = if avg_vel.z > 0.0 && avgspeed < 0.5 {
avgtotal.min(0.5)
} else {
avgtotal
};
next.torso.offset = Vec3::new(0.0, 0.0, 1.0) * skeleton_attr.scaler; next.torso.offset = Vec3::new(0.0, 0.0, 1.0) * skeleton_attr.scaler;
next.torso.ori = Quaternion::rotation_x(adjust + avg_vel.z * 0.12) next.torso.ori = Quaternion::rotation_x(
* Quaternion::rotation_z(tilt * 12.0 + short * 0.0 * intensity); (((1.0 / switch) * PI / 2.0 + avg_vel.z * 0.12).min(1.57) - PI / 2.0)
+ avgspeed * avg_vel.z * -0.003,
) * Quaternion::rotation_z(tilt * 8.0);
next.torso.scale = Vec3::one() / 11.0 * skeleton_attr.scaler; next.torso.scale = Vec3::one() / 11.0 * skeleton_attr.scaler;
next.control.scale = Vec3::one(); next.control.scale = Vec3::one(); //avgspeed*-0.14*reverse +
next.l_control.scale = Vec3::one(); next.l_control.scale = Vec3::one();

View File

@ -70,7 +70,7 @@ impl Animation for SwimWieldAnimation {
next.l_foot.offset = Vec3::new( next.l_foot.offset = Vec3::new(
-skeleton_attr.foot.0, -skeleton_attr.foot.0,
skeleton_attr.foot.1 + foothoril * 1.5 * intensity, skeleton_attr.foot.1 + foothoril * 1.5 * intensity,
-15.0 + skeleton_attr.foot.2 + footrotl * 3.0 * intensity, -10.0 + skeleton_attr.foot.2 + footrotl * 3.0 * intensity,
); );
next.l_foot.ori = Quaternion::rotation_x(-0.8 + footrotl * 0.4 * intensity); next.l_foot.ori = Quaternion::rotation_x(-0.8 + footrotl * 0.4 * intensity);
next.l_foot.scale = Vec3::one(); next.l_foot.scale = Vec3::one();
@ -78,11 +78,11 @@ impl Animation for SwimWieldAnimation {
next.r_foot.offset = Vec3::new( next.r_foot.offset = Vec3::new(
skeleton_attr.foot.0, skeleton_attr.foot.0,
skeleton_attr.foot.1 + foothorir * 1.5 * intensity, skeleton_attr.foot.1 + foothorir * 1.5 * intensity,
-15.0 + skeleton_attr.foot.2 + footrotr * 3.0 * intensity, -10.0 + skeleton_attr.foot.2 + footrotr * 3.0 * intensity,
); );
next.r_foot.ori = Quaternion::rotation_x(-0.8 + footrotr * 0.4 * intensity); next.r_foot.ori = Quaternion::rotation_x(-0.8 + footrotr * 0.4 * intensity);
next.r_foot.scale = Vec3::one(); next.r_foot.scale = Vec3::one();
if velocity > 0.1 { if velocity > 0.01 {
next.torso.offset = Vec3::new(0.0, 0.0, 1.0) * skeleton_attr.scaler; next.torso.offset = Vec3::new(0.0, 0.0, 1.0) * skeleton_attr.scaler;
next.torso.ori = Quaternion::rotation_x(velocity * -0.05); next.torso.ori = Quaternion::rotation_x(velocity * -0.05);
next.torso.scale = Vec3::one() / 11.0 * skeleton_attr.scaler; next.torso.scale = Vec3::one() / 11.0 * skeleton_attr.scaler;
@ -123,7 +123,7 @@ impl Animation for SwimWieldAnimation {
); );
next.chest.ori = next.chest.ori =
Quaternion::rotation_y(u_slowalt * 0.04) * Quaternion::rotation_z(0.15); Quaternion::rotation_y(u_slowalt * 0.04) * Quaternion::rotation_z(0.25);
next.belt.offset = Vec3::new(0.0, skeleton_attr.belt.0, skeleton_attr.belt.1); next.belt.offset = Vec3::new(0.0, skeleton_attr.belt.0, skeleton_attr.belt.1);
next.belt.ori = Quaternion::rotation_y(u_slowalt * 0.03) * Quaternion::rotation_z(0.22); next.belt.ori = Quaternion::rotation_y(u_slowalt * 0.03) * Quaternion::rotation_z(0.22);

View File

@ -584,7 +584,7 @@ impl FigureMgr {
physics.in_fluid, // In water physics.in_fluid, // In water
) { ) {
// Standing // Standing
(true, false, _) => anim::character::StandAnimation::update_skeleton( (true, false, false) => anim::character::StandAnimation::update_skeleton(
&CharacterSkeleton::new(), &CharacterSkeleton::new(),
( (
active_tool_kind.clone(), active_tool_kind.clone(),