DUE DATE: Dec 3 midnight


What to do

I am giving you three 3D models, each modelled as a number of Bezier patches: teapot, teacup and teaspoon. You have to put them neatly on a virtual table (which can be simply a rectangle) and render this scene using OpenGL. All OpenGL commands are allowed in this project. You may want to color the pieces with your favourite color (make sure everyhing is clearly visible).

File format

Each file has two parts: patch data and vertex data. The first entry in each part is the number of its items (integer). Then, there follows information specifying each item. Patches are described by 16 labels of the control vertices (indices into the vertex table). Thus, a line

v1 v2 v3 v4 v5 v6 v7 v8 v9 v10 v11 v12 v13 v14 v15 v16

defines a patch with an array of control points

v1 v2 v3 v4
v5 v6 v7 v8
v9 v10 v11 v12
v13 v14 v15 v16.

Each point is, of course, specified by 3 floats (x,y,z-coordinates). Look at the input files below and make sure that you understand their structure. For example, the teapot has 32 patches and 306 vertices (teaspoon: 16 and 256, teacup: 26 and 251). Notice that the vertices are numbered starting from 1, not 0 (there is no reference to vertex 0 in the patch specification part).

The models

Here are the files: teapot, teaspoon, teacup. You will have to read them somewhere in your programs or incorporate into your code as constant arrays.
If you decide to read them, please read them from the current directory and don't change their names.
This will make our life simpler in the first week after you turn in your programs :). Here is an image of the teapot (this one is very coarsely tesselated, so yours are likely to look better). You can view it under ivview using this file.


Extra credit (10 points)

Implement shadows on the surface of the table, e.g. by rendering in two passes: first using the light source location as the center of projection (to compute the shadows) and then using the result to generate the texture for the table. This is a great practice of a trickier side of OpenGL programming.
You also have a chance to shape this project! If you have any other suggestions for extra credit, please send them to me by Nov 26.

Esthetical requirements

I am leaving the specific details up to you, but please make things look well and physically plausible (no floating teapots please!). You are free to use different colors and viewing parameters; please make sure that the pieces are visible. Also, feel free to change the light and its properties. The files show a rotating scene. Your programs should show the table from viewpoint which is rotating over the table. Try to make all the pieces fit into the window, at least most of the time.

Some OpenGL calls you may have to use

Drawing Bezier patches (it's all OpenGL supported): glMap2*(), glMapGrid2*(), glEvalMesh2()
To get all this working, you may need to examine the meaning of gl Enable with parameters: GL_MAP2_VERTEX_3, GL_AUTO_NORMAL, GL_MAP2_NORMAL.

Clearly, you'll have to use display list (put all your scene to one), transformations to put the objects in place (glTranslate*,glRotate*, perhaps glScale*).

Grading

Objects drawn correctly: 30
Lighting (this includes normals): 30
Clarity of the code: 10
Camera movement and object placement: 30

The programs will be run from a directory containing the input files named 'teaspoon', 'teacup' and 'teapot'. So, if you are reading them, please don't change their names and read them from the current working directory. If you prefer some other way, include all files you use in the tar file you are submitting.

Project files (same as for Project 2)

cs4451_a2.c Makefile