CS 651: Modern Research in Computer Graphics
Assignment 1.1
Goal: Minor extension to Assignment 1. My sense is that nearly everybody ran out of time, so this assignment is mostly to give you a chance to get assignment 1 done right.
Assigned: Tuesday, September 29th
Due: Monday, October 5th by 9 AM
Relevant reading:
- If you haven't yet, read the red OpenGL book, Chapters 1-5
Relevant software:
- I have the xforms library compiled for Solaris at /home/luebke/lib/solaris/libforms.a
- You may also wish to check out GLUI (GLUT-based User Interface), a C++ library which provides a simple way to add a GUI to your GLUT application. GLUI has the advantage of being completely built on top of GLUT, and thus guaranteed to run native anywhere. See http://www.cs.unc.edu/~rademach/glui
Synopsis: Extend and/or finish your OpenGL viewer for polygonal objects. Again, you need only support a single object. This time you must implement a GUI with:
- Sliders or spinners to control material parameters (ambient, specular, diffuse, etc.)
- Sliders to control the background color
- A Quit button to exit the program and a Reset button to reset all viewing parameters
- A button or radio button pair to toggle between wireframe and shaded modes
- A button or radio button pair to toggle between inspect and walkthrough modes
- Sliders to control azimuth and elevation of a directional light source
Comments:
- We continue to use the .poly format:
- You may ignore normals specified in the file and calculate per-triangle normals using the cross-product of two edges if you wish (don't forget to normalize!)
- You must support triangles and quadrilaterals, but may ignore larger polygons
- All models are built to a different scale. Find the model's extent and adjust:
- Your initial camera position
- The near and far clipping planes (you may want to adjust these each frame)
- Camera translation increments for walkthrough mode
- Inspect mode should support moving closer to or farther from the center of the object. You may wish to use a second mouse button, a modifier key, or a GUI slider for this.
Grading: The same grading criteria described in assignment 1 still apply; fulfilling the requirements gets a B+ and getting an A requires doing something extra. The grade for assignment 1.1 will be used instead of assignment 1.
Turning in the assignment: Same as before. Send me mail by nine o'clock Monday morning directing me to your completed assignment & README file. You don't need to print out the source code this time.
Miscellaneous advice:
- The gluLookAt() function is the easiest way to implement walkthrough mode. Keep track of the camera position and a view vector. You may use a constant up vector.
- Turn off lighting when rendering in wireframe mode, and use glColor() to set the color of the lines to the current material diffuse color.
- Be very careful to initialize all the sliders, radio buttons, and so on in the GUI to the initial values actually used.
- If you use Xforms, you probably want to use the non-blocking fl_check_forms() call rather than the blocking fl_do_forms() call. The easiest way to integrate Xforms and GLUT is to call fl_check_forms() from the idle function set in GLUT.
- If the motion callback registered with GLUT redraws the object every time it is called, the mouse events can pile up in the queue, causing the display to fall behind. Instead, have the motion callback call glutPostRedisplay(), and have a display callback that actually draws the scene.
- Start now! I'm around all week to help if you have problems, but not over the weekend. Most people underestimated the time the assignment would take, and weren't satisfied with what they turned in. Don't make that mistake again.
Remark: David Coppit observed that he felt as if he were reinventing the wheel, and asked whether good read-in-a-file-and-fly-around programs don't already exist. I've thought about this and decided that the answer is, "not really". Plenty of commercial modeling packages will read files (usually in their own proprietary formats) and let you view them, and VRML plug-ins for web browsers will let you fly around a 3-D scene described in the VRML format. But that's about it. When people want a viewer, they usually write one. Higher-level graphics APIs than OpenGL (such as Performer, Inventor, and Farenheit) may make the job easier, but these are still programming toolkits rather than turnkey applications.
So will you have to write OpenGL code for your project? If what you're doing is strictly geometric (e.g., an LOD algorithm) you might be able to use VRML and a web browser. But if you're doing anything interesting in the way of interactive rendering (such as dynamic LOD, cells & portals, hierarchical image caching, etc…) you'll probably use OpenGL or one of the higher-level APIs mentioned above. This assignment may not be extensive enough to give you useful boilerplate, but it will certainly introduce you to OpenGL and some of the issues involved in rendering simple scenes.