WorldViz User Forum  

Go Back   WorldViz User Forum > Vizard

Reply
 
Thread Tools Rate Thread Display Modes
  #1  
Old 12-08-2005, 01:21 PM
pkhoosh pkhoosh is offline
Member
 
Join Date: Feb 2005
Posts: 21
Send a message via AIM to pkhoosh Send a message via Yahoo to pkhoosh
animation sequence

Hello,

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,

pete
Reply With Quote
  #2  
Old 12-09-2005, 10:37 AM
farshizzo farshizzo is offline
WorldViz Team Member
 
Join Date: Mar 2003
Posts: 2,849
Hi,

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.
Code:
import viz
viz.go()


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

viz.callback(viz.TIMER_EVENT,ontimer)
viz.starttimer(0,0,viz.FOREVER)
Reply With Quote
  #3  
Old 01-23-2006, 08:03 AM
pkhoosh pkhoosh is offline
Member
 
Join Date: Feb 2005
Posts: 21
Send a message via AIM to pkhoosh Send a message via Yahoo to pkhoosh
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,

pete
Reply With Quote
Reply


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


All times are GMT -7. The time now is 09:22 AM.


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