|
Computer Graphics |
Fall 2000
|
Computer Graphics
Homework 08
6 hours
Copyright © 2000 David C. Banks

Search google for opengl examples. Download a bunch of them onto your Vis Lab account. Create a Makefile for them. Compile and run. You will give a demo of them in class, so it's not enough to compile them for your machine at home.
Pick one of your OpenGL examples. Go through the gl library calls and look at the man page for them. For example, type man glenable. Be prepared to describe, in class, what the gl functions do in the example you've chosen.
Run /usr/sbin/insight on the SGIs and browse the OpenGL programmer's guide. Read the first section "About This Guide" and Chapter 1 "Introduction to OpenGL."
Search google for parametric equation torus and find the equations for the (x,y,z) coordinates of a torus as a function of parameters (u,v). Deprecated link warning: the treasure troves math site is shut down as of 10/24/2000 due to a lawsuit filed by CRC Press against the author of the site.
Compute the tangent vectors from the partial derivatives in
the parametric coordinate functions for the torus.
T1 = ( dx/du , dy/du , dz/du )
T2 = ( dx/dv , dy/dv , dz/dv )
Compute the normal as the cross product of the tangents.
Put your solution in your notebook.
Here is a Makefile that worked for me on the SGIs to compile a simple OpenGL program surface.c . Copy it, compile it, and run it. It draws a triangle. Look at the source code.
To interact with your torus, you need a user interface that reads mouse events. I wrote a simple interface that mimics the Inventor examiner viewer. Rotate with the left button. Translate with the middle button. Here is the source and the header. Here is a modified version of the surface program that employs the user interface. Download. Compile. Run.
void surfacePoint(double u, double v) receives parameters u,v, computes the point (x,y,z) and the normal vector, and gives them to OpenGL. This example finds a point and a normal on a planar surface. Your job is to make it produce a point and normal on a torus. The torus has major radius R and minor radius r. Make these be parameters, if you like, so that you can create a torus whose shape changes over time.
void surface(int uDim, int vDim) receives parameters defining the dimensions of the mesh. They are ignored in my example, which generates just a single triangle. Your job is to loop over the u,v dimensions and draw triangles covering the torus.
Give your torus code a different name. Add your comments. Record an image and an animation (from you moving the mouse to rotate/translate the object) to put on your Web page.
In your README file, explain how to use your commnd line arguments and give a working example of how your program can be invoked. Don't let faulty arguments cause your program to crash.
Tar and gzip your code, Makefile, README. Link from your Web page.
Modify your torus program to also draw one or more spheres. Put an image on your Web page.
Generate multiple spheres and toruses, with random centers, radiuses, orientations, and materials. Make them move around. Record an image and animation and put them on your Web page.
Make the spheres bounce off each other, and off the sides of a cube, like they did in the last assignment. But use OpenGL. Record an image and animation and put them on your Web page.