// Copyright HTC Corporation All Rights Reserved.
using System;
using System.Runtime.InteropServices;
namespace VIVE.OpenXR.FacialTracking
{
///
/// The XrFacialTrackerHTC handle represents the resources for an facial tracker of the specific facial tracking type.
///
public struct XrFacialTrackerHTC : IEquatable
{
private readonly UInt64 value;
public XrFacialTrackerHTC(UInt64 u)
{
value = u;
}
public static implicit operator UInt64(XrFacialTrackerHTC equatable)
{
return equatable.value;
}
public static implicit operator XrFacialTrackerHTC(UInt64 u)
{
return new XrFacialTrackerHTC(u);
}
public bool Equals(XrFacialTrackerHTC other)
{
return value == other.value;
}
public bool Equals(UInt64 other)
{
return value == other;
}
public override bool Equals(object obj)
{
return obj is XrFacialTrackerHTC && Equals((XrFacialTrackerHTC)obj);
}
public override int GetHashCode()
{
return value.GetHashCode();
}
public override string ToString()
{
return value.ToString();
}
public static bool operator ==(XrFacialTrackerHTC a, XrFacialTrackerHTC b) { return a.Equals(b); }
public static bool operator !=(XrFacialTrackerHTC a, XrFacialTrackerHTC b) { return !a.Equals(b); }
public static bool operator >=(XrFacialTrackerHTC a, XrFacialTrackerHTC b) { return a.value >= b.value; }
public static bool operator <=(XrFacialTrackerHTC a, XrFacialTrackerHTC b) { return a.value <= b.value; }
public static bool operator >(XrFacialTrackerHTC a, XrFacialTrackerHTC b) { return a.value > b.value; }
public static bool operator <(XrFacialTrackerHTC a, XrFacialTrackerHTC b) { return a.value < b.value; }
public static XrFacialTrackerHTC operator +(XrFacialTrackerHTC a, XrFacialTrackerHTC b) { return a.value + b.value; }
public static XrFacialTrackerHTC operator -(XrFacialTrackerHTC a, XrFacialTrackerHTC b) { return a.value - b.value; }
public static XrFacialTrackerHTC operator *(XrFacialTrackerHTC a, XrFacialTrackerHTC b) { return a.value * b.value; }
public static XrFacialTrackerHTC operator /(XrFacialTrackerHTC a, XrFacialTrackerHTC b)
{
if (b.value == 0)
{
throw new DivideByZeroException();
}
return a.value / b.value;
}
}
///
/// The XrFacialTrackingTypeHTC describes which type of tracking the XrFacialTrackerHTC is using.
///
public enum XrFacialTrackingTypeHTC
{
///
/// Specifies this handle will observe eye expressions, with values indexed by XrEyeExpressionHTC whose count is XR_FACIAL_EXPRESSION_EYE_COUNT_HTC.
///
XR_FACIAL_TRACKING_TYPE_EYE_DEFAULT_HTC = 1,
///
/// Specifies this handle will observe lip expressions, with values indexed by XrLipExpressionHTC whose count is XR_FACIAL_EXPRESSION_LIP_COUNT_HTC.
///
XR_FACIAL_TRACKING_TYPE_LIP_DEFAULT_HTC = 2,
};
///
/// Indicates the eye expressions. Refer to XrEyeExpressionHTC about the illustrations.
///
public enum XrEyeExpressionHTC
{
///
/// This blend shape influences blinking of the right eye. When this value goes higher, left eye approaches close.
///
XR_EYE_EXPRESSION_LEFT_BLINK_HTC = 0,
///
/// This blend shape keeps left eye wide and at that time XR_EYE_EXPRESSION_LEFT_BLINK_HTC value is 0.
///
XR_EYE_EXPRESSION_LEFT_WIDE_HTC = 1,
///
/// This blend shape influences blinking of the right eye. When this value goes higher, right eye approaches close.
///
XR_EYE_EXPRESSION_RIGHT_BLINK_HTC = 2,
///
/// This blend shape keeps right eye wide and at that time XR_EYE_EXPRESSION_RIGHT_BLINK_HTC value is 0.
///
XR_EYE_EXPRESSION_RIGHT_WIDE_HTC = 3,
///
/// The blend shape closes eye tightly and at that time XR_EYE_EXPRESSION_LEFT_BLINK_HTC value is 1.
///
XR_EYE_EXPRESSION_LEFT_SQUEEZE_HTC = 4,
///
/// The blend shape closes eye tightly and at that time XR_EYE_EXPRESSION_RIGHT_BLINK_HTC value is 1.
///
XR_EYE_EXPRESSION_RIGHT_SQUEEZE_HTC = 5,
///
/// This blendShape influences the muscles around the left eye, moving these muscles further downward with a higher value.
///
XR_EYE_EXPRESSION_LEFT_DOWN_HTC = 6,
///
/// This blendShape influences the muscles around the right eye, moving these muscles further downward with a higher value.
///
XR_EYE_EXPRESSION_RIGHT_DOWN_HTC = 7,
///
/// This blendShape influences the muscles around the left eye, moving these muscles further leftward with a higher value.
///
XR_EYE_EXPRESSION_LEFT_OUT_HTC = 8,
///
/// This blendShape influences the muscles around the right eye, moving these muscles further leftward with a higher value.
///
XR_EYE_EXPRESSION_RIGHT_IN_HTC = 9,
///
/// This blendShape influences the muscles around the left eye, moving these muscles further rightward with a higher value.
///
XR_EYE_EXPRESSION_LEFT_IN_HTC = 10,
///
/// This blendShape influences the muscles around the right eye, moving these muscles further rightward with a higher value.
///
XR_EYE_EXPRESSION_RIGHT_OUT_HTC = 11,
///
/// This blendShape influences the muscles around the left eye, moving these muscles further upward with a higher value.
///
XR_EYE_EXPRESSION_LEFT_UP_HTC = 12,
///
/// This blendShape influences the muscles around the right eye, moving these muscles further upward with a higher value.
///
XR_EYE_EXPRESSION_RIGHT_UP_HTC = 13,
XR_EYE_EXPRESSION_MAX_ENUM_HTC = 14
};
///
/// Indicates the lip expressions. Refer to XrLipExpressionHTC about the illustrations.
///
public enum XrLipExpressionHTC
{
///
/// This blend shape moves the jaw further rightward with a higher value.
///
XR_LIP_EXPRESSION_JAW_RIGHT_HTC = 0,
///
/// This blend shape moves the jaw further leftward with a higher value.
///
XR_LIP_EXPRESSION_JAW_LEFT_HTC = 1,
///
/// This blend shape moves the jaw forward with a higher value.
///
XR_LIP_EXPRESSION_JAW_FORWARD_HTC = 2,
///
/// This blend shape opens the mouth further with a higher value.
///
XR_LIP_EXPRESSION_JAW_OPEN_HTC = 3,
///
/// This blend shape stretches the jaw further with a higher value.
///
XR_LIP_EXPRESSION_MOUTH_APE_SHAPE_HTC = 4,
///
/// This blend shape moves your upper lip rightward.
///
XR_LIP_EXPRESSION_MOUTH_UPPER_RIGHT_HTC = 5,
///
/// This blend shape moves your upper lip leftward.
///
XR_LIP_EXPRESSION_MOUTH_UPPER_LEFT_HTC = 6,
///
/// This blend shape moves your lower lip rightward.
///
XR_LIP_EXPRESSION_MOUTH_LOWER_RIGHT_HTC = 7,
///
/// This blend shape moves your lower lip leftward.
///
XR_LIP_EXPRESSION_MOUTH_LOWER_LEFT_HTC = 8,
///
/// This blend shape pouts your upper lip. Can be used with XR_LIP_EXPRESSION_MOUTH_UPPER_UPRIGHT_HTC and XR_LIP_EXPRESSION_MOUTH_UPPER_UPLEFT_HTC to complete upper O mouth shape.
///
XR_LIP_EXPRESSION_MOUTH_UPPER_OVERTURN_HTC = 9,
///
/// This blend shape pouts your lower lip. Can be used with XR_LIP_EXPRESSION_MOUTH_UPPER_UPRIGHT_HTC and XR_LIP_EXPRESSION_MOUTH_LOWER_DOWNRIGHT_HTC to complete upper O mouth shape.
///
XR_LIP_EXPRESSION_MOUTH_LOWER_OVERTURN_HTC = 10,
///
/// This blend shape allows the lips to pout more with a higher value.
///
XR_LIP_EXPRESSION_MOUTH_POUT_HTC = 11,
///
/// This blend shape raises the right side of the mouth further with a higher value.
///
XR_LIP_EXPRESSION_MOUTH_RAISER_RIGHT_HTC = 12,
///
/// This blend shape raises the left side of the mouth further with a higher value.
///
XR_LIP_EXPRESSION_MOUTH_RAISER_LEFT_HTC = 13,
///
/// This blend shape lowers the right side of the mouth further with a higher value.
///
XR_LIP_EXPRESSION_MOUTH_STRETCHER_RIGHT_HTC = 14,
///
/// This blend shape lowers the left side of the mouth further with a higher value.
///
XR_LIP_EXPRESSION_MOUTH_STRETCHER_LEFT_HTC = 15,
///
/// This blend shape puffs up the right side of the cheek further with a higher value.
///
XR_LIP_EXPRESSION_CHEEK_PUFF_RIGHT_HTC = 16,
///
/// This blend shape puffs up the left side of the cheek further with a higher value.
///
XR_LIP_EXPRESSION_CHEEK_PUFF_LEFT_HTC = 17,
///
/// This blend shape sucks in the cheeks on both sides further with a higher value.
///
XR_LIP_EXPRESSION_CHEEK_SUCK_HTC = 18,
///
/// This blend shape raises the right upper lip further with a higher value.
///
XR_LIP_EXPRESSION_MOUTH_UPPER_UPRIGHT_HTC = 19,
///
/// This blend shape raises the left upper lip further with a higher value.
///
XR_LIP_EXPRESSION_MOUTH_UPPER_UPLEFT_HTC = 20,
///
/// This blend shape lowers the right lower lip further with a higher value.
///
XR_LIP_EXPRESSION_MOUTH_LOWER_DOWNRIGHT_HTC = 21,
///
/// This blend shape lowers the left lower lip further with a higher value.
///
XR_LIP_EXPRESSION_MOUTH_LOWER_DOWNLEFT_HTC = 22,
///
/// This blend shape rolls in the upper lip further with a higher value.
///
XR_LIP_EXPRESSION_MOUTH_UPPER_INSIDE_HTC = 23,
///
/// This blend shape rolls in the lower lip further with a higher value.
///
XR_LIP_EXPRESSION_MOUTH_LOWER_INSIDE_HTC = 24,
///
/// This blend shape stretches the lower lip further and lays it on the upper lip further with a higher value.
///
XR_LIP_EXPRESSION_MOUTH_LOWER_OVERLAY_HTC = 25,
///
/// This blend shape sticks the tongue out slightly.
///
/// In step 1 of extending the tongue, the main action of the tongue is to lift up, and the elongated length only extends to a little bit beyond the teeth.
///
XR_LIP_EXPRESSION_TONGUE_LONGSTEP1_HTC = 26,
///
/// This blend shape sticks the tongue out and left extremely.
///
XR_LIP_EXPRESSION_TONGUE_LEFT_HTC = 27,
///
/// This blend shape sticks the tongue out and right extremely.
///
XR_LIP_EXPRESSION_TONGUE_RIGHT_HTC = 28,
///
/// This blend shape sticks the tongue out and up extremely.
///
XR_LIP_EXPRESSION_TONGUE_UP_HTC = 29,
///
/// This blend shape sticks the tongue out and down extremely.
///
XR_LIP_EXPRESSION_TONGUE_DOWN_HTC = 30,
///
/// This blend shape sticks the tongue out with roll type.
///
XR_LIP_EXPRESSION_TONGUE_ROLL_HTC = 31,
///
/// This blend shape sticks the tongue out extremely.
///
/// Continuing the step 1, it extends the tongue to the longest.
///
XR_LIP_EXPRESSION_TONGUE_LONGSTEP2_HTC = 32,
///
/// This blend shape doesn’t make sense. When both the right and up blend shapes appear at the same time, the tongue will be deformed.
///
XR_LIP_EXPRESSION_TONGUE_UPRIGHT_MORPH_HTC = 33,
///
/// This blend shape doesn’t make sense. When both the left and up blend shapes appear at the same time, the tongue will be deformed.
///
XR_LIP_EXPRESSION_TONGUE_UPLEFT_MORPH_HTC = 34,
///
/// This blend shape doesn’t make sense. When both the right and down blend shapes appear at the same time, the tongue will be deformed.
///
XR_LIP_EXPRESSION_TONGUE_DOWNRIGHT_MORPH_HTC = 35,
///
/// This blend shape doesn’t make sense. When both the left and down blend shapes appear at the same time, the tongue will be deformed.
///
XR_LIP_EXPRESSION_TONGUE_DOWNLEFT_MORPH_HTC = 36,
XR_LIP_EXPRESSION_MAX_ENUM_HTC = 37
};
///
/// An application can inspect whether the system is capable of two of the facial tracking by extending the XrSystemProperties with XrSystemFacialTrackingPropertiesHTC structure when calling xrGetSystemProperties.
///
[StructLayout(LayoutKind.Sequential)]
public struct XrSystemFacialTrackingPropertiesHTC
{
///
/// The XrStructureType of this structure.
///
public XrStructureType type;
///
/// NULL or a pointer to the next structure in a structure chain. No such structures are defined in core OpenXR or this extension.
///
public IntPtr next;
///
/// Indicates if the current system is capable of generating eye expressions.
///
public XrBool32 supportEyeFacialTracking;
///
/// Indicates if the current system is capable of generating lip expressions.
///
public XrBool32 supportLipFacialTracking;
};
///
/// The XrFacialTrackerCreateInfoHTC structure describes the information to create an XrFacialTrackerHTC handle.
///
[StructLayout(LayoutKind.Sequential)]
public struct XrFacialTrackerCreateInfoHTC
{
///
/// The XrStructureType of this structure.
///
public XrStructureType type;
///
/// NULL or a pointer to the next structure in a structure chain. No such structures are defined in core OpenXR or this extension.
///
public IntPtr next;
///
/// An XrFacialTrackingTypeHTC which describes which type of facial tracking should be used for this handle.
///
public XrFacialTrackingTypeHTC facialTrackingType;
/// The XrStructureType of this structure.
/// NULL or a pointer to the next structure in a structure chain. No such structures are defined in core OpenXR or this extension.
/// An XrFacialTrackingTypeHTC which describes which type of facial tracking should be used for this handle.
public XrFacialTrackerCreateInfoHTC(XrStructureType in_type, IntPtr in_next, XrFacialTrackingTypeHTC in_facialTrackingType)
{
type = in_type;
next = in_next;
facialTrackingType = in_facialTrackingType;
}
};
///
/// XrFacialExpressionsHTC structure returns data of a lip facial expression or an eye facial expression.
///
[StructLayout(LayoutKind.Sequential)]
public struct XrFacialExpressionsHTC
{
/// The XrStructureType of this structure.
public XrStructureType type;
/// NULL or a pointer to the next structure in a structure chain. No such structures are defined in core OpenXR or this extension.
public IntPtr next;
/// An XrBool32 indicating if the facial tracker is active.
public XrBool32 isActive;
/// When in time the expression is expressed.
public XrTime sampleTime;
/// A uint32_t describing the count of elements in expressionWeightings array.
public UInt32 expressionCount;
/// A float array filled in by the runtime, specifying the weightings for each blend shape.
public IntPtr expressionWeightings;
/// The XrStructureType of this structure.
/// NULL or a pointer to the next structure in a structure chain. No such structures are defined in core OpenXR or this extension.
/// An XrBool32 indicating if the facial tracker is active.
/// When in time the expression is expressed.
/// >A uint32_t describing the count of elements in expressionWeightings array.
/// A float array filled in by the runtime, specifying the weightings for each blend shape.
public XrFacialExpressionsHTC(
XrStructureType in_type,
IntPtr in_next,
XrBool32 in_isActive,
XrTime in_sampleTime,
UInt32 in_expressionCount,
IntPtr in_expressionWeightings)
{
type = in_type;
next = in_next;
isActive = in_isActive;
sampleTime = in_sampleTime;
expressionCount = in_expressionCount;
expressionWeightings = in_expressionWeightings;
}
};
public static class ViveFacialTrackingHelper
{
/// The number of blend shapes in an expression of type XR_FACIAL_TRACKING_TYPE_EYE_DEFAULT_HTC.
public const UInt32 XR_FACIAL_EXPRESSION_EYE_COUNT_HTC = 14;
/// The number of blend shapes in an expression of type XR_FACIAL_TRACKING_TYPE_LIP_DEFAULT_HTC.
public const UInt32 XR_FACIAL_EXPRESSION_LIP_COUNT_HTC = 37;
///
/// The delegate function of xrCreateFacialTrackerHTC.
///
/// An XrSession in which the facial expression will be active.
/// The XrFacialTrackerCreateInfoHTC used to specify the facial tracking type.
/// The returned XrFacialTrackerHTC handle.
/// XR_SUCCESS for success.
public delegate XrResult xrCreateFacialTrackerHTCDelegate(
XrSession session,
XrFacialTrackerCreateInfoHTC createInfo,
out XrFacialTrackerHTC facialTracker);
///
/// The delegate function of xrDestroyFacialTrackerHTC.
///
/// An XrFacialTrackerHTC previously created by xrCreateFacialTrackerHTC.
/// XR_SUCCESS for success.
public delegate XrResult xrDestroyFacialTrackerHTCDelegate(
XrFacialTrackerHTC facialTracker);
///
/// The delegate function of xrGetFacialExpressionsHTC.
///
/// An XrFacialTrackerHTC previously created by xrCreateFacialTrackerHTC.
/// A pointer to XrFacialExpressionsHTC receiving the returned facial expressions.
/// XR_SUCCESS for success.
public delegate XrResult xrGetFacialExpressionsHTCDelegate(
XrFacialTrackerHTC facialTracker,
ref XrFacialExpressionsHTC facialExpressions);
}
}