public void BuildMeshFromGeometry() { triMesh = new TriangleNet.Mesh(); triMesh.behavior.Quality = true; triMesh.behavior.MinAngle = 1f; triMesh.Triangulate(Geometry); // var statistic = new Statistic(); // statistic.Update(triMesh, 1); // Refine by setting a custom maximum area constraint. //triMesh.Refine(statistic.LargestArea / 4); //triMesh.Smooth(); triMesh.Renumber(); UniMesh.vertices = TriangleConverter.ConverteVertices(triMesh.Vertices); UniMesh.RecalculateNormals(); UniMesh.triangles = TriangleConverter.ConverteTriangles(triMesh.Triangles); UniMesh.uv = TriangleConverter.ConverteUVs(triMesh); Debug.Log(string.Format("width {0:0.00}, height {1:0.00}; min {2:0.00}, {3:0.00}; max {4:0.00}, {5:0.00}", triMesh.Bounds.Width, triMesh.Bounds.Height, triMesh.Bounds.Xmin, triMesh.Bounds.Ymin, triMesh.Bounds.Xmax, triMesh.Bounds.Ymax)); }
public void OnRender(TriangleNet.Mesh triangleMesh) { /*data.SetMesh(mesh); * UniMesh.vertices = data.Vertices; * UniMesh.triangles = data.Triangles;*/ var _mesh = GetComponent <MeshFilter>().mesh; if (!_mesh) { _mesh = new Mesh(); GetComponent <MeshFilter>().mesh = _mesh; } _mesh.Clear(); _mesh.vertices = TriangleConverter.ConverteVertices(triangleMesh.Vertices); List <Vector3> normals = new List <Vector3>(); for (int i = 0; i < _mesh.vertices.Length; i++) { normals.Add(Vector3.back); } _mesh.normals = normals.ToArray(); _mesh.uv = TriangleConverter.ConverteUVs(triangleMesh); _mesh.triangles = TriangleConverter.ConverteTriangles(triangleMesh.Triangles); }