vrshoot
view libs/assimp/Importer.h @ 1:e7ca128b8713
looks nice :)
author | John Tsiombikas <nuclear@member.fsf.org> |
---|---|
date | Sun, 02 Feb 2014 00:35:22 +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 Importer.h mostly internal stuff for use by #Assimp::Importer */
42 #ifndef INCLUDED_AI_IMPORTER_H
43 #define INCLUDED_AI_IMPORTER_H
45 namespace Assimp {
47 class BaseImporter;
48 class BaseProcess;
51 //! @cond never
52 // ---------------------------------------------------------------------------
53 /** @brief Internal PIMPL implementation for Assimp::Importer
54 *
55 * Using this idiom here allows us to drop the dependency from
56 * std::vector and std::map in the public headers. Furthermore we are dropping
57 * any STL interface problems caused by mismatching STL settings. All
58 * size calculation are now done by us, not the app heap. */
59 class ImporterPimpl
60 {
61 public:
63 // Data type to store the key hash
64 typedef unsigned int KeyType;
66 // typedefs for our three configuration maps.
67 // We don't need more, so there is no need for a generic solution
68 typedef std::map<KeyType, int> IntPropertyMap;
69 typedef std::map<KeyType, float> FloatPropertyMap;
70 typedef std::map<KeyType, std::string> StringPropertyMap;
72 public:
74 /** IO handler to use for all file accesses. */
75 IOSystem* mIOHandler;
76 bool mIsDefaultHandler;
78 /** Progress handler for feedback. */
79 ProgressHandler* mProgressHandler;
80 bool mIsDefaultProgressHandler;
82 /** Format-specific importer worker objects - one for each format we can read.*/
83 std::vector< BaseImporter* > mImporter;
85 /** Post processing steps we can apply at the imported data. */
86 std::vector< BaseProcess* > mPostProcessingSteps;
88 /** The imported data, if ReadFile() was successful, NULL otherwise. */
89 aiScene* mScene;
91 /** The error description, if there was one. */
92 std::string mErrorString;
94 /** List of integer properties */
95 IntPropertyMap mIntProperties;
97 /** List of floating-point properties */
98 FloatPropertyMap mFloatProperties;
100 /** List of string properties */
101 StringPropertyMap mStringProperties;
103 /** Used for testing - extra verbose mode causes the ValidateDataStructure-Step
104 * to be executed before and after every single postprocess step */
105 bool bExtraVerbose;
107 /** Used by post-process steps to share data */
108 SharedPostProcessInfo* mPPShared;
109 };
110 //! @endcond
113 struct BatchData;
115 // ---------------------------------------------------------------------------
116 /** FOR IMPORTER PLUGINS ONLY: A helper class to the pleasure of importers
117 * that need to load many external meshes recursively.
118 *
119 * The class uses several threads to load these meshes (or at least it
120 * could, this has not yet been implemented at the moment).
121 *
122 * @note The class may not be used by more than one thread*/
123 class BatchLoader
124 {
125 // friend of Importer
127 public:
129 //! @cond never
130 // -------------------------------------------------------------------
131 /** Wraps a full list of configuration properties for an importer.
132 * Properties can be set using SetGenericProperty */
133 struct PropertyMap
134 {
135 ImporterPimpl::IntPropertyMap ints;
136 ImporterPimpl::FloatPropertyMap floats;
137 ImporterPimpl::StringPropertyMap strings;
139 bool operator == (const PropertyMap& prop) const {
140 // fixme: really isocpp? gcc complains
141 return ints == prop.ints && floats == prop.floats && strings == prop.strings;
142 }
144 bool empty () const {
145 return ints.empty() && floats.empty() && strings.empty();
146 }
147 };
148 //! @endcond
150 public:
153 // -------------------------------------------------------------------
154 /** Construct a batch loader from a given IO system to be used
155 * to acess external files */
156 BatchLoader(IOSystem* pIO);
157 ~BatchLoader();
160 // -------------------------------------------------------------------
161 /** Add a new file to the list of files to be loaded.
162 * @param file File to be loaded
163 * @param steps Post-processing steps to be executed on the file
164 * @param map Optional configuration properties
165 * @return 'Load request channel' - an unique ID that can later
166 * be used to access the imported file data.
167 * @see GetImport */
168 unsigned int AddLoadRequest (
169 const std::string& file,
170 unsigned int steps = 0,
171 const PropertyMap* map = NULL
172 );
175 // -------------------------------------------------------------------
176 /** Get an imported scene.
177 * This polls the import from the internal request list.
178 * If an import is requested several times, this function
179 * can be called several times, too.
180 *
181 * @param which LRWC returned by AddLoadRequest().
182 * @return NULL if there is no scene with this file name
183 * in the queue of the scene hasn't been loaded yet. */
184 aiScene* GetImport(
185 unsigned int which
186 );
189 // -------------------------------------------------------------------
190 /** Waits until all scenes have been loaded. This returns
191 * immediately if no scenes are queued.*/
192 void LoadAll();
194 private:
196 // No need to have that in the public API ...
197 BatchData* data;
198 };
200 }
204 #endif