-
Setup a two dimensional array representing the discrete
nodes in a cutting plane.
For example:
struct node
{
float x, y, z;
float t;
};
struct node PlaneXY[NX][NY], PlaneXZ[NX][NZ], PlaneYZ[NY][NZ];
-
Use small values for NX, NY, and NZ to start with (5?)
so that debugging printout will have some meaning.
-
For the interpolated color part of the assignment,
compute a color at each vertex, and use glShadeModel( GL_SMOOTH ) to
get OpenGL to interpolate the colors for you inside the quadrilateral cutting plane:
glShadeMoidel( GL_SMOOTH );
glBegin( GL_QUADS );
glColor3f( r0, g0, b0 );
glVertex3f( x0, y0, z0 );
glColor3f( r1, g1, b1 );
glVertex3f( x1, y1, z1 );
glColor3f( r2, g2, b2 );
glVertex3f( x2, y2, z2 );
glColor3f( r3, g3, b3 );
glVertex3f( x3, y3, z3 );
glEnd();
-
For the contour part of the assignment,
write a routine that will generate the correct contours for one single quadrilateral.
If you use structures, you could pass in pointers to each point:
void
ProcessQuad( struct node *p0, struct node *p1, struct node *p2, struct node *p3 )
{
. . .
... p0->x ...
... p3->t ...
. . .
}
If you aren't comfortable with structures and pointers, you can create
the same routine but pass in the 3 array indices for each of the four
bounding vertices:
void
Process3uad( int i0, int j0, int k0, int i1, int j1, int k1, int i2, int j2, int k2, int i3, int j3, int k3 )
{
. . .
}
-
The nice part of having this ProcessQuad() routine
setup like this is that you can use it to draw the contour lines
on the cutting plane and the contour lines that will become
the Project #5 isosurfaces.
-
Each cutting plane moves in one dimension only -- perpendicular to itself.
For example, the XZ cutting plane only moves in Y.
So, its grid points have X and Z coordinates that never change.
At any given Y position of the XZ cutting plane, use each node's
X and Z coordinates combined with the Y of the cutting plane
to recompute via the equation the scalar value at each node.
Thus, the 3D cutting planes are really a 2D contour-generation exercise.
-
In "real life" you don't usually get an equation.
You typically get data that has been sampled or computed at each 3D node.
In that case, you would have to interpolate between known data layers.
Remember that in the Marching Squares contour algorithm,
you determine where (if anywhere) a contour line of the magic temperature, T*,
would cross each edge of the square: