PDA

View Full Version : texture mapping for n-sided concave polygon



ammuselvi
07-02-2004, 09:07 PM
1. For that I'm having the co-ordinates of the polygon(not in either clock-wise or anti-clockwise order).
2. I can sort them in one order. But, what I need to do is,I have to divide that polygon into convex polygons for mapping textures properly.
3.The polygon what Im getting is rectilinear polygon(polygon with edges parallel to XZ co-ordinate axes) with n-sides.
4.I want to convert it into convex polygons.

I have attached some complex cases in which I'm facing more problems...

Case 1:
-------
---------
| |
| |
----------------- |
| ----------------
| |
| |
| ---------------
-------------- |
| |
| |
| |
---------------
The Co-ordinates are,

150,100
150,150
70,150
70,250
120,250
120,300
220,300
220,230
250,230
250,170
200,170
200,100

case 2:
--------

-----------------
| |
| |
| |
---- ----
| |
| |
| |
---- ----
| |
| |
| |
------------------
The Co-ordinates are,
100,100
100,175
150,175
150,225
100,225
100,300
300,300
300,225
225,225
225,175
300,175
300,100

Could anyone please guide me how to overcome this problem?

ZbuffeR
07-03-2004, 02:13 AM
A small hint : edit your posts and put the UBB [ code ] markups aroud your ascii art.

plasmonster
07-03-2004, 11:36 AM
The GLU has routines for tesselating polygons. The appendix here covers this in some detail.

http://fly.cc.fer.hr/~unreal/theredbook/appendixc.html

This facility might do nicely for your needs; you just need to wade through the docs for a while to get up to speed on the API.

An alternative approach would be to roll your own tesselator. Admittedly, this would probably mean more work, but it might be more fun as well :) .