View Single Post
  #4  
Old 04-03-2008, 10:42 AM
farshizzo farshizzo is offline
WorldViz Team Member
 
Join Date: Mar 2003
Posts: 2,849
You need to remove the viz.RELATIVE_LOCAL from the viz.add command. When adding text the 3rd parameter is the parent the text should be attached to. By default it is viz.WORLD. If you want to attach some text to an existing object try the following example:
Code:
import viz
viz.go()

box = viz.add('box.wrl')
box.add(vizact.spin(0,1,0,90,viz.FOREVER))
box.translate(0,1,5)

#Add text as child of box
A = viz.add(viz.TEXT3D,'A', box)
A.alignment(viz.TEXT_CENTER_CENTER)

#Text translation will be relative to boxes local coordinate system
A.translate(0,.985,0)
A.color(0,0,0)
A.scale(.2, .2, 2)

viz.clearcolor(viz.GRAY)
All text object transformations (translate,rotate,scale) will now be relative to the local coordinate system of the box.

In your case, are the boxes static or will they be moving around? If the boxes are static, then you don't need set the parent of the text. Just add the text to viz.WORLD and place it where the boxes are. If the boxes will be moving around then add the text as children of the boxes and position the text locally, relative to the box.
Reply With Quote