Vizard 7 » Tutorials & Examples » Example scripts » Linking » Link merging
7.7

Link merging

\examples\linking\mergeLinking.py

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

"""
The orientation and position information provided by the source argument
in the link function can come from different nodes.
The orientation of the volleyball and the position of the soccerball
are combined to provide source information for the basketball.
"""
import viz
import vizact

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

import vizinfo
vizinfo.InfoPanel(align=viz.ALIGN_LEFT_BOTTOM)

#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.SLATE )