Snow


Class : Snow.h

Made By : Craig

Uses : GL_QUADS & TEXTURES

Complexity : HIGH

Simulates snow flakes falling using the box model.

The snow effect uses the same ideas as rain. The key difference is the use of textures on each particle, as well as the side to side 'flutter'.

The snow is utilized with the Snow class. It is initialized with :

Snow s = new Snow (int MAX_SNOW, vector3f coord, vector3f radius, float rand);

The constructor asks the user to specify the maximum number of snowflakes, middle coordinates of the box, and its dimensions (radius). Since the rain box uses the box model, it is drawn with :

s -> drawSnow();

... and it's surrounding box drawn with :

s -> drawBox();

Since this class uses textures it is important to initialize it after the main OpenGL commands have been set up:

  • Random : This value lies between 0 and 1. Higher values result in snow coming down in batches, and lower gives more distributed snow.
  • Speed : The speed should be between 0 and -1. This is the speed of the snow. Positive values yield snow travelling upwards.

The texture of the snowflakes can be changed whenever desired using the call below. The input must be a relative path to a .tga texture file. EX. "textures/flake.tga"

s -> setTexture(string);

Thoughts : This class is pretty neat. The snowflakes randomly choose an axis (X or Z) then their direction in that axis is applied to a sin wave. this gives them a slight flutter side to side that simulates snow fall more accurately. It is also possible to change the texture of the flakes on the fly. As well this class makes use of the windBox class to add wind effects to the snowflake particles.