PDA

View Full Version : Coordinates for Zones


new_horizon
08-18-2011, 06:07 AM
Hi All,

I am running an experiment where participants will see a number of vehicles move towards there viewpoint.

With the help of Farshizzo (thanks), some gridlines then appear and I want the participant to click in the grid that they thought they saw objects approaching them.

My questions are...

1) Is there any way of setting up "zones" that correspond with the gridlines?
2) How would I go about setting up a range of coordinates that indicate a particular response?

Best wishes.

Mark

new_horizon
08-18-2011, 08:03 AM
OK so I managed to do this by inserting a number of buttons within the gridlines - does anyone know how to make them transparent?

Lastly, I need to allow the user to select up to five zones of action - is anyone able to tell me the command that will allow this?

farshizzo
08-18-2011, 08:58 AM
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.
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)

new_horizon
08-18-2011, 09:03 AM
That's great thank you.

Do you know if there is a way of allowing the user to select multiple zones? So if there are vehicles moving in three of the zones, they can click each one in turn before the program progresses?

Thanks again