Project 3

CSE 167: Computer Graphics


Project 3: Make a program that tessellates and renders a smooth cubic Bezier surface. It should start with the 16 control points of the surface and output a ‘Model’ class, making use of shared vertices. Use the 16 points provided below as an example, but you can also add more surfaces of your own as well. It must also compute correct, unit length normals, and use simple lighting. The code should be structured in an object oriented fashion.


Project 3 is due at or before 11:00 am, November 17, 2005

Project 3 is worth 10 points. The breakdown is as follows:


2: Evaluate points on the surface

2: Properly generate single-indexed model with shared verts

2: Compute correct normals & use some lighting

2: Good object oriented style with classes for key components

1: Be able to switch between shaded and wireframe view modes

1: Be able to toggle on/off rendering of the control mesh as a grid of lines

Object Oriented Approach

Project 3 must have some object oriented structure and have classes for major components. It should re-use the Model class from previous projects, but in this project it is required to use single indexing to enable vertices to be shared.


You don’t have to do it exactly like this, but I would suggest something like:


//// Surface ////


class Surface {

            Vector3 Point[16];


            Model *GenerateModel(int sres,int tres);

            void DrawControlMesh();




//// Curve ////


class Curve {

            Vector3 Point[4];


            Curve(Vector3 p0,Vector3 p1,Vector3 p2,Vector3 p3);

            void Evaluate(float t,Vector3 &pos,Vector3 &tan);




// Note: the Surface::GenerateModel() function takes an ‘sres’ and ‘tres’ (s- and t-resolution) and outputs a model containing (sres+1)*(tres+1) vertices and (2*sres*tres) triangles


// Note: the Curve::Evaluate() function takes a value ‘t’ and computes the position ‘pos’ and tangent ‘tan’ of the curve as output

Sample Surface

Try these 16 control points. See slides 25 & 27 of lecture 13 for a description of the specific ordering in S & T.


-1.5,     -1.5,     1.0

-0.5,     -1.0,     0.0

0.5,      -1.5,     0.0

1.5,      -1.5,     -1.0

-1.0,     -0.5,     0.0

-0.5,     -0.5,     -5.0

0.5,      -0.5,     5.0

1.5,      -0.5,     0.0

-1.5,     0.5,      0.5

-0.5,     0.5,      0.5

0.5,      0.5,      0.5

1.0,      0.5,      0.5

-1.5,     1.5,      0.0

-0.5,     2.0,      0.0

0.5,      1.0,      0.0

1.5,      1.5,      0.0

Sample Object

For a more complex test, try loading this text file. It is a simple text file containing 28 Bezier patches. At the top of the file is an integer which is the number of patches. After that, the individual patches are listed, in groups of 16 control points.