An opensource C++ / Java / AS3 library for solving and displaying real-time 2D (cell-based) fluid simulations based on Navier-Stokes equations.
openFrameworks (C++) demo
Processing (Java) demo
The source code for the above demos are included with the library as an example to demonstrate how to use the features (including how to interact with the fluid using camera and/or multi-touch screens).
Some examples from the wild
This library and demo has turned out to be hugely popular and now has a life of its own. Many multi-touch / interactive dance / visuals performances use MSAFluid. Some without even changing the example parameters!
Java version (for processing) – github.com/memo/p5-MSAFluid
C++ version (for openFrameworks or Cinder) – github.com/memo/ofxMSAFluid
AS 3.0 version (ported by Eugene Zatepyakin) – blog.inspirit.ru/?p=248
The javadoc reference can be found here. A copy of the reference is also included in the .zip.
Released under the MIT License
The code is based on Jos Stam’s famous paper – Real-Time Fluid Dynamics for Games.
The demo was inspired by the brilliant Plasma Pong (even with some advice by the author, Steve Taylor, who pointed me in the direction of Jos Stam’s paper).
A lot of the fluid solving algorithms are from Jos Stam’s paper. I tried to wrap it up in an easy to use API to provide methods for adding and getting forces and color at any position. Other useful resources and implementations I looked at while developing this library are:
- Mike Ash (C)
- Alexander McKenzie (Java)
- Pierluigi Pesenti (AS3 port of Alexander’s)
- Gustav Taxen (C)
- Dave Wallin (C++) (uses portions from Gustav’s)
and some other Stam solver implementations I’ve come across since writing this are: