From a8dd44325f4dc0c3e7ab8e36fff7fed72d9be4b0 Mon Sep 17 00:00:00 2001 From: Snowram Date: Sun, 18 Oct 2020 01:29:20 +0200 Subject: [PATCH] Convert some animations to new style keyframes --- voxygen/src/anim/src/biped_large/beam.rs | 201 ++++-------- voxygen/src/anim/src/character/alpha.rs | 88 +++--- voxygen/src/anim/src/character/beam.rs | 204 ++++--------- voxygen/src/anim/src/character/beta.rs | 72 ++--- voxygen/src/anim/src/character/leapmelee.rs | 323 +++++--------------- voxygen/src/anim/src/character/spin.rs | 103 +++---- 6 files changed, 313 insertions(+), 678 deletions(-) diff --git a/voxygen/src/anim/src/biped_large/beam.rs b/voxygen/src/anim/src/biped_large/beam.rs index 5c8eef49d4..77d791d6d1 100644 --- a/voxygen/src/anim/src/biped_large/beam.rs +++ b/voxygen/src/anim/src/biped_large/beam.rs @@ -38,9 +38,18 @@ impl Animation for BeamAnimation { *rate = 1.0; let mut next = (*skeleton).clone(); - let movement = (anim_time as f32 * 1.0).min(1.0); - - next.head.position = Vec3::new(0.0, -2.0 + skeleton_attr.head.0, skeleton_attr.head.1); + let (movement1, movement2, movement3) = match stage_section { + Some(StageSection::Buildup) => { + (anim_time as f32, 0.0, 0.0) + }, + Some(StageSection::Cast) => { + (1.0, anim_time as f32, 0.0) + }, + Some(StageSection::Recover) => { + (1.0, 1.0, anim_time as f32) + }, + _ => (0.0, 0.0, 0.0), + }; next.hand_l.position = Vec3::new(0.0, 0.0, -4.0); next.hand_l.orientation = Quaternion::rotation_x(1.27) * Quaternion::rotation_y(0.0); @@ -56,151 +65,59 @@ impl Animation for BeamAnimation { * Quaternion::rotation_y(0.15) * Quaternion::rotation_z(0.0); next.control.scale = Vec3::one(); - let slow = (anim_time as f32 * 8.0).sin(); - let slowalt = (anim_time as f32 * 8.0 + PI / 2.0).sin(); - let slowmid = (anim_time as f32 * 8.0 + PI / 4.0).sin(); - - let fast = (anim_time as f32 * 16.0).sin(); + //println!("{:?}", anim_time); match active_tool_kind { + //TODO: Inventory Some(ToolKind::Staff(_)) | Some(ToolKind::Sceptre(_)) => { - if let Some(stage_section) = stage_section { - match stage_section { - StageSection::Buildup => { - next.control.position = Vec3::new( - -4.0 + movement * 16.0, - 7.0 + movement, - 4.0 + movement * 4.0, - ); - next.control.orientation = - Quaternion::rotation_x(-0.3 + movement * -1.2) - * Quaternion::rotation_y(0.15 + movement * -1.4) - * Quaternion::rotation_z(0.0 + movement * -1.7); - next.head.orientation = - Quaternion::rotation_x(0.0) * Quaternion::rotation_z(0.0); + next.control.position = Vec3::new( + -4.0 + movement1 * 16.0 + movement3 * -16.0, + 7.0 + movement1 + (movement2 * 8.0).sin() * 2.0 + movement3 * -1.0, + 4.0 + movement1 * 4.0 + movement3 * -4.0, + ); + next.control.orientation = + Quaternion::rotation_x(-0.3 + movement1 * -1.2 + movement3 * 1.2) + * Quaternion::rotation_y(0.15 + movement1 * -1.4 + (movement2 * 16.0).sin() * 0.07 + movement3 * 1.4) + * Quaternion::rotation_z(movement1 * -1.7 + (movement2 * 8.0 + PI / 4.0).sin() * 0.3 + movement3 * 1.7); + next.head.orientation = + Quaternion::rotation_x(0.0) * Quaternion::rotation_z(0.0); - next.hand_l.position = Vec3::new( - 0.0 + movement * -1.0, - 0.0 + movement * -5.0, - -4.0 + movement * 19.0, - ); + next.hand_l.position = Vec3::new( + 0.0 + movement1 * -1.0 + (movement2 * 8.0).sin() * 3.5 + movement3, + 0.0 + movement1 * -5.0 + (movement2 * 8.0).sin() * -2.0 + (movement2 * 16.0).sin() * -1.5 + movement3 * 5.0, + -4.0 + movement1 * 19.0 + (movement2 * 8.0 + PI / 2.0).sin() * 3.5 + movement3 * -19.0, + ); + next.hand_l.orientation = + Quaternion::rotation_x(1.57 + movement3 * -0.3) + * Quaternion::rotation_y(movement1 *-1.1 + (movement2 * 8.0 + PI / 2.0).sin() * -0.3 + movement3 * 1.1) + * Quaternion::rotation_z(movement1 * -2.8 + movement3 * 2.8); - if velocity < 0.5 { - next.head.orientation = Quaternion::rotation_z(movement * -0.5); + if velocity < 0.5 { + next.head.orientation = Quaternion::rotation_z(movement1 * -0.5 + (movement2 * 16.0).sin() * 0.05); - next.foot_l.position = Vec3::new( - -skeleton_attr.foot.0, - skeleton_attr.foot.1 + movement * -3.0, - skeleton_attr.foot.2, - ); - next.foot_l.orientation = Quaternion::rotation_x(movement * -0.5) - * Quaternion::rotation_z(movement * 0.5); + next.foot_l.position = Vec3::new( + -skeleton_attr.foot.0, + skeleton_attr.foot.1 + movement1 * -3.0, + skeleton_attr.foot.2, + ); + next.foot_l.orientation = + Quaternion::rotation_x(movement1 * -0.5) + * Quaternion::rotation_z(movement1 * 0.5); - next.foot_r.position = Vec3::new( - skeleton_attr.foot.0, - skeleton_attr.foot.1 + movement * 4.0, - skeleton_attr.foot.2, - ); - next.foot_r.orientation = Quaternion::rotation_z(movement * 0.5); - next.upper_torso.orientation = - Quaternion::rotation_x(movement * -0.2) - * Quaternion::rotation_z(movement * 0.5); - next.lower_torso.orientation = - Quaternion::rotation_x(movement * 0.2) - * Quaternion::rotation_z(movement * -0.2); - } else { - }; - }, - StageSection::Cast => { - next.control.position = Vec3::new(12.0, 8.0 + slow * 2.0, 8.0); - next.control.orientation = Quaternion::rotation_x(-1.5) - * Quaternion::rotation_y(-1.25 + fast * 0.07) - * Quaternion::rotation_z(-1.7 + slowmid * 0.3); - - next.hand_l.position = Vec3::new( - -1.0 + slow * 3.5, - -5.0 + slow * -2.0 + fast * -1.5, - 15.0 + slowalt * 3.5, - ); - next.hand_l.orientation = Quaternion::rotation_x(1.57) - * Quaternion::rotation_y(-1.1 + slowmid * -0.3) - * Quaternion::rotation_z(-2.8); - if velocity < 0.5 { - next.head.orientation = Quaternion::rotation_z(-0.5 + fast * 0.05); - - next.foot_l.position = Vec3::new( - -skeleton_attr.foot.0, - skeleton_attr.foot.1 - 3.0, - skeleton_attr.foot.2, - ); - next.foot_l.orientation = - Quaternion::rotation_x(-0.5) * Quaternion::rotation_z(0.5); - - next.foot_r.position = Vec3::new( - skeleton_attr.foot.0, - skeleton_attr.foot.1 + 4.0, - skeleton_attr.foot.2, - ); - next.foot_r.orientation = Quaternion::rotation_z(0.5); - next.upper_torso.orientation = - Quaternion::rotation_x(-0.2 + slow * 0.05) - * Quaternion::rotation_z(0.5); - next.lower_torso.orientation = - Quaternion::rotation_x(0.2) * Quaternion::rotation_z(-0.2); - } else { - }; - }, - - StageSection::Recover => { - next.control.position = Vec3::new( - 12.0 + movement * -16.0, - 8.0 + movement * -1.0, - 8.0 + movement * -4.0, - ); - next.control.orientation = - Quaternion::rotation_x(-1.5 + movement * 1.2) - * Quaternion::rotation_y(-1.25 + movement * 1.4) - * Quaternion::rotation_z(-1.7 + movement * 1.7); - next.hand_l.position = Vec3::new( - -1.0 + movement, - -5.0 + movement * 5.0, - 15.0 + movement * -19.0, - ); - next.hand_l.orientation = - Quaternion::rotation_x(1.57 + movement * -0.3) - * Quaternion::rotation_y(-1.1 + movement * 1.1) - * Quaternion::rotation_z(-2.8 + movement * 2.8); - if velocity < 0.5 { - next.head.orientation = Quaternion::rotation_z(movement * 0.5); - - next.foot_l.position = Vec3::new( - -skeleton_attr.foot.0, - skeleton_attr.foot.1 - 3.0 + movement * 3.0, - skeleton_attr.foot.2, - ); - next.foot_l.orientation = - Quaternion::rotation_x(-0.5 + movement * 0.5) - * Quaternion::rotation_z(0.5 + movement * -0.5); - - next.foot_r.position = Vec3::new( - skeleton_attr.foot.0, - skeleton_attr.foot.1 + 4.0 + movement * -4.0, - skeleton_attr.foot.2, - ); - next.foot_r.orientation = - Quaternion::rotation_z(0.5 + movement * -0.5); - next.upper_torso.orientation = - Quaternion::rotation_x(-0.2 + movement * 0.2) - * Quaternion::rotation_z(0.5 + movement * -0.5); - next.lower_torso.orientation = - Quaternion::rotation_x(0.2 + movement * -0.2) - * Quaternion::rotation_z(-0.2 + movement * 0.2); - } else { - }; - }, - _ => {}, - } - } + next.foot_r.position = Vec3::new( + skeleton_attr.foot.0, + skeleton_attr.foot.1 + movement1 * 4.0, + skeleton_attr.foot.2, + ); + next.foot_r.orientation = Quaternion::rotation_z(movement1 * 0.5); + next.upper_torso.orientation = + Quaternion::rotation_x(movement1 * -0.2 + (movement2 * 8.0).sin() * 0.05) + * Quaternion::rotation_z(movement1 * 0.5); + next.lower_torso.orientation = + Quaternion::rotation_x(movement1 * 0.2) + * Quaternion::rotation_z(movement1 * -0.2); + } else { + }; }, _ => {}, } @@ -214,4 +131,4 @@ impl Animation for BeamAnimation { next } -} +} \ No newline at end of file diff --git a/voxygen/src/anim/src/character/alpha.rs b/voxygen/src/anim/src/character/alpha.rs index ee747967ef..627ced2027 100644 --- a/voxygen/src/anim/src/character/alpha.rs +++ b/voxygen/src/anim/src/character/alpha.rs @@ -37,6 +37,19 @@ impl Animation for AlphaAnimation { let lab = 1.0; + let (movement1, movement2, movement3) = match stage_section { + Some(StageSection::Buildup) => { + (anim_time as f32, 0.0, 0.0) + }, + Some(StageSection::Swing) => { + (1.0, anim_time as f32, 0.0) + }, + Some(StageSection::Recover) => { + (1.0, 1.0, anim_time as f32) + }, + _ => (0.0, 0.0, 0.0), + }; + let foot = (((1.0) / (0.2 + 0.8 @@ -70,9 +83,6 @@ impl Animation for AlphaAnimation { .sqrt()) * ((anim_time as f32 * lab as f32 * 4.0).sin()); - let movement = anim_time as f32 * 1.0; - let test = (anim_time as f32 * 1.75).sin(); - if let Some(ToolKind::Sword(_)) = active_tool_kind { next.hand_l.position = Vec3::new(-0.75, -1.0, 2.5); next.hand_l.orientation = Quaternion::rotation_x(1.47) * Quaternion::rotation_y(-0.2); @@ -85,48 +95,24 @@ impl Animation for AlphaAnimation { * Quaternion::rotation_y(0.0) * Quaternion::rotation_z(0.0); + next.control.position = + Vec3::new( + -7.0, + 7.0 + movement1 * -4.0 + movement2 * 16.0 + movement3 * -4.0, + 2.0 + movement1 * 1.0 + ); + next.control.orientation = + Quaternion::rotation_x(movement1 * -0.5) + * Quaternion::rotation_y(movement1 * -1.0 + movement2 * -0.6 + movement3 * 1.0) + * Quaternion::rotation_z(movement1 * -1.2 + movement2 * 1.3); + + next.chest.orientation = Quaternion::rotation_z(movement1 * 1.5 + (movement2 * 1.75).sin() * -3.0 + movement3 * 0.5); + next.head.position = Vec3::new(0.0, skeleton_attr.head.0 + 0.0, skeleton_attr.head.1); - - if let Some(stage_section) = stage_section { - match stage_section { - StageSection::Buildup => { - next.control.position = - Vec3::new(-7.0, 7.0 + movement * -4.0, 2.0 + movement * 1.0); - next.control.orientation = Quaternion::rotation_x(movement * -0.5) - * Quaternion::rotation_y(movement * -1.0) - * Quaternion::rotation_z(movement * -1.2); - - next.chest.orientation = Quaternion::rotation_z(movement * 1.5); - next.head.orientation = Quaternion::rotation_z(movement * -0.9); - }, - StageSection::Swing => { - next.control.position = Vec3::new(-7.0, 3.0 + movement * 16.0, 3.0); - next.control.orientation = - Quaternion::rotation_x(-0.5 + movement * -1.0 * 0.0) - * Quaternion::rotation_y(-1.0 + movement * -0.6) - * Quaternion::rotation_z(-1.2 + movement * 1.3); - - next.chest.orientation = Quaternion::rotation_z(1.5 + test * -3.0); - next.head.orientation = Quaternion::rotation_z(-0.9 + test * 2.5); - }, - StageSection::Recover => { - next.control.position = Vec3::new(-7.0, 15.0, 2.0); - next.control.orientation = Quaternion::rotation_x(-0.5) - * Quaternion::rotation_y(-1.57 + movement * 1.0) - * Quaternion::rotation_z(0.0); - next.control.scale = Vec3::one(); - next.chest.orientation = Quaternion::rotation_y(0.0) - * Quaternion::rotation_z(-1.57 + movement * 0.5); - - next.head.orientation = Quaternion::rotation_y(0.0) - * Quaternion::rotation_z(1.57 + movement * -0.5); - }, - _ => {}, - } - } + next.head.orientation = Quaternion::rotation_z(movement1 * -0.9 + (movement2 * 1.75).sin() * 2.5 + movement3 * -0.5); } - match active_tool_kind { + //TODO: Inventory Some(ToolKind::Dagger(_)) => { next.head.position = Vec3::new(0.0, -2.0 + skeleton_attr.head.0, skeleton_attr.head.1); @@ -148,6 +134,7 @@ impl Animation for AlphaAnimation { Vec3::new(0.0, skeleton_attr.shorts.0, skeleton_attr.shorts.1); next.shorts.orientation = next.chest.orientation * -0.45; + // TODO: Fix animation next.hand_l.position = Vec3::new(0.0, 0.0, 0.0); next.hand_l.orientation = Quaternion::rotation_x(0.0); next.hand_l.scale = Vec3::one() * 1.12; @@ -172,6 +159,23 @@ impl Animation for AlphaAnimation { next.control_r.orientation = Quaternion::rotation_x(0.0); next.control_r.scale = Vec3::one(); + // next.control_r.position = Vec3::new(-10.0 + push * 5.0, 6.0 + push * 5.0, + // 2.0); next.control_r.orientation = + // Quaternion::rotation_x(-1.4 + slow * 0.4) + // * Quaternion::rotation_y(slow * -1.3) + // * Quaternion::rotation_z(1.4 + slow * -0.5); + // next.control_r.scale = Vec3::one(); + + // next.hand_r.position = Vec3::new(0.75, -1.5, -5.5); + // next.hand_r.orientation = Quaternion::rotation_x(1.27); + // next.hand_r.scale = Vec3::one() * 1.05; + + // next.control.position = Vec3::new(-10.0 + push * 5.0, 6.0 + push * 5.0, 2.0); + // next.control.orientation = Quaternion::rotation_x(-1.4 + slow * 0.4) + // * Quaternion::rotation_y(slow * -1.3) + // * Quaternion::rotation_z(1.4 + slow * -0.5); + // next.control.scale = Vec3::one(); + next.foot_l.position = Vec3::new( -skeleton_attr.foot.0, slow * -3.0 + quick * 3.0 - 4.0, diff --git a/voxygen/src/anim/src/character/beam.rs b/voxygen/src/anim/src/character/beam.rs index 231ea961d0..1f08dc082b 100644 --- a/voxygen/src/anim/src/character/beam.rs +++ b/voxygen/src/anim/src/character/beam.rs @@ -38,9 +38,18 @@ impl Animation for BeamAnimation { *rate = 1.0; let mut next = (*skeleton).clone(); - let movement = (anim_time as f32 * 1.0).min(1.0); - - next.head.position = Vec3::new(0.0, -2.0 + skeleton_attr.head.0, skeleton_attr.head.1); + let (movement1, movement2, movement3) = match stage_section { + Some(StageSection::Buildup) => { + (anim_time as f32, 0.0, 0.0) + }, + Some(StageSection::Cast) => { + (1.0, anim_time as f32, 0.0) + }, + Some(StageSection::Recover) => { + (1.0, 1.0, anim_time as f32) + }, + _ => (0.0, 0.0, 0.0), + }; next.hand_l.position = Vec3::new(0.0, 0.0, -4.0); next.hand_l.orientation = Quaternion::rotation_x(1.27) * Quaternion::rotation_y(0.0); @@ -56,157 +65,62 @@ impl Animation for BeamAnimation { * Quaternion::rotation_y(0.15) * Quaternion::rotation_z(0.0); next.control.scale = Vec3::one(); - let slow = (anim_time as f32 * 8.0).sin(); - let slowalt = (anim_time as f32 * 8.0 + PI / 2.0).sin(); - let slowmid = (anim_time as f32 * 8.0 + PI / 4.0).sin(); - - let fast = (anim_time as f32 * 16.0).sin(); //println!("{:?}", anim_time); match active_tool_kind { //TODO: Inventory Some(ToolKind::Staff(_)) | Some(ToolKind::Sceptre(_)) => { - if let Some(stage_section) = stage_section { - match stage_section { - StageSection::Buildup => { - next.control.position = Vec3::new( - -4.0 + movement * 16.0, - 7.0 + movement, - 4.0 + movement * 4.0, - ); - next.control.orientation = - Quaternion::rotation_x(-0.3 + movement * -1.2) - * Quaternion::rotation_y(0.15 + movement * -1.4) - * Quaternion::rotation_z(0.0 + movement * -1.7); - next.head.orientation = - Quaternion::rotation_x(0.0) * Quaternion::rotation_z(0.0); + next.control.position = Vec3::new( + -4.0 + movement1 * 16.0 + movement3 * -16.0, + 7.0 + movement1 + (movement2 * 8.0).sin() * 2.0 + movement3 * -1.0, + 4.0 + movement1 * 4.0 + movement3 * -4.0, + ); + next.control.orientation = + Quaternion::rotation_x(-0.3 + movement1 * -1.2 + movement3 * 1.2) + * Quaternion::rotation_y(0.15 + movement1 * -1.4 + (movement2 * 16.0).sin() * 0.07 + movement3 * 1.4) + * Quaternion::rotation_z(movement1 * -1.7 + (movement2 * 8.0 + PI / 4.0).sin() * 0.3 + movement3 * 1.7); + next.head.orientation = + Quaternion::rotation_x(0.0) * Quaternion::rotation_z(0.0); - next.hand_l.position = Vec3::new( - 0.0 + movement * -1.0, - 0.0 + movement * -5.0, - -4.0 + movement * 19.0, - ); + next.hand_l.position = Vec3::new( + 0.0 + movement1 * -1.0 + (movement2 * 8.0).sin() * 3.5 + movement3, + 0.0 + movement1 * -5.0 + (movement2 * 8.0).sin() * -2.0 + (movement2 * 16.0).sin() * -1.5 + movement3 * 5.0, + -4.0 + movement1 * 19.0 + (movement2 * 8.0 + PI / 2.0).sin() * 3.5 + movement3 * -19.0, + ); + next.hand_l.orientation = + Quaternion::rotation_x(1.57 + movement3 * -0.3) + * Quaternion::rotation_y(movement1 *-1.1 + (movement2 * 8.0 + PI / 2.0).sin() * -0.3 + movement3 * 1.1) + * Quaternion::rotation_z(movement1 * -2.8 + movement3 * 2.8); - if velocity < 0.5 { - next.head.orientation = Quaternion::rotation_z(movement * -0.5); + if velocity < 0.5 { + next.head.orientation = Quaternion::rotation_z(movement1 * -0.5 + (movement2 * 16.0).sin() * 0.05); - next.foot_l.position = Vec3::new( - -skeleton_attr.foot.0, - skeleton_attr.foot.1 + movement * -3.0, - skeleton_attr.foot.2, - ); - next.foot_l.orientation = Quaternion::rotation_x(movement * -0.5) - * Quaternion::rotation_z(movement * 0.5); + next.foot_l.position = Vec3::new( + -skeleton_attr.foot.0, + skeleton_attr.foot.1 + movement1 * -3.0, + skeleton_attr.foot.2, + ); + next.foot_l.orientation = + Quaternion::rotation_x(movement1 * -0.5) + * Quaternion::rotation_z(movement1 * 0.5); - next.foot_r.position = Vec3::new( - skeleton_attr.foot.0, - skeleton_attr.foot.1 + movement * 4.0, - skeleton_attr.foot.2, - ); - next.foot_r.orientation = Quaternion::rotation_z(movement * 0.5); - next.chest.orientation = Quaternion::rotation_x(movement * -0.2) - * Quaternion::rotation_z(movement * 0.5); - next.belt.orientation = Quaternion::rotation_x(movement * 0.1) - * Quaternion::rotation_z(movement * -0.1); - next.shorts.orientation = Quaternion::rotation_x(movement * 0.2) - * Quaternion::rotation_z(movement * -0.2); - } else { - }; - }, - StageSection::Cast => { - next.control.position = Vec3::new(12.0, 8.0 + slow * 2.0, 8.0); - next.control.orientation = Quaternion::rotation_x(-1.5) - * Quaternion::rotation_y(-1.25 + fast * 0.07) - * Quaternion::rotation_z(-1.7 + slowmid * 0.3); - - next.hand_l.position = Vec3::new( - -1.0 + slow * 3.5, - -5.0 + slow * -2.0 + fast * -1.5, - 15.0 + slowalt * 3.5, - ); - next.hand_l.orientation = Quaternion::rotation_x(1.57) - * Quaternion::rotation_y(-1.1 + slowmid * -0.3) - * Quaternion::rotation_z(-2.8); - if velocity < 0.5 { - next.head.orientation = Quaternion::rotation_z(-0.5 + fast * 0.05); - - next.foot_l.position = Vec3::new( - -skeleton_attr.foot.0, - skeleton_attr.foot.1 - 3.0, - skeleton_attr.foot.2, - ); - next.foot_l.orientation = - Quaternion::rotation_x(-0.5) * Quaternion::rotation_z(0.5); - - next.foot_r.position = Vec3::new( - skeleton_attr.foot.0, - skeleton_attr.foot.1 + 4.0, - skeleton_attr.foot.2, - ); - next.foot_r.orientation = Quaternion::rotation_z(0.5); - next.chest.orientation = Quaternion::rotation_x(-0.2 + slow * 0.05) - * Quaternion::rotation_z(0.5); - next.belt.orientation = - Quaternion::rotation_x(0.1) * Quaternion::rotation_z(-0.1); - next.shorts.orientation = - Quaternion::rotation_x(0.2) * Quaternion::rotation_z(-0.2); - } else { - }; - }, - - StageSection::Recover => { - next.control.position = Vec3::new( - 12.0 + movement * -16.0, - 8.0 + movement * -1.0, - 8.0 + movement * -4.0, - ); - next.control.orientation = - Quaternion::rotation_x(-1.5 + movement * 1.2) - * Quaternion::rotation_y(-1.25 + movement * 1.4) - * Quaternion::rotation_z(-1.7 + movement * 1.7); - next.hand_l.position = Vec3::new( - -1.0 + movement, - -5.0 + movement * 5.0, - 15.0 + movement * -19.0, - ); - next.hand_l.orientation = - Quaternion::rotation_x(1.57 + movement * -0.3) - * Quaternion::rotation_y(-1.1 + movement * 1.1) - * Quaternion::rotation_z(-2.8 + movement * 2.8); - if velocity < 0.5 { - next.head.orientation = Quaternion::rotation_z(movement * 0.5); - - next.foot_l.position = Vec3::new( - -skeleton_attr.foot.0, - skeleton_attr.foot.1 - 3.0 + movement * 3.0, - skeleton_attr.foot.2, - ); - next.foot_l.orientation = - Quaternion::rotation_x(-0.5 + movement * 0.5) - * Quaternion::rotation_z(0.5 + movement * -0.5); - - next.foot_r.position = Vec3::new( - skeleton_attr.foot.0, - skeleton_attr.foot.1 + 4.0 + movement * -4.0, - skeleton_attr.foot.2, - ); - next.foot_r.orientation = - Quaternion::rotation_z(0.5 + movement * -0.5); - next.chest.orientation = - Quaternion::rotation_x(-0.2 + movement * 0.2) - * Quaternion::rotation_z(0.5 + movement * -0.5); - next.belt.orientation = - Quaternion::rotation_x(0.1 + movement * -0.1) - * Quaternion::rotation_z(-0.1 + movement * 0.1); - next.shorts.orientation = - Quaternion::rotation_x(0.2 + movement * -0.2) - * Quaternion::rotation_z(-0.2 + movement * 0.2); - } else { - }; - }, - _ => {}, - } - } + next.foot_r.position = Vec3::new( + skeleton_attr.foot.0, + skeleton_attr.foot.1 + movement1 * 4.0, + skeleton_attr.foot.2, + ); + next.foot_r.orientation = Quaternion::rotation_z(movement1 * 0.5); + next.chest.orientation = + Quaternion::rotation_x(movement1 * -0.2 + (movement2 * 8.0).sin() * 0.05) + * Quaternion::rotation_z(movement1 * 0.5); + next.belt.orientation = + Quaternion::rotation_x(movement1 * 0.1) + * Quaternion::rotation_z(movement1 * -0.1); + next.shorts.orientation = + Quaternion::rotation_x(movement1 * 0.2) + * Quaternion::rotation_z(movement1 * -0.2); + } else { + }; }, _ => {}, } diff --git a/voxygen/src/anim/src/character/beta.rs b/voxygen/src/anim/src/character/beta.rs index 71ce9925c9..cb9e47e5d3 100644 --- a/voxygen/src/anim/src/character/beta.rs +++ b/voxygen/src/anim/src/character/beta.rs @@ -35,6 +35,19 @@ impl Animation for BetaAnimation { let lab = 1.0; + let (movement1, movement2, movement3) = match stage_section { + Some(StageSection::Buildup) => { + (anim_time as f32, 0.0, 0.0) + }, + Some(StageSection::Cast) => { + (1.0, anim_time as f32, 0.0) + }, + Some(StageSection::Recover) => { + (1.0, 1.0, anim_time as f32) + }, + _ => (0.0, 0.0, 0.0), + }; + let fast = (((5.0) / (1.1 + 3.9 * ((anim_time as f32 * lab as f32 * 28.0).sin()).powf(2.0 as f32))) .sqrt()) @@ -52,11 +65,6 @@ impl Animation for BetaAnimation { .sqrt()) * ((anim_time as f32 * lab as f32 * 14.0).sin()); - let recover = (anim_time as f32 * 8.0).sin(); - - let movement = anim_time as f32 * 1.0; - let stab = (anim_time as f32 * 2.5).sin(); - if let Some(ToolKind::Sword(_)) = active_tool_kind { next.hand_l.position = Vec3::new(-0.75, -1.0, 2.5); next.hand_l.orientation = Quaternion::rotation_x(1.47) * Quaternion::rotation_y(-0.2); @@ -71,48 +79,18 @@ impl Animation for BetaAnimation { next.head.position = Vec3::new(0.0, skeleton_attr.head.0, skeleton_attr.head.1); - if let Some(stage_section) = stage_section { - match stage_section { - StageSection::Buildup => { - //println!("{:.3} recover", anim_time); - next.control.position = Vec3::new( - -8.0 + movement * -5.0, - 1.0 - recover * 0.8 + movement * 2.0, - 2.0 - recover * 0.4, - ); - next.control.orientation = Quaternion::rotation_x(-1.57) - * Quaternion::rotation_y(0.0 + movement * 1.5) - * Quaternion::rotation_z(1.0); - next.chest.orientation = Quaternion::rotation_y(-0.1) - * Quaternion::rotation_z(0.4 + movement * 1.5); - next.head.orientation = Quaternion::rotation_y(0.1) - * Quaternion::rotation_z(-0.1 + movement * -1.1); - }, - StageSection::Swing => { - //println!("{:.3} swing", anim_time); - next.control.position = - Vec3::new(-8.0 + stab * 30.0, 6.0 + movement * 2.0, 6.0); - next.control.orientation = Quaternion::rotation_x(-1.57) - * Quaternion::rotation_y(1.5 + stab * 0.5) - * Quaternion::rotation_z(1.0 + stab * 1.0); - next.chest.orientation = Quaternion::rotation_y(-0.1) - * Quaternion::rotation_z(1.9 + stab * -0.5); - next.head.orientation = Quaternion::rotation_y(0.1) - * Quaternion::rotation_z(-1.2 + stab * -0.5); - }, - StageSection::Recover => { - next.control.position = Vec3::new(10.0 + movement * -5.0, 8.0, 6.0); - next.control.orientation = Quaternion::rotation_x(-1.57) - * Quaternion::rotation_y(2.0) - * Quaternion::rotation_z(2.0); - next.chest.orientation = Quaternion::rotation_y(-0.1) - * Quaternion::rotation_z(1.4 + movement * 1.0); - next.head.orientation = - Quaternion::rotation_y(0.1) * Quaternion::rotation_z(-1.5); - }, - _ => {}, - } - } + next.control.position = Vec3::new( + -8.0 + movement1 * -5.0 + (movement2 as f32 * 2.5).sin() * 30.0 + movement3 * -5.0, + 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) + * Quaternion::rotation_y(0.0 + movement1 * 1.5 + (movement2 as f32 * 2.5).sin() * 0.5) + * Quaternion::rotation_z(1.0 + (movement2 as f32 * 2.5).sin() * 1.0); + next.chest.orientation = Quaternion::rotation_y(-0.1) + * Quaternion::rotation_z(0.4 + movement1 * 1.5 + (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); } match active_tool_kind { diff --git a/voxygen/src/anim/src/character/leapmelee.rs b/voxygen/src/anim/src/character/leapmelee.rs index 6b4059b59f..5bd6674d65 100644 --- a/voxygen/src/anim/src/character/leapmelee.rs +++ b/voxygen/src/anim/src/character/leapmelee.rs @@ -34,7 +34,21 @@ impl Animation for LeapAnimation { *rate = 1.0; let mut next = (*skeleton).clone(); - let movement = (anim_time as f32 * 1.0).min(1.0); + let (movement1, movement2, movement3, movement4) = match stage_section { + Some(StageSection::Buildup) => { + (anim_time as f32, 0.0, 0.0, 0.0) + }, + Some(StageSection::Movement) => { + (1.0, anim_time as f32, 0.0, 0.0) + }, + Some(StageSection::Swing) => { + (1.0, 1.0, anim_time as f32, 0.0) + }, + Some(StageSection::Recover) => { + (1.0, 1.0, 1.0, anim_time as f32) + }, + _ => (0.0, 0.0, 0.0, 0.0), + }; if let Some(ToolKind::Hammer(_)) = active_tool_kind { next.hand_l.position = Vec3::new(-12.0, 0.0, 0.0); @@ -46,106 +60,42 @@ impl Animation for LeapAnimation { 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.control.position = Vec3::new(6.0, 7.0, 1.0); - next.control.orientation = Quaternion::rotation_x(0.3) - * Quaternion::rotation_y(0.0) - * Quaternion::rotation_z(0.0); - next.control.scale = Vec3::one(); - next.head.position = Vec3::new(0.0, -2.0 + skeleton_attr.head.0, skeleton_attr.head.1); - if let Some(stage_section) = stage_section { - match stage_section { - StageSection::Buildup => { - next.control.position = Vec3::new(6.0, 7.0, 1.0); - next.control.orientation = Quaternion::rotation_x(0.3) - * Quaternion::rotation_y(0.0) - * Quaternion::rotation_z(movement * 0.5); - next.chest.orientation = Quaternion::rotation_x(movement * 0.3) - * Quaternion::rotation_y(0.0) - * Quaternion::rotation_z(movement * 0.5); + next.control.position = Vec3::new( + 6.0 + movement1 * -10.0, + 7.0 + movement2 * 5.0 + movement3 * 5.0, + 1.0 + movement2 * 5.0 + movement3 * -7.0 + ); + next.control.orientation = + Quaternion::rotation_x(0.3 + movement3 * -3.0) + * Quaternion::rotation_y(0.0) + * Quaternion::rotation_z(movement1 * 0.5 + movement2 * 0.5 + movement3 * 0.5); + next.chest.orientation = + Quaternion::rotation_x(movement1 * 0.3 + movement2 * 0.3 + movement3 * -0.9 + movement4 * 0.3) + * Quaternion::rotation_y(0.0) + * Quaternion::rotation_z(movement1 * 0.5 + movement2 * 0.2 + movement3 * -0.7); - next.head.orientation = Quaternion::rotation_x(0.0) - * Quaternion::rotation_y(0.0) - * Quaternion::rotation_z(movement * -0.4); - }, + next.head.orientation = + Quaternion::rotation_x(movement3 * 0.2) + * Quaternion::rotation_y(0.0 + movement2 * -0.1) + * Quaternion::rotation_z(movement1 * -0.4 + movement2 * -0.2 + movement3 * 0.6); - StageSection::Movement => { - next.control.position = Vec3::new( - 6.0 + movement * -10.0, - 7.0 + movement * 5.0, - 1.0 + movement * 5.0, - ); - next.control.orientation = Quaternion::rotation_x(0.3) - * Quaternion::rotation_y(0.0) - * Quaternion::rotation_z(0.5 + movement * 0.5); - next.chest.orientation = Quaternion::rotation_x(0.3 + movement * 0.3) - * Quaternion::rotation_y(0.0) - * Quaternion::rotation_z(0.5 + movement * 0.2); - next.head.orientation = Quaternion::rotation_x(0.0) - * Quaternion::rotation_y(movement * -0.1) - * Quaternion::rotation_z(-0.4 + movement * -0.2); + next.hand_l.position = Vec3::new(-12.0 + movement3 * 10.0, 0.0, 0.0); - next.foot_l.position = Vec3::new( - -skeleton_attr.foot.0, - skeleton_attr.foot.1 - 5.0, - skeleton_attr.foot.2, - ); - next.foot_l.orientation = Quaternion::rotation_x(-0.8); + next.foot_l.position = Vec3::new( + -skeleton_attr.foot.0, + skeleton_attr.foot.1 - 5.0 + movement3 * 13.0, + skeleton_attr.foot.2 + movement3 * -5.0, + ); + next.foot_l.orientation = Quaternion::rotation_x(-0.8 + movement3 * 1.7); - next.foot_r.position = Vec3::new( - skeleton_attr.foot.0, - skeleton_attr.foot.1 + 8.0, - skeleton_attr.foot.2 + 5.0, - ); - next.foot_r.orientation = Quaternion::rotation_x(0.9); - }, - StageSection::Swing => { - next.control.position = - Vec3::new(-4.0, 12.0 + movement * 5.0, 6.0 + movement * -7.0); - next.control.orientation = Quaternion::rotation_x(0.3 + movement * -3.0) - * Quaternion::rotation_y(0.0) - * Quaternion::rotation_z(1.0 + movement * 0.5); - next.chest.orientation = Quaternion::rotation_x(0.6 + movement * -0.9) - * Quaternion::rotation_y(0.0) - * Quaternion::rotation_z(0.7 + movement * -0.7); - next.head.orientation = Quaternion::rotation_x(movement * 0.2) - * Quaternion::rotation_y(-0.1) - * Quaternion::rotation_z(-0.6 + movement * 0.6); - - next.hand_l.position = Vec3::new(-12.0 + movement * 10.0, 0.0, 0.0); - - next.foot_l.position = Vec3::new( - -skeleton_attr.foot.0, - skeleton_attr.foot.1 + 8.0, - skeleton_attr.foot.2 - 5.0, - ); - next.foot_l.orientation = Quaternion::rotation_x(0.9); - - next.foot_r.position = Vec3::new( - skeleton_attr.foot.0, - skeleton_attr.foot.1 - 5.0, - skeleton_attr.foot.2, - ); - next.foot_r.orientation = Quaternion::rotation_x(-0.8); - }, - StageSection::Recover => { - next.control.position = Vec3::new(-4.0, 17.0, -1.0); - next.control.orientation = Quaternion::rotation_x(-2.7) - * Quaternion::rotation_y(0.0) - * Quaternion::rotation_z(1.5); - next.chest.orientation = Quaternion::rotation_x(-0.3 + movement * 0.3) - * Quaternion::rotation_y(0.0) - * Quaternion::rotation_z(0.0); - next.head.orientation = Quaternion::rotation_x(0.2) - * Quaternion::rotation_y(-0.1) - * Quaternion::rotation_z(0.0); - - next.hand_l.position = Vec3::new(-2.0, 0.0, 0.0); - }, - _ => {}, - } - } + next.foot_r.position = Vec3::new( + skeleton_attr.foot.0, + skeleton_attr.foot.1 + 8.0 + movement3 * -13.0, + skeleton_attr.foot.2 + 5.0 + movement3 * -5.0, + ); + next.foot_r.orientation = Quaternion::rotation_x(0.9 + movement3 * -1.7); } else if let Some(ToolKind::Axe(_)) = active_tool_kind { next.hand_l.position = Vec3::new(-0.5, 0.0, 4.0); next.hand_l.orientation = Quaternion::rotation_x(PI / 2.0) @@ -170,160 +120,46 @@ impl Animation for LeapAnimation { next.head.position = Vec3::new(0.0, -2.0 + skeleton_attr.head.0, skeleton_attr.head.1); - if let Some(stage_section) = stage_section { - match stage_section { - StageSection::Buildup => { - next.control.position = Vec3::new( - -3.0 + movement * 3.0, - 11.0 + movement * 1.0, - 3.0 + movement * 12.0, - ); - next.control.orientation = Quaternion::rotation_x(1.8 + movement * -1.0) - * Quaternion::rotation_y(-0.5 + movement * 0.5) - * Quaternion::rotation_z(PI + 0.2 - movement * 0.2); - next.chest.orientation = Quaternion::rotation_x(movement * -0.3) - * Quaternion::rotation_y(0.0) - * Quaternion::rotation_z(movement * 0.5); + next.control.position = Vec3::new( + -3.0 + movement1 * 3.0, + 11.0 + movement1 * 1.0 + movement3 * 3.0, + 3.0 + movement1 * 12.0 + movement3 * -15.0, + ); + next.control.orientation = + Quaternion::rotation_x(1.8 + movement1 * -1.0 + movement2 * -0.5 + movement3 * -1.0) + * Quaternion::rotation_y(-0.5 + movement1 * 0.5) + * Quaternion::rotation_z(PI + 0.2 - movement1 * 0.2); - next.head.orientation = Quaternion::rotation_x(0.0 + movement * -0.4); + next.torso.orientation = + Quaternion::rotation_x(-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.foot_l.position = Vec3::new( - skeleton_attr.foot.0, - skeleton_attr.foot.1, - skeleton_attr.foot.2 - 8.0, - ); + next.head.orientation = Quaternion::rotation_x(0.0 + movement1 * -0.4 + movement2 * 0.4 + movement3 * 0.2); - next.foot_r.position = Vec3::new( - skeleton_attr.foot.0, - skeleton_attr.foot.1, - skeleton_attr.foot.2 - 8.0, - ); + next.foot_l.position = Vec3::new( + skeleton_attr.foot.0, + skeleton_attr.foot.1 + movement2 * 4.0 + movement3 * -8.0, + skeleton_attr.foot.2 - 8.0 + movement2 * 3.0 + movement3 * -3.0, + ); - next.foot_l.orientation = Quaternion::rotation_x(movement * 0.9); + next.foot_r.position = Vec3::new( + skeleton_attr.foot.0, + skeleton_attr.foot.1 + movement2 * 4.0 + movement3 * -8.0, + skeleton_attr.foot.2 - 8.0 + movement2 * 3.0 + movement3 * -3.0, + ); - next.foot_r.orientation = Quaternion::rotation_x(movement * 0.9); + next.foot_l.orientation = Quaternion::rotation_x(movement1 * 0.9 - movement3 * 1.8); - next.belt.orientation = Quaternion::rotation_x(movement * 0.22); - next.shorts.orientation = Quaternion::rotation_x(movement * 0.3); + next.foot_r.orientation = Quaternion::rotation_x(movement1 * 0.9 - movement3 * 1.8); - next.chest.position = - Vec3::new(0.0, skeleton_attr.chest.0, skeleton_attr.chest.1 - 8.0); - next.torso.position = - Vec3::new(0.0, 0.0, 0.0 + 8.0) * skeleton_attr.scaler / 11.0; - }, + next.belt.orientation = Quaternion::rotation_x(movement1 * 0.22 + movement2 * 0.1); + next.shorts.orientation = Quaternion::rotation_x(movement1 * 0.3 + movement2 * 0.1); - StageSection::Movement => { - next.control.position = Vec3::new( - 0.0, 12.0, //11 - 15.0, - ); - - next.chest.position = - Vec3::new(0.0, skeleton_attr.chest.0, skeleton_attr.chest.1 - 8.0); - next.torso.position = Vec3::new(0.0, 0.0, 0.0 + 8.0) * skeleton_attr.scaler; - next.control.orientation = Quaternion::rotation_x(0.8 + movement * -0.5) - * Quaternion::rotation_y(0.0) - * Quaternion::rotation_z(PI); - next.torso.orientation = Quaternion::rotation_x(-0.3 + movement * 6.0) - * Quaternion::rotation_y(0.0) - * Quaternion::rotation_z(0.0); - next.head.orientation = Quaternion::rotation_x(-0.4 + movement * 0.4); - - next.foot_l.position = Vec3::new( - -skeleton_attr.foot.0, - skeleton_attr.foot.1 + movement * 4.0, - skeleton_attr.foot.2 - 8.0 + movement * 3.0, - ); - next.foot_l.orientation = Quaternion::rotation_x(0.9); - - next.foot_r.position = Vec3::new( - skeleton_attr.foot.0, - skeleton_attr.foot.1 + movement * 4.0, - skeleton_attr.foot.2 - 8.0 + movement * 3.0, - ); - next.foot_r.orientation = Quaternion::rotation_x(0.9); - next.chest.position = - Vec3::new(0.0, skeleton_attr.chest.0, skeleton_attr.chest.1 - 8.0); - next.torso.position = - Vec3::new(0.0, 0.0, 0.0 + 8.0) * skeleton_attr.scaler / 11.0; - next.torso.orientation = Quaternion::rotation_x(movement * -1.8 * PI); - next.torso.scale = Vec3::one() / 11.0 * skeleton_attr.scaler; - - next.belt.orientation = Quaternion::rotation_x(0.22 + movement * 0.1); - next.shorts.orientation = Quaternion::rotation_x(0.3 + movement * 0.1); - - next.chest.position = - Vec3::new(0.0, skeleton_attr.chest.0, skeleton_attr.chest.1 - 8.0); - next.torso.position = - Vec3::new(0.0, 0.0, 0.0 + 8.0) * skeleton_attr.scaler / 11.0; - }, - StageSection::Swing => { - next.control.position = - Vec3::new(0.0, 12.0 + movement * 3.0, 15.0 + movement * -15.0); - next.control.orientation = Quaternion::rotation_x(0.3 + movement * -1.0) - * Quaternion::rotation_y(0.0) - * Quaternion::rotation_z(PI); - - next.head.orientation = Quaternion::rotation_x(movement * 0.2); - - next.hand_l.position = Vec3::new(-0.5, 0.0, 4.0); - - next.foot_l.position = Vec3::new( - -skeleton_attr.foot.0, - skeleton_attr.foot.1 + 4.0 + movement * -8.0, - skeleton_attr.foot.2 - 5.0 + movement * -3.0, - ); - next.foot_l.orientation = Quaternion::rotation_x(0.9 - movement * 1.8); - - next.foot_r.position = Vec3::new( - skeleton_attr.foot.0, - skeleton_attr.foot.1 + 4.0 + movement * -8.0, - skeleton_attr.foot.2 - 5.0 + movement * -3.0, - ); - next.foot_r.orientation = Quaternion::rotation_x(0.9 - movement * 1.8); - - next.torso.orientation = - Quaternion::rotation_x(-1.9 * PI - movement * 0.2 * PI); - - next.chest.position = - Vec3::new(0.0, skeleton_attr.chest.0, skeleton_attr.chest.1 - 8.0); - next.torso.position = - Vec3::new(0.0, 0.0, 0.0 + 8.0) * skeleton_attr.scaler / 11.0; - }, - StageSection::Recover => { - next.control.position = Vec3::new(0.0, 15.0, 0.0); - next.control.orientation = Quaternion::rotation_x(-0.7) - * Quaternion::rotation_y(0.0) - * Quaternion::rotation_z(PI); - - next.head.orientation = Quaternion::rotation_x(0.2); - - next.hand_l.position = Vec3::new(-0.5, 0.0, 4.0); - - next.chest.position = - Vec3::new(0.0, skeleton_attr.chest.0, skeleton_attr.chest.1 - 8.0); - next.torso.position = - Vec3::new(0.0, 0.0, 0.0 + 8.0) * skeleton_attr.scaler / 11.0; - next.torso.orientation = - Quaternion::rotation_x(-6.7 + movement * -0.1 * PI); - next.foot_l.position = Vec3::new( - -skeleton_attr.foot.0, - skeleton_attr.foot.1 - 4.0, - skeleton_attr.foot.2 - 8.0, - ); - next.foot_l.orientation = Quaternion::rotation_x(-0.9); - - next.foot_r.position = Vec3::new( - skeleton_attr.foot.0, - skeleton_attr.foot.1 - 4.0, - skeleton_attr.foot.2 - 8.0, - ); - next.foot_r.orientation = Quaternion::rotation_x(-0.9); - }, - _ => {}, - } - } - } + next.chest.position = + Vec3::new(0.0, skeleton_attr.chest.0, skeleton_attr.chest.1 - 8.0); + next.torso.position = + Vec3::new(0.0, 0.0, 0.0 + 8.0) * skeleton_attr.scaler / 11.0; //next.lantern.position = Vec3::new( // skeleton_attr.lantern.0, @@ -332,8 +168,9 @@ impl Animation for LeapAnimation { //); //next.glider.position = Vec3::new(0.0, 0.0, 10.0); //next.glider.scale = Vec3::one() * 0.0; - //next.l_control.scale = Vec3::one(); - //next.r_control.scale = Vec3::one(); + //next.control_l.scale = Vec3::one(); + //next.control_r.scale = Vec3::one(); + } next.second.scale = match ( active_tool_kind.map(|tk| tk.hands()), diff --git a/voxygen/src/anim/src/character/spin.rs b/voxygen/src/anim/src/character/spin.rs index 312fc7fea5..9ca44e13dd 100644 --- a/voxygen/src/anim/src/character/spin.rs +++ b/voxygen/src/anim/src/character/spin.rs @@ -38,6 +38,19 @@ impl Animation for SpinAnimation { let lab = 1.0; + let (movement1, movement2, movement3) = match stage_section { + Some(StageSection::Buildup) => { + (anim_time as f32, 0.0, 0.0) + }, + Some(StageSection::Swing) => { + (1.0, anim_time as f32, 0.0) + }, + Some(StageSection::Recover) => { + (1.0, 1.0, anim_time as f32) + }, + _ => (0.0, 0.0, 0.0), + }; + let foot = (((5.0) / (1.1 + 3.9 * ((anim_time as f32 * lab as f32 * 10.32).sin()).powf(2.0 as f32))) .sqrt()) @@ -48,12 +61,7 @@ impl Animation for SpinAnimation { 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 build = (anim_time as f32 * 8.0).sin(); - let recover = (anim_time as f32 * 8.0).sin(); - - let movement = anim_time as f32 * 1.0; - let stab = (anim_time as f32 * 8.0).sin(); - let rotate = (anim_time as f32 * 1.0).sin(); + fn slow(x: f32) -> f32 {(x * 8.0).sin()} next.head.position = Vec3::new(0.0, skeleton_attr.head.0, skeleton_attr.head.1); @@ -69,61 +77,38 @@ impl Animation for SpinAnimation { * Quaternion::rotation_y(0.0) * Quaternion::rotation_z(0.0); - if let Some(stage_section) = stage_section { - match stage_section { - StageSection::Buildup => { - //println!("{:.3} build", anim_time); - next.control.position = - Vec3::new(5.0, 11.0 + build * 0.6, 2.0 + build * 0.6); - next.control.orientation = Quaternion::rotation_x(0.0) - * Quaternion::rotation_y(-0.57 + movement * 2.0) - * Quaternion::rotation_z(0.0); - next.chest.orientation = Quaternion::rotation_y(movement * -0.1) - * Quaternion::rotation_z(-1.07 + movement * -0.6); - next.belt.orientation = Quaternion::rotation_x(movement * 0.1); - next.shorts.orientation = Quaternion::rotation_x(movement * 0.1); + next.control.position = + Vec3::new( + 5.0 + movement1 * 2.0 + movement2 * -8.0 + movement3 * -7.0, + 11.0 + slow(movement1) * 0.6 + slow(movement2) * 3.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(movement1 * -1.57 + movement2 * -0.6 + slow(movement2) * -0.25) + * Quaternion::rotation_y(-0.57 + movement1 * 2.0 + movement2 * -2.0) + * Quaternion::rotation_z(movement1 + movement2); - next.head.orientation = Quaternion::rotation_y(movement * 0.1) - * Quaternion::rotation_z(1.07 + movement * 0.4); - }, - StageSection::Swing => { - //println!("{:.3} swing", anim_time); - next.control.position = Vec3::new( - 7.0 + movement * -8.0, - 11.0 + stab * 3.0, - 2.0 + stab * 3.5 + movement * 3.0, - ); - next.control.orientation = - Quaternion::rotation_x(-1.57 + movement * -0.6 + stab * -0.25) - * Quaternion::rotation_y(2.8 + movement * -2.0) - * Quaternion::rotation_z(1.0 + movement * 1.0); - next.head.orientation = Quaternion::rotation_z(-stab * 0.8); - next.chest.orientation = Quaternion::rotation_x(stab * 0.15) - * Quaternion::rotation_y(movement * 0.3) - * Quaternion::rotation_z(movement * 1.5); - next.belt.orientation = Quaternion::rotation_z(rotate * 0.5); - next.shorts.orientation = Quaternion::rotation_z(rotate * 1.5); - next.torso.orientation = Quaternion::rotation_z(rotate * 7.2); - }, - StageSection::Recover => { - //println!("{:.3} recover", anim_time); - next.control.position = Vec3::new( - -8.0, - 11.0 - recover * 0.8 + movement * -10.0, - 6.0 - recover * 0.4 + movement * -4.0, - ); - next.control.orientation = Quaternion::rotation_x(-1.57) - * Quaternion::rotation_y(0.0) - * Quaternion::rotation_z(1.0); - next.chest.orientation = Quaternion::rotation_y(movement * -0.1) - * Quaternion::rotation_z(movement * 0.4); - next.head.orientation = Quaternion::rotation_y(movement * 0.1) - * Quaternion::rotation_z(movement * -0.1); - }, - _ => {}, - } - } + next.head.orientation = Quaternion::rotation_z(slow(movement2) * -0.8); + + next.chest.orientation = + Quaternion::rotation_x(slow(movement2) * 0.15) + * Quaternion::rotation_y(movement1 * -0.1 + movement2 * 0.3 + movement3 * -0.1) + * Quaternion::rotation_z(-1.0 + movement1 * -0.6 + movement2 * 1.5 + movement3 * 0.5); + + next.belt.orientation = + Quaternion::rotation_x(movement1 * 0.1) + * Quaternion::rotation_z(movement2.sin() * 0.5); + + next.shorts.orientation = + Quaternion::rotation_x(movement1 * 0.1) + * Quaternion::rotation_z(movement2.sin() * 1.5); + + next.head.orientation = + Quaternion::rotation_y(movement1 * 0.1 - movement2 * -0.1) + * Quaternion::rotation_z(1.07 + movement1 * 0.4 + movement2 * -1.5); + + next.torso.orientation = Quaternion::rotation_z((movement2).sin() * 7.2); } // println!("{:?}", stage_progress),