vrshoot

diff 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
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/libs/assimp/Importer.h	Sat Feb 01 19:58:19 2014 +0200
     1.3 @@ -0,0 +1,204 @@
     1.4 +/*
     1.5 +Open Asset Import Library (assimp)
     1.6 +----------------------------------------------------------------------
     1.7 +
     1.8 +Copyright (c) 2006-2012, assimp team
     1.9 +All rights reserved.
    1.10 +
    1.11 +Redistribution and use of this software in source and binary forms, 
    1.12 +with or without modification, are permitted provided that the 
    1.13 +following conditions are met:
    1.14 +
    1.15 +* Redistributions of source code must retain the above
    1.16 +  copyright notice, this list of conditions and the
    1.17 +  following disclaimer.
    1.18 +
    1.19 +* Redistributions in binary form must reproduce the above
    1.20 +  copyright notice, this list of conditions and the
    1.21 +  following disclaimer in the documentation and/or other
    1.22 +  materials provided with the distribution.
    1.23 +
    1.24 +* Neither the name of the assimp team, nor the names of its
    1.25 +  contributors may be used to endorse or promote products
    1.26 +  derived from this software without specific prior
    1.27 +  written permission of the assimp team.
    1.28 +
    1.29 +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
    1.30 +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
    1.31 +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
    1.32 +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 
    1.33 +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
    1.34 +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 
    1.35 +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
    1.36 +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 
    1.37 +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 
    1.38 +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
    1.39 +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    1.40 +
    1.41 +----------------------------------------------------------------------
    1.42 +*/
    1.43 +
    1.44 +/** @file Importer.h mostly internal stuff for use by #Assimp::Importer */
    1.45 +#ifndef INCLUDED_AI_IMPORTER_H
    1.46 +#define INCLUDED_AI_IMPORTER_H
    1.47 +
    1.48 +namespace Assimp	{
    1.49 +
    1.50 +	class BaseImporter;
    1.51 +	class BaseProcess;
    1.52 +
    1.53 +	
    1.54 +//! @cond never
    1.55 +// ---------------------------------------------------------------------------
    1.56 +/** @brief Internal PIMPL implementation for Assimp::Importer
    1.57 + *
    1.58 + *  Using this idiom here allows us to drop the dependency from
    1.59 + *  std::vector and std::map in the public headers. Furthermore we are dropping
    1.60 + *  any STL interface problems caused by mismatching STL settings. All
    1.61 + *  size calculation are now done by us, not the app heap. */
    1.62 +class ImporterPimpl 
    1.63 +{
    1.64 +public:
    1.65 +
    1.66 +	// Data type to store the key hash
    1.67 +	typedef unsigned int KeyType;
    1.68 +	
    1.69 +	// typedefs for our three configuration maps.
    1.70 +	// We don't need more, so there is no need for a generic solution
    1.71 +	typedef std::map<KeyType, int> IntPropertyMap;
    1.72 +	typedef std::map<KeyType, float> FloatPropertyMap;
    1.73 +	typedef std::map<KeyType, std::string> StringPropertyMap;
    1.74 +
    1.75 +public:
    1.76 +
    1.77 +	/** IO handler to use for all file accesses. */
    1.78 +	IOSystem* mIOHandler;
    1.79 +	bool mIsDefaultHandler;
    1.80 +
    1.81 +	/** Progress handler for feedback. */
    1.82 +	ProgressHandler* mProgressHandler;
    1.83 +	bool mIsDefaultProgressHandler;
    1.84 +
    1.85 +	/** Format-specific importer worker objects - one for each format we can read.*/
    1.86 +	std::vector< BaseImporter* > mImporter;
    1.87 +
    1.88 +	/** Post processing steps we can apply at the imported data. */
    1.89 +	std::vector< BaseProcess* > mPostProcessingSteps;
    1.90 +
    1.91 +	/** The imported data, if ReadFile() was successful, NULL otherwise. */
    1.92 +	aiScene* mScene;
    1.93 +
    1.94 +	/** The error description, if there was one. */
    1.95 +	std::string mErrorString;
    1.96 +
    1.97 +	/** List of integer properties */
    1.98 +	IntPropertyMap mIntProperties;
    1.99 +
   1.100 +	/** List of floating-point properties */
   1.101 +	FloatPropertyMap mFloatProperties;
   1.102 +
   1.103 +	/** List of string properties */
   1.104 +	StringPropertyMap mStringProperties;
   1.105 +
   1.106 +	/** Used for testing - extra verbose mode causes the ValidateDataStructure-Step
   1.107 +	 *  to be executed before and after every single postprocess step */
   1.108 +	bool bExtraVerbose;
   1.109 +
   1.110 +	/** Used by post-process steps to share data */
   1.111 +	SharedPostProcessInfo* mPPShared;
   1.112 +};
   1.113 +//! @endcond
   1.114 +
   1.115 +
   1.116 +struct BatchData;
   1.117 +
   1.118 +// ---------------------------------------------------------------------------
   1.119 +/** FOR IMPORTER PLUGINS ONLY: A helper class to the pleasure of importers 
   1.120 + *  that need to load many external meshes recursively.
   1.121 + *
   1.122 + *  The class uses several threads to load these meshes (or at least it
   1.123 + *  could, this has not yet been implemented at the moment).
   1.124 + *
   1.125 + *  @note The class may not be used by more than one thread*/
   1.126 +class BatchLoader 
   1.127 +{
   1.128 +	// friend of Importer
   1.129 +
   1.130 +public:
   1.131 +
   1.132 +	//! @cond never
   1.133 +	// -------------------------------------------------------------------
   1.134 +	/** Wraps a full list of configuration properties for an importer.
   1.135 +	 *  Properties can be set using SetGenericProperty */
   1.136 +	struct PropertyMap
   1.137 +	{
   1.138 +		ImporterPimpl::IntPropertyMap     ints;
   1.139 +		ImporterPimpl::FloatPropertyMap   floats;
   1.140 +		ImporterPimpl::StringPropertyMap  strings;
   1.141 +
   1.142 +		bool operator == (const PropertyMap& prop) const {
   1.143 +			// fixme: really isocpp? gcc complains
   1.144 +			return ints == prop.ints && floats == prop.floats && strings == prop.strings; 
   1.145 +		}
   1.146 +
   1.147 +		bool empty () const {
   1.148 +			return ints.empty() && floats.empty() && strings.empty();
   1.149 +		}
   1.150 +	};
   1.151 +	//! @endcond
   1.152 +
   1.153 +public:
   1.154 +	
   1.155 +
   1.156 +	// -------------------------------------------------------------------
   1.157 +	/** Construct a batch loader from a given IO system to be used 
   1.158 +	 *  to acess external files */
   1.159 +	BatchLoader(IOSystem* pIO);
   1.160 +	~BatchLoader();
   1.161 +
   1.162 +
   1.163 +	// -------------------------------------------------------------------
   1.164 +	/** Add a new file to the list of files to be loaded.
   1.165 +	 *  @param file File to be loaded
   1.166 +	 *  @param steps Post-processing steps to be executed on the file
   1.167 +	 *  @param map Optional configuration properties
   1.168 +	 *  @return 'Load request channel' - an unique ID that can later
   1.169 +	 *    be used to access the imported file data.
   1.170 +	 *  @see GetImport */
   1.171 +	unsigned int AddLoadRequest	(
   1.172 +		const std::string& file,
   1.173 +		unsigned int steps = 0, 
   1.174 +		const PropertyMap* map = NULL
   1.175 +		);
   1.176 +
   1.177 +
   1.178 +	// -------------------------------------------------------------------
   1.179 +	/** Get an imported scene.
   1.180 +	 *  This polls the import from the internal request list.
   1.181 +	 *  If an import is requested several times, this function
   1.182 +	 *  can be called several times, too.
   1.183 +	 *
   1.184 +	 *  @param which LRWC returned by AddLoadRequest().
   1.185 +	 *  @return NULL if there is no scene with this file name
   1.186 +	 *  in the queue of the scene hasn't been loaded yet. */
   1.187 +	aiScene* GetImport(
   1.188 +		unsigned int which
   1.189 +		);
   1.190 +
   1.191 +
   1.192 +	// -------------------------------------------------------------------
   1.193 +	/** Waits until all scenes have been loaded. This returns
   1.194 +	 *  immediately if no scenes are queued.*/
   1.195 +	void LoadAll();
   1.196 +
   1.197 +private:
   1.198 +
   1.199 +	// No need to have that in the public API ...
   1.200 +	BatchData* data;
   1.201 +};
   1.202 +
   1.203 +}
   1.204 +
   1.205 +
   1.206 +
   1.207 +#endif