Problems with ofxMSAFluid

Hi all

i tried to use OFXMSAFLUID for…-AFluid/src

but when i tried to compile apper an error

ofxMSAParticleUpdater.h: No such file or directory

i have all files but never appear the particle updater apper the MSAFluidParticleupdater

Anyone now how can i use this addon ??

thx :slight_smile:

If anyone have this problem you need to added ofxMSAPhysic and ofxObjCPointer, and works ok.

This MSAFluids not have yet documentacion but memo say the idea is CREATE the Fluid, UPDATE THE FLUID and finaly DRAW the fluid.

I created fluid with .init(width,higth,velocity,biscosity,movement) or somethinf like that in SETUP.

I update i user .update()

and in dra i used .draw(x,y,SIZE X,SIZE Y);

but nots works, anyone can helpme with an example of this Addon



You shouldn’t really need ofxMSAPhysics and ofxObjCPointer to use the fluid lib. THe ofxMSAParticleUpdater is only supposed to be defined if you *are* using ofxMSAPhysics, and not defined if you are not. But I"ll look into it.

If you are using the latest version of fxMSAFluid from the svn, then the setup is a bit different, I’ve simplified it a bit, and made it a bit more ofw-like. Sorry that there is no documentation, but I will add that in the near future. In the meantime, you can look at the header file:…-idSolver.h

You setup with

        ofxMSAFluidSolver& setup(int NX = FLUID_DEFAULT_NX, int NY = FLUID_DEFAULT_NY);  

and then can use

        ofxMSAFluidSolver& enableRGB(bool isRGB);  
        ofxMSAFluidSolver& setDeltaT(float dt = FLUID_DEFAULT_DT);  
        ofxMSAFluidSolver& setFadeSpeed(float fadeSpeed = FLUID_DEFAULT_FADESPEED);  
        ofxMSAFluidSolver& setSolverIterations(int solverIterations = FLUID_DEFAULT_SOLVER_ITERATIONS);  

to further customize the some properties of the fluid solver.

The above is for the fluid solver, which does the solving. if you want to draw the fluid, you need a FluidDrawer as well.…-idDrawer.h

You can either:

  • create your FluidSolver yourself, then add it to the FluidDrawer for it to draw.
  • OR just tell FluidDrawer to create a Solver, and access the solver through that.

hope that makes sense, wlil post a very simple example soon.

I help you with the documentacion and with examples i see this librarys and i think can help the people so much, look for my examples and documentes for yours librarys very soon…


Hello… well I’m not having any compile issues with the ofxMSAFluid add-on, but I am having troubles getting it to draw anything besides a blank white area.

I am using an ofxMSAFluidDrawer… and in my update method, I do something like this:

	ofxMSAFluidSolver* fluidSolver = fluid.getFluidSolver();  
	fluidSolver->addForceAtPos(nx, ny, dx, dy);  
	fluidSolver->addColorAtPos(nx, ny, 1.0, 0.5, 0.0);  

where dx and dy are floating point values read from an optical flow analyzer.

Was wondering if anyone has a simple example testApp using ofxMSAFluid?

Hey, Firstly try calling solver->randomizeColor(). That fills it with random colors useful for debugging drawing problems. If you call that and still can’t see it ,problem is in the drawing, otherwise problem is in adding dye. Btw are nx and ny normalized pos values? Also you will probably need to scale down the optical flow vels too.

Oh by the way, where did you get the addon from? Zip or svn? Last time I used it was on iPhone (gold dust uses it) and I might have disabled textures :o Check the fluiddrawer class for a usetexture #define.

I got the add-on from svn ( nx and ny are normalized values, between 0 and 1.

There is a #define FLUID_TEXTURE at the top of ofxMSAFluidDrawer.h

I added the fluidSolver->randomizeColor() call, and got it drawing a pretty psychedelic image! lol it looks cool flashing colours.

Guess now that that’s working, I will start tweaking values till things are more what I’m after.

Thanks for the help!

here is a sample set of min/max for of all my values.

–update values–
min nx: 0
max nx: 0.99375
min ny: 0
max ny: 0.991667
min dx: -1.36882
max dx: 0.477354
min dy: -0.780231
max dy: 1.65471

I use the values from those ranges in
fluidSolver->addForceAtPos(nx, ny, dx*this->flowToFluidMultiplier, dy*this->flowToFluidMultiplier);

I’ve been playing with the flowToFluidMultiplier value, and it seems to make a difference… but I can’t seem to get anything really fluid like. It mostly looks like static, but I can see a little bit of my motions reflected in it.

I get the same thing I’m assuming plong0 (a somewhat static looking image; no fluid really).

Memo, I tried using the values from your processing app for the most part, but I don’t get anything similar looking. I’m using tbeta right now (all the values are normalized already). It should theoretically work similar to if using TUIO. I’m thinking I’m missing some setup values and proper drawing. After about 30 seconds it also gets really slow and unusable (2fps) and occasionally the whole screen fills up with a solid color and then everything stops. I’m clearly missing something heh.

I’m not exactly sure where the update, draw, and random color go and in what order.

hmm, ok weird. I use msafluid for nearly all my projects, reincarnation, body paint etc so I know it works, maybe i’m forgetting to tell you guys a step. I’m away from home at the moment, when I get back later on in the week I’ll post a sample.

P.S. Seth, does tbeta send tuio velocity values? Cos the version thats out there doesnt I think.

Hi memo :slight_smile:

Yeah, I’m the one developing tbeta right now so I have velocity in. Values are generally from:

min nx: 0
max nx: 1
min ny: 0
max ny: 1
min dx: -.003
max dx: 0.2125
min dy: -0.003
max dy: 0.2125

Do those values look about right?

I’m doing something like this right now:

std::map<int, Blob> blobs;  
std::map<int, Blob>::iterator iter;  
blobs = tbeta->getBlobs(); //get blobs from tracker  
for(iter=blobs.begin(); iter!=blobs.end(); iter++)  
	Blob drawBlob;  
	drawBlob = iter->second;  
	fluid.getFluidSolver()->addForceAtPos(drawBlob.centroid.x, drawBlob.centroid.y, drawBlob.D.x, drawBlob.D.y);  
	fluid.getFluidSolver()->addColorAtPos(drawBlob.centroid.x, drawBlob.centroid.y, 1.0, 1.0, 1.0);	  
ofSetColor(0xFF0000); //draws read fluid?  
fluid.drawColor(0,0, ofGetWidth(), ofGetHeight());  

If I set fluid.getFluidSolver()->randomizeColor(); then I get a static looking image on the whole page. If I don’t addColorAtPos(), I get nothing drawn and if I don’t ofSetColor() I get nothing (probably black). So it appears it’s not using the color of the texture, but the tint of ofSetColor().

Also, when there are no blobs (fingers) the movement/velcocity and fade stops. So the fluid will stay on screen forever if there are no fingers. Also, the fluid doesn’t really flow, as in it kind of just appears where fingers are (no continual movement).

I have fluid.update in the update function and the rest in the draw function. I’m currently using tbeta as an addon (not through tuio), but the blob data is the same.

I’m still trying to get MSAFluids to work but without success! Does any one have any working examples or documentation to help me on my way? Any help would be greatly appreciated! :slight_smile:


Hi, yea I have an example ready, I’m waiting for a friend who is doing some hardcore optimizations on the solver (about 10% - 100% faster!!) and I"ll upload the new solver and the example later on today. Here is a little teaser :wink: I’ll be posting the source of that app (supports tuio too).

Awesome! I just grabbed the optimized code! Very exciting! Thanks! Keep up the amazing work!


example is up;-demo-with-tuio/1915/0