Fix controller orientation when using OpenXR
This commit is contained in:
parent
927dfff7d1
commit
e33f599371
@ -11,6 +11,12 @@ namespace Passer.Tracking {
|
|||||||
|
|
||||||
protected XRNode xrNode;
|
protected XRNode xrNode;
|
||||||
|
|
||||||
|
protected enum LoadedDeviceType {
|
||||||
|
None,
|
||||||
|
Oculus,
|
||||||
|
OpenXR,
|
||||||
|
}
|
||||||
|
protected LoadedDeviceType loadedDevice = LoadedDeviceType.None;
|
||||||
public GameObject model;
|
public GameObject model;
|
||||||
|
|
||||||
#region Manage
|
#region Manage
|
||||||
@ -130,6 +136,12 @@ namespace Passer.Tracking {
|
|||||||
|
|
||||||
InputDevices.deviceConnected += OnDeviceConnected;
|
InputDevices.deviceConnected += OnDeviceConnected;
|
||||||
InputDevices.deviceDisconnected += OnDeviceDisconnected;
|
InputDevices.deviceDisconnected += OnDeviceDisconnected;
|
||||||
|
|
||||||
|
if (XRSettings.loadedDeviceName == "oculus display")
|
||||||
|
loadedDevice = LoadedDeviceType.Oculus;
|
||||||
|
else if (XRSettings.loadedDeviceName == "OpenXR Display")
|
||||||
|
loadedDevice = LoadedDeviceType.OpenXR;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -188,6 +200,8 @@ namespace Passer.Tracking {
|
|||||||
|
|
||||||
Quaternion rotation;
|
Quaternion rotation;
|
||||||
if (isTracked && device.TryGetFeatureValue(CommonUsages.deviceRotation, out rotation)) {
|
if (isTracked && device.TryGetFeatureValue(CommonUsages.deviceRotation, out rotation)) {
|
||||||
|
if (loadedDevice == LoadedDeviceType.OpenXR)
|
||||||
|
rotation *= Quaternion.AngleAxis(45, Vector3.right);
|
||||||
transform.rotation = trackerTransform.rotation * rotation;
|
transform.rotation = trackerTransform.rotation * rotation;
|
||||||
rotationConfidence = 1;
|
rotationConfidence = 1;
|
||||||
status = Tracker.Status.Tracking;
|
status = Tracker.Status.Tracking;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user