Amazon VERSION 2.0V1 Uživatelská příručka Strana 164

  • Stažení
  • Přidat do mých příruček
  • Tisk
  • Strana
    / 264
  • Tabulka s obsahem
  • KNIHY
  • Hodnocené. / 5. Na základě hodnocení zákazníků
Zobrazit stránku 163
164
A Group Node Example
The following stand alone example produces a group node containing a network that produces a Scene Graph with
sphere and cube locations. It uses only Nodegraph API calls covered by this chapter. There is no access to the
generated Scene Graph from outside of the group node.
# Constants
TIME = 0
HALF_DISTANCE_APART = 1.0
# Create the group at root level
root = NodegraphAPI.GetRootNode()
group = NodegraphAPI.CreateNode('Group', root)
# Create the sphere at group level
sphere = NodegraphAPI.CreateNode('PrimitiveCreate', group)
sphere.setName( 'Sphere' )
sphere.getParameter( 'name' )\
.setValue( "/root/world/geo/sphere", TIME )
# Set the type to sphere
sphere.getParameter( 'type' ).setValue( 'sphere', TIME )
sphere.getParameter( 'transform.translate.x' ).\
setValue( HALF_DISTANCE_APART, TIME )
NodegraphAPI.SetNodePosition(sphere, ( -100, 100 ) )
# Create the cube
cube = NodegraphAPI.CreateNode( 'PrimitiveCreate', group )
cube.setName( 'Cube' )
cube.getParameter( 'name' ).\
setValue( "/root/world/geo/cube", TIME )
# Set the type to cube
cube.getParameter( 'type' ).setValue( 'cube', TIME )
cube.getParameter( 'transform.translate.x' ).\
setValue( - HALF_DISTANCE_APART, TIME )
NodegraphAPI.SetNodePosition( cube, ( 100, 100 ) )
# Create a Merge node at group level
merge = NodegraphAPI.CreateNode( 'Merge', group )
# Connect the two PrimitiveCreate nodes to a Merge node
mergeSphere = merge.addInputPort( 'sphere' )
mergecube = merge.addInputPort( 'cube' )
mergeSphere.connect( sphere.getOutputPort( 'out' ) )
mergecube.connect(cube.getOutputPort( 'out' ) )
# Rename our merge node to 'Result' to make it clear that
# this is the final result.
23 NODEGRAPH API | GROUP NODES
Zobrazit stránku 163
1 2 ... 159 160 161 162 163 164 165 166 167 168 169 ... 263 264

Komentáře k této Příručce

Žádné komentáře