Water Simulation

By Vladimir Kozyrev and Cesar Sanchez

CMPS160 Final Project

GOAL:

The goal of this project is to simulate a body of water. This includes basic reflections and wave dynamics.

Control Interface:

-The camera is FPS style, with wasd keys used to move, and the mouse changes the look direction.

-The key t will change the terrain from flat to mountains.

-Comma wil create a small disturbance.

-Forward Slash spawns a large disturbance.

-Question mark (shift-FS) will spawn an Enterprise that falls and causes a disturbance.

-Semi Colon will start a wave-trai that moves across the surface.

-Zero will reset the water

 

Features and Algorithms:

-Deformable Terrain: When the user presses T the terrain deformas. This is done by determining the difference between each

vertex and dividing it by the number of frames desired in the animation. This value is then added to the Terrain data-structure

until it reaches the desired form.

-.BMP Terrain Generation: Terrain is generated from greyscale.BPM files. The darker the shade the higher the terrain is at

that point. This allows quick large and detailed terrain generation in any image manipulation program without the need for manual point entry.

-Water Reflection: The water reflection is generated by rendering the scene upside down and generating a texture from the viewport. This is then

mapped onto the water surface with automatic texture coordinate generation. The drawback of this method is that the reflection can look wrong from

certain angles, but from the right angle is still looks more believable than Cube Mapping (but just the top view). The distortion of the

image during a wave is achieved by adding a z value to the automatic texture generation. This causes the texture to go crazy when the

surface is not flat. While this is not true reflection distortion, it does look very good.

-Animated Caustic Textures: When the user goes under the water with the camera, the surface of the terrain attains animated

caustic texture. This is basically 16 textures being rotated and applied to the terrain. Theoretically more textures can be applied

for a smoother animation.

-Physics Engine: The falling enterprise falls according to the laws of physics, including acceleration due to gravity.

-FPS Style Camera: Allows for easy movement around the scene. Determines the direction the camera is facing and

calculates how far to translate in each direction using trigonometry.

-Skybox: The skybox is rendered and rotates with the camera, but the viewer cannot reach it as it moves with the camera.

-Teapot: Teapot added to add the illusion of there being some one behind the camera holding a teapot.

Video:

video