Skip to main content
Tweeted twitter.com/#!/StackGameDev/status/484520544453558273
deleted 35 characters in body
Source Link
Roy T.
  • 10.2k
  • 38
  • 58

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)

Start situation

Using this information I'm trying to compute two triangles which should result in:

Extruded

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. Maybe itsIt doesn't seem to be as simple as using the direction from the centercentroid of the triangle to the middle of the chosen edge?.

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.

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)

Start situation

Using this information I'm trying to compute two triangles which should result in:

Extruded

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. Maybe its as simple as using the direction from the center of the triangle to the middle of the chosen edge? 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.

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)

Start situation

Using this information I'm trying to compute two triangles which should result in:

Extruded

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.

Source Link
Roy T.
  • 10.2k
  • 38
  • 58

Calculating the winding and normal when programatically adding triangles to a mesh

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)

Start situation

Using this information I'm trying to compute two triangles which should result in:

Extruded

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. Maybe its as simple as using the direction from the center of the triangle to the middle of the chosen edge? 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.