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::ILineRenderable { public: // properties Transform FollowTransform; Transform PalmRaysOrigin; int PalmRaysCount; float PalmRaysLength; float PalmRaysConeAngle; HandPose ExtendedGripPose; HandPose ExtendedTriggerPose; HandPose RetractedGripPose; HandPose RetractedTriggerPose; float IdlePoseLerpFactor; float PoseSwayIntensity; override bool IsHoverEnabled; bool HandPoseVisualEnabled; int HandPoseVisualizerIndex; bool ObjectInteractionWithRaycast; Transform RayOrigin; float RayLength; Transform DirectUIInteractionOrigin; float DirectUIInteractionRange; GameObject Reticle; bool UIInteractionWithRaycast; bool UIInteractionWithTouch; IInteractor Interactor; bool IsInPoseArea; // methods 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 SetHandPose(HandPose pose); void SetHandPose( HandPose pose, float interpolationTime, System.Action<HandPose> onInterpolationFinished ); void ResetDefaultHandPose(); bool CreateAutomaticHandPose(HandPose pose, IInteractable interactable); 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(); };
Inherited Members¶
public: // enums enum ControllerSide; // 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; AudioSource SoundSource; AudioClip HoverEnterSound; AudioClip SelectEnterSound; AudioClip ActivateEnterSound; float UIHoverEnterHapticIntensity; float HoverEnterHapticIntensity; float SelectEnterHapticIntensity; float ActivateEnterHapticIntensity; 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 SelectEnterSound; AudioClip ActivateEnterSound; float UIHoverEnterHapticIntensity; float HoverEnterHapticIntensity; float SelectEnterHapticIntensity; float ActivateEnterHapticIntensity; 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; 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); bool PlayHaptics(float intensity, float duration); virtual override bool CanSelect(IInteractable interactable); virtual override bool CanActivate(IInteractable interactable); bool PlayHaptics(float intensity, float duration = 0.1f); 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¶
A VR hand interactor.
Properties¶
Transform FollowTransform
Gets or sets the transform the hand will follow. Usually this is the controller’s transform.
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.
HandPose ExtendedGripPose
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 ExtendedTriggerPose
Gets or sets the grip pose. Typically with the index finger extended.
This pose should only contain the index finger poses.
HandPose RetractedGripPose
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 RetractedTriggerPose
Gets or sets the grip pose. Typically with the index finger retracted.
This pose should only contain the index finger poses.
float IdlePoseLerpFactor
Gets or sets the lerp factor of the idle pose [0,1f]. 0 means fully extended, 1 means fully retracted.
float PoseSwayIntensity
Gets or sets the intensity of the hand pose sway when moving the hand fast.
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.
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.
GameObject Reticle
Gets or sets the reticle that will be used to visualize the hit point.
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 IsInPoseArea
Gets or sets a value indicating whether the interactor is inside a pose area.
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.
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 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.
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.
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.