WorldViz User Forum

WorldViz User Forum (
-   Vizard (
-   -   animation sequence (

pkhoosh 12-08-2005 01:21 PM

animation sequence

I am using timers to animate an object and I make it work by using different keys to initiate each different animation. I want to automate the playing of an animation sequence without having to press a key each time I want a different animation. I also want each animation to play for a minute.

Any ideas if about how to do this most elegeantly?

many thanks,


farshizzo 12-09-2005 10:37 AM


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):


pkhoosh 01-23-2006 08:03 AM

Thanks for the help. I couldn't use the vizact because I wanted to show a series of static images; vizact doesn't really accomplish this and is more than I needed, as far as I could tell. The skeleton code you gave helped me accomplish what I needed, to an extent.

The other thing I want to implement is an animation that repeats every minute. Whereas the other images being displayed were just static and changed every minute, the thing that is going to change now is an object that is continually rotating. This rotation is controlled by a timer that repeats very often (0.01 seconds). I was thinking of just making a 'wrapper' timer that fires every minute, in turn 'calling' the timer that controls the actual rotation.

When I try to use the same logic as that for the static images, I get a Python warning and my virtual world crashes.

Many thanks,


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

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