More biped_large work

This commit is contained in:
Snowram
2020-10-27 00:26:41 +01:00
committed by Robin Gilh
parent f009492319
commit b47f42bad5
16 changed files with 751 additions and 730 deletions

View File

@ -24,7 +24,7 @@ impl Animation for AlphaAnimation {
#[allow(clippy::approx_constant)] // TODO: Pending review in #587 #[allow(clippy::approx_constant)] // TODO: Pending review in #587
fn update_skeleton_inner( fn update_skeleton_inner(
skeleton: &Self::Skeleton, skeleton: &Self::Skeleton,
(active_tool_kind, _second_tool_kind, _velocity, global_time, stage_section): Self::Dependency, (active_tool_kind, _second_tool_kind, velocity, global_time, stage_section): Self::Dependency,
anim_time: f64, anim_time: f64,
rate: &mut f32, rate: &mut f32,
s_a: &SkeletonAttr, s_a: &SkeletonAttr,
@ -35,157 +35,149 @@ impl Animation for AlphaAnimation {
let lab = 1.0; let lab = 1.0;
let (movement1, movement2, movement3) = match stage_section { let (movement1, movement2, movement3) = match stage_section {
Some(StageSection::Buildup) => (anim_time as f32, 0.0, 0.0), Some(StageSection::Buildup) => ((anim_time as f32).powf(0.25), 0.0, 0.0),
Some(StageSection::Swing) => (1.0, anim_time as f32, 0.0), Some(StageSection::Swing) => (1.0, anim_time as f32, 0.0),
Some(StageSection::Recover) => (1.0, 1.0, anim_time as f32), Some(StageSection::Recover) => (1.0, 1.0, (anim_time as f32).powf(4.0)),
_ => (0.0, 0.0, 0.0), _ => (0.0, 0.0, 0.0),
}; };
let foot = (((1.0)
/ (0.2
+ 0.8
* ((anim_time as f32 * lab as f32 * 2.0 * velocity).sin()).powf(2.0 as f32)))
.sqrt())
* ((anim_time as f32 * lab as f32 * 2.0 * velocity).sin());
let slowersmooth = (anim_time as f32 * lab as f32 * 4.0).sin(); let slowersmooth = (anim_time as f32 * lab as f32 * 4.0).sin();
let push = anim_time as f32 * lab as f32 * 4.0;
let slow = (((5.0) let slow = (((5.0)
/ (0.4 + 4.6 * ((anim_time as f32 * lab as f32 * 9.0).sin()).powf(2.0 as f32))) / (0.4 + 4.6 * ((anim_time as f32 * lab as f32 * 9.0).sin()).powf(2.0 as f32)))
.sqrt()) .sqrt())
* ((anim_time as f32 * lab as f32 * 9.0).sin()); * ((anim_time as f32 * lab as f32 * 9.0).sin());
let axe = (((1.0)
let slower = (((1.0) / (0.05 + 0.95 * ((anim_time as f32 * lab as f32 * 8.0).sin()).powf(2.0 as f32)))
/ (0.05
+ 0.95
* ((anim_time as f32 * lab as f32 * 8.0 - 0.5 * PI).sin()).powf(2.0 as f32)))
.sqrt()) .sqrt())
* ((anim_time as f32 * lab as f32 * 8.0 - 0.5 * PI).sin()) * ((anim_time as f32 * lab as f32 * 8.0).sin());
+ 1.0; let slower = (((1.0)
let twist = (anim_time as f32 * lab as f32 * 4.0).sin() + 0.5; / (0.0001 + 0.999 * ((anim_time as f32 * lab as f32 * 4.0).sin()).powf(2.0 as f32)))
.sqrt())
let random = ((((2.0 * ((anim_time as f32 * lab as f32 * 4.0).sin());
* (((global_time as f32 - anim_time as f32) * 10.0)
- (((global_time as f32 - anim_time as f32) * 10.0).round())))
.abs())
* 10.0)
.round())
/ 10.0;
let switch = if random > 0.5 { 1.0 } else { -1.0 };
next.hand_l.scale = Vec3::one() * 1.04;
next.hand_r.scale = Vec3::one() * 1.04;
next.torso.scale = Vec3::one() / 8.0;
next.torso.position = Vec3::new(0.0, 0.0, 0.1);
next.torso.orientation = Quaternion::rotation_z(0.0);
match active_tool_kind { match active_tool_kind {
Some(ToolKind::Sword(_)) => { Some(ToolKind::Sword(_)) => {
next.hand_l.position = Vec3::new(-4.75, -1.0, 2.5); next.main.position = Vec3::new(0.0, 0.0, 0.0);
next.hand_l.orientation = next.main.orientation = Quaternion::rotation_x(0.0);
Quaternion::rotation_x(1.47) * Quaternion::rotation_y(-0.2);
next.hand_r.position = Vec3::new(0.75, -1.5, -0.5);
next.hand_r.orientation =
Quaternion::rotation_x(1.47) * Quaternion::rotation_y(0.3);
next.main.position = Vec3::new(0.0, 5.0, -6.0);
next.main.orientation = Quaternion::rotation_x(-0.1);
next.head.position = Vec3::new(0.0, s_a.head.0, s_a.head.1); next.hand_l.position = Vec3::new(s_a.shl.0, s_a.shl.1, s_a.shl.2);
next.hand_l.orientation =
Quaternion::rotation_x(s_a.shl.3) * Quaternion::rotation_y(s_a.shl.4);
next.hand_r.position = Vec3::new(s_a.shr.0, s_a.shr.1, s_a.shr.2);
next.hand_r.orientation =
Quaternion::rotation_x(s_a.shr.3) * Quaternion::rotation_y(s_a.shr.4);
next.control.position = Vec3::new( next.control.position = Vec3::new(
-7.0, s_a.sc.0,
7.0 + movement1 * -4.0 + movement2 * 16.0 + movement3 * -4.0, s_a.sc.1 + movement1 * -4.0 + movement2 * 16.0 + movement3 * -4.0,
2.0 + movement1 * 1.0, s_a.sc.2 + movement1 * 1.0,
); );
next.control.orientation = Quaternion::rotation_x(movement1 * -0.5) next.control.orientation = Quaternion::rotation_x(s_a.sc.3 + movement1 * -0.5)
* Quaternion::rotation_y(movement1 * -1.0 + movement2 * -0.6 + movement3 * 1.0) * Quaternion::rotation_y(
* Quaternion::rotation_z(movement1 * -1.2 + movement2 * 1.3); s_a.sc.4 + movement1 * -1.0 + movement2 * -0.6 + movement3 * 1.0,
)
* Quaternion::rotation_z(s_a.sc.5 + movement1 * -1.2 + movement2 * 1.3);
next.upper_torso.orientation = Quaternion::rotation_z( next.upper_torso.orientation = Quaternion::rotation_z(
movement1 * 1.5 + (movement2 * 1.75).sin() * -3.0 + movement3 * 0.5, movement1 * 1.5 + (movement2 * 1.75).sin() * -3.0 + movement3 * 0.5,
); );
next.head.position = Vec3::new(0.0, s_a.head.0, s_a.head.1); next.head.position = Vec3::new(0.0 + movement2 * 2.0, s_a.head.0, s_a.head.1);
next.head.orientation = Quaternion::rotation_z( next.head.orientation = Quaternion::rotation_z(
movement1 * -0.9 + (movement2 * 1.75).sin() * 2.5 + movement3 * -0.5, movement1 * -0.9 + (movement2 * 1.75).sin() * 2.5 + movement3 * -0.5,
); );
}, },
Some(ToolKind::Axe(_)) => {
next.head.position = Vec3::new(0.0, 0.0 + s_a.head.0, s_a.head.1);
next.head.orientation = Quaternion::rotation_z(0.1 + axe * 0.2)
* Quaternion::rotation_x(0.0)
* Quaternion::rotation_y(0.2);
next.upper_torso.position = Vec3::new(0.0, 0.0, 7.0);
next.upper_torso.orientation = Quaternion::rotation_z(0.2 + axe * 0.2);
next.lower_torso.position = Vec3::new(0.0, 0.0, -5.0);
next.lower_torso.orientation = Quaternion::rotation_z(0.2 + axe * -0.2);
next.hand_l.position = Vec3::new(-0.5, 0.0, 4.0);
next.hand_l.orientation = Quaternion::rotation_x(PI / 2.0);
next.hand_r.position = Vec3::new(0.5, 0.0, -2.5);
next.hand_r.orientation = Quaternion::rotation_x(PI / 2.0);
next.main.position = Vec3::new(-0.0, -2.0, -1.0);
next.main.orientation = Quaternion::rotation_x(0.0);
next.control.position = Vec3::new(2.0 + axe * -7.0, 11.0, 3.0);
next.control.orientation = Quaternion::rotation_x(1.6)
* Quaternion::rotation_y(-2.0 + axe * 0.5)
* Quaternion::rotation_z(PI * 0.4);
},
Some(ToolKind::Hammer(_)) => { Some(ToolKind::Hammer(_)) => {
next.hand_l.position = next.hand_l.position = Vec3::new(-12.0, 0.0, 0.0);
Vec3::new(-s_a.hand.0 - 7.0, s_a.hand.1 - 7.0, s_a.hand.2 + 10.0);
next.hand_l.orientation = next.hand_l.orientation =
Quaternion::rotation_x(0.57) * Quaternion::rotation_z(1.57); Quaternion::rotation_x(-0.0) * Quaternion::rotation_y(0.0);
next.hand_r.position = Vec3::new(3.0, 0.0, 0.0);
next.hand_r.position = next.hand_r.orientation = Quaternion::rotation_x(0.0) * Quaternion::rotation_y(0.0);
Vec3::new(s_a.hand.0 - 7.0, s_a.hand.1 - 7.0, s_a.hand.2 + 10.0);
next.hand_r.orientation =
Quaternion::rotation_x(0.57) * Quaternion::rotation_z(1.57);
next.main.position = Vec3::new(0.0, 0.0, 0.0); next.main.position = Vec3::new(0.0, 0.0, 0.0);
next.main.orientation = Quaternion::rotation_y(-1.57) * Quaternion::rotation_z(1.0); next.main.orientation =
Quaternion::rotation_y(-1.57) * Quaternion::rotation_z(1.57);
next.head.position = Vec3::new(0.0, s_a.head.0, s_a.head.1);
next.head.orientation = Quaternion::rotation_z(slower * 0.03) next.head.orientation = Quaternion::rotation_z(slower * 0.03)
* Quaternion::rotation_x(-0.3 + slowersmooth * 0.1) * Quaternion::rotation_x(slowersmooth * 0.1)
* Quaternion::rotation_y(slower * 0.05 + slowersmooth * 0.06) * Quaternion::rotation_y(slower * 0.05 + slowersmooth * 0.06)
* Quaternion::rotation_z((slowersmooth * -0.4).max(0.0)); * Quaternion::rotation_z((slowersmooth * -0.4).max(0.0));
next.upper_torso.position = Vec3::new(0.0, s_a.upper_torso.0, s_a.upper_torso.1); next.upper_torso.position = Vec3::new(0.0, s_a.upper_torso.0, s_a.upper_torso.1);
next.upper_torso.orientation = next.upper_torso.orientation =
Quaternion::rotation_z(slower * 0.18 + slowersmooth * 0.15) Quaternion::rotation_z(slower * 0.18 + slowersmooth * 0.15)
* Quaternion::rotation_x(slower * 0.05 + slowersmooth * 0.05); * Quaternion::rotation_x(0.0 + slower * 0.18 + slowersmooth * 0.15)
* Quaternion::rotation_y(slower * 0.18 + slowersmooth * 0.15);
next.lower_torso.position = Vec3::new(0.0, s_a.lower_torso.0, s_a.lower_torso.1);
next.lower_torso.orientation = next.lower_torso.orientation =
Quaternion::rotation_z(slower * -0.1 + slowersmooth * -0.075) Quaternion::rotation_z(slower * -0.1 + slowersmooth * -0.075)
* Quaternion::rotation_x(0.0 + slower * -0.1) * Quaternion::rotation_x(0.0 + slower * -0.1)
* Quaternion::rotation_y(slower * -0.1); * Quaternion::rotation_y(slower * -0.1);
next.control.position = Vec3::new(-8.0, 7.0 + slower * 4.0, 1.0 + slower * -9.0); if velocity > 0.5 {
next.control.orientation = next.foot_l.position = Vec3::new(-s_a.foot.0, foot * -6.0, s_a.foot.2);
Quaternion::rotation_x(-1.5 + slower * -1.2) * Quaternion::rotation_z(1.5); next.foot_l.orientation = Quaternion::rotation_x(foot * -0.4)
}, * Quaternion::rotation_z((slower * 0.3).max(0.0));
Some(ToolKind::NpcWeapon(_)) => {
if switch > 0.0 {
next.head.position = Vec3::new(0.0, s_a.head.0, s_a.head.1) * 1.02;
next.head.orientation = Quaternion::rotation_z((twist * -0.5).max(-1.0))
* Quaternion::rotation_x(-0.2);
next.upper_torso.position = next.foot_r.position = Vec3::new(s_a.foot.0, foot * 6.0, s_a.foot.2);
Vec3::new(0.0, s_a.upper_torso.0, s_a.upper_torso.1); next.foot_r.orientation = Quaternion::rotation_x(foot * 0.4)
next.upper_torso.orientation = Quaternion::rotation_z((twist * 0.5).min(1.0)); * Quaternion::rotation_z((slower * 0.3).max(0.0));
next.torso.orientation = Quaternion::rotation_x(-0.15);
next.lower_torso.position =
Vec3::new(0.0, s_a.lower_torso.0, s_a.lower_torso.1);
next.lower_torso.orientation = Quaternion::rotation_z((twist * -0.5).max(-1.0));
next.hand_r.position = Vec3::new(s_a.hand.0, s_a.hand.1, s_a.hand.2);
next.hand_r.orientation = Quaternion::rotation_z(-1.5);
next.arm_control_r.position = Vec3::new(0.0, 0.0, -4.0);
next.arm_control_r.orientation =
Quaternion::rotation_x(1.0) * Quaternion::rotation_y(slow * -1.35);
next.tail.orientation = Quaternion::rotation_z(twist * 0.5);
} else { } else {
next.head.position = Vec3::new(0.0, s_a.head.0, s_a.head.1) * 1.02; next.foot_l.position =
next.head.orientation = Quaternion::rotation_z((twist * 0.5).min(1.0)) Vec3::new(-s_a.foot.0, -2.5, s_a.foot.2 + (slower * 2.5).max(0.0));
* Quaternion::rotation_x(-0.2); next.foot_l.orientation = Quaternion::rotation_x(slower * -0.2 - 0.2)
* Quaternion::rotation_z((slower * 1.0).max(0.0));
next.upper_torso.position = next.foot_r.position = Vec3::new(s_a.foot.0, 3.5 - slower * 2.0, s_a.foot.2);
Vec3::new(0.0, s_a.upper_torso.0, s_a.upper_torso.1); next.foot_r.orientation = Quaternion::rotation_x(slower * 0.1)
next.upper_torso.orientation = Quaternion::rotation_z((twist * -0.5).max(-1.0)) * Quaternion::rotation_z((slower * 0.5).max(0.0));
* Quaternion::rotation_x(0.0); }
next.lower_torso.position = next.control.position = Vec3::new(-8.0, 7.0, 1.0);
Vec3::new(0.0, s_a.lower_torso.0, s_a.lower_torso.1); next.control.orientation = Quaternion::rotation_x(-1.5 + slower * 1.5)
next.lower_torso.orientation = Quaternion::rotation_z((twist * 0.5).min(1.0)) * Quaternion::rotation_y(slowersmooth * 0.35 - 0.3)
* Quaternion::rotation_x(0.0); * Quaternion::rotation_z(1.4 + slowersmooth * 0.2);
},
next.arm_control_l.position = Vec3::new(0.0, 0.0, -4.0); Some(ToolKind::Debug(_)) => {
next.arm_control_l.orientation = next.hand_l.position = Vec3::new(-7.0, 4.0, 3.0);
Quaternion::rotation_x(1.0) * Quaternion::rotation_y(slow * 1.35); next.hand_l.orientation = Quaternion::rotation_x(1.27);
next.main.position = Vec3::new(-5.0, 5.0, 23.0);
next.hand_l.position = Vec3::new(-s_a.hand.0, s_a.hand.1, s_a.hand.2); next.main.orientation = Quaternion::rotation_x(PI);
next.hand_l.orientation = Quaternion::rotation_z(1.5);
next.tail.orientation = Quaternion::rotation_z(twist * -0.5);
};
}, },
_ => {}, _ => {},
} }
next next
} }
} }

View File

@ -43,11 +43,13 @@ impl Animation for BeamAnimation {
next.hand_l.orientation = Quaternion::rotation_x(1.27) * Quaternion::rotation_y(0.0); next.hand_l.orientation = Quaternion::rotation_x(1.27) * Quaternion::rotation_y(0.0);
next.hand_r.position = Vec3::new(0.0, 0.0, 2.0); next.hand_r.position = Vec3::new(0.0, 0.0, 2.0);
next.hand_r.orientation = Quaternion::rotation_x(1.57) * Quaternion::rotation_y(0.2); next.hand_r.orientation = Quaternion::rotation_x(1.57) * Quaternion::rotation_y(0.2);
next.main.position = Vec3::new(0.0, 8.0, 13.2); next.main.position = Vec3::new(0.0, 0.0, 13.2);
next.main.orientation = Quaternion::rotation_y(PI); next.main.orientation = Quaternion::rotation_y(PI);
next.control.position = Vec3::new(-4.0, 7.0, 4.0); next.control.position = Vec3::new(-4.0, 7.0, 4.0);
next.control.orientation = Quaternion::rotation_x(-0.3) * Quaternion::rotation_y(0.15); next.control.orientation = Quaternion::rotation_x(-0.3)
* Quaternion::rotation_y(0.15)
* Quaternion::rotation_z(0.0);
match active_tool_kind { match active_tool_kind {
Some(ToolKind::Staff(_)) | Some(ToolKind::Sceptre(_)) => { Some(ToolKind::Staff(_)) | Some(ToolKind::Sceptre(_)) => {
@ -110,6 +112,7 @@ impl Animation for BeamAnimation {
}, },
_ => {}, _ => {},
} }
next next
} }
} }

View File

@ -31,57 +31,48 @@ impl Animation for BetaAnimation {
let mut next = (*skeleton).clone(); let mut next = (*skeleton).clone();
let (movement1, movement2, movement3) = match stage_section { let (movement1, movement2, movement3) = match stage_section {
Some(StageSection::Buildup) => (anim_time as f32, 0.0, 0.0), Some(StageSection::Buildup) => ((anim_time as f32).powf(0.25), 0.0, 0.0),
Some(StageSection::Cast) => (1.0, anim_time as f32, 0.0), Some(StageSection::Swing) => (1.0, anim_time as f32, 0.0),
Some(StageSection::Recover) => (1.0, 1.0, anim_time as f32), Some(StageSection::Recover) => (1.0, 1.0, (anim_time as f32).powf(4.0)),
_ => (0.0, 0.0, 0.0), _ => (0.0, 0.0, 0.0),
}; };
match active_tool_kind { match active_tool_kind {
Some(ToolKind::Sword(_)) => { Some(ToolKind::Sword(_)) => {
next.hand_l.position = Vec3::new(-4.75, -1.0, 2.5); next.main.position = Vec3::new(0.0, 0.0, 0.0);
next.hand_l.orientation = next.main.orientation = Quaternion::rotation_x(0.0);
Quaternion::rotation_x(1.47) * Quaternion::rotation_y(-0.2);
next.hand_l.scale = Vec3::one() * 1.04;
next.hand_r.position = Vec3::new(0.75, -1.5, -0.5);
next.hand_r.orientation =
Quaternion::rotation_x(1.47) * Quaternion::rotation_y(0.3);
next.hand_r.scale = Vec3::one() * 1.04;
next.main.position = Vec3::new(0.0, 5.0, -6.0);
next.main.orientation = Quaternion::rotation_x(-0.1)
* Quaternion::rotation_y(0.0)
* Quaternion::rotation_z(0.0);
next.head.position = Vec3::new(0.0, s_a.head.0, s_a.head.1); next.hand_l.position = Vec3::new(s_a.shl.0, s_a.shl.1, s_a.shl.2);
next.hand_l.orientation =
Quaternion::rotation_x(s_a.shl.3) * Quaternion::rotation_y(s_a.shl.4);
next.hand_r.position = Vec3::new(s_a.shr.0, s_a.shr.1, s_a.shr.2);
next.hand_r.orientation =
Quaternion::rotation_x(s_a.shr.3) * Quaternion::rotation_y(s_a.shr.4);
next.control.position = Vec3::new( next.control.position = Vec3::new(
-8.0 + movement1 * -5.0 s_a.sc.0 + (-1.4 + movement1 * -3.0 + movement2 * -2.0) * (1.0 - movement3),
+ (movement2 as f32 * 2.5).sin() * 30.0 s_a.sc.1 + (-1.4 + movement1 * 3.0 + movement2 * 3.0) * (1.0 - movement3),
+ movement3 * -5.0, s_a.sc.2 + (-1.9 + movement1 * 2.5 * (1.0 - movement3)),
1.0 - (movement1 as f32 * 8.0).sin() * 0.8 + movement1 * 2.0 + movement3 * 2.0,
2.0 - (movement1 as f32 * 8.0).sin() * 0.4,
); );
next.control.orientation = Quaternion::rotation_x(-1.57) next.control.orientation =
* Quaternion::rotation_y( Quaternion::rotation_x(s_a.sc.3 + (-1.7) * (1.0 - movement3))
0.0 + movement1 * 1.5 + (movement2 as f32 * 2.5).sin() * 0.5, * Quaternion::rotation_y(
) s_a.sc.4
* Quaternion::rotation_z(1.0 + (movement2 as f32 * 2.5).sin() * 1.0); + (0.4 + movement1 * 1.5 + movement2 * -2.5) * (1.0 - movement3),
next.upper_torso.orientation = Quaternion::rotation_y(-0.1) )
* Quaternion::rotation_z(
s_a.sc.5 + (1.67 + movement2 * 1.57) * (1.0 - movement3),
);
next.upper_torso.orientation = Quaternion::rotation_x(0.15)
* Quaternion::rotation_y((-0.1) * (1.0 - movement3))
* Quaternion::rotation_z( * Quaternion::rotation_z(
0.4 + movement1 * 1.5 (0.4 + movement1 * 1.5 + movement2 * -2.5) * (1.0 - movement3),
+ (movement2 as f32 * 2.5).sin() * -0.5
+ movement3 * 1.0,
);
next.head.orientation = Quaternion::rotation_y(0.1)
* Quaternion::rotation_z(
-0.1 + movement1 * -1.1 + (movement2 as f32 * 2.5).sin() * -0.5,
); );
next.head.orientation = Quaternion::rotation_z((-0.4) * (1.0 - movement3));
}, },
_ => {}, _ => {},
} }
next.hold.scale = Vec3::one() * 0.0;
next next
} }
} }

View File

@ -31,72 +31,24 @@ impl Animation for ChargeAnimation {
) -> Self::Skeleton { ) -> Self::Skeleton {
let mut next = (*skeleton).clone(); let mut next = (*skeleton).clone();
let lab = 0.55; let lab = 1.0;
let breathe = (anim_time as f32 + 1.5 * PI).sin();
let test = (anim_time as f32 + 36.0 * PI).sin();
let slower = (anim_time as f32 * 1.0 + PI).sin(); let foot = (((5.0)
let slow = (anim_time as f32 * 3.5 + PI).sin(); / (0.2 + 4.8 * ((anim_time as f32 * lab as f32 * 8.0).sin()).powf(2.0 as f32)))
let tailmove = Vec2::new(
((global_time + anim_time) as f32 / 2.0)
.floor()
.mul(7331.0)
.sin()
* 0.25,
((global_time + anim_time) as f32 / 2.0)
.floor()
.mul(1337.0)
.sin()
* 0.125,
);
let foothoril = (((1.0)
/ (0.4
+ (0.6)
* ((anim_time as f32 * 16.0 * lab as f32 + PI * 1.4).sin()).powf(2.0 as f32)))
.sqrt())
* ((anim_time as f32 * 16.0 * lab as f32 + PI * 1.4).sin());
let foothorir = (((1.0)
/ (0.4
+ (0.6)
* ((anim_time as f32 * 16.0 * lab as f32 + PI * 0.4).sin()).powf(2.0 as f32)))
.sqrt())
* ((anim_time as f32 * 16.0 * lab as f32 + PI * 0.4).sin());
let footvertl = (anim_time as f32 * 16.0 * lab as f32).sin();
let footvertr = (anim_time as f32 * 16.0 * lab as f32 + PI).sin();
let footrotl = (((5.0)
/ (2.5
+ (2.5)
* ((anim_time as f32 * 16.0 * lab as f32 + PI * 1.4).sin()).powf(2.0 as f32)))
.sqrt())
* ((anim_time as f32 * 16.0 * lab as f32 + PI * 1.4).sin());
let footrotr = (((5.0)
/ (1.0
+ (4.0)
* ((anim_time as f32 * 16.0 * lab as f32 + PI * 0.4).sin()).powf(2.0 as f32)))
.sqrt())
* ((anim_time as f32 * 16.0 * lab as f32 + PI * 0.4).sin());
let quick = (((5.0)
/ (3.5 + 1.5 * ((anim_time as f32 * lab as f32 * 8.0).sin()).powf(2.0 as f32)))
.sqrt()) .sqrt())
* ((anim_time as f32 * lab as f32 * 8.0).sin()); * ((anim_time as f32 * lab as f32 * 8.0).sin());
let quicka = (((5.0) let foote = (((5.0)
/ (3.5 / (0.5 + 4.5 * ((anim_time as f32 * lab as f32 * 8.0 + 1.57).sin()).powf(2.0 as f32)))
+ 1.5
* ((anim_time as f32 * lab as f32 * 8.0 + PI / 2.0).sin()).powf(2.0 as f32)))
.sqrt()) .sqrt())
* ((anim_time as f32 * lab as f32 * 8.0 + PI / 2.0).sin()); * ((anim_time as f32 * lab as f32 * 8.0).sin());
let stress = (((5.0) let stress = (((5.0)
/ (0.5 + 4.5 * ((anim_time as f32 * lab as f32 * 20.0).cos()).powf(2.0 as f32))) / (0.5 + 4.5 * ((anim_time as f32 * lab as f32 * 20.0).cos()).powf(2.0 as f32)))
.sqrt()) .sqrt())
* ((anim_time as f32 * lab as f32 * 20.0).cos()); * ((anim_time as f32 * lab as f32 * 20.0).cos());
let quick = (((5.0)
let short = (anim_time as f32 * lab as f32 * 16.0).sin(); / (3.5 + 1.5 * ((anim_time as f32 * lab as f32 * 8.0).sin()).powf(2.0 as f32)))
.sqrt())
* ((anim_time as f32 * lab as f32 * 8.0).sin());
let stop = ((anim_time as f32).powf(0.3 as f32)).min(1.2); let stop = ((anim_time as f32).powf(0.3 as f32)).min(1.2);
let stopa = ((anim_time as f32).powf(0.9 as f32)).min(5.0); let stopa = ((anim_time as f32).powf(0.9 as f32)).min(5.0);
@ -114,10 +66,10 @@ impl Animation for ChargeAnimation {
0.0 0.0
} * 1.3; } * 1.3;
next.head.position = Vec3::new(stop * -2.0, -3.5 + stop * 2.5 + s_a.head.0, s_a.head.1); next.head.position = Vec3::new(stop * -2.0, -1.5 + stop * 2.5 + s_a.head.0, s_a.head.1);
next.head.orientation = next.head.orientation =
Quaternion::rotation_z(stop * -1.0 + tilt * -2.0) * Quaternion::rotation_y(stop * -0.3); Quaternion::rotation_z(stop * -1.0 + tilt * -2.0) * Quaternion::rotation_y(stop * -0.3);
next.head.scale = Vec3::one() * 1.02; next.head.scale = Vec3::one();
next.upper_torso.position = Vec3::new(0.0, s_a.upper_torso.0, s_a.upper_torso.1); next.upper_torso.position = Vec3::new(0.0, s_a.upper_torso.0, s_a.upper_torso.1);
next.upper_torso.orientation = next.upper_torso.orientation =
@ -126,187 +78,84 @@ impl Animation for ChargeAnimation {
next.lower_torso.position = Vec3::new(0.0, s_a.lower_torso.0, s_a.lower_torso.1); next.lower_torso.position = Vec3::new(0.0, s_a.lower_torso.0, s_a.lower_torso.1);
next.lower_torso.orientation = Quaternion::rotation_z(stop * -0.7 + tilt * 4.0); next.lower_torso.orientation = Quaternion::rotation_z(stop * -0.7 + tilt * 4.0);
if velocity < 0.5 {
next.jaw.position = Vec3::new(0.0, s_a.jaw.0 - slower * 0.12, s_a.jaw.1 + slow * 0.2);
next.jaw.orientation = Quaternion::rotation_x(slow * 0.05);
next.jaw.scale = Vec3::one() * 1.02;
next.tail.position = Vec3::new(0.0, s_a.tail.0, s_a.tail.1);
next.tail.orientation =
Quaternion::rotation_z(0.0 + slow * 0.2 + tailmove.x) * Quaternion::rotation_x(0.0);
next.shoulder_l.position = Vec3::new(-s_a.shoulder.0, s_a.shoulder.1, s_a.shoulder.2);
next.shoulder_l.orientation = Quaternion::rotation_z(0.0) * Quaternion::rotation_x(0.0);
next.shoulder_r.position = Vec3::new(s_a.shoulder.0, s_a.shoulder.1, s_a.shoulder.2);
next.shoulder_r.orientation = Quaternion::rotation_z(0.0) * Quaternion::rotation_x(0.0);
next.leg_l.position =
Vec3::new(-s_a.leg.0, s_a.leg.1, s_a.leg.2 + breathe * 0.2) * 1.02;
next.leg_l.orientation = Quaternion::rotation_z(0.0);
next.leg_l.scale = Vec3::one() * 1.02;
next.leg_r.position = Vec3::new(s_a.leg.0, s_a.leg.1, s_a.leg.2 + breathe * 0.2) * 1.02;
next.leg_r.orientation = Quaternion::rotation_z(0.0);
next.leg_r.scale = Vec3::one() * 1.02;
next.foot_l.position = Vec3::new(-s_a.foot.0, s_a.foot.1, s_a.foot.2);
next.foot_l.orientation = Quaternion::rotation_z(0.0);
next.foot_r.position = Vec3::new(s_a.foot.0, s_a.foot.1, s_a.foot.2);
next.foot_r.orientation = Quaternion::rotation_z(0.0);
next.torso.position = Vec3::new(0.0, 0.0, 0.0) / 8.0;
next.torso.orientation = Quaternion::rotation_z(test * 0.0);
next.torso.scale = Vec3::one() / 8.0;
next.control.position = Vec3::new(7.0, 9.0, -10.0);
next.control.orientation = Quaternion::rotation_x(test * 0.02)
* Quaternion::rotation_y(test * 0.02)
* Quaternion::rotation_z(test * 0.02);
} else {
next.jaw.position = Vec3::new(0.0, s_a.jaw.0 - slower * 0.12, s_a.jaw.1 + slow * 0.2);
next.jaw.orientation = Quaternion::rotation_x(slow * 0.05);
next.jaw.scale = Vec3::one() * 1.02;
next.tail.position = Vec3::new(0.0, s_a.tail.0, s_a.tail.1);
next.tail.orientation =
Quaternion::rotation_z(0.0 + slow * 0.2 + tailmove.x) * Quaternion::rotation_x(0.0);
next.torso.position = Vec3::new(0.0, 0.0, 0.0) / 8.0;
next.torso.orientation = Quaternion::rotation_z(0.0) * Quaternion::rotation_x(-0.25);
next.torso.scale = Vec3::one() / 8.0;
next.leg_l.position = Vec3::new(-s_a.leg.0, s_a.leg.1, s_a.leg.2) * 0.98;
next.leg_l.orientation =
Quaternion::rotation_z(short * 0.18) * Quaternion::rotation_x(foothoril * 0.3);
next.leg_l.scale = Vec3::one() * 0.98;
next.leg_r.position = Vec3::new(s_a.leg.0, s_a.leg.1, s_a.leg.2) * 0.98;
next.leg_r.orientation =
Quaternion::rotation_z(short * 0.18) * Quaternion::rotation_x(foothorir * 0.3);
next.leg_r.scale = Vec3::one() * 0.98;
next.foot_l.position = Vec3::new(
-s_a.foot.0,
4.0 + s_a.foot.1 + foothoril * 8.5,
s_a.foot.2 + ((footvertl * 6.5).max(0.0)),
);
next.foot_l.orientation =
Quaternion::rotation_x(-0.5 + footrotl * 0.85) * Quaternion::rotation_y(0.0);
next.foot_r.position = Vec3::new(
s_a.foot.0,
4.0 + s_a.foot.1 + foothorir * 8.5,
s_a.foot.2 + ((footvertr * 6.5).max(0.0)),
);
next.foot_r.orientation =
Quaternion::rotation_x(-0.5 + footrotr * 0.85) * Quaternion::rotation_y(0.0);
}
match active_tool_kind { match active_tool_kind {
Some(ToolKind::Bow(_)) => { Some(ToolKind::Staff(_)) | Some(ToolKind::Sceptre(_)) => {
next.hand_l.position = Vec3::new(2.0, -2.0 + stop * -1.0, 0.0); next.hand_l.position = Vec3::new(s_a.sthl.0, s_a.sthl.1, s_a.sthl.2);
next.hand_l.orientation = Quaternion::rotation_x(1.20) next.hand_l.orientation = Quaternion::rotation_x(s_a.sthl.3);
* Quaternion::rotation_y(-0.6)
* Quaternion::rotation_z(-0.3);
next.hand_l.scale = Vec3::one() * 1.04;
next.hand_r.position = Vec3::new(5.9, 0.0, -5.0); next.hand_r.position = Vec3::new(s_a.sthr.0, s_a.sthr.1, s_a.sthr.2);
next.hand_r.orientation = Quaternion::rotation_x(1.20)
* Quaternion::rotation_y(-0.6)
* Quaternion::rotation_z(-0.3);
next.hand_r.scale = Vec3::one() * 1.04;
next.shoulder_l.position = Vec3::new(
-s_a.shoulder.0,
s_a.shoulder.1 + foothoril * -1.0,
s_a.shoulder.2,
);
next.shoulder_l.orientation = Quaternion::rotation_x(1.4 + footrotl * -0.06)
* Quaternion::rotation_y(-0.9)
* Quaternion::rotation_z(footrotl * -0.05);
next.shoulder_r.position = Vec3::new(
s_a.shoulder.0,
s_a.shoulder.1 + foothorir * -1.0,
s_a.shoulder.2,
);
next.shoulder_r.orientation = Quaternion::rotation_x(1.3 + footrotr * -0.06)
* Quaternion::rotation_y(-0.5) //1.9
* Quaternion::rotation_z(footrotr * -0.05);
next.jaw.position = Vec3::new(0.0, s_a.jaw.0, s_a.jaw.1);
next.jaw.orientation = Quaternion::rotation_x(stop * 0.05);
next.tail.position = Vec3::new(0.0, s_a.tail.0, s_a.tail.1);
next.tail.orientation = Quaternion::rotation_z(0.02 * stress * stop + tilt * 2.0)
* Quaternion::rotation_x(-0.2 * stop);
next.main.position = Vec3::new(7.0, 2.0, -13.0);
next.main.orientation = Quaternion::rotation_x(-0.3)
* Quaternion::rotation_y(0.3)
* Quaternion::rotation_z(-0.6);
next.hold.position = Vec3::new(1.4, -0.3, -13.8);
next.hold.orientation = Quaternion::rotation_x(-1.6)
* Quaternion::rotation_y(-0.1)
* Quaternion::rotation_z(0.0);
next.hold.scale = Vec3::one() * 1.0;
next.control.position = Vec3::new(-10.0 + stop * 13.0, 6.0 + stop * 4.0, -2.0);
next.control.orientation = Quaternion::rotation_x(0.0)
* Quaternion::rotation_y(stop * -0.4)
* Quaternion::rotation_z(stop * -0.6);
},
Some(ToolKind::Staff(_)) => {
next.hand_l.position = Vec3::new(11.0, 5.0, -4.0);
next.hand_l.orientation = Quaternion::rotation_x(1.27);
next.hand_l.scale = Vec3::one() * 1.04;
next.hand_r.position = Vec3::new(12.0, 5.5, 2.0);
next.hand_r.orientation = next.hand_r.orientation =
Quaternion::rotation_x(1.57) * Quaternion::rotation_y(0.2); Quaternion::rotation_x(s_a.sthr.3) * Quaternion::rotation_y(s_a.sthr.4);
next.hand_r.scale = Vec3::one() * 1.04;
next.shoulder_l.position = Vec3::new( next.main.position = Vec3::new(0.0, 0.0, 0.0);
-s_a.shoulder.0, next.main.orientation = Quaternion::rotation_y(0.0);
s_a.shoulder.1 + foothoril * -1.0,
s_a.shoulder.2,
);
next.shoulder_l.orientation = Quaternion::rotation_x(0.5 + footrotl * -0.16)
* Quaternion::rotation_y(0.1)
* Quaternion::rotation_z(footrotl * 0.1);
next.shoulder_r.position = Vec3::new(
s_a.shoulder.0,
s_a.shoulder.1 + foothorir * -1.0,
s_a.shoulder.2,
);
next.shoulder_r.orientation = Quaternion::rotation_x(0.5 + footrotr * -0.16)
* Quaternion::rotation_y(-0.1)
* Quaternion::rotation_z(footrotr * -0.1);
next.tail.position = Vec3::new(0.0, s_a.tail.0, s_a.tail.1);
next.tail.orientation = Quaternion::rotation_z(0.02 * stress * stop + tilt * 2.0)
* Quaternion::rotation_x(-0.2 * stop);
next.main.position = Vec3::new(8.0, 8.5, 13.2);
next.main.orientation = Quaternion::rotation_x(0.0)
* Quaternion::rotation_y(PI)
* Quaternion::rotation_z(0.0);
next.control.position = Vec3::new( next.control.position = Vec3::new(
-7.0 + quick * 3.5 * (1.0 / (stopa + 0.1)), s_a.stc.0 + quick * 3.5 * (1.0 / (stopa + 0.1)),
6.0 + quicka * 3.5 * (1.0 / (stopa + 0.1)), s_a.stc.1,
6.0 - stop * 3.0, s_a.stc.2 - stop * 3.0,
); );
next.control.orientation = next.control.orientation = Quaternion::rotation_x(s_a.stc.3 + stop * -0.2)
Quaternion::rotation_x(stop * -0.2) * Quaternion::rotation_z(stop * 0.2); * Quaternion::rotation_y(s_a.stc.4)
* Quaternion::rotation_z(s_a.stc.5 + stop * 0.2);
},
Some(ToolKind::Bow(_)) => {
next.main.position = Vec3::new(0.0, 0.0, 0.0);
next.main.orientation = Quaternion::rotation_x(0.0);
next.hand_l.position = Vec3::new(s_a.bhl.0, s_a.bhl.1, s_a.bhl.2);
next.hand_l.orientation = Quaternion::rotation_x(s_a.bhl.3);
next.hand_r.position = Vec3::new(s_a.bhr.0, s_a.bhr.1, s_a.bhr.2);
next.hand_r.orientation = Quaternion::rotation_x(s_a.bhr.3);
next.hold.position = Vec3::new(0.0, -1.0, -15.2);
next.hold.orientation = Quaternion::rotation_x(-1.57);
next.hold.scale = Vec3::one() * 1.0;
next.control.position = Vec3::new(
3.0 + s_a.bc.0 + stop * 13.0,
-5.0 + s_a.bc.1 + stop * 4.0,
6.0 + s_a.bc.2,
);
next.control.orientation = Quaternion::rotation_x(0.2 + s_a.bc.3)
* Quaternion::rotation_y(-0.8 + s_a.bc.4 + stop * -0.4)
* Quaternion::rotation_z(s_a.bc.5 + stop * -0.6);
}, },
_ => {}, _ => {},
} }
if velocity > 0.2 {
next.foot_l.position = Vec3::new(
-s_a.foot.0 - foot * 1.5,
s_a.foot.1 + foote * 2.0,
s_a.foot.2,
);
next.foot_l.orientation = Quaternion::rotation_x(foote * -0.1)
* Quaternion::rotation_z(0.4)
* Quaternion::rotation_y(0.15);
next.foot_r.position = Vec3::new(
s_a.foot.0 + foot * 1.5,
s_a.foot.1 + foote * -1.5,
s_a.foot.2,
);
next.foot_r.orientation = Quaternion::rotation_z(0.4);
} else {
next.foot_l.position = Vec3::new(
-s_a.foot.0,
-2.5 + stop * -1.3,
s_a.foot.2 + tilt * -4.0 * foot,
);
next.foot_l.orientation =
Quaternion::rotation_x(stop * -0.2 - 0.2 + stop * stress * 0.02)
* Quaternion::rotation_z(stop * 0.1)
* Quaternion::rotation_y(stop * 0.08);
next.foot_r.position =
Vec3::new(s_a.foot.0, 3.5 + stop * 1.5, s_a.foot.2 + tilt * 4.0 * foot);
next.foot_r.orientation =
Quaternion::rotation_x(stop * 0.1) * Quaternion::rotation_z(stop * 0.1);
}
next next
} }
} }

View File

@ -42,8 +42,8 @@ impl Animation for EquipAnimation {
next.hand_r.position = Vec3::new(-5.0, -4.5, 14.0); next.hand_r.position = Vec3::new(-5.0, -4.5, 14.0);
}, },
Some(ToolKind::Hammer(_)) => { Some(ToolKind::Hammer(_)) => {
next.hand_l.position = Vec3::new(-5.0, -5.0, 13.0); next.hand_l.position = Vec3::new(-5.0 - 10.0, -5.0, 13.0 - 10.0);
next.hand_r.position = Vec3::new(-3.0, -4.5, 10.0); next.hand_r.position = Vec3::new(-3.0 - 10.0, -4.5, 10.0 - 10.0);
}, },
Some(ToolKind::Staff(_)) | Some(ToolKind::Sceptre(_)) => { Some(ToolKind::Staff(_)) | Some(ToolKind::Sceptre(_)) => {
next.hand_l.position = Vec3::new(-3.0, -5.0, 8.0); next.hand_l.position = Vec3::new(-3.0, -5.0, 8.0);

View File

@ -2,12 +2,13 @@ use super::{
super::{vek::*, Animation}, super::{vek::*, Animation},
BipedLargeSkeleton, SkeletonAttr, BipedLargeSkeleton, SkeletonAttr,
}; };
use common::comp::item::ToolKind;
use std::{f32::consts::PI, ops::Mul}; use std::{f32::consts::PI, ops::Mul};
pub struct IdleAnimation; pub struct IdleAnimation;
impl Animation for IdleAnimation { impl Animation for IdleAnimation {
type Dependency = f64; type Dependency = (Option<ToolKind>, Option<ToolKind>, f64);
type Skeleton = BipedLargeSkeleton; type Skeleton = BipedLargeSkeleton;
#[cfg(feature = "use-dyn-lib")] #[cfg(feature = "use-dyn-lib")]
@ -16,7 +17,7 @@ impl Animation for IdleAnimation {
#[cfg_attr(feature = "be-dyn-lib", export_name = "biped_large_idle")] #[cfg_attr(feature = "be-dyn-lib", export_name = "biped_large_idle")]
fn update_skeleton_inner( fn update_skeleton_inner(
skeleton: &Self::Skeleton, skeleton: &Self::Skeleton,
global_time: Self::Dependency, (active_tool_kind, _second_tool_kind, global_time): Self::Dependency,
anim_time: f64, anim_time: f64,
_rate: &mut f32, _rate: &mut f32,
s_a: &SkeletonAttr, s_a: &SkeletonAttr,
@ -88,9 +89,28 @@ impl Animation for IdleAnimation {
next.tail.orientation = next.tail.orientation =
Quaternion::rotation_z(0.0 + slow * 0.2) * Quaternion::rotation_x(0.0); Quaternion::rotation_z(0.0 + slow * 0.2) * Quaternion::rotation_x(0.0);
next.main.position = Vec3::new(-5.0, -7.0, 7.0); match active_tool_kind {
next.main.orientation = Some(ToolKind::Bow(_)) => {
Quaternion::rotation_x(PI) * Quaternion::rotation_y(0.6) * Quaternion::rotation_z(1.57); next.main.position = Vec3::new(-2.0, -5.0, -6.0);
next.main.orientation = Quaternion::rotation_y(2.5) * Quaternion::rotation_z(1.57);
},
Some(ToolKind::Staff(_)) | Some(ToolKind::Sceptre(_)) => {
next.main.position = Vec3::new(-6.0, -5.0, -12.0);
next.main.orientation = Quaternion::rotation_y(0.6) * Quaternion::rotation_z(1.57);
},
Some(ToolKind::Sword(_)) => {
next.main.position = Vec3::new(-10.0, -8.0, 12.0);
next.main.orientation = Quaternion::rotation_y(2.5) * Quaternion::rotation_z(1.57);
},
Some(ToolKind::Hammer(_)) => {
next.main.position = Vec3::new(-10.0, -8.0, 12.0);
next.main.orientation = Quaternion::rotation_y(2.5) * Quaternion::rotation_z(1.57);
},
_ => {
next.main.position = Vec3::new(-2.0, -5.0, -6.0);
next.main.orientation = Quaternion::rotation_y(0.6) * Quaternion::rotation_z(1.57);
},
}
next.shoulder_l.position = Vec3::new(-s_a.shoulder.0, s_a.shoulder.1, s_a.shoulder.2); 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(breathe); next.shoulder_l.orientation = Quaternion::rotation_x(breathe);

View File

@ -2,12 +2,13 @@ use super::{
super::{vek::*, Animation}, super::{vek::*, Animation},
BipedLargeSkeleton, SkeletonAttr, BipedLargeSkeleton, SkeletonAttr,
}; };
use common::comp::item::ToolKind;
use std::f32::consts::PI; use std::f32::consts::PI;
pub struct JumpAnimation; pub struct JumpAnimation;
impl Animation for JumpAnimation { impl Animation for JumpAnimation {
type Dependency = f64; type Dependency = (Option<ToolKind>, Option<ToolKind>, f64);
type Skeleton = BipedLargeSkeleton; type Skeleton = BipedLargeSkeleton;
#[cfg(feature = "use-dyn-lib")] #[cfg(feature = "use-dyn-lib")]
@ -16,7 +17,7 @@ impl Animation for JumpAnimation {
#[cfg_attr(feature = "be-dyn-lib", export_name = "biped_large_jump")] #[cfg_attr(feature = "be-dyn-lib", export_name = "biped_large_jump")]
fn update_skeleton_inner( fn update_skeleton_inner(
skeleton: &Self::Skeleton, skeleton: &Self::Skeleton,
_global_time: Self::Dependency, (active_tool_kind, _second_tool_kind, _global_time): Self::Dependency,
anim_time: f64, anim_time: f64,
_rate: &mut f32, _rate: &mut f32,
s_a: &SkeletonAttr, s_a: &SkeletonAttr,
@ -58,10 +59,28 @@ impl Animation for JumpAnimation {
Quaternion::rotation_x(PI) * Quaternion::rotation_y(0.0) * Quaternion::rotation_z(0.0); Quaternion::rotation_x(PI) * Quaternion::rotation_y(0.0) * Quaternion::rotation_z(0.0);
next.second.scale = Vec3::one() * 0.0; next.second.scale = Vec3::one() * 0.0;
next.main.position = Vec3::new(-5.0, -7.0, 7.0); match active_tool_kind {
next.main.orientation = Some(ToolKind::Bow(_)) => {
Quaternion::rotation_x(PI) * Quaternion::rotation_y(0.6) * Quaternion::rotation_z(1.57); next.main.position = Vec3::new(-2.0, -5.0, -6.0);
next.main.scale = Vec3::one() * 1.02; next.main.orientation = Quaternion::rotation_y(2.5) * Quaternion::rotation_z(1.57);
},
Some(ToolKind::Staff(_)) | Some(ToolKind::Sceptre(_)) => {
next.main.position = Vec3::new(-6.0, -5.0, -12.0);
next.main.orientation = Quaternion::rotation_y(0.6) * Quaternion::rotation_z(1.57);
},
Some(ToolKind::Sword(_)) => {
next.main.position = Vec3::new(-10.0, -8.0, 12.0);
next.main.orientation = Quaternion::rotation_y(2.5) * Quaternion::rotation_z(1.57);
},
Some(ToolKind::Hammer(_)) => {
next.main.position = Vec3::new(-10.0, -8.0, 12.0);
next.main.orientation = Quaternion::rotation_y(2.5) * Quaternion::rotation_z(1.57);
},
_ => {
next.main.position = Vec3::new(-2.0, -5.0, -6.0);
next.main.orientation = Quaternion::rotation_y(0.6) * Quaternion::rotation_z(1.57);
},
}
next.shoulder_l.position = Vec3::new(-s_a.shoulder.0, s_a.shoulder.1, s_a.shoulder.2); next.shoulder_l.position = Vec3::new(-s_a.shoulder.0, s_a.shoulder.1, s_a.shoulder.2);
next.shoulder_l.orientation = Quaternion::rotation_z(0.0) * Quaternion::rotation_x(0.5); next.shoulder_l.orientation = Quaternion::rotation_z(0.0) * Quaternion::rotation_x(0.5);

View File

@ -46,7 +46,7 @@ impl Animation for LeapAnimation {
next.hand_r.position = Vec3::new(2.0, 0.0, 0.0); next.hand_r.position = Vec3::new(2.0, 0.0, 0.0);
next.hand_r.orientation = Quaternion::rotation_x(PI) * Quaternion::rotation_y(0.0); next.hand_r.orientation = Quaternion::rotation_x(PI) * Quaternion::rotation_y(0.0);
next.hand_r.scale = Vec3::one() * 1.04; next.hand_r.scale = Vec3::one() * 1.04;
next.main.position = Vec3::new(0.0, 0.0, 12.0); next.main.position = Vec3::new(0.0, 0.0, 0.0);
next.main.orientation = Quaternion::rotation_y(-1.57) * Quaternion::rotation_z(1.57); next.main.orientation = Quaternion::rotation_y(-1.57) * Quaternion::rotation_z(1.57);
next.head.position = Vec3::new(0.0, s_a.head.0, s_a.head.1); next.head.position = Vec3::new(0.0, s_a.head.0, s_a.head.1);
@ -110,7 +110,8 @@ impl Animation for LeapAnimation {
next.torso.orientation = Quaternion::rotation_x( next.torso.orientation = Quaternion::rotation_x(
-0.3 + movement2 * -1.8 * PI + movement3 * -0.2 * PI + movement4 * -0.1 * PI, -0.3 + movement2 * -1.8 * PI + movement3 * -0.2 * PI + movement4 * -0.1 * PI,
); ) * Quaternion::rotation_y(0.0)
* Quaternion::rotation_z(0.0);
next.head.orientation = next.head.orientation =
Quaternion::rotation_x(0.0 + movement1 * -0.4 + movement2 * 0.4 + movement3 * 0.2); Quaternion::rotation_x(0.0 + movement1 * -0.4 + movement2 * 0.4 + movement3 * 0.2);
@ -135,7 +136,6 @@ impl Animation for LeapAnimation {
Quaternion::rotation_x(movement1 * 0.3 + movement2 * 0.1); Quaternion::rotation_x(movement1 * 0.3 + movement2 * 0.1);
next.upper_torso.position = Vec3::new(0.0, s_a.upper_torso.0, s_a.upper_torso.1 - 8.0); next.upper_torso.position = Vec3::new(0.0, s_a.upper_torso.0, s_a.upper_torso.1 - 8.0);
next.torso.position = Vec3::new(0.0, 0.0, 0.0 + 8.0);
} }
next next

View File

@ -294,17 +294,17 @@ impl<'a> From<&'a Body> for SkeletonAttr {
}, },
shl: match (body.species, body.body_type) { shl: match (body.species, body.body_type) {
(Dullahan, _) => (-4.75, -11.0, 8.5, 1.47, -0.2, 0.0), (Dullahan, _) => (-4.75, -11.0, 8.5, 1.47, -0.2, 0.0),
(Mightysaurok, _) => (-4.75, -11.0, 8.5, 1.47, -0.2, 0.0), (Mightysaurok, _) => (-1.75, -9.0, 3.5, 1.47, -0.2, 0.0),
(_, _) => (-4.75, -1.0, 2.5, 1.47, -0.2, 0.0), (_, _) => (-4.75, -1.0, 2.5, 1.47, -0.2, 0.0),
}, },
shr: match (body.species, body.body_type) { shr: match (body.species, body.body_type) {
(Dullahan, _) => (5.75, -11.5, 4.5, 1.47, 0.3, 0.0), (Dullahan, _) => (5.75, -11.5, 4.5, 1.47, 0.3, 0.0),
(Mightysaurok, _) => (-4.75, -11.0, 8.5, 1.47, -0.2, 0.0), (Mightysaurok, _) => (2.75, -9.5, -0.5, 1.47, 0.3, 0.0),
(_, _) => (3.75, -1.5, -0.5, 1.47, 0.3, 0.0), (_, _) => (3.75, -1.5, -0.5, 1.47, 0.3, 0.0),
}, },
sc: match (body.species, body.body_type) { sc: match (body.species, body.body_type) {
(Dullahan, _) => (-7.0, 17.0, -16.0, -0.1, 0.0, 0.0), (Dullahan, _) => (-7.0, 17.0, -16.0, -0.1, 0.0, 0.0),
(Mightysaurok, _) => (-4.75, -11.0, 8.5, 1.47, -0.2, 0.0), (Mightysaurok, _) => (-7.0, 15.0, -11.0, -0.1, 0.0, 0.0),
(_, _) => (-7.0, 7.0, -10.0, -0.1, 0.0, 0.0), (_, _) => (-7.0, 7.0, -10.0, -0.1, 0.0, 0.0),
}, },
hhl: match (body.species, body.body_type) { hhl: match (body.species, body.body_type) {
@ -326,18 +326,18 @@ impl<'a> From<&'a Body> for SkeletonAttr {
(_, _) => (8.5, 6.0, -12.0, -0.57, -1.57, 1.0), (_, _) => (8.5, 6.0, -12.0, -0.57, -1.57, 1.0),
}, },
sthl: match (body.species, body.body_type) { sthl: match (body.species, body.body_type) {
(Ogre, Female) => (11.0, 5.0, -4.0, 1.27, 0.0, 0.0), (Ogre, Female) => (-1.0, -5.0, 12.0, 1.27, 0.0, 0.0),
(Occultsaurok, _) => (11.0, 5.0, -4.0, 1.27, 0.0, 0.0), (Occultsaurok, _) => (-1.0, -7.0, 12.0, 1.27, 0.0, 0.0),
(_, _) => (11.0, 5.0, -4.0, 1.27, 0.0, 0.0), (_, _) => (11.0, 5.0, -4.0, 1.27, 0.0, 0.0),
}, },
sthr: match (body.species, body.body_type) { sthr: match (body.species, body.body_type) {
(Ogre, Female) => (17.0, 7.5, 2.0, 1.57, 0.8, 0.0), (Ogre, Female) => (5.0, -3.5, 18.0, 1.57, 0.8, 0.0),
(Occultsaurok, _) => (17.0, 7.5, 2.0, 1.57, 0.8, 0.0), (Occultsaurok, _) => (7.0, -3.5, 18.0, 1.57, 0.8, 0.0),
(_, _) => (17.0, 7.5, 2.0, 1.57, 0.8, 0.0), (_, _) => (17.0, 7.5, 2.0, 1.57, 0.8, 0.0),
}, },
stc: match (body.species, body.body_type) { stc: match (body.species, body.body_type) {
(Ogre, Female) => (-18.0, 1.0, -2.0, -0.3, 0.15, 0.0), (Ogre, Female) => (-18.0, 1.0, -2.0, -0.3, 0.15, 0.0),
(Occultsaurok, _) => (-18.0, 1.0, -2.0, -0.3, 0.15, 0.0), (Occultsaurok, _) => (-10.0, 7.0, -22.0, -0.3, 0.15, 0.0),
(_, _) => (-18.0, 1.0, -2.0, -0.3, 0.15, 0.0), (_, _) => (-18.0, 1.0, -2.0, -0.3, 0.15, 0.0),
}, },
ahl: match (body.species, body.body_type) { ahl: match (body.species, body.body_type) {
@ -350,15 +350,15 @@ impl<'a> From<&'a Body> for SkeletonAttr {
(_, _) => (-8.0, 11.0, 3.0, 2.0, 0.0, 3.14), (_, _) => (-8.0, 11.0, 3.0, 2.0, 0.0, 3.14),
}, },
bhl: match (body.species, body.body_type) { bhl: match (body.species, body.body_type) {
(Slysaurok, _) => (3.0, 2.5, 0.0, 1.2, -0.6, -0.3), (Slysaurok, _) => (-1.0, -12.0, 1.0, 1.57, 0.0, 0.0),
(_, _) => (3.0, 2.5, 0.0, 1.2, -0.6, -0.3), (_, _) => (3.0, 2.5, 0.0, 1.2, -0.6, -0.3),
}, },
bhr: match (body.species, body.body_type) { bhr: match (body.species, body.body_type) {
(Slysaurok, _) => (3.0, 2.5, 0.0, 1.2, -0.6, -0.3), (Slysaurok, _) => (0.0, -6.0, -2.0, 1.57, 0.0, 0.0),
(_, _) => (5.9, 5.5, -5.0, 1.2, -0.6, -0.3), (_, _) => (5.9, 5.5, -5.0, 1.2, -0.6, -0.3),
}, },
bc: match (body.species, body.body_type) { bc: match (body.species, body.body_type) {
(Slysaurok, _) => (3.0, 2.5, 0.0, 1.2, -0.6, -0.3), (Slysaurok, _) => (1.0, 13.0, -8.0, 0.0, 1.2, -0.6),
(_, _) => (-7.0, 3.0, -8.0, 0.0, 0.0, 0.0), (_, _) => (-7.0, 3.0, -8.0, 0.0, 0.0, 0.0),
}, },
beast: matches!((body.species, body.body_type), (Werewolf, _)), beast: matches!((body.species, body.body_type), (Werewolf, _)),

View File

@ -2,12 +2,21 @@ use super::{
super::{vek::*, Animation}, super::{vek::*, Animation},
BipedLargeSkeleton, SkeletonAttr, BipedLargeSkeleton, SkeletonAttr,
}; };
use common::comp::item::ToolKind;
use std::{f32::consts::PI, ops::Mul}; use std::{f32::consts::PI, ops::Mul};
pub struct RunAnimation; pub struct RunAnimation;
impl Animation for RunAnimation { impl Animation for RunAnimation {
type Dependency = (f32, Vec3<f32>, Vec3<f32>, f64, Vec3<f32>); type Dependency = (
Option<ToolKind>,
Option<ToolKind>,
f32,
Vec3<f32>,
Vec3<f32>,
f64,
Vec3<f32>,
);
type Skeleton = BipedLargeSkeleton; type Skeleton = BipedLargeSkeleton;
#[cfg(feature = "use-dyn-lib")] #[cfg(feature = "use-dyn-lib")]
@ -16,7 +25,15 @@ impl Animation for RunAnimation {
#[cfg_attr(feature = "be-dyn-lib", export_name = "biped_large_run")] #[cfg_attr(feature = "be-dyn-lib", export_name = "biped_large_run")]
fn update_skeleton_inner( fn update_skeleton_inner(
skeleton: &Self::Skeleton, skeleton: &Self::Skeleton,
(velocity, orientation, last_ori, global_time, avg_vel): Self::Dependency, (
active_tool_kind,
_second_tool_kind,
velocity,
orientation,
last_ori,
global_time,
avg_vel,
): Self::Dependency,
anim_time: f64, anim_time: f64,
rate: &mut f32, rate: &mut f32,
s_a: &SkeletonAttr, s_a: &SkeletonAttr,
@ -279,10 +296,33 @@ impl Animation for RunAnimation {
* Quaternion::rotation_y(0.0) * Quaternion::rotation_y(0.0)
* Quaternion::rotation_z(0.0); * Quaternion::rotation_z(0.0);
next.main.position = Vec3::new(-5.0, -7.0, 7.0); match active_tool_kind {
next.main.orientation = Quaternion::rotation_x(PI) Some(ToolKind::Bow(_)) => {
* Quaternion::rotation_y(0.6) next.main.position = Vec3::new(-2.0, -5.0, -6.0);
* Quaternion::rotation_z(1.57); next.main.orientation =
Quaternion::rotation_y(2.5) * Quaternion::rotation_z(1.57);
},
Some(ToolKind::Staff(_)) | Some(ToolKind::Sceptre(_)) => {
next.main.position = Vec3::new(-6.0, -5.0, -12.0);
next.main.orientation =
Quaternion::rotation_y(0.6) * Quaternion::rotation_z(1.57);
},
Some(ToolKind::Sword(_)) => {
next.main.position = Vec3::new(-10.0, -8.0, 12.0);
next.main.orientation =
Quaternion::rotation_y(2.5) * Quaternion::rotation_z(1.57);
},
Some(ToolKind::Hammer(_)) => {
next.main.position = Vec3::new(-10.0, -8.0, 12.0);
next.main.orientation =
Quaternion::rotation_y(2.5) * Quaternion::rotation_z(1.57);
},
_ => {
next.main.position = Vec3::new(-2.0, -5.0, -6.0);
next.main.orientation =
Quaternion::rotation_y(0.6) * Quaternion::rotation_z(1.57);
},
}
next.shoulder_l.position = Vec3::new( next.shoulder_l.position = Vec3::new(
-s_a.shoulder.0, -s_a.shoulder.0,

View File

@ -39,36 +39,33 @@ impl Animation for ShockwaveAnimation {
_ => (0.0, 0.0, 0.0), _ => (0.0, 0.0, 0.0),
}; };
let movement = (anim_time as f32 * 1.0).min(1.0);
next.head.position = Vec3::new(0.0, s_a.head.0, s_a.head.1); next.head.position = Vec3::new(0.0, s_a.head.0, s_a.head.1);
next.hand_l.position = Vec3::new(0.0, 0.0, -4.0); next.hand_l.position = Vec3::new(s_a.sthl.0, s_a.sthl.1, s_a.sthl.2);
next.hand_l.orientation = Quaternion::rotation_x(1.27) * Quaternion::rotation_y(0.0); next.hand_l.orientation =
next.hand_l.scale = Vec3::one() * 1.04; Quaternion::rotation_x(s_a.sthl.3) * Quaternion::rotation_y(s_a.sthl.4);
next.hand_r.position = Vec3::new(0.0, 0.0, 2.0); next.hand_r.position = Vec3::new(s_a.sthr.0, s_a.sthr.1, s_a.sthr.2);
next.hand_r.orientation = Quaternion::rotation_x(1.57) * Quaternion::rotation_y(0.2); next.hand_r.orientation =
next.hand_r.scale = Vec3::one() * 1.04; Quaternion::rotation_x(s_a.sthr.3) * Quaternion::rotation_y(s_a.sthr.4);
next.main.position = Vec3::new(0.0, 8.0, 13.2); next.main.position = Vec3::new(0.0, 0.0, 0.0);
next.main.orientation = Quaternion::rotation_y(PI); next.main.orientation = Quaternion::rotation_y(0.0);
next.control.position = Vec3::new(-4.0, 7.0, 4.0); next.control.position = Vec3::new(s_a.stc.0, s_a.stc.1, s_a.stc.2);
next.control.orientation = Quaternion::rotation_x(-0.3) next.control.orientation =
* Quaternion::rotation_y(0.15) Quaternion::rotation_x(s_a.stc.3) * Quaternion::rotation_y(s_a.stc.4);
* Quaternion::rotation_z(0.0);
let twist = movement * 0.8; let twist = movement1 * 0.8;
next.control.position = Vec3::new( next.control.position = Vec3::new(
-4.0 + movement1 * 5.0 + movement3 * -5.0, s_a.stc.0 + movement1 * 5.0 + movement3 * -5.0,
7.0 + movement1 * 3.0 + movement3 * -3.0, s_a.stc.1 + movement1 * 3.0 + movement3 * -3.0,
4.0 + movement1 * 10.0 + movement2 * -2.0 + movement3 * -8.0, s_a.stc.2 + movement1 * 10.0 + movement2 * -2.0 + movement3 * -8.0,
); );
next.control.orientation = next.control.orientation = Quaternion::rotation_x(
Quaternion::rotation_x(-0.3 + movement1 * 0.8 + movement2 * 0.3 + movement3 * -1.1) s_a.stc.3 + movement1 * 0.8 + movement2 * 0.3 + movement3 * -1.1,
* Quaternion::rotation_y( ) * Quaternion::rotation_y(
0.15 + movement1 * -0.15 + movement2 * 0.3 + movement3 * -0.45, s_a.stc.4 + movement1 * -0.15 + movement2 * 0.3 + movement3 * -0.45,
) ) * Quaternion::rotation_z(movement1 * 0.8 + movement2 * -0.8);
* Quaternion::rotation_z(movement1 * 0.8 + movement2 * -0.8);
next.head.orientation = Quaternion::rotation_x(movement1 * 0.4 + movement3 * -0.4) next.head.orientation = Quaternion::rotation_x(movement1 * 0.4 + movement3 * -0.4)
* Quaternion::rotation_z(twist * 0.2 + movement2 * -0.8 + movement3 * 0.6); * Quaternion::rotation_z(twist * 0.2 + movement2 * -0.8 + movement3 * 0.6);

View File

@ -15,265 +15,378 @@ impl Animation for ShootAnimation {
const UPDATE_FN: &'static [u8] = b"biped_large_shoot\0"; const UPDATE_FN: &'static [u8] = b"biped_large_shoot\0";
#[cfg_attr(feature = "be-dyn-lib", export_name = "biped_large_shoot")] #[cfg_attr(feature = "be-dyn-lib", export_name = "biped_large_shoot")]
fn update_skeleton_inner( /* fn update_skeleton_inner(
skeleton: &Self::Skeleton, skeleton: &Self::Skeleton,
(active_tool_kind, _second_tool_kind, velocity, global_time): Self::Dependency, (active_tool_kind, _second_tool_kind, velocity, global_time): Self::Dependency,
anim_time: f64, anim_time: f64,
_rate: &mut f32, _rate: &mut f32,
s_a: &SkeletonAttr, s_a: &SkeletonAttr,
) -> Self::Skeleton { ) -> Self::Skeleton {
let mut next = (*skeleton).clone(); let mut next = (*skeleton).clone();
let lab = 0.55; let lab = 0.55;
let breathe = (anim_time as f32 + 1.5 * PI).sin(); let breathe = (anim_time as f32 + 1.5 * PI).sin();
let test = (anim_time as f32 + 36.0 * PI).sin(); let test = (anim_time as f32 + 36.0 * PI).sin();
let slower = (anim_time as f32 * 1.0 + PI).sin(); let slower = (anim_time as f32 * 1.0 + PI).sin();
let slow = (anim_time as f32 * 3.5 + PI).sin(); let slow = (anim_time as f32 * 3.5 + PI).sin();
let exp = ((anim_time as f32).powf(0.3 as f32)).min(1.2); let exp = ((anim_time as f32).powf(0.3 as f32)).min(1.2);
let tailmove = Vec2::new( let tailmove = Vec2::new(
((global_time + anim_time) as f32 / 2.0) ((global_time + anim_time) as f32 / 2.0)
.floor() .floor()
.mul(7331.0) .mul(7331.0)
.sin() .sin()
* 0.25, * 0.25,
((global_time + anim_time) as f32 / 2.0) ((global_time + anim_time) as f32 / 2.0)
.floor() .floor()
.mul(1337.0) .mul(1337.0)
.sin() .sin()
* 0.125, * 0.125,
);
let 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,
);
let foothoril = (((1.0)
/ (0.4
+ (0.6)
* ((anim_time as f32 * 16.0 * lab as f32 + PI * 1.4).sin()).powf(2.0 as f32)))
.sqrt())
* ((anim_time as f32 * 16.0 * lab as f32 + PI * 1.4).sin());
let foothorir = (((1.0)
/ (0.4
+ (0.6)
* ((anim_time as f32 * 16.0 * lab as f32 + PI * 0.4).sin()).powf(2.0 as f32)))
.sqrt())
* ((anim_time as f32 * 16.0 * lab as f32 + PI * 0.4).sin());
let footvertl = (anim_time as f32 * 16.0 * lab as f32).sin();
let footvertr = (anim_time as f32 * 16.0 * lab as f32 + PI).sin();
let footrotl = (((5.0)
/ (2.5
+ (2.5)
* ((anim_time as f32 * 16.0 * lab as f32 + PI * 1.4).sin()).powf(2.0 as f32)))
.sqrt())
* ((anim_time as f32 * 16.0 * lab as f32 + PI * 1.4).sin());
let footrotr = (((5.0)
/ (1.0
+ (4.0)
* ((anim_time as f32 * 16.0 * lab as f32 + PI * 0.4).sin()).powf(2.0 as f32)))
.sqrt())
* ((anim_time as f32 * 16.0 * lab as f32 + PI * 0.4).sin());
let short = (anim_time as f32 * lab as f32 * 16.0).sin();
let shortalt = (anim_time as f32 * lab as f32 * 16.0 + PI / 2.0).sin();
if velocity < 0.5 {
next.head.position = Vec3::new(0.0, s_a.head.0, s_a.head.1 + breathe * 0.2) * 1.02;
next.head.orientation =
Quaternion::rotation_z(look.x * 0.6) * Quaternion::rotation_x(look.y * 0.6);
next.upper_torso.position =
Vec3::new(0.0, s_a.upper_torso.0, s_a.upper_torso.1 + breathe * 0.5);
next.upper_torso.orientation =
Quaternion::rotation_z(0.0) * Quaternion::rotation_x(0.0);
next.lower_torso.position =
Vec3::new(0.0, s_a.lower_torso.0, s_a.lower_torso.1 + breathe * 0.15);
next.lower_torso.orientation =
Quaternion::rotation_z(0.0) * Quaternion::rotation_x(0.0);
next.jaw.position = Vec3::new(0.0, s_a.jaw.0 - slower * 0.12, s_a.jaw.1 + slow * 0.2);
next.jaw.orientation = Quaternion::rotation_x(slow * 0.05);
next.tail.position = Vec3::new(0.0, s_a.tail.0, s_a.tail.1);
next.tail.orientation =
Quaternion::rotation_z(0.0 + slow * 0.2 + tailmove.x) * Quaternion::rotation_x(0.0);
next.shoulder_l.position = Vec3::new(-s_a.shoulder.0, s_a.shoulder.1, s_a.shoulder.2);
next.shoulder_l.orientation = Quaternion::rotation_z(0.0) * Quaternion::rotation_x(0.0);
next.shoulder_r.position = Vec3::new(s_a.shoulder.0, s_a.shoulder.1, s_a.shoulder.2);
next.shoulder_r.orientation = Quaternion::rotation_z(0.0) * Quaternion::rotation_x(0.0);
next.leg_l.position =
Vec3::new(-s_a.leg.0, s_a.leg.1, s_a.leg.2 + breathe * 0.2) * 1.02;
next.leg_l.orientation = Quaternion::rotation_z(0.0);
next.leg_r.position = Vec3::new(s_a.leg.0, s_a.leg.1, s_a.leg.2 + breathe * 0.2) * 1.02;
next.leg_r.orientation = Quaternion::rotation_z(0.0);
next.foot_l.position = Vec3::new(-s_a.foot.0, s_a.foot.1, s_a.foot.2);
next.foot_l.orientation = Quaternion::rotation_z(0.0);
next.foot_r.position = Vec3::new(s_a.foot.0, s_a.foot.1, s_a.foot.2);
next.foot_r.orientation = Quaternion::rotation_z(0.0);
next.torso.position = Vec3::new(0.0, 0.0, 0.0) / 8.0;
next.torso.orientation = Quaternion::rotation_z(test * 0.0);
next.control.position = Vec3::new(7.0, 9.0, -10.0);
next.control.orientation = Quaternion::rotation_x(test * 0.02)
* Quaternion::rotation_y(test * 0.02)
* Quaternion::rotation_z(test * 0.02);
} else {
next.head.position = Vec3::new(0.0, s_a.head.0, s_a.head.1) * 1.02;
next.head.orientation =
Quaternion::rotation_z(short * -0.18) * Quaternion::rotation_x(-0.05);
next.upper_torso.position =
Vec3::new(0.0, s_a.upper_torso.0, s_a.upper_torso.1 + shortalt * -1.5);
next.upper_torso.orientation = Quaternion::rotation_z(short * 0.18);
next.lower_torso.position = Vec3::new(0.0, s_a.lower_torso.0, s_a.lower_torso.1);
next.lower_torso.orientation =
Quaternion::rotation_z(short * 0.15) * Quaternion::rotation_x(0.14);
next.jaw.position = Vec3::new(0.0, s_a.jaw.0 - slower * 0.12, s_a.jaw.1 + slow * 0.2);
next.jaw.orientation = Quaternion::rotation_x(slow * 0.05);
next.tail.orientation =
Quaternion::rotation_z(0.0 + slow * 0.2 + tailmove.x) * Quaternion::rotation_x(0.0);
next.shoulder_l.position = Vec3::new(
-s_a.shoulder.0,
s_a.shoulder.1 + foothoril * -1.0,
s_a.shoulder.2,
); );
next.shoulder_l.orientation = Quaternion::rotation_x(0.5 + footrotl * -0.16)
* Quaternion::rotation_y(0.1)
* Quaternion::rotation_z(footrotl * 0.1);
next.shoulder_r.position = Vec3::new( let look = Vec2::new(
s_a.shoulder.0, ((global_time + anim_time) as f32 / 8.0)
s_a.shoulder.1 + foothorir * -1.0, .floor()
s_a.shoulder.2, .mul(7331.0)
.sin()
* 0.5,
((global_time + anim_time) as f32 / 8.0)
.floor()
.mul(1337.0)
.sin()
* 0.25,
); );
next.shoulder_r.orientation = Quaternion::rotation_x(0.5 + footrotr * -0.16)
* Quaternion::rotation_y(-0.1)
* Quaternion::rotation_z(footrotr * -0.1);
next.torso.position = Vec3::new(0.0, 0.0, 0.0) / 8.0; let foothoril = (((1.0)
next.torso.orientation = Quaternion::rotation_z(0.0) * Quaternion::rotation_x(-0.25); / (0.4
+ (0.6)
* ((anim_time as f32 * 16.0 * lab as f32 + PI * 1.4).sin()).powf(2.0 as f32)))
.sqrt())
* ((anim_time as f32 * 16.0 * lab as f32 + PI * 1.4).sin());
let foothorir = (((1.0)
/ (0.4
+ (0.6)
* ((anim_time as f32 * 16.0 * lab as f32 + PI * 0.4).sin()).powf(2.0 as f32)))
.sqrt())
* ((anim_time as f32 * 16.0 * lab as f32 + PI * 0.4).sin());
next.leg_l.orientation = let footvertl = (anim_time as f32 * 16.0 * lab as f32).sin();
Quaternion::rotation_z(short * 0.18) * Quaternion::rotation_x(foothoril * 0.3); let footvertr = (anim_time as f32 * 16.0 * lab as f32 + PI).sin();
next.leg_r.orientation = let footrotl = (((5.0)
Quaternion::rotation_z(short * 0.18) * Quaternion::rotation_x(foothorir * 0.3); / (2.5
+ (2.5)
* ((anim_time as f32 * 16.0 * lab as f32 + PI * 1.4).sin()).powf(2.0 as f32)))
.sqrt())
* ((anim_time as f32 * 16.0 * lab as f32 + PI * 1.4).sin());
next.foot_l.position = Vec3::new( let footrotr = (((5.0)
-s_a.foot.0, / (1.0
4.0 + s_a.foot.1 + foothoril * 8.5, + (4.0)
s_a.foot.2 + ((footvertl * 6.5).max(0.0)), * ((anim_time as f32 * 16.0 * lab as f32 + PI * 0.4).sin()).powf(2.0 as f32)))
); .sqrt())
next.foot_l.orientation = Quaternion::rotation_x(-0.5 + footrotl * 0.85); * ((anim_time as f32 * 16.0 * lab as f32 + PI * 0.4).sin());
next.foot_r.position = Vec3::new( let short = (anim_time as f32 * lab as f32 * 16.0).sin();
s_a.foot.0, let shortalt = (anim_time as f32 * lab as f32 * 16.0 + PI / 2.0).sin();
4.0 + s_a.foot.1 + foothorir * 8.5,
s_a.foot.2 + ((footvertr * 6.5).max(0.0)),
);
next.foot_r.orientation = Quaternion::rotation_x(-0.5 + footrotr * 0.85);
}
match active_tool_kind {
Some(ToolKind::Bow(_)) => {
next.hand_l.position =
Vec3::new(-10.0 - exp * 2.0, -4.0 - exp * 4.0, -1.0 + exp * 6.0);
next.hand_l.orientation = Quaternion::rotation_x(1.20)
* Quaternion::rotation_y(-0.6 + exp * 0.8)
* Quaternion::rotation_z(-0.3 + exp * 0.9);
next.hand_r.position = Vec3::new(4.9, 3.0, -4.0); if velocity < 0.5 {
next.hand_r.orientation = Quaternion::rotation_x(1.20) next.head.position = Vec3::new(0.0, s_a.head.0, s_a.head.1 + breathe * 0.2) * 1.02;
* Quaternion::rotation_y(-0.6) next.head.orientation =
* Quaternion::rotation_z(-0.3); Quaternion::rotation_z(look.x * 0.6) * Quaternion::rotation_x(look.y * 0.6);
next.upper_torso.position =
Vec3::new(0.0, s_a.upper_torso.0, s_a.upper_torso.1 + breathe * 0.5);
next.upper_torso.orientation =
Quaternion::rotation_z(0.0) * Quaternion::rotation_x(0.0);
next.lower_torso.position =
Vec3::new(0.0, s_a.lower_torso.0, s_a.lower_torso.1 + breathe * 0.15);
next.lower_torso.orientation =
Quaternion::rotation_z(0.0) * Quaternion::rotation_x(0.0);
next.jaw.position = Vec3::new(0.0, s_a.jaw.0 - slower * 0.12, s_a.jaw.1 + slow * 0.2);
next.jaw.orientation = Quaternion::rotation_x(slow * 0.05);
next.tail.position = Vec3::new(0.0, s_a.tail.0, s_a.tail.1);
next.tail.orientation =
Quaternion::rotation_z(0.0 + slow * 0.2 + tailmove.x) * Quaternion::rotation_x(0.0);
next.shoulder_l.position = Vec3::new(-s_a.shoulder.0, s_a.shoulder.1, s_a.shoulder.2);
next.shoulder_l.orientation = Quaternion::rotation_z(0.0) * Quaternion::rotation_x(0.0);
next.shoulder_r.position = Vec3::new(s_a.shoulder.0, s_a.shoulder.1, s_a.shoulder.2);
next.shoulder_r.orientation = Quaternion::rotation_z(0.0) * Quaternion::rotation_x(0.0);
next.leg_l.position =
Vec3::new(-s_a.leg.0, s_a.leg.1, s_a.leg.2 + breathe * 0.2) * 1.02;
next.leg_l.orientation = Quaternion::rotation_z(0.0);
next.leg_r.position = Vec3::new(s_a.leg.0, s_a.leg.1, s_a.leg.2 + breathe * 0.2) * 1.02;
next.leg_r.orientation = Quaternion::rotation_z(0.0);
next.foot_l.position = Vec3::new(-s_a.foot.0, s_a.foot.1, s_a.foot.2);
next.foot_l.orientation = Quaternion::rotation_z(0.0);
next.foot_r.position = Vec3::new(s_a.foot.0, s_a.foot.1, s_a.foot.2);
next.foot_r.orientation = Quaternion::rotation_z(0.0);
next.torso.position = Vec3::new(0.0, 0.0, 0.0) / 8.0;
next.torso.orientation = Quaternion::rotation_z(test * 0.0);
next.control.position = Vec3::new(7.0, 9.0, -10.0);
next.control.orientation = Quaternion::rotation_x(test * 0.02)
* Quaternion::rotation_y(test * 0.02)
* Quaternion::rotation_z(test * 0.02);
} else {
next.head.position = Vec3::new(0.0, s_a.head.0, s_a.head.1) * 1.02;
next.head.orientation =
Quaternion::rotation_z(short * -0.18) * Quaternion::rotation_x(-0.05);
next.upper_torso.position =
Vec3::new(0.0, s_a.upper_torso.0, s_a.upper_torso.1 + shortalt * -1.5);
next.upper_torso.orientation = Quaternion::rotation_z(short * 0.18);
next.lower_torso.position = Vec3::new(0.0, s_a.lower_torso.0, s_a.lower_torso.1);
next.lower_torso.orientation =
Quaternion::rotation_z(short * 0.15) * Quaternion::rotation_x(0.14);
next.jaw.position = Vec3::new(0.0, s_a.jaw.0 - slower * 0.12, s_a.jaw.1 + slow * 0.2);
next.jaw.orientation = Quaternion::rotation_x(slow * 0.05);
next.tail.orientation =
Quaternion::rotation_z(0.0 + slow * 0.2 + tailmove.x) * Quaternion::rotation_x(0.0);
next.shoulder_l.position = Vec3::new( next.shoulder_l.position = Vec3::new(
-s_a.shoulder.0, -s_a.shoulder.0,
s_a.shoulder.1 + foothoril * -1.0, s_a.shoulder.1 + foothoril * -1.0,
s_a.shoulder.2, s_a.shoulder.2,
); );
next.shoulder_l.orientation = Quaternion::rotation_x(1.4 + footrotl * -0.06) next.shoulder_l.orientation = Quaternion::rotation_x(0.5 + footrotl * -0.16)
* Quaternion::rotation_y(-0.9) * Quaternion::rotation_y(0.1)
* Quaternion::rotation_z(footrotl * -0.05); * Quaternion::rotation_z(footrotl * 0.1);
next.shoulder_r.position = Vec3::new( next.shoulder_r.position = Vec3::new(
s_a.shoulder.0, s_a.shoulder.0,
s_a.shoulder.1 + foothorir * -1.0, s_a.shoulder.1 + foothorir * -1.0,
s_a.shoulder.2, s_a.shoulder.2,
); );
next.shoulder_r.orientation = Quaternion::rotation_x(1.8 + footrotr * -0.06) next.shoulder_r.orientation = Quaternion::rotation_x(0.5 + footrotr * -0.16)
* Quaternion::rotation_y(-0.5) //1.9 * Quaternion::rotation_y(-0.1)
* Quaternion::rotation_z(footrotr * -0.05); * Quaternion::rotation_z(footrotr * -0.1);
next.jaw.position = Vec3::new(0.0, s_a.jaw.0, s_a.jaw.1); next.torso.position = Vec3::new(0.0, 0.0, 0.0) / 8.0;
next.jaw.orientation = Quaternion::rotation_x(-0.2); next.torso.orientation = Quaternion::rotation_z(0.0) * Quaternion::rotation_x(-0.25);
next.main.position = Vec3::new(7.0, 5.0, -13.0); next.leg_l.orientation =
next.main.orientation = Quaternion::rotation_x(-0.3) Quaternion::rotation_z(short * 0.18) * Quaternion::rotation_x(foothoril * 0.3);
* Quaternion::rotation_y(0.3)
* Quaternion::rotation_z(-0.6);
next.control.position = Vec3::new(6.0, 6.0, 8.0); next.leg_r.orientation =
next.control.orientation = Quaternion::rotation_x(exp * 0.4); Quaternion::rotation_z(short * 0.18) * Quaternion::rotation_x(foothorir * 0.3);
},
Some(ToolKind::Staff(_)) => {
next.hand_l.position = Vec3::new(11.0, 5.0, -4.0);
next.hand_l.orientation =
Quaternion::rotation_x(1.27) * Quaternion::rotation_y(0.0);
next.hand_r.position = Vec3::new(12.0, 5.5, 2.0); next.foot_l.position = Vec3::new(
-s_a.foot.0,
4.0 + s_a.foot.1 + foothoril * 8.5,
s_a.foot.2 + ((footvertl * 6.5).max(0.0)),
);
next.foot_l.orientation = Quaternion::rotation_x(-0.5 + footrotl * 0.85);
next.foot_r.position = Vec3::new(
s_a.foot.0,
4.0 + s_a.foot.1 + foothorir * 8.5,
s_a.foot.2 + ((footvertr * 6.5).max(0.0)),
);
next.foot_r.orientation = Quaternion::rotation_x(-0.5 + footrotr * 0.85);
}
match active_tool_kind {
Some(ToolKind::Bow(_)) => {
next.hand_l.position =
Vec3::new(-10.0 - exp * 2.0, -4.0 - exp * 4.0, -1.0 + exp * 6.0);
next.hand_l.orientation = Quaternion::rotation_x(1.20)
* Quaternion::rotation_y(-0.6 + exp * 0.8)
* Quaternion::rotation_z(-0.3 + exp * 0.9);
next.hand_r.position = Vec3::new(4.9, 3.0, -4.0);
next.hand_r.orientation = Quaternion::rotation_x(1.20)
* Quaternion::rotation_y(-0.6)
* Quaternion::rotation_z(-0.3);
next.shoulder_l.position = Vec3::new(
-s_a.shoulder.0,
s_a.shoulder.1 + foothoril * -1.0,
s_a.shoulder.2,
);
next.shoulder_l.orientation = Quaternion::rotation_x(1.4 + footrotl * -0.06)
* Quaternion::rotation_y(-0.9)
* Quaternion::rotation_z(footrotl * -0.05);
next.shoulder_r.position = Vec3::new(
s_a.shoulder.0,
s_a.shoulder.1 + foothorir * -1.0,
s_a.shoulder.2,
);
next.shoulder_r.orientation = Quaternion::rotation_x(1.8 + footrotr * -0.06)
* Quaternion::rotation_y(-0.5) //1.9
* Quaternion::rotation_z(footrotr * -0.05);
next.jaw.position = Vec3::new(0.0, s_a.jaw.0, s_a.jaw.1);
next.jaw.orientation = Quaternion::rotation_x(-0.2);
next.main.position = Vec3::new(7.0, 5.0, -13.0);
next.main.orientation = Quaternion::rotation_x(-0.3)
* Quaternion::rotation_y(0.3)
* Quaternion::rotation_z(-0.6);
next.control.position = Vec3::new(6.0, 6.0, 8.0);
next.control.orientation = Quaternion::rotation_x(exp * 0.4);
},
Some(ToolKind::Staff(_)) => {
next.hand_l.position = Vec3::new(11.0, 5.0, -4.0);
next.hand_l.orientation =
Quaternion::rotation_x(1.27) * Quaternion::rotation_y(0.0);
next.hand_r.position = Vec3::new(12.0, 5.5, 2.0);
next.hand_r.orientation =
Quaternion::rotation_x(1.57) * Quaternion::rotation_y(0.2);
next.jaw.position = Vec3::new(0.0, s_a.jaw.0, s_a.jaw.1);
next.shoulder_l.position =
Vec3::new(-s_a.shoulder.0, s_a.shoulder.1, s_a.shoulder.2);
next.shoulder_l.orientation =
Quaternion::rotation_z(0.0) * Quaternion::rotation_x(2.0);
next.shoulder_r.position =
Vec3::new(s_a.shoulder.0, s_a.shoulder.1, s_a.shoulder.2);
next.shoulder_r.orientation =
Quaternion::rotation_z(0.4) * Quaternion::rotation_x(2.0);
next.jaw.orientation = Quaternion::rotation_x(-0.2);
next.main.position = Vec3::new(10.0, 12.5, 13.2);
next.main.orientation = Quaternion::rotation_y(PI);
next.control.position = Vec3::new(-7.0, 6.0, 6.0 - exp * 5.0);
next.control.orientation =
Quaternion::rotation_x(exp * 1.3) * Quaternion::rotation_z(exp * 1.5);
},
_ => {},
}
next
}
}
*/
fn update_skeleton_inner(
skeleton: &Self::Skeleton,
(active_tool_kind, _second_tool_kind, velocity, _global_time): Self::Dependency,
anim_time: f64,
rate: &mut f32,
s_a: &SkeletonAttr,
) -> Self::Skeleton {
*rate = 1.0;
let mut next = (*skeleton).clone();
let lab = 1.0;
let foot = (((5.0)
/ (0.2 + 4.8 * ((anim_time as f32 * lab as f32 * 8.0).sin()).powf(2.0 as f32)))
.sqrt())
* ((anim_time as f32 * lab as f32 * 8.0).sin());
let foote = (((5.0)
/ (0.5 + 4.5 * ((anim_time as f32 * lab as f32 * 8.0 + 1.57).sin()).powf(2.0 as f32)))
.sqrt())
* ((anim_time as f32 * lab as f32 * 8.0).sin());
let exp = ((anim_time as f32).powf(0.3 as f32)).min(1.2);
next.head.position = Vec3::new(0.0, s_a.head.0, s_a.head.1);
next.head.orientation = Quaternion::rotation_z(exp * -0.4)
* Quaternion::rotation_x(0.0)
* Quaternion::rotation_y(exp * 0.1);
next.upper_torso.position =
Vec3::new(0.0, s_a.upper_torso.0 - exp * 1.5, s_a.upper_torso.1);
next.upper_torso.orientation = Quaternion::rotation_z(0.4 + exp * 1.0)
* Quaternion::rotation_x(0.0 + exp * 0.2)
* Quaternion::rotation_y(exp * -0.08);
next.lower_torso.position =
Vec3::new(0.0, s_a.lower_torso.0 + exp * 1.0, s_a.lower_torso.1);
next.lower_torso.orientation = next.upper_torso.orientation * -0.08;
match active_tool_kind {
Some(ToolKind::Staff(_)) | Some(ToolKind::Sceptre(_)) => {
next.hand_l.position = Vec3::new(s_a.sthl.0, s_a.sthl.1, s_a.sthl.2);
next.hand_l.orientation = Quaternion::rotation_x(s_a.sthl.3);
next.hand_r.position = Vec3::new(s_a.sthr.0, s_a.sthr.1, s_a.sthr.2);
next.hand_r.orientation = next.hand_r.orientation =
Quaternion::rotation_x(1.57) * Quaternion::rotation_y(0.2); Quaternion::rotation_x(s_a.sthr.3) * Quaternion::rotation_y(s_a.sthr.4);
next.jaw.position = Vec3::new(0.0, s_a.jaw.0, s_a.jaw.1); next.main.position = Vec3::new(0.0, 0.0, 0.0);
next.main.orientation = Quaternion::rotation_y(0.0);
next.shoulder_l.position = next.control.position = Vec3::new(
Vec3::new(-s_a.shoulder.0, s_a.shoulder.1, s_a.shoulder.2); s_a.stc.0,
next.shoulder_l.orientation = s_a.stc.1 + exp * 5.0,
Quaternion::rotation_z(0.0) * Quaternion::rotation_x(2.0); 10.0 + s_a.stc.2 - exp * 5.0,
);
next.control.orientation = Quaternion::rotation_x(s_a.stc.3 + exp * 0.4)
* Quaternion::rotation_y(s_a.stc.4)
* Quaternion::rotation_z(s_a.stc.5 + exp * 1.5);
},
Some(ToolKind::Bow(_)) => {
next.hand_l.position = Vec3::new(
s_a.bhl.0 - exp * 2.0,
s_a.bhl.1 - exp * 4.0,
s_a.bhl.2 + exp * 6.0,
);
next.hand_l.orientation = Quaternion::rotation_x(s_a.bhl.3)
* Quaternion::rotation_y(s_a.bhl.4 + exp * 0.8)
* Quaternion::rotation_z(s_a.bhl.5 + exp * 0.9);
next.hand_r.position = Vec3::new(s_a.bhr.0, s_a.bhr.1, s_a.bhr.2);
next.hand_r.orientation = Quaternion::rotation_x(s_a.bhl.3)
* Quaternion::rotation_y(s_a.bhr.4)
* Quaternion::rotation_z(s_a.bhr.5);
next.main.position = Vec3::new(0.0, 0.0, 0.0);
next.main.orientation = Quaternion::rotation_x(0.0);
next.shoulder_r.position = next.control.position = Vec3::new(s_a.bc.0, s_a.bc.1, 4.0 + s_a.bc.2);
Vec3::new(s_a.shoulder.0, s_a.shoulder.1, s_a.shoulder.2); next.control.orientation = Quaternion::rotation_x(s_a.bc.3 + exp * 0.4);
next.shoulder_r.orientation =
Quaternion::rotation_z(0.4) * Quaternion::rotation_x(2.0);
next.jaw.orientation = Quaternion::rotation_x(-0.2);
next.main.position = Vec3::new(10.0, 12.5, 13.2);
next.main.orientation = Quaternion::rotation_y(PI);
next.control.position = Vec3::new(-7.0, 6.0, 6.0 - exp * 5.0);
next.control.orientation =
Quaternion::rotation_x(exp * 1.3) * Quaternion::rotation_z(exp * 1.5);
}, },
_ => {}, _ => {},
} }
if velocity > 0.5 {
next.foot_l.position = Vec3::new(
-s_a.foot.0 - foot * 1.0 + exp * -1.0,
foote * 0.8 + exp * 1.5,
s_a.foot.2,
);
next.foot_l.orientation = Quaternion::rotation_x(exp * 0.5)
* Quaternion::rotation_z(exp * 0.4)
* Quaternion::rotation_y(0.15);
next.foot_r.position = Vec3::new(
s_a.foot.0 + foot * 1.0 + exp * 1.0,
foote * -0.8 + exp * -1.0,
s_a.foot.2,
);
next.foot_r.orientation = Quaternion::rotation_x(exp * -0.5)
* Quaternion::rotation_z(exp * 0.4)
* Quaternion::rotation_y(0.0);
next.torso.orientation = Quaternion::rotation_x(-0.15);
} else {
next.foot_l.position = Vec3::new(-s_a.foot.0, -2.5, s_a.foot.2 + exp * 2.5);
next.foot_l.orientation =
Quaternion::rotation_x(exp * -0.2 - 0.2) * Quaternion::rotation_z(exp * 1.0);
next.foot_r.position = Vec3::new(s_a.foot.0, 3.5 - exp * 2.0, s_a.foot.2);
next.foot_r.orientation =
Quaternion::rotation_x(exp * 0.1) * Quaternion::rotation_z(exp * 0.5);
}
next next
} }

View File

@ -33,9 +33,9 @@ impl Animation for SpinAnimation {
let lab = 1.0; let lab = 1.0;
let (movement1, movement2, movement3) = match stage_section { let (movement1, movement2, movement3) = match stage_section {
Some(StageSection::Buildup) => (anim_time as f32, 0.0, 0.0), Some(StageSection::Buildup) => ((anim_time as f32).powf(0.25), 0.0, 0.0),
Some(StageSection::Swing) => (1.0, anim_time as f32, 0.0), Some(StageSection::Swing) => (1.0, (anim_time as f32).powf(1.8), 0.0),
Some(StageSection::Recover) => (1.0, 1.0, anim_time as f32), Some(StageSection::Recover) => (1.0, 1.0, (anim_time as f32).powf(4.0)),
_ => (0.0, 0.0, 0.0), _ => (0.0, 0.0, 0.0),
}; };
@ -49,44 +49,35 @@ impl Animation for SpinAnimation {
let spin = (anim_time as f32 * 2.8 * lab as f32).sin(); let spin = (anim_time as f32 * 2.8 * lab as f32).sin();
let spinhalf = (anim_time as f32 * 1.4 * lab as f32).sin(); let spinhalf = (anim_time as f32 * 1.4 * lab as f32).sin();
fn slow(x: f32) -> f32 { (x * 8.0).sin() }
let stab = (anim_time as f32 * 8.0).sin();
let rotate = (anim_time as f32 * 1.0).sin();
next.head.position = Vec3::new(0.0, s_a.head.0, s_a.head.1); next.head.position = Vec3::new(0.0, s_a.head.0, s_a.head.1);
if let Some(ToolKind::Sword(_)) = active_tool_kind { if let Some(ToolKind::Sword(_)) = active_tool_kind {
next.hand_l.position = Vec3::new(-4.75, -1.0, 2.5); next.main.position = Vec3::new(0.0, 0.0, 0.0);
next.hand_l.orientation = Quaternion::rotation_x(1.47) * Quaternion::rotation_y(-0.2); next.main.orientation = Quaternion::rotation_x(0.0);
next.hand_r.position = Vec3::new(0.75, -1.5, -0.5);
next.hand_r.orientation = Quaternion::rotation_x(1.47) * Quaternion::rotation_y(0.3); next.hand_l.position = Vec3::new(s_a.shl.0, s_a.shl.1, s_a.shl.2);
next.main.position = Vec3::new(0.0, 5.0, -6.0); next.hand_l.orientation =
next.main.orientation = Quaternion::rotation_x(-0.1) Quaternion::rotation_x(s_a.shl.3) * Quaternion::rotation_y(s_a.shl.4);
* Quaternion::rotation_y(0.0) next.hand_r.position = Vec3::new(s_a.shr.0, s_a.shr.1, s_a.shr.2);
* Quaternion::rotation_z(0.0); next.hand_r.orientation =
Quaternion::rotation_x(s_a.shr.3) * Quaternion::rotation_y(s_a.shr.4);
next.control.position = Vec3::new( next.control.position = Vec3::new(
5.0 + movement1 * 2.0 + movement2 * -8.0 + movement3 * -7.0, s_a.sc.0 + movement1 * 2.0 + movement2 * -4.0 + movement3 * -7.0,
11.0 + slow(movement1) * 0.6 s_a.sc.1 + 8.0 + movement1 * 0.6 + movement3 * -10.0,
+ slow(movement2) * 3.0 s_a.sc.2 + 1.0 + movement1 * 0.6 + movement2 * 1.5 + movement3 * -4.0,
+ slow(movement3) * -0.8
+ movement3 * -10.0,
2.0 + slow(movement1) * 0.6
+ slow(movement2) * 3.5
+ movement2 * 3.0
+ slow(movement3) * -0.4
+ movement3 * -4.0,
); );
next.control.orientation = Quaternion::rotation_x( next.control.orientation = Quaternion::rotation_x(-0.5 + s_a.sc.3 + movement1 * -1.2)
movement1 * -1.57 + movement2 * -0.6 + slow(movement2) * -0.25, * Quaternion::rotation_y(s_a.sc.4 - 0.6 + movement1 * 1.0)
) * Quaternion::rotation_y( * Quaternion::rotation_z(s_a.sc.5 + 0.1 + movement1 * 1.57);
-0.57 + movement1 * 2.0 + movement2 * -2.0, next.head.position = Vec3::new(
) * Quaternion::rotation_z(movement1 + movement2); 0.0 + 2.0 + movement2 * -2.0,
2.0 + movement2 * -2.0 + s_a.head.0,
s_a.head.1,
);
next.head.orientation = Quaternion::rotation_z(movement2 * -0.4);
next.head.orientation = Quaternion::rotation_z(slow(movement2) * -0.8); next.upper_torso.orientation = Quaternion::rotation_x(movement2 * 0.15)
next.upper_torso.orientation = Quaternion::rotation_x(slow(movement2) * 0.15)
* Quaternion::rotation_y(movement1 * -0.1 + movement2 * 0.3 + movement3 * -0.1) * Quaternion::rotation_y(movement1 * -0.1 + movement2 * 0.3 + movement3 * -0.1)
* Quaternion::rotation_z( * Quaternion::rotation_z(
-1.0 + movement1 * -0.6 + movement2 * 1.5 + movement3 * 0.5, -1.0 + movement1 * -0.6 + movement2 * 1.5 + movement3 * 0.5,
@ -98,7 +89,7 @@ impl Animation for SpinAnimation {
next.head.orientation = Quaternion::rotation_y(movement1 * 0.1 - movement2 * -0.1) next.head.orientation = Quaternion::rotation_y(movement1 * 0.1 - movement2 * -0.1)
* Quaternion::rotation_z(1.07 + movement1 * 0.4 + movement2 * -1.5); * Quaternion::rotation_z(1.07 + movement1 * 0.4 + movement2 * -1.5);
next.torso.orientation = Quaternion::rotation_z((movement2).sin() * 7.2); next.torso.orientation = Quaternion::rotation_z(movement2 * 6.28);
} }
if let Some(ToolKind::Axe(_) | ToolKind::Hammer(_) | ToolKind::Dagger(_)) = active_tool_kind if let Some(ToolKind::Axe(_) | ToolKind::Hammer(_) | ToolKind::Dagger(_)) = active_tool_kind
@ -108,21 +99,24 @@ impl Animation for SpinAnimation {
next.hand_r.position = Vec3::new(0.75, -1.5, -5.5); next.hand_r.position = Vec3::new(0.75, -1.5, -5.5);
next.hand_r.orientation = Quaternion::rotation_x(1.27); next.hand_r.orientation = Quaternion::rotation_x(1.27);
next.main.position = Vec3::new(0.0, 6.0, -1.0); next.main.position = Vec3::new(0.0, 6.0, -1.0);
next.main.orientation = Quaternion::rotation_x(-0.3); next.main.orientation = Quaternion::rotation_x(-0.3)
* Quaternion::rotation_y(0.0)
* Quaternion::rotation_z(0.0);
next.control.position = Vec3::new(-4.5 + spinhalf * 4.0, 11.0, 8.0); next.control.position = Vec3::new(-4.5 + spinhalf * 4.0, 11.0, 8.0);
next.control.orientation = Quaternion::rotation_x(-1.7) next.control.orientation = Quaternion::rotation_x(-1.7)
* Quaternion::rotation_y(0.2 + spin * -2.0) * Quaternion::rotation_y(0.2 + spin * -2.0)
* Quaternion::rotation_z(1.4 + spin * 0.1); * Quaternion::rotation_z(1.4 + spin * 0.1);
next.head.position = Vec3::new(0.0, s_a.head.0 + spin * -0.8, s_a.head.1); next.head.position = Vec3::new(0.0, -1.0 + s_a.head.0 + spin * -0.8, s_a.head.1);
next.head.orientation = Quaternion::rotation_z(spin * -0.25) next.head.orientation = Quaternion::rotation_z(spin * -0.25)
* Quaternion::rotation_x(0.0 + spin * -0.1) * Quaternion::rotation_x(0.0 + spin * -0.1)
* Quaternion::rotation_y(spin * -0.2); * Quaternion::rotation_y(spin * -0.2);
next.upper_torso.position = Vec3::new(0.0, s_a.upper_torso.0, s_a.upper_torso.1); next.upper_torso.position = Vec3::new(0.0, s_a.upper_torso.0, s_a.upper_torso.1);
next.upper_torso.orientation = Quaternion::rotation_z(spin * 0.1) next.upper_torso.orientation = Quaternion::rotation_z(spin * 0.1)
* Quaternion::rotation_x(spin * 0.1) * Quaternion::rotation_x(0.0 + spin * 0.1)
* Quaternion::rotation_y(decel * -0.2); * Quaternion::rotation_y(decel * -0.2);
next.lower_torso.position = Vec3::new(0.0, 0.0, -5.0);
next.torso.orientation = Quaternion::rotation_z((spin * 7.0).max(0.3)); next.torso.orientation = Quaternion::rotation_z((spin * 7.0).max(0.3));
next.foot_l.position = Vec3::new(-s_a.foot.0, foot * 1.0, s_a.foot.2); next.foot_l.position = Vec3::new(-s_a.foot.0, foot * 1.0, s_a.foot.2);
@ -130,11 +124,8 @@ impl Animation for SpinAnimation {
next.foot_r.position = Vec3::new(s_a.foot.0, foot * -1.0, s_a.foot.2); next.foot_r.position = Vec3::new(s_a.foot.0, foot * -1.0, s_a.foot.2);
next.foot_r.orientation = Quaternion::rotation_x(foot * 1.2); next.foot_r.orientation = Quaternion::rotation_x(foot * 1.2);
next.shoulder_l.orientation = Quaternion::rotation_x(0.0);
next.shoulder_r.orientation = Quaternion::rotation_x(0.0);
} }
next next
} }
} }

View File

@ -63,20 +63,20 @@ impl Animation for SpinMeleeAnimation {
match active_tool_kind { match active_tool_kind {
Some(ToolKind::Sword(_)) => { Some(ToolKind::Sword(_)) => {
next.hand_l.position = Vec3::new(-0.75, -1.0, 2.5); next.main.position = Vec3::new(0.0, 0.0, 0.0);
next.hand_l.orientation = next.main.orientation = Quaternion::rotation_x(0.0);
Quaternion::rotation_x(1.47) * Quaternion::rotation_y(-0.2);
next.hand_r.position = Vec3::new(0.75, -1.5, -0.5);
next.hand_r.orientation =
Quaternion::rotation_x(1.47) * Quaternion::rotation_y(0.3);
next.main.position = Vec3::new(3.0, 6.0, -5.0);
next.main.orientation = Quaternion::rotation_x(-0.1)
* Quaternion::rotation_y(0.0)
* Quaternion::rotation_z(0.0);
next.control.position = Vec3::new(-7.0, 7.0, 2.0); next.hand_l.position = Vec3::new(s_a.shl.0, s_a.shl.1, s_a.shl.2);
next.control.orientation = Quaternion::rotation_x(-PI / 2.0 + movement3 * PI / 2.0) next.hand_l.orientation =
* Quaternion::rotation_z(-PI / 2.0 + movement3 * PI / 2.0); Quaternion::rotation_x(s_a.shl.3) * Quaternion::rotation_y(s_a.shl.4);
next.hand_r.position = Vec3::new(s_a.shr.0, s_a.shr.1, s_a.shr.2);
next.hand_r.orientation =
Quaternion::rotation_x(s_a.shr.3) * Quaternion::rotation_y(s_a.shr.4);
next.control.position = Vec3::new(s_a.sc.0, s_a.sc.1, s_a.sc.2);
next.control.orientation =
Quaternion::rotation_x(s_a.sc.3 - PI / 2.0 + movement3 * PI / 2.0)
* Quaternion::rotation_z(s_a.sc.5 - PI / 2.0 + movement3 * PI / 2.0);
next.torso.orientation = Quaternion::rotation_z(movement2 * PI * 2.0); next.torso.orientation = Quaternion::rotation_z(movement2 * PI * 2.0);
next.upper_torso.position = Vec3::new(0.0, s_a.upper_torso.0, s_a.upper_torso.1); next.upper_torso.position = Vec3::new(0.0, s_a.upper_torso.0, s_a.upper_torso.1);
@ -98,25 +98,30 @@ impl Animation for SpinMeleeAnimation {
next.control.orientation = next.control.orientation =
Quaternion::rotation_x(-1.4) * Quaternion::rotation_z(1.4); Quaternion::rotation_x(-1.4) * Quaternion::rotation_z(1.4);
next.head.position = Vec3::new(0.0, s_a.head.0, s_a.head.1);
next.head.orientation = next.head.orientation =
Quaternion::rotation_x(-0.15) * Quaternion::rotation_y(0.08); Quaternion::rotation_x(-0.15) * Quaternion::rotation_y(0.08);
next.upper_torso.position = next.upper_torso.position =
Vec3::new(0.0, s_a.upper_torso.0 - 3.0, s_a.upper_torso.1 - 2.0); Vec3::new(0.0, s_a.upper_torso.0 - 3.0, s_a.upper_torso.1 - 2.0);
next.upper_torso.orientation = next.upper_torso.orientation = Quaternion::rotation_z(0.0)
Quaternion::rotation_x(-0.1) * Quaternion::rotation_y(0.3); * Quaternion::rotation_x(-0.1)
* Quaternion::rotation_y(0.3);
next.lower_torso.position = Vec3::new(0.0, 3.0, -2.5); next.lower_torso.position = Vec3::new(0.0, 3.0, -2.5);
next.lower_torso.orientation = Quaternion::rotation_x(0.7); next.lower_torso.orientation = Quaternion::rotation_z(0.0)
* Quaternion::rotation_x(0.7)
* Quaternion::rotation_y(0.0);
next.torso.position = Vec3::new( next.torso.position = Vec3::new(
-xshift * (anim_time as f32).min(0.6), -xshift * (anim_time as f32).min(0.6),
-yshift * (anim_time as f32).min(0.6), -yshift * (anim_time as f32).min(0.6),
0.0, 0.0,
) * 1.01; );
next.torso.orientation = Quaternion::rotation_z(spin * -16.0); next.torso.orientation = Quaternion::rotation_z(spin * -16.0)
* Quaternion::rotation_x(0.0)
* Quaternion::rotation_y(0.0);
if velocity.z.abs() > 0.1 { if velocity.z.abs() > 0.1 {
next.foot_l.position = Vec3::new(-s_a.foot.0, 8.0, s_a.foot.2 + 2.0); next.foot_l.position = Vec3::new(-s_a.foot.0, 8.0, s_a.foot.2 + 2.0);
next.foot_l.orientation = Quaternion::rotation_x(1.0); next.foot_l.orientation =
Quaternion::rotation_x(1.0) * Quaternion::rotation_z(0.0);
next.foot_r.position = Vec3::new(s_a.foot.0, 8.0, s_a.foot.2 + 2.0); next.foot_r.position = Vec3::new(s_a.foot.0, 8.0, s_a.foot.2 + 2.0);
next.foot_r.orientation = Quaternion::rotation_x(1.0); next.foot_r.orientation = Quaternion::rotation_x(1.0);
@ -137,6 +142,7 @@ impl Animation for SpinMeleeAnimation {
}, },
_ => {}, _ => {},
} }
next next
} }
} }

View File

@ -130,6 +130,7 @@ impl Animation for WieldAnimation {
next.main.position = Vec3::new(0.0, 0.0, 0.0); next.main.position = Vec3::new(0.0, 0.0, 0.0);
next.main.orientation = Quaternion::rotation_y(0.0); next.main.orientation = Quaternion::rotation_y(0.0);
next.hold.scale = Vec3::one() * 0.0;
if velocity > 0.5 { if velocity > 0.5 {
next.head.position = Vec3::new(0.0, s_a.head.0, s_a.head.1) * 1.02; next.head.position = Vec3::new(0.0, s_a.head.0, s_a.head.1) * 1.02;
@ -233,15 +234,14 @@ impl Animation for WieldAnimation {
next.main.position = Vec3::new(0.0, 0.0, 0.0); next.main.position = Vec3::new(0.0, 0.0, 0.0);
next.main.orientation = Quaternion::rotation_y(0.0); next.main.orientation = Quaternion::rotation_y(0.0);
next.hold.position = Vec3::new(1.2, -1.0, -14.2); next.hold.position = Vec3::new(0.0, -1.0, -15.2);
next.hold.orientation = Quaternion::rotation_x(-1.7) next.hold.orientation = Quaternion::rotation_x(-1.57);
* Quaternion::rotation_y(0.0)
* Quaternion::rotation_z(-0.1);
next.hold.scale = Vec3::one() * 1.0; next.hold.scale = Vec3::one() * 1.0;
next.control.position = Vec3::new(s_a.bc.0, s_a.bc.1, s_a.bc.2); next.control.position = Vec3::new(s_a.bc.0, s_a.bc.1, s_a.bc.2);
next.control.orientation = Quaternion::rotation_x(u_slow * 0.2) next.control.orientation = Quaternion::rotation_x(u_slow * 0.06)
* Quaternion::rotation_z(u_slowalt * 0.1); * Quaternion::rotation_y(s_a.bc.4)
* Quaternion::rotation_z(s_a.bc.5 + u_slowalt * 0.1);
}, },
Some(ToolKind::Hammer(_)) => { Some(ToolKind::Hammer(_)) => {
next.hand_l.position = Vec3::new(s_a.hhl.0, s_a.hhl.1, s_a.hhl.2); next.hand_l.position = Vec3::new(s_a.hhl.0, s_a.hhl.1, s_a.hhl.2);

View File

@ -2217,18 +2217,18 @@ impl FigureMgr {
vel.0.magnitude_squared() > MOVING_THRESHOLD_SQR, // Moving vel.0.magnitude_squared() > MOVING_THRESHOLD_SQR, // Moving
physics.in_fluid.is_some(), // In water physics.in_fluid.is_some(), // In water
) { ) {
// Standing
(true, false, false) => anim::biped_large::IdleAnimation::update_skeleton(
&BipedLargeSkeleton::default(),
time,
state.state_time,
&mut state_animation_rate,
skeleton_attr,
),
// Running // Running
(true, true, false) => anim::biped_large::RunAnimation::update_skeleton( (true, true, false) => anim::biped_large::RunAnimation::update_skeleton(
&BipedLargeSkeleton::default(), &BipedLargeSkeleton::default(),
(vel.0.magnitude(), ori, state.last_ori, time, state.avg_vel), (
active_tool_kind.clone(),
second_tool_kind.clone(),
vel.0.magnitude(),
ori,
state.last_ori,
time,
state.avg_vel,
),
state.state_time, state.state_time,
&mut state_animation_rate, &mut state_animation_rate,
skeleton_attr, skeleton_attr,
@ -2236,14 +2236,14 @@ impl FigureMgr {
// In air // In air
(false, _, false) => anim::biped_large::JumpAnimation::update_skeleton( (false, _, false) => anim::biped_large::JumpAnimation::update_skeleton(
&BipedLargeSkeleton::default(), &BipedLargeSkeleton::default(),
time, (active_tool_kind.clone(), second_tool_kind.clone(), time),
state.state_time, state.state_time,
&mut state_animation_rate, &mut state_animation_rate,
skeleton_attr, skeleton_attr,
), ),
_ => anim::biped_large::IdleAnimation::update_skeleton( _ => anim::biped_large::IdleAnimation::update_skeleton(
&BipedLargeSkeleton::default(), &BipedLargeSkeleton::default(),
time, (active_tool_kind.clone(), second_tool_kind.clone(), time),
state.state_time, state.state_time,
&mut state_animation_rate, &mut state_animation_rate,
skeleton_attr, skeleton_attr,