#### Archived

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

# Texture mapping quads or triangles

## Recommended Posts

RajanSky    100
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
Bong    122
Check out

http://nehe.gamedev.net

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

- Bong, James Bong