summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOliver Schinagl <oliver@schinagl.nl>2008-01-08 20:37:54 (GMT)
committerOliver Schinagl <oliver@schinagl.nl>2008-01-08 20:37:54 (GMT)
commitc3c41f66a48f40ae3471155ac302cc78175b5eac (patch)
treeb34ad8798cbfa5b784c357df81b00d222c9247e9
parent63b3f9cf7f2a5d2822f62c672eabe2e893bac441 (diff)
download2iv35-c3c41f66a48f40ae3471155ac302cc78175b5eac.zip
2iv35-c3c41f66a48f40ae3471155ac302cc78175b5eac.tar.gz
2iv35-c3c41f66a48f40ae3471155ac302cc78175b5eac.tar.bz2
minor fixes
-rw-r--r--Smoke/fluids.c33
-rw-r--r--Smoke/normals.c15
-rw-r--r--Smoke/normals.h3
-rw-r--r--Smoke/renderer_gl.c21
-rwxr-xr-xSmoke/smoke.binbin637075 -> 637207 bytes
5 files changed, 40 insertions, 32 deletions
diff --git a/Smoke/fluids.c b/Smoke/fluids.c
index f80a2f0..c020b2f 100644
--- a/Smoke/fluids.c
+++ b/Smoke/fluids.c
@@ -21,6 +21,7 @@
#include "colormap.h"
#include "glyphs.h"
#include "heightplots.h"
+#include "normals.h"
//--- SIMULATION PARAMETERS ------------------------------------------------------------------------
int var_dims = 25;
@@ -96,7 +97,7 @@ fftw_real *init_simulation(int n, struct vis_data_arrays *vis_data)
vis_data->div_force = (fftw_real *)malloc(dim2);
vis_data->div_vel = (fftw_real *)malloc(dim1);
vis_data->height = (fftw_real *)malloc(dim2);
- vis_data->normals = (struct point *)malloc(dim2);
+ vis_data->normals = (struct point *)malloc(dim2 *sizeof(struct point *));
return return_value;
}
@@ -398,9 +399,11 @@ void populate_arrays(struct vis_data_arrays *vis_data)
vis_data->height[idx] = calculate_height_plot(heightplots_get_dataset(), idx);
- //vis_data->normals[idx] = calculate_normal_vector(vis_data->height, idx, i, j);
- // printf("vis: h: %lf n: %lf; old: h: %lf n: %lf\n",
- // vis_data->height[idx], vis_data->normals[idx].x, height_array[idx], normal_array[idx].x);
+ vis_data->normals[idx] = calculate_normal_vector(vis_data->height, idx, i, j);
+// if (normal_array[idx].x != vis_data->normals[idx].x) {
+ // printf("n: %lf; old: %lf\n",
+ // vis_data->normals[idx].x, normal_array[idx].x);
+ //}
}
}
}
@@ -465,6 +468,7 @@ void calculate_one_simulation_step(struct vis_data_arrays *vis_data)
glyphs_set_frame(frame);
heightplots_set_frame(vis_data->height);
+ normals_set_frame(vis_data->normals);
}
//------ VISUALIZATION CODE STARTS HERE -----------------------------------------------------------------
@@ -537,27 +541,6 @@ float get_dataset(int index)
return return_value;
}
-#if 0
-void set_autoscaling(void)
-{
- int k;
- float value, scale_min, scale_max;
-
- scale_min = scale_max = get_dataset(0);
- colormap_set_scale_min(scale_min);
- colormap_set_scale_max(scale_max);
-
- for (k = 1; k < DIM * DIM; k++)
- {
- value = get_dataset(k);
-
- if (scale_min > value) { colormap_set_scale_min(value); }
- if (scale_max < value) { colormap_set_scale_max(value); }
- }
-
- //threshold = (scale_min + scale_max) / 2;
-}
-#endif
void fluids_insert_smoke(int x, int y)
{
diff --git a/Smoke/normals.c b/Smoke/normals.c
index 0684b6a..9797d0a 100644
--- a/Smoke/normals.c
+++ b/Smoke/normals.c
@@ -1,3 +1,6 @@
+#include <rfftw.h>
+#include "fluids.h"
+
#include "funcs.h"
#include "normals.h"
@@ -6,6 +9,8 @@
static int normals_render = FALSE;
static int normals_render2 = FALSE;
+static struct point *normals_frame;
+
int normals_get_render(void)
{
@@ -26,3 +31,13 @@ void normals_set_render2(int render_normals)
{
normals_render2 = render_normals;
}
+
+void normals_set_frame(struct point *normals)
+{
+ normals_frame = normals;
+}
+
+struct point *normals_get_frame(void)
+{
+ return normals_frame;
+}
diff --git a/Smoke/normals.h b/Smoke/normals.h
index 4763c45..f61b248 100644
--- a/Smoke/normals.h
+++ b/Smoke/normals.h
@@ -7,4 +7,7 @@ int normals_get_render(void);
void normals_set_render2(int render_normals);
int normals_get_render2(void);
+void normals_set_frame(struct point *normals);
+struct point *normals_get_frame(void);
+
#endif
diff --git a/Smoke/renderer_gl.c b/Smoke/renderer_gl.c
index 13b3b90..5e6bb95 100644
--- a/Smoke/renderer_gl.c
+++ b/Smoke/renderer_gl.c
@@ -52,6 +52,8 @@
#define BITMAP_WIDTH 0x12
#define BITMAP_HEIGHT 0x16
+#define NORMAL_SCALE 16
+
float x_pos = DEFAULT_X_POS;
float y_pos = DEFAULT_Y_POS;
float z_pos = DEFAULT_ZOOM;
@@ -155,7 +157,7 @@ static void render_grid(void)
DIM = fluids_get_dim();
- glColor3f(0.0f, 0.0f, 0.5f);
+ glColor4f(0.0f, 0.0f, 0.5f, 0.8f);
glLineWidth(1.0f);
for (i = 0; i < winWidth; i += DIM) {
@@ -214,16 +216,16 @@ static void render_normal(void)
static void render_normals(void)
{
int i, j, idx, DIM;
- double px, py;
fftw_real wn, hn;
fftw_real *height;
- float normal_scale = 10.0f;
+ struct point *normals;
DIM = fluids_get_dim();
wn = (fftw_real)winWidth / (fftw_real)(DIM + 1); // Grid cell width
hn = (fftw_real)winHeight / (fftw_real)(DIM + 1); // Grid cell height
height = heightplots_get_frame();
+ normals = normals_get_frame();
glDisable(GL_LIGHTING);
glBegin(GL_LINES);
@@ -233,14 +235,19 @@ static void render_normals(void)
{
for (i = 0; i < DIM; i++)
{
+ int height_multiplier;
+ double px, py, pz;
+
+ height_multiplier = heightplots_get_height();
idx = (j * DIM) + i;
px = wn + (fftw_real)i * wn;
py = hn + (fftw_real)(j + 1) * hn;
+ pz = height[idx] *height_multiplier;
- glVertex3f(px, py, height[idx]);
- glVertex3f(px + normal_array[idx].x * normal_scale,
- py + normal_array[idx].y * normal_scale,
- height[idx] + normal_array[idx].z * normal_scale);
+ glVertex3f(px, py, pz);
+ glVertex3f(px +(normal_array[idx].x *NORMAL_SCALE),
+ py +(normal_array[idx].y *NORMAL_SCALE),
+ pz +(normal_array[idx].z *NORMAL_SCALE));
}
}
glEnable(GL_LIGHTING);
diff --git a/Smoke/smoke.bin b/Smoke/smoke.bin
index 84bc838..580da38 100755
--- a/Smoke/smoke.bin
+++ b/Smoke/smoke.bin
Binary files differ