using System;
namespace UnityEngine.XR.Hands
{
///
/// Represents the values being tracked for a particular joint.
///
[Flags]
public enum XRHandJointTrackingState
{
///
/// No data is currently being tracked for a joint.
///
None = 0,
///
/// Radius of current joint.
///
Radius = 1 << 0,
///
/// Pose of current joint.
///
Pose = 1 << 1,
///
/// Linear velocity of current joint.
///
LinearVelocity = 1 << 2,
///
/// Angular velocity of current joint.
///
AngularVelocity = 1 << 3,
///
/// Joint was marked as not being part of the hand layout for the current provider.
///
WillNeverBeValid = 1 << 4,
///
/// The joint is being actively tracked by the runtime, and the pose is not based on inference.
///
HighFidelityPose = 1 << 5,
}
///
/// Represents the type of a hand joint. If you wish to convert it to an
/// index, call .ToIndex() on the joint ID.
///
public enum XRHandJointID
{
///
/// Invalid ID.
///
Invalid,
///
/// Marks the beginning of joints, or start of an array of data related
/// to them. Casting this to an integer type will not result in a
/// correct start. Use instead.
///
BeginMarker,
///
/// Joint for the wrist.
///
Wrist = BeginMarker,
///
/// Represents the palm of the hand.
///
Palm,
///
/// Metacarpal joint of the thumb.
///
ThumbMetacarpal,
///
/// Proximal joint of the thumb.
///
ThumbProximal,
///
/// Distal joint of the thumb.
///
ThumbDistal,
///
/// Tip of the thumb.
///
ThumbTip,
///
/// Metacarpal joint of the index finger.
///
IndexMetacarpal,
///
/// Proximal joint of the index finger.
///
IndexProximal,
///
/// Intermediate joint of the index finger.
///
IndexIntermediate,
///
/// Distal joint of the index finger.
///
IndexDistal,
///
/// Tip of the index finger.
///
IndexTip,
///
/// Metacarpal joint of the middle finger.
///
MiddleMetacarpal,
///
/// Proximal joint of the middle finger.
///
MiddleProximal,
///
/// Intermediate joint of the middle finger.
///
MiddleIntermediate,
///
/// Distal joint of the middle finger.
///
MiddleDistal,
///
/// Tip of the middle finger.
///
MiddleTip,
///
/// Metacarpal joint of the ring finger.
///
RingMetacarpal,
///
/// Proximal joint of the ring finger.
///
RingProximal,
///
/// Intermediate joint of the ring finger.
///
RingIntermediate,
///
/// Distal joint of the ring finger.
///
RingDistal,
///
/// Tip of the ring finger.
///
RingTip,
///
/// Metacarpal joint of the little finger.
///
LittleMetacarpal,
///
/// Proximal joint of the little finger.
///
LittleProximal,
///
/// Intermediate joint of the little finger.
///
LittleIntermediate,
///
/// Distal joint of the little finger.
///
LittleDistal,
///
/// Tip of the little finger.
///
LittleTip,
///
/// Marks the end of joints, or size of an array of data related to
/// them. Casting this to an integer type will not result in a correct
/// count. Use instead.
///
EndMarker
}
///
/// Represents which hand is being referred to.
///
public enum Handedness
{
///
/// Invalid hand. Will never be usable. Use
/// or to obtain a valid hand.
///
Invalid,
///
/// Left hand.
///
Left,
///
/// Right hand.
///
Right
}
///
/// Represents a finger on either hand. Useful with the
/// and
/// APIs.
///
public enum XRHandFingerID
{
///
/// Represents the thumb.
///
Thumb,
///
/// Represents the index finger.
///
Index,
///
/// Represents the middle finger.
///
Middle,
///
/// Represents the ring finger.
///
Ring,
///
/// Represents the little finger.
///
Little
}
///
/// Houses extension and utility methods for .
///
public static class XRHandJointIDUtility
{
///
/// Call .ToIndex() on a to get its
/// corresponding index into an array of joint data.
///
/// ID of the joint to convert to an index.
///
/// The index matching the ID passed in.
///
public static int ToIndex(this XRHandJointID jointId) => (int)jointId - 1;
///
/// Call this to get the corresponding from
/// an index into an array of associated data.
///
/// Index to convert to an ID.
///
/// The ID matching the index passed in.
///
public static XRHandJointID FromIndex(int index) => (XRHandJointID)(index + 1);
///
/// Gets the metacarpal of a given .
///
/// ID of the finger of which you want the first .
///
/// First for the given finger in an
/// object's list of joints.
///
///
///
/// You can use GetFrontJointID and to iterate
/// through the joints of a specific finger:
///
///
///
///
///
public static XRHandJointID GetFrontJointID(this XRHandFingerID fingerId)
{
switch (fingerId)
{
case XRHandFingerID.Thumb:
return XRHandJointID.ThumbMetacarpal;
case XRHandFingerID.Index:
return XRHandJointID.IndexMetacarpal;
case XRHandFingerID.Middle:
return XRHandJointID.MiddleMetacarpal;
case XRHandFingerID.Ring:
return XRHandJointID.RingMetacarpal;
case XRHandFingerID.Little:
return XRHandJointID.LittleMetacarpal;
}
throw new ArgumentException(nameof(fingerId) + " must be a valid value!");
}
///
/// Gets the tip of a given .
///
/// ID of the finger you want the last of.
/// Last for the given finger in an
/// object's list of joints.
/// Use with to iterate through the joints
/// of a finger.
public static XRHandJointID GetBackJointID(this XRHandFingerID fingerId)
{
switch (fingerId)
{
case XRHandFingerID.Thumb:
return XRHandJointID.ThumbTip;
case XRHandFingerID.Index:
return XRHandJointID.IndexTip;
case XRHandFingerID.Middle:
return XRHandJointID.MiddleTip;
case XRHandFingerID.Ring:
return XRHandJointID.RingTip;
case XRHandFingerID.Little:
return XRHandJointID.LittleTip;
}
throw new ArgumentException(nameof(fingerId) + " must be a valid value!");
}
}
}