From Ohm

# Cross Section Example

Let (x,y) be the intersection point of two axis-aligned planes in x/z- and y/z- direction and let n be the uniform dimension of the 3D texture (in voxels), then the OpenGL setup to draw and texture the two corresponding quads is:

glMatrixMode(GL_TEXTURE);
glLoadIdentity();
glTranslated(0.5/n,0.5/n,0.5/n);
glScaled((n-1.0)/n,(n-1.0)/n,(n-1.0)/n);
glTranslated(0.5,0.5,0.5);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
gluLookAt(...);
glRotated(90,1,0,0);

glBegin(GL_QUADS);
glColor3f(1.0f,0.5f,0.5f);
glTexCoord3d(x,-0.5,-0.5);
glVertex3d(x,-0.5,-0.5);
glTexCoord3d(x,0.5,-0.5);
glVertex3d(x,0.5,-0.5);
glTexCoord3d(x,0.5,0.5);
glVertex3d(x,0.5,0.5);
glTexCoord3d(x,-0.5,0.5);
glVertex3d(x,-0.5,0.5);

glColor3f(0.5f,0.5f,1.0f);
glTexCoord3d(-0.5,y,-0.5);
glVertex3d(-0.5,y,-0.5);
glTexCoord3d(0.5,y,-0.5);
glVertex3d(0.5,y,-0.5);
glTexCoord3d(0.5,y,0.5);
glVertex3d(0.5,y,0.5);
glTexCoord3d(-0.5,y,0.5);
glVertex3d(-0.5,y,0.5);
glEnd(); Retrieved from http://schorsch.efi.fh-nuernberg.de/roettger/index.php/MedicalVisualization/CrossSectionExample

Page last modified on November 28, 2014, at 10:54 AM