ModelView program

The ModelView program will let you experiment with using 4x4 matrices to perform transformations in 3-space.  The purpose of this program for this class is twofold:

• Gain experience with model view transformations.  This will be helpful in understanding how to compose transformations in your own OpenGL programs.
• Provide an example of how to use MFC widgets (specifically the dialog box).   Learning how to do this is *optional* for this class, since you can use the "aux" or "glut" routines to control your programs via keyboard input or via popup menus.

Getting started:  Find the ModelView program in the C++ Projects folder.  Compile and run.  Try the following items:

• Note that you can toggle between displaying a solid letter "F" and a teapot.
• Enter a scaling transformation: for instance make the diagonal entries of the matrix "2", "1" and "0.5" and then press the Apply button.  Observe what happens.  Which axes are the x, y, z axes?  Does this make sense?  Is it a righthanded coordinate system.
• Enter a transformation that rotates around the y-axis:
 ( ) 0 0 -1 0 0 1 0 0 1 0 0 0 0 0 0 1
• Try some translation transformations (by setting the three upper entries in the third column.
• For fun: what happens if you use the identity matrix, but change the lower right 1 to 2 (or to 0.5)?  Why does this happen?

Composing transformations.  The other buttons can be used to compose transformations, e.g., to see the effect of a translation followed by a rotation (or vice-versa.)
The operation of the program is little difficult to explain, but here goes:  There are 3 matrices that are being maintained, there is a matrix M (main matrix), a matrix C (current matrix) and the displayed matrix D.    The transformation that is applied to the teapot or the letter F is the matrix CM. (the matrix product).

Initially all matrices are the identity.   The D matrix is what you edit on the screen.  The buttons on the dialog have the following functions:

• Apply: sets C := D.  No change to M.
• Reset and Apply: Sets M equal to the identity and C := D.
• Premultiply and Apply: Sets M := CM.  Then sets C := D.
• Identity Matrix.  Sets D equal to the identity.

Important:  The transformations are composed by premultiplying.   This is the easy way to intuitively create and visualize the composition of transformations.  However, in OpenGL, transformations are post-multiplied, so your program has to apply the transformations in the reverse order from how you apply them in this demonstration program.

Try it out: Smooth vs. Flat shading:  Find the place in the code where the teapot is drawn in ModelviewView.cpp..  Change GL_FLAT to GL_SMOOTH to do smooth shading.  How does this change the appearance of the teapot?    You might want to scale the teapot by a factor of 2 to see the difference more clearly?  Can you see the individual polygons in the smooth shading mode?