vrshoot
diff libs/assimp/BlenderLoader.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/BlenderLoader.h Sat Feb 01 19:58:19 2014 +0200 1.3 @@ -0,0 +1,223 @@ 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 BlenderLoader.h 1.45 + * @brief Declaration of the Blender 3D (*.blend) importer class. 1.46 + */ 1.47 +#ifndef INCLUDED_AI_BLEND_LOADER_H 1.48 +#define INCLUDED_AI_BLEND_LOADER_H 1.49 + 1.50 +#include "BaseImporter.h" 1.51 +#include "LogAux.h" 1.52 + 1.53 +namespace Assimp { 1.54 + 1.55 + // TinyFormatter.h 1.56 + namespace Formatter { 1.57 + template <typename T,typename TR, typename A> class basic_formatter; 1.58 + typedef class basic_formatter< char, std::char_traits<char>, std::allocator<char> > format; 1.59 + } 1.60 + 1.61 + // BlenderDNA.h 1.62 + namespace Blender { 1.63 + class FileDatabase; 1.64 + struct ElemBase; 1.65 + } 1.66 + 1.67 + // BlenderScene.h 1.68 + namespace Blender { 1.69 + struct Scene; 1.70 + struct Object; 1.71 + struct Mesh; 1.72 + struct Camera; 1.73 + struct Lamp; 1.74 + struct MTex; 1.75 + struct Image; 1.76 + struct Material; 1.77 + } 1.78 + 1.79 + // BlenderIntermediate.h 1.80 + namespace Blender { 1.81 + struct ConversionData; 1.82 + template <template <typename,typename> class TCLASS, typename T> struct TempArray; 1.83 + } 1.84 + 1.85 + // BlenderModifier.h 1.86 + namespace Blender { 1.87 + class BlenderModifierShowcase; 1.88 + class BlenderModifier; 1.89 + } 1.90 + 1.91 + 1.92 + 1.93 +// ------------------------------------------------------------------------------------------- 1.94 +/** Load blenders official binary format. The actual file structure (the `DNA` how they 1.95 + * call it is outsourced to BlenderDNA.cpp/BlenderDNA.h. This class only performs the 1.96 + * conversion from intermediate format to aiScene. */ 1.97 +// ------------------------------------------------------------------------------------------- 1.98 +class BlenderImporter : public BaseImporter, public LogFunctions<BlenderImporter> 1.99 +{ 1.100 +public: 1.101 + BlenderImporter(); 1.102 + ~BlenderImporter(); 1.103 + 1.104 + 1.105 +public: 1.106 + 1.107 + // -------------------- 1.108 + bool CanRead( const std::string& pFile, 1.109 + IOSystem* pIOHandler, 1.110 + bool checkSig 1.111 + ) const; 1.112 + 1.113 +protected: 1.114 + 1.115 + // -------------------- 1.116 + const aiImporterDesc* GetInfo () const; 1.117 + 1.118 + // -------------------- 1.119 + void GetExtensionList(std::set<std::string>& app); 1.120 + 1.121 + // -------------------- 1.122 + void SetupProperties(const Importer* pImp); 1.123 + 1.124 + // -------------------- 1.125 + void InternReadFile( const std::string& pFile, 1.126 + aiScene* pScene, 1.127 + IOSystem* pIOHandler 1.128 + ); 1.129 + 1.130 + // -------------------- 1.131 + void ParseBlendFile(Blender::FileDatabase& out, 1.132 + boost::shared_ptr<IOStream> stream 1.133 + ); 1.134 + 1.135 + // -------------------- 1.136 + void ExtractScene(Blender::Scene& out, 1.137 + const Blender::FileDatabase& file 1.138 + ); 1.139 + 1.140 + // -------------------- 1.141 + void ConvertBlendFile(aiScene* out, 1.142 + const Blender::Scene& in, 1.143 + const Blender::FileDatabase& file 1.144 + ); 1.145 + 1.146 +private: 1.147 + 1.148 + // -------------------- 1.149 + aiNode* ConvertNode(const Blender::Scene& in, 1.150 + const Blender::Object* obj, 1.151 + Blender::ConversionData& conv_info, 1.152 + const aiMatrix4x4& parentTransform 1.153 + ); 1.154 + 1.155 + // -------------------- 1.156 + void ConvertMesh(const Blender::Scene& in, 1.157 + const Blender::Object* obj, 1.158 + const Blender::Mesh* mesh, 1.159 + Blender::ConversionData& conv_data, 1.160 + Blender::TempArray<std::vector,aiMesh>& temp 1.161 + ); 1.162 + 1.163 + // -------------------- 1.164 + aiLight* ConvertLight(const Blender::Scene& in, 1.165 + const Blender::Object* obj, 1.166 + const Blender::Lamp* mesh, 1.167 + Blender::ConversionData& conv_data 1.168 + ); 1.169 + 1.170 + // -------------------- 1.171 + aiCamera* ConvertCamera(const Blender::Scene& in, 1.172 + const Blender::Object* obj, 1.173 + const Blender::Camera* mesh, 1.174 + Blender::ConversionData& conv_data 1.175 + ); 1.176 + 1.177 + // -------------------- 1.178 + void BuildMaterials( 1.179 + Blender::ConversionData& conv_data 1.180 + ) ; 1.181 + 1.182 + // -------------------- 1.183 + void ResolveTexture( 1.184 + aiMaterial* out, 1.185 + const Blender::Material* mat, 1.186 + const Blender::MTex* tex, 1.187 + Blender::ConversionData& conv_data 1.188 + ); 1.189 + 1.190 + // -------------------- 1.191 + void ResolveImage( 1.192 + aiMaterial* out, 1.193 + const Blender::Material* mat, 1.194 + const Blender::MTex* tex, 1.195 + const Blender::Image* img, 1.196 + Blender::ConversionData& conv_data 1.197 + ); 1.198 + 1.199 + void AddSentinelTexture( 1.200 + aiMaterial* out, 1.201 + const Blender::Material* mat, 1.202 + const Blender::MTex* tex, 1.203 + Blender::ConversionData& conv_data 1.204 + ); 1.205 + 1.206 +private: // static stuff, mostly logging and error reporting. 1.207 + 1.208 + // -------------------- 1.209 + static void CheckActualType(const Blender::ElemBase* dt, 1.210 + const char* check 1.211 + ); 1.212 + 1.213 + // -------------------- 1.214 + static void NotSupportedObjectType(const Blender::Object* obj, 1.215 + const char* type 1.216 + ); 1.217 + 1.218 + 1.219 +private: 1.220 + 1.221 + Blender::BlenderModifierShowcase* modifier_cache; 1.222 + 1.223 +}; // !class BlenderImporter 1.224 + 1.225 +} // end of namespace Assimp 1.226 +#endif // AI_UNREALIMPORTER_H_INC