Tanoda
Leap.Unity.Interaction.InteractionController Class Referenceabstract
Inheritance diagram for Leap.Unity.Interaction.InteractionController:
Leap.Unity.Interaction.IInternalInteractionController Leap.Unity.Interaction.InteractionHand Leap.Unity.Interaction.InteractionXRController

Classes

class  GizmoColors
 

Public Member Functions

void NotifyObjectUnregistered (IInteractionBehaviour intObj)
 
void LockPrimaryHover (InteractionBehaviour intObj)
 Sets the argument interaction object to be the current primary hover of this interaction controller and locks the primary hover state of the interaction controller. primaryHoverLocked More...
 
void ClearHoverTracking ()
 Clears all hover tracking state and fires the hover-end callbacks immediately. If objects are still in the hover radius around this controller and the controller and manager are still active, HoverBegin callbacks will be invoked again on the next fixed frame. More...
 
void ClearHoverTrackingForObject (IInteractionBehaviour intObj)
 Clears the hover tracking state for an object and fires the hover-end callback for that object immediately. More...
 
void ClearPrimaryHoverTracking ()
 Clears primary hover tracking state for the current primary hovered object. More...
 
void EnableSoftContact ()
 
void DisableSoftContact ()
 
void NotifySoftContactCollisionEnter (ContactBone bone, IInteractionBehaviour intObj, Collider collider)
 
void NotifySoftContactCollisionExit (ContactBone bone, IInteractionBehaviour intObj, Collider collider)
 
void NotifyContactBoneCollisionEnter (ContactBone contactBone, IInteractionBehaviour interactionObj)
 
void NotifyContactBoneCollisionStay (ContactBone contactBone, IInteractionBehaviour interactionObj)
 
void NotifyContactBoneCollisionExit (ContactBone contactBone, IInteractionBehaviour interactionObj)
 
void ClearContactTracking ()
 Clears contact state for this controller and fires the appropriate ContactEnd callbacks on currently-contacted interaction objects immediately. More...
 
void ClearContactTrackingForObject (IInteractionBehaviour intObj)
 Clears contact state for the specified object and fires its ContactEnd callbacks immediately. More...
 
abstract Vector3 GetGraspPoint ()
 Returns approximately where the controller is grasping the currently grasped InteractionBehaviour. This method will print an error if the controller is not currently grasping an object. More...
 
bool TryGrasp (IInteractionBehaviour intObj)
 Checks if the provided interaction object can be grasped by this interaction controller in its current state. If so, the controller will initiate a grasp and this method will return true, otherwise this method returns false. More...
 
virtual void SwapGrasp (IInteractionBehaviour replacement)
 Seamlessly swap the currently grasped object for a replacement object. It will behave like the hand released the current object, and then grasped the new object. More...
 
bool ReleaseGrasp ()
 Releases the object this hand is holding and returns true if the hand was holding an object, or false if there was no object to release. The released object will dispatch OnGraspEnd() immediately. The hand is guaranteed not to be holding an object directly after this method is called. More...
 
bool ReleaseGrasp (out IInteractionBehaviour releasedObject)
 As ReleaseGrasp(), but also outputs the released object into releasedObject if the hand successfully released an object. More...
 
bool ReleaseObject (IInteractionBehaviour toRelease)
 Attempts to release this hand's object, but only if the argument object is the object currently grasped by this hand. If the hand was holding the argument object, returns true, otherwise returns false. More...
 
virtual void OnDrawRuntimeGizmos (RuntimeGizmoDrawer drawer)
 By default, this method will draw all of the colliders found in the contactBoneParent hierarchy, or draw the controller's soft contact representation when in soft contact mode. Optionally override this method to modify its behavior. More...
 
void FixedUpdateController ()
 
bool CheckHoverEnd (out HashSet< IInteractionBehaviour > hoverEndedObjects)
 
bool CheckHoverBegin (out HashSet< IInteractionBehaviour > hoverBeganObjects)
 
bool CheckHoverStay (out HashSet< IInteractionBehaviour > hoveredObjects)
 
bool CheckPrimaryHoverEnd (out IInteractionBehaviour primaryHoverEndedObject)
 
bool CheckPrimaryHoverBegin (out IInteractionBehaviour primaryHoverBeganObject)
 
bool CheckPrimaryHoverStay (out IInteractionBehaviour primaryHoveredObject)
 
bool CheckContactEnd (out HashSet< IInteractionBehaviour > contactEndedObjects)
 
bool CheckContactBegin (out HashSet< IInteractionBehaviour > contactBeganObjects)
 
bool CheckContactStay (out HashSet< IInteractionBehaviour > contactedObjects)
 
bool CheckGraspEnd (out IInteractionBehaviour releasedObject)
 
bool CheckGraspBegin (out IInteractionBehaviour newlyGraspedObject)
 
bool CheckGraspHold (out IInteractionBehaviour graspedObject)
 
bool CheckSuspensionBegin (out IInteractionBehaviour suspendedObject)
 
bool CheckSuspensionEnd (out IInteractionBehaviour resumedObject)
 

Static Public Member Functions

static float GetHoverDistance (Vector3 hoverPoint, IInteractionBehaviour behaviour)
 Returns the hover distance from the hoverPoint to the specified object, automatically accounting for ISpaceComponent warping if necessary. More...
 
static Vector3 TransformPoint (Vector3 worldPoint, ISpaceComponent element)
 Applies the spatial warping of the provided ISpaceComponent to a world-space point. More...
 
static void ReleaseGrasps (IInteractionBehaviour graspedObj, ReadonlyHashSet< InteractionController > controllers)
 Helper static method for forcing multiple controllers to release their grasps on a single object simultaneously. All of the provided controllers must be grasping the argument interaction object. More...
 

Public Attributes

InteractionManager manager
 
Action< InteractionBehaviourOnBeginPrimaryHoveringObject = (intObj) => { }
 Called when this InteractionController begins primarily hovering over an InteractionBehaviour. If the controller transitions to primarily hovering a new object, OnEndPrimaryHoveringObject will first be called on the old object, then OnBeginPrimaryHoveringObject will be called for the new object. More...
 
Action< InteractionBehaviourOnEndPrimaryHoveringObject = (intObj) => { }
 Called when this InteractionController stops primarily hovering over an InteractionBehaviour. If the controller transitions to primarily-hovering a new object, OnEndPrimaryHoveringObject will first be called on the old object, then OnBeginPrimaryHoveringObject will be called for the new object. More...
 
Action< InteractionBehaviourOnStayPrimaryHoveringObject = (intObj) => { }
 Called every (fixed) frame this InteractionController is primarily hovering over an InteractionBehaviour. More...
 
Action OnGraspBegin = () => { }
 Called when the InteractionController begins grasping an object. More...
 
Action OnGraspStay = () => { }
 Called while the InteractionController is grasping an object. More...
 
Action OnGraspEnd = () => { }
 Called when the InteractionController releases an object. More...
 
Action< InteractionControllerOnContactInitialized = (intCtrl) => { }
 Called when contact data is initialized. More...
 
Func< IInteractionBehaviour, bool > customHoverActivityFilter = null
 In addition to standard hover validity checks, you can set this filter property to further filter objects for hover consideration. Only objects for which this function returns true will be hover candidates (if the filter is not null). More...
 

Protected Member Functions

virtual void Reset ()
 
virtual void OnEnable ()
 
virtual void Start ()
 
virtual void OnDisable ()
 
abstract void onObjectUnregistered (IInteractionBehaviour intObj)
 This method is called by the InteractionController when it is notified by the InteractionManager that an InteractionBehaviour has been unregistered from the Interaction Engine. If your controller has any state that remembers or tracks interaction objects, this method should clear that state, because unregistered objects won't receive state updates or callbacks from this controller's Interaction Manager anymore. More...
 
virtual void fixedUpdateController ()
 Called just before the InteractionController proceeds with its usual FixedUpdate. More...
 
abstract void unwarpColliders (Transform primaryHoverPoint, ISpaceComponent warpedSpaceElement)
 Implementing this method is necessary to support curved spaces as rendered by a Leap Graphic Renderer. See InteractionHand for an example implementation. (Implementing this method is optional if you are not using a curved space as rendered by a Leap Graphic Renderer.) More...
 
abstract bool initContact ()
 Called to initialize contact colliders. See remarks for implementation requirements. More...
 
abstract void getColliderBoneTargetPositionRotation (int contactBoneIndex, out Vector3 targetPosition, out Quaternion targetRotation)
 If your controller features no moving colliders relative to itself, simply return the desired position and rotation for the given indexed contact bone in the contactBones array. (For example, by recording the local position and local rotation of each contact bone in initContact()). More complex controllers, such as InteractionHand, uses this method to set ContactBone target positions and rotations based on the tracked Leap hand. More...
 
virtual void onPreEnableSoftContact ()
 Optionally override this method to perform logic just before soft contact is enabled for this controller. More...
 
virtual void onPostDisableSoftContact ()
 Optionally override this method to perform logic just after soft contact is disabled for this controller. More...
 
abstract bool checkShouldGraspAtemporal (IInteractionBehaviour intObj)
 Checks if the provided interaction object can be grasped by this interaction controller in its current state. If so, the controller will initiate a grasp and this method will return true, otherwise this method returns false. More...
 
abstract void fixedUpdateGraspingState ()
 Called every fixed frame if grasping is enabled in the Interaction Manager. More...
 
virtual void onGraspedObjectForciblyReleased (IInteractionBehaviour objectToBeReleased)
 Optionally override this method to perform logic just before a grasped object is released because it is no longer eligible to be grasped by this controller or ReleaseGrasp() was manually called on the controller. More...
 
abstract bool checkShouldGrasp (out IInteractionBehaviour objectToGrasp)
 Returns whether this controller should grasp an object this fixed frame, and if so, sets objectToGrasp to the object the controller should grasp. More...
 
abstract bool checkShouldRelease (out IInteractionBehaviour objectToRelease)
 Returns whether this controller should release an object this fixed frame, and if so, sets objectToRelease to the object the controller should release. More...
 

Static Protected Member Functions

static void drawHoverPoint (RuntimeGizmoDrawer drawer, Vector3 pos)
 
static void drawPrimaryHoverPoint (RuntimeGizmoDrawer drawer, Vector3 pos)
 

Protected Attributes

float lastObjectTouchedAdjustedMassMass = 0.2f
 

Static Protected Attributes

const float DEAD_ZONE_FRACTION = 0.04F
 

Properties

bool hoverEnabled [get, set]
 
bool contactEnabled [get, set]
 
bool graspingEnabled [get, set]
 
abstract bool isTracked [get]
 Gets whether the underlying object (Leap hand or a held controller) is currently in a tracked state. Objects grasped by a controller that becomes untracked will become "suspended" and receive specific suspension callbacks. (Implementing any behaviour during the suspension state is left up to the developer, however.) More...
 
abstract bool isBeingMoved [get]
 Gets whether the underlying object (Leap hand or a held controller) is currently being moved or being actively manipulated by the player. More...
 
abstract bool isLeft [get]
 Gets whether the underlying object (Leap hand or a held controller) represents or is held by a left hand (true) or a right hand (false). More...
 
bool isRight [get]
 Gets whether the underlying object (Leap hand or a held controller) represents or is held by a right hand (true) or a left hand (false). More...
 
abstract Vector3 position [get]
 Returns the current position of this controller. More...
 
abstract Quaternion rotation [get]
 Returns the current rotation of this controller. More...
 
abstract Vector3 velocity [get]
 Returns the current velocity of this controller. More...
 
abstract ControllerType controllerType [get]
 Gets the type of controller this object represents underneath the InteractionController abstraction. If the type is ControllerType.Hand, the intHand property will contain the InteractionHand object this object abstracts from. More...
 
abstract InteractionHand intHand [get]
 If this InteractionController's controllerType is ControllerType.Hand, this gets the InteractionHand, otherwise this returns null. More...
 
float scale [get]
 Contact requires knowledge of the controller's scale. Non-uniformly scaled controllers are NOT supported. More...
 
ActivityManager< IInteractionBehaviourhoverActivityManager [get]
 
bool primaryHoverLocked [get, set]
 When set to true, locks the current primarily hovered object, even if the hand gets closer to a different object. More...
 
abstract Vector3 hoverPoint [get]
 Gets the current position to check against nearby objects for hovering. Position is only used if the controller is currently tracked. For example, InteractionHand returns the center of the palm of the underlying Leap hand. More...
 
ReadonlyHashSet< IInteractionBehaviourhoveredObjects [get]
 Returns a set of all Interaction objects currently hovered by this InteractionController. More...
 
abstract List< Transform > _primaryHoverPoints [get]
 
ReadonlyList< Transform > primaryHoverPoints [get]
 Gets the list of Transforms to consider against nearby objects to determine the closest object (primary hover) of this controller. More...
 
bool isPrimaryHovering [get]
 Gets whether the InteractionController is currently primarily hovering over any interaction object. More...
 
IInteractionBehaviour primaryHoveredObject [get]
 Gets the InteractionBehaviour that is currently this InteractionController's primary hovered object, if there is one. More...
 
float primaryHoverDistance [get]
 Gets the distance from the closest primary hover point on this controller to its primarily hovered object, if there are any. More...
 
Vector3 primaryHoveringPoint [get]
 Gets the position of the primary hovering point that is closest to its primary hovered object, if this controller has a primary hover. Otherwise, returns Vector3.zero. More...
 
int primaryHoveringPointIndex [get]
 Gets the index in the primaryHoverPoints array of the primary hover point that is currently closest to this controller's primary hover object. More...
 
ReadonlyHashSet< IInteractionBehaviourcontactingObjects [get]
 Gets the set of interaction objects that are currently touching this interaction controller. More...
 
float softContactDislocationDistance [get, set]
 
static PhysicMaterial defaultContactBoneMaterial [get]
 
bool _wasContactInitialized [get]
 
abstract ContactBone[] contactBones [get]
 
abstract GameObject contactBoneParent [get]
 
bool softContactEnabled [get]
 
bool isGraspingObject [get]
 Gets whether the controller is currently grasping an object. More...
 
IInteractionBehaviour graspedObject [get]
 Gets the object the controller is currently grasping, or null if there is no such object. More...
 
ReadonlyHashSet< IInteractionBehaviourgraspCandidates [get]
 Gets the set of objects currently considered graspable. More...
 
abstract List< Vector3 > graspManipulatorPoints [get]
 Gets the points of the controller to add to the calculation to determine how held objects should move as the controller moves. Interaction Controllers utilize the Kabsch algorithm to determine this, which is most noticeable when using Leap hands via InteractionHands to manipulate held objects. Rigid controllers may simply return a single rigid point on the controller. Refer to InteractionHand for a reference implementation for dynamic controllers (e.g. hands). More...
 

Detailed Description

Definition at line 38 of file InteractionController.cs.

Member Function Documentation

◆ checkShouldGrasp()

abstract bool Leap.Unity.Interaction.InteractionController.checkShouldGrasp ( out IInteractionBehaviour  objectToGrasp)
protectedpure virtual

Returns whether this controller should grasp an object this fixed frame, and if so, sets objectToGrasp to the object the controller should grasp.

Implemented in Leap.Unity.Interaction.InteractionHand, and Leap.Unity.Interaction.InteractionXRController.

◆ checkShouldGraspAtemporal()

abstract bool Leap.Unity.Interaction.InteractionController.checkShouldGraspAtemporal ( IInteractionBehaviour  intObj)
protectedpure virtual

Checks if the provided interaction object can be grasped by this interaction controller in its current state. If so, the controller will initiate a grasp and this method will return true, otherwise this method returns false.

This method is useful if the controller requires conditions to initiate a grasp that differ from the conditions necessary to maintain a grasp after it has been initiated. This method allows a grasp to occur if certain initiation conditions are not met, such as the motion of a hand's fingers towards the palm, but if the grasp holding conditions are met, such as the penetration of a hand's fingers inside the interaction object.

Implemented in Leap.Unity.Interaction.InteractionHand, and Leap.Unity.Interaction.InteractionXRController.

◆ checkShouldRelease()

abstract bool Leap.Unity.Interaction.InteractionController.checkShouldRelease ( out IInteractionBehaviour  objectToRelease)
protectedpure virtual

Returns whether this controller should release an object this fixed frame, and if so, sets objectToRelease to the object the controller should release.

Implemented in Leap.Unity.Interaction.InteractionHand, and Leap.Unity.Interaction.InteractionXRController.

◆ ClearContactTracking()

void Leap.Unity.Interaction.InteractionController.ClearContactTracking ( )

Clears contact state for this controller and fires the appropriate ContactEnd callbacks on currently-contacted interaction objects immediately.

If the controller is still contacting objects and it and its manager are still active, contact will begin anew on the next fixed frame.

Definition at line 1485 of file InteractionController.cs.

◆ ClearContactTrackingForObject()

void Leap.Unity.Interaction.InteractionController.ClearContactTrackingForObject ( IInteractionBehaviour  intObj)

Clears contact state for the specified object and fires its ContactEnd callbacks immediately.

If the controller is still contacting the object and it and its manager are still active, contact will begin anew on the next fixed frame.

Definition at line 1515 of file InteractionController.cs.

◆ ClearHoverTracking()

void Leap.Unity.Interaction.InteractionController.ClearHoverTracking ( )

Clears all hover tracking state and fires the hover-end callbacks immediately. If objects are still in the hover radius around this controller and the controller and manager are still active, HoverBegin callbacks will be invoked again on the next fixed frame.

Definition at line 619 of file InteractionController.cs.

◆ ClearHoverTrackingForObject()

void Leap.Unity.Interaction.InteractionController.ClearHoverTrackingForObject ( IInteractionBehaviour  intObj)

Clears the hover tracking state for an object and fires the hover-end callback for that object immediately.

If the object is still in the hover radius of this controller and the controller and manager are still active, the hover will begin anew on the next fixed frame.

Definition at line 653 of file InteractionController.cs.

◆ ClearPrimaryHoverTracking()

void Leap.Unity.Interaction.InteractionController.ClearPrimaryHoverTracking ( )

Clears primary hover tracking state for the current primary hovered object.

If the current primary hover is still the most eligible hovered object and this controller and its manager are still active, primary hover will begin anew on the next fixed frame.

Definition at line 749 of file InteractionController.cs.

◆ DisableSoftContact()

void Leap.Unity.Interaction.InteractionController.DisableSoftContact ( )

Definition at line 1333 of file InteractionController.cs.

◆ drawHoverPoint()

static void Leap.Unity.Interaction.InteractionController.drawHoverPoint ( RuntimeGizmoDrawer  drawer,
Vector3  pos 
)
staticprotected

Definition at line 2099 of file InteractionController.cs.

◆ drawPrimaryHoverPoint()

static void Leap.Unity.Interaction.InteractionController.drawPrimaryHoverPoint ( RuntimeGizmoDrawer  drawer,
Vector3  pos 
)
staticprotected

Definition at line 2104 of file InteractionController.cs.

◆ EnableSoftContact()

void Leap.Unity.Interaction.InteractionController.EnableSoftContact ( )

Definition at line 1309 of file InteractionController.cs.

◆ fixedUpdateController()

virtual void Leap.Unity.Interaction.InteractionController.fixedUpdateController ( )
protectedvirtual

Called just before the InteractionController proceeds with its usual FixedUpdate.

It's generally better to override this method instead of having your InteractionController implement FixedUpdate because its execution order relative to the Interaction Manager is fixed.

Reimplemented in Leap.Unity.Interaction.InteractionHand, and Leap.Unity.Interaction.InteractionXRController.

Definition at line 290 of file InteractionController.cs.

◆ fixedUpdateGraspingState()

abstract void Leap.Unity.Interaction.InteractionController.fixedUpdateGraspingState ( )
protectedpure virtual

Called every fixed frame if grasping is enabled in the Interaction Manager.

graspActivityManager.ActiveObjects will contain objects around the hoverPoint within the grasping radius – in other words, objects eligible to be grasped by the controller. Refer to it to avoid checking grasp eligibility against all graspable objects in your scene.

Implemented in Leap.Unity.Interaction.InteractionHand, and Leap.Unity.Interaction.InteractionXRController.

◆ getColliderBoneTargetPositionRotation()

abstract void Leap.Unity.Interaction.InteractionController.getColliderBoneTargetPositionRotation ( int  contactBoneIndex,
out Vector3  targetPosition,
out Quaternion  targetRotation 
)
protectedpure virtual

If your controller features no moving colliders relative to itself, simply return the desired position and rotation for the given indexed contact bone in the contactBones array. (For example, by recording the local position and local rotation of each contact bone in initContact()). More complex controllers, such as InteractionHand, uses this method to set ContactBone target positions and rotations based on the tracked Leap hand.

Implemented in Leap.Unity.Interaction.InteractionHand, and Leap.Unity.Interaction.InteractionXRController.

◆ GetGraspPoint()

abstract Vector3 Leap.Unity.Interaction.InteractionController.GetGraspPoint ( )
pure virtual

Returns approximately where the controller is grasping the currently grasped InteractionBehaviour. This method will print an error if the controller is not currently grasping an object.

Implemented in Leap.Unity.Interaction.InteractionHand, and Leap.Unity.Interaction.InteractionXRController.

◆ GetHoverDistance()

static float Leap.Unity.Interaction.InteractionController.GetHoverDistance ( Vector3  hoverPoint,
IInteractionBehaviour  behaviour 
)
static

Returns the hover distance from the hoverPoint to the specified object, automatically accounting for ISpaceComponent warping if necessary.

Definition at line 842 of file InteractionController.cs.

◆ initContact()

abstract bool Leap.Unity.Interaction.InteractionController.initContact ( )
protectedpure virtual

Called to initialize contact colliders. See remarks for implementation requirements.

initContact() should:

  • Return false at any time if initialization cannot be performed.
  • Ensure the "contactBones" property returns all contact colliders.
    • (Construct contact colliders if they don't already exist.)
  • Ensure the "contactBoneParent" property returns the common parent of all contact colliders.
    • (Construct the contact bone parent if it doesn't already exist.)
  • Return true if initialization was successful.

Contact will only begin updating after initialization succeeds, otherwise it will try to initialize again on the next fixed frame.

After initialization, the contact bone parent's layer will be set to the Interaction Manager's contactBoneLayer.

Implemented in Leap.Unity.Interaction.InteractionHand, and Leap.Unity.Interaction.InteractionXRController.

◆ LockPrimaryHover()

void Leap.Unity.Interaction.InteractionController.LockPrimaryHover ( InteractionBehaviour  intObj)

Sets the argument interaction object to be the current primary hover of this interaction controller and locks the primary hover state of the interaction controller. primaryHoverLocked

Definition at line 355 of file InteractionController.cs.

◆ NotifyContactBoneCollisionEnter()

void Leap.Unity.Interaction.InteractionController.NotifyContactBoneCollisionEnter ( ContactBone  contactBone,
IInteractionBehaviour  interactionObj 
)

Definition at line 1436 of file InteractionController.cs.

◆ NotifyContactBoneCollisionExit()

void Leap.Unity.Interaction.InteractionController.NotifyContactBoneCollisionExit ( ContactBone  contactBone,
IInteractionBehaviour  interactionObj 
)

Definition at line 1458 of file InteractionController.cs.

◆ NotifyContactBoneCollisionStay()

void Leap.Unity.Interaction.InteractionController.NotifyContactBoneCollisionStay ( ContactBone  contactBone,
IInteractionBehaviour  interactionObj 
)

Definition at line 1447 of file InteractionController.cs.

◆ NotifyObjectUnregistered()

void Leap.Unity.Interaction.InteractionController.NotifyObjectUnregistered ( IInteractionBehaviour  intObj)

Definition at line 266 of file InteractionController.cs.

◆ NotifySoftContactCollisionEnter()

void Leap.Unity.Interaction.InteractionController.NotifySoftContactCollisionEnter ( ContactBone  bone,
IInteractionBehaviour  intObj,
Collider  collider 
)

Definition at line 1394 of file InteractionController.cs.

◆ NotifySoftContactCollisionExit()

void Leap.Unity.Interaction.InteractionController.NotifySoftContactCollisionExit ( ContactBone  bone,
IInteractionBehaviour  intObj,
Collider  collider 
)

Definition at line 1405 of file InteractionController.cs.

◆ OnDisable()

virtual void Leap.Unity.Interaction.InteractionController.OnDisable ( )
protectedvirtual

Definition at line 238 of file InteractionController.cs.

◆ OnDrawRuntimeGizmos()

virtual void Leap.Unity.Interaction.InteractionController.OnDrawRuntimeGizmos ( RuntimeGizmoDrawer  drawer)
virtual

By default, this method will draw all of the colliders found in the contactBoneParent hierarchy, or draw the controller's soft contact representation when in soft contact mode. Optionally override this method to modify its behavior.

Definition at line 2071 of file InteractionController.cs.

◆ OnEnable()

virtual void Leap.Unity.Interaction.InteractionController.OnEnable ( )
protectedvirtual

Definition at line 226 of file InteractionController.cs.

◆ onGraspedObjectForciblyReleased()

virtual void Leap.Unity.Interaction.InteractionController.onGraspedObjectForciblyReleased ( IInteractionBehaviour  objectToBeReleased)
protectedvirtual

Optionally override this method to perform logic just before a grasped object is released because it is no longer eligible to be grasped by this controller or ReleaseGrasp() was manually called on the controller.

Reimplemented in Leap.Unity.Interaction.InteractionHand.

Definition at line 1807 of file InteractionController.cs.

◆ onObjectUnregistered()

abstract void Leap.Unity.Interaction.InteractionController.onObjectUnregistered ( IInteractionBehaviour  intObj)
protectedpure virtual

This method is called by the InteractionController when it is notified by the InteractionManager that an InteractionBehaviour has been unregistered from the Interaction Engine. If your controller has any state that remembers or tracks interaction objects, this method should clear that state, because unregistered objects won't receive state updates or callbacks from this controller's Interaction Manager anymore.

Implemented in Leap.Unity.Interaction.InteractionHand, and Leap.Unity.Interaction.InteractionXRController.

◆ onPostDisableSoftContact()

virtual void Leap.Unity.Interaction.InteractionController.onPostDisableSoftContact ( )
protectedvirtual

Optionally override this method to perform logic just after soft contact is disabled for this controller.

The InteractionHand implementation takes the opportunity to reset its contact bone's joints, which my have initialized slightly out of alignment on initial construction.

Reimplemented in Leap.Unity.Interaction.InteractionHand.

Definition at line 1307 of file InteractionController.cs.

◆ onPreEnableSoftContact()

virtual void Leap.Unity.Interaction.InteractionController.onPreEnableSoftContact ( )
protectedvirtual

Optionally override this method to perform logic just before soft contact is enabled for this controller.

The InteractionHand implementation takes the opportunity to reset its contact bone's joints, which may have initialized slightly out of alignment on initial construction.

Reimplemented in Leap.Unity.Interaction.InteractionHand.

Definition at line 1297 of file InteractionController.cs.

◆ ReleaseGrasp() [1/2]

bool Leap.Unity.Interaction.InteractionController.ReleaseGrasp ( )

Releases the object this hand is holding and returns true if the hand was holding an object, or false if there was no object to release. The released object will dispatch OnGraspEnd() immediately. The hand is guaranteed not to be holding an object directly after this method is called.

Definition at line 1828 of file InteractionController.cs.

◆ ReleaseGrasp() [2/2]

bool Leap.Unity.Interaction.InteractionController.ReleaseGrasp ( out IInteractionBehaviour  releasedObject)

As ReleaseGrasp(), but also outputs the released object into releasedObject if the hand successfully released an object.

Definition at line 1916 of file InteractionController.cs.

◆ ReleaseGrasps()

static void Leap.Unity.Interaction.InteractionController.ReleaseGrasps ( IInteractionBehaviour  graspedObj,
ReadonlyHashSet< InteractionController controllers 
)
static

Helper static method for forcing multiple controllers to release their grasps on a single object simultaneously. All of the provided controllers must be grasping the argument interaction object.

The input controllers List is copied to a temporary (pooled) buffer before release operations are actually carried out. This prevents errors that might arise from modifying a held-controllers list while enumerating through the same list.

Definition at line 1868 of file InteractionController.cs.

◆ ReleaseObject()

bool Leap.Unity.Interaction.InteractionController.ReleaseObject ( IInteractionBehaviour  toRelease)

Attempts to release this hand's object, but only if the argument object is the object currently grasped by this hand. If the hand was holding the argument object, returns true, otherwise returns false.

Definition at line 1932 of file InteractionController.cs.

◆ Reset()

virtual void Leap.Unity.Interaction.InteractionController.Reset ( )
protectedvirtual

◆ Start()

virtual void Leap.Unity.Interaction.InteractionController.Start ( )
protectedvirtual

◆ SwapGrasp()

virtual void Leap.Unity.Interaction.InteractionController.SwapGrasp ( IInteractionBehaviour  replacement)
virtual

Seamlessly swap the currently grasped object for a replacement object. It will behave like the hand released the current object, and then grasped the new object.

This method will not teleport the replacement object or move it in any way, it will just cause it to be grasped. That means that you will be responsible for moving the replacement object into a reasonable position for it to be grasped.

Reimplemented in Leap.Unity.Interaction.InteractionHand.

Definition at line 1698 of file InteractionController.cs.

◆ TransformPoint()

static Vector3 Leap.Unity.Interaction.InteractionController.TransformPoint ( Vector3  worldPoint,
ISpaceComponent  element 
)
static

Applies the spatial warping of the provided ISpaceComponent to a world-space point.

Definition at line 854 of file InteractionController.cs.

◆ TryGrasp()

bool Leap.Unity.Interaction.InteractionController.TryGrasp ( IInteractionBehaviour  intObj)

Checks if the provided interaction object can be grasped by this interaction controller in its current state. If so, the controller will initiate a grasp and this method will return true, otherwise this method returns false.

Definition at line 1679 of file InteractionController.cs.

◆ unwarpColliders()

abstract void Leap.Unity.Interaction.InteractionController.unwarpColliders ( Transform  primaryHoverPoint,
ISpaceComponent  warpedSpaceElement 
)
protectedpure virtual

Implementing this method is necessary to support curved spaces as rendered by a Leap Graphic Renderer. See InteractionHand for an example implementation. (Implementing this method is optional if you are not using a curved space as rendered by a Leap Graphic Renderer.)

Warps the collider transforms of this controller by the inverse of the transformation that is applied on the provided warpedSpaceElement, using the primaryHoverPoint as the pivot transform for the transformation.

ITransformer.WorldSpaceUnwarp is a useful method here. (ISpaceComponents contain references to their transformers via their anchors.)

ISpaceComponents denote game objects whose visual positions are warped from rectilinear (non-warped) space into a curved space (via, for example, a LeapCylindricalSpace, which can only be rendered correctly by the Leap Graphic Renderer). This method reverses that transformation for the hand, bringing it into the object's rectilinear space, allowing objects curved in this way to correctly collide with the bones in the hand or collider of a held controller.

The provided Transform is the closest primary hover point to any given primary hover candidate, so it is used as the pivot point for unwarping the colliders of this InteractionController.

Implemented in Leap.Unity.Interaction.InteractionHand, and Leap.Unity.Interaction.InteractionXRController.

Member Data Documentation

◆ customHoverActivityFilter

Func<IInteractionBehaviour, bool> Leap.Unity.Interaction.InteractionController.customHoverActivityFilter = null

In addition to standard hover validity checks, you can set this filter property to further filter objects for hover consideration. Only objects for which this function returns true will be hover candidates (if the filter is not null).

Definition at line 299 of file InteractionController.cs.

◆ DEAD_ZONE_FRACTION

const float Leap.Unity.Interaction.InteractionController.DEAD_ZONE_FRACTION = 0.04F
staticprotected

Definition at line 876 of file InteractionController.cs.

◆ lastObjectTouchedAdjustedMassMass

float Leap.Unity.Interaction.InteractionController.lastObjectTouchedAdjustedMassMass = 0.2f
protected

Definition at line 911 of file InteractionController.cs.

◆ manager

InteractionManager Leap.Unity.Interaction.InteractionController.manager

Definition at line 45 of file InteractionController.cs.

◆ OnBeginPrimaryHoveringObject

Action<InteractionBehaviour> Leap.Unity.Interaction.InteractionController.OnBeginPrimaryHoveringObject = (intObj) => { }

Called when this InteractionController begins primarily hovering over an InteractionBehaviour. If the controller transitions to primarily hovering a new object, OnEndPrimaryHoveringObject will first be called on the old object, then OnBeginPrimaryHoveringObject will be called for the new object.

Definition at line 183 of file InteractionController.cs.

◆ OnContactInitialized

Action<InteractionController> Leap.Unity.Interaction.InteractionController.OnContactInitialized = (intCtrl) => { }

Called when contact data is initialized.

Definition at line 216 of file InteractionController.cs.

◆ OnEndPrimaryHoveringObject

Action<InteractionBehaviour> Leap.Unity.Interaction.InteractionController.OnEndPrimaryHoveringObject = (intObj) => { }

Called when this InteractionController stops primarily hovering over an InteractionBehaviour. If the controller transitions to primarily-hovering a new object, OnEndPrimaryHoveringObject will first be called on the old object, then OnBeginPrimaryHoveringObject will be called for the new object.

Definition at line 191 of file InteractionController.cs.

◆ OnGraspBegin

Action Leap.Unity.Interaction.InteractionController.OnGraspBegin = () => { }

Called when the InteractionController begins grasping an object.

Definition at line 201 of file InteractionController.cs.

◆ OnGraspEnd

Action Leap.Unity.Interaction.InteractionController.OnGraspEnd = () => { }

Called when the InteractionController releases an object.

Definition at line 211 of file InteractionController.cs.

◆ OnGraspStay

Action Leap.Unity.Interaction.InteractionController.OnGraspStay = () => { }

Called while the InteractionController is grasping an object.

Definition at line 206 of file InteractionController.cs.

◆ OnStayPrimaryHoveringObject

Action<InteractionBehaviour> Leap.Unity.Interaction.InteractionController.OnStayPrimaryHoveringObject = (intObj) => { }

Called every (fixed) frame this InteractionController is primarily hovering over an InteractionBehaviour.

Definition at line 196 of file InteractionController.cs.

Property Documentation

◆ _primaryHoverPoints

abstract List<Transform> Leap.Unity.Interaction.InteractionController._primaryHoverPoints
getprotected

Definition at line 374 of file InteractionController.cs.

◆ _wasContactInitialized

bool Leap.Unity.Interaction.InteractionController._wasContactInitialized
getprotected

Definition at line 908 of file InteractionController.cs.

◆ contactBoneParent

abstract GameObject Leap.Unity.Interaction.InteractionController.contactBoneParent
getprotected

Definition at line 910 of file InteractionController.cs.

◆ contactBones

abstract ContactBone [] Leap.Unity.Interaction.InteractionController.contactBones
get

Definition at line 909 of file InteractionController.cs.

◆ contactEnabled

bool Leap.Unity.Interaction.InteractionController.contactEnabled
getset

Definition at line 73 of file InteractionController.cs.

◆ contactingObjects

ReadonlyHashSet<IInteractionBehaviour> Leap.Unity.Interaction.InteractionController.contactingObjects
get

Gets the set of interaction objects that are currently touching this interaction controller.

Definition at line 872 of file InteractionController.cs.

◆ controllerType

abstract ControllerType Leap.Unity.Interaction.InteractionController.controllerType
get

Gets the type of controller this object represents underneath the InteractionController abstraction. If the type is ControllerType.Hand, the intHand property will contain the InteractionHand object this object abstracts from.

Definition at line 159 of file InteractionController.cs.

◆ defaultContactBoneMaterial

PhysicMaterial Leap.Unity.Interaction.InteractionController.defaultContactBoneMaterial
staticgetprotected

Definition at line 885 of file InteractionController.cs.

◆ graspCandidates

ReadonlyHashSet<IInteractionBehaviour> Leap.Unity.Interaction.InteractionController.graspCandidates
get

Gets the set of objects currently considered graspable.

Definition at line 1655 of file InteractionController.cs.

◆ graspedObject

IInteractionBehaviour Leap.Unity.Interaction.InteractionController.graspedObject
get

Gets the object the controller is currently grasping, or null if there is no such object.

Definition at line 1652 of file InteractionController.cs.

◆ graspingEnabled

bool Leap.Unity.Interaction.InteractionController.graspingEnabled
getset

Definition at line 96 of file InteractionController.cs.

◆ graspManipulatorPoints

abstract List<Vector3> Leap.Unity.Interaction.InteractionController.graspManipulatorPoints
get

Gets the points of the controller to add to the calculation to determine how held objects should move as the controller moves. Interaction Controllers utilize the Kabsch algorithm to determine this, which is most noticeable when using Leap hands via InteractionHands to manipulate held objects. Rigid controllers may simply return a single rigid point on the controller. Refer to InteractionHand for a reference implementation for dynamic controllers (e.g. hands).

Definition at line 1665 of file InteractionController.cs.

◆ hoverActivityManager

ActivityManager<IInteractionBehaviour> Leap.Unity.Interaction.InteractionController.hoverActivityManager
get

Definition at line 321 of file InteractionController.cs.

◆ hoveredObjects

ReadonlyHashSet<IInteractionBehaviour> Leap.Unity.Interaction.InteractionController.hoveredObjects
get

Returns a set of all Interaction objects currently hovered by this InteractionController.

Definition at line 372 of file InteractionController.cs.

◆ hoverEnabled

bool Leap.Unity.Interaction.InteractionController.hoverEnabled
getset

Definition at line 57 of file InteractionController.cs.

◆ hoverPoint

abstract Vector3 Leap.Unity.Interaction.InteractionController.hoverPoint
get

Gets the current position to check against nearby objects for hovering. Position is only used if the controller is currently tracked. For example, InteractionHand returns the center of the palm of the underlying Leap hand.

Definition at line 365 of file InteractionController.cs.

◆ intHand

abstract InteractionHand Leap.Unity.Interaction.InteractionController.intHand
get

If this InteractionController's controllerType is ControllerType.Hand, this gets the InteractionHand, otherwise this returns null.

Definition at line 165 of file InteractionController.cs.

◆ isBeingMoved

abstract bool Leap.Unity.Interaction.InteractionController.isBeingMoved
get

Gets whether the underlying object (Leap hand or a held controller) is currently being moved or being actively manipulated by the player.

Definition at line 124 of file InteractionController.cs.

◆ isGraspingObject

bool Leap.Unity.Interaction.InteractionController.isGraspingObject
get

Gets whether the controller is currently grasping an object.

Definition at line 1649 of file InteractionController.cs.

◆ isLeft

abstract bool Leap.Unity.Interaction.InteractionController.isLeft
get

Gets whether the underlying object (Leap hand or a held controller) represents or is held by a left hand (true) or a right hand (false).

Definition at line 130 of file InteractionController.cs.

◆ isPrimaryHovering

bool Leap.Unity.Interaction.InteractionController.isPrimaryHovering
get

Gets whether the InteractionController is currently primarily hovering over any interaction object.

Definition at line 385 of file InteractionController.cs.

◆ isRight

bool Leap.Unity.Interaction.InteractionController.isRight
get

Gets whether the underlying object (Leap hand or a held controller) represents or is held by a right hand (true) or a left hand (false).

Definition at line 136 of file InteractionController.cs.

◆ isTracked

abstract bool Leap.Unity.Interaction.InteractionController.isTracked
get

Gets whether the underlying object (Leap hand or a held controller) is currently in a tracked state. Objects grasped by a controller that becomes untracked will become "suspended" and receive specific suspension callbacks. (Implementing any behaviour during the suspension state is left up to the developer, however.)

Definition at line 118 of file InteractionController.cs.

◆ position

abstract Vector3 Leap.Unity.Interaction.InteractionController.position
get

Returns the current position of this controller.

Definition at line 141 of file InteractionController.cs.

◆ primaryHoverDistance

float Leap.Unity.Interaction.InteractionController.primaryHoverDistance
get

Gets the distance from the closest primary hover point on this controller to its primarily hovered object, if there are any.

Definition at line 399 of file InteractionController.cs.

◆ primaryHoveredObject

IInteractionBehaviour Leap.Unity.Interaction.InteractionController.primaryHoveredObject
get

Gets the InteractionBehaviour that is currently this InteractionController's primary hovered object, if there is one.

Definition at line 392 of file InteractionController.cs.

◆ primaryHoveringPoint

Vector3 Leap.Unity.Interaction.InteractionController.primaryHoveringPoint
get

Gets the position of the primary hovering point that is closest to its primary hovered object, if this controller has a primary hover. Otherwise, returns Vector3.zero.

Definition at line 406 of file InteractionController.cs.

◆ primaryHoveringPointIndex

int Leap.Unity.Interaction.InteractionController.primaryHoveringPointIndex
get

Gets the index in the primaryHoverPoints array of the primary hover point that is currently closest to this controller's primary hover object.

Definition at line 417 of file InteractionController.cs.

◆ primaryHoverLocked

bool Leap.Unity.Interaction.InteractionController.primaryHoverLocked
getset

When set to true, locks the current primarily hovered object, even if the hand gets closer to a different object.

Definition at line 344 of file InteractionController.cs.

◆ primaryHoverPoints

ReadonlyList<Transform> Leap.Unity.Interaction.InteractionController.primaryHoverPoints
get

Gets the list of Transforms to consider against nearby objects to determine the closest object (primary hover) of this controller.

Definition at line 379 of file InteractionController.cs.

◆ rotation

abstract Quaternion Leap.Unity.Interaction.InteractionController.rotation
get

Returns the current rotation of this controller.

Definition at line 146 of file InteractionController.cs.

◆ scale

float Leap.Unity.Interaction.InteractionController.scale
get

Contact requires knowledge of the controller's scale. Non-uniformly scaled controllers are NOT supported.

Definition at line 171 of file InteractionController.cs.

◆ softContactDislocationDistance

float Leap.Unity.Interaction.InteractionController.softContactDislocationDistance
getsetprotected

Definition at line 879 of file InteractionController.cs.

◆ softContactEnabled

bool Leap.Unity.Interaction.InteractionController.softContactEnabled
get

Definition at line 1115 of file InteractionController.cs.

◆ velocity

abstract Vector3 Leap.Unity.Interaction.InteractionController.velocity
get

Returns the current velocity of this controller.

Definition at line 151 of file InteractionController.cs.


The documentation for this class was generated from the following file: