Thread: User-Interface
View Single Post
  #18  
Old 02-14-2005, 05:12 PM
farshizzo farshizzo is offline
WorldViz Team Member
 
Join Date: Mar 2003
Posts: 2,849
Make sure you are using Vizard 2.5

I've included a sample script. It adds a quad to the lower left of the SCREEN and a quad to the center of the WORLD. Clicking the left mouse button will perform a pick on the WORLD and clicking the right mouse button will perform a pick on the SCREEN. When the screen quad is picked it will print out "Picked screen quad". When the world quad is picked it will print out "Picked world quad". If it doesn't work can you check if any errors are being printed out.
Code:
import viz
viz.go()

ScreenQuad = viz.add(viz.TEXQUAD,viz.SCREEN)
ScreenQuad.translate(0.2,0.2)

WorldQuad = viz.add(viz.TEXQUAD)
WorldQuad.translate(0,1.8,4)

viz.mouse(0)

def onmousedown(button):
	object = 0
	if button == viz.MOUSEBUTTON_LEFT:
		object = viz.pick()
	elif button == viz.MOUSEBUTTON_RIGHT:
		object = viz.pick(0,viz.SCREEN)
	if object and object.valid():
		if object == ScreenQuad:
			print 'Picked screen quad'
		elif object == WorldQuad:
			print 'Picked world quad'

viz.callback(viz.MOUSEDOWN_EVENT,onmousedown)
Reply With Quote