I have been using OpenGl Tesselation functions. And when i pass a contour with superimposed points, meaning a concave polygon, then the Tesselation function screws up. This is supposed to be a known bug with the tesselation functions.
I would be grateful if anyone knows a work around to this problem. The thing is that I cant change the points that I give to the tesselate function.
Thanks in advance
What do you mean by superimposed? Didn’t really get it, but here are a couple of suggestions.
First, have you specified a GLU_TESS_COMBINE callback? You will need it, if some contour edges cross each other. Also make sure your vertice are coplanar, and your tesselation normal, winding rule and other properties are correct. Adjusting the tolerance might make your problem go away.
Second, I once had a problem with the tesselators, they sometimes create degenerate triangles if several contour vertice lie on the same line. I got around it by detecting such cases from the resulting data and turning edges with an adjacent face.
My contour has various points(vertices) which are of the same value. Like for example a square, the first and the last point although different have the same point values.
This is what i meant by supeimposed.
I dont get a problem when two such points are present in the contour, but three or more gives me this problem.
And also when I have a concave contour ie: lines crossing then the tesselation faults.
My contours are 2D so they are coplanar vertices.
Could you please explain what you meant by turning edges with and adjacent face.
To make the contours with crossing lines work, you have to create a GLU_TESS_COMBINE callback (see opengl specs) and select a proper winding rule with gluTessProperty.
As for the superimposed points, I don’t see why you can’t just not send them to the tesselator. Just keep track of the previous point and if the next point is the same, don’t send it. If two such points don’t create the problem, you don’t even have to worry about the endpoints.
I don’t think the turning edges situation applies to your problem, but since you asked…
First, turning an edge between two triangles means (to me) this:
| /| -> |\ |
|/ | | |
Now, depending on the order in which the points are sent to tesselator, the following contour sometimes results in a degenerate triangle, like this:
_________ <- Triangle1
| / | /
| / -> | / <- Triangle2
| / | /
So now the flat triangle 1 has vertice 0, 1 and 2, and triaggle 2 vertice 0, 3, 2.
This can be fixed by turning the edge between these triangles. The result looks like this:
| / /
| / /
I wrote a kind of an iterative algorithm, which keeps turning edges until there are no degenerate triangels left. It seems to handle all the cases, altough I can’t prove it correct theoretically.
Hope you get it work.
The reason i cant change the vertices that I am giving into the tesselator is because I am reading these from a file.
Also, checking the previous point for the same value wont work because, vertices which have the same values are not consequent.
And for my contour to complete, all these vertices must come in the order that they are read from the file.
Basically these are glyph contours.
For characters like k the contour is something like this
| | 4—5
| | / /
| | / /
| /3 /6
| | \
| | \
as you can see it starts from 1 and follows the order. At points 3 and 9 the value of the vertice is the same.
The problem comes because there are lines
2-3,3-4,8-9 and 9-10 all converging on a single point.
This is where it screws up.
Apart from this problem there is a problem of the overcrossing contour lines also
For this I will try the solution that you have given, about GLU_TESS_COMBINE. Currently the gluTessProperty Winding rule is ODD winding
I will try some other WINDING value and see.
Thanks a lot
Ok, now I see the problem. Well, if you are lucky, the GLU_TESS_COMBINE thing will solve the other case as well. Other than that, i’m all out of ideas.
If all you want to do is draw some text, maybe you can use wglUseFontOutlines. It creates display lists of normal windows fonts. If you need to know the actual faces, draw them in feedback mode. That is, of course, if you are developing for windows. I don’t know, whether there’s anything similar for other operating systems.
You must be doing something else wrong because I do this in my font library and have no problems. What platform are you on? I know that in the past MESAs tesselator wasn’t the best.
I am workin Multiplatform. But this error seems to come on Win2K as well as the Unix
flavours for which I am porting.
Have a look at this code… http://homepages.paradise.net.nz/henryj/code/index.html
It might help
I checked the FreeType lib code, but other than font decoding, I couldnt find the actual OpenGL tesselation of the contours generated.