HandModelΒΆ

Handmodel is the base class for all the other hand scripts. If you are creating your own hands and need a custom hand script to go with them, extend HandModel and implement the Init() and Update() methods. You may need to extend the FingerModel class, too.

class Leap::Unity::HandModel

The base class for all hand models, both graphics and physics.

This class serves as the interface between the HandController object and the concrete hand object containing the graphics and physics of a hand.

Subclasses of HandModel must implement InitHand() and UpdateHand(). The UpdateHand() function is called in the Unity Update() phase for graphics HandModel instances; and in the Unity FixedUpdate() phase for physics objects. InitHand() is called once, when the hand is created and is followed by a call to UpdateHand().

Public Functions

Vector3 GetArmCenter()

Calculates the center of the forearm in global coordinates.

Return
A Vector3 containing the Unity coordinates of the center of the forearm.

Vector3 GetArmDirection()

Calculates the direction vector of the forearm in global coordinates.

Return
A Vector3 representing the direction of the forearm (pointing from elbow to wrist).

float GetArmLength()

Returns the measured length of the forearm in meters.

Quaternion GetArmRotation()

Calculates the rotation of the forearm in global coordinates.

Return
A Quaternion representing the rotation of the arm.

float GetArmWidth()

Returns the measured width of the forearm in meters.

Vector3 GetElbowPosition()

Calculates the position of the elbow in global coordinates.

Return
A Vector3 containing the Unity coordinates of the elbow.

override Hand GetLeapHand()

Returns the Leap Hand object represented by this HandModel.

Note that any physical quantities and directions obtained from the Leap Hand object are relative to the Leap Motion coordinate system, which uses a right-handed axes and units of millimeters.

Vector3 GetPalmDirection()

Calculates the direction vector of the hand in global coordinates.

Return
A Vector3 representing the direction of the hand.

Vector3 GetPalmNormal()

Calculates the normal vector projecting from the hand in global coordinates.

Return
A Vector3 representing the vector perpendicular to the palm.

Vector3 GetPalmPosition()

Calculates the position of the palm in global coordinates.

Return
A Vector3 containing the Unity coordinates of the palm position.

Quaternion GetPalmRotation()

Calculates the rotation of the hand in global coordinates.

Return
A Quaternion representing the rotation of the hand.

Vector3 GetWristPosition()

Calculates the position of the wrist in global coordinates.

Return
A Vector3 containing the Unity coordinates of the wrist.

override void InitHand()

Implement this function to initialise this hand after it is created.

This function is called by the HandController during the Unity Update() phase when a new hand is detected by the Leap Motion device.

int LeapID()

Returns the ID associated with the hand in the Leap API.

This ID is guaranteed to be unique among all hands in a frame, and is invariant for the lifetime of the hand model.

override void SetLeapHand(Hand hand)

Assigns a Leap Hand object to this hand model.

Note that the Leap Hand objects are recreated every frame. The parent HandController calls this method to set or update the underlying hand.

abstract override void UpdateHand()

Implement this function to update this hand once every game loop.

For HandModel instances assigned to the HandController graphics hand list, the HandController calls this function during the Unity Update() phase. For HandModel instances in the physics hand list, the HandController calls this function in the FixedUpdate() phase.

Public Members

Transform elbowJoint

Transform object for the elbow joint of this hand.

FingerModel [] fingers

The array of finger objects for this hand.

The array is ordered from thumb (element 0) to pinky (element 4).

Transform forearm

Transform object for the forearm object of this hand.

float handModelPalmWidth

The model width of the hand in meters.

This value is used with the measured value of the user’s hand to scale the model proportionally.

const int NUM_FINGERS

The number of fingers on a hand.

Transform palm

Transform object for the palm object of this hand.

Transform wristJoint

Transform object for the wrist joint of this hand.