Selector Tool

Tool for interacting with the scene using a highlighter tool. Default mapping is controller (right or left) grip button to turn on, trigger to use or for desktop right mouse button to toggle on and left mouse button to use. See code below for how to import and map to a function. 

#Import modules:

from utils import selector

from tools import highlighter


#Set items: 

selector.tool.setItems([button1,button2])


#Can change highlight mode

selector.tool.setHighlightMode(highlighter.MODE_NONE)


#Parent to main transport

transportNode = vizconnect.getTransport('main_transport').getNode3d()

selector.tool.setParent(transportNode)


# Global variables and key event handlers

isConfirmingTarget = False

currentHighlightedObject = None


#Create dictionary to hold items (or use from gazeObjectsDict)

button_name_map = {button1: 'button1', button2: 'button2'}


#Function to Trigger

def confirmTarget(e):

global isConfirmingTarget, currentHighlightedObject

isConfirmingTarget = True

if currentHighlightedObject in [button1, button2]:

#Action to perform

print(f'{button_name_map[currentHighlightedObject]} found')

isConfirmingTarget = False


# Highlight event callback

def onHighlight(e):

global currentHighlightedObject

currentHighlightedObject = e.new

if isConfirmingTarget and currentHighlightedObject in [button1, button2]:

print(f'{currentHighlightedObject} is highlighted')


viz.callback(viz.getEventID('triggerPress'), confirmTarget)

viz.callback(highlighter.HIGHLIGHT_EVENT, onHighlight)

For more information see also this page in the Vizard Documentation