PDA

View Full Version : More on avatar animations


vjonshih
09-20-2004, 03:49 PM
Hi there,

This is a tough question to explain in text, but I'll try my best:

In regards to this this previous post, (http://www.worldviz.com/forum/showthread.php3?s=&threadid=190)

I attempted to start a timer to freeze an avatar's actions in the middle of an animation -- so the code went something like this:

#Perform the action
male.act(7)
#Start a timer to freeze the avatar after 85% of the action has #been performed
viz.starttimer(FREEZE_AVATAR,male.getduration(7) * 0.85)

However, I noticed that the timing of the action's duration was not consistent -- each time I ran the script, the avatar would stop at a different point in the animation. Similarly, if I removed the male.getduration(7) * 0.85 parameter and just simply put 1.5 (for 1.5 seconds), 1.5 seconds seemed to be measured differently each time I ran the script. Is there a way to get around this and to get a standardized measure of time?

Thanks a lot in advance!

farshizzo
09-20-2004, 04:10 PM
Hi,

What framerate does your script run at? If your framerate is too low then a lot of time based functions can act rather inconsistently. Also, how inconsistent were the timings? An inconsistency of a frame or so is to be expected.

vjonshih
09-20-2004, 04:21 PM
Thanks for the reply -- I ran it again and there seems to be no more timing issues.

I have one more question regarding time:

We made a script that uses a timer callback function simply displays a running clock in the world (going from 0:00 to 0:01, etc.) and the time runs much faster than realtime. How do we make the running clock run in realtime?

Thanks!

farshizzo
09-20-2004, 04:37 PM
Hi,

Are you running this script on a laptop computer? Vizard uses CPU clockspeed to determine elapsed time, and most laptops have variable CPU speeds in order to save power, which causes inconsistencies in timing.

If you aren't using a laptop then I've included a sample script which displays the elapsed time on the screen. Make sure you are doing something similar to this:import viz
viz.go()

text = viz.add(viz.TEXT3D,'0',viz.SCREEN)
text.translate(0.5,0.5)
text.time = 0

def ontimer(num):
text.time += viz.elapsed()
text.message('%d::%.2f'%(int(text.time/60.0),text.time%60.0))

viz.callback(viz.TIMER_EVENT,ontimer)
viz.starttimer(0,0.01,viz.FOREVER)