WorldViz User Forum

WorldViz User Forum (https://forum.worldviz.com/index.php)
-   Vizard (https://forum.worldviz.com/forumdisplay.php?f=17)
-   -   How to link the Mainview to a child object (https://forum.worldviz.com/showthread.php?t=4563)

jacky 05-01-2013 10:22 AM

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)

Jeff 05-02-2013 09:51 AM

You'll need to specify that the link is getting the source object's position in global coordinates. Otherwise the link takes the position of box2 in it's parent's coordinate system which is fixed at [0,1,0].
Code:

link1=viz.link(box2,viz.MainView,srcFlag=viz.ABS_GLOBAL)


All times are GMT -7. The time now is 06:21 PM.

Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Copyright 2002-2023 WorldViz LLC