From 14d95b41978e0c59faeac81596418da2da8338d0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B7=A6=E5=8F=B3=E7=9C=8B?= <1918891542@qq.com> Date: Mon, 19 Sep 2022 00:18:14 +0800 Subject: [PATCH] fix emotion rotation --- Assets/Scripts/RotationConvert.cs | 9 +++++++-- .../Scripts/umamusume/Gallop/FaceDrivenKeyTarget.cs | 12 ++++++------ 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/Assets/Scripts/RotationConvert.cs b/Assets/Scripts/RotationConvert.cs index c2a9b58..702af55 100644 --- a/Assets/Scripts/RotationConvert.cs +++ b/Assets/Scripts/RotationConvert.cs @@ -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; } } diff --git a/Assets/Scripts/umamusume/Gallop/FaceDrivenKeyTarget.cs b/Assets/Scripts/umamusume/Gallop/FaceDrivenKeyTarget.cs index b72a0e3..28fc0cb 100644 --- a/Assets/Scripts/umamusume/Gallop/FaceDrivenKeyTarget.cs +++ b/Assets/Scripts/umamusume/Gallop/FaceDrivenKeyTarget.cs @@ -130,7 +130,7 @@ namespace Gallop { trs.transform.localScale += trs._scale * morph.Weight; trs.transform.localPosition += trs._position * morph.Weight; - trs.transform.localEulerAngles += RotationConvert.fromMaya(trs._rotation).eulerAngles * morph.Weight; + trs.transform.localEulerAngles += RotationConvert.fromMaya(trs._rotation) * morph.Weight; }; } } @@ -144,7 +144,7 @@ namespace Gallop trs.transform.localPosition = trs._position; trs.transform.localScale = trs._scale; - trs.transform.localEulerAngles = RotationConvert.fromMaya(trs._rotation).eulerAngles; + trs.transform.localEulerAngles = RotationConvert.fromMaya(trs._rotation); }; } @@ -155,7 +155,7 @@ namespace Gallop trs.transform.localPosition = trs._position; trs.transform.localScale = trs._scale; - trs.transform.localEulerAngles = RotationConvert.fromMaya(trs._rotation).eulerAngles; + trs.transform.localEulerAngles = RotationConvert.fromMaya(trs._rotation); }; } @@ -166,7 +166,7 @@ namespace Gallop trs.transform.localPosition = trs._position; trs.transform.localScale = trs._scale; - trs.transform.localEulerAngles = RotationConvert.fromMaya(trs._rotation).eulerAngles; + trs.transform.localEulerAngles = RotationConvert.fromMaya(trs._rotation); }; } @@ -177,7 +177,7 @@ namespace Gallop trs.transform.localPosition = trs._position; trs.transform.localScale = trs._scale; - trs.transform.localEulerAngles = RotationConvert.fromMaya(trs._rotation).eulerAngles; + trs.transform.localEulerAngles = RotationConvert.fromMaya(trs._rotation); }; } @@ -188,7 +188,7 @@ namespace Gallop trs.transform.localPosition = trs._position; trs.transform.localScale = trs._scale; - trs.transform.localEulerAngles = RotationConvert.fromMaya(trs._rotation).eulerAngles; + trs.transform.localEulerAngles = RotationConvert.fromMaya(trs._rotation); }; } }