Init
This commit is contained in:
@@ -0,0 +1,251 @@
|
||||
#if PICO_OPENXR_SDK
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Runtime.InteropServices;
|
||||
using Unity.XR.PXR;
|
||||
using UnityEngine;
|
||||
#if AR_FOUNDATION_5||AR_FOUNDATION_6
|
||||
using UnityEngine.XR.ARSubsystems;
|
||||
#endif
|
||||
using UnityEngine.XR.OpenXR;
|
||||
using UnityEngine.XR.OpenXR.Features;
|
||||
#if UNITY_EDITOR
|
||||
using UnityEditor.XR.OpenXR.Features;
|
||||
#endif
|
||||
|
||||
namespace Unity.XR.OpenXR.Features.PICOSupport
|
||||
{
|
||||
public enum XrBodyJointSetBD
|
||||
{
|
||||
XR_BODY_JOINT_SET_DEFAULT_BD = 0, //default joint set XR_BODY_JOINT_SET_BODY_STAR_WITHOUT_ARM_BD
|
||||
XR_BODY_JOINT_SET_BODY_START_WITHOUT_ARM_BD = 1,
|
||||
XR_BODY_JOINT_SET_BODY_FULL_STAR_BD = 2
|
||||
}
|
||||
|
||||
|
||||
#if UNITY_EDITOR
|
||||
[OpenXRFeature(UiName = "PICO Body Tracking",
|
||||
Hidden = false,
|
||||
BuildTargetGroups = new[] { UnityEditor.BuildTargetGroup.Android },
|
||||
Company = "PICO",
|
||||
OpenxrExtensionStrings = extensionString,
|
||||
Version = PXR_Constants.SDKVersion,
|
||||
FeatureId = featureId)]
|
||||
#endif
|
||||
|
||||
public class BodyTrackingFeature : OpenXRFeatureBase
|
||||
{
|
||||
public const string featureId = "com.pico.openxr.feature.PICO_BodyTracking";
|
||||
public const string extensionString = "XR_BD_body_tracking XR_PICO_body_tracking2";
|
||||
|
||||
public static bool isEnable => OpenXRRuntime.IsExtensionEnabled("XR_BD_body_tracking");
|
||||
|
||||
public override string GetExtensionString()
|
||||
{
|
||||
return extensionString;
|
||||
}
|
||||
|
||||
[Obsolete("Please use StartBodyTracking(BodyJointSet JointSet, BodyTrackingBoneLength boneLength)")]
|
||||
public static bool StartBodyTracking(XrBodyJointSetBD Mode)
|
||||
{
|
||||
if (!isEnable)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
BodyTrackingBoneLength boneLength=new BodyTrackingBoneLength();
|
||||
|
||||
return StartBodyTracking((BodyJointSet)Mode, boneLength)==0;
|
||||
}
|
||||
/// <summary>Starts body tracking.</summary>
|
||||
/// <param name="mode">Specifies the body tracking mode (default or high-accuracy).</param>
|
||||
/// <param name="boneLength">Specifies lengths (unit: cm) for the bones of the avatar, which is only available for the `BTM_FULL_BODY_HIGH` mode.
|
||||
/// Bones that are not set lengths for will use the default values.
|
||||
/// </param>
|
||||
/// <returns>
|
||||
/// - `0`: success
|
||||
/// - `1`: failure
|
||||
/// </returns>
|
||||
public static int StartBodyTracking(BodyJointSet JointSet, BodyTrackingBoneLength boneLength)
|
||||
{
|
||||
if (!isEnable)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
BodyTrackingStartInfo startInfo = new BodyTrackingStartInfo();
|
||||
startInfo.jointSet = JointSet;
|
||||
startInfo.BoneLength = boneLength;
|
||||
|
||||
return Pxr_StartBodyTracking(ref startInfo);
|
||||
}
|
||||
/// <summary>Launches the PICO Motion Tracker app to perform calibration.
|
||||
/// - For PICO Motion Tracker (Beta), the user needs to follow the instructions on the home of the PICO Motion Tracker app to complete calibration.
|
||||
/// - For PICO Motion Tracker (Official), "single-glance calibration" will be performed. When a user has a glance at the PICO Motion Tracker on their lower legs, calibration is completed.
|
||||
/// </summary>
|
||||
/// <returns>
|
||||
/// - `0`: success
|
||||
/// - `1`: failure
|
||||
/// </returns>
|
||||
public static int StartMotionTrackerCalibApp()
|
||||
{
|
||||
if (!isEnable)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
return Pxr_StartBodyTrackingCalibApp();
|
||||
}
|
||||
|
||||
public static bool IsBodyTrackingSupported()
|
||||
{
|
||||
if (!isEnable)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
bool supported=false;
|
||||
Pxr_GetBodyTrackingSupported(ref supported);
|
||||
return supported;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the data about the poses of body joints.
|
||||
/// </summary>
|
||||
/// <param name="predictTime">Reserved parameter, pass `0`.</param>
|
||||
/// <param name="bodyTrackerResult">Contains the data about the poses of body joints, including position, action, and more.</param>
|
||||
[Obsolete("Please use GetBodyTrackingData",true)]
|
||||
public static bool GetBodyTrackingPose(ref BodyTrackerResult bodyTrackerResult)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
/// <summary>Stops body tracking.</summary>
|
||||
/// <returns>
|
||||
/// - `0`: success
|
||||
/// - `1`: failure
|
||||
/// </returns>
|
||||
public static int StopBodyTracking()
|
||||
{
|
||||
return Pxr_StopBodyTracking();
|
||||
}
|
||||
[Obsolete("Please use StopBodyTracking")]
|
||||
private void OnDestroy()
|
||||
{
|
||||
if (!isEnable)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
StopBodyTracking();
|
||||
}
|
||||
|
||||
[Obsolete("Please use StartMotionTrackerCalibApp")]
|
||||
public static void OpenFitnessBandCalibrationAPP()
|
||||
{
|
||||
StartMotionTrackerCalibApp();
|
||||
}
|
||||
|
||||
/// <summary>Gets body tracking data.</summary>
|
||||
/// <param name="getInfo"> Specifies the display time and the data filtering flags.
|
||||
/// For the display time, for example, when it is set to 0.1 second, it means predicting the pose of the tracked node 0.1 seconds ahead.
|
||||
/// </param>
|
||||
/// <param name="data">Returns the array of data for all tracked nodes.</param>
|
||||
/// <returns>
|
||||
/// - `0`: success
|
||||
/// - `1`: failure
|
||||
/// </returns>
|
||||
public unsafe static int GetBodyTrackingData(ref BodyTrackingGetDataInfo getInfo, ref BodyTrackingData data)
|
||||
{
|
||||
if (!isEnable)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
int val = -1;
|
||||
{
|
||||
val = Pxr_GetBodyTrackingData(ref getInfo, ref data);
|
||||
for (int i = 0; i < (int)BodyTrackerRole.ROLE_NUM; i++)
|
||||
{
|
||||
data.roleDatas[i].localPose.PosZ = -data.roleDatas[i].localPose.PosZ;
|
||||
data.roleDatas[i].localPose.RotQz = -data.roleDatas[i].localPose.RotQz;
|
||||
data.roleDatas[i].localPose.RotQw = -data.roleDatas[i].localPose.RotQw;
|
||||
data.roleDatas[i].velo[3] = -data.roleDatas[i].velo[3];
|
||||
data.roleDatas[i].acce[3] = -data.roleDatas[i].acce[3];
|
||||
data.roleDatas[i].wvelo[3] = -data.roleDatas[i].wvelo[3];
|
||||
data.roleDatas[i].wacce[3] = -data.roleDatas[i].wacce[3];
|
||||
}
|
||||
}
|
||||
return val;
|
||||
}
|
||||
/// <summary>Gets the state of PICO Motion Tracker and, if any, the reason for an exception.</summary>
|
||||
/// <param name="isTracking">Indicates whether the PICO Motion Tracker is tracking normally:
|
||||
/// - `true`: is tracking
|
||||
/// - `false`: tracking lost
|
||||
/// </param>
|
||||
/// <param name="state">Returns the information about body tracking state.</param>
|
||||
/// <returns>
|
||||
/// - `0`: success
|
||||
/// - `1`: failure
|
||||
/// </returns>
|
||||
public static int GetBodyTrackingState(ref bool isTracking, ref BodyTrackingStatus state)
|
||||
{
|
||||
int val = -1;
|
||||
{
|
||||
val = Pxr_GetBodyTrackingState(ref isTracking, ref state);
|
||||
}
|
||||
return val;
|
||||
}
|
||||
|
||||
#if AR_FOUNDATION_5||AR_FOUNDATION_6
|
||||
public bool isBodyTracking=false;
|
||||
static List<XRHumanBodySubsystemDescriptor> s_HumanBodyDescriptors = new List<XRHumanBodySubsystemDescriptor>();
|
||||
protected override void OnSubsystemCreate()
|
||||
{
|
||||
base.OnSubsystemCreate();
|
||||
if (isBodyTracking)
|
||||
{
|
||||
CreateSubsystem<XRHumanBodySubsystemDescriptor, XRHumanBodySubsystem>(
|
||||
s_HumanBodyDescriptors,
|
||||
PXR_HumanBodySubsystem.k_SubsystemId);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
protected override void OnSubsystemStart()
|
||||
{
|
||||
if (isBodyTracking)
|
||||
{
|
||||
StartSubsystem<XRHumanBodySubsystem>();
|
||||
}
|
||||
}
|
||||
protected override void OnSubsystemStop()
|
||||
{
|
||||
if (isBodyTracking)
|
||||
{
|
||||
StopSubsystem<XRHumanBodySubsystem>();
|
||||
}
|
||||
}
|
||||
protected override void OnSubsystemDestroy()
|
||||
{
|
||||
if (isBodyTracking)
|
||||
{
|
||||
DestroySubsystem<XRHumanBodySubsystem>();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
[DllImport(OpenXRExtensions.PXR_PLATFORM_DLL, CallingConvention = CallingConvention.Cdecl)]
|
||||
private static extern int Pxr_StartBodyTrackingCalibApp();
|
||||
[DllImport(OpenXRExtensions.PXR_PLATFORM_DLL, CallingConvention = CallingConvention.Cdecl)]
|
||||
private static extern int Pxr_GetBodyTrackingSupported(ref bool supported);
|
||||
[DllImport(OpenXRExtensions.PXR_PLATFORM_DLL, CallingConvention = CallingConvention.Cdecl)]
|
||||
private static extern int Pxr_StartBodyTracking(ref BodyTrackingStartInfo startInfo);
|
||||
[DllImport(OpenXRExtensions.PXR_PLATFORM_DLL, CallingConvention = CallingConvention.Cdecl)]
|
||||
private static extern int Pxr_StopBodyTracking();
|
||||
[DllImport(OpenXRExtensions.PXR_PLATFORM_DLL, CallingConvention = CallingConvention.Cdecl)]
|
||||
private static extern int Pxr_GetBodyTrackingState(ref bool isTracking, ref BodyTrackingStatus state);
|
||||
[DllImport(OpenXRExtensions.PXR_PLATFORM_DLL, CallingConvention = CallingConvention.Cdecl)]
|
||||
private static extern int Pxr_GetBodyTrackingData(ref BodyTrackingGetDataInfo getInfo, ref BodyTrackingData data);
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: aa772d31a64f93d49bd62d49064fee41
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,55 @@
|
||||
#if PICO_OPENXR_SDK
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
using Unity.XR.PXR;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
using UnityEngine.XR.OpenXR;
|
||||
using UnityEngine.XR.OpenXR.Features;
|
||||
using Object = UnityEngine.Object;
|
||||
|
||||
#if UNITY_EDITOR
|
||||
using UnityEditor.XR.OpenXR.Features;
|
||||
#endif
|
||||
|
||||
|
||||
namespace Unity.XR.OpenXR.Features.PICOSupport
|
||||
{
|
||||
#if UNITY_EDITOR
|
||||
[OpenXRFeature(UiName = "PICO Scene Capture",
|
||||
Hidden = false,
|
||||
BuildTargetGroups = new[] { UnityEditor.BuildTargetGroup.Android },
|
||||
Company = "PICO",
|
||||
OpenxrExtensionStrings = extensionString,
|
||||
Version = "1.0.0",
|
||||
FeatureId = featureId)]
|
||||
#endif
|
||||
public class PICOSceneCapture: OpenXRFeature
|
||||
{
|
||||
public const string featureId = "com.pico.openxr.feature.scenecapture";
|
||||
public const string extensionString = "XR_PICO_scene_capture XR_PICO_spatial_sensing XR_EXT_future";
|
||||
public static bool isEnable => OpenXRRuntime.IsExtensionEnabled("XR_PICO_scene_capture");
|
||||
protected override void OnSessionCreate(ulong xrSession)
|
||||
{
|
||||
base.OnSessionCreate(xrSession);
|
||||
PXR_Plugin.MixedReality.UPxr_CreateSceneCaptureSenseDataProvider();
|
||||
}
|
||||
|
||||
protected override void OnSessionExiting(ulong xrSession)
|
||||
{
|
||||
PXR_MixedReality.GetSenseDataProviderState(PxrSenseDataProviderType.SceneCapture, out var providerState);
|
||||
if (providerState == PxrSenseDataProviderState.Running)
|
||||
{
|
||||
PXR_MixedReality.StopSenseDataProvider(PxrSenseDataProviderType.SceneCapture);
|
||||
}
|
||||
|
||||
PXR_Plugin.MixedReality.UPxr_DestroySenseDataProvider(
|
||||
PXR_Plugin.MixedReality.UPxr_GetSenseDataProviderHandle(PxrSenseDataProviderType.SceneCapture));
|
||||
|
||||
base.OnSessionExiting(xrSession);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a0b5403262c64d5888bf5672e1e1f3bb
|
||||
timeCreated: 1721806849
|
||||
@@ -0,0 +1,96 @@
|
||||
#if PICO_OPENXR_SDK
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
using Unity.XR.PXR;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
#if AR_FOUNDATION_5||AR_FOUNDATION_6
|
||||
using UnityEngine.XR.ARSubsystems;
|
||||
#endif
|
||||
using UnityEngine.XR.OpenXR;
|
||||
using UnityEngine.XR.OpenXR.Features;
|
||||
using Object = UnityEngine.Object;
|
||||
|
||||
#if UNITY_EDITOR
|
||||
using UnityEditor.XR.OpenXR.Features;
|
||||
#endif
|
||||
|
||||
|
||||
namespace Unity.XR.OpenXR.Features.PICOSupport
|
||||
{
|
||||
#if UNITY_EDITOR
|
||||
[OpenXRFeature(UiName = "PICO Spatial Anchor",
|
||||
Hidden = false,
|
||||
BuildTargetGroups = new[] { UnityEditor.BuildTargetGroup.Android },
|
||||
Company = "PICO",
|
||||
OpenxrExtensionStrings = extensionString,
|
||||
Version = "1.0.0",
|
||||
FeatureId = featureId)]
|
||||
#endif
|
||||
public class PICOSpatialAnchor: OpenXRFeature
|
||||
{
|
||||
public const string featureId = "com.pico.openxr.feature.spatialanchor";
|
||||
public const string extensionString = "XR_PICO_spatial_anchor XR_PICO_spatial_sensing XR_EXT_future";
|
||||
|
||||
public static bool isEnable => OpenXRRuntime.IsExtensionEnabled("XR_PICO_spatial_anchor");
|
||||
|
||||
protected override void OnSessionCreate(ulong xrSession)
|
||||
{
|
||||
base.OnSessionCreate(xrSession);
|
||||
PXR_Plugin.MixedReality.UPxr_CreateSpatialAnchorSenseDataProvider();
|
||||
}
|
||||
protected override void OnSessionExiting(ulong xrSession)
|
||||
{
|
||||
PXR_MixedReality.GetSenseDataProviderState(PxrSenseDataProviderType.SpatialAnchor, out var providerState);
|
||||
if (providerState == PxrSenseDataProviderState.Running)
|
||||
{
|
||||
PXR_MixedReality.StopSenseDataProvider(PxrSenseDataProviderType.SpatialAnchor);
|
||||
}
|
||||
|
||||
PXR_Plugin.MixedReality.UPxr_DestroySenseDataProvider(
|
||||
PXR_Plugin.MixedReality.UPxr_GetSenseDataProviderHandle(PxrSenseDataProviderType.SpatialAnchor));
|
||||
|
||||
base.OnSessionExiting(xrSession);
|
||||
}
|
||||
|
||||
#if AR_FOUNDATION_5||AR_FOUNDATION_6
|
||||
public bool isAnchorSubsystem=false;
|
||||
static List<XRAnchorSubsystemDescriptor> anchorSubsystemDescriptors = new List<XRAnchorSubsystemDescriptor>();
|
||||
protected override void OnSubsystemCreate()
|
||||
{
|
||||
base.OnSubsystemCreate();
|
||||
if (isAnchorSubsystem)
|
||||
{
|
||||
CreateSubsystem<XRAnchorSubsystemDescriptor, XRAnchorSubsystem>(
|
||||
anchorSubsystemDescriptors,
|
||||
PXR_AnchorSubsystem.k_SubsystemId);
|
||||
}
|
||||
|
||||
}
|
||||
protected override void OnSubsystemStart()
|
||||
{
|
||||
if (isAnchorSubsystem)
|
||||
{
|
||||
StartSubsystem<XRAnchorSubsystem>();
|
||||
}
|
||||
}
|
||||
protected override void OnSubsystemStop()
|
||||
{
|
||||
if (isAnchorSubsystem)
|
||||
{
|
||||
StopSubsystem<XRAnchorSubsystem>();
|
||||
}
|
||||
}
|
||||
protected override void OnSubsystemDestroy()
|
||||
{
|
||||
if (isAnchorSubsystem)
|
||||
{
|
||||
DestroySubsystem<XRAnchorSubsystem>();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a8b7731b990240c0b289e41fb880787b
|
||||
timeCreated: 1721806849
|
||||
@@ -0,0 +1,72 @@
|
||||
#if PICO_OPENXR_SDK
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
// using Unity.XR.CoreUtils;
|
||||
using Unity.XR.PXR;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
using UnityEngine.XR;
|
||||
using UnityEngine.XR.OpenXR;
|
||||
using UnityEngine.XR.OpenXR.Features;
|
||||
using Object = UnityEngine.Object;
|
||||
|
||||
#if UNITY_EDITOR
|
||||
using UnityEditor.XR.OpenXR.Features;
|
||||
#endif
|
||||
|
||||
|
||||
namespace Unity.XR.OpenXR.Features.PICOSupport
|
||||
{
|
||||
#if UNITY_EDITOR
|
||||
[OpenXRFeature(UiName = "PICO Spatial Mesh",
|
||||
Hidden = false,
|
||||
BuildTargetGroups = new[] { UnityEditor.BuildTargetGroup.Android },
|
||||
Company = "PICO",
|
||||
OpenxrExtensionStrings = extensionString,
|
||||
Version = "1.0.0",
|
||||
FeatureId = featureId)]
|
||||
#endif
|
||||
public class PICOSpatialMesh: OpenXRFeature
|
||||
{
|
||||
public const string featureId = "com.pico.openxr.feature.spatialmesh";
|
||||
public const string extensionString = "XR_PICO_spatial_mesh XR_PICO_spatial_sensing XR_EXT_future";
|
||||
private static List<XRMeshSubsystemDescriptor> meshSubsystemDescriptors = new List<XRMeshSubsystemDescriptor>();
|
||||
|
||||
public PxrMeshLod LOD;
|
||||
|
||||
private XRMeshSubsystem subsystem;
|
||||
public static bool isEnable => OpenXRRuntime.IsExtensionEnabled("XR_PICO_spatial_mesh");
|
||||
protected override void OnSubsystemCreate()
|
||||
{
|
||||
base.OnSubsystemCreate();
|
||||
PXR_Plugin.Pxr_SetMeshLOD(Convert.ToUInt16(LOD));
|
||||
|
||||
}
|
||||
|
||||
protected override void OnSessionCreate(ulong xrSession)
|
||||
{
|
||||
base.OnSessionCreate(xrSession);
|
||||
CreateSubsystem<XRMeshSubsystemDescriptor, XRMeshSubsystem>(meshSubsystemDescriptors, "PICO Mesh");
|
||||
}
|
||||
|
||||
protected override void OnSubsystemStop()
|
||||
{
|
||||
base.OnSubsystemStop();
|
||||
StopSubsystem<XRMeshSubsystem>();
|
||||
|
||||
}
|
||||
|
||||
protected override void OnSubsystemDestroy()
|
||||
{
|
||||
base.OnSubsystemDestroy();
|
||||
PXR_Plugin.MixedReality.UPxr_DisposeMesh();
|
||||
DestroySubsystem<XRMeshSubsystem>();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b1248416ce414cd0a788c5240bec5766
|
||||
timeCreated: 1721806849
|
||||
Reference in New Issue
Block a user