View Single Post
  #2  
Old 07-22-2008, 12:25 PM
farshizzo farshizzo is offline
WorldViz Team Member
 
Join Date: Mar 2003
Posts: 2,849
You can use the vizinfo module to display an information box. You can use the viz.MainWindow.worldToScreen command to convert world coordinates to screen coordinates, in order to position the info box near the avatar. Here is some sample code that shows how to accomplish this:
Code:
import viz
viz.go()

#Create avatar
female = viz.add('vcc_female.cfg',euler=(180,0,0),pos=(0,0,6))

#Create info box that is aligned to lower left corner
import vizinfo
info = vizinfo.add('')
info.alignment(vizinfo.LOWER_LEFT)

#Setup timer to position info box near avatar head
def UpdateInfoPosition():
	m = female.getBone('Bip01 Head').getMatrix(viz.AVATAR_WORLD)
	m.preTrans(0,0.2,0)
	x,y,z = viz.MainWindow.worldToScreen(m.getPosition())
	info.translate(x+0.03,y+0.02)
	info.visible(z>0)
vizact.ontimer(0,UpdateInfoPosition)

#Use the following code to change the message of the box
info.message('hello')
Reply With Quote