How to link the Mainview to a child object
Hi everyone,
I want to link the Mainview to the box2. The box2 is the child of box1. When the box1 changes its position and orientation, the box1 will follow it and the Mainview too. But it doesn't work. When I operate the position of box1. The Mainview doesn't move. Who knows the reasons? My script is below.
import viz
import vizact
import math
viz.go()
dojo = viz.addChild('dojo.osgb')
box1=viz.addChild('crate.osgb')
box1.setScale(0.1,0.1,0.1)
box1.setPosition(0,1.8,1)
box1.color(viz.RED)
box2=viz.addChild('crate.osgb')
box2.setPosition(0,1,0)
box2.color(viz.BLUE)
box2.setParent(box1)
link1=viz.link(box2,viz.MainView)
def position():
pos=box1.getPosition()
pos[0]=pos[0]+0.01
box1.setPosition(pos)
vizact.onkeydown('1',position)
|