WorldViz User Forum

WorldViz User Forum (https://forum.worldviz.com/index.php)
-   Vizard (https://forum.worldviz.com/forumdisplay.php?f=17)
-   -   Problem with getting duration of walkto() (https://forum.worldviz.com/showthread.php?t=1028)

ghazanfar 03-21-2007 03:59 AM

Problem with getting duration of walkto()
 
We are trying to let avatars walk to each other, after that face to each other and wave (say hello).

We have a problem with letting the avatars face to each other, because deciding which angle they have to rotate happens before the agents are done walking.

Does anyone know how to get the duration of walking to a certain point, so we can get the angle to rotate after the walking has finished? Or just letting the program wait until the walking has finished and the continue?

Our current code is the following:

if (ag1=='a1' and ag2=='a3'):
walk_over = male.walkto(meetingpoint[0]+1,meetingpoint[1],meetingpoint[2])
#This line calls that animation.
male.act(walk_over)

#THIS IS WHAT WE HAVE TRIED UNTIL NOW
#male_wave_duration = male.getduration(walk_over)
malepd=male.getduration(5) # THIS WORKS
print "malepd", malepd
#malewd2=male.getduration(walkto)
#print "malewd2", malewd2 # THIS RETURNS AN ERROR
malewd=male.getduration(male.walkto)
print "malewd", malewd # THIS RETURNS AN ERROR
#viz.starttimer(1,malewd )
#print "male_wave_duration", malewd
#wait until walk_over is ready

pos=male.get(viz.POSITION)
pos2=male1.get(viz.POSITION)
rotate_degrees = vizmat.AngleToPoint(pos[0],pos[2],pos2[0],pos2[2])
male.rotate(0,1,0,rotate_degrees)
male.act(5)
walk_over2 = male1.walkto(meetingpoint[0],meetingpoint[1],meetingpoint[2])
male1.act(walk_over2)
pos=male1.get(viz.POSITION)
pos2=male.get(viz.POSITION)
rotate_degrees = vizmat.AngleToPoint(pos[0],pos[2],pos2[0],pos2[2])
male1.rotate(0,1,0,rotate_degrees)
male1.act(5)

farshizzo 03-21-2007 01:00 PM

The .getduration() function returns the duration of built-in animations, not actions. There is no way to get the duration of an action, but you can register a callback to notify you when an action is finished. Here is some sample code:
Code:

import viz
viz.go()

male = viz.add('male.cfg')

walk = vizact.walkto(0,0,10)

male.add(walk)

def onActionEnd(obj,action,pool):
        if obj == male and action == walk:
                print 'Male finished walking'
                viz.clearcolor(viz.SKYBLUE)
viz.callback(viz.ACTION_END_EVENT,onActionEnd)


ghazanfar 03-22-2007 09:17 AM

Do you know how to send a value for 'pool' to the onActionEnd function?

We are trying to use the function in this function:

if (ag1=='a1' and ag2=='a3'):
walk_over = male.walkto(meetingpoint[0]+1,meetingpoint[1],meetingpoint[2])
#This line calls that animation.
male.act(walk_over)
walk_over2 = male1.walkto(meetingpoint[0],meetingpoint[1],meetingpoint[2])
male1.act(walk_over2)
viz.callback(viz.ACTION_END_EVENT,onActionEnd)

And the onActionEnd function currently looks like this:

def onActionEnd(obj,action,pool):
if obj == male and action == walk and pool == malemale1:
pos=male.get(viz.POSITION)
pos2=male1.get(viz.POSITION)
rotate_degrees = vizmat.AngleToPoint(pos[0],pos[2],pos2[0],pos2[2])
male.rotate(0,1,0,rotate_degrees)
male.act(5)

farshizzo 03-22-2007 10:22 AM

You probably won't need to worry about the pool parameter. When you add an action, you can specify a pool number. This allows you to execute actions in parallel by adding them to different pools. The default pool is 0.

ghazanfar 03-23-2007 09:17 AM

OK thanks we understand this function now.
We have decided to solve our problem otherwise.

We created a timer that would count every step, and every 5 steps the next step would be done. This way, we could say that the avatar had to turn 3 steps after the walking action, and also give the other avatar to turn to as a variable.


All times are GMT -7. The time now is 03:14 AM.

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