Class Leap::FingerModel

class Leap.FingerModel : public MonoBehaviour

The base class for all fingers.

This class serves as the interface between the HandController object, the parent Hand object and the concrete finger objects.

Subclasses of FingerModel must implement InitFinger() and UpdateFinger(). The InitHand() function is typically called by the parent HandModel InitHand() method; likewise, the UpdateFinger() function is typically called by the parent HandModel UpdateHand() function.

Public Functions

void SetLeapHand (Hand hand)

Sets the Leap Hand and Leap Finger for this finger. Note that Leap Hand and Finger objects are recreated every frame. The parent HandModel object calls this function to set or update the underlying finger. The tracking data in the Leap objects are used to update the FingerModel.

Hand GetLeapHand ()

The Leap Hand object.

Finger GetLeapFinger ()

The Leap Finger object.

virtual void InitFinger ()

Implement this function to initialize this finger after it is created. Typically, this function is called by the parent HandModel object.

virtual abstract void UpdateFinger ()

Implement this function to update this finger once per game loop. Typically, this function is called by the parent HandModel object’s UpdateHand() function, which is called in the Unity Update() phase for graphics hand models and in the FixedUpdate() phase for physics hand models.

Vector3 GetTipPosition ()

Returns the location of the tip of the finger

Vector3 GetJointPosition (int joint)

Returns the location of the given joint on the finger

Ray GetRay ()

Returns a ray from the tip of the finger in the direction it is pointing.

Vector3 GetBoneCenter (int bone_type)

Returns the center of the given bone on the finger

Vector3 GetBoneDirection (int bone_type)

Returns the direction the given bone is facing on the finger

Quaternion GetBoneRotation (int bone_type)

Returns the rotation quaternion of the given bone

float GetBoneLength (int bone_type)

Returns the length of the finger bone.

float GetBoneWidth (int bone_type)

Returns the width of the finger bone.

float GetFingerJointStretchMecanim (int joint_type)

Returns Mecanim stretch angle in the range (-180, +180] NOTE: Positive stretch opens the hand. For the thumb this moves it away from the palm.

float GetFingerJointSpreadMecanim ()

Returns Mecanim spread angle, which only applies to joint_type = 0 NOTE: Positive spread is towards thumb for index and middle, but is in the opposite direction for the ring and pinky. For the thumb negative spread rotates the thumb in to the palm.

Public Members

Transform[] bones = new Transform[NUM_BONES]

Bones positioned and rotated by FingerModel.

Transform[] joints = new Transform[NUM_BONES - 1]

Joints positioned and rotated by FingerModel.

Public Static Attributes

static constint NUM_BONES = 4

The number of bones in a finger.

static constint NUM_JOINTS = 3

The number of joints in a finger.