Written Questions Due: Tuesday, Sept 23rd by 9:30/11:00 AM (in class)

Program Due: Tuesday, Sept 23rd by 11:59 PM Late assignments will be penalized 20 points per day.

0. Getting Started

Download CS370_Assign02.zip, saving it into the assignment directory.

Double-click on CS370_Assign02.zip and extract the contents of the archive into a subdirectory called CS370_Assign02

Navigate into the CS370_Assign02 directory and double-click on CS370_Assign02.sln (the file with the little Visual Studio icon with the 13 on it).

If the source file is not already open in the main window, open the source file by expanding the Source Files item in the Solution Explorer window and double-clicking RollinTrain.cpp.

1. Written Questions

  1. Show that a rotation and a uniform scaling transformations are commutative, i.e. that they can be applied in either order.

    Hint: Given the general 4x4 matrices for each transformation

    image

    show that the appropriate matrix products commute, i.e. give the same result for both orderings.

  2. In class we have defined an instance transformation to be the product of a scaling, rotation, and translation. Can the same final effect be accomplished by multiplying the three matrices in a different order? Hint: In order to show that the product of all three transformations is the same regardless of order (i.e. is commutative) you would need to show it to be true for all possible combinations of all possible transformation matrices. However to contradict the hypothesis, simply give a single example that shows it to be false (which can be done with only two of the three transformations). NOTE: This problem does not show that a final transformation requires a unique set of basic transformations as there may be several ways to get the same final transformation from different combinations of basic ones.

  3. Typically when we draw 3D objects on paper (or the board) we draw the x and y axes at 90 degrees (x axis pointing right and y axis pointing up). We then represent the z axis (which would be coming out of the board) by a line at -135 degrees from the x axis (diagonally down towards the left). This type of projection is known as an oblique projection. Determine the projection matrix that would render the objects in this fashion.

    Hint: In order to achieve this projection, we need to find a transformation matrix that takes the standard axes and converts them as follows:

    image

    Use the above axis values to find the rows of a (homogeneous) transformation matrix by considering the matrix-vector products

    image

  4. Some of my research has been in the area of stereoscopic 3D images, which is now common in movies and TV. To create a stereoscopic 3D image, we simply render the scene from two different viewpoints (one to represent what the left eye would see and one to represent what the right eye would see). If the viewer is considered to be at the origin with an ocular spacing of Δx, what are the appropriate gluLookAt() functions to produce a stereo image pair? Hint: We need to render the scene from two different camera locations (separated by dx). Consider two possible locations where these cameras can be pointed, i.e. the at vector, to produce a stereoscopic image.

Extra credit Quaternions are a better, but far less intuitive, way to represent rotations (particularly dynamically changing ones) that involves representing the rotations using complex numbers. Find quaternions for a 90 degree rotation about the x and y axes. What is the product of these two rotations as a quaternion?

2. Programming assignment

Write a program that draws a 3D "train" scene using OpenGL. A sample executable is included in the skeleton file as either RollinTrainWinSol.exe or RollinTrainMacSol.exe. The scene should include:

Hints:

Use regular OpenGL primatives (user defined vertices), glu quadrics, and/or glut objects to build the scene.

Use instance objects and display lists where possible, e.g. tracks, blocks, etc. Remember, however, that the objects in display lists must have fixed values. Hence if objects move relative to each other, they must be in different lists. Transformations can be applied to the entire display list when it is rendered, so consider the display lists as creating larger "instance" objects from the graphics primatives.

Use global variables to avoid magic numbers in the code, particularly for object geometries and colors. Even better is to create symbolic constants with #define statements within the header file train.h. The constants should be interrelated as much as possible so that objects that are referenced off each other can be adjusted with a single value. This adds a tremendous amount of flexibility when creating the scene as it becomes much easier to modify entire objects at once rather than needing to recalculate multiple dependent values. (After all, you are developing this scene iteratively aren't you?)

You should begin the orthographic viewing from an isometric viewpoint, i.e. the camera should be positioned along a line going through (1,1,1) but far enough back to see the entire scene. You should be able to compute the azimuth and elevation angles that correspond to your chosen starting position to initialize the spherical coordinates properly.

Grading Criteria

The program MUST compile to receive any credit (so develop incrementally).

For up to 70% credit: Draw the basic scene without display lists, only static projections (i.e. fixed orthographic and perspective viewpoints), and no animation.

For up to 75% credit: Draw the basic scene using display lists, only static projections (i.e. fixed orthographic and perspective viewpoints), and no animation.

For up to 80% credit: Draw the basic scene using display lists, only static projections (i.e. fixed orthographic and perspective viewpoints), and animation.

For up to 90% credit: Draw the basic scene using display lists, dynamic projections (i.e. moving camera viewpoints in both projection modes), and animation.

For above 90% credit: Be creative! For example, enhance the geometry of the scene or with additional animations.

Compiling and running the program

Once you have completed typing in the code, you can build and run the program in one of two ways:

(On Linux/OSX: In a terminal window, navigate to the directory containing the source file and simply type make. To run the program type ./RollinTrain.exe)

The output should look similar to below

image

image

To quit the program simply close the window.

Submitting to Marmoset

To submit your completed assignment, open a terminal window, navigate to the working directory and type:

make submit

Then enter your Marmoset id and password. You should see a confirmation that the file was submitted successfully.

You are responsible for making sure that your submission contains the correct file(s).