问题
I need to import a mesh to an app that can only handle a certain number of meshes per object. Because of that, I'm forced to split the mesh into several pieces until all pices are below the maximum vertex count. The splitting has to happen in runtime, so I can't use an external application to split the mesh.
I don't have any requirement regarding how the mesh is split, but it should conservate all faces, normals and UVs.
Is there any known algorithm that can do so?
回答1:
You need to use a triangle adjacency graph. Start from a triangle and mark it visited. Then from each triangle side, move on adjacent triangles not visited and mark them visited. Once the vertex count reaches the limit, create a new mesh and start over.
回答2:
A possibility that is both simple to code and gives a reasonably good result is to sort the triangles spatially, with the Hilbert sort [1]. Then you traverse the ordered list of triangles, group them into clusters of n elements and generate the different parts of your mesh. An implementation is available in my GEOGRAM programming library [2]. See function mesh_partition() [3]. If you want to optimize the "compactness" of the parts (i.e. minimize the number of connected components in each part), then you can use a graph partitioning algorithm such as METIS [4] or SCOTCH [5], applied to the graph of the facets (that has a node per facet and an edge connecting each pair of adjacent facets). However, it is more expensive (in terms of both time and memory consumption).
[1] https://en.wikipedia.org/wiki/Hilbert_curve
[2] http://alice.loria.fr/software/geogram/doc/html/index.html
[3] http://alice.loria.fr/software/geogram/doc/html/mesh__partition_8h.html
[4] http://glaros.dtc.umn.edu/gkhome/metis/metis/overview
[5] http://www.labri.fr/perso/pelegrin/scotch/
来源:https://stackoverflow.com/questions/42532392/how-can-i-split-a-mesh-in-several-pieces-so-that-all-are-smaller-than-a-given-nu