Search Unity

Tessellation algorithms for polygons

Discussion in 'Scripting' started by guavaman, Feb 12, 2014.

  1. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,624
    I need to triangulate a polygon with any number of vertices without adding any internal points as you would get with a Delaunay triangulation. The polygon will never have holes in it. I'm basically trying to replicate how Unity creates a mesh shaped to the source image when you create a Sprite.

    I've found a number of different approaches and tried 3 of them with mixed results:

    Unity Wiki: http://wiki.unity3d.com/index.php?title=Triangulator
    LibTessDotNet: https://github.com/speps/LibTessDotNet
    Stevesan: http://forum.unity3d.com/threads/141281-Efficient-Polygon-Triangulation-implementation-Open-source!

    I've attached some images of the results at the end of this post.

    Does anyone know of a more appropriate algorithm for polygon tessellation that will output a cleaner mesh?
     

    Attached Files:

    Last edited: Feb 12, 2014
  2. mu-kow

    mu-kow

    Joined:
    May 15, 2012
    Posts:
    106
  3. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,624
    That looks just about perfect! Thanks a bunch for the link!
     
  4. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,624
    @mu-kow Its perfect! Thank you! :D
     

    Attached Files:

  5. mu-kow

    mu-kow

    Joined:
    May 15, 2012
    Posts:
    106
    Awesome. Glad it worked out for you!
     
  6. vahab2

    vahab2

    Joined:
    Nov 12, 2009
    Posts:
    11
    Could you please share your unity c# code?
     
  7. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,624
    This thread is 6.5 years old and I don't even have this code anymore.
     
    LapidistCubed and Bunny83 like this.