fix emotion rotation

This commit is contained in:
左右看
2022-09-19 00:18:14 +08:00
parent 7e3460991a
commit 14d95b4197
2 changed files with 13 additions and 8 deletions
+7 -2
View File
@@ -4,7 +4,7 @@ using UnityEngine;
public class RotationConvert : MonoBehaviour
{
public static Quaternion fromMaya(Vector3 euler_angle)
public static Vector3 fromMaya(Vector3 euler_angle)
{
euler_angle.x *= Mathf.Deg2Rad;
euler_angle.y *= Mathf.Deg2Rad;
@@ -22,6 +22,11 @@ public class RotationConvert : MonoBehaviour
float z = c * d * h - f * g * e;
float w = c * d * e + f * g * h;
return new Quaternion(x, y, z, w);
Vector3 realAngle = new Quaternion(x, y, z, w).eulerAngles;
if (realAngle.x > 180) realAngle.x -= 360;
if (realAngle.y > 180) realAngle.y -= 360;
if (realAngle.z > 180) realAngle.z -= 360;
return realAngle;
}
}