v2 WORKING ROTATIONS

This commit is contained in:
2018-11-10 23:23:03 +01:00
parent b41db01a55
commit cbe7b00b3a
7 changed files with 110 additions and 44 deletions
Binary file not shown.
Binary file not shown.
Binary file not shown.
+23 -18
View File
@@ -127,36 +127,41 @@ public class Foot : Component
Y += translateY;
Z += translateZ;
Y = Y * (invert ? -1 : 1);
X = X * (invert ? -1 : -1);
Z = Z * (invert ? -1 : -1);
/*RotateX();
RotateY();
RotateZ();*/
rotationY = rotationY * (invert ? 1 : 1);
// Z and X is working. Y has problems when combined with others.
Vector3 v = new Vector3((float)Z, (float)Y, (float)X);
v = Quaternion.Euler((float)rotationX, (float)rotationY, (float)rotationZ) * v;
Z = v.x;
Vector3 v = new Vector3((float)X, (float)Y, (float)Z);
v = Quaternion.Euler((float)0, (float)rotationY, (float)0) * v;
v = Quaternion.Euler((float)rotationX, (float)0, (float)0) * v;
v = Quaternion.Euler((float)0, (float)0, (float)rotationZ) * v;
X = v.x;
Y = v.y;
X = v.z;
Y = Y * (invert ? -1 : 1);
X = X * (invert ? -1 : -1);
Z = Z * (invert ? -1 : -1);
Z = v.z;
X -= translateX;
Y -= translateY;
Z -= translateZ;
// translate to my stupid formula coordinates.
double tx = X;
double ty = Y;
double tz = Z;
X = tz * (invert ? -1 : 1);
Y = ty * -1;
Z = tx * -1;
// run IK
O1 = (90 - FO1());
O2 = T1();
O3 = 180 - T3();
Y = Y * -1;
pos = new Vector3((float)Z, (float)Y, (float)X);
// translate to my stupid formula coordinates.
X = tx;
Y = ty;
Z = tz;
pos = new Vector3((float)X * (invert ? -1 : 1), (float)Y, (float)Z * (invert ? -1 : 1));
}
}
+5 -8
View File
@@ -34,13 +34,12 @@ public class Leg : MonoBehaviour {
void Update()
{
foot.X = point.x;
foot.Y = point.y * -1;
//foot.Z = point.z * (invert ? -1 : 1);
foot.Z = point.z * (invert ? 1 : -1);
foot.Y = point.y;
foot.Z = point.z;
foot.rotationX = rotation.x;
foot.rotationY = rotation.y * (invert ? -1 : 1);
foot.rotationZ = rotation.z * (invert ? -1 : 1);
foot.rotationY = rotation.y;
foot.rotationZ = rotation.z;
foot.translateX = translateX;
foot.translateY = translateY;
@@ -67,8 +66,6 @@ public class Leg : MonoBehaviour {
Hip2.transform.localRotation = Quaternion.Euler((float)a2, 0, 0);
Knie.transform.localRotation = Quaternion.Euler((float)a3, 0, 0);
pos = foot.pos;
pos.x = pos.x * (invert ? 1 : -1);
pointShouldBe.transform.localPosition = pos;
pointShouldBe.transform.localPosition = foot.pos;
}
}
+75 -11
View File
@@ -192,7 +192,7 @@ Prefab:
- target: {fileID: 114741880654588862, guid: c2064a01ffb68a84fa55bd109ccf70a4,
type: 2}
propertyPath: point.z
value: 1
value: -10
objectReference: {fileID: 0}
- target: {fileID: 114741880654588862, guid: c2064a01ffb68a84fa55bd109ccf70a4,
type: 2}
@@ -202,12 +202,21 @@ Prefab:
- target: {fileID: 114741880654588862, guid: c2064a01ffb68a84fa55bd109ccf70a4,
type: 2}
propertyPath: point.x
value: 10
value: -1
objectReference: {fileID: 0}
- target: {fileID: 114741880654588862, guid: c2064a01ffb68a84fa55bd109ccf70a4,
type: 2}
propertyPath: translateZ
value: 5
value: -5
objectReference: {fileID: 0}
- target: {fileID: 114741880654588862, guid: c2064a01ffb68a84fa55bd109ccf70a4,
type: 2}
propertyPath: translateX
value: -5
objectReference: {fileID: 0}
- target: {fileID: 1281778670178016, guid: c2064a01ffb68a84fa55bd109ccf70a4, type: 2}
propertyPath: m_IsActive
value: 1
objectReference: {fileID: 0}
m_RemovedComponents: []
m_ParentPrefab: {fileID: 100100000, guid: c2064a01ffb68a84fa55bd109ccf70a4, type: 2}
@@ -358,7 +367,7 @@ Prefab:
- target: {fileID: 114741880654588862, guid: c2064a01ffb68a84fa55bd109ccf70a4,
type: 2}
propertyPath: point.z
value: -1
value: 10
objectReference: {fileID: 0}
- target: {fileID: 114741880654588862, guid: c2064a01ffb68a84fa55bd109ccf70a4,
type: 2}
@@ -368,12 +377,16 @@ Prefab:
- target: {fileID: 114741880654588862, guid: c2064a01ffb68a84fa55bd109ccf70a4,
type: 2}
propertyPath: point.x
value: 10
value: 1
objectReference: {fileID: 0}
- target: {fileID: 114741880654588862, guid: c2064a01ffb68a84fa55bd109ccf70a4,
type: 2}
propertyPath: translateZ
value: -5
value: 5
objectReference: {fileID: 0}
- target: {fileID: 1281778670178016, guid: c2064a01ffb68a84fa55bd109ccf70a4, type: 2}
propertyPath: m_IsActive
value: 1
objectReference: {fileID: 0}
m_RemovedComponents: []
m_ParentPrefab: {fileID: 100100000, guid: c2064a01ffb68a84fa55bd109ccf70a4, type: 2}
@@ -442,7 +455,7 @@ Prefab:
- target: {fileID: 114741880654588862, guid: c2064a01ffb68a84fa55bd109ccf70a4,
type: 2}
propertyPath: point.x
value: 10
value: 0
objectReference: {fileID: 0}
- target: {fileID: 114741880654588862, guid: c2064a01ffb68a84fa55bd109ccf70a4,
type: 2}
@@ -452,8 +465,22 @@ Prefab:
- target: {fileID: 114741880654588862, guid: c2064a01ffb68a84fa55bd109ccf70a4,
type: 2}
propertyPath: translateZ
value: -5
objectReference: {fileID: 0}
- target: {fileID: 114741880654588862, guid: c2064a01ffb68a84fa55bd109ccf70a4,
type: 2}
propertyPath: translateX
value: 0
objectReference: {fileID: 0}
- target: {fileID: 1281778670178016, guid: c2064a01ffb68a84fa55bd109ccf70a4, type: 2}
propertyPath: m_IsActive
value: 1
objectReference: {fileID: 0}
- target: {fileID: 114741880654588862, guid: c2064a01ffb68a84fa55bd109ccf70a4,
type: 2}
propertyPath: point.z
value: -10
objectReference: {fileID: 0}
m_RemovedComponents: []
m_ParentPrefab: {fileID: 100100000, guid: c2064a01ffb68a84fa55bd109ccf70a4, type: 2}
m_IsPrefabParent: 0
@@ -533,7 +560,7 @@ Prefab:
- target: {fileID: 114741880654588862, guid: c2064a01ffb68a84fa55bd109ccf70a4,
type: 2}
propertyPath: point.z
value: -1
value: -10
objectReference: {fileID: 0}
- target: {fileID: 114741880654588862, guid: c2064a01ffb68a84fa55bd109ccf70a4,
type: 2}
@@ -543,13 +570,22 @@ Prefab:
- target: {fileID: 114741880654588862, guid: c2064a01ffb68a84fa55bd109ccf70a4,
type: 2}
propertyPath: point.x
value: 10
value: 1
objectReference: {fileID: 0}
- target: {fileID: 114741880654588862, guid: c2064a01ffb68a84fa55bd109ccf70a4,
type: 2}
propertyPath: translateZ
value: -5
objectReference: {fileID: 0}
- target: {fileID: 114741880654588862, guid: c2064a01ffb68a84fa55bd109ccf70a4,
type: 2}
propertyPath: translateX
value: 5
objectReference: {fileID: 0}
- target: {fileID: 1281778670178016, guid: c2064a01ffb68a84fa55bd109ccf70a4, type: 2}
propertyPath: m_IsActive
value: 1
objectReference: {fileID: 0}
m_RemovedComponents: []
m_ParentPrefab: {fileID: 100100000, guid: c2064a01ffb68a84fa55bd109ccf70a4, type: 2}
m_IsPrefabParent: 0
@@ -792,13 +828,27 @@ Prefab:
- target: {fileID: 114741880654588862, guid: c2064a01ffb68a84fa55bd109ccf70a4,
type: 2}
propertyPath: point.x
value: 10
value: -1
objectReference: {fileID: 0}
- target: {fileID: 114741880654588862, guid: c2064a01ffb68a84fa55bd109ccf70a4,
type: 2}
propertyPath: point.y
value: -10
objectReference: {fileID: 0}
- target: {fileID: 114741880654588862, guid: c2064a01ffb68a84fa55bd109ccf70a4,
type: 2}
propertyPath: translateX
value: -5
objectReference: {fileID: 0}
- target: {fileID: 1281778670178016, guid: c2064a01ffb68a84fa55bd109ccf70a4, type: 2}
propertyPath: m_IsActive
value: 1
objectReference: {fileID: 0}
- target: {fileID: 114741880654588862, guid: c2064a01ffb68a84fa55bd109ccf70a4,
type: 2}
propertyPath: point.z
value: 10
objectReference: {fileID: 0}
m_RemovedComponents: []
m_ParentPrefab: {fileID: 100100000, guid: c2064a01ffb68a84fa55bd109ccf70a4, type: 2}
m_IsPrefabParent: 0
@@ -852,7 +902,7 @@ Prefab:
- target: {fileID: 114741880654588862, guid: c2064a01ffb68a84fa55bd109ccf70a4,
type: 2}
propertyPath: point.x
value: 10
value: 0
objectReference: {fileID: 0}
- target: {fileID: 114741880654588862, guid: c2064a01ffb68a84fa55bd109ccf70a4,
type: 2}
@@ -862,8 +912,22 @@ Prefab:
- target: {fileID: 114741880654588862, guid: c2064a01ffb68a84fa55bd109ccf70a4,
type: 2}
propertyPath: translateZ
value: 5
objectReference: {fileID: 0}
- target: {fileID: 114741880654588862, guid: c2064a01ffb68a84fa55bd109ccf70a4,
type: 2}
propertyPath: translateX
value: 0
objectReference: {fileID: 0}
- target: {fileID: 1281778670178016, guid: c2064a01ffb68a84fa55bd109ccf70a4, type: 2}
propertyPath: m_IsActive
value: 1
objectReference: {fileID: 0}
- target: {fileID: 114741880654588862, guid: c2064a01ffb68a84fa55bd109ccf70a4,
type: 2}
propertyPath: point.z
value: 10
objectReference: {fileID: 0}
m_RemovedComponents: []
m_ParentPrefab: {fileID: 100100000, guid: c2064a01ffb68a84fa55bd109ccf70a4, type: 2}
m_IsPrefabParent: 0
+7 -7
View File
@@ -25,34 +25,34 @@ public class RotationControl : MonoBehaviour
// Update is called once per frame
void Update()
{
/*if (!dir2 && rotation.x < max)
if (!dir2 && rotation.x < max)
rotation.x += speed2;
else if (!dir2)
dir2 = !dir2;
else if (dir2 && rotation.x > min)
rotation.x -= speed2;
else if (dir2)
dir2 = !dir2;*/
dir2 = !dir2;
/*if (!dir3 && rotation.y < max)
if (!dir3 && rotation.y < max)
rotation.y += speed3;
else if (!dir3)
dir3 = !dir3;
else if (dir3 && rotation.y > min)
rotation.y -= speed3;
else if (dir3)
dir3 = !dir3;*/
dir3 = !dir3;
/*if (!dir && rotation.z < max)
if (!dir && rotation.z < max)
rotation.z += speed;
else if (!dir)
dir = !dir;
else if (dir && rotation.z > min)
rotation.z -= speed;
else if (dir)
dir = !dir;*/
dir = !dir;
body.transform.eulerAngles = new Vector3(rotation.x*-1, rotation.y, rotation.z);
body.transform.eulerAngles = new Vector3(rotation.x*-1, rotation.y*-1, rotation.z*-1);
for (int index = 0; index < rotation2.Count; ++index)
{