WorldViz User Forum  

Go Back   WorldViz User Forum > Vizard

 
 
Thread Tools Rating: Thread Rating: 5 votes, 5.00 average. Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 07-30-2009, 07:50 AM
ptjt255 ptjt255 is offline
Member
 
Join Date: Oct 2008
Posts: 24
Question Semi-circle array containing target and distractor objects

Hi,

I wonder if someone can help me, I am trying to set up a semi-circle array of positions on the left hand side of the screen, depending on how many distractors are selected (e.g. either 2, 4, 6 or 8) each position should contain one target object and the rest distractors, these should be randomised. I then want the target position to be a hotspot. But at this stage I'm having trouble just getting an array of positions where I want them with the correct objects in them.

Any help would be hugely appreciated.

Thank you.

Code:
import viz
import viztask
import random
viz.go()

Z_dist = -5
#viz.move(0,0,Z_dist)
viz.MainView.move(0.5,0,-10)

# Add distractor and target objects
ballsize = [2.0,2.0,2.0,1.0,1.0,1.0]

# Distractor ball
distractor = viz.add('soccerball.ive')
distractor.setScale(ballsize[0],ballsize[1],2)
distractor.addAction(vizact.spin(0,1,0,100))

# Target Ball
target = viz.add('ball.wrl')
target.setScale(ballsize[3],ballsize[4],1)
target.addAction(vizact.spin(0,1,0,100))

# Set up zones for the objects to appear on the screen
choice = ['2', '4', '6', '8']
select  = viz.choose('How many distractors?', choice)

#make a list with the objects in it
objects = [distractor,target]

# keep 2 positions in an array
pos = [[-1.0,0.0,Z_dist],[-1.0,0.5,Z_dist],[-2.0,1.0,Z_dist],[-1.0,1.5,Z_dist],[-1.0,2.0,Z_dist],[-1.0,2.5,Z_dist],[-1.0,3.0,Z_dist],[-1.0,3.5,Z_dist]]

rand_positions = []

def sceneOn(num):
	global rand_positions
	positions = [0,1,2,3,4,5,6,7]
	if select == 0:

		#set objects to 2 different random positions
		rand_positions = random.sample(positions,2)

		objects[0].setPosition(pos[rand_positions[0]])
		objects[1].setPosition(pos[rand_positions[1]])

	if select == 1:

		#set objects to 4 different random positions
		rand_positions = random.sample(positions,4)
		
		objects[0].setPosition(pos[rand_positions[0]])
		objects[0].setPosition(pos[rand_positions[1]])
		objects[0].setPosition(pos[rand_positions[2]])
		objects[1].setPosition(pos[rand_positions[3]])

	if select == 2:

		#set objects to 4 different random positions
		rand_positions = random.sample(positions,6)
		
		objects[0].setPosition(pos[rand_positions[0]])
		objects[0].setPosition(pos[rand_positions[1]])
		objects[0].setPosition(pos[rand_positions[2]])
		objects[0].setPosition(pos[rand_positions[3]])
		objects[0].setPosition(pos[rand_positions[4]])
		objects[1].setPosition(pos[rand_positions[5]])
		
	if select == 3:
		rand_positions = random.sample(positions,8)
		
		objects[0].setPosition(pos[rand_positions[0]])
		objects[0].setPosition(pos[rand_positions[1]])
		objects[0].setPosition(pos[rand_positions[2]])
		objects[0].setPosition(pos[rand_positions[3]])
		objects[0].setPosition(pos[rand_positions[4]])
		objects[0].setPosition(pos[rand_positions[5]])
		objects[0].setPosition(pos[rand_positions[6]])
		objects[1].setPosition(pos[rand_positions[7]])

sceneOn(1)
Reply With Quote
 

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -7. The time now is 02:22 AM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2021, vBulletin Solutions, Inc.
Copyright 2002-2018 WorldViz LLC