Triangulation Plugin Development for Unity
[Bane by Eliasmadan.]
As part of a project for one of our clients, we are working with Unity in a 3D environment. We love 3D, however, it can be somewhat restrictive when you have to draw a simple polygon. Unfortunately, it is not possible to do so using Unity’s standard libraries. Below you will find information on how to solve this issue.
Solution 1: Editing the Texture
A simple solution is to focus on the 2D texture as opposed to the 3D mesh. However, sometimes we may not have this option and are left with no other choice but to triangulate our polygon!
Solution 2: Triangulation, by Necessity
Triangulation has been around since the early stages of 3D, and mathematicians such as Boris Delaunay and Gueorgui Voronoï have left their marks in our current computers.
Since the triangle is the basic unit for 3D modelling, the goal of “triangulation” is to divide a surface in a series of carefully selected triangles.
Oddly enough, these basic functions are not available in Unity’s standard libraries.
For our project, we decided to bring Berkley University Professor Jonathan R. Shwechuk’s Triangle library for Unity as a multiplatform plugin. This plugin works with Android, iOS, Windows and Mac.
Here is the result. This was achieved using the plugin we developed for our client as well as the Triangle library:
Executable demo available here: http://goo.gl/GO1vCC
While we solely focused on polygons drawing as part of our project, this tool allows for other uses:
- Dynamic production of a 3D mesh
- Possibility of carrying out simulations by decomposing finite elements (ex.: aerodynamics of a plane, wi-fi network coverage, shock calculation)
- Using a shader, we can achieve graphical representation such as heat map or Voronoi
- For video games, we could imagine a new destruction system where a 3D mesh could increase its “tessellation" level before shattering.