Optimize code
This commit is contained in:
@@ -4,7 +4,7 @@ using UnityEngine;
|
|||||||
|
|
||||||
public class RotationConvert : MonoBehaviour
|
public class RotationConvert : MonoBehaviour
|
||||||
{
|
{
|
||||||
public static Vector3 fromMaya(Vector3 euler_angle)
|
public static Quaternion fromMaya(Vector3 euler_angle)
|
||||||
{
|
{
|
||||||
euler_angle.x *= Mathf.Deg2Rad;
|
euler_angle.x *= Mathf.Deg2Rad;
|
||||||
euler_angle.y *= Mathf.Deg2Rad;
|
euler_angle.y *= Mathf.Deg2Rad;
|
||||||
@@ -22,10 +22,6 @@ public class RotationConvert : MonoBehaviour
|
|||||||
float z = c * d * h - f * g * e;
|
float z = c * d * h - f * g * e;
|
||||||
float w = c * d * e + f * g * h;
|
float w = c * d * e + f * g * h;
|
||||||
|
|
||||||
Vector3 realAngle = new Quaternion(x, y, z, w).eulerAngles;
|
return new Quaternion(x, y, z, w);
|
||||||
realAngle.x = Mathf.Repeat(realAngle.x + 180, 360) - 180;
|
|
||||||
realAngle.y = Mathf.Repeat(realAngle.y + 180, 360) - 180;
|
|
||||||
realAngle.z = Mathf.Repeat(realAngle.z + 180 ,360) - 180;
|
|
||||||
return realAngle;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -197,7 +197,7 @@ namespace Gallop
|
|||||||
public void ApplyRotation(){
|
public void ApplyRotation(){
|
||||||
foreach (var trs in RotationRecorder)
|
foreach (var trs in RotationRecorder)
|
||||||
{
|
{
|
||||||
trs.Key.localEulerAngles = RotationConvert.fromMaya(trs.Value);
|
trs.Key.localRotation = RotationConvert.fromMaya(trs.Value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user