Non puoi selezionare più di 25 argomenti Gli argomenti devono iniziare con una lettera o un numero, possono includere trattini ('-') e possono essere lunghi fino a 35 caratteri.

DeboneProcess.h 4.8 KiB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. /*
  2. Open Asset Import Library (assimp)
  3. ----------------------------------------------------------------------
  4. Copyright (c) 2006-2012, assimp team
  5. All rights reserved.
  6. Redistribution and use of this software in source and binary forms,
  7. with or without modification, are permitted provided that the
  8. following conditions are met:
  9. * Redistributions of source code must retain the above
  10. copyright notice, this list of conditions and the
  11. following disclaimer.
  12. * Redistributions in binary form must reproduce the above
  13. copyright notice, this list of conditions and the
  14. following disclaimer in the documentation and/or other
  15. materials provided with the distribution.
  16. * Neither the name of the assimp team, nor the names of its
  17. contributors may be used to endorse or promote products
  18. derived from this software without specific prior
  19. written permission of the assimp team.
  20. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  21. "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  22. LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  23. A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  24. OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  25. SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  26. LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  27. DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  28. THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  29. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  30. OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  31. ----------------------------------------------------------------------
  32. */
  33. /** Defines a post processing step to limit the number of bones affecting a single vertex. */
  34. #ifndef AI_DEBONEPROCESS_H_INC
  35. #define AI_DEBONEPROCESS_H_INC
  36. #include <vector>
  37. #include <utility>
  38. #include "BaseProcess.h"
  39. #include "../include/assimp/mesh.h"
  40. #include "../include/assimp/scene.h"
  41. class DeboneTest;
  42. namespace Assimp
  43. {
  44. #if (!defined AI_DEBONE_THRESHOLD)
  45. # define AI_DEBONE_THRESHOLD 1.0f
  46. #endif // !! AI_DEBONE_THRESHOLD
  47. // ---------------------------------------------------------------------------
  48. /** This post processing step removes bones nearly losslessly or according to
  49. * a configured threshold. In order to remove the bone, the primitives affected by
  50. * the bone are split from the mesh. The split off (new) mesh is boneless. At any
  51. * point in time, bones without affect upon a given mesh are to be removed.
  52. */
  53. class DeboneProcess : public BaseProcess
  54. {
  55. public:
  56. DeboneProcess();
  57. ~DeboneProcess();
  58. public:
  59. // -------------------------------------------------------------------
  60. /** Returns whether the processing step is present in the given flag.
  61. * @param pFlags The processing flags the importer was called with.
  62. * A bitwise combination of #aiPostProcessSteps.
  63. * @return true if the process is present in this flag fields,
  64. * false if not.
  65. */
  66. bool IsActive( unsigned int pFlags) const;
  67. // -------------------------------------------------------------------
  68. /** Called prior to ExecuteOnScene().
  69. * The function is a request to the process to update its configuration
  70. * basing on the Importer's configuration property list.
  71. */
  72. void SetupProperties(const Importer* pImp);
  73. protected:
  74. // -------------------------------------------------------------------
  75. /** Executes the post processing step on the given imported data.
  76. * At the moment a process is not supposed to fail.
  77. * @param pScene The imported data to work at.
  78. */
  79. void Execute( aiScene* pScene);
  80. // -------------------------------------------------------------------
  81. /** Counts bones total/removable in a given mesh.
  82. * @param pMesh The mesh to process.
  83. */
  84. bool ConsiderMesh( const aiMesh* pMesh);
  85. /// Splits the given mesh by bone count.
  86. /// @param pMesh the Mesh to split. Is not changed at all, but might be superfluous in case it was split.
  87. /// @param poNewMeshes Array of submeshes created in the process. Empty if splitting was not necessary.
  88. void SplitMesh(const aiMesh* pMesh, std::vector< std::pair< aiMesh*,const aiBone* > >& poNewMeshes) const;
  89. /// Recursively updates the node's mesh list to account for the changed mesh list
  90. void UpdateNode(aiNode* pNode) const;
  91. // -------------------------------------------------------------------
  92. // Apply transformation to a mesh
  93. void ApplyTransform(aiMesh* mesh, const aiMatrix4x4& mat)const;
  94. public:
  95. /** Number of bones present in the scene. */
  96. unsigned int mNumBones;
  97. unsigned int mNumBonesCanDoWithout;
  98. float mThreshold;
  99. bool mAllOrNone;
  100. /// Per mesh index: Array of indices of the new submeshes.
  101. std::vector< std::vector< std::pair< unsigned int,aiNode* > > > mSubMeshIndices;
  102. };
  103. } // end of namespace Assimp
  104. #endif // AI_DEBONEPROCESS_H_INC