COS 426 - Computer Graphics

Spring 2011

Course home Outline and lecture notes Assignments


Assignment 4: Particle Systems

Due Tuesday, Apr. 26, 11:59 PM

Overview

In this assignment, you will implement a basic particle system. The program will read in a scene file with particle commands and then draw particles as they move over time in an interactive viewer. At its simplest, your program will be able to spawn particles, apply forces such as gravity and drag to them, and bounce them off of scene geometry. Once you have the basic system in place, you have a broad selection of options to improve your system. You can choose to focus on the rendering or the physics of the particles. Improved rendering will allow for more convincing simulation of phenomena such as smoke, fire, and sparks. Improved physics will allow simulation of rope and cloth, or even flocks of birds or schools of fish.


Getting Started

You should use the following skeleton code (cos426_assignment4.zip) as a starting point for your assignment. We provide you with several files, but you should mainly change particle.cpp.

After you have renamed the cos426_assignment4 directory to [your NetID]_cos426_assignment4, the first thing to do is compile the program. This will create particleview (or particleview.exe). particleview is like rayview, but also calls functions from particle.cpp for simulation and drawing of particle systems.

The skeleton code is able to read scene files (like in assignment 3) augmented to support particle systems. Specifically, the scene file format now supports five new commands: particle, particle_source, particle_sink, particle_spring, and particle_gravity.

We provide several scenes with particles in the input subdirectory of the zip file that you can use to test your program along with a set of examples. However, you should definitely create your own files for testing, demonstration, and artistic purposes.


How the Program Works

When particleview is executed, it reads a scene file and spawns a window.

% particleview in.scn
As in meshview and rayview, particleview allows interactive viewing of the scene with the mouse and keyboard. Dragging with the left, middle, and right mouse buttons down rotates, scales, and translates the scene, respectively. Hitting keyboard keys toggle display of particles (P), psrticle springs (R), particle source and sinks (S), faces (F), edges (E), node bounding boxes (B), lights (L), and the camera (C), respectively. Hitting the SPACE key prints the current camera parameters (in a format that can be included in another .scn file), `Q' quits, and F1 saves a screenshot in an image (in "imageN.jpg", for N=1,2,etc. increasing each time an image is dumped in the same session). Some of these commands are also available via a menu that pops up when the right mouse button is pressed. Of course, you are welcome to modify the source code in particleview.cpp in any way you want to produce new displays, but please keep the semantics of the existing user interface, and please provide documentation of them with your writeup.

In the provided version of the source code, the scene is drawn (with particles shown as white points), but the particle system is not implemented. Your job is to fill in the code in particle.cpp to generate, update, and render particles at each time step of the simulation. For every refresh of the window in particleview.cpp, the DrawParticles function is called. It reads the current time (in seconds since the start of the program) and calls three functions that you must implement (in particle.cpp): UpdateParticles, GenerateParticles, and RenderParticles. UpdateParticles should update the position (and possibly other parameters) of every particle at the current time. GenerateParticles should create new particles for every particle source. RenderParticles should use OpenGL commands to draw every particle on the screen. Shells are provided for these three functions in particle.cpp, but you must fill in the details.


What You Have to Do

The assignment is worth 10 points. The following is a list of features that you may implement (listed roughly from easiest to hardest within each group). The number in front of the feature corresponds to how many points the feature is worth. The features in bold face are required. The other ones are optional.

By implementing all the required features, you get 7 points. There are many ways to get more points:

Full credit is 10 points, and scores past 10 will incur diminishing returns. You should provide a working program with scripts to run it, along with short movies to demonstrate that your program works. For each movie that you submit, you also have to submit the sequence of commands used to created it.

What to Submit

Please submit a single .zip file named [your NetID]_cos426_assignment4.zip containing:

We remind you that you are expected to use good programming style at all times, including meaningful variable names, a comment or three describing what the code is doing, etc. We will test your code by running make in your src/ subdirectory, followed by make in the main assignment directory to create the output images. Please ensure that your code builds/runs in this way.

Please see the general notes on submitting your assignments, or the same notes explained in slides, as well as the late policy and the collaboration policy.

The Dropbox link to submit the assignment is here.


FAQ


Last update 17-Apr-2011 09:05:40
smr at princeton edu