Math 217A - Spring 2002 - Assignment #3
due Wednesday, April 24
Goals: Build a torus with a single long, wrapping quad strip,
similar to figure 10(b) on page 13 of the book draft. Animate it, and change the
mesh resolution with keyboard controls. This should help you (a) gain
more experience with OpenGL, (b) confront some of the basic issues in animation with
keyboard controls, (c) possibly appreciate the dangers of using floating point numbers.
- Download the PC executable program WrapTorus.exe.
Try running it, and observe what it does. Your assignment is to rewrite
this program or something very similar. Your program should support the following
- Press arrow keys (left, right, up and down) to make the torus rotate.
- Press "s" to single step the animation,
- Press "a" to start the animation running again without stopping. (Undoes
the "s" effect.)
- Press "r" to reset the torus back to its original orientation with no
- Press "0" (zero) to zero the velocity of the torus, but leave its position
- Press "W" to increase the number of wraps, "w" to decrease the
number of wraps.
- Press "N" to increase the number of segments per wrap. "n" to
decrease the number of segments per wrap.
- Press "q" to toggle between drawing quadrangles and triangles.
- Press "p" to toggle between rendering in filled polygon mode, and in wireframe
- You will have to write much of this yourself. To get started, you can
download a simple program that makes an unanimated, non-wrapped torus. WrapStart.c and WrapStart.h.
Download these (and rename them) to serve as the foundation for your homework
Hints/Suggestions: (if you have difficulties, let us
know, and I might post more hints to help your fellow students!)
- There is a handout available for help with starting a new
project in Visual C++.
- You will need to write a torus drawing routine from scratch.
- You do not need to make the keyboard controls in your program work exactly like the
keyboard controls for WrapTorus.exe listed as items a.-i. above. If you prefer to
try different functionality, that is OK. Important: it should be
possible to make the rotation rates slow down and speed up in small-ish increments, so we
can get good control of the motion.
- To toggle quad mode and triangle mode, you can call glVertex3f with the
same points in the same order for both modes, just vary the parameter to glBegin().
- To toggle "fill" mode and "wireframe" mode, use the OpenGL command
(before rendering the torus)
where polygonMode is either GL_FILL or GL_LINE.
Then draw everything as polygons (quads or triangles). In line mode, only
the outlines of the polygons are drawn.
- The torus will look terrible in "filled in polygon" mode. This will
improve in the next assignment when you add lights and material properties.
- You should use integer values to drive the computations whenever possible. For
example, when keeping track of the current "wrap number" or current segment in a
wrap, you should use integer values. Also, see the section in the textbook draft
about the perils of floating point roundoff errors (at the end of chapter 2).
Homework turn-in procedure: Your turned in results should
consist of two parts. First, a report on your work. (1) Talk
in person to me or Frank Chang, demonstrate your code and discuss the assignment. Or
(2), email me and Frank (firstname.lastname@example.org, email@example.com) with a report of what you did.
A plain text report is preferred. For the email option, a long report is not
needed, but you should at least
- Say what parts of the assignments you did,
- Describe any problems or difficulties you encountered.
- Describe how your keyboard controls work for controlling animation.
- Describe any optional or extra work you did.
Second, turn in your code and an executable. Executable
files will be made publicly available, so everyone can have their results demoed to the
rest of the class. You should turn in source files and executable, by using
anonymous ftp to euclid.ucsd.edu, directory pub/sbuss/turnin217/ma217sXX/WrapTorusProg.
Here, replace "ma217sXX" by your own
userid. Make sure the executable file is uploaded in binary mode.
Click here for more detailed