vrshoot

view libs/assimp/XFileImporter.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 XFileImporter.h
42 * @brief Definition of the XFile importer class.
43 */
44 #ifndef AI_XFILEIMPORTER_H_INC
45 #define AI_XFILEIMPORTER_H_INC
47 #include <map>
49 #include "XFileHelper.h"
50 #include "BaseImporter.h"
52 #include "assimp/types.h"
54 struct aiNode;
56 namespace Assimp {
58 namespace XFile {
59 struct Scene;
60 struct Node;
61 }
63 // ---------------------------------------------------------------------------
64 /** The XFileImporter is a worker class capable of importing a scene from a
65 * DirectX file .x
66 */
67 class XFileImporter : public BaseImporter
68 {
69 public:
70 XFileImporter();
71 ~XFileImporter();
74 public:
75 // -------------------------------------------------------------------
76 /** Returns whether the class can handle the format of the given file.
77 * See BaseImporter::CanRead() for details. */
78 bool CanRead( const std::string& pFile, IOSystem* pIOHandler,
79 bool CheckSig) const;
81 protected:
83 // -------------------------------------------------------------------
84 /** Return importer meta information.
85 * See #BaseImporter::GetInfo for the details
86 */
87 const aiImporterDesc* GetInfo () const;
89 // -------------------------------------------------------------------
90 /** Imports the given file into the given scene structure.
91 * See BaseImporter::InternReadFile() for details
92 */
93 void InternReadFile( const std::string& pFile, aiScene* pScene,
94 IOSystem* pIOHandler);
96 // -------------------------------------------------------------------
97 /** Constructs the return data structure out of the imported data.
98 * @param pScene The scene to construct the return data in.
99 * @param pData The imported data in the internal temporary
100 * representation.
101 */
102 void CreateDataRepresentationFromImport( aiScene* pScene, XFile::Scene* pData);
104 // -------------------------------------------------------------------
105 /** Recursively creates scene nodes from the imported hierarchy.
106 * The meshes and materials of the nodes will be extracted on the way.
107 * @param pScene The scene to construct the return data in.
108 * @param pParent The parent node where to create new child nodes
109 * @param pNode The temporary node to copy.
110 * @return The created node
111 */
112 aiNode* CreateNodes( aiScene* pScene, aiNode* pParent,
113 const XFile::Node* pNode);
115 // -------------------------------------------------------------------
116 /** Converts all meshes in the given mesh array. Each mesh is split
117 * up per material, the indices of the generated meshes are stored in
118 * the node structure.
119 * @param pScene The scene to construct the return data in.
120 * @param pNode The target node structure that references the
121 * constructed meshes.
122 * @param pMeshes The array of meshes to convert
123 */
124 void CreateMeshes( aiScene* pScene, aiNode* pNode,
125 const std::vector<XFile::Mesh*>& pMeshes);
127 // -------------------------------------------------------------------
128 /** Converts the animations from the given imported data and creates
129 * them in the scene.
130 * @param pScene The scene to hold to converted animations
131 * @param pData The data to read the animations from
132 */
133 void CreateAnimations( aiScene* pScene, const XFile::Scene* pData);
135 // -------------------------------------------------------------------
136 /** Converts all materials in the given array and stores them in the
137 * scene's material list.
138 * @param pScene The scene to hold the converted materials.
139 * @param pMaterials The material array to convert.
140 */
141 void ConvertMaterials( aiScene* pScene, std::vector<XFile::Material>& pMaterials);
143 protected:
144 /** Buffer to hold the loaded file */
145 std::vector<char> mBuffer;
146 };
148 } // end of namespace Assimp
150 #endif // AI_BASEIMPORTER_H_INC