Vizard 7 » Tutorials & Examples » Vizard Introduction » Script
7.6

Vizard Script

For this section of the tutorial you'll run a simple Vizard script that opens a render window on a desktop monitor. The first thing to know about scripting in Vizard is that it’s all done in the Python programming language. Python, the world’s most accessible and popular scripting language, is known for being quick and easy to learn. As an open source language, Python has a large user community and a host of free resources. Vizard's libraries of commands for creating virtual worlds and connecting to VR devices are called from Python. At the lower level, however, the Vizard engine executes everything using C++ for high performance.

Tutorial Folder Setup

First create a folder (e.g. Vizard Tutorial) on your desktop to save the files that will be used in this tutorial. Download the lobby.osgb model and save it into the tutorial folder.

Create a script

Create a new script by selecting File > New Vizard File and copy the following lines into it:

import viz
import vizfx

viz.go()
lobby = vizfx.addChild('lobby.osgb')
viz.MainView.getHeadLight().disable()

The code above imports two of Vizard's command libraries, opens a Vizard application window, and loads a scene model. Select File > Save, browse to the folder location and enter vizard_intro_tutorial.py for the file name. To run the script use the run icon in the standard toolbar, select the Script > Run menu option, or use the F5 keyboard shortcut.

The script currently uses Vizard's built-in mouse navigation. Set the mouse cursor to the middle of the render screen and then press and hold the left mouse button to drive the viewpoint. The speed is increased when the cursor is moved farther away, either up or down, from the center of the screen:

When you're finished exploring the scene, press the Esc button to close the render window.

Introduction

Script

Scene Model

Hardware Connection

Complete Application