CMPS-4490 - Game Development

Lab 4 - Transparency, billboarding, with particle system

Part 1:
Grab the lab files at: /home/fac/gordon/p/4490/code/smoke_lab

Place your work in Odin directory: /4490/4

Do your work on your local computer, if possible.
This program requires fast performance to operate well.
Odin is slow.

Build and run the lab4 program.

Look at the image below.
Your goal is to make those blobs look like smoke.




Sort the smoke particles
Activate the sort by pressing S.

Look in the source code to find a recommended spot to
sort the smoke particles.

1. Sort all smoke particles by distance-from-camera.

2. Sort in descending sequence.

3. Draw smoke particles in order from farthest to closest. 

4. Choose a simple-to-write sort algorithm at first.

   Such as bubblesort.


Sample code for billboadring
Activate the billboarding by pressing B.

Look in the source code to find a recommended spot to
billboard the smoke particles.

Below is psuedocode.
It is close to the actual code needed, but must be adjusted.

//Setup camera rotation matrix
//
Vec v;
VecSub(smoke.pos, camera.pos, v);
Vec z = {0.0f, 0.0f, 0.0f};
make_view_matrix(z, v, camera.mat);
//
//Billboard_to_camera();
//
float mat[16];
mat[ 0] = camera.mat[0][0];
mat[ 1] = camera.mat[0][1];
mat[ 2] = camera.mat[0][2];
mat[ 4] = camera.mat[1][0];
mat[ 5] = camera.mat[1][1];
mat[ 6] = camera.mat[1][2];
mat[ 8] = camera.mat[2][0];
mat[ 9] = camera.mat[2][1];
mat[10] = camera.mat[2][2];
mat[ 3] = mat[ 7] = mat[11] = mat[12] = mat[13] = mat[14] = 0.0f;
mat[15] = 1.0f;
glMultMatrixf(mat);
//
//Draw smoke particle here
//


billboarding tutorial


Homework...
What you don't finish of the lab becomes homework.

Additional homework:

1. Bring this smoke into your 3D lab2.cpp program.

2. Look around with your camera controls to find the smoke
   somewhere in the scene.

3. Walk up to the smoke.
   Walk around the smoke.
   The billboarding should make it look like smoke from any angle.


You may also try these...

 1. As a smoke particle grows too large, break it up into smaller particles.
 2. Apply a breeze blowing the smoke.
 3. Apply a color gradient to the particles.
 4. Apply a texture to the particles. (difficult)
 5. Show flames at the base of the smoke.


Code from class will be shown here... if any







What to turn in...
Your instructor will find your work on Odin.