Seperating isolated triangles into mesh
Hello, I have the following dynamically generated mesh and I'm looking for a way to detach the triangles in the middle into a separate mesh:
This got generated with:
NavMeshTriangulation navmesh = NavMesh.CalculateTriangulation();
Mesh mesh = new Mesh();
GetComponent<MeshFilter>().mesh = mesh;
mesh.vertices = navmesh.vertices;
mesh.triangles = navmesh.indices;
I looked at this thread but unfortunately the code does not provide satisfying results: http://answers.unity3d.com/questions/753188/seperating-one-single-mesh-into-meshes.html
The only real way I can think of is recursively iterate all triangles and find their neighbors; Until all neighbors and their neighbor's neighbors got added (and so on). Then redo the same for the remaining triangles that weren't iterated yet. Then use those subsets to generate meshes.
Is there maybe a more elegant solution to this problem?
Regards Walki
Your answer
Follow this Question
Related Questions
How to get triangle index of meshe's desired part? 0 Answers
Add mesh to a scene in Runtime takes too long 0 Answers
Triangles become black when flipping triangles 0 Answers
Finding the vertices of each edge of a mesh face found by a raycast hit 0 Answers
Easy way to curve a virtual screen? 1 Answer