Due Date: See Schedule
200 points
Overview
There are three parts to this assignment:
1. Implement geometric transformations so that the user can move your 3D objects around.
2. Implement viewing transformations so that once the objects have been placed in the environment, the user can then change the viewing parameters.
3. Implement Phong shading, using the shading model given in class.
For this program, you are only required to have a single object (comprised of multiple polygons, of course). If you want to allow multiple objects, you may do so.
Part 1: Geometric Transformations
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. NOTE: Make sure you convert from degrees to radians prior to 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. NOTE: You will need to provide the mapping that will translate your object the correct distance in world space to correspond to the appropriate number of pixels in screen space.
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.3
* 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
Part 2: Viewing Transformations
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. You also need to implement perspective viewing.
Part 3: Shading
The third part of this assignment is to implement Phong shading. Using the shading model 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.
next time
post some exmaple images.
timing was a little off.
the exact process (in my code) phong shading didn't quite work at times.
error in slides for window to viewport has 2 x xmin 2x .59 is wrong. viewing part 2.
Related Files





