This fixes a whole bunch of coordinate and rotation issues.
This commit is contained in:
parent
f8b26af1af
commit
0d0a30dedb
2 changed files with 15 additions and 8 deletions
|
|
@ -8,8 +8,8 @@ public class OpenSeeIKTarget : MonoBehaviour
|
|||
public float translationScale = 0.3f;
|
||||
public float smooth = 0.2f;
|
||||
double updated = 0.0f;
|
||||
Quaternion dR;
|
||||
Vector3 dT;
|
||||
Quaternion dR = Quaternion.Euler(0f, 0f, -90f);
|
||||
Vector3 dT = new Vector3(0f, 0f, 0f);
|
||||
|
||||
void Update()
|
||||
{
|
||||
|
|
@ -31,19 +31,19 @@ public class OpenSeeIKTarget : MonoBehaviour
|
|||
return;
|
||||
}
|
||||
|
||||
// new Quaternion(-openSeeData[idx].rawQuaternion.x, -openSeeData[idx].rawQuaternion.y, openSeeData[idx].rawQuaternion.z, openSeeData[idx].rawQuaternion.w); // Good except for the head tilt in the start being flipped
|
||||
Quaternion convertedQuaternion = new Quaternion(-openSeeData[idx].rawQuaternion.y, -openSeeData[idx].rawQuaternion.x, openSeeData[idx].rawQuaternion.z, openSeeData[idx].rawQuaternion.w);
|
||||
|
||||
if (calibrate) {
|
||||
calibrate = false;
|
||||
dR = convertedQuaternion;//Quaternion.Euler(-openSeeData[idx].rotation.x, openSeeData[idx].rotation.y, -openSeeData[0].rotation.z);
|
||||
dR = convertedQuaternion;
|
||||
dR = Quaternion.Inverse(dR);
|
||||
dT = openSeeData[idx].translation;
|
||||
}
|
||||
|
||||
Vector3 v = openSeeData[idx].translation - dT;
|
||||
v.x = -v.x;
|
||||
v.z = -v.z;
|
||||
transform.localPosition = Vector3.Lerp(transform.localPosition, v * translationScale, 1f - smooth);
|
||||
transform.localRotation = Quaternion.Lerp(transform.localRotation, /*Quaternion.Euler(-openSeeData[idx].rotation.x, openSeeData[idx].rotation.y, -openSeeData[idx].rotation.z)*/ convertedQuaternion * dR, 1f - smooth);
|
||||
transform.localRotation = Quaternion.Lerp(transform.localRotation, convertedQuaternion * dR, 1f - smooth);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue