View Single Post
  #3  
Old 08-18-2011, 08:58 AM
farshizzo farshizzo is offline
WorldViz Team Member
 
Join Date: Mar 2003
Posts: 2,849
You can disable viz.RENDERING on a node to prevent it from being displayed, but still allow it to be picked. Here is an example that splits the screen into 4 zones and prints out which zone was clicked when the mouse button is pressed. This should give you an idea of how to assign arbitrary zones to the screen.
Code:
import viz
import vizact
import vizshape
viz.go()

ZONE_POSITIONS = [ (0.25,0.25,0), (0.25,0.75,0), (0.75,0.75,0), (0.75,0.25,0) ]

zones = []
for pos in ZONE_POSITIONS:
	z = vizshape.addQuad(size=(0.5,0.5),pos=pos,parent=viz.SCREEN)
	z.disable(viz.RENDERING)
	zones.append(z)

def PickZone():
	node = viz.pick(mode=viz.SCREEN)
	if node in zones:
		print 'picked zone',zones.index(node)

vizact.onmousedown(viz.MOUSEBUTTON_LEFT,PickZone)
Reply With Quote