Dynamic Geometry Creation: Marching Cubes and Metaballs!

I have been interested in the field of computational fluid dynamics for some time, and have been researching the subject in some detail. Computation fluid dynamics is basically realistic computer modelling of liquids. Until recently, this was onyl possibly on extremely high end hardware, and/or could not be run in real time. However, several solutions have now become at least viable, if not available for real time use on personal computers.


Nvidia's work on fluid dynamics, which they call "position based fluids" is quite inspiring. It is available as part of the APEX library. Here is a video of the Library in action (Property of Nvidia):


Due to its complexity, I had not gone past the research stage before now, however, I have recently come across information regarding "metablobs". These are essentially the same as the blobs of wax that you see inside lava lamps, they float around and merge together upon contact. These blobs can be generated using an algorithm called "Marching cubes", which is relatively simple. It was copyrighted in the US until 2005, which led to a free alternative, marching tetrahedrons, being developed. It's quite rare for an algorithm, particularly one as simple as this to be copyrighted. In fact, I believe that in Europe, algorithms can't be copyrighted at all. However, the copyright has now expired, so marching cubes can be used anywhere, or at least, that's my understanding.


I have found some code here licensed under the New BSD licence, which I am using as a starting point. Ideally, I would like to get this code working in T3D, and then modify it to create some kind of water simulation. Metablobs (or Metaballs) are however, very slow, and it is unlikely that I will be able to create a fully-fledged fluid dynamics system from them. However, this would be a demonstration of dynamic geometry creation.


The vast majority of the time, a computer game loads a 3D model in order to display geometry. Creating an actual mesh in code has tremendous possibilties. Not just fluid dynamics, but what about a Terminator-2 style effect, where a model is torn apart, and then changes to a liquid state before reforming itself? Or the ability to shoot holes in characters? You could also create a voxel based level geometry system, like the original Red Faction game, allowing you to shoot through walls or even buildings. This is something that modern games rarely have.


Then there are the opportunities for dynamic content, and this is where things can get really interesting. What about entire models made from metablobs? Dynamic characters, created by the game according to a set of rules? No more one-size-fits all characters, or having to choose from a limited set of body types, clothing an armour options, hair colour, etc etc, but a completely unique character mesh? The game spore does this. The following link is to an article on Chris Heckers website, one of the people who worked on Spore. He says:


"The first thing I worked on when I started on Spore (in October, 2003) was the creature skin. Unlike games with fixed characters, like a James Bond or Lara Croft game, or games with parameterizable meshes, like the Sims or City of Heroes, Spore has to generate the entire mesh on the fly as the player makes the creature. While a typical game's fixed or parameterizable character mesh might be worked on for days in a 3D modeling tool like Maya by a professional game artist, Spore needs to regenerate the skin in real-time as the player deforms the torso and attaches and detaches limbs. I chose a blobby implicit surface (sometimes called metaballs) to represent the skin. "


For this reason, I think metablobs are a great place to start with dynamically created meshes, even if the computational fluid dynamics idea doesn't work out. At least I'll be able to make an interesting "lava-lamp" effect!

So far, the main problem seems to be loading the triangles from the dynamic mesh (generated by the marching cubes algorithm) into index and primitive buffers. Low-Level computer graphics is an area of computer science that I have not got a whole lot of experience in. I had concentrated more on higher level work, but this will be an exciting opportunity to develop those skills.

You must be a member of this blog to see the comments. Log in now!