Advertisement

how can i texture a triangle?

Started by October 19, 2000 06:44 PM
3 comments, last by PrinceofZ 24 years, 1 month ago
So...how?
u wouldnt understand a german quote :)
Well, that depends on what kind of api do you use...
but that principal is like that:
for each vertex of the triangle, you need to adjust the uv of the texture
it can be like that:
(0,0)
(1,0)
(0,1)
but that depends on the triangle in most cases
Advertisement
I use OpenGL...
depends on the triangle?
Can u give me an example code?
How to draw the texture in paint(and related)with 128x128? this would be a square...????
u wouldnt understand a german quote :)
That''s right, you will draw the original texture as a square, you have to, all image types are saved as rectangles of some sort... First off, you might not want to use a 128 x 128 texture, go with 32 x 32 or 16 x 16 just because they''re smaller and load faster... Second, the texture applied, if using the texcoords as (0, 0), (1, 0), and (0, 1) will cut out the shape of your triangle from your texture and apply it, this way there is no stretching or warping of the picture and it''s just applied how you define it. By "it depends on the triangle", I think he just meant that the (0, 0), (1, 0), and (0, 1) will only work for triangles that have base and height the same... Well, it will work for any triangle, but if the texture''s square then you will be stretching the texture in the direction of the longer side. (If you follow that you get a cupie doll... )

S.
Texture coordanites are kind of hard to "get", but once you "get" it, then they''re simple.

Basicly, Pretend that your texture is painted on graph paper. Now For each Vertex of your triangle, you give texture coordanites. Plot these down on your graph paper and you get a textured triangle. Now you morph this in to the "real" shape of the triangle defined by the glVertex calls. Tada! You have a textured triangle.

The same works for quads and every other polygon.

This topic is closed to new replies.

Advertisement