CMPS-4490 - Game Design

Lab 2 - Transparency and billboarding

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

Before leaving this lab session...
Place your work in Odin directory: /4490/2

I recommend that you do your work on the local Desktop.
This program required fast performance to operate properly.
Odin is too slow.

Build and run the lab2 program.

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



Optional to try later...

 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.

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.
   Sort in descending sequence.

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

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

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.m);
//
//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 Lab-1 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 will make it look like smoke from any angle.


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