vrshoot

diff libs/assimp/BlenderIntermediate.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/BlenderIntermediate.h	Sat Feb 01 19:58:19 2014 +0200
     1.3 @@ -0,0 +1,183 @@
     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  BlenderIntermediate.h
    1.45 + *  @brief Internal utility structures for the BlenderLoader. It also serves
    1.46 + *    as master include file for the whole (internal) Blender subsystem.
    1.47 + */
    1.48 +#ifndef INCLUDED_AI_BLEND_INTERMEDIATE_H
    1.49 +#define INCLUDED_AI_BLEND_INTERMEDIATE_H
    1.50 +
    1.51 +#include "BlenderLoader.h"
    1.52 +#include "BlenderDNA.h"
    1.53 +#include "BlenderScene.h"
    1.54 +#include "BlenderSceneGen.h"
    1.55 +
    1.56 +#define for_each(x,y) BOOST_FOREACH(x,y)
    1.57 +
    1.58 +namespace Assimp {
    1.59 +namespace Blender {
    1.60 +
    1.61 +	// --------------------------------------------------------------------
    1.62 +	/** Mini smart-array to avoid pulling in even more boost stuff. usable with vector and deque */
    1.63 +	// --------------------------------------------------------------------
    1.64 +	template <template <typename,typename> class TCLASS, typename T>
    1.65 +	struct TempArray	{
    1.66 +		typedef TCLASS< T*,std::allocator<T*> > mywrap;
    1.67 +
    1.68 +		TempArray() {
    1.69 +		}
    1.70 +
    1.71 +		~TempArray () {
    1.72 +			for_each(T* elem, arr) {
    1.73 +				delete elem;
    1.74 +			}
    1.75 +		}
    1.76 +
    1.77 +		void dismiss() {
    1.78 +			arr.clear();
    1.79 +		}
    1.80 +
    1.81 +		mywrap* operator -> () {
    1.82 +			return &arr;
    1.83 +		}
    1.84 +
    1.85 +		operator mywrap& () {
    1.86 +			return arr;
    1.87 +		}
    1.88 +
    1.89 +		operator const mywrap& () const {
    1.90 +			return arr;
    1.91 +		}
    1.92 +
    1.93 +		mywrap& get () {
    1.94 +			return arr;
    1.95 +		}
    1.96 +
    1.97 +		const mywrap& get () const {
    1.98 +			return arr;
    1.99 +		}
   1.100 +
   1.101 +		T* operator[] (size_t idx) const {
   1.102 +			return arr[idx];
   1.103 +		}
   1.104 +
   1.105 +		T*& operator[] (size_t idx) {
   1.106 +			return arr[idx];
   1.107 +		}
   1.108 +
   1.109 +	private:
   1.110 +		// no copy semantics
   1.111 +		void operator= (const TempArray&)  {
   1.112 +		}
   1.113 +
   1.114 +		TempArray(const TempArray& arr) {
   1.115 +		}
   1.116 +
   1.117 +	private:
   1.118 +		mywrap arr;
   1.119 +	};
   1.120 +	
   1.121 +#ifdef _MSC_VER
   1.122 +#	pragma warning(disable:4351)
   1.123 +#endif
   1.124 +	// --------------------------------------------------------------------
   1.125 +	/** ConversionData acts as intermediate storage location for
   1.126 +	 *  the various ConvertXXX routines in BlenderImporter.*/
   1.127 +	// --------------------------------------------------------------------
   1.128 +	struct ConversionData	
   1.129 +	{
   1.130 +		ConversionData(const FileDatabase& db)
   1.131 +			: sentinel_cnt()
   1.132 +			, next_texture()
   1.133 +			, db(db)
   1.134 +		{}
   1.135 +
   1.136 +		std::set<const Object*> objects;
   1.137 +
   1.138 +		TempArray <std::vector, aiMesh> meshes;
   1.139 +		TempArray <std::vector, aiCamera> cameras;
   1.140 +		TempArray <std::vector, aiLight> lights;
   1.141 +		TempArray <std::vector, aiMaterial> materials;
   1.142 +		TempArray <std::vector, aiTexture> textures;
   1.143 +
   1.144 +		// set of all materials referenced by at least one mesh in the scene
   1.145 +		std::deque< boost::shared_ptr< Material > > materials_raw;
   1.146 +
   1.147 +		// counter to name sentinel textures inserted as substitutes for procedural textures.
   1.148 +		unsigned int sentinel_cnt;
   1.149 +
   1.150 +		// next texture ID for each texture type, respectively
   1.151 +		unsigned int next_texture[aiTextureType_UNKNOWN+1];
   1.152 +
   1.153 +		// original file data
   1.154 +		const FileDatabase& db;
   1.155 +	};
   1.156 +#ifdef _MSC_VER
   1.157 +#	pragma warning(default:4351)
   1.158 +#endif
   1.159 +
   1.160 +// ------------------------------------------------------------------------------------------------
   1.161 +inline const char* GetTextureTypeDisplayString(Tex::Type t)
   1.162 +{
   1.163 +	switch (t)	{
   1.164 +	case Tex::Type_CLOUDS		:  return  "Clouds";			
   1.165 +	case Tex::Type_WOOD			:  return  "Wood";			
   1.166 +	case Tex::Type_MARBLE		:  return  "Marble";			
   1.167 +	case Tex::Type_MAGIC		:  return  "Magic";		
   1.168 +	case Tex::Type_BLEND		:  return  "Blend";			
   1.169 +	case Tex::Type_STUCCI		:  return  "Stucci";			
   1.170 +	case Tex::Type_NOISE		:  return  "Noise";			
   1.171 +	case Tex::Type_PLUGIN		:  return  "Plugin";			
   1.172 +	case Tex::Type_MUSGRAVE		:  return  "Musgrave";		
   1.173 +	case Tex::Type_VORONOI		:  return  "Voronoi";			
   1.174 +	case Tex::Type_DISTNOISE	:  return  "DistortedNoise";	
   1.175 +	case Tex::Type_ENVMAP		:  return  "EnvMap";	
   1.176 +	case Tex::Type_IMAGE		:  return  "Image";	
   1.177 +	default: 
   1.178 +		break;
   1.179 +	}
   1.180 +	return "<Unknown>";
   1.181 +}
   1.182 +
   1.183 +} // ! Blender
   1.184 +} // ! Assimp
   1.185 +
   1.186 +#endif // ! INCLUDED_AI_BLEND_INTERMEDIATE_H