docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Struct XRHandJoint

    Represents a joint of an XRHand.

    Implements
    IEquatable<XRHandJoint>
    Inherited Members
    object.Equals(object, object)
    object.GetType()
    object.ReferenceEquals(object, object)
    Namespace: UnityEngine.XR.Hands
    Assembly: Unity.XR.Hands.dll
    Syntax
    public struct XRHandJoint : IEquatable<XRHandJoint>
    Remarks

    The term "joint" should be taken loosely in this context. In addition to the anatomical finger joints, the list of joints includes the fingertips, a point on the palm and a point on the wrist. See XRHandJointID for the full list of joints.

    Refer to Hand data model for a description of the joint locations and the data they contain.

    Properties

    handedness

    Denotes which hand this joint is on.

    Declaration
    public Handedness handedness { get; }
    Property Value
    Type Description
    Handedness

    Right or left.

    id

    The ID of this joint.

    Declaration
    public XRHandJointID id { get; }
    Property Value
    Type Description
    XRHandJointID

    The joint ID.

    trackingState

    Represents which tracking data is valid.

    Declaration
    public XRHandJointTrackingState trackingState { get; }
    Property Value
    Type Description
    XRHandJointTrackingState

    A flag is set for each valid type of data. If the The WillNeverBeValid flag is set when this joint ID isn't supported by the hand data provider.

    Methods

    Equals(object)

    Tests for equality.

    Declaration
    public override bool Equals(object obj)
    Parameters
    Type Name Description
    object obj

    An object to compare against.

    Returns
    Type Description
    bool

    Returns true if obj is an XRHandJoint and it compares equal to this one using Equals(XRHandJoint).

    Overrides
    ValueType.Equals(object)

    Equals(XRHandJoint)

    Tests for equality.

    Declaration
    public bool Equals(XRHandJoint other)
    Parameters
    Type Name Description
    XRHandJoint other

    The XRHandJoint to compare against.

    Returns
    Type Description
    bool

    Returns true if the underlying native pointers are the same. Returns false otherwise.

    GetHashCode()

    Computes a hash code from all fields of XRHandJoint.

    Declaration
    public override int GetHashCode()
    Returns
    Type Description
    int

    Returns a hash code of this object.

    Overrides
    ValueType.GetHashCode()

    ToString()

    Returns a string representation of the XRHandJoint.

    Declaration
    public override string ToString()
    Returns
    Type Description
    string

    String representation of the value.

    Overrides
    ValueType.ToString()

    TryGetAngularVelocity(out Vector3)

    Retrieves the joint's angular velocity vector, if available

    Declaration
    public bool TryGetAngularVelocity(out Vector3 angularVelocity)
    Parameters
    Type Name Description
    Vector3 angularVelocity

    Assigned the tracked angular velocity of this joint, if successful. Set to zero, if unsuccessful.

    Returns
    Type Description
    bool

    Returns true if successful and the angular velocity filled out with valid tracking data, returns false otherwise.

    Remarks

    To transform to world space so that the vector has the correct direction relative to the user, rotate this by the rotation of the XROrigin.

    TryGetLinearVelocity(out Vector3)

    Retrieves the joint's linear velocity vector, if available.

    Declaration
    public bool TryGetLinearVelocity(out Vector3 linearVelocity)
    Parameters
    Type Name Description
    Vector3 linearVelocity

    Assigned the tracked linear velocity of this joint, if successful. Set to zero, if unsuccessful.

    Returns
    Type Description
    bool

    Returns true if successful and the velocity was filled out with valid tracking data, returns false otherwise.

    Remarks

    To transform to world space so that the vector has the correct direction relative to the user, rotate this by the rotation of the XROrigin.

    TryGetPose(out Pose)

    Retrieves the joint's pose, if available.

    Declaration
    public bool TryGetPose(out Pose pose)
    Parameters
    Type Name Description
    Pose pose

    Assigned the tracked pose of this joint, if successful. Set to identity, if unsuccessful.

    Returns
    Type Description
    bool

    Returns true if successful and the joint pose was filled out with valid tracking data, returns false otherwise.

    Remarks

    Joint poses are relative to the real-world point chosen by the user's device.

    To transform to world space so that the joint appears in the correct location relative to the user, transform the pose based on the XROrigin.

    Examples

    The following example illustrates how to transform a pose into world space using the transform from the XROrigin object in a scene.

    public Pose ToWorldPose(XRHandJoint joint, Transform origin)
    {
        Pose xrOriginPose = new Pose(origin.position, origin.rotation);
        if (joint.TryGetPose(out Pose jointPose))
        {
            return jointPose.GetTransformedBy(xrOriginPose);
        }
        else
        {
            return Pose.identity;
        }
    }

    TryGetRadius(out float)

    Retrieves the joint's radius, if available.

    Declaration
    public bool TryGetRadius(out float radius)
    Parameters
    Type Name Description
    float radius

    Assigned the tracked radius of this joint, if successful. Set to zero, if unsuccessful.

    Returns
    Type Description
    bool

    Returns true if successful and the radius was filled out with valid tracking data, returns false otherwise.

    Operators

    operator ==(XRHandJoint, XRHandJoint)

    Tests for equality. Same as Equals(XRHandJoint).

    Declaration
    public static bool operator ==(XRHandJoint lhs, XRHandJoint rhs)
    Parameters
    Type Name Description
    XRHandJoint lhs

    The left-hand side of the comparison.

    XRHandJoint rhs

    The right-hand side of the comparison.

    Returns
    Type Description
    bool

    Returns the same value as Equals(XRHandJoint).

    operator !=(XRHandJoint, XRHandJoint)

    Tests for inequality. Same as !Equals(XRHandJoint)

    Declaration
    public static bool operator !=(XRHandJoint lhs, XRHandJoint rhs)
    Parameters
    Type Name Description
    XRHandJoint lhs

    The left-hand side of the comparison.

    XRHandJoint rhs

    The right-hand side of the comparison.

    Returns
    Type Description
    bool

    Returns the negation of Equals(XRHandJoint).

    Implements

    IEquatable<T>

    Extension Methods

    XRHandProcessingUtility.SetAngularVelocity(ref XRHandJoint, Vector3)
    XRHandProcessingUtility.SetLinearVelocity(ref XRHandJoint, Vector3)
    XRHandProcessingUtility.SetPose(ref XRHandJoint, Pose)
    In This Article
    Back to top
    Copyright © 2024 Unity Technologies — Trademarks and terms of use
    • Legal
    • Privacy Policy
    • Cookie Policy
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)