View Single Post
  #6  
Old 06-07-2005, 05:43 PM
farshizzo farshizzo is offline
WorldViz Team Member
 
Join Date: Mar 2003
Posts: 2,849
Let me know if this example script works. There should be two avatars in front of you who will be tracking a ball that is moving back and forth across the screen.
Code:
import viz
viz.go()

viz.add('tut_ground.wrl')

ball = viz.add('white_ball.wrl')

ball.add(vizact.sequence(vizact.goto(-2,1,0),vizact.goto(2,1,0),viz.FOREVER))

avatar1 = viz.add('male.cfg')
avatar1.translate(-2,0,3)
avatar1.rotate(180,0,0)

avatar2 = viz.add('female.cfg')
avatar2.translate(2,0,3)
avatar2.rotate(180,0,0)

dummy = viz.add(viz.GROUP)

def lookatpoint(avatar,point):
	_headbone = avatar.getbone('skel_Head')
	_headbone.lock()
	dummy.translate(_headbone.get(viz.POSITION,viz.ABSOLUTE_WORLD))
	dummy.lookat(point)
	_headbone.rotatequat(dummy.get(viz.QUAT), viz.ABSOLUTE_WORLD)

def ontimer(num):
	pos = ball.get(viz.POSITION)
	lookatpoint(avatar1,pos)
	lookatpoint(avatar2,pos)

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

viz.move(0,0,-5)
Reply With Quote