Added PlayspaceLocation.
This commit is contained in:
parent
8a3786f4ce
commit
8d5ec72de1
|
|
@ -61,11 +61,6 @@ namespace VRDash
|
|||
{
|
||||
ProfileManager.SaveProfile();
|
||||
}
|
||||
if(e.Key == Key.F6 || e.Key == Key.P)
|
||||
{
|
||||
var profile = ProfileManager.LoadProfile();
|
||||
LoadProfile(profile);
|
||||
}
|
||||
};
|
||||
|
||||
try
|
||||
|
|
|
|||
|
|
@ -102,12 +102,12 @@ namespace VRDash.Overlay
|
|||
|
||||
public void Destroy()
|
||||
{
|
||||
m_ScreenTexture.Dispose();
|
||||
m_Device.ImmediateContext.ClearState();
|
||||
m_Device.ImmediateContext.Flush();
|
||||
m_Device.Dispose();
|
||||
m_Adapter.Dispose();
|
||||
m_Factory.Dispose();
|
||||
m_ScreenTexture?.Dispose();
|
||||
m_Device.ImmediateContext?.ClearState();
|
||||
m_Device.ImmediateContext?.Flush();
|
||||
m_Device?.Dispose();
|
||||
m_Adapter?.Dispose();
|
||||
m_Factory?.Dispose();
|
||||
CurrentFPS = 0;
|
||||
|
||||
var err = OpenVR.Overlay.DestroyOverlay(m_OverlayHandle);
|
||||
|
|
|
|||
|
|
@ -109,7 +109,13 @@ namespace VRDash.Overlay.Config.OverlayLocation
|
|||
M33 = matrix.M33 / scaling.Z
|
||||
};
|
||||
|
||||
Quaternion quatRes = Quaternion.FromMatrix(rotation);
|
||||
//Quaternion quatRes = Quaternion.FromMatrix(rotation);
|
||||
|
||||
|
||||
//Face center of playspace (hopefully)
|
||||
Vector3 up = new Vector3(0, 1, 0);
|
||||
|
||||
Quaternion quatRes = OpenTKExtensions.QuaternionLookRotation(new Vector3(0, 0, 0) - transform);
|
||||
|
||||
var q = quatRes;
|
||||
|
||||
|
|
@ -139,9 +145,9 @@ namespace VRDash.Overlay.Config.OverlayLocation
|
|||
yaw = MathHelper.RadiansToDegrees(yaw);
|
||||
roll = MathHelper.RadiansToDegrees(roll);
|
||||
|
||||
RotP = (float)pitch;
|
||||
RotY = (float)yaw;
|
||||
RotR = (float)roll;
|
||||
//RotP = (float)pitch;
|
||||
//RotY = (float)yaw;
|
||||
//RotR = (float)roll;
|
||||
}
|
||||
|
||||
private void Overlay_Update(object sender, EventArgs e)
|
||||
|
|
|
|||
|
|
@ -10,6 +10,66 @@ namespace VRDash.Utilities
|
|||
{
|
||||
public static class OpenTKExtensions
|
||||
{
|
||||
public static Quaternion QuaternionLookRotation(Vector3 forward)
|
||||
{
|
||||
Vector3 up = new Vector3(0, 1, 0);
|
||||
forward.Normalize();
|
||||
|
||||
Vector3 vector = Vector3.Normalize(forward);
|
||||
Vector3 vector2 = Vector3.Normalize(Vector3.Cross(up, vector));
|
||||
Vector3 vector3 = Vector3.Cross(vector, vector2);
|
||||
var m00 = vector2.X;
|
||||
var m01 = vector2.Y;
|
||||
var m02 = vector2.Z;
|
||||
var m10 = vector3.X;
|
||||
var m11 = vector3.Y;
|
||||
var m12 = vector3.Z;
|
||||
var m20 = vector.X;
|
||||
var m21 = vector.Y;
|
||||
var m22 = vector.Z;
|
||||
|
||||
|
||||
float num8 = (m00 + m11) + m22;
|
||||
var quaternion = new Quaternion();
|
||||
if (num8 > 0f)
|
||||
{
|
||||
var num = (float)Math.Sqrt(num8 + 1f);
|
||||
quaternion.W = num * 0.5f;
|
||||
num = 0.5f / num;
|
||||
quaternion.X = (m12 - m21) * num;
|
||||
quaternion.Y = (m20 - m02) * num;
|
||||
quaternion.Z = (m01 - m10) * num;
|
||||
return quaternion;
|
||||
}
|
||||
if ((m00 >= m11) && (m00 >= m22))
|
||||
{
|
||||
var num7 = (float)Math.Sqrt(((1f + m00) - m11) - m22);
|
||||
var num4 = 0.5f / num7;
|
||||
quaternion.X = 0.5f * num7;
|
||||
quaternion.Y = (m01 + m10) * num4;
|
||||
quaternion.Z = (m02 + m20) * num4;
|
||||
quaternion.W = (m12 - m21) * num4;
|
||||
return quaternion;
|
||||
}
|
||||
if (m11 > m22)
|
||||
{
|
||||
var num6 = (float)Math.Sqrt(((1f + m11) - m00) - m22);
|
||||
var num3 = 0.5f / num6;
|
||||
quaternion.X = (m10 + m01) * num3;
|
||||
quaternion.Y = 0.5f * num6;
|
||||
quaternion.Z = (m21 + m12) * num3;
|
||||
quaternion.W = (m20 - m02) * num3;
|
||||
return quaternion;
|
||||
}
|
||||
var num5 = (float)Math.Sqrt(((1f + m22) - m00) - m11);
|
||||
var num2 = 0.5f / num5;
|
||||
quaternion.X = (m20 + m02) * num2;
|
||||
quaternion.Y = (m21 + m12) * num2;
|
||||
quaternion.Z = 0.5f * num5;
|
||||
quaternion.W = (m01 - m10) * num2;
|
||||
return quaternion;
|
||||
}
|
||||
|
||||
public static HmdMatrix34_t ToOpenVRMatrix(this Matrix3x4 matrix)
|
||||
{
|
||||
var newmatrix = new HmdMatrix34_t();
|
||||
|
|
|
|||
Loading…
Reference in New Issue