I haven’t done much Texture Mapping beyond the simple ‘map to cube’ demos, but I get the ‘gist’ of UV points and manipulations…
Still, I have doubts as to how I can map to ‘irregular poly-surfaces’ (let’s assume that all poly-surfaces are defined in tri’s, and are flat, for simplicity), so I thought I would pose a few ‘what ifs’ and see if anyone can help solve them:
What if - I have a concave poly, for example, a star. How would I map a single texture so it would ‘fit’ the star? Can I use a ‘square’ surrounding the star to define the UV points to map my texture to? Do I have to sub-divide my poly into convex pieces (and do the same to my texture)?
What if - I have to ‘cut off’ part of the texture? Let’s say I have an object, and I ‘lop off’ the end of it. Now the texture extends beyond the remaining piece. Is there a way to ‘truncate’ my texture?
What if - I have transparent portions in my texture? How does the bitmap data need to be represented(what colors, maybe alpha data req’d?) for the transparent pixels? Do I need a transparency mask?
Keep in mind that I’m half way between beginner and expert, and I haven’t the time to dig through all tutorials looking for answers to these questions (I’m on a schedule).
With all due respect, if you are asking these questions, you are much closer to beginner than expert. Unfortunately, a “gist” is usually not enough to do what you want.
As a general answer to your questions, I’ll explain texture mapping:
OpenGL only renders convex polygons, usually triangles and sometimes quads. For simplicity, consider triangles only. Each vertex has a texture coordinate, and the texture coordinates for all the fragments generated by rasterizing the triangle will have texture coordinates created by interpolating along those vertices. This is essentially the same as when you interpolate vertex colors, although interpolating texture coordinates is usually perspective corrected whereas interpolating colors is not. In any case, texture coordinates index the currently bound texture. This means that your mapping from your geometry to your texture map is very flexible; each triangle can have its own set of texture coordinates.
You can define your texture any way you think is reasonable. You only need to subdivide your concave poly into convex polys.
A truncation happens automatically. If you don’t have any texture coordinates addressing part of a texture, then it never gets drawn.
3)Transparency is usually represented in the alpha channel of a texture.
For 1), I meant that you can define your texture mapping however you want. The mapping is defined by the texture coordinates you assign for each vertex. If you wanted your star to be a “cookie cutter” out of a texture pattern, then you can certainly do that by assigning texture coordinates for each vertex to correspond to their location on the texture. But texture mapping is much more flexible than that. Maybe if you describe exactly what you want to do, I can help you out more.
Sorry if I hurt your pride with that “all due respect” comment, but it was just a gentle way of telling you that you’re asking a beginner’s question.