msafluid library
in
Contributed Library Questions
•
1 year ago
Hi, im taking a look at the msafluid library:
http://www.memo.tv/msafluid/
Im try to execute the MSAfluidDemo.pde. The code is pasted below. I´ve made a folder called msafluid inside another folder called libraries inside the sketchbox folder as I have done with others libraries that worked correctly. I´ve put the msafluid.jar inside msafluid folder, and MSAFluidDemo.pde inside a MSAFluidDemo folder inside scketchbook.
I receive a message " the mackage msafluid does not exist. You migh be missing a library"
I´ve executed MSAFluidDemo.pde from diferent places with the same result
This is the code:
import msafluid.*;
import processing.opengl.*;
import javax.media.opengl.*;
import javax.media.opengl.*;
final float FLUID_WIDTH = 120;
float invWidth, invHeight; // inverse of screen dimensions
float aspectRatio, aspectRatio2;
float aspectRatio, aspectRatio2;
MSAFluidSolver2D fluidSolver;
ParticleSystem particleSystem;
PImage imgFluid;
boolean drawFluid = true;
void setup() {
size(960, 640, OPENGL); // use OPENGL rendering for bilinear filtering on texture
// size(screen.width * 49/50, screen.height * 49/50, OPENGL);
hint( ENABLE_OPENGL_4X_SMOOTH ); // Turn on 4X antialiasing
size(960, 640, OPENGL); // use OPENGL rendering for bilinear filtering on texture
// size(screen.width * 49/50, screen.height * 49/50, OPENGL);
hint( ENABLE_OPENGL_4X_SMOOTH ); // Turn on 4X antialiasing
invWidth = 1.0f/width;
invHeight = 1.0f/height;
aspectRatio = width * invHeight;
aspectRatio2 = aspectRatio * aspectRatio;
invHeight = 1.0f/height;
aspectRatio = width * invHeight;
aspectRatio2 = aspectRatio * aspectRatio;
// create fluid and set options
fluidSolver = new MSAFluidSolver2D((int)(FLUID_WIDTH), (int)(FLUID_WIDTH * height/width));
fluidSolver.enableRGB(true).setFadeSpeed(0.003).setDeltaT(0.5).setVisc(0.0001);
fluidSolver = new MSAFluidSolver2D((int)(FLUID_WIDTH), (int)(FLUID_WIDTH * height/width));
fluidSolver.enableRGB(true).setFadeSpeed(0.003).setDeltaT(0.5).setVisc(0.0001);
// create image to hold fluid picture
imgFluid = createImage(fluidSolver.getWidth(), fluidSolver.getHeight(), RGB);
imgFluid = createImage(fluidSolver.getWidth(), fluidSolver.getHeight(), RGB);
// create particle system
particleSystem = new ParticleSystem();
particleSystem = new ParticleSystem();
// init TUIO
initTUIO();
}
initTUIO();
}
void mouseMoved() {
float mouseNormX = mouseX * invWidth;
float mouseNormY = mouseY * invHeight;
float mouseVelX = (mouseX - pmouseX) * invWidth;
float mouseVelY = (mouseY - pmouseY) * invHeight;
addForce(mouseNormX, mouseNormY, mouseVelX, mouseVelY);
}
}
void draw() {
updateTUIO();
fluidSolver.update();
updateTUIO();
fluidSolver.update();
if(drawFluid) {
for(int i=0; i<fluidSolver.getNumCells(); i++) {
int d = 2;
imgFluid.pixels[i] = color(fluidSolver.r[i] * d, fluidSolver.g[i] * d, fluidSolver.b[i] * d);
}
imgFluid.updatePixels();// fastblur(imgFluid, 2);
image(imgFluid, 0, 0, width, height);
}
for(int i=0; i<fluidSolver.getNumCells(); i++) {
int d = 2;
imgFluid.pixels[i] = color(fluidSolver.r[i] * d, fluidSolver.g[i] * d, fluidSolver.b[i] * d);
}
imgFluid.updatePixels();// fastblur(imgFluid, 2);
image(imgFluid, 0, 0, width, height);
}
particleSystem.updateAndDraw();
}
}
void mousePressed() {
drawFluid ^= true;
}
drawFluid ^= true;
}
void keyPressed() {
switch(key) {
case 'r':
renderUsingVA ^= true;
println("renderUsingVA: " + renderUsingVA);
break;
}
println(frameRate);
}
switch(key) {
case 'r':
renderUsingVA ^= true;
println("renderUsingVA: " + renderUsingVA);
break;
}
println(frameRate);
}
// add force and dye to fluid, and create particles
void addForce(float x, float y, float dx, float dy) {
float speed = dx * dx + dy * dy * aspectRatio2; // balance the x and y components of speed with the screen aspect ratio
void addForce(float x, float y, float dx, float dy) {
float speed = dx * dx + dy * dy * aspectRatio2; // balance the x and y components of speed with the screen aspect ratio
if(speed > 0) {
if(x<0) x = 0;
else if(x>1) x = 1;
if(y<0) y = 0;
else if(y>1) y = 1;
if(x<0) x = 0;
else if(x>1) x = 1;
if(y<0) y = 0;
else if(y>1) y = 1;
float colorMult = 5;
float velocityMult = 30.0f;
float velocityMult = 30.0f;
int index = fluidSolver.getIndexForNormalizedPosition(x, y);
color drawColor;
colorMode(HSB, 360, 1, 1);
float hue = ((x + y) * 180 + frameCount) % 360;
drawColor = color(hue, 1, 1);
colorMode(RGB, 1);
float hue = ((x + y) * 180 + frameCount) % 360;
drawColor = color(hue, 1, 1);
colorMode(RGB, 1);
fluidSolver.rOld[index] += red(drawColor) * colorMult;
fluidSolver.gOld[index] += green(drawColor) * colorMult;
fluidSolver.bOld[index] += blue(drawColor) * colorMult;
fluidSolver.gOld[index] += green(drawColor) * colorMult;
fluidSolver.bOld[index] += blue(drawColor) * colorMult;
particleSystem.addParticles(x * width, y * height, 10);
fluidSolver.uOld[index] += dx * velocityMult;
fluidSolver.vOld[index] += dy * velocityMult;
}
}
fluidSolver.uOld[index] += dx * velocityMult;
fluidSolver.vOld[index] += dy * velocityMult;
}
}
1