Class ViveFacialTracking
Inherited Members
Namespace: VIVE.OpenXR.FacialTracking
Assembly: VIVE.OpenXR.dll
Syntax
public class ViveFacialTracking : OpenXRFeature
Fields
featureId
The feature id string. This is used to give the feature a well known id for reference.
Declaration
public const string featureId = "vive.openxr.feature.facial.tracking"
Field Value
Type | Description |
---|---|
string |
kOpenxrExtensionString
OpenXR specification 12.68. XR_HTC_facial_tracking.
Declaration
public const string kOpenxrExtensionString = "XR_HTC_facial_tracking"
Field Value
Type | Description |
---|---|
string |
Methods
CreateFacialTracker(XrFacialTrackerCreateInfoHTC, out XrFacialTrackerHTC)
An application can create an XrFacialTrackerHTC handle using CreateFacialTracker.
Declaration
public XrResult CreateFacialTracker(XrFacialTrackerCreateInfoHTC createInfo, out XrFacialTrackerHTC facialTracker)
Parameters
Type | Name | Description |
---|---|---|
XrFacialTrackerCreateInfoHTC | createInfo | |
XrFacialTrackerHTC | facialTracker | The returned XrFacialTrackerHTC handle. |
Returns
Type | Description |
---|---|
XrResult | XR_SUCCESS for success. |
CreateFacialTracker(XrFacialTrackingTypeHTC)
An application can create an XrFacialTrackerHTC handle using CreateFacialTracker.
Declaration
public bool CreateFacialTracker(XrFacialTrackingTypeHTC facialTrackingType)
Parameters
Type | Name | Description |
---|---|---|
XrFacialTrackingTypeHTC | facialTrackingType | The XrFacialTrackingTypeHTC describes which type of tracking the XrFacialTrackerHTC is using. |
Returns
Type | Description |
---|---|
bool | True for success. |
DestroyFacialTracker(XrFacialTrackerHTC)
Releases the facial tracker and the underlying resources of the facial tracking type when finished with facial tracking experiences.
Declaration
public XrResult DestroyFacialTracker(XrFacialTrackerHTC facialTracker)
Parameters
Type | Name | Description |
---|---|---|
XrFacialTrackerHTC | facialTracker | Facial tracker in XrFacialTrackerHTC. |
Returns
Type | Description |
---|---|
XrResult | XR_SUCCESS for success. |
DestroyFacialTracker(XrFacialTrackingTypeHTC)
Releases the facial tracker and the underlying resources of the facial tracking type when finished with facial tracking experiences.
Declaration
public bool DestroyFacialTracker(XrFacialTrackingTypeHTC facialTrackingType)
Parameters
Type | Name | Description |
---|---|---|
XrFacialTrackingTypeHTC | facialTrackingType | The XrFacialTrackingTypeHTC describes which type of tracking the XrFacialTrackerHTC is using. |
Returns
Type | Description |
---|---|
bool | True for success. |
GetFacialExpressions(XrFacialTrackerHTC, out XrFacialExpressionsHTC)
Retrieves the XrFacialExpressionsHTC data of a XrFacialTrackerHTC.
Declaration
public XrResult GetFacialExpressions(XrFacialTrackerHTC facialTracker, out XrFacialExpressionsHTC facialExpressions)
Parameters
Type | Name | Description |
---|---|---|
XrFacialTrackerHTC | facialTracker | The XrFacialTrackerHTC handle represents the resources for an facial tracker of the specific facial tracking type. |
XrFacialExpressionsHTC | facialExpressions | Structure returns data of a lip facial expression or an eye facial expression. |
Returns
Type | Description |
---|---|
XrResult | XR_SUCCESS for success. |
GetFacialExpressions(XrFacialTrackingTypeHTC, out float[])
Retrieves an array of values of blend shapes for a facial expression on a given time.
Declaration
public bool GetFacialExpressions(XrFacialTrackingTypeHTC facialTrackingType, out float[] expressionWeightings)
Parameters
Type | Name | Description |
---|---|---|
XrFacialTrackingTypeHTC | facialTrackingType | The XrFacialTrackingTypeHTC describes which type of tracking the XrFacialTrackerHTC is using. |
float[] | expressionWeightings | A float array filled in by the runtime, specifying the weightings for each blend shape. The array size is XR_EYE_EXPRESSION_MAX_ENUM_HTC for eye expression and XR_LIP_EXPRESSION_MAX_ENUM_HTC for lip expression. |
Returns
Type | Description |
---|---|
bool | True for success. |
Examples
using UnityEngine;
using UnityEngine.XR.OpenXR;
using VIVE.OpenXR.FacialTracking;
public class Example : MonoBehaviour
{
private static float[] eyeExps = new float[(int)XrEyeExpressionHTC.XR_EYE_EXPRESSION_MAX_ENUM_HTC];
private static float[] lipExps = new float[(int)XrLipExpressionHTC.XR_LIP_EXPRESSION_MAX_ENUM_HTC];
void Update()
{
var feature = OpenXRSettings.Instance.GetFeature();
if (feature != null)
{
// Eye expressions
{
if (feature.GetFacialExpressions(XrFacialTrackingTypeHTC.XR_FACIAL_TRACKING_TYPE_EYE_DEFAULT_HTC, out float[] exps))
{
eyeExps = exps;
}
}
// Lip expressions
{
if (feature.GetFacialExpressions(XrFacialTrackingTypeHTC.XR_FACIAL_TRACKING_TYPE_LIP_DEFAULT_HTC, out float[] exps))
{
lipExps = exps;
}
}
}
//How large is the user's mouth is opening. 0 = closed 1 = full opened
Debug.Log("Jaw Open: " + lipExps[(int)XrLipExpressionHTC.XR_LIP_EXPRESSION_JAW_OPEN_HTC]);
//Is the user's left eye opening? 0 = opened 1 = full closed
Debug.Log("Left Eye Blink: " + eyeExps[(int)XrEyeExpressionHTC.XR_EYE_EXPRESSION_LEFT_BLINK_HTC]);
}
}
OnInstanceCreate(ulong)
Called when xrCreateInstance is done.
Declaration
protected override bool OnInstanceCreate(ulong xrInstance)
Parameters
Type | Name | Description |
---|---|---|
ulong | xrInstance | The created instance. |
Returns
Type | Description |
---|---|
bool | True for valid XrInstance |
Overrides
OnInstanceDestroy(ulong)
Called when xrDestroyInstance is done.
Declaration
protected override void OnInstanceDestroy(ulong xrInstance)
Parameters
Type | Name | Description |
---|---|---|
ulong | xrInstance | The instance to destroy. |
Overrides
OnSessionCreate(ulong)
Called when xrCreateSession is done.
Declaration
protected override void OnSessionCreate(ulong xrSession)
Parameters
Type | Name | Description |
---|---|---|
ulong | xrSession | The created session ID. |
Overrides
OnSessionDestroy(ulong)
Called when xrDestroySession is done.
Declaration
protected override void OnSessionDestroy(ulong xrSession)
Parameters
Type | Name | Description |
---|---|---|
ulong | xrSession | The session ID to destroy. |
Overrides
OnSystemChange(ulong)
Called when the XrSystemId retrieved by xrGetSystem is changed.
Declaration
protected override void OnSystemChange(ulong xrSystem)
Parameters
Type | Name | Description |
---|---|---|
ulong | xrSystem | The system id. |