

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!


Due: October 8, 2008 @ 6:00 pm (200 Points)
There are three parts to this assignment:
Now that you are able to display 3-dimensional objects on the screen, the next step is to allow the user to manipulate those objects. To accomplish this, you will implement 3D geometric transformations. You will do this by monitoring the user's actions and performing the appropriate function for those actions. The transformations that need to be implemented are rotate , translate , and scale. Rotate A positive number indicates a rotation, in the positive direction, of 10 degrees times the number entered by the user. Thus, if 4 were entered, the object should be rotated 40 degrees in the positive direction. A negative number indicates a similar rotation, but in the negative (opposite) direction. You’ll probably need to convert from degrees to radians before performing the rotation. Translate A positive number indicates a translation, in the positive direction, of 10 pixels times the number entered by the user. Thus, if 4 were entered, the object should be translated 40 pixels in the positive direction. A negative number indicates a similar translation, but in the negative (opposite) direction. Scale A positive number indicates a magnification scaling factor. Thus, if 4 were entered, the object should be enlarged 4 times in all directions. A negative number indicates an reduction (shrinking) scaling of the object by 0.1 times the number entered by the user. Thus, if -4 were entered, the object should be shrunk by a scaling factor of 0.4.
Manipulating Geometric Transformations You should establish an interface so that the user can easily interact with your system to transform the object on the screen. One possible technique for doing this is to have the user type in keystrokes that signal the transformations he or she wishes to perform. Each of the transformations could be represented as a series of 2, 3 or 4 keystrokes. The first keystroke will be either 'r', 't', or 's', for rotate, translate, or scale, respectively. For translation and rotation, the second keystroke will be either 'x', 'y', or 'z', representing the axis about which, along which, or in which, you are to rotate or translate. Scaling should be done uniformly about all axes (so it won't mess up your normal vectors), so no axis is specified for that transformation. The next keystroke will be either the minus sign or a number. If it is the minus sign, the following keystroke will be a number. You should also allow for two other directives: "quit" and "restart". The "quit" directive will allow the user to exit the program gracefully. The "restart" directive will allow the user to return the object back to its original location and orientation, allowing us to start over if something goes wrong in your program. This "restart" feature will require you to store your original polygon points so that you can get back to them as needed. The "quit" and "restart" directives could be implemented using the 'q' and 'p' ('r' is already used for "rotate") keystroke inputs. Here is a sample keystroke sequence using this scheme, and its interpretation: s-3tx5ry-1ptx-9q Scale by a factor of 0. Translate in the positive x direction by 50 pixels Rotate about the y axis 10 degrees in the negative direction Restart, returning the object back to its original location/orientation Translate in the negative x direction by 90 pixels Quit
The second part of this assignment is to allow the user to change the viewing parameters in the system. To do this, you need to allow the user to input a look-from point, a look-at point, a view up direction, and a field of view. Once these four parameters have been entered, you should change the view accordingly.
The third part of this assignment is to implement Phong shading. Using the shading model which will be given in class, you need to color pixels based on the computed, shaded color. As you scan convert a polygon, after checking the Z-buffer and determining that the pixel is to be drawn, compute the shaded color and color the pixel accordingly.