1/*
2Open Asset Import Library (assimp)
3----------------------------------------------------------------------
4
5Copyright (c) 2006-2017, assimp team
6
7All rights reserved.
8
9Redistribution and use of this software in source and binary forms,
10with or without modification, are permitted provided that the
11following 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
27THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
28"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
29LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
30A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
31OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
32SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
33LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
34DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
35THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
36(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
37OF 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
56struct aiMesh;
57struct aiNodeAnim;
58struct aiNode;
59struct aiMaterial;
60
61namespace 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 */
73class MakeLeftHandedProcess : public BaseProcess
74{
75
76
77public:
78 MakeLeftHandedProcess();
79 ~MakeLeftHandedProcess();
80
81 // -------------------------------------------------------------------
82 bool IsActive( unsigned int pFlags) const;
83
84 // -------------------------------------------------------------------
85 void Execute( aiScene* pScene);
86
87protected:
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 */
121class FlipWindingOrderProcess : public BaseProcess
122{
123 friend class Importer;
124
125public:
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
138protected:
139 void ProcessMesh( aiMesh* pMesh);
140};
141
142// ---------------------------------------------------------------------------
143/** Postprocessing step to flip the UV coordinate system of the import data
144 */
145class FlipUVsProcess : public BaseProcess
146{
147 friend class Importer;
148
149public:
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
162protected:
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