Vizard 8 » Tutorials & Examples » Collaboration » Multiple Tools and Devices
8.1

Multiple Tools and Devices

One input device and proxy tool can be used to control multiple tools. In the last section, the proxy tool was configured in vizconnect with two actions mapped to the left and right mouse buttons. Then, action1 (left button) was redirected to the grabber's grabAndHold action in the following line of code:

rawProxy.setCallback(grabberTool, grabberTool.grabAndHold, 1)

Multiple tools are defined in sequence within the init function. Replace the init function with the code below to add both the grabber and laser pointer tools:

def init():
    for proxyWrapper in vizconnect.getToolsWithMode('Proxy'):
        # add grabber based on proxy tool
        grabberTool = tools.grabber.HandGrabber(usingPhysics=False,usingSprings=False,
                                                placementMode=tools.placer.MODE_MID_AIR)
                                                
        name = 'grabber_tool_based_on_'+proxyWrapper.getName()
        grabberWrapper = vizconnect.addTool(raw=grabberTool,
                                            name=name,
                                            make='Virtual',
                                            model='Grabber')
        grabberWrapper.setParent(proxyWrapper)
        grabberTool.setItems(shapes)
        
        rawProxy = proxyWrapper.getRaw()
        rawProxy.setCallback(grabberTool, grabberTool.grabAndHold, 1)
        
        # add laser pointer based on proxy tool
        laserTool = tools.laser_pointer.LaserPointer()
        name = 'laser_tool_based_on_'+proxyWrapper.getName()
        laserWrapper = vizconnect.addTool(raw=laserTool,
                                            name=name,
                                            make='Virtual',
                                            model='Laser Pointer')
        laserWrapper.setParent(proxyWrapper)
        rawProxy.setCallback(laserTool, laserTool.shoot, 2)

In the last line of code, action2 is redirected to the laser's shoot action:

rawProxy.setCallback(laserTool, laserTool.shoot, 2)

Run the code again and use the left mouse button to grab and the right mouse button to shoot the laser pointer.

Two Hand Controllers

For this tutorial a single input device (mouse) and virtual hand is used. A setup with two hand controllers (e.g. Vive) requires that each controller has it's own tools. For example, one grabber for the left controller and another grabber for the right controller. To set this up, add a second proxy tool in vizconnect with the same number of action mappings. The init function code does not need to be modified. The code above would create two grabbers and two laser pointers when run with a vizconnect file that has two proxy tools.

Collaboration Basics

Multiple Tools and Devices