The Selector Tool is designed for interacting with objects in a VR scene using a highlighter mechanism. This document outlines its functionality, implementation, and usage.
VR Mode:
Controller grip button (right or left): Turn on the selector (for Vive controllers these are the Left and Right system buttons)
Trigger: Use the selector
Desktop Mode:
Right mouse button: Toggle the selector on/off
Left mouse button: Use the selector
Locate the following files in the ExampleScripts\Selector Tool directory:
Selector_Tool_GUI:
Automatically targets objects tagged for interactions
Displays a window with the name of the highlighted object
Selector_Tool_GUI_Grab:
Allows grabbing objects from a distance
Left click to select and move objects, left click again to place
Selector_Tool:
A simple non-GUI example
from sightlab_utils import selector
from tools import highlighter
isConfirmingTarget = False
currentHighlightedObject = None
Manually:
soccerball = env.getChild('soccerball')
basketball = env.getChild('basketball')
target_objects = [basketball, soccerball]
for obj in target_objects:
selector.tool.setItems([obj])
selector.tool2.setItems([obj])
targetObject = basketball
Automatically from GUI:
target_names = list(sightlab.sceneObjects[GAZE_OBJECTS].keys())
target_objects = {}
object_name_map = {}
for name in target_names:
obj = env.getChild(name)
if obj:
target_objects[name] = obj
object_name_map[obj] = name
selector.tool.setItems(list(target_objects.values()))
selector.tool2.setItems(list(target_objects.values()))
targetObject = list(target_objects.values())
def confirmTarget(e):
global isConfirmingTarget, currentHighlightedObject
isConfirmingTarget = True
if currentHighlightedObject == targetObject:
# Action to perform
print('Object is Targetted')
isConfirmingTarget = False
def onHighlight(e):
global currentHighlightedObject
currentHighlightedObject = e.new
if isConfirmingTarget and currentHighlightedObject == targetObject:
print(f'{currentHighlightedObject} is highlighted')
viz.callback(viz.getEventID('triggerPress'), confirmTarget)
viz.callback(highlighter.HIGHLIGHT_EVENT, onHighlight)
selector.setupSelector(sightlab.getConfig())
For more information see also this page in the Vizard Documentation