Class HandConstraint
Provides a solver that constrains the target to a region safe for hand constrained interactive content. This solver is intended to work with IMixedRealityHand but also works with IMixedRealityController.
Implements
Inherited Members
Namespace: Microsoft.MixedReality.Toolkit.Utilities.Solvers
Assembly: cs.temp.dll.dll
Syntax
public class HandConstraint : Solver, MonoBehaviour
Fields
handBounds
Declaration
protected HandBounds handBounds
Field Value
Type | Description |
---|---|
HandBounds |
handBounds
Declaration
protected HandBounds handBounds
Field Value
Type | Description |
---|---|
HandBounds |
trackedController
Declaration
protected IMixedRealityController trackedController
Field Value
Type | Description |
---|---|
IMixedRealityController |
trackedController
Declaration
protected IMixedRealityController trackedController
Field Value
Type | Description |
---|---|
IMixedRealityController |
Properties
HideHandCursorsOnActivate
When a hand is activated for tracking, should the cursor(s) be disabled on that hand?
Declaration
public bool HideHandCursorsOnActivate { get; set; }
Property Value
Type | Description |
---|---|
Boolean |
HideHandCursorsOnActivate
When a hand is activated for tracking, should the cursor(s) be disabled on that hand?
Declaration
public bool HideHandCursorsOnActivate { get; set; }
Property Value
Type | Description |
---|---|
Boolean |
OffsetBehavior
Specifies how the solver's offset relative to the hand will be computed.
Declaration
public HandConstraint.SolverOffsetBehavior OffsetBehavior { get; set; }
Property Value
Type | Description |
---|---|
HandConstraint.SolverOffsetBehavior |
OnFirstHandDetected
Event which is triggered when zero hands to one hand is tracked.
Declaration
public UnityEvent OnFirstHandDetected { get; set; }
Property Value
Type | Description |
---|---|
UnityEvent |
OnFirstHandDetected
Event which is triggered when zero hands to one hand is tracked.
Declaration
public UnityEvent OnFirstHandDetected { get; set; }
Property Value
Type | Description |
---|---|
UnityEvent |
OnHandActivate
Event which is triggered when a hand begins being tracked.
Declaration
public UnityEvent OnHandActivate { get; set; }
Property Value
Type | Description |
---|---|
UnityEvent |
OnHandActivate
Event which is triggered when a hand begins being tracked.
Declaration
public UnityEvent OnHandActivate { get; set; }
Property Value
Type | Description |
---|---|
UnityEvent |
OnHandDeactivate
Event which is triggered when a hand stops being tracked.
Declaration
public UnityEvent OnHandDeactivate { get; set; }
Property Value
Type | Description |
---|---|
UnityEvent |
OnHandDeactivate
Event which is triggered when a hand stops being tracked.
Declaration
public UnityEvent OnHandDeactivate { get; set; }
Property Value
Type | Description |
---|---|
UnityEvent |
OnLastHandLost
Event which is triggered when all hands are lost.
Declaration
public UnityEvent OnLastHandLost { get; set; }
Property Value
Type | Description |
---|---|
UnityEvent |
OnLastHandLost
Event which is triggered when all hands are lost.
Declaration
public UnityEvent OnLastHandLost { get; set; }
Property Value
Type | Description |
---|---|
UnityEvent |
RotationBehavior
Specifies how the solver should rotate when tracking the hand.
Declaration
public HandConstraint.SolverRotationBehavior RotationBehavior { get; set; }
Property Value
Type | Description |
---|---|
HandConstraint.SolverRotationBehavior |
RotationBehavior
Specifies how the solver should rotate when tracking the hand.
Declaration
public HandConstraint.SolverRotationBehavior RotationBehavior { get; set; }
Property Value
Type | Description |
---|---|
HandConstraint.SolverRotationBehavior |
SafeZone
Which part of the hand to move the tracked object towards. The ulnar side of the hand is recommended for most situations.
Declaration
public HandConstraint.SolverSafeZone SafeZone { get; set; }
Property Value
Type | Description |
---|---|
HandConstraint.SolverSafeZone |
SafeZone
Which part of the hand to move the tracked object towards. The ulnar side of the hand is recommended for most situations.
Declaration
public HandConstraint.SolverSafeZone SafeZone { get; set; }
Property Value
Type | Description |
---|---|
HandConstraint.SolverSafeZone |
SafeZoneBuffer
Additional offset to apply to the intersection point with the hand bounds.
Declaration
public float SafeZoneBuffer { get; set; }
Property Value
Type | Description |
---|---|
Single |
SafeZoneBuffer
Additional offset to apply to the intersection point with the hand bounds.
Declaration
public float SafeZoneBuffer { get; set; }
Property Value
Type | Description |
---|---|
Single |
UpdateWhenOppositeHandNear
Should the solver continue to move when the opposite hand (hand which is not being tracked) is near the tracked hand. This can improve stability when one hand occludes the other."
Declaration
public bool UpdateWhenOppositeHandNear { get; set; }
Property Value
Type | Description |
---|---|
Boolean |
UpdateWhenOppositeHandNear
Should the solver continue to move when the opposite hand (hand which is not being tracked) is near the tracked hand. This can improve stability when one hand occludes the other."
Declaration
public bool UpdateWhenOppositeHandNear { get; set; }
Property Value
Type | Description |
---|---|
Boolean |
Methods
CalculateGoalPosition()
Performs a ray vs AABB test to determine where the solver can constrain the tracked object without intersection. The "safe zone" is calculated as if projected into the horizontal and vertical plane of the camera.
Declaration
protected virtual Vector3 CalculateGoalPosition()
Returns
Type | Description |
---|---|
Vector3 | The new goal position. |
CalculateGoalPosition()
Performs a ray vs AABB test to determine where the solver can constrain the tracked object without intersection. The "safe zone" is calculated as if projected into the horizontal and vertical plane of the camera.
Declaration
protected virtual Vector3 CalculateGoalPosition()
Returns
Type | Description |
---|---|
Vector3 | The new goal position. |
CalculateGoalRotation()
Determines the solver's goal rotation based off of the SolverRotationBehavior.
Declaration
protected virtual Quaternion CalculateGoalRotation()
Returns
Type | Description |
---|---|
Quaternion | The new goal rotation. |
CalculateGoalRotation()
Determines the solver's goal rotation based off of the SolverRotationBehavior.
Declaration
protected virtual Quaternion CalculateGoalRotation()
Returns
Type | Description |
---|---|
Quaternion | The new goal rotation. |
GetController(Handedness)
Returns the first detected controller in the input system that matches the passed-in handedness
Declaration
protected static IMixedRealityController GetController(Handedness handedness)
Parameters
Type | Name | Description |
---|---|---|
Handedness | handedness | The handedness of the returned controller |
Returns
Type | Description |
---|---|
IMixedRealityController | The IMixedRealityController for the desired handedness, or null if none are present. |
IsOppositeHandNear(IMixedRealityController)
Performs an intersection test to see if the left hand is near the right hand or vice versa.
Declaration
protected virtual bool IsOppositeHandNear(IMixedRealityController controller)
Parameters
Type | Name | Description |
---|---|---|
IMixedRealityController | controller | The hand to check against. |
Returns
Type | Description |
---|---|
Boolean | True, when hands are near each other. |
IsOppositeHandNear(IMixedRealityController)
Performs an intersection test to see if the left hand is near the right hand or vice versa.
Declaration
protected virtual bool IsOppositeHandNear(IMixedRealityController controller)
Parameters
Type | Name | Description |
---|---|---|
IMixedRealityController | controller | The hand to check against. |
Returns
Type | Description |
---|---|
Boolean | True, when hands are near each other. |
IsValidController(IMixedRealityController)
Determines if a hand meets the requirements for use with constraining the tracked object.
Declaration
protected virtual bool IsValidController(IMixedRealityController controller)
Parameters
Type | Name | Description |
---|---|---|
IMixedRealityController | controller | The controller to check against. |
Returns
Type | Description |
---|---|
Boolean | True if this hand should be used from tracking. |
IsValidController(IMixedRealityController)
Determines if a hand meets the requirements for use with constraining the tracked object.
Declaration
protected virtual bool IsValidController(IMixedRealityController controller)
Parameters
Type | Name | Description |
---|---|---|
IMixedRealityController | controller | The controller to check against. |
Returns
Type | Description |
---|---|
Boolean | True if this hand should be used from tracking. |
OnEnable()
Declaration
protected override void OnEnable()
Overrides
OnEnable()
Declaration
protected override void OnEnable()
Overrides
SolverUpdate()
Declaration
public override void SolverUpdate()
Overrides
SolverUpdate()
Declaration
public override void SolverUpdate()
Overrides
ToggleCursors(IMixedRealityController, Boolean, Boolean)
Enables/disables all cursors on the currently tracked hand.
Declaration
protected virtual IEnumerator ToggleCursors(IMixedRealityController controller, bool visible, bool frameDelay = false)
Parameters
Type | Name | Description |
---|---|---|
IMixedRealityController | controller | Controller target to search for pointers |
Boolean | visible | Is the cursor visible? |
Boolean | frameDelay | Delay one frame before performing the toggle to allow the pointers to instantiate their cursors. |
Returns
Type | Description |
---|---|
IEnumerator |
ToggleCursors(IMixedRealityController, Boolean, Boolean)
Enables/disables all cursors on the currently tracked hand.
Declaration
protected virtual IEnumerator ToggleCursors(IMixedRealityController controller, bool visible, bool frameDelay = false)
Parameters
Type | Name | Description |
---|---|---|
IMixedRealityController | controller | Controller target to search for pointers |
Boolean | visible | Is the cursor visible? |
Boolean | frameDelay | Delay one frame before performing the toggle to allow the pointers to instantiate their cursors. |
Returns
Type | Description |
---|---|
IEnumerator |