View Full Version : Move canvas mouse with WorldViz wand

03-13-2018, 04:57 PM
In the vizard demo launcher, there is a menu that can be interacted with by pointing the wand at it to move the mouse. So far I have the canvas set up, and I have set the canvas mouse style to CANVAS_MOUSE_VISIBLE, but I am somewhat lost on the rest. Here is the function I have come up with:

def manualCursorPositionTask():
global listDisplayed, grabber

while True:
if listDisplayed:
pos = grabber.getPosition()
x = pos[0],y=pos[1],z=pos[2]
euler = grabber.getEuler()
intersection = viz.intersect([x + math.sin(euler.yaw/180*math.pi),y,z + math.sin(euler.pitch/180*math.pi)], [x + 100*math.sin(euler.yaw/180*math.pi),y,z + 100*math.sin(euler.pitch)/180*math.pi])

if intersection.object.id == canvas.id:
canvas.setCursorPosition(intersection.point, viz.CANVAS_CURSOR_PIXELS)

yield viztask.waitFrame(1)

This is based off of example code I found in example code, specifically canvasExample.py. This code does not seem to work, however. I have used viz.director() to add the function to Vizard's task management as well. If anyone could explain to me what I would need to do to interact with a menu by pointing the wand, or what's wrong with my methodology, I could really use an explanation. Thanks.