Skip to content

Commit 7f2a459

Browse files
Sean Lu(呂祥榮)Sean Lu(呂祥榮)
authored andcommitted
version 2.3.0
1 parent 45b4e46 commit 7f2a459

File tree

289 files changed

+116109
-5168
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

289 files changed

+116109
-5168
lines changed

com.htc.upm.vive.openxr/Editor/CompositionLayer/Scripts/CompositionLayerEditor.cs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,11 @@ public class CompositionLayerEditor : Editor
7575
static GUIContent Label_ApplyColorScaleBias = new GUIContent("Apply Color Scale Bias", "Color scale and bias are applied to a layer color during composition, after its conversion to premultiplied alpha representation. LayerColor = LayerColor * colorScale + colorBias");
7676
SerializedProperty Property_ApplyColorScaleBias;
7777

78+
static string PropertyName_SolidEffect = "solidEffect";
79+
static GUIContent Label_SolidEffect = new GUIContent("Solid Effect", "Apply UnderLay Color Scale Bias in Runtime Level.");
80+
SerializedProperty Property_SolidEffect;
81+
82+
7883
static string PropertyName_ColorScale = "colorScale";
7984
static GUIContent Label_ColorScale = new GUIContent("Color Scale", "Will be used for modulatting the color sourced from the images.");
8085
SerializedProperty Property_ColorScale;
@@ -114,6 +119,7 @@ public override void OnInspectorGUI()
114119
if (Property_AngleOfArc == null) Property_AngleOfArc = serializedObject.FindProperty(PropertyName_AngleOfArc);
115120
if (Property_IsDynamicLayer == null) Property_IsDynamicLayer = serializedObject.FindProperty(PropertyName_IsDynamicLayer);
116121
if (Property_ApplyColorScaleBias == null) Property_ApplyColorScaleBias = serializedObject.FindProperty(PropertyName_ApplyColorScaleBias);
122+
if (Property_SolidEffect == null) Property_SolidEffect = serializedObject.FindProperty(PropertyName_SolidEffect);
117123
if (Property_ColorScale == null) Property_ColorScale = serializedObject.FindProperty(PropertyName_ColorScale);
118124
if (Property_ColorBias == null) Property_ColorBias = serializedObject.FindProperty(PropertyName_ColorBias);
119125
if (Property_IsProtectedSurface == null) Property_IsProtectedSurface = serializedObject.FindProperty(PropertyName_IsProtectedSurface);
@@ -441,6 +447,11 @@ public override void OnInspectorGUI()
441447
}
442448

443449
EditorGUI.indentLevel++;
450+
if (targetCompositionLayer.layerType == CompositionLayer.LayerType.Underlay)
451+
{
452+
EditorGUILayout.PropertyField(Property_SolidEffect, Label_SolidEffect);
453+
serializedObject.ApplyModifiedProperties();
454+
}
444455
showColorScaleBiasParams = EditorGUILayout.Foldout(showColorScaleBiasParams, "Color Scale Bias Parameters");
445456
if (showColorScaleBiasParams)
446457
{

com.htc.upm.vive.openxr/Editor/VIVEFocus3FeatureSet.cs

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,24 +7,26 @@
77
namespace VIVE.OpenXR
88
{
99
[OpenXRFeatureSet(
10-
FeatureIds = new string[] {
10+
FeatureIds = new string[] {
1111
VIVEFocus3Feature.featureId,
1212
VIVEFocus3Profile.featureId,
1313
Hand.ViveHandTracking.featureId,
14-
"vive.vive.openxr.feature.compositionlayer",
15-
"vive.vive.openxr.feature.compositionlayer.cylinder",
16-
"vive.vive.openxr.feature.compositionlayer.colorscalebias",
14+
"vive.openxr.feature.compositionlayer",
15+
"vive.openxr.feature.compositionlayer.cylinder",
16+
"vive.openxr.feature.compositionlayer.colorscalebias",
1717
Tracker.ViveWristTracker.featureId,
1818
Hand.ViveHandInteraction.featureId,
19-
"vive.vive.openxr.feature.foveation",
19+
"vive.openxr.feature.foveation",
2020
FacialTracking.ViveFacialTracking.featureId,
21-
},
22-
UiName = "VIVE XR Support",
23-
Description = "Necessary to deploy an VIVE XR compatible app.",
24-
FeatureSetId = "com.htc.vive.openxr.featureset.vivexr",
25-
DefaultFeatureIds = new string[] { VIVEFocus3Feature.featureId, VIVEFocus3Profile.featureId, },
26-
SupportedBuildTargets = new BuildTargetGroup[] { BuildTargetGroup.Android }
27-
)]
21+
PlaneDetection.VivePlaneDetection.featureId,
22+
Anchor.ViveAnchor.featureId,
23+
},
24+
UiName = "VIVE XR Support",
25+
Description = "Necessary to deploy an VIVE XR compatible app.",
26+
FeatureSetId = "com.htc.vive.openxr.featureset.vivexr",
27+
DefaultFeatureIds = new string[] { VIVEFocus3Feature.featureId, VIVEFocus3Profile.featureId, },
28+
SupportedBuildTargets = new BuildTargetGroup[] { BuildTargetGroup.Android }
29+
)]
2830
sealed class VIVEFocus3FeatureSet { }
2931
}
3032
#endif
Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 140 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,140 @@
1+
// Copyright HTC Corporation All Rights Reserved.
2+
3+
using System;
4+
using System.Runtime.InteropServices;
5+
using UnityEngine;
6+
7+
namespace VIVE.OpenXR.Feature
8+
{
9+
/// <summary>
10+
/// To use this wrapper, you need to call CommonWrapper.Instance.OnInstanceCreate() in your feature's OnInstanceCreate(),
11+
/// and call CommonWrapper.Instance.OnInstanceDestroy() in your feature's OnInstanceDestroy().
12+
/// </summary>
13+
public class CommonWrapper
14+
{
15+
static CommonWrapper instance = null;
16+
public static CommonWrapper Instance
17+
{
18+
get
19+
{
20+
if (instance == null)
21+
instance = new CommonWrapper();
22+
return instance;
23+
}
24+
}
25+
26+
bool isInited = false;
27+
28+
OpenXRHelper.xrGetInstanceProcAddrDelegate XrGetInstanceProcAddr;
29+
OpenXRHelper.xrGetSystemPropertiesDelegate XrGetSystemProperties;
30+
31+
/// <summary>
32+
/// In feature's OnInstanceCreate(), call CommonWrapper.Instance.OnInstanceCreate() for init common APIs.
33+
/// </summary>
34+
/// <param name="xrInstance">Passed in feature's OnInstanceCreate.</param>
35+
/// <param name="xrGetInstanceProcAddr">Pass OpenXRFeature.xrGetInstanceProcAddr in.</param>
36+
/// <returns></returns>
37+
/// <exception cref="Exception">If input data not valid.</exception>
38+
public bool OnInstanceCreate(XrInstance xrInstance, IntPtr xrGetInstanceProcAddr)
39+
{
40+
if (isInited) return true;
41+
42+
if (xrInstance == 0)
43+
throw new Exception("CommonWrapper: xrInstance is null");
44+
45+
Debug.Log("CommonWrapper: OnInstanceCreate()");
46+
/// OpenXRFeature.xrGetInstanceProcAddr
47+
if (xrGetInstanceProcAddr == null || xrGetInstanceProcAddr == IntPtr.Zero)
48+
throw new Exception("CommonWrapper: xrGetInstanceProcAddr is null");
49+
50+
Debug.Log("CommonWrapper: Get function pointer of xrGetInstanceProcAddr.");
51+
XrGetInstanceProcAddr = Marshal.GetDelegateForFunctionPointer(
52+
xrGetInstanceProcAddr,
53+
typeof(OpenXRHelper.xrGetInstanceProcAddrDelegate)) as OpenXRHelper.xrGetInstanceProcAddrDelegate;
54+
55+
bool ret = true;
56+
IntPtr funcPtr = IntPtr.Zero;
57+
58+
ret &= OpenXRHelper.GetXrFunctionDelegate(XrGetInstanceProcAddr, xrInstance, "xrGetSystemProperties", out XrGetSystemProperties);
59+
60+
if (!ret)
61+
throw new Exception("CommonWrapper: Get function pointers failed.");
62+
63+
isInited = ret;
64+
return ret;
65+
}
66+
67+
/// <summary>
68+
/// In feature's OnInstanceDestroy(), call CommonWrapper.Instance.OnInstanceDestroy() for disable common APIs.
69+
/// </summary>
70+
/// <returns></returns>
71+
public void OnInstanceDestroy()
72+
{
73+
isInited = false;
74+
XrGetInstanceProcAddr = null;
75+
XrGetSystemProperties = null;
76+
Debug.Log("CommonWrapper: OnInstanceDestroy()");
77+
}
78+
79+
public XrResult GetInstanceProcAddr(XrInstance instance, string name, out IntPtr function)
80+
{
81+
if (isInited == false || XrGetInstanceProcAddr == null)
82+
{
83+
function = IntPtr.Zero;
84+
return XrResult.XR_ERROR_HANDLE_INVALID;
85+
}
86+
87+
return XrGetInstanceProcAddr(instance, name, out function);
88+
}
89+
90+
/// <summary>
91+
/// Helper function to get system properties. Need input your features' xrInstance and xrSystemId. Fill the system properites in next for you feature.
92+
/// See <see href="https://registry.khronos.org/OpenXR/specs/1.0/html/xrspec.html#xrGetSystemProperties">xrGetSystemProperties</see>
93+
/// </summary>
94+
/// <param name="instance"></param>
95+
/// <param name="systemId"></param>
96+
/// <param name="properties"></param>
97+
/// <returns></returns>
98+
public XrResult GetSystemProperties(XrInstance instance, XrSystemId systemId, ref XrSystemProperties properties)
99+
{
100+
if (isInited == false || XrGetSystemProperties == null)
101+
{
102+
return XrResult.XR_ERROR_HANDLE_INVALID;
103+
}
104+
105+
return XrGetSystemProperties(instance, systemId, ref properties);
106+
}
107+
108+
109+
public XrResult GetProperties<T>(XrInstance instance, XrSystemId systemId, ref T featureProperty)
110+
{
111+
XrSystemProperties systemProperties = new XrSystemProperties();
112+
systemProperties.type = XrStructureType.XR_TYPE_SYSTEM_PROPERTIES;
113+
systemProperties.next = Marshal.AllocHGlobal(Marshal.SizeOf(featureProperty));
114+
115+
long offset = 0;
116+
if (IntPtr.Size == 4)
117+
offset = systemProperties.next.ToInt32();
118+
else
119+
offset = systemProperties.next.ToInt64();
120+
121+
IntPtr pdPropertiesPtr = new IntPtr(offset);
122+
Marshal.StructureToPtr(featureProperty, pdPropertiesPtr, false);
123+
124+
var ret = GetSystemProperties(instance, systemId, ref systemProperties);
125+
if (ret == XrResult.XR_SUCCESS)
126+
{
127+
if (IntPtr.Size == 4)
128+
offset = systemProperties.next.ToInt32();
129+
else
130+
offset = systemProperties.next.ToInt64();
131+
132+
pdPropertiesPtr = new IntPtr(offset);
133+
featureProperty = Marshal.PtrToStructure<T>(pdPropertiesPtr);
134+
}
135+
136+
Marshal.FreeHGlobal(systemProperties.next);
137+
return ret;
138+
}
139+
}
140+
}
Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)