summaryrefslogtreecommitdiffstats
path: root/Smoke/fluids.c
diff options
context:
space:
mode:
authorOliver Schinagl <oliver@schinagl.nl>2008-01-03 11:50:30 (GMT)
committerOliver Schinagl <oliver@schinagl.nl>2008-01-03 11:50:30 (GMT)
commitff646235f1ab52e6cb894eec0e93d6f00dc4d71c (patch)
treefaa868f360f0094005376da235827d5715c408e8 /Smoke/fluids.c
parentc2e9578dd9b5c4f547485a0db6127401c902547e (diff)
download2iv35-ff646235f1ab52e6cb894eec0e93d6f00dc4d71c.zip
2iv35-ff646235f1ab52e6cb894eec0e93d6f00dc4d71c.tar.gz
2iv35-ff646235f1ab52e6cb894eec0e93d6f00dc4d71c.tar.bz2
fixes additions etc
Diffstat (limited to 'Smoke/fluids.c')
-rw-r--r--Smoke/fluids.c133
1 files changed, 21 insertions, 112 deletions
diff --git a/Smoke/fluids.c b/Smoke/fluids.c
index 4c96636..7476a6d 100644
--- a/Smoke/fluids.c
+++ b/Smoke/fluids.c
@@ -45,15 +45,6 @@ GLuint startList;
float threshold1 = 0.2f;
float threshold2 = 2.0f;
int isolines_nr = 1;
-int prev_mx = 0;
-int prev_my = 0;
-
-// rotation and translation vars
-int rotate_plane = 0;
-int seed_insert = 0;
-float x_rot = 0.0f;
-float y_rot = 0.0f;
-float z_rot = 0.0f;
static int fluids_calculate = TRUE;
@@ -454,118 +445,36 @@ void set_autoscaling(void)
//threshold = (scale_min + scale_max) / 2;
}
-//------ INTERACTION CODE STARTS HERE -----------------------------------------------------------------
-
-void click(int button, int state, int mx, int my)
+fluids_insert_smoke(int x, int y)
{
- /* First check wether we are on the top half, or bottom half of the bar, if neither then
- * the mouseinput is for the smoke
- */
- if (!state)
- {
- prev_mx = mx;
- prev_my = my;
- }
-
- if (seed_insert)
- {
- create_seedpoint(mx, my);
- }
+ int xi,yi,X,Y; double dx, dy, len;
+ int clamp_scaled_min, clamp_scaled_max;
+ static int lx=0,ly=0; //remembers last mouse location
- if (my <25) {
- /* Click received on button bar */
- float min, max;
- if (my <13) {
- /* Upper half */
- /* check wether mx is min or max slider */
- min = colormap_get_scale_min();
- max = colormap_get_scale_max();
- if (mx <(rescale_to_winwidth(min +((max - min) /2)))) {
- active_slider = MOUSE_SCALE_MIN;
- } else if (mx >(rescale_to_winwidth(max -((max - min) /2)))) {
- active_slider = MOUSE_SCALE_MAX;
- }
- } else {
- /* Bottom half */
- min = colormap_get_clamp_min();
- max = colormap_get_clamp_max();
- /* check wether mx is min or max slider */
- if (mx <(rescale_to_winwidth(min +((max - min) /2)))) {
- active_slider = MOUSE_CLAMP_MIN;
- } else if (mx >(rescale_to_winwidth(max -((max - min) /2)))) {
- active_slider = MOUSE_CLAMP_MAX;
- }
- }
- }
-}
+ /* Density calculations etc are only computed on area's below the slider */
-void mouse_rotate(int mx, int my)
-{
- x_rot -= ((float)(my - prev_my) / 5.0f);
- y_rot -= ((float)(mx - prev_mx) / 5.0f);
+ // Compute the array index that corresponds to the cursor location
+ xi = (int)clamp((double)(DIM + 1) * ((double)x / (double)winWidth));
+ yi = (int)clamp((double)(DIM + 1) * ((double)(winHeight - y) / (double)winHeight));
- prev_mx = mx;
- prev_my = my;
-}
+ X = xi; Y = yi;
-// drag: When the user drags with the mouse, add a force that corresponds to the direction of the mouse
-// cursor movement. Also inject some new matter into the field at the mouse location.
-void drag(int mx, int my)
-{
- int xi,yi,X,Y; double dx, dy, len;
- int clamp_scaled_min, clamp_scaled_max;
- static int lmx=0,lmy=0; //remembers last mouse location
+ if (X > (DIM - 1)) X = DIM - 1; if (Y > (DIM - 1)) Y = DIM - 1;
+ if (X < 0) X = 0; if (Y < 0) Y = 0;
- /* Density calculations etc are only computed on area's below the slider */
- if (rotate_plane)
- {
- mouse_rotate(mx, my);
- return;
- }
-
- if (my > 25) {
- // Compute the array index that corresponds to the cursor location
- xi = (int)clamp((double)(DIM + 1) * ((double)mx / (double)winWidth));
- yi = (int)clamp((double)(DIM + 1) * ((double)(winHeight - my) / (double)winHeight));
-
- X = xi; Y = yi;
-
- if (X > (DIM - 1)) X = DIM - 1; if (Y > (DIM - 1)) Y = DIM - 1;
- if (X < 0) X = 0; if (Y < 0) Y = 0;
-
- // Add force at the cursor location
- my = winHeight - my;
- dx = mx - lmx; dy = my - lmy;
- len = vec_len2f(dx, dy);
- if (len != 0.0) { dx *= 0.1 / len; dy *= 0.1 / len; }
- fx[Y * DIM + X] += dx;
- fy[Y * DIM + X] += dy;
- rho[Y * DIM + X] = 10.0f;
- lmx = mx; lmy = my;
- } else {
- switch (active_slider) {
- case MOUSE_SCALE_MIN:
- colormap_set_scale_min((float)mx /winWidth);
- break;
- case MOUSE_SCALE_MAX:
- colormap_set_scale_max((float)mx /winWidth);
- break;
- case MOUSE_CLAMP_MIN:
- colormap_set_clamp_min((float)mx /winWidth);
- break;
- case MOUSE_CLAMP_MAX:
- colormap_set_clamp_max((float)mx /winWidth);
- break;
- case MOUSE_SMOKE:
- default:
- break;
- }
- }
+ // Add force at the cursor location
+ y = winHeight - y;
+ dx = x - lx; dy = y - ly;
+ len = vec_len2f(dx, dy);
+ if (len != 0.0) { dx *= 0.1 / len; dy *= 0.1 / len; }
+ fx[Y * DIM + X] += dx;
+ fy[Y * DIM + X] += dy;
+ rho[Y * DIM + X] = 10.0f;
+ lx = x; ly = y;
}
+//------ INTERACTION CODE STARTS HERE -----------------------------------------------------------------
void select_dataset(int arg) { vis_dataset = arg; }
-void toggle_mouse_rotate(void) { rotate_plane = (rotate_plane) ? FALSE : TRUE; }
-void toggle_seed_insert(void) { seed_insert = (seed_insert) ? FALSE : TRUE; }
void set_glyph_scalar(int arg) { glyph_scalar = arg; }
void set_glyph_vector(int arg) { glyph_vector = arg; }