diff options
Diffstat (limited to 'Smoke/renderer_gl.c')
-rw-r--r-- | Smoke/renderer_gl.c | 65 |
1 files changed, 22 insertions, 43 deletions
diff --git a/Smoke/renderer_gl.c b/Smoke/renderer_gl.c index 1e06356..a312f3d 100644 --- a/Smoke/renderer_gl.c +++ b/Smoke/renderer_gl.c @@ -342,7 +342,6 @@ void render_smoke(void) for (j = 0; j < DIM - 1; j++) //draw smoke { glBegin(GL_TRIANGLE_STRIP); - i = 0; idx = (j * DIM) + i; px = wn + (fftw_real)i * wn; @@ -351,7 +350,7 @@ void render_smoke(void) color = colormap_get_color(frame[idx]); glColor4f(color.r, color.b, color.g, color.a); - glNormal3f(normal[idx].x, normal[idx].y, normal[idx].z); +// glNormal3f(normal[idx].x, normal[idx].y, normal[idx].z); glVertex3f(px, py, pz); for (i = 0; i < DIM - 1; i++) @@ -362,7 +361,7 @@ void render_smoke(void) pz = height[idx] *heightplots_get_height(); color = colormap_get_color(frame[idx]); glColor4f(color.r, color.g, color.b, color.a); - glNormal3f(normal[idx].x, normal[idx].y, normal[idx].z); + // glNormal3f(normal[idx].x, normal[idx].y, normal[idx].z); glVertex3f(px, py, pz); idx = (j * DIM) + (i + 1); px = wn + (fftw_real)(i + 1) * wn; @@ -370,7 +369,7 @@ void render_smoke(void) pz = height[idx] *heightplots_get_height(); color = colormap_get_color(frame[idx]); glColor4f(color.r, color.g, color.b, color.a); - glNormal3f(normal[idx].x, normal[idx].y, normal[idx].z); + // glNormal3f(normal[idx].x, normal[idx].y, normal[idx].z); glVertex3f(px, py, pz); } @@ -380,7 +379,7 @@ void render_smoke(void) pz = height[idx] *heightplots_get_height(); color = colormap_get_color(frame[idx]); glColor4f(color.r, color.g, color.b, color.a); - glNormal3f(normal[idx].x, normal[idx].y, normal[idx].z); + // glNormal3f(normal[idx].x, normal[idx].y, normal[idx].z); glVertex3f(px, py, pz); glEnd(); } @@ -571,14 +570,18 @@ static void render_glyph(GLUquadricObj *qobj, float x_value, float y_value, floa static void render_glyphs(void) { int i, j, idx, DIM; - float value, scale, idxcf, idxrf; + float scale, idxcf, idxrf; struct color4f color; + fftw_real *frame_color; + struct fftw_real_xy_p frames_direction; GLUquadricObj *qobj = gluNewQuadric(); gluQuadricDrawStyle(qobj, GLU_FILL); gluQuadricNormals(qobj, GLU_SMOOTH); DIM = fluids_get_dim(); + frame_color = glyphs_get_frame_color(); + frames_direction = glyphs_get_frames_direction(); scale = (float)((float)DIM / (float)fluids_get_var_dim()); for (i = 0; i < fluids_get_var_dim(); i++) @@ -589,35 +592,10 @@ static void render_glyphs(void) idxrf = round(i * scale); idx = idxcf + idxrf; - switch (glyph_scalar) - { - default: - case SCALAR_RHO: - value = rho[idx]; - break; - - case SCALAR_VEL: - value = vec_len2f(vx[idx], vy[idx]); - break; - - case SCALAR_FORCE: - value = vec_len2f(fx[idx], fy[idx]); - break; - } - color = glyphs_get_color(value); + color = glyphs_get_color(frame_color[idx]); glColor4f(color.r, color.b, color.g, color.a); - switch (glyph_vector) - { - default: - case VECTOR_VEL: - render_glyph(qobj, vx[idx], vy[idx], i, j); - break; - - case VECTOR_FORCE: - render_glyph(qobj, fx[idx], fy[idx], i, j); - break; - } + render_glyph(qobj, frames_direction.x[idx], frames_direction.y[idx], i, j); } } @@ -650,8 +628,10 @@ static void render_isolines(void) float x_offset, y_offset, z_pos = 8.0f; struct color4f color; struct point p0, p1, p2, p3, e1, e2; + fftw_real *frame; DIM = fluids_get_dim(); + frame = isolines_get_frame(); wn = (fftw_real)winWidth / (fftw_real)(DIM + 1); // Grid cell width hn = (fftw_real)winHeight / (fftw_real)(DIM + 1); // Grid cell height @@ -679,13 +659,13 @@ static void render_isolines(void) { state = 0; idx = (j * DIM) + i; - color = isolines_get_color(get_dataset(idx)); + color = isolines_get_color(frame[idx]); glColor4f(color.r, color.g, color.b, color.a); - v0 = get_dataset(idx + DIM); - v1 = get_dataset(idx + 1 + DIM); - v2 = get_dataset(idx + 1); - v3 = get_dataset(idx); + v0 = frame[idx + DIM]; + v1 = frame[idx + 1 + DIM]; + v2 = frame[idx + 1]; + v3 = frame[idx]; if (v0 >= threshold) { state += 1; } if (v1 >= threshold) { state += 2; } @@ -974,7 +954,6 @@ void renderer_reset_roll(void) //visualize: This is the main visualization function void visualize(struct vis_data_arrays *vis_data) { - // Rotate field glPushMatrix(); @@ -990,10 +969,6 @@ void visualize(struct vis_data_arrays *vis_data) render_grid(); } - if (isolines_get_render()) { - render_isolines(); - } - if (smoke_get_render()) { render_smoke(); } @@ -1001,6 +976,10 @@ void visualize(struct vis_data_arrays *vis_data) render_grid_smoke(); } + if (isolines_get_render()) { + render_isolines(); + } + if (glyphs_get_render()) { render_glyphs(); } |