mesh_splitter.h 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. /*
  2. Assimp2Json
  3. Copyright (c) 2011, Alexander C. Gessler
  4. Licensed under a 3-clause BSD license. See the LICENSE file for more information.
  5. */
  6. #ifndef INCLUDED_MESH_SPLITTER
  7. #define INCLUDED_MESH_SPLITTER
  8. // ----------------------------------------------------------------------------
  9. // Note: this is largely based on assimp's SplitLargeMeshes_Vertex process.
  10. // it is refactored and the coding style is slightly improved, though.
  11. // ----------------------------------------------------------------------------
  12. #include <vector>
  13. struct aiScene;
  14. struct aiMesh;
  15. struct aiNode;
  16. // ---------------------------------------------------------------------------
  17. /** Splits meshes of unique vertices into meshes with no more vertices than
  18. * a given, configurable threshold value.
  19. */
  20. class MeshSplitter
  21. {
  22. public:
  23. void SetLimit(unsigned int l) {
  24. LIMIT = l;
  25. }
  26. unsigned int GetLimit() const {
  27. return LIMIT;
  28. }
  29. public:
  30. // -------------------------------------------------------------------
  31. /** Executes the post processing step on the given imported data.
  32. * At the moment a process is not supposed to fail.
  33. * @param pScene The imported data to work at.
  34. */
  35. void Execute( aiScene* pScene);
  36. private:
  37. void UpdateNode(aiNode* pcNode, const std::vector<std::pair<aiMesh*, unsigned int> >& source_mesh_map);
  38. void SplitMesh (unsigned int index, aiMesh* mesh, std::vector<std::pair<aiMesh*, unsigned int> >& source_mesh_map);
  39. public:
  40. unsigned int LIMIT;
  41. };
  42. #endif // INCLUDED_MESH_SPLITTER