#### Archived

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

# Texture mapping quads or triangles

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

## Recommended Posts

Hi, I''m having trouble figuring out how to texture quads! I need to write a function which will give texture coordinates (u,v), where u and v range from 0.0 to 1.0, for any point p on a quadrilateral. I know the point p, and I know the four vertices but nothing else. I''ve been trying to figure this out for a while but I can''t seem to get it. I decided it might be easier to divide the quad into two triangles and then texture map each one of those, but I can''t seem to get that to work either. The basic method that I''ve heard is that you find two orthogonal unit vectors, one is defined by one of the triangle''s vertices minus the other. And the other one is the cross product of That vector, with the normal vector of the triangle. Then you can solve some sort of simultaneous equations to get u and v. It doesn''t seem to be working and I''m having trouble finding a clearly-written page on the net which explains how to do it in a ray tracing context. I mean, some of them use incremental algorithms and things like that, but I can''t do that, I''m just given a point and I have to calculate the coordinates straight from that... If anyone might have any tips, hints, or help, I''d really appreciate it! Thank you Rajan

##### Share on other sites
Check out

http://nehe.gamedev.net

It has just about everything you need to get started in OpenGL.

- Bong, James Bong

##### Share on other sites
Thanks for the link, I''ll definitely hold on to it for future reference! I looked through the articles and I don''t think they have what I''m looking for though, since their code lets OpenGL handle the texture coordinate generation. My problem is that I have to figure out the texture coordinates myself. Thanks a lot for the link though, it looks really useful

• 48
• 12
• 10
• 10
• 9
• ### Forum Statistics

• Total Topics
631378
• Total Posts
2999665
×