PDA

View Full Version : how to calculate texture coordinate

Ale
04-01-2004, 09:35 AM
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?
:confused:
I want only use glTexCoord4f to implement projective texture mapping.

Ale.

Zeno
04-01-2004, 09:02 PM
The answer to your question is in the OpenGL Red Book (http://fly.cc.fer.hr/~unreal/theredbook/) . Check out chapter 9 under "Automatic Texture-Coordinate Generation".

howie
04-04-2004, 01:35 PM
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.

Ale
04-13-2004, 01:38 AM
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?

Ale.

Mazy
04-14-2004, 03:00 AM
you should consider the modelviewmatrix at the time you set the autogen planes.

Ale
04-14-2004, 06:16 AM
[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=S*Pp*Vp*(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.
:confused:

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