From e11f414bbc60e564e8ff42243ae32238b0c9955c Mon Sep 17 00:00:00 2001
From: jshipsey <jshipsey18@gmail.com>
Date: Tue, 23 Apr 2019 20:17:50 -0400
Subject: [PATCH] run animation incremental tweaks

Former-commit-id: f8800cad3d50eb3c536a1673bbe216b3098ce81e
---
 voxygen/src/anim/character/idle.rs | 16 ++++++---
 voxygen/src/anim/character/mod.rs  | 10 ++++--
 voxygen/src/anim/character/run.rs  | 55 +++++++++++++++++-------------
 voxygen/src/scene/figure.rs        | 10 +++---
 4 files changed, 56 insertions(+), 35 deletions(-)

diff --git a/voxygen/src/anim/character/idle.rs b/voxygen/src/anim/character/idle.rs
index 69f1ed5bfd..26633b13c5 100644
--- a/voxygen/src/anim/character/idle.rs
+++ b/voxygen/src/anim/character/idle.rs
@@ -32,7 +32,7 @@ impl Animation for IdleAnimation {
         let waveultracos_slow = (time as f32 * 1.0 + PI).cos();
         let wave_dip = (wave_slow.abs() - 0.5).abs();
 
-        next.head.offset = Vec3::new(-1.0, 0.0, 12.0 + waveultra_slow * 0.4) / SCALE;
+        next.head.offset = Vec3::new(5.5, 0.0, 12.0 + waveultra_slow * 0.4) / SCALE;
         next.head.ori = Quaternion::rotation_y(waveultra_slow * 0.05);
         next.head.scale = Vec3::one() / SCALE;
 
@@ -48,9 +48,9 @@ impl Animation for IdleAnimation {
         next.shorts.ori = Quaternion::rotation_y(0.0);
         next.shorts.scale = Vec3::one() / SCALE;
 
-        next.l_hand.offset = Vec3::new(2.0 + waveultracos_slow * 0.3, 7.5, 13.5 + waveultra_slow * 1.1) / SCALE;
+        next.l_hand.offset = Vec3::new(2.0 + waveultracos_slow * 0.3, 7.5, 12.5 + waveultra_slow * 1.1) / SCALE;
         next.l_hand.ori = Quaternion::rotation_y(0.0 + waveultra_slow * 0.06);
-        next.r_hand.offset = Vec3::new(2.0 + waveultracos_slow * 0.3 , - 7.5, 13.5 + waveultra_slow * 1.1) / SCALE;
+        next.r_hand.offset = Vec3::new(2.0 + waveultracos_slow * 0.3 , - 7.5, 12.5 + waveultra_slow * 1.1) / SCALE;
         next.r_hand.ori = Quaternion::rotation_y(0.0 + waveultra_slow * 0.06);
 
         next.l_foot.offset = Vec3::new(5.0, 3.4, 8.0) / SCALE;
@@ -58,7 +58,7 @@ impl Animation for IdleAnimation {
         next.r_foot.offset = Vec3::new(5.0, -3.4, 8.0) / SCALE;
         next.r_foot.ori = Quaternion::rotation_y(0.04 + waveultra_slow * 0.04);
 
-        next.back.offset = Vec3::new(-4.5, 12.0, 11.0);
+        next.back.offset = Vec3::new(-4.5, 14.0, 13.0);
         next.back.ori = Quaternion::rotation_x(2.5);
         next.back.scale = Vec3::one();
 
@@ -67,6 +67,14 @@ impl Animation for IdleAnimation {
         next.torso.ori = Quaternion::rotation_y(0.0);
         next.torso.scale = Vec3::one();
 
+        next.l_shoulder.offset = Vec3::new(2.9, 6.0, 18.0) / SCALE;
+        next.l_shoulder.ori = Quaternion::rotation_y(0.0);
+        next.l_shoulder.scale = Vec3::one() / SCALE;
+
+        next.r_shoulder.offset = Vec3::new(2.9, -6.0, 18.0) / SCALE;
+        next.r_shoulder.ori = Quaternion::rotation_y(0.0);
+        next.r_shoulder.scale = Vec3::one() / SCALE;
+
         next
     }
 }
diff --git a/voxygen/src/anim/character/mod.rs b/voxygen/src/anim/character/mod.rs
index f043977867..1579c6a906 100644
--- a/voxygen/src/anim/character/mod.rs
+++ b/voxygen/src/anim/character/mod.rs
@@ -28,6 +28,8 @@ pub struct CharacterSkeleton {
     r_foot: Bone,
     back: Bone,
     torso: Bone,
+    l_shoulder: Bone,
+    r_shoulder: Bone,
 
 }
 
@@ -44,6 +46,8 @@ impl CharacterSkeleton {
             r_foot: Bone::default(),
             back: Bone::default(),
             torso: Bone::default(),
+            l_shoulder: Bone::default(),
+            r_shoulder: Bone::default(),
 
         }
     }
@@ -64,8 +68,8 @@ impl Skeleton for CharacterSkeleton {
             FigureBoneData::new(torso_mat * self.r_foot.compute_base_matrix()),
             FigureBoneData::new(torso_mat * chest_mat * self.back.compute_base_matrix()),
             FigureBoneData::new(torso_mat),
-            FigureBoneData::default(),
-            FigureBoneData::default(),
+            FigureBoneData::new(torso_mat * self.l_shoulder.compute_base_matrix()),
+            FigureBoneData::new(torso_mat * self.r_shoulder.compute_base_matrix()),
             FigureBoneData::default(),
             FigureBoneData::default(),
             FigureBoneData::default(),
@@ -85,6 +89,8 @@ impl Skeleton for CharacterSkeleton {
         self.r_foot.interpolate(&target.r_foot);
         self.back.interpolate(&target.back);
         self.torso.interpolate(&target.torso);
+        self.l_shoulder.interpolate(&target.l_shoulder);
+        self.r_shoulder.interpolate(&target.r_shoulder);
 
     }
 }
diff --git a/voxygen/src/anim/character/run.rs b/voxygen/src/anim/character/run.rs
index 6ea0654d0f..f2a769fcb3 100644
--- a/voxygen/src/anim/character/run.rs
+++ b/voxygen/src/anim/character/run.rs
@@ -23,53 +23,60 @@ impl Animation for RunAnimation {
     ) -> Self::Skeleton {
         let mut next = (*skeleton).clone();
 
-        let wave = (time as f32 * 16.0).sin();
+        let wave = (time as f32 * 14.0).sin();
         let wavetest = (wave.cbrt());
         let fuzzwave = (time as f32 * 12.0).sin();
-        let wavecos = (time as f32 * 16.0).cos();
-        let wave_slow = (time as f32 * 8.0 + PI).sin();
+        let wavecos = (time as f32 * 14.0).cos();
+        let wave_slow = (time as f32 * 7.0 + PI).sin();
         let wavecos_slow = (time as f32 * 8.0 + PI).cos();
         let wave_dip = (wave_slow.abs() - 0.5).abs();
 
 
-        next.head.offset = Vec3::unit_z() * (12.0 + wave *1.3)/ SCALE;
-        next.chest.scale = Vec3::one() * 1.0;
+        next.head.offset = Vec3::new(6.0, 0.0, 12.0 + wavecos * 1.3)  / SCALE;
+        next.head.ori = Quaternion::rotation_y(-0.15);
 
-        next.chest.offset = Vec3::new(2.5, 0.0, 8.0 + wave * 1.1)  / SCALE;
-        next.chest.ori = Quaternion::rotation_z(wavecos * 0.2);
+        next.chest.offset = Vec3::new(2.5, 0.0, 8.0 + wavecos * 1.1)  / SCALE;
+        next.chest.ori = Quaternion::rotation_z(wave * 0.1);
         next.chest.scale = Vec3::one() / SCALE;
 
-        next.belt.offset = Vec3::new(2.5, 0.0, 6.0 + wave * 1.1) / SCALE;
-        next.belt.ori = Quaternion::rotation_z(wavecos * 0.2);
+        next.belt.offset = Vec3::new(2.5, 0.0, 6.0 + wavecos * 1.1) / SCALE;
+        next.belt.ori = Quaternion::rotation_z(wave * 0.25);
         next.belt.scale = Vec3::one() /SCALE;
 
-        next.shorts.offset = Vec3::new(2.5, 0.0, 3.0 + wave * 1.1) / SCALE;
-        next.shorts.ori = Quaternion::rotation_z(wavecos * 0.6);
+        next.shorts.offset = Vec3::new(2.5, 0.0, 3.0 + wavecos * 1.1) / SCALE;
+        next.shorts.ori = Quaternion::rotation_z(wave * 0.6);
         next.shorts.scale = Vec3::one() /SCALE;
 
-        next.l_hand.offset = Vec3::new(2.0 - wavecos * 1.0, 7.5, 11.0 - wave * 1.0) / SCALE;
-        next.l_hand.ori = Quaternion::rotation_y(wavecos * -1.8);
-        next.r_hand.offset = Vec3::new(2.0 + wavecos * 1.0, -7.5, 11.0 + wave * 1.0) / SCALE;
-        next.r_hand.ori = Quaternion::rotation_y(wavecos * 1.8);
+        next.l_hand.offset = Vec3::new(2.0 - wavecos * 2.5, 7.5, 12.0 + wave * 1.5) / SCALE;
+        next.l_hand.ori = Quaternion::rotation_y(wavecos * 0.9);
 
-        next.l_foot.offset = Vec3::new(3.5 - wave * 1.0, 3.4, 6.0) / SCALE;
-        next.l_foot.ori = Quaternion::rotation_y(-0.0 + wave * 1.5);
-        next.l_foot.scale = Vec3::one() / SCALE;
+        next.r_hand.offset = Vec3::new(2.0 + wavecos * 2.5, -7.5, 12.0 - wave * 1.5) / SCALE;
+        next.r_hand.ori = Quaternion::rotation_y(wavecos * -0.9);
 
-        next.r_foot.offset = Vec3::new(3.5 + wave * 1.0, -3.4, 6.0) / SCALE;
-        next.r_foot.ori = Quaternion::rotation_y(-0.0 - wave * 1.5);
+        next.l_foot.offset = Vec3::new(3.5 + wave * 1.0, 3.4, 6.0) / SCALE;
+        next.l_foot.ori = Quaternion::rotation_y(-0.0 - wave * 1.5);
 
-        next.back.offset = Vec3::new(-4.5, 12.0, 11.0);
+        next.r_foot.offset = Vec3::new(3.5 - wave * 1.0, -3.4, 6.0) / SCALE;
+        next.r_foot.ori = Quaternion::rotation_y(-0.0 + wave * 1.5);
+
+        next.back.offset = Vec3::new(-5.0, 14.0, 13.0);
         next.back.ori = Quaternion::rotation_x(2.5);
         next.back.scale = Vec3::one();
 
         next.torso.offset = Vec3::new(0.0, 0.0, 0.0);
-        next.torso.ori = Quaternion::rotation_y(0.2 + wave * 0.1);
-
-
+        next.torso.ori = Quaternion::rotation_y(0.25 + wavecos * 0.1);
         next.torso.scale = Vec3::one();
 
 
+        next.l_shoulder.offset = Vec3::new(3.0, 6.0, 18.0) / SCALE;
+        next.l_shoulder.ori = Quaternion::rotation_y(0.0);
+        next.l_shoulder.scale = Vec3::one() / SCALE;
+
+        next.r_shoulder.offset = Vec3::new(3.0, -6.0, 18.0) / SCALE;
+        next.r_shoulder.ori = Quaternion::rotation_y(0.0);
+        next.r_shoulder.scale = Vec3::one() / SCALE; //???why are shoulder scales like this
+
+
 
         next
 
diff --git a/voxygen/src/scene/figure.rs b/voxygen/src/scene/figure.rs
index ec99764650..96c938deba 100644
--- a/voxygen/src/scene/figure.rs
+++ b/voxygen/src/scene/figure.rs
@@ -55,18 +55,18 @@ impl Figures {
         let bone_meshes = [
 
 
-            Some(load_segment("head.vox").generate_mesh(Vec3::new(1.0, -7.0, -6.0))),
+            Some(load_segment("head.vox").generate_mesh(Vec3::new(-5.5, -7.0, -6.0))),
             Some(load_segment("chest.vox").generate_mesh(Vec3::new(-2.5, -6.0, 0.0))),
             Some(load_segment("belt.vox").generate_mesh(Vec3::new(-2.5, -5.0, 0.0))),
             Some(load_segment("pants.vox").generate_mesh(Vec3::new(-2.5, -5.0, 0.0))),
-            Some(load_segment("hand.vox").generate_mesh(Vec3::new(0.0, -2.0, -8.0))),
-            Some(load_segment("hand.vox").generate_mesh(Vec3::new(0.0, -2.0, -8.0))),
+            Some(load_segment("hand.vox").generate_mesh(Vec3::new(0.0, -2.0, -7.0))),
+            Some(load_segment("hand.vox").generate_mesh(Vec3::new(0.0, -2.0, -7.0))),
             Some(load_segment("foot.vox").generate_mesh(Vec3::new(-3.5, -2.5, -8.0))),
             Some(load_segment("foot.vox").generate_mesh(Vec3::new(-3.5, -2.5, -8.0))),
             Some(load_segment("sword.vox").generate_mesh(Vec3::new(0.0, -0.0, -4.0))),
             None,
-            None,
-            None,
+            //Some(load_segment("shoulder_left.vox").generate_mesh(Vec3::new(-3.0, -2.5, -8.0))),
+            //Some(load_segment("shoulder_right.vox").generate_mesh(Vec3::new(-3.0, -2.5, -8.0))),
             None,
             None,
             None,