mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Idle, run, vel/ori aware fly anims
This commit is contained in:
parent
bc95484863
commit
0f6b902924
@ -56,7 +56,6 @@ impl Animation for FlyAnimation {
|
||||
} else {
|
||||
0.0
|
||||
} * 1.3;
|
||||
let x_tilt = avg_vel.z.atan2(avg_vel.xy().magnitude());
|
||||
|
||||
next.chest.scale = Vec3::one() * s_a.scaler / 4.0;
|
||||
|
||||
@ -103,15 +102,18 @@ impl Animation for FlyAnimation {
|
||||
next.chest.position =
|
||||
Vec3::new(0.0, s_a.chest.0, s_a.chest.1 + slow * 0.05) * s_a.scaler / 4.0;
|
||||
next.chest.orientation =
|
||||
Quaternion::rotation_x(-0.5 + slow * 0.05) * Quaternion::rotation_y(tilt * 1.8);
|
||||
Quaternion::rotation_x(-0.5 + slow * 0.05 + (0.8 * velocity.z / 80.0).min(0.8))
|
||||
* Quaternion::rotation_y(tilt * 1.8);
|
||||
|
||||
next.wing_in_l.position = Vec3::new(-s_a.wing_in.0, s_a.wing_in.1, s_a.wing_in.2);
|
||||
next.wing_in_r.position = Vec3::new(s_a.wing_in.0, s_a.wing_in.1, s_a.wing_in.2);
|
||||
|
||||
next.wing_in_l.orientation =
|
||||
Quaternion::rotation_y(0.1 + slow * 0.04) * Quaternion::rotation_x(0.6);
|
||||
Quaternion::rotation_y(0.1 + slow * 0.04 + (0.8 * velocity.z / 80.0).min(0.8))
|
||||
* Quaternion::rotation_x(0.6);
|
||||
next.wing_in_r.orientation =
|
||||
Quaternion::rotation_y(-0.1 + slow * -0.04) * Quaternion::rotation_x(0.6);
|
||||
Quaternion::rotation_y(-0.1 + slow * -0.04 - (0.8 * velocity.z / 80.0).min(0.8))
|
||||
* Quaternion::rotation_x(0.6);
|
||||
|
||||
next.wing_mid_l.position = Vec3::new(-s_a.wing_mid.0, s_a.wing_mid.1, s_a.wing_mid.2);
|
||||
next.wing_mid_r.position = Vec3::new(s_a.wing_mid.0, s_a.wing_mid.1, s_a.wing_mid.2);
|
||||
@ -120,8 +122,10 @@ impl Animation for FlyAnimation {
|
||||
|
||||
next.wing_out_l.position = Vec3::new(-s_a.wing_out.0, s_a.wing_out.1, s_a.wing_out.2);
|
||||
next.wing_out_r.position = Vec3::new(s_a.wing_out.0, s_a.wing_out.1, s_a.wing_out.2);
|
||||
next.wing_out_l.orientation = Quaternion::rotation_y(0.1 + slow * 0.04);
|
||||
next.wing_out_r.orientation = Quaternion::rotation_y(-0.1 + slow * -0.04);
|
||||
next.wing_out_l.orientation =
|
||||
Quaternion::rotation_y(0.1 + slow * 0.04 + (0.4 * velocity.z / 80.0).min(0.2));
|
||||
next.wing_out_r.orientation =
|
||||
Quaternion::rotation_y(-0.1 + slow * -0.04 - (0.4 * velocity.z / 80.0).min(0.2));
|
||||
|
||||
next.tail_front.position = Vec3::new(0.0, s_a.tail_front.0, s_a.tail_front.1);
|
||||
next.tail_front.orientation =
|
||||
@ -131,9 +135,9 @@ impl Animation for FlyAnimation {
|
||||
Quaternion::rotation_x(-0.2 + slow * 0.08) * Quaternion::rotation_z(-tilt * 1.0);
|
||||
}
|
||||
|
||||
next.leg_l.position = Vec3::new(-s_a.leg.0, s_a.leg.1, s_a.leg.2 + 3.0);
|
||||
next.leg_l.position = Vec3::new(-s_a.leg.0, s_a.leg.1, s_a.leg.2);
|
||||
next.leg_l.orientation = Quaternion::rotation_x(-1.0 - flap1 * 0.1);
|
||||
next.leg_r.position = Vec3::new(s_a.leg.0, s_a.leg.1, s_a.leg.2 + 3.0);
|
||||
next.leg_r.position = Vec3::new(s_a.leg.0, s_a.leg.1, s_a.leg.2);
|
||||
next.leg_r.orientation = Quaternion::rotation_x(-1.0 - flap1 * 0.1);
|
||||
|
||||
next.foot_l.position = Vec3::new(-s_a.foot.0, s_a.foot.1, s_a.foot.2);
|
||||
|
@ -2,6 +2,7 @@ use super::{
|
||||
super::{vek::*, Animation},
|
||||
BirdLargeSkeleton, SkeletonAttr,
|
||||
};
|
||||
use std::ops::Mul;
|
||||
|
||||
pub struct IdleAnimation;
|
||||
|
||||
@ -15,43 +16,41 @@ impl Animation for IdleAnimation {
|
||||
#[cfg_attr(feature = "be-dyn-lib", export_name = "bird_large_idle")]
|
||||
fn update_skeleton_inner(
|
||||
skeleton: &Self::Skeleton,
|
||||
_global_time: Self::Dependency,
|
||||
global_time: Self::Dependency,
|
||||
anim_time: f32,
|
||||
_rate: &mut f32,
|
||||
s_a: &SkeletonAttr,
|
||||
) -> Self::Skeleton {
|
||||
let mut next = (*skeleton).clone();
|
||||
|
||||
let fast = anim_time * 4.0;
|
||||
|
||||
let freq = 8.0;
|
||||
let off2 = -1.7;
|
||||
let off3 = -2.0;
|
||||
let off4 = -2.4;
|
||||
let flap1 = 7.0 / 16.0 * (freq * anim_time).sin()
|
||||
+ 7.0 / 64.0 * (freq * 2.0 * anim_time).sin()
|
||||
+ 1.0 / 48.0 * (freq * 3.0 * anim_time).sin();
|
||||
let flap2 = 7.0 / 16.0 * (freq * anim_time + off2).sin()
|
||||
+ 7.0 / 64.0 * (freq * 2.0 * anim_time + off2).sin()
|
||||
+ 1.0 / 48.0 * (freq * 3.0 * anim_time + off2).sin();
|
||||
let flap3 = 7.0 / 16.0 * (freq * anim_time + off3).sin()
|
||||
+ 7.0 / 64.0 * (freq * 2.0 * anim_time + off3).sin()
|
||||
+ 1.0 / 48.0 * (freq * 3.0 * anim_time + off3).sin();
|
||||
let flap4 = 7.0 / 16.0 * (freq * anim_time + off4).sin()
|
||||
+ 7.0 / 64.0 * (freq * 2.0 * anim_time + off4).sin()
|
||||
+ 1.0 / 48.0 * (freq * 3.0 * anim_time + off4).sin();
|
||||
let duck_head_look = Vec2::new(
|
||||
(global_time / 2.0 + anim_time / 8.0)
|
||||
.floor()
|
||||
.mul(7331.0)
|
||||
.sin()
|
||||
* 0.5,
|
||||
(global_time / 2.0 + anim_time / 8.0)
|
||||
.floor()
|
||||
.mul(1337.0)
|
||||
.sin()
|
||||
* 0.25,
|
||||
);
|
||||
let wave_slow_cos = (anim_time * 4.5).cos();
|
||||
|
||||
next.chest.scale = Vec3::one() * s_a.scaler / 4.0;
|
||||
next.chest.position = Vec3::new(0.0, s_a.chest.0, s_a.chest.1) * s_a.scaler / 4.0;
|
||||
next.chest.position =
|
||||
Vec3::new(0.0, s_a.chest.0, s_a.chest.1 + wave_slow_cos * 0.06) * s_a.scaler / 4.0;
|
||||
next.chest.orientation = Quaternion::rotation_x(0.0);
|
||||
|
||||
next.neck.position = Vec3::new(0.0, s_a.neck.0, s_a.neck.1);
|
||||
next.neck.orientation = Quaternion::rotation_x(0.0);
|
||||
|
||||
next.head.position = Vec3::new(0.0, s_a.head.0, s_a.head.1);
|
||||
next.head.orientation = Quaternion::rotation_x(0.0);
|
||||
next.head.orientation = Quaternion::rotation_z(duck_head_look.x)
|
||||
* Quaternion::rotation_x(-duck_head_look.y.abs() + wave_slow_cos * 0.01);
|
||||
|
||||
next.beak.position = Vec3::new(0.0, s_a.beak.0, s_a.beak.1);
|
||||
next.beak.orientation = Quaternion::rotation_x(wave_slow_cos * -0.02 - 0.02);
|
||||
|
||||
next.tail_front.position = Vec3::new(0.0, s_a.tail_front.0, s_a.tail_front.1);
|
||||
next.tail_front.orientation = Quaternion::rotation_x(0.0);
|
||||
@ -61,22 +60,24 @@ impl Animation for IdleAnimation {
|
||||
next.wing_in_l.position = Vec3::new(-s_a.wing_in.0, s_a.wing_in.1, s_a.wing_in.2);
|
||||
next.wing_in_r.position = Vec3::new(s_a.wing_in.0, s_a.wing_in.1, s_a.wing_in.2);
|
||||
|
||||
next.wing_in_l.orientation = Quaternion::rotation_y(0.0);
|
||||
next.wing_in_r.orientation = Quaternion::rotation_y(0.0) * Quaternion::rotation_x(0.0);
|
||||
next.wing_in_l.orientation =
|
||||
Quaternion::rotation_y(-1.3 + wave_slow_cos * 0.06) * Quaternion::rotation_z(0.2);
|
||||
next.wing_in_r.orientation =
|
||||
Quaternion::rotation_y(1.3 - wave_slow_cos * 0.06) * Quaternion::rotation_z(-0.2);
|
||||
|
||||
next.wing_mid_l.position = Vec3::new(-s_a.wing_mid.0, s_a.wing_mid.1, s_a.wing_mid.2);
|
||||
next.wing_mid_r.position = Vec3::new(s_a.wing_mid.0, s_a.wing_mid.1, s_a.wing_mid.2);
|
||||
next.wing_mid_l.orientation = Quaternion::rotation_y(0.0);
|
||||
next.wing_mid_r.orientation = Quaternion::rotation_y(0.0);
|
||||
next.wing_mid_l.orientation = Quaternion::rotation_y(-0.1) * Quaternion::rotation_z(0.7);
|
||||
next.wing_mid_r.orientation = Quaternion::rotation_y(0.1) * Quaternion::rotation_z(-0.7);
|
||||
|
||||
next.wing_out_l.position = Vec3::new(-s_a.wing_out.0, s_a.wing_out.1, s_a.wing_out.2);
|
||||
next.wing_out_r.position = Vec3::new(s_a.wing_out.0, s_a.wing_out.1, s_a.wing_out.2);
|
||||
next.wing_out_l.orientation = Quaternion::rotation_y(0.0);
|
||||
next.wing_out_r.orientation = Quaternion::rotation_y(0.0);
|
||||
next.wing_out_l.orientation = Quaternion::rotation_y(-0.2) * Quaternion::rotation_z(0.2);
|
||||
next.wing_out_r.orientation = Quaternion::rotation_y(0.2) * Quaternion::rotation_z(-0.2);
|
||||
|
||||
next.leg_l.position = Vec3::new(-s_a.leg.0, s_a.leg.1, s_a.leg.2 + 3.0);
|
||||
next.leg_l.position = Vec3::new(-s_a.leg.0, s_a.leg.1, s_a.leg.2 - wave_slow_cos * 0.06);
|
||||
next.leg_l.orientation = Quaternion::rotation_x(0.0);
|
||||
next.leg_r.position = Vec3::new(s_a.leg.0, s_a.leg.1, s_a.leg.2 + 3.0);
|
||||
next.leg_r.position = Vec3::new(s_a.leg.0, s_a.leg.1, s_a.leg.2 - wave_slow_cos * 0.06);
|
||||
next.leg_r.orientation = Quaternion::rotation_x(0.0);
|
||||
|
||||
next.foot_l.position = Vec3::new(-s_a.foot.0, s_a.foot.1, s_a.foot.2);
|
||||
|
@ -134,13 +134,13 @@ impl<'a> From<&'a Body> for SkeletonAttr {
|
||||
use comp::bird_large::Species::*;
|
||||
Self {
|
||||
chest: match (body.species, body.body_type) {
|
||||
(Phoenix, _) => (2.5, 8.5),
|
||||
(Phoenix, _) => (2.5, 7.5),
|
||||
},
|
||||
neck: match (body.species, body.body_type) {
|
||||
(Phoenix, _) => (0.5, 3.0),
|
||||
},
|
||||
head: match (body.species, body.body_type) {
|
||||
(Phoenix, _) => (2.0, 3.0),
|
||||
(Phoenix, _) => (2.0, 2.0),
|
||||
},
|
||||
beak: match (body.species, body.body_type) {
|
||||
(Phoenix, _) => (2.0, 1.0),
|
||||
@ -152,7 +152,7 @@ impl<'a> From<&'a Body> for SkeletonAttr {
|
||||
(Phoenix, _) => (-3.0, -3.0),
|
||||
},
|
||||
wing_in: match (body.species, body.body_type) {
|
||||
(Phoenix, _) => (3.0, 2.5, 4.0),
|
||||
(Phoenix, _) => (3.0, 2.5, 3.0),
|
||||
},
|
||||
wing_mid: match (body.species, body.body_type) {
|
||||
(Phoenix, _) => (6.5, -1.0, 0.0),
|
||||
@ -161,7 +161,7 @@ impl<'a> From<&'a Body> for SkeletonAttr {
|
||||
(Phoenix, _) => (0.5, -1.0, 0.0),
|
||||
},
|
||||
leg: match (body.species, body.body_type) {
|
||||
(Phoenix, _) => (2.5, -2.5, -6.5),
|
||||
(Phoenix, _) => (2.5, -2.5, -3.5),
|
||||
},
|
||||
foot: match (body.species, body.body_type) {
|
||||
(Phoenix, _) => (2.5, -16.5, -6.5),
|
||||
|
@ -28,7 +28,7 @@ impl Animation for RunAnimation {
|
||||
//let speednorm = speed / 13.0;
|
||||
let speednorm = (speed / 13.0).powf(0.25);
|
||||
|
||||
let speedmult = 1.0;
|
||||
let speedmult = 2.0;
|
||||
let lab: f32 = 0.6; //6
|
||||
|
||||
let short = ((1.0
|
||||
@ -60,7 +60,6 @@ impl Animation for RunAnimation {
|
||||
} else {
|
||||
0.0
|
||||
} * 1.3;
|
||||
let x_tilt = avg_vel.z.atan2(avg_vel.xy().magnitude()) * speednorm;
|
||||
|
||||
next.head.scale = Vec3::one() * 1.02;
|
||||
next.neck.scale = Vec3::one() * 0.98;
|
||||
@ -71,52 +70,66 @@ impl Animation for RunAnimation {
|
||||
|
||||
next.head.position = Vec3::new(0.0, s_a.head.0, s_a.head.1);
|
||||
next.head.orientation = Quaternion::rotation_x(-0.1 * speednorm + short * -0.05)
|
||||
* Quaternion::rotation_y(tilt * 0.8)
|
||||
* Quaternion::rotation_z(shortalt * -0.2 - tilt * 2.5);
|
||||
* Quaternion::rotation_y(tilt * 0.2)
|
||||
* Quaternion::rotation_z(shortalt * -0.05 - tilt * 1.5);
|
||||
|
||||
next.beak.position = Vec3::new(0.0, s_a.beak.0, s_a.beak.1);
|
||||
next.beak.orientation = Quaternion::rotation_x(short * -0.03);
|
||||
next.beak.orientation = Quaternion::rotation_x(short * -0.02 - 0.02);
|
||||
|
||||
next.neck.position = Vec3::new(0.0, s_a.neck.0, s_a.neck.1);
|
||||
next.neck.orientation = Quaternion::rotation_x(-0.1 * speednorm + short * -0.04)
|
||||
* Quaternion::rotation_y(tilt * 0.3)
|
||||
* Quaternion::rotation_z(shortalt * -0.1 - tilt * 3.2);
|
||||
* Quaternion::rotation_y(tilt * 0.1)
|
||||
* Quaternion::rotation_z(shortalt * -0.1 - tilt * 0.5);
|
||||
|
||||
next.chest.position = Vec3::new(
|
||||
0.0,
|
||||
s_a.chest.0,
|
||||
s_a.chest.1 + short * 0.5 + x_tilt * 10.0 + 0.5 * speednorm,
|
||||
s_a.chest.1 + short * 0.5 + 0.5 * speednorm,
|
||||
) * s_a.scaler
|
||||
/ 4.0;
|
||||
next.chest.orientation = Quaternion::rotation_x(short * 0.07 + x_tilt)
|
||||
next.chest.orientation = Quaternion::rotation_x(short * 0.07)
|
||||
* Quaternion::rotation_y(tilt * 0.8)
|
||||
* Quaternion::rotation_z(shortalt * 0.15 + tilt * -1.5);
|
||||
* Quaternion::rotation_z(shortalt * 0.10);
|
||||
|
||||
next.tail_front.position = Vec3::new(0.0, s_a.tail_front.0, s_a.tail_front.1);
|
||||
next.tail_front.orientation = Quaternion::rotation_x(0.1 + short * -0.02)
|
||||
* Quaternion::rotation_z(shortalt * -0.1 + tilt * 1.0);
|
||||
next.tail_front.orientation = Quaternion::rotation_x(short * -0.02);
|
||||
|
||||
next.tail_rear.position = Vec3::new(0.0, s_a.tail_rear.0, s_a.tail_rear.1);
|
||||
next.tail_rear.orientation = Quaternion::rotation_x(0.2 + short * -0.1)
|
||||
* Quaternion::rotation_z(shortalt * -0.2 + tilt * 1.4);
|
||||
next.tail_rear.orientation = Quaternion::rotation_x(short * -0.1);
|
||||
|
||||
next.wing_in_l.position = Vec3::new(-s_a.wing_in.0, s_a.wing_in.1, s_a.wing_in.2);
|
||||
next.wing_in_r.position = Vec3::new(s_a.wing_in.0, s_a.wing_in.1, s_a.wing_in.2);
|
||||
|
||||
next.wing_in_l.orientation = Quaternion::rotation_y(-1.3) * Quaternion::rotation_z(0.2);
|
||||
next.wing_in_r.orientation = Quaternion::rotation_y(1.3) * Quaternion::rotation_z(-0.2);
|
||||
|
||||
next.wing_mid_l.position = Vec3::new(-s_a.wing_mid.0, s_a.wing_mid.1, s_a.wing_mid.2);
|
||||
next.wing_mid_r.position = Vec3::new(s_a.wing_mid.0, s_a.wing_mid.1, s_a.wing_mid.2);
|
||||
next.wing_mid_l.orientation = Quaternion::rotation_y(-0.1) * Quaternion::rotation_z(0.7);
|
||||
next.wing_mid_r.orientation = Quaternion::rotation_y(0.1) * Quaternion::rotation_z(-0.7);
|
||||
|
||||
next.wing_out_l.position = Vec3::new(-s_a.wing_out.0, s_a.wing_out.1, s_a.wing_out.2);
|
||||
next.wing_out_r.position = Vec3::new(s_a.wing_out.0, s_a.wing_out.1, s_a.wing_out.2);
|
||||
next.wing_out_l.orientation =
|
||||
Quaternion::rotation_y(-0.2 + short * 0.05) * Quaternion::rotation_z(0.2);
|
||||
next.wing_out_r.orientation =
|
||||
Quaternion::rotation_y(0.2 + short * -0.05) * Quaternion::rotation_z(-0.2);
|
||||
|
||||
next.leg_l.position = Vec3::new(
|
||||
-s_a.leg.0 + speednorm * 1.5,
|
||||
s_a.leg.1 + foot1b * -1.3,
|
||||
s_a.leg.2 + foot1a * 1.0,
|
||||
s_a.leg.1 + foot1b * -2.3,
|
||||
s_a.leg.2,
|
||||
);
|
||||
next.leg_l.orientation = Quaternion::rotation_x(-0.2 * speednorm + foot1a * 0.15)
|
||||
* Quaternion::rotation_y(tilt * 0.5)
|
||||
* Quaternion::rotation_z(foot1a * -0.3 + tilt * -0.5);
|
||||
* Quaternion::rotation_y(tilt * 0.5);
|
||||
|
||||
next.leg_r.position = Vec3::new(
|
||||
s_a.leg.0 + speednorm * -1.5,
|
||||
s_a.leg.1 + foot2b * -1.3,
|
||||
s_a.leg.2 + foot2a * 1.0,
|
||||
s_a.leg.1 + foot2b * -2.3,
|
||||
s_a.leg.2,
|
||||
);
|
||||
next.leg_r.orientation = Quaternion::rotation_x(-0.2 * speednorm + foot2a * 0.15)
|
||||
* Quaternion::rotation_y(tilt * 0.5)
|
||||
* Quaternion::rotation_z(foot2a * 0.3 + tilt * -0.5);
|
||||
* Quaternion::rotation_y(tilt * 0.5);
|
||||
|
||||
next.foot_l.position = Vec3::new(
|
||||
-s_a.foot.0,
|
||||
|
@ -3382,7 +3382,7 @@ impl BirdLargeLateralSpec {
|
||||
return load_mesh("not_found", Vec3::new(-5.0, -5.0, -2.5));
|
||||
},
|
||||
};
|
||||
let lateral = graceful_load_segment(&spec.wing_in_l.lateral.0);
|
||||
let lateral = graceful_load_segment(&spec.wing_mid_r.lateral.0);
|
||||
|
||||
(lateral, Vec3::from(spec.wing_mid_r.offset))
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user