Selector Tool

Selector Tool Documentation

Overview

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.

Default Controls

Examples

Locate the following files in the ExampleScripts\Selector Tool directory:

from sightlab_utils import selector

from tools import highlighter

2. Next Steps After (sightlab.startTrial() or yield viztask.waitEvent(TRIAL_START)
Set Up Global Variables

isConfirmingTarget = False

currentHighlightedObject = None

3. Define Target Objects

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())

4. Define Callback Functions
(After "Action to Peform" is where you place what you want to happen, when target is clicked on)

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')

5. Set Up Event Callbacks

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

viz.callback(highlighter.HIGHLIGHT_EVENT, onHighlight)

6. Configure Highlighter for Hand Controllers

selector.setupSelector(sightlab.getConfig())

For more information see also this page in the Vizard Documentation