CS 420 Computer Graphics


Lab 11
Dr. Tong Yu, Fall 2009

Affine Transformation

  • Login and open two windows, one for editing and one for compiling and executing programs.

  • Try the program cube.cpp discussed in class. Change parameters of gluLookAt() and glScalf() to see their effects on rendering.

  • Make the directory ~your_login_name/cs420/mesh1 copy the files from /pool/u/class/cs420/polygon/mesh1 to it. Compile and execute mesh. ( Other object files should reside in the directory "../mesh/" that you have used in Lab 9 and 10. ) You should see the effects of affine transformation as discussed in class. Now make a simple animation of rotating the barn. Note that you should not increment your rotating angle as the OpenGL matrix multiplication has already effectively incremented the angle each time you call the rotating function. Next, try the animation of translating and scaling then a combination of translating, rotating and scaling.

    You may clear the screen with the command

      glClear(GL_COLOR_BUFFER_BIT);

    If you want the animation to appear more smoothly, you may use double buffering. Simply use

      glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH );

    in your main.cpp and use

      glutSwapBuffers();

    to render your image in display().

  • ( EC 0.2 ) Write a program that rotates the cube discussed above by 10 degrees around the y-axis each time you press the key 'y'.