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.
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 FunctionsPublic MembersVector3 GetArmCenter()Calculates the center of the forearm relative to the controller.
- Return
- A Vector3 containing the Unity coordinates of the center of the forearm.
Vector3 GetArmDirection()Calculates the direction vector of the forearm relative to the controller.
- 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 relative to the controller.
- Return
- A Quaternion representing the rotation of the arm relative to the controller.
float GetArmWidth()Returns the measured width of the forearm in meters.
HandController GetController()The parent HandController object of this hand.
Vector3 GetElbowPosition()Calculates the position of the elbow relative to the controller.
- Return
- A Vector3 containing the Unity coordinates of the elbow.
Vector3 GetHandOffset()Calculates the offset between the wrist position and the controller based on the HandController.handMovementScale property and the Leap hand wrist position.
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 relative to the controller.
- Return
- A Vector3 representing the direction of the hand relative to the controller.
Vector3 GetPalmNormal()Calculates the normal vector projecting from the hand relative to the controller.
- Return
- A Vector3 representing the vector perpendicular to the palm.
Vector3 GetPalmPosition()Calculates the position of the palm relative to the controller.
- Return
- A Vector3 containing the Unity coordinates of the palm position.
Quaternion GetPalmRotation()Calculates the rotation of the hand relative to the controller.
- Return
- A Quaternion representing the rotation of the hand relative to the controller.
Vector3 GetWristPosition()Calculates the position of the wrist relative to the controller.
- Return
- A Vector3 containing the Unity coordinates of the wrist.
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.
bool IsMirrored()Whether this hand is currently mirrored.
void MirrorZAxis(bool mirror = true)Sets the mirror z-axis flag for this Hand Model and its fingers.
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)Sets the parent HandController object.
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 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.
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.