TeraRecon, Inc. Real Time Visualization April-12-2001 ======================= 7th point text and code There has been a slight change in the geometric coordinates returned by VLIContext::FetchBasePlane, starting with VLI version 2.0. In earlier versions, the coordinates formed a flat hexagon, parallel to the screen. In other words, all six Z coordinates were returned as the Z coordinate of the center of the volume. In version 2.0 and later, the Z coordinates returned are those of the appropriate volume corner, and therefore are not all equal. If you are not using depth testing in OpenGL, the Z coordinates will be ignored (after the projection and viewport transformations), and so this change will not make any visible difference. However, the Z values interpolated by OpenGL will not be correct if you render the base plane as a hexagon, because OpenGL assumes that polygons are flat. This means that using depth testing to hide a volume behind a surface (or vice versa) will produce improper results. Instead, you can compute a 7th point from the 6 coordinates given and render the base plane as a triangle fan instead. This has the effect that the base plane will be projected onto the front faces of the volume parallelepiped, and will interact with other depth tested geometry in a more usable way. This will result in a more pleasing display, but does not correctly embed geometry inside the volume -- all surface/volume interactions are at the outside of the volume. The computations for the 7th point are quite simple. Here is the code for those computations in Revli (in file VLIVolumeOpenGLView.cpp): (Altered slightly for better clarity.) // Since the hex is a parallelpiped and the points we // are getting back from FetchBasePlane are in eye coords, // we can use vector math to compute the 7th point. VLIVector3D seventhPoint = hex[2] + hex[0] - hex[1]; // The texture coordinates for the 7th point can // be pulled directly from two other texture coordinates VLIVector2D seventhTexCoord (tex[4].X(), tex[2].Y() ); The triangle fan is drawn starting with the 7th point, touching all six points in order, and finally repeating point 0. // Rather than draw a hex, we draw a triangle // fan based at the 7th point. glBegin (GL_TRIANGLE_FAN); //the seventh point is the center of the fan glTexCoord2d( seventhTexCoord.X(), seventhTexCoord[2].Y()); glVertex3d( seventhPoint.X(), seventhPoint.Y(), seventhPoint.Z()); for (int i = 0; i < 6; i++) { glTexCoord2d(tex[i].X(), tex[i].Y()); glVertex3d(hex[i].X(),hex[i].Y(), hex[i].Z()); } glTexCoord2d(tex[0].X(), tex[0].Y()); glVertex3d(hex[0].X(),hex[0].Y(), hex[0].Z()); glEnd (); Finally, if the original behavior is required, you can project the eye coordinates to a plane simply by sending the same Z value for all points: double z = (hex[0].Z() + hex[3].Z()) * 0.5; glBegin (GL_POLYGON); for (i = 0; i < 6; i++) { glTexCoord2d(tex[i].X(), tex[i].Y()); glVertex3d(hex[i].X(),hex[i].Y(), z); } glEnd (); i++) { glTexCoord2d(tex[i].X(), tex[i].Y()); glVertex3d(hex[i].X(),hex[i].Y(), z); } glEnd ();