class MAGES::Interaction::Interactors::HandInteractor¶
Overview¶
A VR hand interactor. More…
class HandInteractor: public MAGES::Interaction::Interactors::BaseControllerInteractor, public MAGES::Interaction::IHandPoseVisualizer, public MAGES::Interaction::IUIInteractor, public MAGES::Interaction::ILineRenderable { public: // properties HandPoser HandPoser; Transform FollowTransform; Collider PalmCollider; HandPose IdlePose; HandPose GripIdlePose; HandPose TriggerIdlePose; HandPose GripPose; HandPose TriggerPose; override bool IsHoverEnabled; bool HandPoseVisualEnabled; int HandPoseVisualizerIndex; bool UIInteractionWithRaycast; bool ObjectInteractionWithRaycast; Transform RayOrigin; float RayLength; GameObject Reticle; IInteractor Interactor; // methods virtual override bool CanHover(IInteractable interactable); virtual override bool CanSelect(IInteractable interactable); virtual override bool CanActivate(IInteractable interactable); virtual override void GetValidTargets(List<IInteractable> result); virtual override void PreprocessInteractor(UpdatePhase updatePhase); virtual override void ProcessInteractor(UpdatePhase updatePhase); void SetHandPose(HandPose pose); void SetHandPose( HandPose pose, float interpolationTime, System.Action<HandPose> onInterpolationFinished ); void ResetDefaultHandPose(); void GetCurrentHandPose(HandPose result); void OverrideFollowTransform(Transform overrideVal); void RestoreFollowTransform(); void SetMovementWithInteractable(bool enabled); bool TryGetLinePoints(out Vector3[] points); bool TryGetHitPoint( out Vector3 hitPosition, out Vector3 hitNormal, out int pointIndex ); bool TryGetReticle(out GameObject reticle); bool CanInteractWithUIs(); virtual void UpdateUIModel(ref TrackedDeviceModel model); };
Inherited Members¶
public: // enums enum ControllerSide; // properties IInteractionManager InteractionManager; 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; float SelectionIntensity; bool IsActivateEnabled; bool HasActivation; IInteractable ActivatedInteractable; float ActivationIntensity; IInteractionManager InteractionManager; 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; float SelectionIntensity; IInteractable SelectedInteractable; bool IsActivateEnabled; bool HasActivation; float ActivationIntensity; IInteractable ActivatedInteractable; AudioSource SoundSource; AudioClip HoverEnterSound; AudioClip HoverExitSound; AudioClip SelectEnterSound; AudioClip SelectExitSound; AudioClip ActivateEnterSound; AudioClip ActivateExitSound; float HoverEnterHapticIntensity; float HoverExitHapticIntensity; float SelectEnterHapticIntensity; float SelectExitHapticIntensity; float ActivateEnterHapticIntensity; float ActivateExitHapticIntensity; bool IsSelectInputEnabled; bool WasSelectInputEnabledThisFrame; bool WasSelectInputDisabledThisFrame; bool IsActivateInputEnabled; bool WasActivateInputEnabledThisFrame; bool WasActivateInputDisabledThisFrame; bool IsUISelectInputEnabled; bool WasUISelectInputEnabledThisFrame; bool WasUISelectInputDisabledThisFrame; ControllerSide InputControllerSide; AudioSource SoundSource; AudioClip HoverEnterSound; AudioClip HoverExitSound; AudioClip SelectEnterSound; AudioClip SelectExitSound; AudioClip ActivateEnterSound; AudioClip ActivateExitSound; float HoverEnterHapticIntensity; float HoverExitHapticIntensity; float SelectEnterHapticIntensity; float SelectExitHapticIntensity; float ActivateEnterHapticIntensity; float ActivateExitHapticIntensity; override bool IsSelectEnabled; override bool IsActivateEnabled; override float SelectionIntensity; override float ActivationIntensity; bool IsSelectInputEnabled; bool WasSelectInputEnabledThisFrame; bool WasSelectInputDisabledThisFrame; bool IsActivateInputEnabled; bool WasActivateInputEnabledThisFrame; bool WasActivateInputDisabledThisFrame; bool IsUISelectInputEnabled; bool WasUISelectInputEnabledThisFrame; bool WasUISelectInputDisabledThisFrame; bool HandPoseVisualEnabled; int HandPoseVisualizerIndex; Transform RayOrigin; float RayLength; // methods bool CanHover(IInteractable interactable); bool IsHovering(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); void OnSelectEnter(SelectEnterInteractionEventArgs args); void OnSelectEntered(SelectEnterInteractionEventArgs args); void OnSelectExit(SelectExitInteractionEventArgs args); void OnSelectExited(SelectExitInteractionEventArgs args); bool CanActivate(IInteractable interactable); bool IsActivating(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 abstract void GetValidTargets(List<IInteractable> result) = 0; bool IsActivating(IInteractable interactable); bool IsHovering(IInteractable interactable); bool IsSelecting(IInteractable interactable); virtual void PreprocessInteractor(UpdatePhase updatePhase); virtual void ProcessInteractor(UpdatePhase updatePhase); bool PlayHaptics(float intensity, float duration); virtual override bool CanSelect(IInteractable interactable); bool PlayHaptics(float intensity, float duration = 0.2f); void SetHandPose(HandPose pose); void SetHandPose( HandPose pose, float interpolationDuration, Action<HandPose> onInterpolationFinished ); void ResetDefaultHandPose(); void GetCurrentHandPose(HandPose result); bool CanInteractWithUIs(); void UpdateUIModel(ref TrackedDeviceModel model); bool TryGetLinePoints(out Vector3[] points); bool TryGetHitPoint( out Vector3 hitPosition, out Vector3 hitNormal, out int pointIndex ); bool TryGetReticle(out GameObject reticle);
Detailed Documentation¶
A VR hand interactor.
Properties¶
HandPoser HandPoser
Gets the handposer of this interactor.
Transform FollowTransform
Gets or sets the transform the hand will follow. Usually this is the controller’s transform.
Collider PalmCollider
Gets or sets the collider of the palm. Mainly used to bring items closer to the palm when using auto grasp.
HandPose IdlePose
Gets or sets the idle pose with all fingers extended.
HandPose GripIdlePose
Gets or sets the grip idle pose. Typically with all fingers extended, except the index.
This pose should contain poses for all the fingers except the index.
HandPose TriggerIdlePose
Gets or sets the grip pose. Typically with the index finger extended.
This pose should only contain the index finger poses.
HandPose GripPose
Gets or sets the grip pose. Typically with all fingers retracted, except the index.
This pose should contain poses for all the fingers except the index.
HandPose TriggerPose
Gets or sets the grip pose. Typically with the index finger retracted.
This pose should only contain the index finger poses.
override bool IsHoverEnabled
Gets a value indicating whether this interactor should send hover events.
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.
bool ObjectInteractionWithRaycast
Gets or sets a value indicating whether interaction with objects using raycasts.
Transform RayOrigin
Gets the transform from which the Raycast for UIs originates.
float RayLength
Gets or sets length of the raycast.
GameObject Reticle
Gets or sets the reticle that will be used to visualize the hit point.
Methods¶
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.
virtual 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. |
void SetHandPose(HandPose pose)
Sets the current pose to the given one.
Parameters:
pose |
The pose to set. |
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 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. |
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. |
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. |
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.
bool CanInteractWithUIs()
Gets a value indicating whether this IUIInteractor has the ability to interact with UIs.
Returns:
true
if can hover UIs.
virtual void UpdateUIModel(ref TrackedDeviceModel model)
Updates the UI model with the current state of the interactor.
Parameters:
model |
The model to fill with the current state of the IUIInteractor. |