Initial run animation work

This commit is contained in:
Snowram 2020-05-03 18:24:58 +02:00 committed by jshipsey
parent 7f0d1e9543
commit 9027967fb7
8 changed files with 141 additions and 59 deletions

View File

@ -17,37 +17,37 @@
lateral: ("npc.reddragon.male.wing_out_r"),
),
foot_fl: (
offset: (-2.5, 0.0, -6.0),
offset: (-2.5, -4.0, -1.5),
lateral: ("npc.reddragon.male.foot_fl"),
),
foot_fr: (
offset: (-2.5, 0.0, -6.0),
offset: (-2.5, -4.0, -1.5),
lateral: ("npc.reddragon.male.foot_fr"),
),
foot_bl: (
offset: (-2.5, 0.0, -7.0),
offset: (-2.5, -4.0, -3.0),
lateral: ("npc.reddragon.male.foot_bl"),
),
foot_br: (
offset: (-2.5, 0.0, -7.0),
offset: (-2.5, -4.0, -3.0),
lateral: ("npc.reddragon.male.foot_br"),
)
),
(Reddragon, Female): (
wing_in_l: (
offset: (20.0, 20.0, 5.0),
offset: (-0.5, -3.5, -27.0),
lateral: ("npc.reddragon.female.wing_in_l"),
),
wing_in_r: (
offset: (20.0, 20.0, 5.0),
offset: (-0.5, -3.5, -27.0),
lateral: ("npc.reddragon.female.wing_in_r"),
),
wing_out_l: (
offset: (20.0, 20.0, 5.0),
offset: (-0.5, -3.5, -27.0),
lateral: ("npc.reddragon.female.wing_out_l"),
),
wing_out_r: (
offset: (20.0, 20.0, 5.0),
offset: (-0.5, -3.5, -27.0),
lateral: ("npc.reddragon.female.wing_out_r"),
),
foot_fl: (

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -86,7 +86,7 @@ impl Animation for IdleAnimation {
next.wing_out_l.ori = Quaternion::rotation_z(0.0);
next.wing_out_l.scale = Vec3::one() * 1.05;
next.wing_in_r.offset = Vec3::new(
next.wing_out_r.offset = Vec3::new(
skeleton_attr.wing_out.0,
skeleton_attr.wing_out.1,
skeleton_attr.wing_out.2,

View File

@ -33,15 +33,15 @@ const TAIL_R_Z: f32 = 0.0;
#[const_tweaker::tweak(min = -40.0, max = 40.0, step = 0.5)]
const WING_IN_X: f32 = 10.0;
#[const_tweaker::tweak(min = -40.0, max = 40.0, step = 0.5)]
const WING_IN_Y: f32 = -32.5;
const WING_IN_Y: f32 = -28.5;
#[const_tweaker::tweak(min = -40.0, max = 40.0, step = 0.5)]
const WING_IN_Z: f32 = -19.0;
const WING_IN_Z: f32 = 6.0;
#[const_tweaker::tweak(min = -40.0, max = 40.0, step = 0.5)]
const WING_OUT_X: f32 = 0.0;
const WING_OUT_X: f32 = 1.0;
#[const_tweaker::tweak(min = -40.0, max = 40.0, step = 0.5)]
const WING_OUT_Y: f32 = 1.5;
const WING_OUT_Y: f32 = 2.0;
#[const_tweaker::tweak(min = -40.0, max = 40.0, step = 0.5)]
const WING_OUT_Z: f32 = -10.5;
const WING_OUT_Z: f32 = 12.0;
#[const_tweaker::tweak(min = -40.0, max = 40.0, step = 0.5)]
const FEET_F_X: f32 = 4.0;
#[const_tweaker::tweak(min = -40.0, max = 40.0, step = 0.5)]
@ -159,6 +159,7 @@ pub struct SkeletonAttr {
wing_out: (f32, f32, f32),
feet_f: (f32, f32, f32),
feet_b: (f32, f32, f32),
height: f32,
}
impl<'a> std::convert::TryFrom<&'a comp::Body> for SkeletonAttr {
@ -184,6 +185,7 @@ impl Default for SkeletonAttr {
wing_out: (0.0, 0.0, 0.0),
feet_f: (0.0, 0.0, 0.0),
feet_b: (0.0, 0.0, 0.0),
height: (0.0),
}
}
}
@ -219,6 +221,9 @@ impl<'a> From<&'a comp::dragon::Body> for SkeletonAttr {
feet_b: match (body.species, body.body_type) {
(Reddragon, _) => (*FEET_B_X, *FEET_B_Y, *FEET_B_Z),
},
height: match (body.species, body.body_type) {
(Reddragon, _) => (1.0),
},
}
}
}

View File

@ -1,5 +1,5 @@
use super::{super::Animation, DragonSkeleton, SkeletonAttr};
//use std::{f32::consts::PI, ops::Mul};
use std::{f32::consts::PI, ops::Mul};
use vek::*;
pub struct RunAnimation;
@ -10,64 +10,141 @@ impl Animation for RunAnimation {
fn update_skeleton(
skeleton: &Self::Skeleton,
(_velocity, _global_time): Self::Dependency,
_anim_time: f64,
(_velocity, global_time): Self::Dependency,
anim_time: f64,
_rate: &mut f32,
_skeleton_attr: &SkeletonAttr,
skeleton_attr: &SkeletonAttr,
) -> Self::Skeleton {
let mut next = (*skeleton).clone();
next.head.offset = Vec3::new(0.0, 7.5, 15.0) / 11.0;
next.head.ori = Quaternion::rotation_z(0.0) * Quaternion::rotation_x(0.0);
next.head.scale = Vec3::one() * 1.01;
let lab = 14;
let vertlf = (anim_time as f32 * lab as f32 + PI * 1.8).sin().max(0.15);
let vertrfoffset = (anim_time as f32 * lab as f32 + PI * 0.80).sin().max(0.15);
let vertlboffset = (anim_time as f32 * lab as f32).sin().max(0.15);
let vertrb = (anim_time as f32 * lab as f32 + PI).sin().max(0.15);
next.chest_front.offset = Vec3::new(0.0, 4.5, 2.0);
next.chest_front.ori = Quaternion::rotation_x(0.0);
next.chest_front.scale = Vec3::one() * 1.01;
let horilf = (anim_time as f32 * lab as f32 + PI * 1.2).sin();
let horirfoffset = (anim_time as f32 * lab as f32 + PI * 0.20).sin();
let horilboffset = (anim_time as f32 * lab as f32 + PI * 1.4).sin();
let horirb = (anim_time as f32 * lab as f32 + PI * 0.4).sin();
next.chest_rear.offset = Vec3::new(0.0, 4.5, 2.0);
next.chest_rear.ori = Quaternion::rotation_x(0.0);
next.chest_rear.scale = Vec3::one() * 1.01;
let vertchest = (anim_time as f32 * lab as f32 + PI * 0.3).sin().max(0.2);
let horichest = (anim_time as f32 * lab as f32 + PI * 0.8).sin();
let verthead = (anim_time as f32 * lab as f32 + PI * 0.3).sin();
next.tail_front.offset = Vec3::new(0.0, 4.5, 2.0);
let footl = (anim_time as f32 * lab as f32 + PI).sin();
let footr = (anim_time as f32 * lab as f32).sin();
let wolf_look = Vec2::new(
((global_time + anim_time) as f32 / 4.0)
.floor()
.mul(7331.0)
.sin()
* 0.25,
((global_time + anim_time) as f32 / 4.0)
.floor()
.mul(1337.0)
.sin()
* 0.125,
);
next.head.offset = Vec3::new(
0.0,
skeleton_attr.head.0 + horichest * 0.9,
skeleton_attr.head.1 + verthead * -0.9,
) * 1.05;
next.head.ori =
Quaternion::rotation_x(wolf_look.y) * Quaternion::rotation_z(wolf_look.x);
next.head.scale = Vec3::one() * 1.05;
next.tail_front.offset = Vec3::new(0.0, skeleton_attr.tail_front.0, skeleton_attr.tail_front.1);
next.tail_front.ori = Quaternion::rotation_x(0.0);
next.tail_front.scale = Vec3::one() * 1.01;
next.tail_front.scale = Vec3::one();
next.tail_rear.offset = Vec3::new(0.0, 4.5, 2.0);
next.tail_rear.offset = Vec3::new(0.0, skeleton_attr.tail_rear.0, skeleton_attr.tail_rear.1);
next.tail_rear.ori = Quaternion::rotation_x(0.0);
next.tail_rear.scale = Vec3::one() * 1.01;
next.tail_rear.scale = Vec3::one();
next.wing_in_l.offset = Vec3::new(0.0, 4.5, 2.0);
next.wing_in_l.ori = Quaternion::rotation_x(0.0);
next.wing_in_l.scale = Vec3::one() * 1.01;
next.chest_front.offset = Vec3::new(
0.0,
skeleton_attr.chest_front.0 + horichest * 1.25,
skeleton_attr.chest_front.1 + vertchest * -1.6 + 1.0,
) * 1.05;
next.chest_front.ori = Quaternion::rotation_y(horichest * -0.09);
next.chest_front.scale = Vec3::one() * 0.98 * 1.05;
next.wing_in_r.offset = Vec3::new(0.0, 4.5, 2.0);
next.wing_in_r.ori = Quaternion::rotation_x(0.0);
next.wing_in_r.scale = Vec3::one() * 1.01;
next.chest_rear.offset = Vec3::new(
0.0,
skeleton_attr.chest_rear.0 + horichest * 1.25,
skeleton_attr.chest_rear.1 + vertchest * -1.6 + 1.0,
) * 1.05;
next.chest_rear.ori = Quaternion::rotation_y(horichest * -0.09);
next.chest_rear.scale = Vec3::one() * 0.98 * 1.05;
next.wing_out_l.offset = Vec3::new(0.0, 4.5, 2.0);
next.wing_out_l.ori = Quaternion::rotation_x(0.0);
next.wing_out_l.scale = Vec3::one() * 1.01;
next.foot_fl.offset = Vec3::new(
-skeleton_attr.feet_f.0,
skeleton_attr.feet_f.1 + horilf * 2.5,
skeleton_attr.feet_f.2 + vertlf * 5.0 * skeleton_attr.height - 0.5,
) * 1.05;
next.foot_fl.ori = Quaternion::rotation_x(horilf * 0.4);
next.foot_fl.scale = Vec3::one() * 1.05;
next.wing_out_r.offset = Vec3::new(0.0, 4.5, 2.0);
next.wing_out_r.ori = Quaternion::rotation_x(0.0);
next.wing_out_r.scale = Vec3::one() * 1.01;
next.foot_fr.offset = Vec3::new(
skeleton_attr.feet_f.0,
skeleton_attr.feet_f.1 + horirfoffset * 2.5,
skeleton_attr.feet_f.2 + vertrfoffset * 5.0 * skeleton_attr.height - 0.5,
) * 1.05;
next.foot_fr.ori = Quaternion::rotation_x(horirfoffset * 0.4);
next.foot_fr.scale = Vec3::one() * 1.05;
next.foot_fl.offset = Vec3::new(0.0, 4.5, 2.0);
next.foot_fl.ori = Quaternion::rotation_x(0.0);
next.foot_fl.scale = Vec3::one() * 1.01;
next.foot_bl.offset = Vec3::new(
-skeleton_attr.feet_b.0,
skeleton_attr.feet_b.1 + horilboffset * 3.0,
skeleton_attr.feet_b.2 + vertlboffset * 5.0 * skeleton_attr.height - 0.5,
) * 1.05;
next.foot_bl.ori = Quaternion::rotation_x(horilboffset * 0.35);
next.foot_bl.scale = Vec3::one() * 1.05;
next.foot_fr.offset = Vec3::new(0.0, 4.5, 2.0);
next.foot_fr.ori = Quaternion::rotation_x(0.0);
next.foot_fr.scale = Vec3::one() * 1.01;
next.foot_br.offset = Vec3::new(
skeleton_attr.feet_b.0,
skeleton_attr.feet_b.1 + horirb * 3.0,
skeleton_attr.feet_b.2 + vertrb * 5.0 * skeleton_attr.height - 0.5,
) * 1.05;
next.foot_br.ori = Quaternion::rotation_x(horirb * 0.35);
next.foot_br.scale = Vec3::one() * 1.05;
next.foot_bl.offset = Vec3::new(0.0, 4.5, 2.0);
next.foot_bl.ori = Quaternion::rotation_x(0.0);
next.foot_bl.scale = Vec3::one() * 1.01;
next.wing_in_l.offset = Vec3::new(
-skeleton_attr.wing_in.0,
skeleton_attr.wing_in.1,
skeleton_attr.wing_in.2,
);
next.wing_in_l.ori = Quaternion::rotation_y((footl * 0.35).max(0.0));
next.wing_in_l.scale = Vec3::one() * 1.05;
next.wing_in_r.offset = Vec3::new(
skeleton_attr.wing_in.0,
skeleton_attr.wing_in.1,
skeleton_attr.wing_in.2,
);
next.wing_in_r.ori = Quaternion::rotation_y((footr * 0.35).max(0.0));
next.wing_in_r.scale = Vec3::one() * 1.05;
next.wing_out_l.offset = Vec3::new(
-skeleton_attr.wing_out.0,
skeleton_attr.wing_out.1,
skeleton_attr.wing_out.2,
);
next.wing_out_l.ori = Quaternion::rotation_y((footl * 0.35).max(0.0));
next.wing_out_l.scale = Vec3::one() * 1.05;
next.wing_out_r.offset = Vec3::new(
skeleton_attr.wing_out.0,
skeleton_attr.wing_out.1,
skeleton_attr.wing_out.2,
);
next.wing_out_r.ori = Quaternion::rotation_y((footr * 0.35).max(0.0));
next.wing_out_r.scale = Vec3::one() * 1.05;
next.foot_br.offset = Vec3::new(0.0, 4.5, 2.0);
next.foot_br.ori = Quaternion::rotation_x(0.0);
next.foot_br.scale = Vec3::one() * 1.01;
next
}
}