CS 4391 Spring '97 - Project 3
Bézier Surface Tessellation

Due: Friday, June 6, 1997, 2:00 PM
Graduating Seniors Due: Wednesday, June 4, 1997, 2:00 PM


Introduction

The purpose of this assignment is to work with several surface representations, and especially with cubic parametric surfaces. Your task is to accept descriptions of polygons, spheres and cubic Bézier surfaces and to convert them all to a common polygon format for display. In the interest of simplicity you will use OpenGL to display your models. As in previous assignments, you will use the CLI command language routines to read descriptions of these surfaces from files.


Provided Code

You will be provided with a skeleton program that uses the command language interpreter and OpenGL to render simple polygon scenes. Your task is to extend this program to handle curved surfaces. The program that will be provided has the following commands:
fov		angle
lookat		fx fy fz  ax ay az  ux uy uz
push
pop
rotate
translate	x y z
scale		x y z
These behave in exactly the same way as in your first two assignments.
In addition, there are a few other commands that are slightly different than previous commands:
light		x y z
This command describes the direction of the light vector. Notice that there is no color provided, so our lights will be white.

color		r g b
Specifies the ambient and diffuse color of a surface. We will use a very simple lighting model for this project.

clear
Clears the screen to black.

begin
vertex		x y z
vertex		x y z
...
end
The above commands describe a polygon, just as before. As usual, the current transformation matrix transforms the polygon vertices. You should look at the code that implements this command carefully because you will do something similar to create polygons that tessellate the curved surfaces. Pay particular attention to the surface normals.


Commands You Will Write

In addition to the above commands, your program should understand two additional kinds of surface descriptions, spheres and Bézier patches. Here are the commands you should implememt:
sphere		x y z radius
The sphere command should cause your program to create a collection of polygons to represent a sphere. Use the latitude-longitude form of sphere tessellation with 20 polygons in each direction (giving 400 polygons per sphere). The current transformation matrix should also affect all of the vertices of these polygons.

bezier1		x1 y1 z1   x2 y2 z2   x3 y3 z3   x4 y4 z4
bezier2		x1 y1 z1   x2 y2 z2   x3 y3 z3   x4 y4 z4
bezier3		x1 y1 z1   x2 y2 z2   x3 y3 z3   x4 y4 z4
bezier4		x1 y1 z1   x2 y2 z2   x3 y3 z3   x4 y4 z4
The four bezier commands define 16 control points for a cubic Bézier surface. Notice that a full patch description requires that four commands be given, each defining four of the control points. The bezier4 command completes a patch, and should cause a tessellated version of the patch to be created out of polygons. You may use either the patch subdivision technique or polynomial evaluation to create the tessellated patches. In either case, one patch should be divided into 16 by 16 polygons. The vertices of these polygons should be affected by the current transformation matrix, as is true with polygons and spheres.


Build A Cylinder

Part of this assignment is to use the bezier commands to model an approximation of a cylinder. The cylinder should have the following specifications:
  1. the center axis should be along the z-axis,
  2. it should span z values from zero to two, and
  3. it should have an approximate radius of one.
You may stitch together this cylinder from as few or as many Bézier patches as you like. The major requirement for successfully creating an almost-cylinder is that the patches join smoothly. Note that it is impossible to exactly match a cylinder using Bézier patches, so your cylinder cannot possibly be exactly smooth. This is perfectly okay.


Sample Files

We will provide to you a few files to test out your routines. They are in
	~cs4391/proj3/assignment/
on College of Computing UNIX machines. In particular, you will be given a description of the so-called Utah Teapot. Make sure that your program correctly renders the teapot.


Hints on Programming

First get the general framework for polygons working, including all of the transformations. Next, implement the sphere command. Finally, begin work on Bézier patches. At first, just render each patch as if it was a collection of 4 by 4 vertices and create polygons from the control points. This will allow you to make sure your four bezier commands are reading in all the numbers properly. Once you are confident of this, then you should create the actual tessellated patches.

The SGI Indy workstation is a good candidate for developing OpenGL programs. Check out the Indy Lab in CoC room 130.


Graduating Seniors

If you are a graduating senior, you will need to turn in this assignment a few days earlier than others. To make up for this shortened time, you do not need to implement the sphere command, nor do you have to create a cylinder out of Bézier patches.


Submission

To submit your program, put your project files in a directory on a College of Computing UNIX machine, then execute the following command in that directory:
	shar *.c *.h makefile cylinder.cli | elm -s "proj3" cs4391@cc.gatech.edu
Basically you need to put all the program source code files, header files, the makefile, and your scene description file after the shar and before the | pipe.

The shar and elm commands are in the /usr/local/bin directory.


Authorship Rules

The code that you turn in must be entirely your own. You are allowed to talk to other members of the class and to the instructor and the TA about high-level questions about the assignment. It is also fine to seek the help of others for general C programming questions. You may not, however, use code that anyone other than yourself has written. Code that is explicitly not allowed includes code taken from the Web, from books, or from any source other than yourself. The only exception to this rule is that you should use the routines that we provide. You should not show your code to other students. If you need help with the assignment, seek the help of the TA. Check the Programing Assignment Policy for details.


Last modified: 31-May-97