class MAGES::Interaction::HandTrackingInteractor¶
Overview¶
An interactor that functions through hand tracking. More…
class HandTrackingInteractor: public MAGES::Interaction::Interactors::BaseInteractor, public MAGES::Interaction::IHandPoseVisualizer, public MAGES::Interaction::ILineRenderable { public: // classes class HandModel; // properties AudioSource SoundSource; AudioClip HoverEnterSound; AudioClip SelectEnterSound; AudioClip ActivateEnterSound; HandModel HandModelMap; bool UIInteractionWithRaycast; bool UIInteractionWithTouch; bool ObjectInteractionWithRaycast; bool HandPoseVisualEnabled; int HandPoseVisualizerIndex; HandPose ExtendedPose; HandPose RetractedPose; Transform PalmRaysOrigin; int PalmRaysCount; float PalmRaysLength; float PalmRaysConeAngle; Transform RayOrigin; float RayLength; Transform DirectUIInteractionOrigin; float DirectUIInteractionRange; Vector3 FollowTransformPosition; Quaternion FollowTransformRotation; GameObject Reticle; bool IsTeleportEnabled; IInteractor Interactor; bool IsInPoseArea; override bool IsSelectEnabled; override bool IsActivateEnabled; bool IsUISelectInputEnabled; bool WasUISelectInputEnabledThisFrame; bool WasUISelectInputDisabledThisFrame; bool IsSelectInputEnabled; bool WasSelectInputEnabledThisFrame; bool WasSelectInputDisabledThisFrame; bool IsActivateInputEnabled; bool WasActivateInputEnabledThisFrame; bool WasActivateInputDisabledThisFrame; // methods bool CanInteractWithUIs(); void GetCurrentHandPose(HandPose result); virtual override bool CanHover(IInteractable interactable); virtual override bool CanSelect(IInteractable interactable); virtual override bool CanActivate(IInteractable interactable); override void GetValidTargets(List<IInteractable> result); virtual override void PreprocessInteractor(UpdatePhase updatePhase); virtual override void ProcessInteractor(UpdatePhase updatePhase); virtual override void AttachInteractorToInteractable(); virtual override void DetachInteractorToInteractable(); void ResetDefaultHandPose(); void SetHandPose(HandPose pose); void SetHandPose( HandPose pose, float interpolationTime, System.Action<HandPose> onInterpolationFinished ); bool CreateAutomaticHandPose(HandPose pose, IInteractable interactable); bool TryGetLinePoints(out Vector3[] points); bool TryGetHitPoint( out Vector3 hitPosition, out Vector3 hitNormal, out int pointIndex ); bool TryGetReticle(out GameObject reticle); void SetMovementWithInteractable(bool enabled); void ResetInteractionBooleans(); void OnSelectInput(); void OnDeselectInput(); void OnActivateInput(); void OnDeactivateInput(); void OnUISelectInput(); void OnUIDeselectInput(); void ChangeSelectionValue(bool value); void OptionsMenuTrigger(); void Teleport(); void OverrideFollowTransform(Transform overrideVal); void RestoreFollowTransform(); };
Inherited Members¶
public: // properties IInteractionManager InteractionManager; InteractionLayer InteractionLayer; Transform Transform; Rigidbody Rigidbody; ListColliders; UnityEvent<InteractorRegisterEventArgs> RegisterEntered; UnityEvent<InteractorDeregisterEventArgs> DeregisterEntered; UnityEvent<HoverEnterInteractionEventArgs> HoverEntered; UnityEvent<HoverExitInteractionEventArgs> HoverExited; UnityEvent<SelectEnterInteractionEventArgs> SelectEntered; UnityEvent<SelectExitInteractionEventArgs> SelectExited; UnityEvent<ActivateEnterInteractionEventArgs> ActivateEntered; UnityEvent<ActivateExitInteractionEventArgs> ActivateExited; bool IsHoverEnabled; bool HasHover; IInteractable HoveredInteractable; bool IsSelectEnabled; bool HasSelection; IInteractable SelectedInteractable; IInteractable ManualSelectionInteractable; float SelectionIntensity; bool IsActivateEnabled; bool HasActivation; IInteractable ActivatedInteractable; float ActivationIntensity; IInteractionManager InteractionManager; HandPoser HandPoser; InteractionLayer InteractionLayer; Transform Transform; Rigidbody Rigidbody; List Colliders; UnityEvent<InteractorRegisterEventArgs> RegisterEntered; UnityEvent<InteractorDeregisterEventArgs> DeregisterEntered; UnityEvent<HoverEnterInteractionEventArgs> HoverEntered; UnityEvent<HoverExitInteractionEventArgs> HoverExited; UnityEvent<SelectEnterInteractionEventArgs> SelectEntered; UnityEvent<SelectExitInteractionEventArgs> SelectExited; UnityEvent<ActivateEnterInteractionEventArgs> ActivateEntered; UnityEvent<ActivateExitInteractionEventArgs> ActivateExited; bool IsHoverEnabled; bool HasHover; IInteractable HoveredInteractable; bool IsSelectEnabled; bool HasSelection; IInteractable ManualSelectionInteractable; float SelectionIntensity; IInteractable SelectedInteractable; bool IsActivateEnabled; bool HasActivation; float ActivationIntensity; IInteractable ActivatedInteractable; bool HandPoseVisualEnabled; bool IsInPoseArea; int HandPoseVisualizerIndex; // methods bool CanHover(IInteractable interactable); bool IsHovering(IInteractable interactable); bool HoverExit(IInteractable interactable); void OnHoverEnter(HoverEnterInteractionEventArgs args); void OnHoverEntered(HoverEnterInteractionEventArgs args); void OnHoverExit(HoverExitInteractionEventArgs args); void OnHoverExited(HoverExitInteractionEventArgs args); bool CanSelect(IInteractable interactable); bool IsSelecting(IInteractable interactable); bool SelectExit(IInteractable interactable); void OnSelectEnter(SelectEnterInteractionEventArgs args); void OnSelectEntered(SelectEnterInteractionEventArgs args); void OnSelectExit(SelectExitInteractionEventArgs args); void OnSelectExited(SelectExitInteractionEventArgs args); void StartManualSelection(IInteractable interactable); void StopManualSelection(); bool CanActivate(IInteractable interactable); bool IsActivating(IInteractable interactable); bool ActivateExit(IInteractable interactable); void OnActivateEnter(ActivateEnterInteractionEventArgs args); void OnActivateEntered(ActivateEnterInteractionEventArgs args); void OnActivateExit(ActivateExitInteractionEventArgs args); void OnActivateExited(ActivateExitInteractionEventArgs args); void OnRegisterEnter(InteractorRegisterEventArgs args); void OnRegisterEntered(InteractorRegisterEventArgs args); void OnDeregisterEnter(InteractorDeregisterEventArgs args); void OnDeregisterEntered(InteractorDeregisterEventArgs args); void GetValidTargets(List<IInteractable> result); void PreprocessInteractor(UpdatePhase updatePhase); void ProcessInteractor(UpdatePhase updatePhase); virtual bool CanHover(IInteractable interactable); virtual bool CanSelect(IInteractable interactable); virtual bool CanActivate(IInteractable interactable); virtual void StartManualSelection(IInteractable interactable); virtual void StopManualSelection(); virtual void AttachInteractorToInteractable(); virtual void DetachInteractorToInteractable(); void GetValidTargets(List<IInteractable> result); bool IsHovering(IInteractable interactable); bool HoverExit(IInteractable interactable); bool IsSelecting(IInteractable interactable); bool SelectExit(IInteractable interactable); bool IsActivating(IInteractable interactable); bool ActivateExit(IInteractable interactable); virtual void PreprocessInteractor(UpdatePhase updatePhase); virtual void ProcessInteractor(UpdatePhase updatePhase); void SetHandPose(HandPose pose); void SetHandPose( HandPose pose, float interpolationDuration, Action<HandPose> onInterpolationFinished ); bool CreateAutomaticHandPose(HandPose pose, IInteractable interactable); void ResetDefaultHandPose(); void GetCurrentHandPose(HandPose result); bool TryGetLinePoints(out Vector3[] points); bool TryGetHitPoint( out Vector3 hitPosition, out Vector3 hitNormal, out int pointIndex ); bool TryGetReticle(out GameObject reticle);
Detailed Documentation¶
An interactor that functions through hand tracking.
Properties¶
AudioSource SoundSource
Gets or sets the sound source to play sounds from.
AudioClip HoverEnterSound
Gets or sets the sound to be played when the interactor starts hovering.
AudioClip SelectEnterSound
Gets or sets the sound to be played when the interactor starts selecting.
AudioClip ActivateEnterSound
Gets or sets the sound to be played when the interactor starts activating.
HandModel HandModelMap
Gets or sets the HandPoseMap that includes the corelation between the master and the puppet hand.
bool UIInteractionWithRaycast
Gets a value indicating whether interaction with UIs using raycasts is enabled.
bool UIInteractionWithTouch
Gets a value indicating whether interaction with UIs using touch is enabled.
bool ObjectInteractionWithRaycast
Gets or sets a value indicating whether interaction with objects using raycasts.
bool HandPoseVisualEnabled
Gets or sets a value indicating whether the hand pose visual is enabled.
int HandPoseVisualizerIndex
Gets the index for the hand pose visualizer. Used to find the HandPoses for this visualizer.
HandPose ExtendedPose
Gets or sets the extended pose that is used for automatic hand pose generation.
HandPose RetractedPose
Gets or sets the retracted pose that is used for automatic hand pose generation.
Transform PalmRaysOrigin
Gets or sets the origin of the palm rays used for detecting which interactables are hovered.
int PalmRaysCount
Gets or sets the number of rays casted from the palm to detect for interactables in range.
float PalmRaysLength
Gets or sets the length of each ray casted from the palm to detect for interactables in range.
float PalmRaysConeAngle
Gets or sets the angle of the cone in which the rays are casted from the palm.
float RayLength
Gets or sets length of the raycast.
Transform DirectUIInteractionOrigin
Gets or sets the direct interaction origin transform.
float DirectUIInteractionRange
Gets or sets the direct interaction range.
Vector3 FollowTransformPosition
Gets or sets the position the interactor will follow.
Quaternion FollowTransformRotation
Gets or sets the rotation the interactor will follow.
GameObject Reticle
Gets or sets the reticle that will be used to visualize the hit point.
bool IsTeleportEnabled
Gets or sets a value indicating whether the user is currently trying to teleport.
bool IsInPoseArea
Gets or sets a value indicating whether the interactor is inside a pose area.
override bool IsSelectEnabled
Gets a value indicating whether this interactor should send select event this frame.
Usually set by the controller input, when the grab button is pressed.
override bool IsActivateEnabled
Gets a value indicating whether this interactor should send activate event this frame.
Usually set by the controller input, when the grab button is pressed.
bool WasSelectInputEnabledThisFrame
/>
Methods¶
void GetCurrentHandPose(HandPose result)
Gets the current hand pose and stores it in the given handpose result.
Parameters:
result |
The handpose in which to store the result. |
virtual override bool CanHover(IInteractable interactable)
Gets if this interactor can send hover events to the interactable.
Parameters:
interactable |
The interactable to check if this interactor can send the hover event to. |
Returns:
true
if the interactable can be hovered by this interactor.
virtual override bool CanSelect(IInteractable interactable)
Gets if this interactor can send select events to the interactable.
Parameters:
interactable |
The interactable to check if this interactor can send the select event to. |
Returns:
true
if the interactable can be selected by this interactor.
virtual override bool CanActivate(IInteractable interactable)
Gets if this interactor can send activate events to the interactable.
Parameters:
interactable |
The interactable to check if this interactor can send the activate event to. |
Returns:
true
if the interactable can be activated by this interactor.
override void GetValidTargets(List<IInteractable> result)
Returns the list of valid targets for this interactor in the current frame.
The result list is cleared before any interactables are added to it.
Parameters:
result |
A list to put all the interactables this interactor may interact in this fram. |
virtual override void PreprocessInteractor(UpdatePhase updatePhase)
Called by the InteractionManager before the Interactor is processed by the interaction manager, in the given update phase.
Parameters:
updatePhase |
The update phase this method is called. |
virtual override void ProcessInteractor(UpdatePhase updatePhase)
Called by the InteractionManager after the Interactor is processed by the interaction manager, in the given update phase.
Parameters:
updatePhase |
The update phase this method is called. |
virtual override void AttachInteractorToInteractable()
Attaches the interactor on the interactable with the corresponding pose.
virtual override void DetachInteractorToInteractable()
Detaches the interactor from the interactable.
void ResetDefaultHandPose()
Resets the hand pose to the default.
Use it after calling SetHandPose(HandPose) in order to go back to the default hand pose.
void SetHandPose(HandPose pose)
Sets the current pose to the given one.
Parameters:
pose |
The pose to set. |
bool CreateAutomaticHandPose(HandPose pose, IInteractable interactable)
Creates an automatic pose from the current position/rotation and stores it in pose.
Parameters:
pose |
A handpose in which the generated pose will be stored to. |
interactable |
The interactable for which to create and automatic hand pose. |
Returns:
If the automatic pose was generated successfully.
bool TryGetLinePoints(out Vector3[] points)
Returns a list of the points that make up the line.
Parameters:
points |
An array of all the points defining the line. |
Returns:
true
if able to get at least 2 points (that make a line).
bool TryGetHitPoint( out Vector3 hitPosition, out Vector3 hitNormal, out int pointIndex )
Gets the hit point of the line.
Parameters:
hitPosition |
The position the line hits the object. |
hitNormal |
The normal at the hit position. |
pointIndex |
The point index in the line points at which the hit occurs. |
Returns:
true
if the line hits an object and the object can be interacted.
bool TryGetReticle(out GameObject reticle)
Gets the reticle for the line end.
Parameters:
reticle |
The reticle gameobject. Forward will be aligned with the normal of the hit point. |
Returns:
true
if the reticle exists.
void SetMovementWithInteractable(bool enabled)
Enables hand movement with the interactable. This hides any physics jittering from the hand.
Parameters:
enabled |
Whether to enable or disable movement with interactable. |
void ResetInteractionBooleans()
Resets the select, activate and UISelect booleans of this frame.
void OnSelectInput()
Called the frame when the controller select button is pressed. Similar to OnButtonDown.
void OnDeselectInput()
Called the frame when the controller select button is released. Similar to OnButtonUp.
void OnActivateInput()
Called the frame when the controller activate button is pressed. Similar to OnButtonDown.
void OnDeactivateInput()
Called the frame when the controller activate button is released. Similar to OnButtonUp.
void OnUISelectInput()
Called the frame when the controller UI select button is pressed.
void OnUIDeselectInput()
Called the frame when the controller UI select button is released.
void ChangeSelectionValue(bool value)
Changes the value of the IsSelectEnable property.
Parameters:
value |
The value indicating whether the selection is enabled. |
void OptionsMenuTrigger()
Opens or closes the Options Menu, depending on its current state.
void Teleport()
Activates the teleportation of the camera rig to the last teleport raycast hit position.
void OverrideFollowTransform(Transform overrideVal)
Overrides the current follow transform, with the given one.
Parameters:
overrideVal |
The new transform to follow. |
void RestoreFollowTransform()
If the follow transform was overriden with OverrideFollowTransform(Transform), it restores it.
Parameters:
lerpDuration |
The time for switching between the current overriden follow transform and the initial one. |