Triangulating a surface

Blitz3D Forums/Blitz3D Programming/Triangulating a surface

_33(Posted 2007) [#1]
I'm in front of a sizable problem here. A problem that have stopped me from going further in my 3D development since mid April this year. I'm trying to find the proper algorythm to triangulate considering holes in the surface of the model. I'll link an image here...


Basically, what I know is, it should take in all the corners, and it should analyse from there how to shoot the right connections between the corners, in order to do triangulation of the surface. This is of course a 2D exercise, but it's for building 3D surfaces.


IE. The 2D surface will always be based on rectangle type edges.

It's possible that the way I placed my triangles, it's not in logical steps where a procedure could be build around it, but I posted this image as a simple example of the triangulation need. I think it's close thoe to what a proper function could do.

I tought working with a boundary, or division of the surface, say from top to bottom, keeping that horizontal boundary, and simply shooting lines downwards from there could be the way to go. But really, I don't know from there. Also, I'm making sure that this will generate a closed surface, and to me, that's a little puzzling. If anyone has a tutorial on closed vs open mesh, I'd read that through.

Cheers :)


Stevie G(Posted 2007) [#2]
http://www.geometrictools.com/Documentation/TriangulationByEarClipping.pdf

There are some triangulate algorithms in the code archives ( one of which I adapted to produce my 3d/2d landscapes for Stramash ) but they do not deal with holes. I looked at the above paper in the past and it seems that the same methods can be used but the inner polygon vertices must be passed in the opposite order to that of the outer one. Whether that works or not - no idea I'm afraid.

Stevie

Not much help


_33(Posted 2007) [#3]
Stevie, very very interesting concept with the ear tip, and stuff. If I understand this, what I should do is triangulate, and each time void some vertices for further usage. That way, I'll end up filling the space. At the same time, making sure the line's angle isn't between vert_end° and vert_start° (outside the figure). What do you think?

I'll post the function if I ever get to make it working.


Stevie G(Posted 2007) [#4]
Yes, that's how basic triangulation works but getting it to work with holes will be quite tricky I reckon. I'd be interested to see if you can get this to work as this technique will also be a good start for a nice non-uniform pathfinding algo.

Stevie


_33(Posted 2007) [#5]
http://www.blitzbasic.com/Community/posts.php?topic=26708

If only I could take that and add possibility of holes in the routine. I'm positive it's not a big thing to add that in, as the code seems really clean. I'l dig that up some more, but don't hold your breath...

EDIT: Actually that one is a little bogus as it doesn't seem to know the boundaries... I've had examples that I tried where it did what it tougth was right but messed it up bad. So I'll see what else I can dig up.

EDIT 2: Here's something that actually works well, but will need to add possibility of holes in the figure, and see if that will work. But it's like 3/4 of the way to what I need.

http://www.blitzbasic.com/Community/posts.php?topic=26539

The notions I'm trying to find in this is about outer node and inner node, and see what can be done to add the feature there.

Here's something I meditate on:
http://www.cs.cmu.edu/~quake/triangle.html

More meditation:
http://www.cgal.org/Manual/3.3/doc_html/cgal_manual/Mesh_2/Chapter_main.html


_33(Posted 2007) [#6]
I've cleaned up and updated the code in the previous reply, for whoever needs it. Much cleaner, but still doesn't cover all the cases:
- holes in surface
- figure in hole in surface
- hole in figure in hole in surface
- multiple figures in surface

The "hierarchies of polygons" concept is still blowing my mind, but I'm yet to fully understand the triangulation process to sort this out, so I'm far behind in this. Any help truely appreciated.

Cheers.


Difference(Posted 2007) [#7]
@_33 : The "hierarchies of polygons" is simpler than you think.

When you can triangulate and do hole(s) in polys you are almost done.

Sort the polys by size.
Take the biggest one and find it's hole(s)
Triangulate those, disregarding the rest.
Delete the biggest one and it's holes polys from the poly list.
Start over until you've done all.