Dorbie… I think its almost working but there seems to be something I’m not understanding about the rotating…
I’m rotating the texture (about the origin) and then switching back to model view and passing planes through the texture…
It I rotate model view everything looks normal but I don’t get back faces of objects… However if I rotate the texture then I can’t even begin to describe the results… they are truely warped…
I’m at my wits end with this dorbie… I’ve been through the thread you have suggested… and this is still not doing what I expect…
When this works I’ll add the clipping code…
Keep in mind dorbie that my texture is not a cube in dimensions… in fact its like 512x512x32. So it seems a bit stretched when viewed… because the code looks to me like it assumes that the texture was cubed. (In your example)
void init(void)
{
glClearColor (0.0, 0.0, 0.0, 0.0);
glShadeModel(GL_FLAT);
glEnable(GL_DEPTH_TEST);
ThreeDTexture * text = readRawSlice("morerawct/ct.raw", iWidth, iHeight, iDepth);
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
glGenTextures(1, &texName);
glBindTexture(GL_TEXTURE_3D, texName);
glTexImage3D(GL_TEXTURE_3D, 0, GL_INTENSITY16, iWidth, iHeight, iDepth, 0, GL_LUMINANCE, GL_UNSIGNED_SHORT, (GLvoid *) text->image);
glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_WRAP_S, GL_CLAMP);
glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_WRAP_T, GL_CLAMP);
glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_WRAP_R, GL_CLAMP);
glEnable(GL_TEXTURE_GEN_S);
glEnable(GL_TEXTURE_GEN_T);
glEnable(GL_TEXTURE_GEN_R);
glEnable(GL_TEXTURE_3D);
glEnable(GL_BLEND);
glBlendEquation(GL_MAX);
}
void display(void)
{
static float planeS[] = {1.0f, 0.0f, 0.0f, 1.0f};
static float planeT[] = {0.0f, 1.0f, 0.0f, 1.0f};
static float planeR[] = {0.0f, 0.0f, 1.0f, 1.0f};
int slice;
float z;
static float r=0.0;
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glMatrixMode(GL_TEXTURE);
glLoadIdentity();
glTranslatef(-0.5f, -0.5f, -0.5f);
glRotatef(r, 1.0f, 1.0f, 1.0f);
glMatrixMode(GL_MODELVIEW);
glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_EYE_LINEAR);
glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_EYE_LINEAR);
glTexGeni(GL_R, GL_TEXTURE_GEN_MODE, GL_EYE_LINEAR);
glTexGenfv(GL_S, GL_EYE_PLANE, planeS);
glTexGenfv(GL_T, GL_EYE_PLANE, planeT);
glTexGenfv(GL_R, GL_EYE_PLANE, planeR);
glBegin(GL_QUADS);
for (slice=0; slice < iDepth; ++slice)
{
z = ((1.0/((float) (iDepth-1))) * (float) slice) - 0.5f;
glVertex3f(-0.5f, -0.5f, z);
glVertex3f(+0.5f, -0.5f, z);
glVertex3f(+0.5f, +0.5f, z);
glVertex3f(-0.5f, +0.5f, z);
}
glEnd();
glFlush();
r = r + 0.5;
}
void reshape(int w, int h)
{
glViewport(0, 0, (GLsizei) w, (GLsizei) h);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(60.0, (GLfloat) w / (GLfloat) h, 1.0, 30.0);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glTranslatef(0.0, 0.0, -2.5);
}