CS 4451, Spring 2005
Project 2: OpenGL Animation
Due: February 23 (Wednesday), 2005, 11:59pm
Overview
The goal of this assignment is to create an animated scene using the OpenGL graphics library. Because you will be using OpenGL routines, your code should run fast enough on a PC for you to have images generated at several frames per second.
Objectives
You will write a program that, when executed, will draw a series of images that make up a short animation. You will use OpenGL to do all of the drawing.
Your images will contain several objects of your own choosing. These objects can be created in either of two ways. First, you can write special-purpose code to draw objects such as a cube, cylinder, cone or sphere. Second, it is fine for you to use models that you read in from a file. We do not care where these model files come from so long as you are not violating any copyright laws. The purpose of this assignment is to piece together and animate a scene containing several objects, and we do not want this assignment to be difficult in terms of creating the objects. Here are the items that must be demonstrated by your program:
- Camera motion. Your program should create a sequence of images of the scene during which the position of the virtual camera changes smoothly. You may wish to use linear interpolation of camera parameters to achieve this, but any technique to smoothly change the camera position is fine.
- Ground plane. Your scene must include one or more large polygons that make up the ground (floor) of your scene. At least one of the objects in your scene must be exactly resting on the ground.
- Object animation. At least one of the objects in the scene should be moving relative to the other objects in the scene. For example, a car could roll along the ground plane. Be sure that there are enough landmarks in your scene so that it is obvious that an object is moving as opposed to apparent motion due to the viewpoint changing.
- Object instancing. At least one of the objects that you create should be replicated using instancing so that it appears in more than one location in the scene. You must not use duplicate lines of code to achieve this, but rather you must use the matrix stack and procedural encapsulation to accomplish this. Your object should be composed of several sub-parts. Just placing a sphere in several places doesn't count. Examples of objects that you might create are a tree, a car, a person, a chair. Place a comment at the very start of your C or C++ program that explicitly states which object you are replicating using instancing.
- Duration. Your animation should create between 30 and 200 frames of images. Please create an animation that finishes in a reasonable amount of time on the Intel Cluster PC's.
- Lighting and shading. You must create at least one light source in your scene. In addition, at least one of the objects in your scene should exhibit specular reflection. So as to make the highlights of this object easily visible from all viewpoints, it is probably best if your specular object is round like a sphere or cylinder, rather than having flat face such as a box.
- Perspective projection. You program must use perspective projection.
- Double-buffering. You must instruct OpenGL to draw your scene off-screen and then swap this second buffer to be the displayed buffer. This avoids flickering of the images.
- Hidden surfaces. Your program must enable z-buffering so that the appropriate hidden surface elimination is performed.
We will be looking for each the above items in your animation program. Missing any of the above elements will cause a deduction in your grade for this assignment.
In addition to the above items, 10% of your grade for this project will be based on the quality of the scene that you create. If you create a very simple program that meets the above requirements, your final grade will be 90 points out of 100. If you show thought, creativity and enthusiasm with your scene, then you will earn a higher score.
To grade this assignment we will be compiling and linking your code on a Windows PC. It is important that you fully test your code on a PC to make sure it works, but you can develop your code on other platforms if you like.
Provided Code and Suggestions
We provide for you two example programs that creates a window and uses OpenGL to draw simple scenes. Both of these examples can be downloaded here: prog2.zip. This code is set up to run using Microsoft Visual Studio 6 or Microsoft VS.NET, which you can run on the CoC Intel cluster. There is a file called "README.txt" in this directory that gives details to compile the code.
The program called "square.c" creates a rotating white square. The program called "animation.c" shows a rotating cube in front of a shiny sphere. Feel free to use these programs as a starting point for this assignment. The program "animation.c" is probably a better starting point because it uses perspective projection, z-buffering and a light source. The "square.c" program is more simple, however, and is a bare-bones illustration of a simple OpenGL program.
You will find that it is easiest to incorporate both camera and object motion by creating a single parameter that is your "clock". You might, for example, create a variable called "frame_count" that begins at zero and is incremented after every frame. You can then deduce the camera position and the object animation from this variable.
Your main references for this assignment will be the OpenGL Programming Guide and the OpenGL Reference Manual, and links to both can be found on our class web page.
Authorship Rules
The code that you turn in must be your own. You are allowed to talk to other members of the class and to the instructor about general implementation of the routines for the assignment. It is also fine to seek the help of others for general C or C++ programming and makefile questions. You may not, however, use code that anyone other than yourself has written. Code that is explicitly not allowed includes code taken from the Web, from books, from previous assignments or from any source other than yourself. The only two exceptions to this rule is that you should feel free to begin with the sample code that we provide and you may also use code written by others to read in individual object geometry (such as collections of polygons). Your scene assembly code and animation code should be your own. You should not show your code to other students. If you need help debugging, seek the help of the instructor or the TA.