WorldViz User Forum  

Go Back   WorldViz User Forum > Vizard

Reply
 
Thread Tools Rate Thread Display Modes
  #1  
Old 08-25-2005, 04:37 PM
shai shai is offline
Member
 
Join Date: Oct 2004
Posts: 29
question about avatar

Hey,

I want to have an avatar animation in my program and want to wait until the whole animation has finished and then let the program keep on running.

What is the easiest way to do this? Is there some function I can use (waitfor?)?

.
.
.
male.act(2)
#command that has to be executed AFTER male.act(2) has completed

thanks,

dominic
Reply With Quote
  #2  
Old 08-26-2005, 12:12 PM
farshizzo farshizzo is offline
WorldViz Team Member
 
Join Date: Mar 2003
Posts: 2,849
Hi,

There are many ways to do this. You can get the duration of the animation and then setup a timer to go off in that time. Or you can use callbacks to detect when the action has finished. Here's an example of using the callback method:
Code:
import viz
viz.go()

male = viz.add('male.cfg')
male.translate(0,0,5)

action2 = vizact.animation(2)

male.add(action2)

def actionend(obj,action,pool):
	if action == action2:
		print 'Action 2 is finished'

male.callback(viz.ACTION_END_EVENT,actionend)
Reply With Quote
  #3  
Old 08-26-2005, 01:35 PM
dominic dominic is offline
Member
 
Join Date: Aug 2005
Posts: 8
Hey,

Thanks for the reply, I guess I could try it that way.
Nevertheless, is there a way that I could do it without leaving a loop?

So something like:

x = 0
while (x < 5)
male.act(1)
ball.translate(x, 1, 1)
x++

so, that the ball wont move before the male has finished his animation? I am looking more something along the line of male.waitfor(action)

thanks,

dominic
Reply With Quote
  #4  
Old 08-26-2005, 01:40 PM
farshizzo farshizzo is offline
WorldViz Team Member
 
Join Date: Mar 2003
Posts: 2,849
Hi,

Is this code inside a director function? If it is, then you could do the following:
Code:
 male.act(1)
viz.waittime(male.getduration(1))
ball.translate(x, 1, 1)
Otherwise you can't do this in a loop since the wait command will stall the graphics engine.
Reply With Quote
  #5  
Old 08-26-2005, 01:53 PM
dominic dominic is offline
Member
 
Join Date: Aug 2005
Posts: 8
I tried this but that doesnt accomplish that the animation finishes before it translates the ball.

Now, the animation just is blocked until the waittime is done and after that, we are back to the original problem.

any other ideas? Or is the way to go the callback method?

thanks,

dominic
Reply With Quote
  #6  
Old 08-26-2005, 02:47 PM
farshizzo farshizzo is offline
WorldViz Team Member
 
Join Date: Mar 2003
Posts: 2,849
Hi,

If your code is inside a director function and you call waittime, then it will wait for the specified amount of seconds. The following sample demonstrates this. Run the script and press spacebar to start the director function.
Code:
import viz
viz.go()

male = viz.add('male.cfg')
male.translate(0,0,5)

def PerformAction():
	male.act(2)
	viz.waittime(male.getduration(2))
	print 'Action finished'

def onkeydown(key):
	if key == ' ':
		viz.director(PerformAction)

viz.callback(viz.KEYDOWN_EVENT,onkeydown)
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 12:29 AM.


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