COS 426:
Computer Graphics
Spring 2013


General | Syllabus | Assignments | Final Project


Assignment 4: Particle Systems

Due Tuesday, April 30, 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. 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), particle springs (R), particle source and sinks (S), faces (F), edges (E), node bounding boxes (B), lights (L), and the camera (C). 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 new features with your writeup.

In the skeleton code, the scene is drawn, 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 as in previous assignments. You should provide a working program with short gifs to demonstrate that your program works.

What to Submit

Following the general guidelines from previous assignments, please submit a single .zip file named [your NetID]_cos426_assignment4.zip containing:

For this assignment, you do not need to submit a Makefile to reproduce your output gifs. Please note any changes or additions you make to the behavior of particleview in your writeup.

The Dropbox link to submit the assignment is here.