vrshoot

annotate libs/assimp/Importer.h @ 0:b2f14e535253

initial commit
author John Tsiombikas <nuclear@member.fsf.org>
date Sat, 01 Feb 2014 19:58:19 +0200
parents
children
rev   line source
nuclear@0 1 /*
nuclear@0 2 Open Asset Import Library (assimp)
nuclear@0 3 ----------------------------------------------------------------------
nuclear@0 4
nuclear@0 5 Copyright (c) 2006-2012, assimp team
nuclear@0 6 All rights reserved.
nuclear@0 7
nuclear@0 8 Redistribution and use of this software in source and binary forms,
nuclear@0 9 with or without modification, are permitted provided that the
nuclear@0 10 following conditions are met:
nuclear@0 11
nuclear@0 12 * Redistributions of source code must retain the above
nuclear@0 13 copyright notice, this list of conditions and the
nuclear@0 14 following disclaimer.
nuclear@0 15
nuclear@0 16 * Redistributions in binary form must reproduce the above
nuclear@0 17 copyright notice, this list of conditions and the
nuclear@0 18 following disclaimer in the documentation and/or other
nuclear@0 19 materials provided with the distribution.
nuclear@0 20
nuclear@0 21 * Neither the name of the assimp team, nor the names of its
nuclear@0 22 contributors may be used to endorse or promote products
nuclear@0 23 derived from this software without specific prior
nuclear@0 24 written permission of the assimp team.
nuclear@0 25
nuclear@0 26 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
nuclear@0 27 "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
nuclear@0 28 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
nuclear@0 29 A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
nuclear@0 30 OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
nuclear@0 31 SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
nuclear@0 32 LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
nuclear@0 33 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
nuclear@0 34 THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
nuclear@0 35 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
nuclear@0 36 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
nuclear@0 37
nuclear@0 38 ----------------------------------------------------------------------
nuclear@0 39 */
nuclear@0 40
nuclear@0 41 /** @file Importer.h mostly internal stuff for use by #Assimp::Importer */
nuclear@0 42 #ifndef INCLUDED_AI_IMPORTER_H
nuclear@0 43 #define INCLUDED_AI_IMPORTER_H
nuclear@0 44
nuclear@0 45 namespace Assimp {
nuclear@0 46
nuclear@0 47 class BaseImporter;
nuclear@0 48 class BaseProcess;
nuclear@0 49
nuclear@0 50
nuclear@0 51 //! @cond never
nuclear@0 52 // ---------------------------------------------------------------------------
nuclear@0 53 /** @brief Internal PIMPL implementation for Assimp::Importer
nuclear@0 54 *
nuclear@0 55 * Using this idiom here allows us to drop the dependency from
nuclear@0 56 * std::vector and std::map in the public headers. Furthermore we are dropping
nuclear@0 57 * any STL interface problems caused by mismatching STL settings. All
nuclear@0 58 * size calculation are now done by us, not the app heap. */
nuclear@0 59 class ImporterPimpl
nuclear@0 60 {
nuclear@0 61 public:
nuclear@0 62
nuclear@0 63 // Data type to store the key hash
nuclear@0 64 typedef unsigned int KeyType;
nuclear@0 65
nuclear@0 66 // typedefs for our three configuration maps.
nuclear@0 67 // We don't need more, so there is no need for a generic solution
nuclear@0 68 typedef std::map<KeyType, int> IntPropertyMap;
nuclear@0 69 typedef std::map<KeyType, float> FloatPropertyMap;
nuclear@0 70 typedef std::map<KeyType, std::string> StringPropertyMap;
nuclear@0 71
nuclear@0 72 public:
nuclear@0 73
nuclear@0 74 /** IO handler to use for all file accesses. */
nuclear@0 75 IOSystem* mIOHandler;
nuclear@0 76 bool mIsDefaultHandler;
nuclear@0 77
nuclear@0 78 /** Progress handler for feedback. */
nuclear@0 79 ProgressHandler* mProgressHandler;
nuclear@0 80 bool mIsDefaultProgressHandler;
nuclear@0 81
nuclear@0 82 /** Format-specific importer worker objects - one for each format we can read.*/
nuclear@0 83 std::vector< BaseImporter* > mImporter;
nuclear@0 84
nuclear@0 85 /** Post processing steps we can apply at the imported data. */
nuclear@0 86 std::vector< BaseProcess* > mPostProcessingSteps;
nuclear@0 87
nuclear@0 88 /** The imported data, if ReadFile() was successful, NULL otherwise. */
nuclear@0 89 aiScene* mScene;
nuclear@0 90
nuclear@0 91 /** The error description, if there was one. */
nuclear@0 92 std::string mErrorString;
nuclear@0 93
nuclear@0 94 /** List of integer properties */
nuclear@0 95 IntPropertyMap mIntProperties;
nuclear@0 96
nuclear@0 97 /** List of floating-point properties */
nuclear@0 98 FloatPropertyMap mFloatProperties;
nuclear@0 99
nuclear@0 100 /** List of string properties */
nuclear@0 101 StringPropertyMap mStringProperties;
nuclear@0 102
nuclear@0 103 /** Used for testing - extra verbose mode causes the ValidateDataStructure-Step
nuclear@0 104 * to be executed before and after every single postprocess step */
nuclear@0 105 bool bExtraVerbose;
nuclear@0 106
nuclear@0 107 /** Used by post-process steps to share data */
nuclear@0 108 SharedPostProcessInfo* mPPShared;
nuclear@0 109 };
nuclear@0 110 //! @endcond
nuclear@0 111
nuclear@0 112
nuclear@0 113 struct BatchData;
nuclear@0 114
nuclear@0 115 // ---------------------------------------------------------------------------
nuclear@0 116 /** FOR IMPORTER PLUGINS ONLY: A helper class to the pleasure of importers
nuclear@0 117 * that need to load many external meshes recursively.
nuclear@0 118 *
nuclear@0 119 * The class uses several threads to load these meshes (or at least it
nuclear@0 120 * could, this has not yet been implemented at the moment).
nuclear@0 121 *
nuclear@0 122 * @note The class may not be used by more than one thread*/
nuclear@0 123 class BatchLoader
nuclear@0 124 {
nuclear@0 125 // friend of Importer
nuclear@0 126
nuclear@0 127 public:
nuclear@0 128
nuclear@0 129 //! @cond never
nuclear@0 130 // -------------------------------------------------------------------
nuclear@0 131 /** Wraps a full list of configuration properties for an importer.
nuclear@0 132 * Properties can be set using SetGenericProperty */
nuclear@0 133 struct PropertyMap
nuclear@0 134 {
nuclear@0 135 ImporterPimpl::IntPropertyMap ints;
nuclear@0 136 ImporterPimpl::FloatPropertyMap floats;
nuclear@0 137 ImporterPimpl::StringPropertyMap strings;
nuclear@0 138
nuclear@0 139 bool operator == (const PropertyMap& prop) const {
nuclear@0 140 // fixme: really isocpp? gcc complains
nuclear@0 141 return ints == prop.ints && floats == prop.floats && strings == prop.strings;
nuclear@0 142 }
nuclear@0 143
nuclear@0 144 bool empty () const {
nuclear@0 145 return ints.empty() && floats.empty() && strings.empty();
nuclear@0 146 }
nuclear@0 147 };
nuclear@0 148 //! @endcond
nuclear@0 149
nuclear@0 150 public:
nuclear@0 151
nuclear@0 152
nuclear@0 153 // -------------------------------------------------------------------
nuclear@0 154 /** Construct a batch loader from a given IO system to be used
nuclear@0 155 * to acess external files */
nuclear@0 156 BatchLoader(IOSystem* pIO);
nuclear@0 157 ~BatchLoader();
nuclear@0 158
nuclear@0 159
nuclear@0 160 // -------------------------------------------------------------------
nuclear@0 161 /** Add a new file to the list of files to be loaded.
nuclear@0 162 * @param file File to be loaded
nuclear@0 163 * @param steps Post-processing steps to be executed on the file
nuclear@0 164 * @param map Optional configuration properties
nuclear@0 165 * @return 'Load request channel' - an unique ID that can later
nuclear@0 166 * be used to access the imported file data.
nuclear@0 167 * @see GetImport */
nuclear@0 168 unsigned int AddLoadRequest (
nuclear@0 169 const std::string& file,
nuclear@0 170 unsigned int steps = 0,
nuclear@0 171 const PropertyMap* map = NULL
nuclear@0 172 );
nuclear@0 173
nuclear@0 174
nuclear@0 175 // -------------------------------------------------------------------
nuclear@0 176 /** Get an imported scene.
nuclear@0 177 * This polls the import from the internal request list.
nuclear@0 178 * If an import is requested several times, this function
nuclear@0 179 * can be called several times, too.
nuclear@0 180 *
nuclear@0 181 * @param which LRWC returned by AddLoadRequest().
nuclear@0 182 * @return NULL if there is no scene with this file name
nuclear@0 183 * in the queue of the scene hasn't been loaded yet. */
nuclear@0 184 aiScene* GetImport(
nuclear@0 185 unsigned int which
nuclear@0 186 );
nuclear@0 187
nuclear@0 188
nuclear@0 189 // -------------------------------------------------------------------
nuclear@0 190 /** Waits until all scenes have been loaded. This returns
nuclear@0 191 * immediately if no scenes are queued.*/
nuclear@0 192 void LoadAll();
nuclear@0 193
nuclear@0 194 private:
nuclear@0 195
nuclear@0 196 // No need to have that in the public API ...
nuclear@0 197 BatchData* data;
nuclear@0 198 };
nuclear@0 199
nuclear@0 200 }
nuclear@0 201
nuclear@0 202
nuclear@0 203
nuclear@0 204 #endif