summaryrefslogtreecommitdiffstats
path: root/Smoke/fluids.c
diff options
context:
space:
mode:
authorOliver Schinagl <oliver@schinagl.nl>2007-12-13 13:27:13 (GMT)
committerOliver Schinagl <oliver@schinagl.nl>2007-12-13 13:27:13 (GMT)
commit24b088df4b8fec9e3ba988e72f8bf2c27dbed347 (patch)
tree50642145b22589af38c9954b15ae693977a9648f /Smoke/fluids.c
parentf0135d0ef75cb8172e5d77b5918f0cc60884bd59 (diff)
download2iv35-24b088df4b8fec9e3ba988e72f8bf2c27dbed347.zip
2iv35-24b088df4b8fec9e3ba988e72f8bf2c27dbed347.tar.gz
2iv35-24b088df4b8fec9e3ba988e72f8bf2c27dbed347.tar.bz2
mouse fix
Diffstat (limited to 'Smoke/fluids.c')
-rw-r--r--Smoke/fluids.c56
1 files changed, 42 insertions, 14 deletions
diff --git a/Smoke/fluids.c b/Smoke/fluids.c
index 332924a..bcd9684 100644
--- a/Smoke/fluids.c
+++ b/Smoke/fluids.c
@@ -45,11 +45,6 @@ int color_dir = 0; //use direction color-coding or not
float vec_scale = 1000; //scaling of hedgehogs
int draw_smoke = 0; //draw the smoke or not
int draw_vecs = 1; //draw the vector field or not
-const int COLOR_BLACKWHITE=0; //different types of color mapping: black-and-white, rainbow, banded
-const int COLOR_RAINBOW=1;
-const int COLOR_BANDS=2;
-const int COLOR_WILRIK=3;
-const int COLOR_OLIVER=4;
int scalar_col = 0; //method for scalar coloring
int frozen = 0; //toggles on/off the animation
int olivers_color = 256;
@@ -82,6 +77,13 @@ float x_pos = 0.0f;
float y_pos = 0.0f;
float z_pos = -1000.0f;
+struct color4f {
+ float r;
+ float g;
+ float b;
+ float a;
+};
+
//------ SIMULATION CODE STARTS HERE -----------------------------------------------------------------
//init_simulation: Initialize simulation data structures as a function of the grid size 'n'.
@@ -346,26 +348,46 @@ float remap(float value)
}
//set_colormap: Sets three different types of colormaps
-void set_colormap(float vy, int draw_bar, float alpha)
+struct color4f set_colormap(float vy, int draw_bar, float alpha)
{
- float R,G,B;
+ float R, G, B;
+ struct color4f return_value;
if (autoscale)
{
vy = remap(vy);
}
- if (!(draw_bar))
- {
- if (vy < clamp_min) vy = clamp_min;
- if (vy > clamp_max) vy = clamp_max;
- }
+ if (!(draw_bar))
+ {
+ if (vy < clamp_min) vy = clamp_min;
+ if (vy > clamp_max) vy = clamp_max;
+ } else {
+
+ }
vy *= olivers_color;
vy = (float)(int)(vy);
vy /= olivers_color;
- if (scalar_col==COLOR_BLACKWHITE) {
+ if (scalar_col==COLOR_BLUE_GREEN_RED) {
+ if (vy < -0.1) {
+ R = G = 0;
+ vy -= -0.1;
+ vy /= 0.9;
+ B = -vy;
+ } else if (vy < 0.1) {
+ R = B = 0;
+ vy += 0.1;
+ vy /= 0.2;
+ G = vy;
+ } else {
+ vy -= 0.1;
+ vy /= 0.9;
+ R = vy;
+ G = B = 0;
+ }
+ } else if (scalar_col==COLOR_BLACKWHITE) {
R = G = B = vy;
}
else if (scalar_col==COLOR_WILRIK) {
@@ -384,6 +406,12 @@ void set_colormap(float vy, int draw_bar, float alpha)
}
glColor4f(R,G,B,alpha);
+
+ return_value.r = R;
+ return_value.g = G;
+ return_value.b = B;
+ return_value.a = alpha;
+ return return_value;
}
@@ -931,7 +959,7 @@ void keyboard(unsigned char key, int x, int y)
case 'a': frozen = 1-frozen; break;
case 'q': exit(0); break;
case 'r': toggle_mouse_rotate(); break;
- break;
+ default: break;
}
}