// unpo by Ichitaro Masuda // based on // fluid3 by Glen Murphy // http://bodytag.org/ // Adjust the 'RES' variable below to change speed - higher is faster. // Don't forget to change the size command in setup if changing the // height/width. int WIDTH = 400; int HEIGHT = 800; int RES = 4; int PENSIZE = 40; int lwidth = WIDTH/RES; int lheight = HEIGHT/RES; int PNUM = 1000; vsquare[][] v = new vsquare[lwidth+1][lheight+1]; vbuffer[][] vbuf = new vbuffer[lwidth+1][lheight+1]; particle[] p = new particle[PNUM]; int pcount = 0; int mouseXvel = 0; int mouseYvel = 0; class particle { float x; float y; float old_x; float old_y; float xvel; float yvel; int pos; particle(float xIn, float yIn) { x = old_x = xIn; y = old_y = yIn; } void updatepos() { float col1; if(x > 0 && x < WIDTH && y > 0 && y < HEIGHT) { int vi = (int)(x/RES); int vu = (int)(y/RES); vsquare o = v[vi][vu]; float ax = (x%RES)/RES; float ay = (y%RES)/RES; xvel += (1-ax)*v[vi][vu].xvel*0.05; yvel += (1-ay)*v[vi][vu].yvel*0.05; xvel += ax*v[vi+1][vu].xvel*0.05; yvel += ax*v[vi+1][vu].yvel*0.05; xvel += ay*v[vi][vu+1].xvel*0.05; yvel += ay*v[vi][vu+1].yvel*0.05; o.col += 4; x += xvel; y += yvel; } xvel *= 0.5; yvel *= 0.5; yvel += 1; float speed = sqrt(xvel*xvel+yvel*yvel); speed *= 2; fill(0,20); ellipse(x,y,speed,speed); } } class vbuffer { int x; int y; float xvel; float yvel; float pressurex = 0; float pressurey = 0; float pressure = 0; vbuffer(int xIn,int yIn) { x = xIn; y = yIn; pressurex = 0; pressurey = 0; } void updatebuf(int i, int u) { if(i>0 && i0 && u0 && i0 && u