Tutorial: Viewpoint control

This tutorial will show you the different ways you can control the viewpoint. In this example the viewer will be placed inside a car. The user will press the arrow keys to move the car around and use the mouse to look around.

 

Note: this content is discussed in more detail in the reference section.

 

Setting up a vehicle

This tutorial will show you the different ways you can control the viewpoint. In this example the viewer will be placed inside a car. The user will press the arrow keys to move the car around and use the mouse to look around.

Start the script

Click here for instructions on creating an empty Vizard script.

 

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

 

 

import viz
viz.go()
viz.clearcolor(0.5,0.5,1)

 

Before we add any objects, let's create some variables that will control how fast the viewpoint will move and turn:

 

MOVE_SPEED = 5
TURN_SPEED = 60

 

This isn't required, but it makes it easier to quickly change the movement and turning speed.

Now let's add some 3d models to your world. Add the following code:

 

car = viz.add('mini.osgx')
viz.add('tut_ground.wrl')

 

This will add the car and ground.

 

 

 

 

 

 

 

Setting up a vehicle

Forward/back motion

Left/right turning

Getting viewpoint information

Head and body motion