WorldViz User Forum  

Go Back   WorldViz User Forum > Vizard

Reply
 
Thread Tools Rate Thread Display Modes
  #1  
Old 11-02-2008, 07:02 AM
znchb znchb is offline
Member
 
Join Date: Sep 2008
Posts: 21
Question How to use 'time function' to control the balls appear separately?

# I want to show balls on the screen one by one, not all the balls appear immediately.
# could you please help me to use the time function to control it. Appreciate.

import viz
viz.go()

OriginalBall = viz.add('ball.wrl')

for x in [0, 0.2, 0.4, 0.6, 0.8]: ## nested loop
for y in [0, 0.3, 0.6, 0.9]:
ball = OriginalBall.copy() ##use the copy() to save cpu resource
ball.translate(2+x, 2+y, 2)
ball.setScale(0.02,0.02,0.02)
Reply With Quote
  #2  
Old 11-03-2008, 12:01 PM
Jeff Jeff is offline
WorldViz Team Member
 
Join Date: Aug 2008
Posts: 2,458
this code adds the balls to an array and initially makes them invisible.
the timer goes off every half second and calls a function that makes one ball visible each time

Code:
import viz
viz.go()

OriginalBall = viz.add('ball.wrl')

viz.MainView.setPosition([-2,2.5,-2])
viz.MainView.setEuler([45,0,0])


balls = []
for x in [0, 0.2, 0.4, 0.6, 0.8]: ## nested loop
	for y in [0, 0.3, 0.6, 0.9]:
		ball = OriginalBall.copy() ##use the copy() to save cpu resource
		ball.translate(2+x, 2+y, 2)
		ball.setScale(.2,.2,.2)
		ball.visible(viz.OFF)
		balls.append(ball)


number = 0
def showBall():
	global number
	balls[number].visible(viz.ON)
	number +=1
	
vizact.ontimer2(.5,len(balls)-1,showBall)
Is this what you wanted to do?
The next time you post code use the code tags so that the indentation is preserved
Reply With Quote
Reply

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
How to wirte words on a BillBoard? znchb Vizard 8 11-02-2008 07:04 AM
timer question Elittdogg Vizard 5 10-10-2007 02:49 PM


All times are GMT -7. The time now is 11:48 PM.


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