CSE 557: Computer Graphics


Project 1 help session -- adapted from the 457 page

This session is to help you get started with the second project: swept surface generation. A description of the project is available here. Topics we will cover are:


Test Suite

We have put together a few test curves to give you an example of what the curves should look like if everything is working right. For more information on the test suite and the Frenet frame, check out the Frenet Frame Page.


Hierarchy of files

There really aren't that many files to be concerned with in this project, and the vast majority of your changes will happen in two files:

The starting point program is very simple. It contains the following files:

sweeper.C
Sets up the user interface and initializes the curve and surface objects. This is the file where new menu items need to be added to the menus.

computecurve.[C,h]
This is where all the code that actually computes the curve and surface points is located. Currently, the only curve type is the piecewise-linear curve (line segments). For surface generation, only the static frame is implemented for you.

curve.[C,h]
These are the files that define the Curve class. The Curve class is a simple C++ class which is responsible for displaying and editing a curve. When the curve is modified (when a user moves or adds control points, for example), the curve object calls ComputeCurve to generate the line segments needed for display. The only modification you should have to do in this file is to add names for new curve types.

surface.[C,h]
These are the files that define the Surface class. The Surface class is also a C++ class, and it acts in much the same way, calling the function ComputeMesh when it is modified. The only modification you should have to do in this file is to add names for new transport types.

menus.[C,h]
These files have helper functions to assist in creating menus. You should only have to modify them if you are adding additional menu features (sliders, checkboxes, etc.)

VecArray.[C,h]
A simple dynamically-resizable array class. There is a 1-D array called VecArray, and a 2-D array called Mesh. Your code will stick the curve and surface points that you compute into these type of arrays to pass back to the Curve and Surface objects. You may want to add functions to this file to make manipulations of the arrays more convenient. For example, adding a function that removes the last element of a VecArray is very useful.

A quick introduction to Inventor

This project also uses the Inventor library. Inventor is a fabulous library supplied by SGI, which provides lots of things to help you build interactive 3D applications. More Inventor help can be found be reading the man pages, or looking at the header files, which can be found in /usr/include/Inventor.


Vector Algebra

The Inventor class SbVec3f (a 3-element vector), has all the vector algebra operators already defined for it, so you can type vector equations in your code much like you see in class.

Here are the standard operators in vector algebra:

Suppose v and w vectors, so v = [vx, vy, vz] and w = [wx, wy, wz] and s is a scalar. Then, the following operations are defined:

(For more information man SbVec3f. You might also want to man sbMatrix)


A quick blurb about C++

This project is written in C++, so you will be doing your programming in C++ also. You shouldn't worry too much if you don't already know C++, since all of the "classes" are already set up for you.

C++ as a better C

C++ has many features that are pretty much just extensions to C. These include:

C++ as an OOL

The basics...

What are called classes are like specialized structs. The difference is that classes can contain function elements as well as data elements.

This allows you to do things like:

  SbVec3f a, b, c;
       
  c = a.cross(b);  /* c is set to cross product of a and b */
The function cross is an element of the SbVec3f class. When a function is included as part of a class, it is referred to as a method.

Another handy feature of classes are overloaded operators. The most common use of these is to define arithmetic functions (+,-,/,*):

  SbVec3f a, b, c;
       
  c = a + b;       /* c is set to be the vector addition of a and b */