vrshoot

view libs/assimp/PretransformVertices.h @ 0:b2f14e535253

initial commit
author John Tsiombikas <nuclear@member.fsf.org>
date Sat, 01 Feb 2014 19:58:19 +0200
parents
children
line source
1 /*
2 Open Asset Import Library (assimp)
3 ----------------------------------------------------------------------
5 Copyright (c) 2006-2012, assimp team
6 All rights reserved.
8 Redistribution and use of this software in source and binary forms,
9 with or without modification, are permitted provided that the
10 following conditions are met:
12 * Redistributions of source code must retain the above
13 copyright notice, this list of conditions and the
14 following disclaimer.
16 * Redistributions in binary form must reproduce the above
17 copyright notice, this list of conditions and the
18 following disclaimer in the documentation and/or other
19 materials provided with the distribution.
21 * Neither the name of the assimp team, nor the names of its
22 contributors may be used to endorse or promote products
23 derived from this software without specific prior
24 written permission of the assimp team.
26 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
27 "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
28 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
29 A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
30 OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
31 SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
32 LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
33 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
34 THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
35 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
36 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
38 ----------------------------------------------------------------------
39 */
41 /** @file PretransformVertices.h
42 * @brief Defines a post processing step to pretransform all
43 * vertices in the scenegraph
44 */
45 #ifndef AI_PRETRANSFORMVERTICES_H_INC
46 #define AI_PRETRANSFORMVERTICES_H_INC
48 #include "BaseProcess.h"
49 #include "assimp/mesh.h"
51 class PretransformVerticesTest;
52 namespace Assimp {
54 // ---------------------------------------------------------------------------
55 /** The PretransformVertices pretransforms all vertices in the nodegraph
56 * and removes the whole graph. The output is a list of meshes, one for
57 * each material.
58 */
59 class PretransformVertices : public BaseProcess
60 {
61 public:
63 PretransformVertices ();
64 ~PretransformVertices ();
66 public:
68 // -------------------------------------------------------------------
69 // Check whether step is active
70 bool IsActive( unsigned int pFlags) const;
72 // -------------------------------------------------------------------
73 // Execute step on a given scene
74 void Execute( aiScene* pScene);
76 // -------------------------------------------------------------------
77 // Setup import settings
78 void SetupProperties(const Importer* pImp);
81 // -------------------------------------------------------------------
82 /** @brief Toggle the 'keep hierarchy' option
83 * @param d hm ... difficult to guess what this means, hu!?
84 */
85 void KeepHierarchy(bool d) {
86 configKeepHierarchy = d;
87 }
89 // -------------------------------------------------------------------
90 /** @brief Check whether 'keep hierarchy' is currently enabled.
91 * @return ...
92 */
93 bool IsHierarchyKept() const {
94 return configKeepHierarchy;
95 }
97 private:
99 // -------------------------------------------------------------------
100 // Count the number of nodes
101 unsigned int CountNodes( aiNode* pcNode );
103 // -------------------------------------------------------------------
104 // Get a bitwise combination identifying the vertex format of a mesh
105 unsigned int GetMeshVFormat(aiMesh* pcMesh);
107 // -------------------------------------------------------------------
108 // Count the number of vertices in the whole scene and a given
109 // material index
110 void CountVerticesAndFaces( aiScene* pcScene, aiNode* pcNode,
111 unsigned int iMat,
112 unsigned int iVFormat,
113 unsigned int* piFaces,
114 unsigned int* piVertices);
116 // -------------------------------------------------------------------
117 // Collect vertex/face data
118 void CollectData( aiScene* pcScene, aiNode* pcNode,
119 unsigned int iMat,
120 unsigned int iVFormat,
121 aiMesh* pcMeshOut,
122 unsigned int aiCurrent[2],
123 unsigned int* num_refs);
125 // -------------------------------------------------------------------
126 // Get a list of all vertex formats that occur for a given material
127 // The output list contains duplicate elements
128 void GetVFormatList( aiScene* pcScene, unsigned int iMat,
129 std::list<unsigned int>& aiOut);
131 // -------------------------------------------------------------------
132 // Compute the absolute transformation matrices of each node
133 void ComputeAbsoluteTransform( aiNode* pcNode );
135 // -------------------------------------------------------------------
136 // Simple routine to build meshes in worldspace, no further optimization
137 void BuildWCSMeshes(std::vector<aiMesh*>& out, aiMesh** in,
138 unsigned int numIn, aiNode* node);
140 // -------------------------------------------------------------------
141 // Apply the node transformation to a mesh
142 void ApplyTransform(aiMesh* mesh, const aiMatrix4x4& mat);
144 // -------------------------------------------------------------------
145 // Reset transformation matrices to identity
146 void MakeIdentityTransform(aiNode* nd);
148 // -------------------------------------------------------------------
149 // Build reference counters for all meshes
150 void BuildMeshRefCountArray(aiNode* nd, unsigned int * refs);
154 //! Configuration option: keep scene hierarchy as long as possible
155 bool configKeepHierarchy, configNormalize;
157 };
159 } // end of namespace Assimp
161 #endif // !!AI_GENFACENORMALPROCESS_H_INC