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, IMixedRealitySourceStateHandler
Fields
autoTransitionBetweenHands
Declaration
protected bool autoTransitionBetweenHands
Field Value
| Type | Description |
|---|---|
| Boolean |
handBounds
Declaration
protected HandBounds handBounds
Field Value
| Type | Description |
|---|---|
| HandBounds |
handStack
Declaration
protected List<IMixedRealityController> handStack
Field Value
| Type | Description |
|---|---|
| List<IMixedRealityController> |
trackedHand
Declaration
protected IMixedRealityController trackedHand
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 |
InputSystem
The active instance of the input system.
Declaration
protected IMixedRealityInputSystem InputSystem { get; }
Property Value
| Type | Description |
|---|---|
| IMixedRealityInputSystem |
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 |
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 |
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 |
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 |
Methods
Awake()
Declaration
protected override void Awake()
Overrides
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. |
IsHandActive(IMixedRealityController)
Determines if a hand meets the requirements for use with constraining the tracked object.
Declaration
protected virtual bool IsHandActive(IMixedRealityController hand)
Parameters
| Type | Name | Description |
|---|---|---|
| IMixedRealityController | hand | The hand to check against. |
Returns
| Type | Description |
|---|---|
| Boolean | True if this hand should be used from tracking. |
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 hand)
Parameters
| Type | Name | Description |
|---|---|---|
| IMixedRealityController | hand | The hand to check against. |
Returns
| Type | Description |
|---|---|
| Boolean | True, when hands are near each other. |
OnDisable()
Declaration
protected virtual void OnDisable()
OnEnable()
Declaration
protected override void OnEnable()
Overrides
OnSourceDetected(SourceStateEventData)
Declaration
public void OnSourceDetected(SourceStateEventData eventData)
Parameters
| Type | Name | Description |
|---|---|---|
| SourceStateEventData | eventData |
OnSourceLost(SourceStateEventData)
Declaration
public void OnSourceLost(SourceStateEventData eventData)
Parameters
| Type | Name | Description |
|---|---|---|
| SourceStateEventData | eventData |
SolverUpdate()
Should be implemented in derived classes, but Solver can be used to flush shared transform to real transform
Declaration
public override void SolverUpdate()
Overrides
ToggleCursor(Boolean, Boolean)
Enables/disables all cursors on the currently tracked hand.
Declaration
protected virtual IEnumerator ToggleCursor(bool visible, bool frameDelay = false)
Parameters
| Type | Name | Description |
|---|---|---|
| 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 |