View Single Post
  #2  
Old 09-03-2010, 01:03 PM
Jeff Jeff is offline
WorldViz Team Member
 
Join Date: Aug 2008
Posts: 2,471
When you scale the bar it's center will remain in the same position. You could either change the bar's center to be at the end that will touch the wall or re-position the bar after scaling it. The following code moves an object's center so it will stay aligned with the ground when scaled:
Code:
import viz
viz.go()

ground = viz.add('tut_ground.wrl')
box = viz.add('box.wrl',pos=[0,0.5,0],scale=[0.2,1,0.2])
box.center(0,-0.5,0)

vizact.onkeydown('1',box.setScale,0.2,1,0.2)
vizact.onkeydown('2',box.setScale,0.2,1.5,.2)
vizact.onkeydown('3',box.setScale,0.2,2,0.2)
vizact.onkeydown('4',box.setScale,0.2,2.5,0.2)


import vizcam
viz.cam.setHandler(vizcam.PivotNavigate(center=[0,1,0],distance=6))

Last edited by Jeff; 09-03-2010 at 01:06 PM.
Reply With Quote