Fireworks


Class : Fireworks.h

Made By : Craig

Uses : GL_LINES

Complexity : HIGH

Shoots off a firework in a random direction. After travelling a preset height the firework explodes. The particles ejected then trail and disappear.

On creation each firework is given an initial ejection direction (randomly). The firwork then shoots up as a small dot for a height based on the height of its bounding box. Once it reaches its final height it explodes into multiple particles. These particles are shot off in random directions based on the radius of a sphere. They travel out to their max radius (this radius, or size of the canopy, is defined by the radius of the bounding box) before fading away. The effect then repeats itself at another random direction.

Fireworks are utilized with the Fireworks class, initialized with :

Fireworks f = new Fireworks (int MAX_FIREWORKS, vector3f coord, float height);

The constructor asks the user to specify the maximum number of particles (number of lines in the firework canopy), the center coordinates of the box, and the height of the box (which in turn defined the height fireworks will travel before exploding). Since fireworks use an altered box model, they are drawn with :

f -> drawFireworks();

Their bounding box is drawn with :

f -> drawBox();

As with any of the line-based effects, GL_LIGHTING must be disabled before making the call to the drawing method. The input values determine the dimensions of the bounding box as well as the size of the firework canopy :

  • Height : This value gives the height of the bounding box and it defines the distance fireworks will travel before exploding.
  • Radius : The radius value again defines the size of the bounding box (X & Z) but also in turn defines the spherical size of the firework canopy (larger values yield a longer explosion with a larger canopy).

Each firework box will only launch a single firework. To create a fireworks show will multiple fireworks (and multiple colors -- changed with the setColor#(r, g, b) method) it is necessary to create multiple fireworks boxes.

Thoughts : This effect is by far my favorite in the whole package. Aside from the test harness version running too fast everything about this effect is perfect to what I had invisioned. The effect of the exploding canopy very accurately emulates that of a real firework. The user also has control over the sizes, distances, and 3 colors of each firework, making it very customizable. There was a few functions I wished to add but ran short on time (control over intervals, curved launch trail, etc.)