Vizard 8 » Tutorials & Examples » Viewpoints & windows » Windows & views » Tutorial: Windows & views
8.0

Tutorial: Windows & Views

This tutorial will show you how to create subwindows with separate views of the scene. In this example we will load a maze model and create two subwindows, one that shows a birds-eye-view of the scene and another which acts as a rear-view mirror.

This content is discussed in more detail in the reference section.

Start the script

If you have trouble getting the code in this tutorial to work, you can find the complete example script windowsAndViews.py in the \tutorials\views directory.

 

Add the following code to load the maze:

import viz

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

maze = viz.addChild('maze.osgb')

Now lets add the subwindow which will act as the birds-eye-view. We'll also increase the field of view to see more of the scene. Add the following code to the end of your script:

BirdEyeWindow = viz.addWindow()
BirdEyeWindow.fov(60)

Now run your script.

 

You will see the maze as usual, but there will be a smaller window in the upper right corner. For now the subwindow shows the exact same view as the main window. To have it show a birds-eye-view we need to create a viewpoint for the subwindow.

 

A viewpoint controls where the camera is positioned and pointed at. Add the following code to create a new viewpoint:

BirdEyeView = viz.addView()

If you run your script nothing will have changed, that is because we need to assign the new viewpoint to the subwindow. The following code will tell vizard to attach the new viewpoint to our subwindow:

BirdEyeWindow.setView(BirdEyeView)

Now that the viewpoint is attached to the subwindow we need to place it above the scene and have it point downward.

 

The following code will set the position of the viewpoint at a height of 25 meters and rotate it so that it points straight down:

BirdEyeView.setPosition([0,25,0])
BirdEyeView.setEuler([0,90,0])

Run your script to see the new viewpoint.

Adding a bird's eye view

Adding a rear view window