diff options
author | Oliver Schinagl <oliver@schinagl.nl> | 2007-12-18 18:24:04 (GMT) |
---|---|---|
committer | Oliver Schinagl <oliver@schinagl.nl> | 2007-12-18 18:24:04 (GMT) |
commit | c287b3f591fe3e10dceedfd90a5ce71b2c703988 (patch) | |
tree | 98a1fe82d85e97199b099a720e9784064f8430b9 /Smoke/fluids.c | |
parent | 9363bc6887a7ffb9ea6c0f6a63a93c215e227502 (diff) | |
download | 2iv35-c287b3f591fe3e10dceedfd90a5ce71b2c703988.zip 2iv35-c287b3f591fe3e10dceedfd90a5ce71b2c703988.tar.gz 2iv35-c287b3f591fe3e10dceedfd90a5ce71b2c703988.tar.bz2 |
More cleaning up, seperating modules etc
Diffstat (limited to 'Smoke/fluids.c')
-rw-r--r-- | Smoke/fluids.c | 79 |
1 files changed, 13 insertions, 66 deletions
diff --git a/Smoke/fluids.c b/Smoke/fluids.c index 59984aa..c9b54e4 100644 --- a/Smoke/fluids.c +++ b/Smoke/fluids.c @@ -10,6 +10,10 @@ #include <math.h> #include <stdio.h> +#include <rfftw.h> +#include <GL/gl.h> +#include <GL/glu.h> + #include "fluids.h" #include "palette.h" #include "colormap.h" @@ -35,7 +39,7 @@ rfftwnd_plan plan_rc, plan_cr; //simulation domain discretization int winWidth, winHeight; //size of the graphics window, in pixels 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 +static int fluids_render_smoke = FALSE; int draw_vecs = 1; //draw the vector field or not int scalar_col = 0; //method for scalar coloring int frozen = 0; //toggles on/off the animation @@ -60,17 +64,17 @@ int seed_insert = 0; float x_rot = 0.0f; float y_rot = 0.0f; float z_rot = 0.0f; -float x_pos = 0.0f; -float y_pos = 0.0f; -float z_pos = -1000.0f; - -// init pos of sim -float xPos = -298.0f; -float yPos = -295.0f; -float zPos = -725.0f; //------ SIMULATION CODE STARTS HERE ----------------------------------------------------------------- +/* Setters and getters */ +void fluids_set_render_smoke(int render_smoke) { + fluids_render_smoke = render_smoke; +} + +int fluids_get_render_smoke(void) { + return fluids_render_smoke; +} //init_simulation: Initialize simulation data structures as a function of the grid size 'n'. // Although the simulation takes place on a 2D grid, we allocate all data structures as 1D arrays, @@ -630,52 +634,6 @@ void render_legend(void) } } -//visualize: This is the main visualization function -void visualize(void) -{ - fftw_real wn = (fftw_real)winWidth / (fftw_real)(DIM + 1); // Grid cell width - fftw_real hn = (fftw_real)winHeight / (fftw_real)(DIM + 1); // Grid cell height - - glTranslatef(xPos, yPos, zPos); - - render_legend(); - - // Rotate field - glLoadIdentity(); - glTranslatef(x_pos, y_pos, z_pos); - glRotatef(x_rot, 1.0f, 0.0f, 0.0f); - glRotatef(y_rot, 0.0f, 1.0f, 0.0f); - glRotatef(z_rot, 0.0f, 0.0f, 1.0f); - - glTranslatef(-(wn*DIM)/2, -(hn*DIM)/2, 0.0f); - - // draw isolines - if (glyph_scalar == SCALAR_RHO) - { - int count; - float iso_scale; - - if (isolines_nr) iso_scale = fabs(threshold1 - threshold2) / isolines_nr; - else iso_scale = 0.0f; - - for (count = 0; count < isolines_nr; count++) - { - draw_isolines(min(threshold1, threshold2) + count * iso_scale); - } - } - - // draw the smoke - if (draw_smoke) - { - render_smoke(); - } - - draw_glyphs(); - render_seedpoints(); - render_streamlines(); -} - - //------ INTERACTION CODE STARTS HERE ----------------------------------------------------------------- void click(int button, int state, int mx, int my) @@ -785,22 +743,11 @@ void drag(int mx, int my) } } -void zoom_in(int zoom) -{ - z_pos += zoom; -} - -void zoom_out(int zoom) -{ - z_pos -= zoom; -} - int get_glyph_usage(void) { return use_glyphs; } void selectColor(int arg) { scalar_col = arg; } void select_dataset(int arg) { vis_dataset = arg; } void toggle_glyph_usage(void) { use_glyphs = (use_glyphs) ? FALSE : TRUE; } -void toggle_smoke_usage(void) { draw_smoke = (draw_smoke) ? FALSE : TRUE; } 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; } |