mirror of
https://github.com/vrm-c/UniVRM.git
synced 2026-07-18 16:21:50 -05:00
pitch の正方向を vrm-0.x と同じにする
This commit is contained in:
parent
996ff6e03b
commit
a3ee9b44b8
|
|
@ -169,7 +169,7 @@ namespace UniVRM10
|
|||
Handles.DrawSolidArc(Vector3.zero,
|
||||
Matrix4x4.identity.GetColumn(0),
|
||||
Matrix4x4.identity.GetColumn(2),
|
||||
pitch,
|
||||
-pitch,
|
||||
RADIUS);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -62,6 +62,11 @@ namespace UniVRM10
|
|||
return (yaw, pitch);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// yaw: 右が+
|
||||
/// pitch: 上が+
|
||||
/// という仕様。vrm-0.x から据え置き
|
||||
/// </summary>
|
||||
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;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// yaw: 右が+
|
||||
/// pitch: 上が+
|
||||
/// という仕様。vrm-0.x から据え置き
|
||||
/// </summary>
|
||||
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)
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user