how to calculate texture coordinate

How to calculate (s,t,r,w) coordinate in projective texture mapping?

I have a projector model trasformation Mproj,
,a projection trasformation Pproj, and
a matrix scale and bias T.
T={1/2,0,0,1/2, 0,1/2,0,0, 0,0,1/2,0, 1/2,1/2,1/2,1} and M is the opengl modelview matrix.

I use coordinate generation
GLfloat eyePlaneS[] = { 1.0, 0.0, 0.0, 0.0 };
GLfloat eyePlaneT[] = { 0.0, 1.0, 0.0, 0.0 };
GLfloat eyePlaneR[] = { 0.0, 0.0, 1.0, 0.0 };
GLfloat eyePlaneQ[] = { 0.0, 0.0, 0.0, 1.0 };
and set GL_EYE_LINEAR.

How opengl computes texture coordinate (s,t,r,q)
for vertex v?
What is the formula?
I want only use glTexCoord4f to implement projective texture mapping.

Thanks in advance.


The answer to your question is in the OpenGL Red Book . Check out chapter 9 under “Automatic Texture-Coordinate Generation”.

What you really should do is use a modeling program and export an asci text file format of your model. Then write a parser. I find the OBJ format easy to parse. You’ll have everything you need.

I read Automatic Texture-Coordinate Generation.
My generated coordinate is p1’xe + p2’ye + p3’ze +p4’
where (p1’ p2’ p3’ p4’) = (p1p2p3p4)M-1.
But M-1 change during the program.What modelview matrix I must consider?

Why in advance opengl demo “projtex.c” to move texture spot I need to multiply texture matrix by
inverse trasformation texture?


you should consider the modelviewmatrix at the time you set the autogen planes.

[QUOTE]Originally posted by Mazy:
[QB]you should consider the modelviewmatrix at the time you set the autogen planes

Thanks Mazy.

My original question was to perform texture coordinate in projective texture mapping.
I read nvidia documentation and I found the formula:

(s,t,r,q)=Te*(xe,ye,ze,we) where (xe,ye,ze,we) are the eye coordinates of the vertex.
where Te=SPpVp*(Ve)-1.

Well,S performs the scale and bias to map the s,t, and r components of the texture coordinate to the [0,1] range.Pp is projection matrix, Vp is view matrix for projector.(Ve)-1 is the inverse of camera.
I don’t understand what do (Ve)-1 in the formula.

Now I move my texture spot in my scene by changing
Vp.Another methods?