summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWilrik de Loose <wilrik@wilrik.nl>2007-12-20 11:34:23 (GMT)
committerWilrik de Loose <wilrik@wilrik.nl>2007-12-20 11:34:23 (GMT)
commit465c136f94ef4e48d0705e94d8fdc522b901882f (patch)
tree212c1caaf1079f420c7f09da7e22da3bf118fb9e
parent6e60076c7bf4b928da25ab37d59b8b38a1588eab (diff)
download2iv35-465c136f94ef4e48d0705e94d8fdc522b901882f.zip
2iv35-465c136f94ef4e48d0705e94d8fdc522b901882f.tar.gz
2iv35-465c136f94ef4e48d0705e94d8fdc522b901882f.tar.bz2
-rw-r--r--Smoke/Week 2.ncbbin15518720 -> 15518720 bytes
-rw-r--r--Smoke/Week 2.suobin44032 -> 45056 bytes
-rw-r--r--Smoke/Week 2.vcproj128
-rw-r--r--Smoke/fluids.c4
-rw-r--r--Smoke/fluids.h1
-rw-r--r--Smoke/renderer_gl.c89
6 files changed, 166 insertions, 56 deletions
diff --git a/Smoke/Week 2.ncb b/Smoke/Week 2.ncb
index 1680b8b..d061b17 100644
--- a/Smoke/Week 2.ncb
+++ b/Smoke/Week 2.ncb
Binary files differ
diff --git a/Smoke/Week 2.suo b/Smoke/Week 2.suo
index 04fe50a..13ef118 100644
--- a/Smoke/Week 2.suo
+++ b/Smoke/Week 2.suo
Binary files differ
diff --git a/Smoke/Week 2.vcproj b/Smoke/Week 2.vcproj
index ae9e5b5..8a0b563 100644
--- a/Smoke/Week 2.vcproj
+++ b/Smoke/Week 2.vcproj
@@ -195,6 +195,10 @@
>
</File>
<File
+ RelativePath=".\divergence.c"
+ >
+ </File>
+ <File
RelativePath="fftw-2.1.3\fftw\executor.c"
>
</File>
@@ -371,6 +375,10 @@
>
</File>
<File
+ RelativePath=".\flowvis.c"
+ >
+ </File>
+ <File
RelativePath="fluids.c"
>
</File>
@@ -707,10 +715,54 @@
>
</File>
<File
+ RelativePath=".\gtk_colormap.c"
+ >
+ </File>
+ <File
+ RelativePath=".\gtk_divergence.c"
+ >
+ </File>
+ <File
+ RelativePath=".\gtk_flowvis.c"
+ >
+ </File>
+ <File
+ RelativePath=".\gtk_glyphs.c"
+ >
+ </File>
+ <File
+ RelativePath=".\gtk_heightplots.c"
+ >
+ </File>
+ <File
+ RelativePath=".\gtk_isolines.c"
+ >
+ </File>
+ <File
+ RelativePath=".\gtk_main.c"
+ >
+ </File>
+ <File
+ RelativePath=".\gtk_streamlines.c"
+ >
+ </File>
+ <File
+ RelativePath=".\heightplots.c"
+ >
+ </File>
+ <File
+ RelativePath=".\isolines.c"
+ >
+ </File>
+ <File
RelativePath="fftw-2.1.3\fftw\malloc.c"
>
</File>
<File
+ RelativePath=".\palette.c"
+ >
+ </File>
+ <File
RelativePath="fftw-2.1.3\fftw\planner.c"
>
</File>
@@ -727,6 +779,10 @@
>
</File>
<File
+ RelativePath=".\renderer_gl.c"
+ >
+ </File>
+ <File
RelativePath="fftw-2.1.3\rfftw\rexec.c"
>
</File>
@@ -755,6 +811,10 @@
>
</File>
<File
+ RelativePath=".\smoke.c"
+ >
+ </File>
+ <File
RelativePath=".\streamlines.c"
>
</File>
@@ -788,6 +848,10 @@
>
</File>
<File
+ RelativePath=".\divergence.h"
+ >
+ </File>
+ <File
RelativePath="fftw-2.1.3\fftw\f77_func.h"
>
</File>
@@ -800,6 +864,10 @@
>
</File>
<File
+ RelativePath=".\flowvis.h"
+ >
+ </File>
+ <File
RelativePath="fluids.h"
>
</File>
@@ -812,6 +880,54 @@
>
</File>
<File
+ RelativePath=".\gtk_colormap.h"
+ >
+ </File>
+ <File
+ RelativePath=".\gtk_divergence.h"
+ >
+ </File>
+ <File
+ RelativePath=".\gtk_flowvis.h"
+ >
+ </File>
+ <File
+ RelativePath=".\gtk_glyphs.h"
+ >
+ </File>
+ <File
+ RelativePath=".\gtk_heightplots.h"
+ >
+ </File>
+ <File
+ RelativePath=".\gtk_isolines.h"
+ >
+ </File>
+ <File
+ RelativePath=".\gtk_main.h"
+ >
+ </File>
+ <File
+ RelativePath=".\gtk_streamlines.h"
+ >
+ </File>
+ <File
+ RelativePath=".\heightplots.h"
+ >
+ </File>
+ <File
+ RelativePath=".\isolines.h"
+ >
+ </File>
+ <File
+ RelativePath=".\palette.h"
+ >
+ </File>
+ <File
+ RelativePath=".\renderer_gl.h"
+ >
+ </File>
+ <File
RelativePath="fftw-2.1.3\rfftw\rfftw.h"
>
</File>
@@ -820,6 +936,10 @@
>
</File>
<File
+ RelativePath=".\smoke.h"
+ >
+ </File>
+ <File
RelativePath=".\streamlines.h"
>
</File>
@@ -838,19 +958,19 @@
>
</File>
<File
- RelativePath="fftw-2.1.3\fftw\Makefile.am"
+ RelativePath="fftw-2.1.3\rfftw\Makefile.am"
>
</File>
<File
- RelativePath="fftw-2.1.3\rfftw\Makefile.am"
+ RelativePath="fftw-2.1.3\fftw\Makefile.am"
>
</File>
<File
- RelativePath="fftw-2.1.3\rfftw\Makefile.in"
+ RelativePath="fftw-2.1.3\fftw\Makefile.in"
>
</File>
<File
- RelativePath="fftw-2.1.3\fftw\Makefile.in"
+ RelativePath="fftw-2.1.3\rfftw\Makefile.in"
>
</File>
<File
diff --git a/Smoke/fluids.c b/Smoke/fluids.c
index 8e8620a..5027700 100644
--- a/Smoke/fluids.c
+++ b/Smoke/fluids.c
@@ -20,7 +20,7 @@
//--- SIMULATION PARAMETERS ------------------------------------------------------------------------
const int DIM = 50; //size of simulation grid
-int var_dims = 50;
+int var_dims = 25;
double dt = 0.4; //simulation time step
float visc = 0.001f; //fluid viscosity
fftw_real *vx, *vy; //(vx,vy) = velocity field at the current moment
@@ -39,7 +39,7 @@ int vis_dataset = DATASET_RHO;
int active_slider = 0;
int glyph_scalar = SCALAR_RHO;
int glyph_vector = VECTOR_VEL;
-int glyph_sort = GLYPH_CYLINDERS;
+int glyph_sort = GLYPH_ARROWS;
GLuint startList;
float threshold1 = 0.2f;
float threshold2 = 2.0f;
diff --git a/Smoke/fluids.h b/Smoke/fluids.h
index f1de92e..7f00a39 100644
--- a/Smoke/fluids.h
+++ b/Smoke/fluids.h
@@ -38,7 +38,6 @@ extern int frame_index;
#define GLYPH_ARROWS 0
#define GLYPH_LINES 1
#define GLYPH_CYLINDERS 2
-#define GLYPH_SPHERES 3
extern int winWidth, winHeight; //size of the graphics window, in pixels
extern int color_dir; //use direction color-coding or not
diff --git a/Smoke/renderer_gl.c b/Smoke/renderer_gl.c
index 497a341..c5bf71c 100644
--- a/Smoke/renderer_gl.c
+++ b/Smoke/renderer_gl.c
@@ -129,8 +129,9 @@ static void render_smoke(void)
py = hn + (fftw_real)j * hn;
idx = (j * DIM) + i;
- glColor3f(rho[idx],rho[idx],rho[idx]);
- glVertex3f(px,py, height_array[idx]);
+ glNormal3f(0.0f, 1.0f, 0.0f);
+ glColor3f(rho[idx],rho[idx],rho[idx]);
+ glVertex3f(px,py, height_array[idx]); // vertex 1
for (i = 0; i < DIM - 1; i++)
{
@@ -139,13 +140,13 @@ static void render_smoke(void)
idx = ((j + 1) * DIM) + i;
color = colormap_get_color(get_dataset(idx));
glColor4f(color.r, color.g, color.b, color.a);
- glVertex3f(px, py, height_array[idx]);
+ glVertex3f(px, py, height_array[idx]); // vertex i + 1
px = wn + (fftw_real)(i + 1) * wn;
py = hn + (fftw_real)j * hn;
idx = (j * DIM) + (i + 1);
color = colormap_get_color(get_dataset(idx));
glColor4f(color.r, color.g, color.b, color.a);
- glVertex3f(px, py, height_array[idx]);
+ glVertex3f(px, py, height_array[idx]); // vertex i + 2
}
px = wn + (fftw_real)(DIM - 1) * wn;
@@ -153,29 +154,20 @@ static void render_smoke(void)
idx = ((j + 1) * DIM) + (DIM - 1);
color = colormap_get_color(get_dataset(idx));
glColor4f(color.r, color.g, color.b, color.a);
- glVertex3f(px, py, height_array[idx]);
+ glVertex3f(px, py, height_array[idx]); // vertex j
glEnd();
}
}
-static void render_glyph(float x_value, float y_value, float i, float j)
+static void render_glyph(GLUquadricObj *qobj, float x_value, float y_value, float i, float j)
{
float x0, y0, z0, x1, y1, z1, x_dev, y_dev, size, length;
float scale = (float)((float)DIM / (float)get_var_dims()) / 6;
double theta, in_prod;
fftw_real wn, hn;
- GLuint startList = glGenLists(1);
- GLUquadricObj *qobj = gluNewQuadric();
-
- gluQuadricDrawStyle(qobj, GLU_FILL);
- gluQuadricNormals(qobj, GLU_SMOOTH);
- glNewList(startList, GL_COMPILE);
- gluCylinder(qobj, 10, 0.2, 8, 8, 8);
- glEndList();
-
- size = quake_root((x_value * x_value * 20) + (y_value * y_value * 20)) * 3 * scale;
+ size = quake_root((x_value * x_value * 20) + (y_value * y_value * 20)) * 5 * scale;
wn = (fftw_real)winWidth / (fftw_real)(get_var_dims() + 1); // Grid cell width
hn = (fftw_real)winHeight / (fftw_real)(get_var_dims() + 1); // Grid cell heigh
@@ -211,52 +203,43 @@ static void render_glyph(float x_value, float y_value, float i, float j)
break;
case GLYPH_ARROWS:
+ if (size < 0.08f) return;
+
glPushMatrix();
- glTranslatef(x0, y0, z0);
- glRotatef(theta, 0.0, 0.0, 1.0);
- glTranslatef(-x0, -y0, -z0);
-
- glBegin(GL_TRIANGLES);
- glVertex2d(-10 * size + x0, -25 * size + y0);
- glVertex2d( 0 * size + x0, 25 * size + y0);
- glVertex2d( 10 * size + x0, -25 * size + y0);
- glEnd();
+
+ glTranslatef(x0, y0, z0);
+ glRotatef(theta, 0.0, 0.0, 1.0);
+ glTranslatef(-x0, -y0, -z0);
+
+ glBegin(GL_TRIANGLE_STRIP);
+ glVertex2d(-10 * size + x0, -25 * size + y0);
+ glVertex2d( 0 * size + x0, 25 * size + y0);
+ glVertex2d( 10 * size + x0, -25 * size + y0);
+ glEnd();
+
+ glRotatef(-theta, 0.0, 0.0, 1.0);
- glRotatef(-theta, 0.0, 0.0, 1.0);
glPopMatrix();
break;
case GLYPH_CYLINDERS:
x_dev = x1 - x0;
y_dev = y1 - y0;
- length = quake_root(x_dev * x_dev + y_dev * y_dev) / 8;
+ length = quake_root(x_dev * x_dev + y_dev * y_dev) / 16;
- glPushMatrix();
-
- glTranslatef(x0, y0, -1.0);
- glRotatef(theta, 0.0, 0.0, 1.0);
- glRotatef(-90, 1.0, 0.0, 0.0);
- glScalef(length, length, length);
- glCallList(startList);
+ if (length < 0.5f) return;
- glPopMatrix();
- break;
-
- case GLYPH_SPHERES:
glPushMatrix();
- glTranslatef(x0, y0, -1.0);
+ glTranslatef(x0, y0, z0);
glRotatef(theta, 0.0, 0.0, 1.0);
glRotatef(-90, 1.0, 0.0, 0.0);
glScalef(length, length, length);
- glCallList(startList);
+ gluCylinder(qobj, 10, 0.2, 8, 8, 8);
glPopMatrix();
break;
}
-
- gluDeleteQuadric(qobj);
- glDeleteLists(startList, 1);
}
static void render_glyphs(void)
@@ -265,6 +248,10 @@ static void render_glyphs(void)
float value, scale, idxcf, idxrf;
struct color4f color;
+ GLUquadricObj *qobj = gluNewQuadric();
+ gluQuadricDrawStyle(qobj, GLU_FILL);
+ gluQuadricNormals(qobj, GLU_SMOOTH);
+
scale = (float)((float)DIM / (float)get_var_dims());
for (i = 0; i < get_var_dims(); i++)
{
@@ -296,15 +283,17 @@ static void render_glyphs(void)
{
default:
case VECTOR_VEL:
- render_glyph(vx[idx], vy[idx], i, j);
+ render_glyph(qobj, vx[idx], vy[idx], i, j);
break;
case VECTOR_FORCE:
- render_glyph(fx[idx], fy[idx], i, j);
+ render_glyph(qobj, fx[idx], fy[idx], i, j);
break;
}
}
}
+
+ gluDeleteQuadric(qobj);
}
@@ -525,8 +514,9 @@ void render_flowvis(fftw_real *field)
void init_gl(void)
{
- float LightAmbient[] = { 0.25f, 0.25f, 0.25f, 1.0f }; // Ambient light values
- float LightPosition[] = { 0.0f, 0.0f, -700.0f, 1.0f }; // Position of the light source
+ float LightAmbient[] = { 0.25f, 0.25f, 0.25f, 1.00f }; // Ambient light values
+ float LightDiffuse[] = { 0.80f, 0.00f, 0.00f, 1.00f }; // Diffuse light values
+ float LightPosition[] = { 0.0f, 0.0f, -700.0f, 1.00f }; // Position of the light source
glShadeModel(GL_SMOOTH); // Enable smooth shading
glClearColor(0.0f, 0.0f, 0.0f, 0.0f); // Black background
@@ -534,14 +524,15 @@ void init_gl(void)
glDepthFunc(GL_LESS); // The type of depth testing to do
glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST); // Really nice perspective calculations
glHint(GL_POINT_SMOOTH_HINT, GL_NICEST); // Really nice point smoothing
- glEnable(GL_BLEND);
+ //glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE);
glEnable(GL_DEPTH_TEST);
- //glEnable(GL_LIGHTING);
+ glEnable(GL_LIGHTING);
glEnable(GL_LIGHT0);
glEnable(GL_COLOR_MATERIAL);
glLightfv(GL_LIGHT0, GL_AMBIENT, LightAmbient);
+ glLightfv(GL_LIGHT0, GL_DIFFUSE, LightDiffuse);
glLightfv(GL_LIGHT0, GL_POSITION, LightPosition);
}