METABALLS!

CSC471
Pete Corey (pcorey@calpoly.edu)


This is an implementation of a 'meta-ball' effect that does not use the Marching Cubes algorithm. I originally intended to use the algorithm to generate an approximation of the balls' surfaces, but after reading about the algorithm I realized that it would be too time consuming to implement within the time frame of this project. Instead, I have implemented a much simpler surface generation algorithm. For each location within the meta-ball 'matrix', both the cube's color and normal are calculated based on the surface of the meta-ball. It is important to note that each cube only has one color and only one normal. In a way, each cube acts as a large three dimensional pixel.

This project demonstrates the meta-ball effect by giving the user the ability to toggle between three scene configurations. The first scene consists of three differently colored balls that move in multiple directions. The second scene is simpler and only consists of one red ball and one blue ball that oscillate towards and away from each other. The third scene is fairly complex and has 4 balls that oscillate vertically. Because the complexity of each scene differs, some scenes may render slowly or in a non-real-time way. The machine that this project was developed on was able to run all scenes smoothly (3.2 Ghz dual core CPU, 4G RAM, Nvidia GeForce GTX 285).

One of the most time consuming aspects of this projects was determining a good 'drop-off' function for the meta-balls. Another time consuming aspect was trying to find a good way to generate surface normals when so little is known about the surface itself. The two equations I settled upon are below. The equation to generate the surface normals isn't completely accurate, but it generates decent approximations.
Drop-off calculation per location (p)Normal calculation per location (p)


WIncrease the surface threshold. (Makes the volumes more condensed)
SDecrease the surface threshold. (Expands the volumes)
ZSwitch to a matte material.
XSwitch to a very specular material.
CToggle between using the assigned ball color, or colored generated based on position.
BToggle bounding box, axes, and ball centers.
NToggle normals.
1Show scene #1. (3 balls)
2Show scene #2. (2 balls)
3Show scene #3. (4 balls)

The project contains a number of parameters that the user can explore in real-time using a keyboard menu.

Additionally, the user can rotate the scene using a virtual trackball (mouse control).







References:
http://en.wikipedia.org/wiki/Metaballs
http://stackoverflow.com/questions/776664/marching-cube-question
http://local.wasp.uwa.edu.au/~pbourke/geometry/polygonise/