Skip to content

mattatz/unity-triangulation2D

master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Code

Latest commit

Add useful method for unity-teddy.
d638e01

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
September 10, 2016 18:59
June 24, 2016 18:44
June 24, 2016 18:44
August 4, 2016 10:52
June 25, 2016 14:54

unity-triangulation2D

Delaunay Triangulation and Ruppert's Delaunay Refinement Algorithm in Unity.

Input contour points for planar straight-line graph

Delaunay Triangulation

Mesh Refinement with minimum angle α(22.5)

Usage

// input points for a polygon2D contor
List<Vector2> points = new List<Vector2>();

// Add Vector2 to points
points.Add(new Vector2(-2.5f, -2.5f));
points.Add(new Vector2(2.5f, -2.5f));
points.Add(new Vector2(4.5f, 2.5f));
points.Add(new Vector2(0.5f, 4.5f));
points.Add(new Vector2(-3.5f, 2.5f));

// construct Polygon2D 
Polygon2D polygon = Polygon2D.Contour(points.ToArray());

// construct Triangulation2D with Polygon2D and threshold angle (18f ~ 27f recommended)
Triangulation2D triangulation = new Triangulation2D(polygon, 22.5f);

// build a mesh from triangles in a Triangulation2D instance
Mesh mesh = triangulation.Build();
// GetComponent<MeshFilter>().sharedMesh = mesh;

Demo

Sources

About

Ruppert's Delaunay Refinement Algorithm in Unity

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published