WorldViz User Forum  

Go Back   WorldViz User Forum > Vizard

 
 
Thread Tools Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #2  
Old 03-09-2009, 01:05 PM
Jeff Jeff is offline
WorldViz Team Member
 
Join Date: Aug 2008
Posts: 2,471
This will turn the scene's visibility on and off based on a timer and reset the objects randomly in one of nine specified positions when the scene comes back

check out the Vizard docs to learn how to write to files so you can record user responses.

Code:
import viz
viz.go()

viz.MainView.move(0,0,-10)

#keep nine positions in an array
pos = [[-4,0,0],[-3,0,0],[-2,0,0],[-1,0,0],[0,0,0],[1,0,0],[2,0,0],[3,0,0],[4,0,0]]

box = viz.add('box.wrl')
ball = viz.add('ball.wrl')
whiteball = viz.add('white_ball.wrl')


import random
def sceneOn():

	#set objects to 3 different random positions
	rand_numbers = [0,1,2,3,4,5,6,7,8]
	random.shuffle(rand_numbers)

	box.setPosition(pos[rand_numbers[0]])
	ball.setPosition(pos[rand_numbers[1]])
	whiteball.setPosition(pos[rand_numbers[2]])

	viz.MainScene.visible(viz.ON)
	vizact.ontimer2(2,0,sceneOff)


def sceneOff():
	
	viz.MainScene.visible(viz.OFF)
	vizact.ontimer2(2,0,sceneOn)

sceneOn()
Reply With Quote
 


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
Sharing Files on SourceForge farshizzo Vizard 1 09-03-2012 11:18 AM
Project .avi or .mpeg file pattie Vizard 2 02-06-2007 08:09 AM


All times are GMT -7. The time now is 03:56 PM.


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