version 2.5.0

This commit is contained in:
Sean Lu
2025-01-10 17:17:03 +08:00
parent ddc3c4c6d8
commit 2372c9429a
1086 changed files with 290974 additions and 77367 deletions

View File

@@ -1,4 +1,4 @@
// ===================== 2022 HTC Corporation. All Rights Reserved. ===================
// Copyright HTC Corporation All Rights Reserved.
using System;
using System.Collections.Generic;
@@ -50,10 +50,12 @@ namespace VIVE.OpenXR
/// </summary>
/// <param name="isLeft">True for left hand.</param>
/// <param name="handJointLocation">Joint location data in <see href="https://registry.khronos.org/OpenXR/specs/1.0/html/xrspec.html#XrHandJointLocationEXT">XrHandJointLocationEXT</see>.</param>
/// <param name="timestamp">The hand tracking data timestamp.</param>
/// <returns>True for valid data.</returns>
public virtual bool GetJointLocations(bool isLeft, out XrHandJointLocationEXT[] handJointLocation)
public virtual bool GetJointLocations(bool isLeft, out XrHandJointLocationEXT[] handJointLocation, out XrTime timestamp)
{
handJointLocation = s_JointLocation[isLeft];
timestamp = 0;
if (m_JointLocations.isActive == 1)
{
@@ -78,6 +80,16 @@ namespace VIVE.OpenXR
return false;
}
/// <summary>
/// A convenient function to retrieve the left/right hand joint <see href="https://registry.khronos.org/OpenXR/specs/1.0/html/xrspec.html#XrHandJointLocationEXT">location data</see>.
/// </summary>
/// <param name="isLeft">True for left hand.</param>
/// <param name="handJointLocation">Joint location data in <see href="https://registry.khronos.org/OpenXR/specs/1.0/html/xrspec.html#XrHandJointLocationEXT">XrHandJointLocationEXT</see>.</param>
/// <returns>True for valid data.</returns>
public virtual bool GetJointLocations(bool isLeft, out XrHandJointLocationEXT[] handJointLocation)
{
return GetJointLocations(isLeft, out handJointLocation, out XrTime timestamp);
}
}
public static class XR_EXT_hand_tracking

View File

@@ -1,35 +1,53 @@
// ===================== 2022 HTC Corporation. All Rights Reserved. ===================
// Copyright HTC Corporation All Rights Reserved.
using System.Collections.Generic;
using System.Text;
using UnityEngine;
using UnityEngine.XR.OpenXR;
using VIVE.OpenXR.Hand;
namespace VIVE.OpenXR
{
public class XR_EXT_hand_tracking_impls : XR_EXT_hand_tracking_defs
{
const string LOG_TAG = "VIVE.OpenXR.Android.XR_EXT_hand_tracking_impls";
void DEBUG(string msg) { Debug.Log(LOG_TAG + " " + msg); }
#region Log
const string LOG_TAG = "VIVE.OpenXR.XR_EXT_hand_tracking_impls";
StringBuilder m_sb = null;
StringBuilder sb
{
get
{
if (m_sb == null) { m_sb = new StringBuilder(); }
return m_sb;
}
}
void DEBUG(StringBuilder msg) { Debug.LogFormat("{0} {1}", LOG_TAG, msg); }
#endregion
public XR_EXT_hand_tracking_impls() { DEBUG("XR_EXT_hand_tracking_impls()"); }
public XR_EXT_hand_tracking_impls() { sb.Clear().Append("XR_EXT_hand_tracking_impls()"); DEBUG(sb); }
private ViveHandTracking feature = null;
private void ASSERT_FEATURE() {
private bool ASSERT_FEATURE(bool init = false)
{
if (feature == null) { feature = OpenXRSettings.Instance.GetFeature<ViveHandTracking>(); }
bool enabled = (feature != null);
if (init)
{
sb.Clear().Append("ViveHandTracking is ").Append((enabled ? "enabled." : "disabled."));
DEBUG(sb);
}
return enabled;
}
public override XrResult xrCreateHandTrackerEXT(ref XrHandTrackerCreateInfoEXT createInfo, out ulong handTracker)
{
DEBUG("xrCreateHandTrackerEXT");
XrResult result = XrResult.XR_ERROR_VALIDATION_FAILURE;
handTracker = 0;
ASSERT_FEATURE();
if (feature)
if (ASSERT_FEATURE(true))
{
sb.Clear().Append("xrCreateHandTrackerEXT"); DEBUG(sb);
XrHandTrackerCreateInfoEXT info = createInfo;
result = (XrResult)feature.CreateHandTrackerEXT(ref info, out XrHandTrackerEXT tracker);
if (result == XrResult.XR_SUCCESS) { handTracker = tracker; }
@@ -39,10 +57,11 @@ namespace VIVE.OpenXR
}
public override XrResult xrDestroyHandTrackerEXT(ulong handTracker)
{
DEBUG("xrDestroyHandTrackerEXT");
ASSERT_FEATURE();
if (feature) { return (XrResult)feature.DestroyHandTrackerEXT(handTracker); }
if (ASSERT_FEATURE(true))
{
sb.Clear().Append("xrDestroyHandTrackerEXT"); DEBUG(sb);
return (XrResult)feature.DestroyHandTrackerEXT(handTracker);
}
return XrResult.XR_ERROR_VALIDATION_FAILURE;
}
@@ -53,8 +72,7 @@ namespace VIVE.OpenXR
InitializeHandJointLocations();
locations = m_JointLocations;
ASSERT_FEATURE();
if (feature)
if (ASSERT_FEATURE())
{
XrHandJointLocationsEXT joints = m_JointLocations;
result = (XrResult)feature.LocateHandJointsEXT(handTracker, locateInfo, ref joints);
@@ -64,12 +82,11 @@ namespace VIVE.OpenXR
return result;
}
public override bool GetJointLocations(bool isLeft, out XrHandJointLocationEXT[] handJointLocation)
public override bool GetJointLocations(bool isLeft, out XrHandJointLocationEXT[] handJointLocation, out XrTime timestamp)
{
ASSERT_FEATURE();
if (feature)
if (ASSERT_FEATURE())
{
if (feature.GetJointLocations(isLeft, out XrHandJointLocationEXT[] array))
if (feature.GetJointLocations(isLeft, out XrHandJointLocationEXT[] array, out timestamp))
{
if (l_HandJointLocation == null) { l_HandJointLocation = new List<XrHandJointLocationEXT>(); }
l_HandJointLocation.Clear();
@@ -81,7 +98,12 @@ namespace VIVE.OpenXR
}
handJointLocation = s_JointLocation[isLeft];
timestamp = 0;
return false;
}
public override bool GetJointLocations(bool isLeft, out XrHandJointLocationEXT[] handJointLocation)
{
return GetJointLocations(isLeft, out handJointLocation, out XrTime timestamp);
}
}
}

View File

@@ -0,0 +1,29 @@
// Copyright HTC Corporation All Rights Reserved.
namespace VIVE.OpenXR
{
public class XR_EXT_user_presence_defs
{
/// <summary>
/// Checks if an user is present. Default is true.
/// </summary>
/// <returns>True for present.</returns>
public virtual bool IsUserPresent() { return true; }
}
public static class XR_EXT_user_presence
{
static XR_EXT_user_presence_defs m_Instance = null;
public static XR_EXT_user_presence_defs Interop
{
get
{
if (m_Instance == null)
{
m_Instance = new XR_EXT_user_presence_impls();
}
return m_Instance;
}
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: afabb243c07ef464c838493b18d0a72b
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,46 @@
// Copyright HTC Corporation All Rights Reserved.
using System.Text;
using UnityEngine;
using UnityEngine.XR.OpenXR;
using VIVE.OpenXR.UserPresence;
namespace VIVE.OpenXR
{
public class XR_EXT_user_presence_impls : XR_EXT_user_presence_defs
{
#region Log
const string LOG_TAG = "VIVE.OpenXR.XR_EXT_user_presence_impls";
StringBuilder m_sb = null;
StringBuilder sb {
get {
if (m_sb == null) { m_sb = new StringBuilder(); }
return m_sb;
}
}
void DEBUG(StringBuilder msg) { Debug.LogFormat("{0} {1}", LOG_TAG, msg); }
#endregion
public XR_EXT_user_presence_impls() { sb.Clear().Append("XR_EXT_user_presence_impls()"); DEBUG(sb); }
private ViveUserPresence feature = null;
private bool ASSERT_FEATURE(bool init = false)
{
if (feature == null) { feature = OpenXRSettings.Instance.GetFeature<ViveUserPresence>(); }
bool enabled = (feature != null);
if (init)
{
sb.Clear().Append("ViveUserPresence is ").Append((enabled ? "enabled." : "disabled."));
DEBUG(sb);
}
return enabled;
}
public override bool IsUserPresent()
{
if (ASSERT_FEATURE()) { return feature.IsUserPresent(); }
return true;
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 0f553917d855c8347a13c7630afb07f6
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,45 @@
// Copyright HTC Corporation All Rights Reserved.
using VIVE.OpenXR.CompositionLayer;
namespace VIVE.OpenXR
{
public class XR_HTC_composition_layer_extra_settings_defs
{
/// <summary>
/// Enable the sharpening setting to the projection layer.
/// </summary>
/// <param name="sharpeningMode">The sharpening mode in <see cref="XrSharpeningModeHTC"/>.</param>
/// <param name="sharpeningLevel">The sharpening level in float [0, 1].</param>
/// <returns>True for success.</returns>
public virtual bool EnableSharpening(XrSharpeningModeHTC sharpeningMode, float sharpeningLevel)
{
return false;
}
/// <summary>
/// Disable the sharpening setting on the projection layer.
/// </summary>
/// <returns>True for success</returns>
public virtual bool DisableSharpening()
{
return false;
}
}
public static class XR_HTC_composition_layer_extra_settings
{
static XR_HTC_composition_layer_extra_settings_defs m_Instance = null;
public static XR_HTC_composition_layer_extra_settings_defs Interop
{
get
{
if (m_Instance == null)
{
m_Instance = new XR_HTC_composition_layer_extra_settings_impls();
}
return m_Instance;
}
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 2f9a9405f2a3f6c44b131cd38cec8ae3
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,44 @@
// Copyright HTC Corporation All Rights Reserved.
using UnityEngine;
using UnityEngine.XR.OpenXR;
using VIVE.OpenXR.CompositionLayer;
namespace VIVE.OpenXR
{
public class XR_HTC_composition_layer_extra_settings_impls : XR_HTC_composition_layer_extra_settings_defs
{
const string LOG_TAG = "VIVE.OpenXR.XR_HTC_composition_layer_extra_settings_impls";
void DEBUG(string msg) { Debug.Log(LOG_TAG + " " + msg); }
public XR_HTC_composition_layer_extra_settings_impls() { DEBUG("XR_HTC_composition_layer_extra_settings_impls()"); }
private ViveCompositionLayerExtraSettings feature = null;
private void ASSERT_FEATURE()
{
if (feature == null) { feature = OpenXRSettings.Instance.GetFeature<ViveCompositionLayerExtraSettings>(); }
}
public override bool EnableSharpening(XrSharpeningModeHTC sharpeningMode, float sharpeningLevel)
{
DEBUG("xrViveCompositionLayer_EnableSharpening");
ASSERT_FEATURE();
if (feature)
{
return feature.EnableSharpening(sharpeningMode, sharpeningLevel);
}
return false;
}
public override bool DisableSharpening()
{
DEBUG("xrViveCompositionLayer_EnableSharpening");
ASSERT_FEATURE();
if (feature)
{
return feature.DisableSharpening();
}
return false;
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: dd47d8d4716ae4c41a5d2e88f849d99b
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -1,9 +1,8 @@
// Copyright HTC Corporation All Rights Reserved.
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using VIVE.OpenXR.CompositionLayer;
using VIVE.OpenXR.CompositionLayer.Passthrough;
using VIVE.OpenXR.Passthrough;
namespace VIVE.OpenXR
{
@@ -36,8 +35,8 @@ namespace VIVE.OpenXR
{
return new XrFrameState();
}
}
public static class XR_HTC_passthrough
{
static XR_HTC_passthrough_defs m_Instance = null;

View File

@@ -0,0 +1,59 @@
// ===================== 2022 HTC Corporation. All Rights Reserved. ===================
using System;
using System.Collections.Generic;
using System.Runtime.InteropServices;
using VIVE.OpenXR.Passthrough;
namespace VIVE.OpenXR
{
public class XR_HTC_passthrough_configuration_defs
{
public virtual XrResult SetPassthroughConfigurationHTC(IntPtr config)
{
return XrResult.XR_ERROR_FEATURE_UNSUPPORTED;
}
public virtual XrResult GetPassthroughConfigurationHTC(IntPtr config)
{
return XrResult.XR_ERROR_FEATURE_UNSUPPORTED;
}
public virtual XrResult EnumeratePassthroughImageRatesHTC([In] UInt32 imageRateCapacityInput, ref UInt32 imageRateCountOutput, [In, Out] XrPassthroughConfigurationImageRateHTC[] imageRates)
{
return XrResult.XR_ERROR_FEATURE_UNSUPPORTED;
}
}
public class XR_HTC_passthrough_configuration
{
static XR_HTC_passthrough_configuration_defs m_Instance = null;
public static XR_HTC_passthrough_configuration_defs Interop
{
get
{
if (m_Instance == null)
{
m_Instance = new XR_HTC_passthrough_configuration_impls();
}
return m_Instance;
}
}
public static XrResult SetPassthroughConfigurationHTC(IntPtr config)
{
return Interop.SetPassthroughConfigurationHTC(config);
}
public static XrResult GetPassthroughConfigurationHTC(IntPtr config)
{
return Interop.GetPassthroughConfigurationHTC(config);
}
public static XrResult EnumeratePassthroughImageRatesHTC([In] UInt32 imageRateCapacityInput, ref UInt32 imageRateCountOutput, [In, Out] XrPassthroughConfigurationImageRateHTC[] imageRates)
{
return Interop.EnumeratePassthroughImageRatesHTC(imageRateCapacityInput, ref imageRateCountOutput, imageRates);
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: fa07bedac75da4b4dbe13a60f146d130
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,75 @@
// ===================== 2022 HTC Corporation. All Rights Reserved. ===================
using System;
using System.Runtime.InteropServices;
using UnityEngine;
using UnityEngine.XR.OpenXR;
using VIVE.OpenXR.Passthrough;
namespace VIVE.OpenXR
{
public class XR_HTC_passthrough_configuration_impls : XR_HTC_passthrough_configuration_defs
{
const string LOG_TAG = "VIVE.OpenXR.XR_HTC_passthrough_configuration_impls";
void DEBUG(string msg) { Debug.Log(LOG_TAG + " " + msg); }
private VivePassthrough feature = null;
private void ASSERT_FEATURE()
{
if (feature == null) { feature = OpenXRSettings.Instance.GetFeature<VivePassthrough>(); }
}
public override XrResult SetPassthroughConfigurationHTC(IntPtr config)
{
DEBUG("SetPassthroughConfigurationHTC");
XrResult result = XrResult.XR_ERROR_VALIDATION_FAILURE;
ASSERT_FEATURE();
if (feature)
{
if (!feature.SupportsImageQuality() || !feature.SupportsImageRate())
return XrResult.XR_ERROR_FEATURE_UNSUPPORTED;
result = (XrResult)feature.SetPassthroughConfigurationHTC(config);
}
return result;
}
public override XrResult GetPassthroughConfigurationHTC(IntPtr config)
{
DEBUG("GetPassthroughConfigurationHTC");
XrResult result = XrResult.XR_ERROR_VALIDATION_FAILURE;
ASSERT_FEATURE();
if (feature)
{
if (!feature.SupportsImageQuality() || !feature.SupportsImageRate())
return XrResult.XR_ERROR_FEATURE_UNSUPPORTED;
result = (XrResult)feature.GetPassthroughConfigurationHTC(config);
}
return result;
}
public override XrResult EnumeratePassthroughImageRatesHTC([In] UInt32 imageRateCapacityInput, ref UInt32 imageRateCountOutput, [In, Out] XrPassthroughConfigurationImageRateHTC[] imageRates)
{
DEBUG("EnumeratePassthroughImageRatesHTC");
XrResult result = XrResult.XR_ERROR_VALIDATION_FAILURE;
ASSERT_FEATURE();
if (feature)
{
if (!feature.SupportsImageQuality() || !feature.SupportsImageRate())
return XrResult.XR_ERROR_FEATURE_UNSUPPORTED;
result = (XrResult)feature.EnumeratePassthroughImageRatesHTC(imageRateCapacityInput, ref imageRateCountOutput, imageRates);
}
return result;
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: e70585d207c033c4999abe9294405298
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -1,10 +1,11 @@
// Copyright HTC Corporation All Rights Reserved.
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.XR.OpenXR;
using VIVE.OpenXR.CompositionLayer;
using VIVE.OpenXR.CompositionLayer.Passthrough;
using VIVE.OpenXR.Passthrough;
namespace VIVE.OpenXR
{
@@ -13,11 +14,11 @@ namespace VIVE.OpenXR
const string LOG_TAG = "VIVE.OpenXR.XR_HTC_passthrough_impls";
void DEBUG(string msg) { Debug.Log(LOG_TAG + " " + msg); }
public XR_HTC_passthrough_impls() { DEBUG("XR_HTC_passthrough_impls()"); }
private ViveCompositionLayerPassthrough feature = null;
private VivePassthrough feature = null;
private void ASSERT_FEATURE()
{
if (feature == null) { feature = OpenXRSettings.Instance.GetFeature<ViveCompositionLayerPassthrough>(); }
if (feature == null) { feature = OpenXRSettings.Instance.GetFeature<VivePassthrough>(); }
}
public override XrResult xrCreatePassthroughHTC(XrPassthroughCreateInfoHTC createInfo, out XrPassthroughHTC passthrough)
@@ -25,20 +26,20 @@ namespace VIVE.OpenXR
XrResult result = XrResult.XR_ERROR_VALIDATION_FAILURE;
passthrough = 0;
ASSERT_FEATURE();
#if UNITY_STANDALONE
if(feature)
result = feature.CreatePassthroughHTC(createInfo,out passthrough);
#endif
return result;
}
public override XrResult xrDestroyPassthroughHTC(XrPassthroughHTC passthrough)
{
XrResult result = XrResult.XR_ERROR_VALIDATION_FAILURE;
ASSERT_FEATURE();
#if UNITY_STANDALONE
if(feature)
result = feature.DestroyPassthroughHTC(passthrough);
#endif
return result;
}
@@ -66,10 +67,10 @@ namespace VIVE.OpenXR
public override XrSpace GetTrackingSpace()
{
ASSERT_FEATURE();
#if UNITY_STANDALONE
if (feature)
return feature.GetTrackingSpace();
#endif
return 0;
}