CS-511 - Alternate Assignment 1 (5%)
2D function viewer
Due by: September 9, 2008
This assignment is intended only for students who took cs411. The
purpose of this assignment is to write a 2D function surface viewer. The
input to your program should be a text file containing the data points
of the 2D function. It is assumed that the function is sampled over
regular intervals in a rectangular region. Your program should support
the following rendering modes:
- wireframe (with hidden line removal).
- non-illuminated surface where color represents height (red=high,
blue=low).
- illuminated uniformly-colored surface
The function surface should be rendered by triangulating the data set
while maintaining the winding of the triangles consistent. This task is
fairly simple under the assumption that the function is sampled over
regular intervals in a rectangular region.
The wireframe plot should be obtained by drawing lines between function
values when is constant, and then repeating it in the direction.
Hidden lines may be removed by rendering filled polygons on top of the
lines with a background color (use the commands
glEnable(GL_POLYGON_OFFSET_FILL);
and
glPolygonOffset(1.0,1.0);
to prevent the deletion of the rendered
lines).
The following are some more specific details:
- Input file format: The input file should be a text
file. The first line of this file should contain the number of rows
and columns in the rectangular grid that was used to sample the
function. Each subsequent line should contain the coordinates of one
point where . The points should be ordered
starting from top to bottom, and left to right. That is the order of
elements in the file is:
|
(1) |
- Display mode: Switching the display mode should be
accomplished by pressing ``1'', ``2'', ``3'' (wireframe, unlit, lit
respectively).
- Viewpoint control: The arrow keys should be used to allow
the user to view the surface from different viewpoints. The ``i'' and
``o'' keys should be used to zoom in/out. In the lit mode, the light
source should be moved with the camera.
- Data file: A data file of a 2D sine function will be provided.
- Color setting: The way to change the color from red to
blue in the non-illuminated mode is to find the minimal and maximal
values of the Z coordinate. Given and , the color
at a height of should be set to:
where
Please follow the submission procedure outlined in the regular
assignment 1 specification.
Gady Agam
2008-09-02