public class DwFluid2D extends Object
Modifier and Type | Class and Description |
---|---|
static interface |
DwFluid2D.Advect |
static interface |
DwFluid2D.FluidData |
static class |
DwFluid2D.Param |
Modifier and Type | Field and Description |
---|---|
DwPixelFlow |
context |
int |
fluid_h |
int |
fluid_w |
int |
GPU_DATA_READ |
int |
grid_scale |
DwFluid2D.Param |
param |
int |
simulation_step |
DwGLTexture |
tex_curl |
DwGLTexture.TexturePingPong |
tex_density |
DwGLTexture |
tex_divergence |
DwGLTexture.TexturePingPong |
tex_obstacleC |
DwGLTexture.TexturePingPong |
tex_obstacleN |
DwGLTexture.TexturePingPong |
tex_pressure |
DwGLTexture.TexturePingPong |
tex_temperature |
DwGLTexture.TexturePingPong |
tex_velocity |
int |
viewp_h |
int |
viewp_w |
Constructor and Description |
---|
DwFluid2D(DwPixelFlow context,
int viewport_width,
int viewport_height,
int fluidgrid_scale) |
Modifier and Type | Method and Description |
---|---|
void |
addCallback_Advect(DwFluid2D.Advect cb_advect) |
void |
addCallback_FluiData(DwFluid2D.FluidData cb_fluid_data) |
void |
addDensity(float px,
float py,
float radius,
float r,
float g,
float b,
float intensity) |
void |
addDensity(float px,
float py,
float radius,
float r,
float g,
float b,
float intensity,
int blend_mode) |
void |
addDensity(processing.opengl.PGraphics2D pg,
float intensity_scale,
int blend_mode,
float mix) |
void |
addObstacles(processing.opengl.PGraphics2D pg) |
void |
addTemperature(float px,
float py,
float radius,
float temperature) |
void |
addVelocity(float px,
float py,
float radius,
float vx,
float vy) |
void |
addVelocity(float px,
float py,
float radius,
float vx,
float vy,
int blend_mode,
float mix) |
void |
dispose() |
float[] |
getDensity(float[] data_F4) |
float[] |
getDensity(float[] data_F4,
int x,
int y,
int w,
int h)
example code for filling the pixels of a pgraphics object
float[] px_density = Fluid.getDensity(null);
PGraphics2D pg = (PGraphics2D) createGraphics(Fluid.fluid_w, Fluid.fluid_h, P2D);
pg.loadPixels();
for(int i = 0, ii = 0; i < pg.pixels.length; i++){
float x = px_density[ii++];
float y = px_density[ii++];
float z = px_density[ii++];
float w = px_density[ii++];
w = constrain(w, 0, 1);
int r = (int)(255 * x / w);
int g = (int)(255 * y / w);
int b = (int)(255 * z / w);
int a = (int)(255 * w);
pg.pixels[i] = a << 24 | r << 16 | g << 8 | b;
}
pg.updatePixels();
|
float[] |
getVelocity(float[] data_F4) |
float[] |
getVelocity(float[] data_F4,
int x,
int y,
int w,
int h) |
void |
release() |
void |
renderFluidTextures(processing.opengl.PGraphics2D dst,
int display_mode) |
void |
renderFluidVectors(processing.opengl.PGraphics2D dst,
int spacing) |
void |
reset() |
void |
resize(int viewport_width,
int viewport_height,
int fluidgrid_scale) |
void |
update() |
void |
update(float timestep) |
public DwPixelFlow context
public int simulation_step
public int grid_scale
public int fluid_w
public int fluid_h
public int viewp_w
public int viewp_h
public DwFluid2D.Param param
public DwGLTexture.TexturePingPong tex_velocity
public DwGLTexture.TexturePingPong tex_density
public DwGLTexture.TexturePingPong tex_pressure
public DwGLTexture.TexturePingPong tex_temperature
public DwGLTexture.TexturePingPong tex_obstacleC
public DwGLTexture.TexturePingPong tex_obstacleN
public DwGLTexture tex_divergence
public DwGLTexture tex_curl
public int GPU_DATA_READ
public DwFluid2D(DwPixelFlow context, int viewport_width, int viewport_height, int fluidgrid_scale)
public void dispose()
public void release()
public void reset()
public void resize(int viewport_width, int viewport_height, int fluidgrid_scale)
public void update(float timestep)
public void update()
public void renderFluidTextures(processing.opengl.PGraphics2D dst, int display_mode)
public void renderFluidVectors(processing.opengl.PGraphics2D dst, int spacing)
public float[] getVelocity(float[] data_F4, int x, int y, int w, int h)
public float[] getVelocity(float[] data_F4)
public float[] getDensity(float[] data_F4, int x, int y, int w, int h)
float[] px_density = Fluid.getDensity(null);
PGraphics2D pg = (PGraphics2D) createGraphics(Fluid.fluid_w, Fluid.fluid_h, P2D);
pg.loadPixels();
for(int i = 0, ii = 0; i < pg.pixels.length; i++){
float x = px_density[ii++];
float y = px_density[ii++];
float z = px_density[ii++];
float w = px_density[ii++];
w = constrain(w, 0, 1);
int r = (int)(255 * x / w);
int g = (int)(255 * y / w);
int b = (int)(255 * z / w);
int a = (int)(255 * w);
pg.pixels[i] = a << 24 | r << 16 | g << 8 | b;
}
pg.updatePixels();
data_F4
- public float[] getDensity(float[] data_F4)
public void addVelocity(float px, float py, float radius, float vx, float vy)
public void addVelocity(float px, float py, float radius, float vx, float vy, int blend_mode, float mix)
public void addDensity(float px, float py, float radius, float r, float g, float b, float intensity)
public void addDensity(float px, float py, float radius, float r, float g, float b, float intensity, int blend_mode)
public void addTemperature(float px, float py, float radius, float temperature)
public void addDensity(processing.opengl.PGraphics2D pg, float intensity_scale, int blend_mode, float mix)
public void addObstacles(processing.opengl.PGraphics2D pg)
public void addCallback_FluiData(DwFluid2D.FluidData cb_fluid_data)
public void addCallback_Advect(DwFluid2D.Advect cb_advect)
Processing library PixelFlow by Thomas Diewald. (c) 2017