Lab 4: Navigation
CS 445: Computer Graphics, Fall 2017


Due Date: be ready to demo at the beginning of lab Monday, Oct 2

Goals

References

Overview

Camera controls enable a user to navigate around the 3D scene. There are various ways of doing this. For example, a "fly-through" allows the user to move through a scene as though one was at the controls of an airplane. Another approach is to allow the user to "dolly, tumble, and track" which are the typical navigation tools used in Maya. In this assignment, you will first implement the fly-through controls using keyboard presses. You will then implement dolly, tumble, and track using mouse controls.

In class, we will talk about the view matrix transform (called V) which transforms vertices from World to Camera coordinates. This is the product of a rotation and translation. In the code, the global variable "viewRotation" is the rotation component of V. It is initialized in the calcUVN method based on the values of VPN and VUP. The variable called "eye" is the location of the camera in World coordinates which can be used to generate the translational component of V:

View matrix: V = viewRotation * EyeTranslation

In the display method, you need to initialize model view matrix (mv) to the value of V.

All of the camera controls (key or mouse) operate by updating only two variables: the camera location stored in the variable "eye" and the camera orientation, stored in "viewRotation"!

Starter Code

Download the program Lab4Navigation.zip. This program is similar to what you did on Lab 3:
  • Run the program. It should look like the image on the left. Navigation instructions are included in the html window. Right now they don't work. Your job in this lab is to get these working!
  • The actions of the cameraSetup function which was previously in render_scene.js has been moved to the Camera class.
  • The Camera class contains the eye and viewRotation variables.
  • The camera is controlled by mouse and key events. The setKeyEventHandler function which was previously in render_scene.js has been removed from render_scene.js and replaced by eventHandlers.js which, in turn, calls functions in the camera class.
  • The code you need to modify is mostly in Camera.js and the render function in render_scene.js.

Part 1: Fly Through Controls

In this part of the lab, you will implement the fly through keyboard controls. Look for the "TO DO" comments in the code.

Part 2: Maya Mouse Controls

In this part of the lab, you will implement the mouse controls for dolly, tumble, and track that are found in the motion function in Camera.js :

The mouse controls are set up as follows:

In class, we will open up Maya to see how they work. The Track and Dolly are quite easy. The Tumble is difficult and will take a bit of thinking!

To Hand In

By the beginning of lab on the due date above, be ready to demonstrate your finished program.