CS 651: Modern Research in Computer Graphics
Assignment #1
Download a model of an
icosahedron.
Download a model of a
cat.
Download a model of a
sphere.
Download a model of a
blob.
Download a model of a
horse.
Goal: Gain familiarity with OpenGL and build a simple viewer for polygonal models.
Assigned: Tuesday, September 12
Due: Thursday, Sept 24
Relevant reading:
- The red OpenGL book, Chapters 1-5
- We have a version of the OpenGL man pages on-line. These are for OpenGL 1.0 rather than OpenGL 1.1, but the difference should not affect you for this assignment. The man pages are at http://www.cs.virginia.edu/~cs551/Software/Doc/opengl.
Relevant software:
- I recommend you use Mesa, an OpenGL clone which runs in software. This will allow you to develop your application on UNIX using X-Windows. Information about downloading, compiling, and running with the Mesa library is available at http://www.ssec.wisc.edu/~brianp/Mesa.html.
- I also recommend using the GL Utility Toolkit, or GLUT. OpenGL is strictly a graphics API and does not address windowing issues, mouse & keyboard input, pop-up menus, and so on. GLUT provides all of these and more, and all the examples in the OpenGL red book use GLUT. You will need to download and compile it. Glut can be compiled with Mesa and is available for PC and UNIX platforms. The GLUT home page is http://reality.sgi.com/opengl/glut3/glut3.html.
- It is often useful to build simple GUIs for this kind of program. If you’re comfortable using Tk/Tcl that may be the way to go. I’ve used a package called Xforms a lot and found it to be a really easy way to whip up a quick GUI. If you’re interested check out the Xforms home page: http://bragg.phys.uwm.edu/xforms.
Synopsis: You will write an OpenGL program for loading and viewing individual polygonal objects. For now your viewer need only support a single object.
- Your viewer should implement two viewing modes with mouse control:
- Inspect
mode uses the common virtual trackball metaphor described in the handout. Some of the GLUT demos implement a variation of the trackball described in the handout.
- Walkthru
mode uses the mouse to control the camera rather than the object:
up = forward, down = backward, left = rotate left, right = rotate right.
- Your viewer should support at least two rendering modes: wireframe and shaded, lit polygons. The latter should use depth-buffering and OpenGL lighting (Chapter 5) and allow the user to set the material properties of the object (Table 5-3). These can be specified either interactively via a GUI or at startup with command-line flags.
- The objects you read (at least for now) will be in the very simple .poly format. The format is almost self-explanatory:
- Number of vertices
- Number of faces
- A list of vertex coordinates and (optionally) normals
- A list of faces, each face a list of vertex indices. Triangles list three vertices, squares four, etc. NOTE: The vertex indices in this format start with 1, not 0!
Several example objects of varying complexity are on the course web page.
Grading: A viewer implementing the requirements above will receive a B+ grade. Higher grades will require something extra; exactly what is up to you. Examples of that something extra might include:
- Put icons representing lights in the scene and let the user manipulate the lights with the mouse (note that you’ll have to use spot lights or point lights for this).
- Read some common 3-D file format (AutoCAD’s DXF, WaveFront’s OBJ, and VRML are all good examples) in addition to the simple stupid .poly format.
- Texture mapping! Read in an image file and project it onto the object.
If you have a question about the difficulty and grade-worthiness of adding a particular feature, don’t hesitate to ask.
Turning in the assignment: Before class starts on Thursday, September 24 you should:
- Send me mail with the name of a directory containing the code for your viewer and a README file with instructions on how to compile and run the viewer. I’m going to tar up this directory and copy it onto my machine, so be sure to avoid any hardwired dependencies in the Makefile. If you use any libraries other than the ones I’ve mentioned above, include them in the directory. Test it – tar, move, recompile, run.
- Hand in printouts of all the code you have written for the viewer – basically everything except libraries such as Mesa and GLUT.
Advice:
- The next stage will support general scene graphs, with hierarchical instancing of multiple objects. Plan your data structures now to simplify your job later.
- OpenGL lighting is finicky. Get everything working in wireframe first.
- Storing a vertex list and a face list that indexes into the vertex list works well.
- Start now! Don’t underestimate how long it can take to get all these libraries to compile & work together, or how hard it can be to debug the dreaded "black screen".