1 /* 2 Open Asset Import Library (assimp) 3 ---------------------------------------------------------------------- 4 5 Copyright (c) 2006-2017, assimp team 6 7 All rights reserved. 8 9 Redistribution and use of this software in source and binary forms, 10 with or without modification, are permitted provided that the 11 following conditions are met: 12 13 * Redistributions of source code must retain the above 14 copyright notice, this list of conditions and the 15 following disclaimer. 16 17 * Redistributions in binary form must reproduce the above 18 copyright notice, this list of conditions and the 19 following disclaimer in the documentation and/or other 20 materials provided with the distribution. 21 22 * Neither the name of the assimp team, nor the names of its 23 contributors may be used to endorse or promote products 24 derived from this software without specific prior 25 written permission of the assimp team. 26 27 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 28 "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 29 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 30 A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 31 OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 32 SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 33 LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 34 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 35 THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 36 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 37 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 38 39 ---------------------------------------------------------------------- 40 */ 41 42 /** @file MakeLeftHandedProcess.h 43 * @brief Defines a bunch of post-processing steps to handle 44 * coordinate system conversions. 45 * 46 * - LH to RH 47 * - UV origin upper-left to lower-left 48 * - face order cw to ccw 49 */ 50 #ifndef AI_CONVERTTOLHPROCESS_H_INC 51 #define AI_CONVERTTOLHPROCESS_H_INC 52 53 #include <assimp/types.h> 54 #include "BaseProcess.h" 55 56 struct aiMesh; 57 struct aiNodeAnim; 58 struct aiNode; 59 struct aiMaterial; 60 61 namespace Assimp { 62 63 // ----------------------------------------------------------------------------------- 64 /** @brief The MakeLeftHandedProcess converts all imported data to a left-handed 65 * coordinate system. 66 * 67 * This implies a mirroring of the Z axis of the coordinate system. But to keep 68 * transformation matrices free from reflections we shift the reflection to other 69 * places. We mirror the meshes and adapt the rotations. 70 * 71 * @note RH-LH and LH-RH is the same, so this class can be used for both 72 */ 73 class MakeLeftHandedProcess : public BaseProcess 74 { 75 76 77 public: 78 MakeLeftHandedProcess(); 79 ~MakeLeftHandedProcess(); 80 81 // ------------------------------------------------------------------- 82 bool IsActive( unsigned int pFlags) const; 83 84 // ------------------------------------------------------------------- 85 void Execute( aiScene* pScene); 86 87 protected: 88 89 // ------------------------------------------------------------------- 90 /** Recursively converts a node and all of its children 91 */ 92 void ProcessNode( aiNode* pNode, const aiMatrix4x4& pParentGlobalRotation); 93 94 // ------------------------------------------------------------------- 95 /** Converts a single mesh to left handed coordinates. 96 * This means that positions, normals and tangents are mirrored at 97 * the local Z axis and the order of all faces are inverted. 98 * @param pMesh The mesh to convert. 99 */ 100 void ProcessMesh( aiMesh* pMesh); 101 102 // ------------------------------------------------------------------- 103 /** Converts a single material to left-handed coordinates 104 * @param pMat Material to convert 105 */ 106 void ProcessMaterial( aiMaterial* pMat); 107 108 // ------------------------------------------------------------------- 109 /** Converts the given animation to LH coordinates. 110 * The rotation and translation keys are transformed, the scale keys 111 * work in local space and can therefore be left untouched. 112 * @param pAnim The bone animation to transform 113 */ 114 void ProcessAnimation( aiNodeAnim* pAnim); 115 }; 116 117 118 // --------------------------------------------------------------------------- 119 /** Postprocessing step to flip the face order of the imported data 120 */ 121 class FlipWindingOrderProcess : public BaseProcess 122 { 123 friend class Importer; 124 125 public: 126 /** Constructor to be privately used by Importer */ 127 FlipWindingOrderProcess(); 128 129 /** Destructor, private as well */ 130 ~FlipWindingOrderProcess(); 131 132 // ------------------------------------------------------------------- 133 bool IsActive( unsigned int pFlags) const; 134 135 // ------------------------------------------------------------------- 136 void Execute( aiScene* pScene); 137 138 protected: 139 void ProcessMesh( aiMesh* pMesh); 140 }; 141 142 // --------------------------------------------------------------------------- 143 /** Postprocessing step to flip the UV coordinate system of the import data 144 */ 145 class FlipUVsProcess : public BaseProcess 146 { 147 friend class Importer; 148 149 public: 150 /** Constructor to be privately used by Importer */ 151 FlipUVsProcess(); 152 153 /** Destructor, private as well */ 154 ~FlipUVsProcess(); 155 156 // ------------------------------------------------------------------- 157 bool IsActive( unsigned int pFlags) const; 158 159 // ------------------------------------------------------------------- 160 void Execute( aiScene* pScene); 161 162 protected: 163 void ProcessMesh( aiMesh* pMesh); 164 void ProcessMaterial( aiMaterial* mat); 165 }; 166 167 } // end of namespace Assimp 168 169 #endif // AI_CONVERTTOLHPROCESS_H_INC 170