WorldViz User Forum  

Go Back   WorldViz User Forum > Vizard

 
 
Thread Tools Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #3  
Old 10-20-2008, 12:39 AM
ptjt255 ptjt255 is offline
Member
 
Join Date: Oct 2008
Posts: 24
Thanks very much for your reply, unfortunately I get an error message:

randomCube = random.choice(cubeList)
AttributeError: 'module' object has no attribute 'choice'

I suspect this has something to do with the way I have set this up?

# Add a cube
cube1 = viz.add('box.wrl')

# Positions the first row of cubes
cube1.setPosition(0,0)
cube2 = cube1.copy()
cube2.setPosition(-3,0)
cube3 = cube1.copy()
cube3.setPosition(3,0)

# Position the second row of cubes
cube4 = cube1.copy()
cube4.setPosition(0,2)
cube5 = cube1.copy()
cube5.setPosition(-3,2)
cube6 = cube1.copy()
cube6.setPosition(3,2)

# Position the third row of cubes
cube7 = cube1.copy()
cube7.setPosition(0,4)
cube8 = cube1.copy()
cube8.setPosition(-3,4)
cube9 = cube1.copy()
cube9.setPosition(3,4)

# Define speed and rotation of cubes
def mytimer(rotate):
global angle
angle = angle + (speed * viz.elapsed())
cube1.rotate(0, 5, 20, angle)
cube2.rotate(0, 5, 20, angle)
cube3.rotate(0, 5, 20, angle)
cube4.rotate(0, 5, 20, angle)
cube5.rotate(0, 5, 20, angle)
cube6.rotate(0, 5, 20, angle)
cube7.rotate(0, 5, 20, angle)
cube8.rotate(0, 5, 20, angle)
cube9.rotate(0, 5, 20, angle)

# Opens file 'response.txt' in write mode
file = open('reaction_time', 'a')

# Sets up looming characterics for cube1
backAndFourth1 = vizact.sequence([vizact.goto(0, 0, -1, 1), vizact.goto(0, 0, 0, 1)])


# Define a function that records reaction times in response to a looming cube
def SaveData():
#Data for getting values from wait conditions
d = viz.Data()
while True:
#Wait random amount of time
yield viztask.waitTime(2)
# Cube 1 looming
cube1.addAction(backAndFourth1)
#Wait for next frame to be drawn to screen
yield viztask.waitDraw(d)
# Calculate reaction time
displayTime = d.time
#Wait for keyboard reaction
yield viztask.waitKeyDown(None,d)
reactionTime = d.time - displayTime
# Create the output string
out = str(reactionTime) + '\t''\n'
# Write the string to the output file
file.write(out)
print 'Reaction time:',reactionTime
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

Similar Threads
Thread Thread Starter Forum Replies Last Post
retrieve Object names Geoffrey Vizard 11 12-11-2009 04:26 AM
Can you link the position of a tracker to the orientation of an object? michaelrepucci Vizard 1 09-19-2008 10:23 AM
Getting object position in screen coordinates v-Salik Vizard 1 10-19-2007 03:41 PM
picking problem... k_iwan Vizard 2 07-27-2007 07:57 PM
rotate to object jargon Vizard 1 08-08-2005 12:20 PM


All times are GMT -7. The time now is 06:50 AM.


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