FingerModelΒΆ

FingerModel is the base class for all the other finger scripts. If you are creating your own fingers and need a custom finger script, extend FingerModel and implement the Init() and Update() methods.

class FingerModel

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

Vector3 GetBoneCenter(int bone_type)

Returns the center of the given bone on the finger in relation to the controller.

Vector3 GetBoneDirection(int bone_type)

Returns the direction the given bone is facing on the finger in relation to the controller.

float GetBoneLength(int bone_type)

Returns the length of the finger bone.

Quaternion GetBoneRotation(int bone_type)

Returns the rotation quaternion of the given bone in relation to the controller.

float GetBoneWidth(int bone_type)

Returns the width of the finger bone.

HandController GetController()

The parent HandController instance.

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.

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.

Vector3 GetJointPosition(int joint)

Returns the location of the given joint on the finger in relation to the controller.

Finger GetLeapFinger()

The Leap Finger object.

Hand GetLeapHand()

The Leap Hand object.

Vector3 GetOffset()

Returns any additional movement the finger needs because of non-relative palm movement.

Ray GetRay()

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

Vector3 GetTipPosition()

Returns the location of the tip of the finger in relation to the controller.

void InitFinger()

Implement this function to initialize this finger after it is created.

Typically, this function is called by the parent HandModel object.

void MirrorZAxis(bool mirror = true)

Sets the mirror z-axis flag for this Finger Model.

Mirroring the z axis reverses the hand so that they face the opposite direction as if in a mirror.

Parameters
  • mirror -

    Set true, the default value to mirror; false for normal rendering.

void SetController(HandController controller)

Assigns the HandController parent for this FingerModel object.

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.

void SetOffset(Vector3 offset)

Sets an offset vector to displace the finger from its normally calculated position relative to the HandController.

Typically, this offset is used to give the virtual hands a larger range of motion then they would have based on their scaled size in the Unity scene.

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.

Public Members

Transform[] bones

Bones positioned and rotated by FingerModel.

Transform[] joints

Joints positioned and rotated by FingerModel.

const int NUM_BONES

The number of bones in a finger.

const int NUM_JOINTS

The number of joints in a finger.