- Home /
2d custom mesh triangulator problem
Hello i having some trouble with well known triangulator class.I implemented the triangulator class directly without an edit.My aim is to create a volumetric light depending on the direction but im having this issue relative with triangles appearently.
Another view i keep the positions of the red colored rays start&end locations and i put these locations as vertices in MESH FILTER component.
public void buildSingleVolume()
{
Mesh _mesh = new Mesh ();
_mesh.name = "VolumeMesh";
for (int i = 0; i < _vert2d.Length; i++)
{
_vert3d [i] = new Vector3 (_vert2d[i].x,_vert2d[i].y,0);
}
Triangulator _tr = new Triangulator (_vert2d);
int[] indices = _tr.Triangulate ();
_mesh.vertices = _vert3d;
_mesh.triangles =indices;
_mesh.RecalculateNormals ();
_mesh.RecalculateBounds ();
GameObject _instance = Instantiate (volume, Vector2.zero,new Quaternion(0,0,0,0)) as GameObject;
_instance.tag = "VolumeL";
_instance.GetComponent<MeshFilter> ().mesh = _mesh;
}
the mesh would show up with exact positions of red rays but it has many zig-zag or false structure.
I have done triangulation of arbitrary 2d points in several projects but I don't know what you mean by "well known" triangulator. Could you elaborate? Which library are you using? I am sure I could help you if I had the correct info. I also do not undersand the red rays, are those your resulting mesh after triangulation?
It's the triangulator from wiki.unity link:http://wiki.unity3d.com/index.php?title=Triangulator like you said those are resulting mesh i use those rays to show if im doing things right.
Answer by alph1 · Apr 02, 2017 at 07:00 PM
Solved.I sorted the vertices of the mesh as clockwise and then i triangulated the vertices i sorted with this link:http://wiki.unity3d.com/index.php?title=Triangulator Triangulator script.
Your answer
Follow this Question
Related Questions
Mesh with Holes 0 Answers
Generating single triangle meshes at run-time 1 Answer
Generated Mesh Triangles not Being Made/Visible? 1 Answer
Why is my script constructed mesh rotating the wrong way 0 Answers
Save only visible part of mesh 1 Answer