mergeLinking.py

This script demonstrates orientation and position information that is provided by different sources.

 

import viz
import vizact

viz.setMultiSample(4)
viz.fov(60)
viz.go()

import vizinfo
info = vizinfo.add( 'The orientation and position information provided by the source argument \nin the link function can come from different nodes.  \nThe orientation of the volleyball and the position of the soccerball \nare combined to provide source information for the basketball.' )
info.translate( [.98, .2] )

#Create moving node
nodeMove = viz.addChild( 'soccerball.osgb', pos = [0,1.8,2] )
nodeMove.addAction( vizact.sequence( vizact.move(0,1,0,1), vizact.move(0,-1,0,1), viz.FOREVER ) )

#Create spinning node
nodeSpin = viz.addChild( 'volleyball.osgb', pos = [0,1.5,2] )
nodeSpin.addAction( vizact.spin( 0, 1, 0, 90, viz.FOREVER ) )

#Create an node that will move and spin
nodeMerge = viz.addChild( 'basketball.osgb' )
moveAndSpinSource = viz.mergeLinkable( nodeMove, nodeSpin ) #new VizLinkable object
mergedLink = viz.link( moveAndSpinSource, nodeMerge ) #link source to nodeMerge
mergedLink.postTrans( [1, 0, 0] ) #move nodeMerge to the right 1 meter in world coordinates

viz.addChild( 'ground.osgb' )
viz.clearcolor( viz.GRAY )