summaryrefslogtreecommitdiffstats
path: root/Smoke/fluids.c
diff options
context:
space:
mode:
authorOliver Schinagl <oliver@schinagl.nl>2007-12-14 18:02:27 (GMT)
committerOliver Schinagl <oliver@schinagl.nl>2007-12-14 18:02:27 (GMT)
commit5a422dac78479f396437b5f9c1e8efbecf2c9b0f (patch)
treeb9910125b40708a3cd496ec46312012350886a7c /Smoke/fluids.c
parent241bfc64ed6446c295846d5ae635f6ba4e25a666 (diff)
download2iv35-5a422dac78479f396437b5f9c1e8efbecf2c9b0f.zip
2iv35-5a422dac78479f396437b5f9c1e8efbecf2c9b0f.tar.gz
2iv35-5a422dac78479f396437b5f9c1e8efbecf2c9b0f.tar.bz2
latest merge
Diffstat (limited to 'Smoke/fluids.c')
-rw-r--r--Smoke/fluids.c61
1 files changed, 25 insertions, 36 deletions
diff --git a/Smoke/fluids.c b/Smoke/fluids.c
index 0f46d84..7614610 100644
--- a/Smoke/fluids.c
+++ b/Smoke/fluids.c
@@ -15,6 +15,7 @@
#include "glyphs.h"
#include "seedpoint.h"
#include "streamlines.h"
+#include "palette.h"
#include "funcs.h"
//--- SIMULATION PARAMETERS ------------------------------------------------------------------------
@@ -47,7 +48,7 @@ int vis_dataset = DATASET_RHO;
int mousebutton;
int mousebuttonstate;
int active_slider = 0;
-int use_glyphs = GLYPHS_OFF;
+int use_glyphs = FALSE;
int glyph_scalar = SCALAR_RHO;
int glyph_vector = VECTOR_VEL;
int glyph_sort = GLYPH_CYLINDERS;
@@ -417,6 +418,7 @@ void draw_isolines(float threshold)
float x0, y0, x1, y1, x_offset, y_offset;
int state = 0;
static int prev_state = 0;
+ struct color4f colormap;
v0 = v1 = v2 = v3 = 0.0f;
x0 = y0 = x1 = y1 = 0.0f;
@@ -431,7 +433,8 @@ void draw_isolines(float threshold)
{
state = 0;
idx = (j * DIM) + i;
- set_colormap(scalar_col, get_dataset(idx), 0, 1.0f);
+ colormap = set_colormap(scalar_col, get_dataset(idx), 1.0f);
+ glColor4f(colormap.r, colormap.g, colormap.b, 1.0f);
v0 = get_dataset(idx + DIM);
v1 = get_dataset(idx + 1 + DIM);
@@ -527,6 +530,7 @@ void render_smoke(void)
fftw_real hn = (fftw_real)winHeight / (fftw_real)(DIM + 1); // Grid cell height
static int delay = 0;
float hight_value = 0.0f;
+ struct color4f colormap;
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
@@ -547,19 +551,22 @@ void render_smoke(void)
px = wn + (fftw_real)i * wn;
py = hn + (fftw_real)(j + 1) * hn;
idx = ((j + 1) * DIM) + i;
- set_colormap(scalar_col, get_dataset(idx), FALSE, 1.0f);
+ colormap = set_colormap(scalar_col, get_dataset(idx), 1.0f);
+ glColor4f(colormap.r, colormap.g, colormap.b, 1.0f);
glVertex3f(px, py, height_array[idx]);
px = wn + (fftw_real)(i + 1) * wn;
py = hn + (fftw_real)j * hn;
idx = (j * DIM) + (i + 1);
- set_colormap(scalar_col, get_dataset(idx), FALSE, 1.0f);
+ colormap = set_colormap(scalar_col, get_dataset(idx), 1.0f);
+ glColor4f(colormap.r, colormap.g, colormap.b, 1.0f);
glVertex3f(px, py, height_array[idx]);
}
px = wn + (fftw_real)(DIM - 1) * wn;
py = hn + (fftw_real)(j + 1) * hn;
idx = ((j + 1) * DIM) + (DIM - 1);
- set_colormap(scalar_col, get_dataset(idx), FALSE, 1.0f);
+ colormap = set_colormap(scalar_col, get_dataset(idx), 1.0f);
+ glColor4f(colormap.r, colormap.g, colormap.b, 1.0f);
glVertex3f(px, py, height_array[idx]);
glEnd();
}
@@ -574,6 +581,7 @@ void visualize(void)
fftw_real hn = (fftw_real)winHeight / (fftw_real)(DIM + 1); // Grid cell height
static int delay = 0;
float hight_value = 0.0f;
+ struct color4f colormap;
glTranslatef(xPos, yPos, zPos);
@@ -581,9 +589,13 @@ void visualize(void)
{
float value, clamp_scaled_min, clamp_scaled_max, scale_scaled_min, scale_scaled_max;
+
value = (float)((float)i/winWidth);
- set_colormap(scalar_col, value, TRUE, 1.0f);
+// if (value < clamp_min) value = clamp_min;
+// if (value > clamp_max) value = clamp_max;
+ colormap = set_colormap(scalar_col, value, 1.0f);
+
clamp_scaled_min = clamp_min *winWidth;
clamp_scaled_max = clamp_max *winWidth;
@@ -601,10 +613,11 @@ void visualize(void)
glVertex2i(i +1, winHeight -6);
glVertex2i(i +1, winHeight -22);
} else {
+ glColor3f(colormap.r, colormap.g, colormap.b);
glVertex2i(i, winHeight -6);
glVertex2i(i, winHeight -18);
}
- glColor3f(0.2, 0.2, 0.2);
+ glColor4f(0.2, 0.2, 0.2, 1.0);
glVertex2i(clamp_scaled_min, winHeight -6);
glVertex2i(clamp_scaled_min, winHeight -18);
glVertex2i(clamp_scaled_max, winHeight -6);
@@ -676,30 +689,6 @@ void visualize(void)
//------ INTERACTION CODE STARTS HERE -----------------------------------------------------------------
-
-//keyboard: Handle key presses
-void keyboard(unsigned char key, int x, int y)
-{
- switch (key)
- {
- case 't': dt -= 0.001; break;
- case 'T': dt += 0.001; break;
- case 'c': color_dir = (color_dir +1) %3; break;
- case 'S': vec_scale *= 1.2f; break;
- case 's': vec_scale *= 0.8f; break;
- case 'V': visc *= 5.0f; break;
- case 'v': visc *= 0.2f; break;
- case 'y': toggle_glyph_usage(); break;
- case 'x': toggle_smoke_usage(); break;
- case 'm': scalar_col++; if (scalar_col>COLOR_OLIVER) scalar_col=COLOR_BLACKWHITE; break;
- case 'a': frozen = 1-frozen; break;
- case 'q': exit(0); break;
- case 'r': toggle_mouse_rotate(); break;
- case 'e': toggle_seed_insert(); break;
- default: break;
- }
-}
-
void click(int button, int state, int mx, int my)
{
/* First check wether we are on the top half, or bottom half of the bar, if neither then
@@ -802,14 +791,14 @@ void drag(int mx, int my)
}
}
-void zoom_in(void)
+void zoom_in(int zoom)
{
- z_pos += 20;
+ z_pos += zoom;
}
-void zoom_out(void)
+void zoom_out(int zoom)
{
- z_pos -= 20;
+ z_pos -= zoom;
}
int get_glyph_usage(void) { return use_glyphs; }
@@ -846,4 +835,4 @@ int get_glyph_sort(void)
void set_glyph_sort(int sort)
{
glyph_sort = sort;
-} \ No newline at end of file
+}