
Planar Mapping
Hi,
can anyone tell me how to calculate the Texture Coordinates for a Triangle by using Planar Mapping???
(or in other words.. can anyone tell me the PlanarMapping Algorithm??
)
Thanks~
Au''revoir,
Aya~

I aim for my endless Dreams and I know they will come true!
It''s detailed in the OpenGL specifications that you can download at www.opengl.org
Basically, you have two planar modes : one mode in object-space, and the other in eye-space. The most common is in object-space.
Basically, each of the texture coordinates is computed as a linear function depending on the (xo,yo,zo) object-space vertex coordinates : texcoord = a*xo+b*yo+c*zo+d.
imagine you setup the S texture coordinate with object-space generation using the 2*x-z+1 equation, like that :
GLfloat equation_s[4] = {2.f, 0, -1.f, 1.f};
glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR);
glTexGenfv(GL_S, GL_OBJECT_PLANE, equation_s);
glEnable(GL_TEXTURE_GEN_S);
Then, every time you call glVertex, the texture coordinate is computed. For instance, when you call :
glVertex3f(0, 3.f, 4.f);
the following S texture coordinate is computed :
s=a*xo+b*yo+c*zo+d
s=2*0+0*3-1*4+1
s=0+0-4+1
s=-3
So, it''s just like you called glTexCoord1f(-3.f);
hth
Basically, you have two planar modes : one mode in object-space, and the other in eye-space. The most common is in object-space.
Basically, each of the texture coordinates is computed as a linear function depending on the (xo,yo,zo) object-space vertex coordinates : texcoord = a*xo+b*yo+c*zo+d.
imagine you setup the S texture coordinate with object-space generation using the 2*x-z+1 equation, like that :
GLfloat equation_s[4] = {2.f, 0, -1.f, 1.f};
glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR);
glTexGenfv(GL_S, GL_OBJECT_PLANE, equation_s);
glEnable(GL_TEXTURE_GEN_S);
Then, every time you call glVertex, the texture coordinate is computed. For instance, when you call :
glVertex3f(0, 3.f, 4.f);
the following S texture coordinate is computed :
s=a*xo+b*yo+c*zo+d
s=2*0+0*3-1*4+1
s=0+0-4+1
s=-3
So, it''s just like you called glTexCoord1f(-3.f);
hth
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement