diff --git a/2018-unity-sim/.vs/Hexapod/v15/Server/sqlite3/storage.ide b/2018-unity-sim/.vs/Hexapod/v15/Server/sqlite3/storage.ide index b9471d5..1772fc1 100644 --- a/2018-unity-sim/.vs/Hexapod/v15/Server/sqlite3/storage.ide +++ b/2018-unity-sim/.vs/Hexapod/v15/Server/sqlite3/storage.ide @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:d61c4d70456f0abfd29aecca2ed8d20f6777e4f66d293946712d789e4d52661d +oid sha256:a112b1a23f82fb2ee5a227783908ee15220ae6538d132124814dbe046b8e7456 size 704512 diff --git a/2018-unity-sim/.vs/Hexapod/v15/Server/sqlite3/storage.ide-shm b/2018-unity-sim/.vs/Hexapod/v15/Server/sqlite3/storage.ide-shm index e98703c..14821ca 100644 --- a/2018-unity-sim/.vs/Hexapod/v15/Server/sqlite3/storage.ide-shm +++ b/2018-unity-sim/.vs/Hexapod/v15/Server/sqlite3/storage.ide-shm @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:1789ed53dec422b13077d32aaf6316b27ffaeb93028b2a0e350bca958d62772d +oid sha256:96725131fe70ef3e5f0c802dfedf2c719ad4b2b18f84abe4342371cb742a04fc size 32768 diff --git a/2018-unity-sim/.vs/Hexapod/v15/Server/sqlite3/storage.ide-wal b/2018-unity-sim/.vs/Hexapod/v15/Server/sqlite3/storage.ide-wal index 401006c..1a46983 100644 --- a/2018-unity-sim/.vs/Hexapod/v15/Server/sqlite3/storage.ide-wal +++ b/2018-unity-sim/.vs/Hexapod/v15/Server/sqlite3/storage.ide-wal @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:4863417bbcb00c136855aab9c10306c8a494aa756b537506fcaa6f3089a243fc +oid sha256:3e4665df57796556f6e9f3b54e1d87794d3e61d4637e00c94f699696e3016e1a size 4140632 diff --git a/2018-unity-sim/Assets/Foot.cs b/2018-unity-sim/Assets/Foot.cs index db17b44..7e4cb66 100644 --- a/2018-unity-sim/Assets/Foot.cs +++ b/2018-unity-sim/Assets/Foot.cs @@ -26,8 +26,9 @@ public class Foot : Component public double O1, O2, O3; public Vector3 transformation = new Vector3(0, 0, 0); + public Vector3 transformation2 = new Vector3(0, 0, 0); - static float temp = 2; + static float knie_offset = 2; void RL3() { @@ -40,7 +41,7 @@ public class Foot : Component l3 = l3 * -1; //todo - l3 -= temp; + l3 -= knie_offset; } double FO1() @@ -63,7 +64,7 @@ public class Foot : Component double z2 = Z * Z; double t = Math.Sqrt(x2 + z2); - t -= temp; + t -= knie_offset; t = t * t; //todo: X,Z remove distance temp. s = Math.Sqrt(y2 + t); @@ -156,6 +157,10 @@ public class Foot : Component Y = v.y; Z = v.z; + X -= transformation2.x; + Y -= transformation2.y; + Z -= transformation2.z; + X -= translateX; Y -= translateY; Z -= translateZ; diff --git a/2018-unity-sim/Assets/Leg.cs b/2018-unity-sim/Assets/Leg.cs index 50cb6be..eead909 100644 --- a/2018-unity-sim/Assets/Leg.cs +++ b/2018-unity-sim/Assets/Leg.cs @@ -15,6 +15,7 @@ public class Leg : MonoBehaviour { public Quaternion rotation = new Quaternion(0, 0, 0, 0); public Vector3 transformation = new Vector3(0, 0, 0); + public Vector3 transformation2 = new Vector3(0, 0, 0); public bool invert = false; @@ -47,8 +48,12 @@ public class Leg : MonoBehaviour { foot.translateY = translateY; foot.translateZ = translateZ; + // transform before rotation. foot.transformation = transformation; + // transform after rotation. + foot.transformation2 = transformation2; + foot.invert = invert; foot.setleg(); diff --git a/2018-unity-sim/Assets/Main.unity b/2018-unity-sim/Assets/Main.unity index e09c1fa..50665ef 100644 --- a/2018-unity-sim/Assets/Main.unity +++ b/2018-unity-sim/Assets/Main.unity @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:e246558765b9012632b9fd65fba8186ffdfe19b1e96581c9f671176030e8e2d6 -size 9964531 +oid sha256:95a2ba9a07a7566824cb024cd928f08c80c2820fdcd86abfc6642b43253d0ab4 +size 9965616 diff --git a/2018-unity-sim/Assets/RotationControl.cs b/2018-unity-sim/Assets/RotationControl.cs index 8797aa0..0652173 100644 --- a/2018-unity-sim/Assets/RotationControl.cs +++ b/2018-unity-sim/Assets/RotationControl.cs @@ -2,22 +2,72 @@ using System.Collections.Generic; using UnityEngine; -public class RotationControl : MonoBehaviour +public class rotation { - public Quaternion rotation = new Quaternion(0, 0, 0, 0); - public List rotation2 = new List(); - public GameObject body; - public float min = -15; public float max = 15; public float speed = 0.3f; - public float speed2 = 0.3f; - public float speed3 = 0.3f; public bool dir = false; - public bool dir2 = false; - public bool dir3 = false; + public bool enabled = true; - public bool p = false, r = false, y = false; + public float i = 0; + + public rotation(float speed, float min, float max) + { + this.speed = speed; + this.min = min; + this.max = max; + } + + public float update() + { + if (enabled) + { + if (!dir && i < max) + { + i += speed; + } + else if (!dir) + { + dir = !dir; + i = (float)max; + } + else if (dir && i > min) + { + i -= speed; + } + else if (dir) + { + dir = !dir; + i = (float)min; + } + } + + return i; + } +} + +public class RotationControl : MonoBehaviour +{ + public Vector3 transformation = new Vector3(0, 0, 0); + public Vector3 transformation2 = new Vector3(0, 0, 0); + + public Quaternion rotation = new Quaternion(0, 0, 0, 0); + public List rotation2 = new List(); + public GameObject body; + public GameObject body2; + + public rotation r1 = new rotation(0.1f, -15, 15); + public rotation r2 = new rotation(0.2f, -15, 15); + public rotation r3 = new rotation(0.3f, -15, 15); + + public rotation r4 = new rotation(0.01f, -3, 3); + public rotation r5 = new rotation(0.02f, -3, 3); + public rotation r6 = new rotation(0.03f, -3, 3); + + public rotation r7 = new rotation(0.001f, -3, 3); + public rotation r8 = new rotation(0.002f, -3, 3); + public rotation r9 = new rotation(0.003f, -3, 3); // Use this for initialization void Start () @@ -27,65 +77,27 @@ public class RotationControl : MonoBehaviour // Update is called once per frame void FixedUpdate() { - if (p) - { - if (!dir2 && rotation.x < max) - rotation.x += speed2; - else if (!dir2) - { - dir2 = !dir2; - rotation.x = (float)max; - } - else if (dir2 && rotation.x > min) - rotation.x -= speed2; - else if (dir2) - { - dir2 = !dir2; - rotation.x = (float)min; - } - } + rotation.x = r1.update(); + rotation.y = r2.update(); + rotation.z = r3.update(); - if (r) - { - if (!dir3 && rotation.y < max) - rotation.y += speed3; - else if (!dir3) - { - dir3 = !dir3; - rotation.y = (float)max; - } - else if (dir3 && rotation.y > min) - rotation.y -= speed3; - else if (dir3) - { - dir3 = !dir3; - rotation.y = (float)min; - } - } + transformation.x = r4.update(); + transformation.y = r5.update(); + transformation.z = r6.update(); - if (y) - { - if (!dir && rotation.z < max) - rotation.z += speed; - else if (!dir) - { - dir = !dir; - rotation.z = (float)max; - } - else if (dir && rotation.z > min) - rotation.z -= speed; - else if (dir) - { - dir = !dir; - rotation.z = (float)min; - } - } + transformation2.x = r7.update(); + transformation2.y = r8.update(); + transformation2.z = r9.update(); body.transform.eulerAngles = new Vector3(rotation.x*-1, rotation.y*-1, rotation.z*-1); + body.transform.position = transformation; + body2.transform.localPosition = transformation2; for (int index = 0; index < rotation2.Count; ++index) { rotation2[index].GetComponent().rotation = rotation; + rotation2[index].GetComponent().transformation = transformation; + rotation2[index].GetComponent().transformation2 = transformation2; rotation2[index].GetComponent().FixedUpdate(); } }