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 PretransformVertices.h
43 * @brief Defines a post processing step to pretransform all
44 * vertices in the scenegraph
45 */
46#ifndef AI_PRETRANSFORMVERTICES_H_INC
47#define AI_PRETRANSFORMVERTICES_H_INC
48
49#include "BaseProcess.h"
50#include <assimp/mesh.h>
51#include <list>
52#include <vector>
53
54struct aiNode;
55class PretransformVerticesTest;
56namespace Assimp {
57
58// ---------------------------------------------------------------------------
59/** The PretransformVertices pre-transforms all vertices in the node tree
60 * and removes the whole graph. The output is a list of meshes, one for
61 * each material.
62*/
63class ASSIMP_API PretransformVertices : public BaseProcess
64{
65public:
66
67 PretransformVertices ();
68 ~PretransformVertices ();
69
70public:
71
72 // -------------------------------------------------------------------
73 // Check whether step is active
74 bool IsActive( unsigned int pFlags) const;
75
76 // -------------------------------------------------------------------
77 // Execute step on a given scene
78 void Execute( aiScene* pScene);
79
80 // -------------------------------------------------------------------
81 // Setup import settings
82 void SetupProperties(const Importer* pImp);
83
84
85 // -------------------------------------------------------------------
86 /** @brief Toggle the 'keep hierarchy' option
87 * @param d hm ... difficult to guess what this means, hu!?
88 */
89 void KeepHierarchy(bool d) {
90 configKeepHierarchy = d;
91 }
92
93 // -------------------------------------------------------------------
94 /** @brief Check whether 'keep hierarchy' is currently enabled.
95 * @return ...
96 */
97 bool IsHierarchyKept() const {
98 return configKeepHierarchy;
99 }
100
101private:
102
103 // -------------------------------------------------------------------
104 // Count the number of nodes
105 unsigned int CountNodes( aiNode* pcNode );
106
107 // -------------------------------------------------------------------
108 // Get a bitwise combination identifying the vertex format of a mesh
109 unsigned int GetMeshVFormat(aiMesh* pcMesh);
110
111 // -------------------------------------------------------------------
112 // Count the number of vertices in the whole scene and a given
113 // material index
114 void CountVerticesAndFaces( aiScene* pcScene, aiNode* pcNode,
115 unsigned int iMat,
116 unsigned int iVFormat,
117 unsigned int* piFaces,
118 unsigned int* piVertices);
119
120 // -------------------------------------------------------------------
121 // Collect vertex/face data
122 void CollectData( aiScene* pcScene, aiNode* pcNode,
123 unsigned int iMat,
124 unsigned int iVFormat,
125 aiMesh* pcMeshOut,
126 unsigned int aiCurrent[2],
127 unsigned int* num_refs);
128
129 // -------------------------------------------------------------------
130 // Get a list of all vertex formats that occur for a given material
131 // The output list contains duplicate elements
132 void GetVFormatList( aiScene* pcScene, unsigned int iMat,
133 std::list<unsigned int>& aiOut);
134
135 // -------------------------------------------------------------------
136 // Compute the absolute transformation matrices of each node
137 void ComputeAbsoluteTransform( aiNode* pcNode );
138
139 // -------------------------------------------------------------------
140 // Simple routine to build meshes in worldspace, no further optimization
141 void BuildWCSMeshes(std::vector<aiMesh*>& out, aiMesh** in,
142 unsigned int numIn, aiNode* node);
143
144 // -------------------------------------------------------------------
145 // Apply the node transformation to a mesh
146 void ApplyTransform(aiMesh* mesh, const aiMatrix4x4& mat);
147
148 // -------------------------------------------------------------------
149 // Reset transformation matrices to identity
150 void MakeIdentityTransform(aiNode* nd);
151
152 // -------------------------------------------------------------------
153 // Build reference counters for all meshes
154 void BuildMeshRefCountArray(aiNode* nd, unsigned int * refs);
155
156
157
158 //! Configuration option: keep scene hierarchy as long as possible
159 bool configKeepHierarchy;
160 bool configNormalize;
161 bool configTransform;
162 aiMatrix4x4 configTransformation;
163};
164
165} // end of namespace Assimp
166
167#endif // !!AI_GENFACENORMALPROCESS_H_INC
168