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:
Getting started: Find the ModelView program in the C++ Projects folder. Compile and run. Try the following items:
( | ) | ||||
---|---|---|---|---|---|
0 | 0 | -1 | 0 | ||
0 | 1 | 0 | 0 | ||
1 | 0 | 0 | 0 | ||
0 | 0 | 0 | 1 | ||
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:
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?