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. Almost every multi-touch / interactive dance / visuals performance I’ve seen uses MSAFluid. Some without even changing the parameters!
MSAFluid is an opensource C++ / Java / AS3 library for solving and displaying real-time 2D fluid simulations based on Navier-Stokes equations.
If your browser supports Java you can play with an interactive online version here.
Java version (for processing) –
C++ version (for openFrameworks or Cinder) –
AS 3.0 version (ported by Eugene Zatepyakin) –
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: