I was able to do subdivision on a triangle mesh with midpoints but then I get polygons with too many faces. How do I convert to triangles after?

Similar to this picture:

Subdivision example

  • \$\begingroup\$ Hello, and welcome to GameDev! What polygons are you trying to convert into triangles? What is the particular issue which is stopping you from moving further? The more specific you are about your issue, the quicker users can answer your question \$\endgroup\$ – liggiorgio Aug 22 '18 at 21:25
  • \$\begingroup\$ For spatial/geometric problems in particular, attaching a screenshot or diagram can often be a big help to ensure everyone understands your use case. Can you also specify what tech you're using? Is this in a 3D modelling program, inside a game engine, or in your own code (using any particular libraries)? \$\endgroup\$ – DMGregory Aug 22 '18 at 21:45
  • 3
    \$\begingroup\$ You say in your question "but then I get polygons with too many faces," but in your image I see only 3-sided polygons, I don't see any polygons with too many sides that we'd need to "convert to triangles after." Can you explain or show us where these non-triangular polygons are showing up? And as asked above, don't forget to tell us what tech you're working with! \$\endgroup\$ – DMGregory Aug 23 '18 at 12:20

I found the solution.

Each edge in the old model is subdivided and we keep a lookup of the edge to the new vertex it generates. Then we can loop through the triangles and generate the new edges.

  • 2
    \$\begingroup\$ This answer would be even better if you included some sample/pseudo-code or step-by-step instructions, so another user who's having a similar problem but has never seen how your code works can learn from your example. \$\endgroup\$ – DMGregory Aug 24 '18 at 12:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.