projective texturing help

Hello,

I’m having a bit of an issue with setting this up. For the most part, it works. For temporary tests, I’ve used the camera matrix to project textures onto the scene. It works. The problem is when I go to a temp camera matrix (to move around and test projective texturing further) and move/rotate the scene, the projective texture also starts to move or rotate around with me. I’m not sure what I’m doing wrong (something tells me it has to do with my modelview matrix not setting up right?).

Here’s a screenshot to illustrate what’s going on: http://hideout.cjb.net/TexProjProb.jpg

Picture 1) is where I’m the actual camera. You can see a bit of the quad and sphere being properly mapped.
Picture 2) is where I “dismember” from the camera to a temporary camera. I moved back a bit and looked up (the white box you see in front is the real camera being drawn). Now note the projected texture followed my movements.

Here’s a code snippet:

oglInit()
{
setup matrix modes (gl proj, gl modelview with glLoadIdentity())
glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_EYE_LINEAR);
glTexGenfv(GL_S, GL_EYE_PLANE, eyePlaneS);
(do this for T, R, and Q)
}

oglDisplay()
{
glPushMatrix();
cDiffCamera.getInvCameraMatrix(camMatrix);
glMultMatrixf(camMatrix);

glMatrixMode(GL_TEXTURE);
glLoadIdentity();
glTranslatef(0.5, 0.5, 0.0);
glScalef(0.5, 0.5, 1.0);
gluPerspective(45.0, width/height, 0.1, 1.0);

	cCamera.getInvCameraMatrix(camMatrix);
	glMultMatrixf(camMatrix);

	glBindTexture(GL_TEXTURE_2D, 1);
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_BORDER);
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_BORDER);

glMatrixMode(GL_MODELVIEW);

glEnable(GL_TEXTURE_2D);
glEnable(GL_TEXTURE_GEN_S);
glEnable(GL_TEXTURE_GEN_T);
glEnable(GL_TEXTURE_GEN_R);
glEnable(GL_TEXTURE_GEN_Q);

drawScene();

glDisable(GL_TEXTURE_2D);
glDisable(GL_TEXTURE_GEN_S);
glDisable(GL_TEXTURE_GEN_T);
glDisable(GL_TEXTURE_GEN_R);
glDisable(GL_TEXTURE_GEN_Q);

}

  • edit: made a little mistake in the code

[This message has been edited by theghost (edited 05-28-2003).]

Set the texture planes after you set the camera matrix