ofxMSAFluid for openFrameworks
This is a set of C++ classes for solving and displaying real-time fluid dynamics simulations based on Navier-Stokes equations and Jos Stam's paper on Real-Time Fluid Dynamics for Games. The solver class has no dependencies on openFrameworks and can be used in any C++ project. The drawer class extends ofBaseDraws and contains an ofTexture for seamless integration with openFrameworks drawing routines. Also included in the addon is a ofxMSAParticleUpdater class which allows the fluid solver to be easily plugged into ofxMSAPhysics as a force field.
The source code for the demo above is included with the ofxMSAFluid addon. In order to use the demo with TUIO you'll need ofxTUIO and ofxOsc addons. In order to use the GUI (highly recommended to play with the fluid parameters) you'll need ofxXmlSettings (included with OF FAT package) and ofxMSAInteractiveObject + ofxSimpleGuiToo (both can be downloaded from my SVN, same place as ofxMSAFluid).
Get ofxMSAFluid (and other addons needed for the demo) here. A Java port (primarily for Processing) can be found at here.
Most of the fluid solving code is straight from Jos Stam's paper. I tried to wrap it up in an easy to use API to provide methods for adding & getting forces and color at any position. Also many thanks to Maa (www.lagraine.com) for some serious optimizations and contributing some ace features. Hopefully next version will be openCL ;)
Other useful resources and implementations I looked at and borrowed from while building this lib are:
* Mike Ash (C) - http://mikeash.com/?page=pyblog/fluid-simulation-for-dummies.html
* Alexander McKenzie (Java) - http://www.multires.caltech.edu/teaching/demos/java/stablefluids.htm
* Pierluigi Pesenti (AS3 port of Alexander's) - http://blog.oaxoa.com/2008/01/21/actionscript-3-fluids-simulation/
* Gustav Taxen (C) - http://www.nada.kth.se/~gustavt/fluids/
* Dave Wallin (C++) - http://nuigroup.com/touchlib/ (uses portions from Gustav's)
and some other Stam solver implementations I've come across since writing this are:
* Chris Sugrue & Arturo Castro (C++) - http://csugrue.com/code/?p=15
* Alain Ramos (C++) - http://code.google.com/p/ofxding/downloads/list
* Mick West - http://www.gamasutra.com/view/feature/1549/practical_fluid_dynamics_part...
* Mick West - http://www.gamasutra.com/view/feature/1615/practical_fluid_dynamics_part...
* NVidia (C / Cg) - http://developer.download.nvidia.com/SDK/9.5/Samples/gpgpu_samples.html - gpgpu is the future
...and you can find a brilliant AS3 port of this library at blog.inspirit.ru/?p=248
P.S. again, thanks to Plasma Pong for inspiring this!
Made with openFrameworks.
Delicious
Digg
StumbleUpon





