new models, shockwave anim

This commit is contained in:
jshipsey 2020-09-03 01:08:16 -04:00
parent 03b7320b4b
commit 789d93b52f
12 changed files with 232 additions and 105 deletions

View File

@ -2,10 +2,12 @@ pub mod alpha;
pub mod idle;
pub mod jump;
pub mod run;
pub mod shockwave;
// Reexports
pub use self::{
alpha::AlphaAnimation, idle::IdleAnimation, jump::JumpAnimation, run::RunAnimation,
shockwave::ShockwaveAnimation,
};
use super::{make_bone, vek::*, FigureBoneData, Skeleton};

View File

@ -0,0 +1,136 @@
use super::{
super::{vek::*, Animation},
GolemSkeleton, SkeletonAttr,
};
use std::f32::consts::PI;
pub struct ShockwaveAnimation;
impl Animation for ShockwaveAnimation {
type Dependency = (f32, f64);
type Skeleton = GolemSkeleton;
#[cfg(feature = "use-dyn-lib")]
const UPDATE_FN: &'static [u8] = b"golem_shockwave\0";
#[cfg_attr(feature = "be-dyn-lib", export_name = "golem_shockwave")]
fn update_skeleton_inner(
skeleton: &Self::Skeleton,
(velocity, _global_time): Self::Dependency,
anim_time: f64,
_rate: &mut f32,
skeleton_attr: &SkeletonAttr,
) -> Self::Skeleton {
let mut next = (*skeleton).clone();
let lab = 1.0;
let breathe = (anim_time as f32 * lab as f32 + 1.5 * PI).sin();
let twist = anim_time as f32 * lab as f32 * 2.5;
let slower = (((1.0)
/ (0.00001
+ 0.9999
* ((anim_time as f32 * lab as f32 * 2.0 - 0.5 * PI).sin()).powf(2.0 as f32)))
.sqrt())
* ((anim_time as f32 * lab as f32 * 2.0 - 0.5 * PI).sin())
+ 1.0;
next.head.position = Vec3::new(0.0, skeleton_attr.head.0, skeleton_attr.head.1) * 1.02;
next.head.orientation =
Quaternion::rotation_z((-twist * 2.0).max(-3.14)) * Quaternion::rotation_x(0.0);
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 + slower * -3.0 + breathe * 1.0,
) / 8.0;
next.upper_torso.orientation =
Quaternion::rotation_z((twist * 2.0).min(3.14)) * Quaternion::rotation_x(0.0);
next.upper_torso.scale = Vec3::one() / 8.0;
next.lower_torso.position = Vec3::new(
0.0,
skeleton_attr.lower_torso.0,
skeleton_attr.lower_torso.1 + slower * 1.0,
);
next.lower_torso.orientation =
Quaternion::rotation_z((-twist * 2.0).max(-3.14)) * Quaternion::rotation_x(0.0);
next.lower_torso.scale = Vec3::one();
next.shoulder_l.position = Vec3::new(
-skeleton_attr.shoulder.0 - 2.0,
skeleton_attr.shoulder.1,
skeleton_attr.shoulder.2 - slower * 1.0,
);
next.shoulder_l.orientation =
Quaternion::rotation_z(0.0) * Quaternion::rotation_y(0.6 + slower * -0.3);
next.shoulder_l.scale = Vec3::one();
next.shoulder_r.position = Vec3::new(
skeleton_attr.shoulder.0 + 2.0,
skeleton_attr.shoulder.1,
skeleton_attr.shoulder.2 - slower * 1.0,
);
next.shoulder_r.orientation =
Quaternion::rotation_z(0.0) * Quaternion::rotation_y(-0.6 + slower * 0.3);
next.shoulder_r.scale = Vec3::one();
next.hand_l.position = Vec3::new(
-skeleton_attr.hand.0 - 1.0,
skeleton_attr.hand.1,
skeleton_attr.hand.2 - slower * 0.5 + breathe * -1.0,
);
next.hand_l.orientation =
Quaternion::rotation_z(0.0) * Quaternion::rotation_y(-0.6 + slower * 0.3);
next.hand_l.scale = Vec3::one() * 1.02;
next.hand_r.position = Vec3::new(
skeleton_attr.hand.0 + 1.0,
skeleton_attr.hand.1,
skeleton_attr.hand.2 - slower * 0.5 + breathe * -1.0,
);
next.hand_r.orientation =
Quaternion::rotation_z(0.0) * Quaternion::rotation_y(0.6 + slower * -0.3);
next.hand_r.scale = Vec3::one() * 1.02;
if velocity < 0.5 {
next.leg_l.position = Vec3::new(
-skeleton_attr.leg.0,
skeleton_attr.leg.1,
skeleton_attr.leg.2 + slower * -0.5,
) * 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_r.position = Vec3::new(
skeleton_attr.leg.0,
skeleton_attr.leg.1,
skeleton_attr.leg.2 + slower * -0.5,
) * 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.foot_l.position = Vec3::new(
-skeleton_attr.foot.0,
skeleton_attr.foot.1,
skeleton_attr.foot.2 + slower * 2.5 + breathe * -1.0,
);
next.foot_l.orientation = Quaternion::rotation_z(0.0) * Quaternion::rotation_x(0.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 + slower * 2.5 + breathe * -1.0,
);
next.foot_r.orientation = Quaternion::rotation_z(0.0) * Quaternion::rotation_x(0.0);
next.foot_r.scale = Vec3::one();
next.torso.position = Vec3::new(0.0, 0.0, 0.0);
next.torso.orientation = Quaternion::rotation_z(0.0) * Quaternion::rotation_x(0.0);
next.torso.scale = Vec3::one();
} else {
}
next
}
}

View File

@ -32,14 +32,12 @@ impl Animation for AlphaAnimation {
.sqrt())
* ((anim_time as f32 * 4.0 + PI * 0.5).sin());
next.head.position =
Vec3::new(0.0, skeleton_attr.head.0, skeleton_attr.head.1);
next.head.position = Vec3::new(0.0, skeleton_attr.head.0, skeleton_attr.head.1);
next.head.orientation =
Quaternion::rotation_y(short * -0.2) * Quaternion::rotation_x(0.1 + short * 0.2);
next.head.scale = Vec3::one();
next.neck.position =
Vec3::new(0.0, skeleton_attr.neck.0, skeleton_attr.neck.1);
next.neck.position = Vec3::new(0.0, skeleton_attr.neck.0, skeleton_attr.neck.1);
next.neck.orientation = Quaternion::rotation_z(0.0) * Quaternion::rotation_x(0.0);
next.neck.scale = Vec3::one() * 1.02;

View File

@ -22,13 +22,11 @@ impl Animation for JumpAnimation {
) -> Self::Skeleton {
let mut next = (*skeleton).clone();
next.head.position =
Vec3::new(0.0, skeleton_attr.head.0, skeleton_attr.head.1);
next.head.position = Vec3::new(0.0, skeleton_attr.head.0, skeleton_attr.head.1);
next.head.orientation = Quaternion::rotation_z(0.4) * Quaternion::rotation_x(0.3);
next.head.scale = Vec3::one();
next.neck.position =
Vec3::new(0.0, skeleton_attr.neck.0, skeleton_attr.neck.1);
next.neck.position = Vec3::new(0.0, skeleton_attr.neck.0, skeleton_attr.neck.1);
next.neck.orientation = Quaternion::rotation_z(0.2) * Quaternion::rotation_x(0.3);
next.neck.scale = Vec3::one() * 1.02;

View File

@ -90,7 +90,6 @@ pub struct SkeletonAttr {
feet_b: (f32, f32, f32),
scaler: f32,
startangle: f32,
maximize: f32,
tempo: f32,
spring: f32,
}
@ -122,7 +121,6 @@ impl Default for SkeletonAttr {
feet_b: (0.0, 0.0, 0.0),
scaler: 0.0,
startangle: 0.0,
maximize: 0.0,
tempo: 0.0,
spring: 0.0,
}
@ -301,7 +299,7 @@ impl<'a> From<&'a Body> for SkeletonAttr {
},
scaler: match (body.species, body.body_type) {
(Grolgar, _) => (1.3),
(Saber, _) => (0.9),
(Saber, _) => (1.1),
(Tuskram, _) => (1.2),
(Lion, _) => (1.3),
(Tarasque, _) => (1.3),
@ -320,31 +318,16 @@ impl<'a> From<&'a Body> for SkeletonAttr {
(Saber, _) => (-0.2),
(Tuskram, _) => (0.3),
(Lion, _) => (0.2),
(Tarasque, _) => (0.2),
(Tarasque, _) => (-0.5),
(Tiger, _) => (0.0),
(Wolf, _) => (0.0),
(Frostfang, _) => (0.0),
(Mouflon, _) => (0.0),
(Catoblepas, _) => (0.2),
(Bonerattler, _) => (0.2),
(Bonerattler, _) => (-0.7),
(Deer, _) => (0.0),
(Hirdrassil, _) => (0.0),
},
maximize: match (body.species, body.body_type) {
(Grolgar, _) => (2.0),
(Saber, _) => (1.5),
(Tuskram, _) => (1.0),
(Lion, _) => (1.1),
(Tarasque, _) => (1.8),
(Tiger, _) => (1.8),
(Wolf, _) => (1.0),
(Frostfang, _) => (1.2),
(Mouflon, _) => (1.1),
(Catoblepas, _) => (0.0),
(Bonerattler, _) => (0.8),
(Deer, _) => (1.1),
(Hirdrassil, _) => (1.1),
},
tempo: match (body.species, body.body_type) {
(Grolgar, _) => (0.95),
(Saber, _) => (1.1),

View File

@ -99,8 +99,7 @@ impl Animation for RunAnimation {
let x_tilt = avg_vel.z.atan2(avg_vel.xy().magnitude());
//Gallop
next.head.position =
Vec3::new(0.0, skeleton_attr.head.0, skeleton_attr.head.1);
next.head.position = Vec3::new(0.0, skeleton_attr.head.0, skeleton_attr.head.1);
next.head.orientation = Quaternion::rotation_x(
look.y * 0.3 / ((canceler).max(0.5)) + amplitude * short * -0.03 - 0.1,
) * Quaternion::rotation_z(
@ -108,8 +107,7 @@ impl Animation for RunAnimation {
) * Quaternion::rotation_y(tilt * 0.8);
next.head.scale = Vec3::one();
next.neck.position =
Vec3::new(0.0, skeleton_attr.neck.0, skeleton_attr.neck.1);
next.neck.position = Vec3::new(0.0, skeleton_attr.neck.0, skeleton_attr.neck.1);
next.neck.orientation = Quaternion::rotation_z(tilt * -0.8)
* Quaternion::rotation_x(amplitude * short * -0.05)
* Quaternion::rotation_y(tilt * 0.3);

View File

@ -25,7 +25,7 @@ impl Animation for IdleAnimation {
let slow = (anim_time as f32 * 3.5).sin();
let slow_alt = (anim_time as f32 * 3.5 + PI).sin();
let slow_alt = (anim_time as f32 * 3.5 + PI / 2.0).sin();
let head_look = Vec2::new(
((global_time + anim_time) as f32 / 8.0)

View File

@ -114,12 +114,12 @@ impl<'a> From<&'a Body> for SkeletonAttr {
(Rabbit, _) => (4.0, 3.0),
(Truffler, _) => (7.5, -9.0),
(Frog, _) => (4.0, 2.0),
(Rat, _) => (6.0, -2.0),
(Axolotl, _) => (7.0, 1.0),
(Gecko, _) => (7.5, 2.0),
(Turtle, _) => (4.0, 3.0),
(Squirrel, _) => (7.5, -9.0),
(Fungome, _) => (4.0, 2.0),
(Rat, _) => (5.0, -1.0),
(Axolotl, _) => (3.0, 2.0),
(Gecko, _) => (4.0, 2.0),
(Turtle, _) => (5.0, -2.0),
(Squirrel, _) => (3.5, 1.0),
(Fungome, _) => (1.5, -1.5),
(Porcupine, _) => (6.0, 1.0),
(Beaver, _) => (5.5, 0.0),
},
@ -140,12 +140,12 @@ impl<'a> From<&'a Body> for SkeletonAttr {
(Rabbit, _) => (-2.0, 6.0),
(Truffler, _) => (-2.0, 16.0),
(Frog, _) => (-2.0, 4.5),
(Rat, _) => (6.0, -2.0),
(Axolotl, _) => (7.0, 1.0),
(Gecko, _) => (7.5, 2.0),
(Turtle, _) => (4.0, 3.0),
(Squirrel, _) => (7.5, -9.0),
(Fungome, _) => (4.0, 2.0),
(Rat, _) => (6.0, 5.0),
(Axolotl, _) => (3.0, 5.0),
(Gecko, _) => (7.5, 3.0),
(Turtle, _) => (1.0, 6.0),
(Squirrel, _) => (4.0, 5.0),
(Fungome, _) => (4.0, 4.0),
(Porcupine, _) => (2.0, 11.0),
(Beaver, _) => (2.0, 6.0),
},
@ -166,12 +166,12 @@ impl<'a> From<&'a Body> for SkeletonAttr {
(Rabbit, _) => (3.0, 3.0, -3.0),
(Truffler, _) => (2.5, 5.0, -9.0),
(Frog, _) => (4.5, 6.5, 0.0),
(Rat, _) => (6.0, -2.0, 0.0),
(Axolotl, _) => (7.0, 1.0, 0.0),
(Gecko, _) => (7.5, 2.0, 0.0),
(Turtle, _) => (4.0, 3.0, 0.0),
(Squirrel, _) => (7.5, -9.0, 0.0),
(Fungome, _) => (4.0, 2.0, 0.0),
(Rat, _) => (5.0, 2.5, -1.0),
(Axolotl, _) => (2.0, 2.0, -2.0),
(Gecko, _) => (2.0, 4.0, 0.0),
(Turtle, _) => (5.0, 4.0, -2.0),
(Squirrel, _) => (3.5, 3.0, -1.0),
(Fungome, _) => (3.0, 2.0, -1.0),
(Porcupine, _) => (4.0, 6.5, -9.0),
(Beaver, _) => (4.5, 4.5, -4.0),
},
@ -192,12 +192,12 @@ impl<'a> From<&'a Body> for SkeletonAttr {
(Rabbit, _) => (3.5, -2.0, -1.0),
(Truffler, _) => (3.0, -5.0, -9.5),
(Frog, _) => (5.0, -3.5, 0.0),
(Rat, _) => (6.0, -2.0, 0.0),
(Axolotl, _) => (7.0, 1.0, 0.0),
(Gecko, _) => (7.5, 2.0, 0.0),
(Turtle, _) => (4.0, 3.0, 0.0),
(Squirrel, _) => (7.5, -9.0, 0.0),
(Fungome, _) => (4.0, 2.0, 0.0),
(Rat, _) => (5.0, -2.0, 1.0),
(Axolotl, _) => (2.0, -3.0, -2.0),
(Gecko, _) => (1.5, -1.0, 0.0),
(Turtle, _) => (5.5, -2.5, -2.0),
(Squirrel, _) => (3.5, -3.0, 0.0),
(Fungome, _) => (3.0, -3.5, -1.0),
(Porcupine, _) => (4.5, -1.0, -8.0),
(Beaver, _) => (4.0, -2.5, -3.0),
},
@ -218,12 +218,12 @@ impl<'a> From<&'a Body> for SkeletonAttr {
(Rabbit, _) => (-4.0, -0.0),
(Truffler, _) => (0.0, 0.0),
(Frog, _) => (0.0, -0.0),
(Rat, _) => (6.0, -2.0),
(Axolotl, _) => (7.0, 1.0),
(Gecko, _) => (7.5, 2.0),
(Turtle, _) => (4.0, 3.0),
(Squirrel, _) => (7.5, -9.0),
(Fungome, _) => (4.0, 2.0),
(Rat, _) => (-1.0, 2.0),
(Axolotl, _) => (-4.0, -1.0),
(Gecko, _) => (-4.0, 0.0),
(Turtle, _) => (-6.0, -2.0),
(Squirrel, _) => (-5.0, 0.0),
(Fungome, _) => (-4.0, -2.0),
(Porcupine, _) => (-6.0, 1.0),
(Beaver, _) => (-6.5, -1.0),
},
@ -244,12 +244,12 @@ impl<'a> From<&'a Body> for SkeletonAttr {
(Rabbit, _) => (0.7),
(Truffler, _) => (1.0),
(Frog, _) => (0.7),
(Rat, _) => (6.0),
(Axolotl, _) => (7.0),
(Gecko, _) => (7.5),
(Turtle, _) => (4.0),
(Squirrel, _) => (7.5),
(Fungome, _) => (4.0),
(Rat, _) => (0.65),
(Axolotl, _) => (0.65),
(Gecko, _) => (0.7),
(Turtle, _) => (0.9),
(Squirrel, _) => (0.7),
(Fungome, _) => (0.9),
(Porcupine, _) => (1.0),
(Beaver, _) => (1.0),
},
@ -270,12 +270,12 @@ impl<'a> From<&'a Body> for SkeletonAttr {
(Rabbit, _) => (1.15),
(Truffler, _) => (1.0),
(Frog, _) => (1.15),
(Rat, _) => (6.0),
(Axolotl, _) => (7.0),
(Gecko, _) => (7.5),
(Turtle, _) => (4.0),
(Squirrel, _) => (7.5),
(Fungome, _) => (4.0),
(Rat, _) => (1.0),
(Axolotl, _) => (1.2),
(Gecko, _) => (1.1),
(Turtle, _) => (0.9),
(Squirrel, _) => (1.15),
(Fungome, _) => (1.0),
(Porcupine, _) => (1.2),
(Beaver, _) => (1.2),
},
@ -296,12 +296,12 @@ impl<'a> From<&'a Body> for SkeletonAttr {
(Rabbit, _) => (1.3),
(Truffler, _) => (1.0),
(Frog, _) => (1.3),
(Rat, _) => (0.1),
(Axolotl, _) => (0.1),
(Gecko, _) => (0.1),
(Turtle, _) => (0.1),
(Squirrel, _) => (0.1),
(Fungome, _) => (0.1),
(Rat, _) => (1.0),
(Axolotl, _) => (0.9),
(Gecko, _) => (1.0),
(Turtle, _) => (0.8),
(Squirrel, _) => (1.0),
(Fungome, _) => (0.7),
(Porcupine, _) => (1.0),
(Beaver, _) => (1.0),
},
@ -322,12 +322,12 @@ impl<'a> From<&'a Body> for SkeletonAttr {
(Rabbit, _) => (0.8),
(Truffler, _) => (1.0),
(Frog, _) => (0.8),
(Rat, _) => (0.1),
(Axolotl, _) => (0.1),
(Gecko, _) => (0.1),
(Turtle, _) => (0.1),
(Squirrel, _) => (0.1),
(Fungome, _) => (0.1),
(Rat, _) => (1.0),
(Axolotl, _) => (1.0),
(Gecko, _) => (1.0),
(Turtle, _) => (0.8),
(Squirrel, _) => (1.0),
(Fungome, _) => (0.4),
(Porcupine, _) => (0.9),
(Beaver, _) => (0.9),
},
@ -348,12 +348,12 @@ impl<'a> From<&'a Body> for SkeletonAttr {
(Rabbit, _) => (2.5),
(Truffler, _) => (0.8),
(Frog, _) => (2.5),
(Rat, _) => (0.1),
(Axolotl, _) => (0.1),
(Gecko, _) => (0.1),
(Turtle, _) => (0.1),
(Squirrel, _) => (0.1),
(Fungome, _) => (0.1),
(Rat, _) => (1.0),
(Axolotl, _) => (0.8),
(Gecko, _) => (1.0),
(Turtle, _) => (0.7),
(Squirrel, _) => (1.0),
(Fungome, _) => (0.8),
(Porcupine, _) => (1.3),
(Beaver, _) => (1.3),
},
@ -374,12 +374,12 @@ impl<'a> From<&'a Body> for SkeletonAttr {
(Rabbit, _) => (1.2),
(Truffler, _) => (0.6),
(Frog, _) => (0.7),
(Rat, _) => (0.1),
(Axolotl, _) => (0.1),
(Gecko, _) => (0.1),
(Turtle, _) => (0.1),
(Squirrel, _) => (0.1),
(Fungome, _) => (0.1),
(Rat, _) => (1.0),
(Axolotl, _) => (0.8),
(Gecko, _) => (1.0),
(Turtle, _) => (0.7),
(Squirrel, _) => (1.0),
(Fungome, _) => (0.7),
(Porcupine, _) => (1.0),
(Beaver, _) => (1.0),
},

View File

@ -72,11 +72,11 @@ impl Animation for RunAnimation {
next.leg_fl.position = Vec3::new(
-skeleton_attr.feet_f.0,
skeleton_attr.feet_f.1 + footverttf * 3.0 * skeleton_attr.maximize,
skeleton_attr.feet_f.1 + footverttf * 3.0 * skeleton_attr.minimize,
skeleton_attr.feet_f.2 + ((footvertf * -1.5).max(-1.0)),
);
next.leg_fl.orientation =
Quaternion::rotation_x(0.2 + skeleton_attr.minimize * footverttf * 0.65)
Quaternion::rotation_x(0.2 + skeleton_attr.maximize * footverttf * 0.65)
* Quaternion::rotation_z(tilt * -0.5)
* Quaternion::rotation_y(tilt * 1.5);
next.leg_fl.scale = Vec3::one() * 1.02;

View File

@ -1,7 +1,7 @@
use super::{super::Animation, SkeletonAttr, TheropodSkeleton};
//use std::{f32::consts::PI, ops::Mul};
use super::super::vek::*;
use std::{f32::consts::PI, ops::Mul};
use std::ops::Mul;
pub struct IdleAnimation;
@ -23,13 +23,26 @@ impl Animation for IdleAnimation {
let mut next = (*skeleton).clone();
let breathe = (anim_time as f32 * 0.8).sin();
let head_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,
);
next.head.position = Vec3::new(
0.0,
skeleton_attr.head.0,
skeleton_attr.head.1 + breathe * 0.3,
);
next.head.orientation = Quaternion::rotation_x(breathe * 0.1 - 0.1);
next.head.orientation = Quaternion::rotation_x(head_look.y + breathe * 0.1 - 0.1)
* Quaternion::rotation_z(head_look.x);
next.head.scale = Vec3::one() * 1.02;
next.jaw.position = Vec3::new(0.0, skeleton_attr.jaw.0, skeleton_attr.jaw.1);

View File

@ -32,7 +32,6 @@ impl Animation for RunAnimation {
let canceler = speed / topspeed;
let lab = 0.5; //6
let amplitude = (speed / topspeed).max(0.25);
let amplitude2 = (speed * 1.4 / topspeed).max(0.6);
let amplitude3 = (speed / topspeed).max(0.35);
let speedmult = if speed > 0.0 {

View File

@ -1210,7 +1210,7 @@ impl FigureMgr {
let target_base = match (
physics.on_ground,
vel.0.magnitude_squared() > 0.25, // Moving
physics.in_fluid.is_some(), // In water
physics.in_fluid.is_some(), // In water
) {
// Standing
(true, false, false) => {