Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

AyaKoshigaya

Planar Mapping

This topic is 5565 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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~

Share this post


Link to post
Share on other sites
Advertisement
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

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!