๐ฆพHand Pose Data
HandPoseData
The HandPoseData
struct encapsulates data related to the hand's pose, including both deprecated and newer data formats. It allows for saving, setting, and interpolating hand poses, taking into account both individual finger poses and the overall hand transformation.
The finger poses data array can always be indexed using Finger.FingerEnum. for example poseData.fingerPoses[(int)FingerEnum.Middle] will return the data for the middle finger pose
Public Variables
Hand Offset
: New hand offset vector.Local Quaternion Offset
: New local quaternion offset.Global Hand Scale
: New global hand scale.Finger Poses
: Array ofFingerPoseData
representing the poses of the fingers.Pose ID
: Identifier for the pose.Is Set
: Indicates if the pose data is set.
Deprecated Variables
Rotation Offset
: Deprecated rotation offset of the hand.Pose Positions
: Deprecated old method array ofVector3
representing positions of the hand's joints.Pose Rotations
: Deprecated old method array ofQuaternion
representing rotations of the hand's joints.Is Data Deprecated
: Indicates if the pose data is deprecated.
Public Methods
Constructors
HandPoseData(Hand hand, Grabbable grabbable): Creates a new pose using the current hand relative to a given grabbable.
HandPoseData(Hand hand, Transform point): Creates a new pose using the current hand relative to a given transform.
HandPoseData(Hand hand): Creates a new pose using the current hand shape.
HandPoseData(ref HandPoseData data): Creates a new pose by copying data from another
HandPoseData
.
Methods
CopyFromData(ref HandPoseData data): Copies data from another
HandPoseData
.SavePose(Hand hand, Transform relativeTo = null): Saves the pose data to match the current shape of the given hand, relative to the specified transform.
SetPose(Hand hand, Transform relativeTo = null): Sets the hand pose to match the given hand data, relative to the specified transform.
SetFingerPose(Hand hand): Sets the finger pose without changing the hand's position.
SetPosition(Hand hand, Transform relativeTo = null): Sets the position without setting the finger pose.
GetHandToWorldMatrix(Transform relativeTo): Gets the hand-to-world matrix relative to the specified transform.
LerpPose(ref HandPoseData from, ref HandPoseData to, float point): Interpolates this pose data between two given pose data by the specified point.
static void LerpPose(ref HandPoseData lerpPose, ref HandPoseData from, ref HandPoseData to, float point): Static method to interpolate pose data between two given pose data.
GetPoseDifference(ref HandPoseData otherPose, out float[] fingerDistances): Gets the pose difference between this pose and another pose for each finger.
GetPoseDifference(ref HandPoseData otherPose, out float indexDifference, out float middleDifference, out float ringDifference, out float pinkyDifference, out float thumbDifference): Gets the pose difference between this pose and another pose for each finger individually.
UpdateDepricatedData(Hand hand, Transform relativeTo): Updates deprecated data for the pose.
SetPositionData(Transform handPoint, Transform relativeTo): Sets the position data for the hand point relative to the specified transform.
Example Usage
Hand Pose Data allocates a decent amount of memory with every "new" pose. Recommend allocating pose data once per script and using copy, set, lerp functions as shown below for most optimized use of pose data. If you are unfamiliar with concepts like references and memory allocation it's recommened you not work this HandPoseData directly and use GrabPose or HandPoseArea instead
FingerPoseData
The FingerPoseData
struct is used to manage and manipulate the pose data of a finger in a 3D space. It contains matrices and quaternions representing the finger's joints, allowing for efficient pose interpolation and transformation operations.
Public Variables
Pose Relative Matrix
: An array ofMatrix4x4
representing the relative pose matrices of the finger joints.Local Rotations
: An array ofQuaternion
representing the local rotations of the finger joints.Is Local Set
: Indicates if the local rotations are set.Is Set
: Indicates if the pose relative matrices are set.
Public Methods
Constructors
FingerPoseData(Hand hand, Finger finger): Initializes the
FingerPoseData
using the givenHand
andFinger
objects.FingerPoseData(Transform hand, Transform knuckleJoint, Transform middleJoint, Transform distalJoint, Transform tip): Initializes the
FingerPoseData
using the given transforms for the hand and finger joints.FingerPoseData(ref FingerPoseData data): Initializes the
FingerPoseData
by copying the data from anotherFingerPoseData
(allocates less memory)FingerPoseData(FingerPoseData data): Initializes the
FingerPoseData
by copying the data from anotherFingerPoseData
object.
Methods
SetPoseData(ref FingerPoseData data, FingerJointEnum[] fingerJoints): Sets the pose data from another
FingerPoseData
for specific finger joints.SetPoseData(Hand hand, Finger finger): Sets the pose data using the given
Hand
andFinger
objects.SetPoseData(Transform hand, Transform knuckleJoint, Transform middleJoint, Transform distalJoint, Transform tip): Sets the pose data using the given transforms for the hand and finger joints.
CopyFromData(ref FingerPoseData fingerPoseData): Copies the data from another
FingerPoseData
.CopyFromData(FingerPoseData fingerPoseData): Copies the data from another
FingerPoseData
.LerpDataTo(ref FingerPoseData otherPose, float point, bool updateMatrixData = false): Interpolates this pose data to the given pose data by the specified point.
LerpData(ref FingerPoseData fromPose, ref FingerPoseData toPose, float point, bool updateMatrixData = false): Interpolates this pose data between two given pose data by the specified point.
SetFingerPose(Finger finger): Sets the finger to match this pose data.
SetFingerPose(Finger finger, Quaternion handRotation, Transform knuckleJoint, Transform middleJoint, Transform distalJoint): Sets the finger to match this pose data, optimized for blending through two poses.
GetPoseDifferenceByAngle(ref FingerPoseData otherPose): Returns the rotation difference between this pose and another pose by angle.
CalculateAdditionalValues(Vector3 handLossyScale): Calculates additional values required for the pose data using the given hand scale.
Example Usage
Last updated