HW#4 --- last modified March 02 2019 21:08:39..
Solution set.
Due date: Nov 17
Files to be submitted:
viewport.cpp
Purpose: To learn about the world coordinate to clipping window to screen viewport mapping.
To learn about GLUT windowing functions.
Specification:
For this homework, your program will be run from the command line with a line like:
viewport world.txt
Here viewport is the compiled name of the .cpp file you will submit; world.txt is a text file
specifying a ``3D world''. An example such file is:
500 300 200
2
3 20 20 20 50 60 70 200 200 100
4 40 50 20 50 60 70 90 200 100 30 40 100
The first line gives respectively the x, y, z sizes of the 3D world. The second line says how many polylines
are contained in the file. The third line through the end of the file lists out the polylines. A polyline is
given in the format: NumberOfPoints p1x p1y p1z p2x p2y p2z ... pLastx pLasty pLastz . You can assume that the polylines
in the test file will be completely contained within the world sizes given by the first line of the file.
When your program is run, it opens two windows: The first window has dimensions the x and y sizes of the world, the
second window has dimensions half these values in both the x and y coordinates. Drawn in the first window are
polylines from the file where we have projected down on the z axis. That is, the 3D point (3, 4, 5) becomes the 2D point
(3, 4). In the first window, you should also draw a dashed rectangle, with lower corner at (0,0) of half the screen width
and screen height.
In the second window, I want drawn the contents of the first window where you have clipped the scene using the appropriate
GLU clipping window functions to the area given by the dashed rectangle.
To make the program more interesting, when a person hits the `x', `y', or `z' keys I want
you to change from whatever
coordinate you are currently projecting out to the new
coordinate given by this letter. i.e., If we have the point
(3, 4, 5) and I hit x this point is now project to (4, 5). I want
the two windows also to change size to the dimensions
of the world in this new plane. If the person switches views, say from x to y, you can resize the clipping
window to half of the new direction's window size and you can reset the clipping window to the origin.
Finally, I want the user to also be
able to move the rectangle in the first window around
and so affect what the user sees clipped in the second window. To do this
I want you to handle the up and down keys as
moving the rectangle forwards and backwards, and I want you to handle the left and right keys
as making the window rotate
left and right. Do something reasonable to prevent the rectangle from going off the first window's screen.
Point Breakdown
Departmental coding guidelines for C++ followed |
1pt
|
File read in correctly |
1pt
|
Window sizes as described | 1pt
|
Contents of first window as described | 1pt
|
Contents of second window as described | 1pt
|
x, y, z keys works as described | 3pts
|
Up/down and left/right keys works as described | 2pts
|
Total | 10pts |
|