Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.
 
 
 
 
 
 

167 lignes
5.4 KiB

  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. /** @file MakeLeftHandedProcess.h
  34. * @brief Defines a bunch of post-processing steps to handle
  35. * coordinate system conversions.
  36. *
  37. * - LH to RH
  38. * - UV origin upper-left to lower-left
  39. * - face order cw to ccw
  40. */
  41. #ifndef AI_CONVERTTOLHPROCESS_H_INC
  42. #define AI_CONVERTTOLHPROCESS_H_INC
  43. #include "../include/assimp/types.h"
  44. #include "BaseProcess.h"
  45. struct aiMesh;
  46. struct aiNodeAnim;
  47. namespace Assimp {
  48. // -----------------------------------------------------------------------------------
  49. /** @brief The MakeLeftHandedProcess converts all imported data to a left-handed
  50. * coordinate system.
  51. *
  52. * This implies a mirroring of the Z axis of the coordinate system. But to keep
  53. * transformation matrices free from reflections we shift the reflection to other
  54. * places. We mirror the meshes and adapt the rotations.
  55. *
  56. * @note RH-LH and LH-RH is the same, so this class can be used for both
  57. */
  58. class MakeLeftHandedProcess : public BaseProcess
  59. {
  60. public:
  61. MakeLeftHandedProcess();
  62. ~MakeLeftHandedProcess();
  63. // -------------------------------------------------------------------
  64. bool IsActive( unsigned int pFlags) const;
  65. // -------------------------------------------------------------------
  66. void Execute( aiScene* pScene);
  67. protected:
  68. // -------------------------------------------------------------------
  69. /** Recursively converts a node and all of its children
  70. */
  71. void ProcessNode( aiNode* pNode, const aiMatrix4x4& pParentGlobalRotation);
  72. // -------------------------------------------------------------------
  73. /** Converts a single mesh to left handed coordinates.
  74. * This means that positions, normals and tangents are mirrored at
  75. * the local Z axis and the order of all faces are inverted.
  76. * @param pMesh The mesh to convert.
  77. */
  78. void ProcessMesh( aiMesh* pMesh);
  79. // -------------------------------------------------------------------
  80. /** Converts a single material to left-handed coordinates
  81. * @param pMat Material to convert
  82. */
  83. void ProcessMaterial( aiMaterial* pMat);
  84. // -------------------------------------------------------------------
  85. /** Converts the given animation to LH coordinates.
  86. * The rotation and translation keys are transformed, the scale keys
  87. * work in local space and can therefore be left untouched.
  88. * @param pAnim The bone animation to transform
  89. */
  90. void ProcessAnimation( aiNodeAnim* pAnim);
  91. };
  92. // ---------------------------------------------------------------------------
  93. /** Postprocessing step to flip the face order of the imported data
  94. */
  95. class FlipWindingOrderProcess : public BaseProcess
  96. {
  97. friend class Importer;
  98. public:
  99. /** Constructor to be privately used by Importer */
  100. FlipWindingOrderProcess();
  101. /** Destructor, private as well */
  102. ~FlipWindingOrderProcess();
  103. // -------------------------------------------------------------------
  104. bool IsActive( unsigned int pFlags) const;
  105. // -------------------------------------------------------------------
  106. void Execute( aiScene* pScene);
  107. protected:
  108. void ProcessMesh( aiMesh* pMesh);
  109. };
  110. // ---------------------------------------------------------------------------
  111. /** Postprocessing step to flip the UV coordinate system of the import data
  112. */
  113. class FlipUVsProcess : public BaseProcess
  114. {
  115. friend class Importer;
  116. public:
  117. /** Constructor to be privately used by Importer */
  118. FlipUVsProcess();
  119. /** Destructor, private as well */
  120. ~FlipUVsProcess();
  121. // -------------------------------------------------------------------
  122. bool IsActive( unsigned int pFlags) const;
  123. // -------------------------------------------------------------------
  124. void Execute( aiScene* pScene);
  125. protected:
  126. void ProcessMesh( aiMesh* pMesh);
  127. void ProcessMaterial( aiMaterial* mat);
  128. };
  129. } // end of namespace Assimp
  130. #endif // AI_CONVERTTOLHPROCESS_H_INC