Building Virtual Environments - Navigation

FOV and aspect ratio of the camera
Ready-made navigation behaviors
Principles of the navigation behaviors
Making your own navigation behaviors


Designing an environment:
Balance, Scale, Proportion, Unity, Emphasis, Rhythm, Harmony

Where's the Design in Level Design? Part I

Where's the Design in Level Design? Part 2

Navigating the environment:

The camera

In the three images below, the camera is in the exact same position. The focal length and aspect ratio has been changed. The gray cube is a reference object for consideration of the size or height of a person in the environment. The camera's height has been adjusted to match the height of a person's eyes in the scene.


left image: camera with 54 degree field of view.
center: camera with 90 degree fov.
right: 90 degree fov and a 16:9 aspect ratio.

The field of view (focal length) of your camera has a dramatic impact on the sense of scale and depth in the environment.
Aspect ratio of the camera can also be adjusted to affect the overall sense of composition.

In the level editor, double-click your camera or right-mouse to choose "setup" to display the camera setup panel.
Here you can adjust field of view and aspect ratio.



Ready-made navigation behaviors:




Two behavior graphs (BBs) have been provided to get you started with navigation:
  • From the BVE_resources directories, drag and drop one of the camera nmo files into the scene.
  • In the perspective view menu, switch to the new camera view.
  • In the schematic panel, the behavior graph in the camera script has three settings: speed of translation and rotation, and the height of the camera above its parent object. The height setting is especially useful when using the "object keep on floor" BB mentioned below.
  • If you want the camera to "slide" against obstacles such as walls, go to the level manager panel and multi-select the objects that are to be obstacles and put them in a group using the "create group" icon (to the left). Name the group anything (e.g. "collision group"). Back in the schematic panel, double-click the "object slider" behavior block (BB) and set the group name accordingly. Set the radius option to the distance you want the camera to stay away from the obstacles (determine this by running the scene and adjusting accordingly).
  • Depending upon your application, you may want to use the "object keep on floor" BB (if you have multiple floors or stairs). In the level manager, select all objects that are to be floors and with the right mouse button select "add attributes" and add the "floor" attribute to them. Other aspects of the "object keep on floor" BB are covered in class, but you can use the right-mouse-button "html help" on the BB as well.
  • From the level manager, you can double-click the new camera to open its setup panel. Here you can adjust the field of view of the camera.

Principles of the ready-made navigation behaviors

For both examples, one of the most important principles is that of motion on an object's LOCAL AXIS versus motion of the object on the WORLD AXIS.

Mouse-look cam BB:


For the mouse-look camera, the mouse movement on X and Y is linked to the rotation of two different objects:

  • mouse X (yellow) is linked to the WORLD Y rotation of the CAMERA'S PARENT OBJECT (a "3D frame" in virtools, or "Null" object).
  • mouse Y (red) is linked to the LOCAL X rotation of the CAMERA.

Using the keyboard controls:

  • To move the camera forward, the camera's PARENT OBJECT is moved on its LOCAL Z AXIS.
  • To move the camera sideways, the camera's PARENT OBJECT is moved on its LOCAL X AXIS.

This arrangement allows the camera to tilt up and down on its own axis, while the motion of the camera always remains on a horizontal plane (driving).

Mouse-Fly BB:



For the mouse-fly camera, the links to rotations are the same as above, except:

Using the keyboard controls to move the camera

  • To move the camera forward, the camera's PARENT OBJECT is moved on on the CAMERA'S LOCAL Z AXIS (blue).
  • To move the camera sideways, the camera's PARENT OBJECT is moved on its LOCAL X AXIS.

This method avoids the introduction of weird banking effects that can occur after a sequence of rotations while flying. It insures the camera will always remain upright.

In Virtools, to move one object based on another object's local axis, use the REFERENTIAL parameter found in most of the transformation behavior blocks.


Making your own navigation behaviors



The image above shows a simple navigation script that can work well:

The Switch On Key BB will activate its outputs based on four different key presses.

  1. Translates the object forward on its local Z axis (0, 0, 1).
  2. Translates the object backward on its local Z axis (0, 0, -1).
  3. Rotates the object on the world Y axis (0, 1, 0) at a speed of 2 degrees per frame.
  4. Rotates the object in the opposite direction on the world Y axis (0, 1, 0) at negative 2 degrees per frame (-2).

Since the object is translated on its LOCAL axis, it will always move forward in the same direction it is facing. The rotation keys can be pressed at the same time as the forward/back keys, so you can turn graceful curves as you drive.

More sophisticated navigation systems can be created. Study the ready-made behavior graphs as well as the examples in the Virtools resource directories. There are lots of other BBs that can be used, as well as making use of hierarchies and the use of referential and local axes. Navigation systems can get very complex depending upon the application. A good way to start is to plot out the scripting you might need in the form of pseudo code.