From a3ee9b44b88bf1995f391063f3f047524bebbc58 Mon Sep 17 00:00:00 2001 From: ousttrue Date: Fri, 5 Aug 2022 15:52:43 +0900 Subject: [PATCH] =?UTF-8?q?pitch=20=E3=81=AE=E6=AD=A3=E6=96=B9=E5=90=91?= =?UTF-8?q?=E3=82=92=20vrm-0.x=20=E3=81=A8=E5=90=8C=E3=81=98=E3=81=AB?= =?UTF-8?q?=E3=81=99=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Editor/EditorTool/VRM10LookAtEditorTool.cs | 2 +- .../Components/LookAt/Matrix4x4Extensions.cs | 16 ++++++++++++---- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/Assets/VRM10/Editor/EditorTool/VRM10LookAtEditorTool.cs b/Assets/VRM10/Editor/EditorTool/VRM10LookAtEditorTool.cs index b7917fee5..d0458b33a 100644 --- a/Assets/VRM10/Editor/EditorTool/VRM10LookAtEditorTool.cs +++ b/Assets/VRM10/Editor/EditorTool/VRM10LookAtEditorTool.cs @@ -169,7 +169,7 @@ namespace UniVRM10 Handles.DrawSolidArc(Vector3.zero, Matrix4x4.identity.GetColumn(0), Matrix4x4.identity.GetColumn(2), - pitch, + -pitch, RADIUS); } } diff --git a/Assets/VRM10/Runtime/Components/LookAt/Matrix4x4Extensions.cs b/Assets/VRM10/Runtime/Components/LookAt/Matrix4x4Extensions.cs index 682c7392a..f88b4905c 100644 --- a/Assets/VRM10/Runtime/Components/LookAt/Matrix4x4Extensions.cs +++ b/Assets/VRM10/Runtime/Components/LookAt/Matrix4x4Extensions.cs @@ -62,6 +62,11 @@ namespace UniVRM10 return (yaw, pitch); } + /// + /// yaw: 右が+ + /// pitch: 上が+ + /// という仕様。vrm-0.x から据え置き + /// public static void CalcYawPitch(this Matrix4x4 m, Vector3 target, out float yaw, out float pitch) { var z = Vector3.Dot(target, m.GetColumn(2)); @@ -71,14 +76,17 @@ namespace UniVRM10 // x+y z plane var xz = Mathf.Sqrt(x * x + z * z); var y = Vector3.Dot(target, m.GetColumn(1)); - - // 正の方向が Euler 角になるように調整 - pitch = -Mathf.Atan2(y, xz) * Mathf.Rad2Deg; + pitch = Mathf.Atan2(y, xz) * Mathf.Rad2Deg; } + /// + /// yaw: 右が+ + /// pitch: 上が+ + /// という仕様。vrm-0.x から据え置き + /// public static Quaternion YawPitchRotation(this Matrix4x4 m, float yaw, float pitch) { - return Quaternion.AngleAxis(yaw, m.GetColumn(1)) * Quaternion.AngleAxis(pitch, m.GetColumn(0)); + return Quaternion.AngleAxis(yaw, m.GetColumn(1)) * Quaternion.AngleAxis(-pitch, m.GetColumn(0)); } public static Matrix4x4 RotationToWorldAxis(this Matrix4x4 m)