I'm writing a program that takes a 2D planar polygon and extrudes it to a 3D mesh with a given height. I identify triangle edges that are borders of the polygon and now I'm trying to automatically compute the two triangles required for the extrusion of the border. However, I'm stuck at how to compute the correct winding and normals
My start situation is this: I have the two coordinates of the edge (marked in white) and the normal of the original triangle (marked in orange)
Using this information I'm trying to compute two triangles which should result in:
The 4 vertices are easy to compute (just the two vertices of the edge and two more at a different height). The normal should be perpendicular to the original normal but to do that I need a second reference point. It doesn't seem to be as simple as using the centroid of the triangle.
The triangle winding confuses me. I need a counter-clockwise winding and I guess I could determine which vertices to use based on the normal but how is not immediately apparent to me.
cross(v1 - v0, v2 - v0)
. You can even normalize it if necessary. This works even for oblique extrusions. \$\endgroup\$