Lab 4: Moving the Camera
CS 445: Computer Graphics, Fall 2014


Due Dates: 5pm, Tuesday, Oct 21

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 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"!

Sample Code

Download the Car Navigation Codeblocks Project. This program has a single car that can move forward or backward (press f or b). Coordinate axes are included to help you see the effect of the transformations. There will be a white box that always sits in the middle of the window. You can't see it in the image here because it is blocked by the z-axis, but you can see it in the image at the top of this lab. The purpose of this will be more clear when you implement the tumble control.

In the project folder, you will see the executable CarNavigationComplete.exe. If you double click on it, you can (hopefully) run the full working version of the code. The black console lists the different key and mouse controls that are available.

If you compile and run the source code that is provided, none of the camera navigation controls work. Your task for this lab is to implement these camera controls.

Remarks on the code:

Part 1: Fly Through Controls

Part 2: Maya

In this part of the lab, you will implement the dolly, tumble, and track. :

Detailed notes are here.

The mouse controls are set up as follows:

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

Demonstrate your program in lab no later than 5pm on Tues, Oct 21. Zip together your codeblocks project (please delete the bin and obj folders) and submit via WISE.