WorldViz User Forum  

Go Back   WorldViz User Forum > Vizard

Reply
 
Thread Tools Rate Thread Display Modes
  #1  
Old 03-21-2007, 03:59 AM
ghazanfar ghazanfar is offline
Member
 
Join Date: Mar 2007
Posts: 11
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)
Reply With Quote
  #2  
Old 03-21-2007, 01:00 PM
farshizzo farshizzo is offline
WorldViz Team Member
 
Join Date: Mar 2003
Posts: 2,849
The <avatar>.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)
Reply With Quote
  #3  
Old 03-22-2007, 09:17 AM
ghazanfar ghazanfar is offline
Member
 
Join Date: Mar 2007
Posts: 11
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)
Reply With Quote
  #4  
Old 03-22-2007, 10:22 AM
farshizzo farshizzo is offline
WorldViz Team Member
 
Join Date: Mar 2003
Posts: 2,849
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.
Reply With Quote
  #5  
Old 03-23-2007, 09:17 AM
ghazanfar ghazanfar is offline
Member
 
Join Date: Mar 2007
Posts: 11
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.
Reply With Quote
Reply

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

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 04:54 PM.


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