Vizard 8 » Reference » Scenes » Scene basics
8.0

Scene basics

A Vizard script can create multiple scenes, each with its own set of objects. When multiple scenes have been created, you can flip back and forth between them by setting the scene that's currently being rendered. By default things are added to the first scene (scene 1). You need to use viz.addScene if you want more than the default 6 scenes.

#Add an object to scene 1 (default)
duck = viz.addChild('duck.wrl')
duck.setPosition([1,1,5])

#Add an object to scene 2
wheelbarrow = viz.addChild('wheelbarrow.ive', scene=viz.Scene2)
wheelbarrow.setPosition([-1,1,5])

#Add keypresses to change between scenes 1 and 2
vizact.onkeydown( '1', viz.MainWindow.setScene, viz.Scene1 )
vizact.onkeydown( '2', viz.MainWindow.setScene, viz.Scene2 )

Duplicating, copying and cloning to another scene

You can copy, duplicate or clone an object to a different scene. The duplicate of an object (<node3d>.addParent(<parent>,<scene>)) will appear in the specified scene. Any transforms or changes in appearance to the original object will also be applied to the duplicate. If you copy an object to another scene, the copy ((<node3d>.copy()) will have the appearance of the original object when it was created but any subsequent changes to the original object's appearance will not effect the copy in the other scene. Copies are created independent of any position, orientation or scale transforms applied to the original object. So, even if you create a copy of an object that's 2 meters about the origin, the copy will appear at the origin. Clones (<node3d>.clone()) share the appearance of each other such that changing the appearance to any one clone will change the appearance of all the clones (although all their position, orientation, and scale transforms will be independent).

#Add a model to scene 1 (default)
soccerball = viz.addChild('soccerball.ive')

#Add a copy to scene 2
soccerballCopy = soccerball.copy(scene=viz.Scene2)

#Duplicate to scene 3
soccerball.addParent(viz.WORLD, scene=viz.Scene3)

#Add a clone to scene 4
soccerballClone = soccerball.clone(scene=viz.Scene4)

#Change the appearance of the original
soccerball.color(viz.RED)

#Apply a transform to the original
soccerball.addAction( vizact.spin(0, 1, 0, 90, viz.FOREVER) )

#Use number keys to switch scenes
for i in range(1,5):
    vizact.onkeydown( str(i), viz.MainWindow.setScene, i )

Windows on different scenes

You can also use different subwindows to render different scenes.

#Set the main window's scene to 2
viz.MainWindow.setScene(viz.Scene2)

#Add a subwindow set on scene 1 
duckWindow = viz.addWindow() 
duckView = viz.addView() 
duckWindow.setScene(viz.Scene1) 
duckWindow.setView(duckView) 

See also

In this section:

Adding fog

Scene Command Table

Other sections:

Viewpoints & windows basics

Window basics

Tutorial: 360 panoramas