summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOliver Schinagl <oliver@schinagl.nl>2008-01-09 11:31:25 (GMT)
committerOliver Schinagl <oliver@schinagl.nl>2008-01-09 11:31:25 (GMT)
commit4da3ab92496c596274a5efb2304a3e80f927c95a (patch)
treefa389ec594ba44d50408650ca9492e6d3ad3e051
parentf946564b55211d2550488e09c997db75a013d49e (diff)
download2iv35-4da3ab92496c596274a5efb2304a3e80f927c95a.zip
2iv35-4da3ab92496c596274a5efb2304a3e80f927c95a.tar.gz
2iv35-4da3ab92496c596274a5efb2304a3e80f927c95a.tar.bz2
new palettes
-rw-r--r--Smoke/fluids.c34
-rw-r--r--Smoke/palette.c201
-rwxr-xr-xSmoke/smoke.binbin640283 -> 640613 bytes
3 files changed, 119 insertions, 116 deletions
diff --git a/Smoke/fluids.c b/Smoke/fluids.c
index e56fcc9..d1fc279 100644
--- a/Smoke/fluids.c
+++ b/Smoke/fluids.c
@@ -469,40 +469,6 @@ void calculate_one_simulation_step(struct vis_data_arrays *vis_data)
}
//------ VISUALIZATION CODE STARTS HERE -----------------------------------------------------------------
-
-//direction_to_color: Set the current color by mapping a direction vector (x,y), using
-// the color mapping method 'method'. If method==1, map the vector direction
-// using a rainbow colormap. If method==0, simply use the white color
-void direction_to_color(float x, float y, int method)
-{
- float r,g,b,f;
-
- switch (method) {
- case 3:
- g = 1;
- break;
- case 2:
- r = 1;
- g = b = 0;
- break;
- case 1:
- f = (float)(atan2((double)y, (double)x) / 3.1415927 + 1);
- r = f;
- if(r > 1) r = 2 - r;
- g = f + 0.66667f;
- if(g > 2) g -= 2;
- if(g > 1) g = 2 - g;
- b = f + 2.0f * 0.66667f;
- if(b > 2) b -= 2;
- if(b > 1) b = 2 - b;
- break;
- case 0:
- default: r = g = b = 1;
- break;
- }
- glColor3f(r,g,b);
-}
-
float get_dataset(int index)
{
fftw_real cell_x = (fftw_real)winWidth / (fftw_real)(DIM + 1); // Grid cell width
diff --git a/Smoke/palette.c b/Smoke/palette.c
index 5a8b9bf..c0fd8b5 100644
--- a/Smoke/palette.c
+++ b/Smoke/palette.c
@@ -101,23 +101,50 @@ void RGBtoHSV(float r, float g, float b, float *h, float *s, float *v)
}
+static struct color4f blackandwhite(float value)
+{
+ struct color4f return_value;
+
+ return_value.r = value;
+ return_value.g = value;
+ return_value.b = value;
+
+ return return_value;
+}
+
//rainbow: Implements a color palette, mapping the scalar 'value' to a rainbow color RGB
-void rainbow(float value, float *R, float *G, float *B)
+static struct colorf4 rainbow(float value)
{
- const float dx = 0.8f;
+ struct color4f return_value;
+ const float dx = 0.8f;
+
+ if (value < 0) { value = 0; }
+ if (value > 1) { value = 1; }
- if (value < 0) value = 0;
- if (value > 1) value = 1;
+ value = (6 - 2 * dx) * value + dx;
- value = (6 - 2 * dx) * value + dx;
+ return_value.r = (float)max(0.0f, (3 - fabs(value - 4.0f) - fabs(value - 5.0f)) / 2.0f);
+ return_value.b = (float)max(0.0f, (4 - fabs(value - 2.0f) - fabs(value - 4.0f)) / 2.0f);
+ return_value.g = (float)max(0.0f, (3 - fabs(value - 1.0f) - fabs(value - 2.0f)) / 2.0f);
- *R = (float)max(0.0f, (3 - fabs(value - 4.0f) - fabs(value - 5.0f)) / 2.0f);
- *G = (float)max(0.0f, (4 - fabs(value - 2.0f) - fabs(value - 4.0f)) / 2.0f);
- *B = (float)max(0.0f, (3 - fabs(value - 1.0f) - fabs(value - 2.0f)) / 2.0f);
+ return return_value;
}
-void colormap_fire(float value, float *R, float *G, float *B)
+
+static struct color4f trip_like_i_do(float value)
{
+ struct color4f return_value;
+
+ return_value.r = value;
+ return_value.g = value;
+ return_value.b = value;
+
+ return return_value;
+}
+
+static struct color4f colormap_fire(float value)
+{
+ struct color4f return_value;
/* Colormap Fire
* A fire effect deals with two parts, first a drop from red to yellow (halfway)
* during which time the Red component remains full e.g. 1. The Green component is
@@ -125,91 +152,101 @@ void colormap_fire(float value, float *R, float *G, float *B)
* point, the Red and Green component (e.g. yellow) have to drop simulataniously
* to go from yellow down to black.
*/
- *B = 0;
- *G = 0;
- *R = 0;
+ return_value.r = 0;
+ return_value.b = 0;
+ return_value.g = 0;
if (value <= (0.01)) {
/* whilst value is 0 - 0.5 both red and green equally change to create yellow */
- *R = *G = value;
+ return_value.r = return_value.g = value;
} else {
/* whilst value is 0.5 - 1 Red is always fully on while the Green component is
* added in steps to go from red to orange to yellow.
*/
- *G = 0.9f - value;
- *R = 0.8f; // not 1, makes red deeper, more intense
+ return_value.g = 0.9f - value;
+ return_value.r = 0.8f; // not 1, makes red deeper, more intense
}
+
+ return return_value;
}
-//set_palette: Sets three different types of colormaps
-struct color4f set_palette(int colormap_sort, float value, int num_colors)
+static struct color4f bluegreenred(float value)
{
- float R, G, B;
- struct color4f return_value;
- const int NLEVELS = 7;
-
- value *= num_colors;
- value = (float)(int)(value);
- value /= num_colors;
-
- switch (colormap_sort)
- {
- case PALETTE_BLACKWHITE:
- R = G = B = value;
- break;
- case PALETTE_RAINBOW:
- rainbow(value,&R,&G,&B);
- break;
- case PALETTE_BANDS:
- value *= NLEVELS; value = (float)(int)(value); value/= NLEVELS;
- rainbow(value,&R,&G,&B);
- break;
- case PALETTE_BLUE_GREEN_RED:
- if (value < -0.1)
- {
- R = G = 0;
- value -= -0.1f;
- value /= 0.9f;
- B = -value;
- }
- else if (value < 0.1)
- {
- R = B = 0;
- value += 0.1f;
- value /= 0.2f;
- G = value;
- }
- else
- {
- value -= 0.1f;
- value /= 0.9f;
- R = value;
- G = B = 0;
- }
- break;
- case PALETTE_WILRIK:
- colormap_fire(value, &R, &G, &B);
- break;
- case PALETTE_OLIVER:
- rainbow(value, &R, &G, &B);
- break;
- case PALETTE_RED:
- R = 1.0f;
- G = B = 0.0f;
- break;
- case PALETTE_GREEN:
- G = 1.0f;
- R = B = 0.0f;
- break;
- case PALETTE_BLUE:
- B = 1.0f;
- R = G = 0.0f;
- break;
+ struct color4f return_value;
+
+ return_value.r = 0;
+ return_value.b = 0;
+ return_value.g = 0;
+
+ if (value < -0.1) {
+ value -= -0.1f;
+ value /= 0.9f;
+
+ return_value.b = -value;
+ } else if (value < 0.1) {
+ value += 0.1f;
+ value /= 0.2f;
+
+ return_value.g = value;
+ } else {
+ value -= 0.1f;
+ value /= 0.9f;
+
+ return_value.r = value;
}
- return_value.r = R;
- return_value.g = G;
- return_value.b = B;
+ return return_value;
+}
+
+//set_palette: Sets three different types of colormaps
+struct color4f set_palette(int colormap_sort, float value, int num_colors)
+{
+ struct color4f return_value;
+
+ return_value.r = 0;
+ return_value.b = 0;
+ return_value.g = 0;
+
+
+ value *= num_colors;
+ value = (float)(int)(value);
+ value /= num_colors;
+
+ switch (colormap_sort)
+ {
+ case PALETTE_BLACKWHITE:
+ return_value = blackandwhite(value);
+ break;
+ case PALETTE_RAINBOW:
+ return_value = rainbow(value);
+ break;
+ case PALETTE_BANDS:
+ value *= 7;
+ value = (float)(int)(value);
+ value/= 7;
+ return_value = rainbow(value);
+ break;
+ case PALETTE_BLUE_GREEN_RED:
+ return_value = bluegreenred(value);
+ break;
+ case PALETTE_WILRIK:
+ return_value = colormap_fire(value);
+ break;
+ case PALETTE_OLIVER:
+ return_value = trip_like_i_do(value);
+ break;
+ case PALETTE_RED:
+ return_value.r = 1.0f;
+ break;
+ case PALETTE_GREEN:
+ return_value.g = 1.0f;
+ break;
+ case PALETTE_BLUE:
+ return_value.b = 1.0f;
+ break;
+ default:
+ break;
+ }
- return return_value;
+ return return_value;
}
diff --git a/Smoke/smoke.bin b/Smoke/smoke.bin
index 78092e2..b5a7166 100755
--- a/Smoke/smoke.bin
+++ b/Smoke/smoke.bin
Binary files differ