Allegro.cc - Online Community

Allegro.cc Forums » Programming Questions » [A5] Software triangulator and 3D polygons

This thread is locked; no one can reply to it. rss feed Print
[A5] Software triangulator and 3D polygons
BitCruncher
Member #11,279
August 2009
avatar

I have a question about al_triangulate_polygon().

Since this function takes a list of 2D vertices, essentially throwing away the z-coordinate, would the triangulation be valid for a 3-dimensional polygon?

Let's say, for example, I saved the z-components of all the vertices in the polygon, triangulated it and then attached the z-components back to their triangulated forms, is the triangulation still valid? My mathematical intuition says yes, but I could be wrong.

In my mind, I'm picturing taking the 3-dimensional polygon and flattening it out to a plane. If I triangulated that 2D polygon, and applied the z-component back, it would still fit the original polygon like a glove.

Edgar Reynaldo
Major Reynaldo
May 2007
avatar

MikiZX
Member #17,092
June 2019

Top of my head, and without having used al_triangulate_polygon() ever, I'm thinking you would need to unwrap the 3d polygon to 2d plane (just like 3d modelling software such as i.e. Blender unwrap the 3d model for UV mapping), triangulate in 2d (using al_triangulate_polygon()) and then wrap the triangulated 2d mesh back to 3d using the previous 3d coordinates for each vertex. Simply flattening the 3d coordinates to 2d will likely fail as you would be flattening it without consideration for its shape or orientation.

Edgar Reynaldo
Major Reynaldo
May 2007
avatar

al_triangulate_polygon outputs a list of vertice triplets. Coordinates don't really matter. It should work the same either way.

NVM, I am wrong. Obviously, it coudln't work on say, a profile.

Can you transform to match your polygon's plane? Or is it dis-planar? That might be too much.

Go to: