Final Project
CS280
Winter 2004
Jason Wither
&
Sean Tucker
Metaball Modeling of Dynamic
Water Fountain
Introduction
To create our dynamic water fountain we created a model of a particle fountain based on random numbers in OpenGL [1]. The coordinates of the particles were then captured to file for further processing with the marching tetrahedra algorithm. The output of the marching tetrahedra processing was written to a format readable by POV-Ray [2]. This process was performed for each frame of the final movie. These frames were then rendered with POV-Ray. The frames rendered by POV-Ray were coded into a movie to demonstrate the dynamic fountain in action.
Model Fountain
To create the initial particle fountain a randomly generated fountain of spheres was created using OpenGL. Unique random numbers were generated for each of the following characteristics for each particle: speed, change along the x-axis and z-axis, time to live, and the strength and size. This gave each particle its own unique characteristic aiding to the dynamic effect. The time to live value was used to calculate the change along the y-axis. It was incremented by a set value each frame causing the change along the y-axis to increase initially and then decrease creating the effect of a particle being tossed up in the air and falling back to earth. A water surface with wave simulation was also placed at the bottom of the fountain to increase the lifelike quality of the fountain. Further each particle generated a splash of smaller particles when it reached the waterÕs surface. To use this model for the next step of our water fountain, the coordinates were captured to file for later processing. Three hundred continuous frames where captured to be processed with the marching tetrahedral algorithm explained below. An example screen shot from the modeling fountain is displayed below is the screen shot section.
Metaballs / Marching Tetrahedra / Rendering
Once we had a fountain of particles we needed a way to render an implicit surface around those particles. To do this we defined a field strength being emitted from each particle, and a fall-off rate for that field. Our implicit surface is then simply defined as a certain cutoff in that field. Every point in space that has a greater influence from the particles than our given cutoff falls inside of our objects, and every point that has a smaller influence falls outside. The example below illustrates how an implicit surface like this acts as two point sources are moved further and further away from each other.

[3]
This still leaves the problem of evaluating points in space, and from that generating a coherent surface. We used marching tetrahedra to solve this problem. Our marching tetrahedra algorithm evaluates a given number of grid points, where each point is part of a number of tetrahedra that fill the entire volume. If some corners of a given tetrahedron are inside the surface, and some are outside, then we know that our implicit surface cuts through that tetrahedron, and we need to add either one or two (depending on the cut) triangles to our implicit surface mesh.
After we generated a triangle mesh we needed a way to render it. We decided to use POV-Ray, a free professional level raytracer to do this, rather than writing something ourselves to do this rendering, so that we could get better looking results, and concentrate on generating our surface. We are very happy with our results, and then in retrospect that this was an excellent decision.
Metaballs
Creating the field from the set of particles was not a very large problem. The most interesting part was picking a good function to define falloff with distance from a given particle. Although we were inspired by papers about metaballs we did not actually use the field strength function defined for metaballs. Instead we used a very similar one with a different name. The creator called their implicit surface a soft surface instead of metaballs. We used the function:
where a is a scaling factor, and b is the maximum distance that the function has any
influence over. Once r (the distance from a particle) is greater than b the function just evaluates to 0. We chose to use this function because
of its similar shape to the metaballs function, and the fact that it is faster
to evaluate than the metaballs function which involves taking square roots.
Marching Tetrahedra
To
evaluate our implicit surface we used marching tetrahedra. We grouped six tetrahedra together at a
time to for a solid cube, this could have been done with only five tetrahedra,
but by using six there is no need to reorient them between cubes.
It is important to have coherence between cubes, so that all the tetrahedra in the entire grid share edges, so when a certain edge is found to have the surface going through it that surface point is used for multiple tetrahedra. If the edges of the different tetrahedra were not the same there would be holes in the final mesh where the edges did not line up properly.

When dividing a single tetrahedron there are eight possible split cases, enumerated here. Through symmetry though these can be reduced to only three cases, all four vertices are either in or out, one vertex is different than the other three, or there are two vertices in and two out. When all four are on the same side we donÕt have to do anything, when one is different than we split the three edges leading to that vertex, and create a single triangle, and when there are two and two we have to split four edges, and can make two triangles from those four points.
When splitting an edge it is important to create the vertex for the surface as near as possible to where the field evaluates to the cutoff strength. Using the midpoint or some other static split results in very strange, blocky looking results. We found though that by simply doing a linear interpolation between the strengths at the two endpoints we were able to achieve nice looking results.
We also took advantage of the coherence between different tetrahedra to make a single mesh of triangles that share vertices, rather than individual triangles with vertices at the same points. This allowed us to do per vertex smooth shading which greatly improved the look of our surfaces.
POV-Ray
To create our final images we exported the triangle mesh generated by the marching tetrahedra, and the one for the water surface to POV-Ray, where we added a cornell box and some lights to properly show our transparent water. We also added caustics in POV-Ray to make the water simulation look more realistic. POV-Ray rendered one of our frames in an average of four minutes.
Screen Shots
|
|
|
Example of the model used for the particle fountain |
|
|
|
Example of Particles after Processing with Marching Tetrahedra |
|
|
|
Example of a Coarse Marching Tetrahedra Grid |
|
|
|
Screen Shot from Final Movie |
Links
References
[1] - http://www.opengl.org/
[2] - http://www.povray.org/
[3] - http://astronomy.swin.edu.au/~pbourke/modelling/implicitsurf/
[4] - http://astronomy.swin.edu.au/~pbourke/modelling/polytetra/