View Single Post
Old 12-09-2005, 10:37 AM
farshizzo farshizzo is offline
WorldViz Team Member
Join Date: Mar 2003
Posts: 2,849

What kind of animations are you performing? Could they be substituted with any existing vizact actions? If so, this would be the easiest and most elegant way to accomplish this.

If not, then you could use the following code as a guideline. It creates a different function for each animation. Then it uses a list to cycle through each animation. Let me know if it isn't clear enough.
import viz

def update1():
	print 'Update 1'
def update2():
	print 'Update 2'
def update3():
	print 'Update 3'

anim_seq = [update1,update2,update3] #List of animation functions
anim_time = 60 #Time remaining on current animation
anim_index = 0 #List index of current animation

def update_animation():
	global anim_time, anim_index
	anim_seq[anim_index]() #Call current animation function
	anim_time -= viz.elapsed() #Update remaining time
	if anim_time < 0: #Check if animation finished
		anim_time = 60 #Reset animation time
		anim_index = (anim_index + 1) % len(anim_seq) #Increment animation index

def ontimer(num):

Reply With Quote