vrshoot

view 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 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 BlenderLoader.h
42 * @brief Declaration of the Blender 3D (*.blend) importer class.
43 */
44 #ifndef INCLUDED_AI_BLEND_LOADER_H
45 #define INCLUDED_AI_BLEND_LOADER_H
47 #include "BaseImporter.h"
48 #include "LogAux.h"
50 namespace Assimp {
52 // TinyFormatter.h
53 namespace Formatter {
54 template <typename T,typename TR, typename A> class basic_formatter;
55 typedef class basic_formatter< char, std::char_traits<char>, std::allocator<char> > format;
56 }
58 // BlenderDNA.h
59 namespace Blender {
60 class FileDatabase;
61 struct ElemBase;
62 }
64 // BlenderScene.h
65 namespace Blender {
66 struct Scene;
67 struct Object;
68 struct Mesh;
69 struct Camera;
70 struct Lamp;
71 struct MTex;
72 struct Image;
73 struct Material;
74 }
76 // BlenderIntermediate.h
77 namespace Blender {
78 struct ConversionData;
79 template <template <typename,typename> class TCLASS, typename T> struct TempArray;
80 }
82 // BlenderModifier.h
83 namespace Blender {
84 class BlenderModifierShowcase;
85 class BlenderModifier;
86 }
90 // -------------------------------------------------------------------------------------------
91 /** Load blenders official binary format. The actual file structure (the `DNA` how they
92 * call it is outsourced to BlenderDNA.cpp/BlenderDNA.h. This class only performs the
93 * conversion from intermediate format to aiScene. */
94 // -------------------------------------------------------------------------------------------
95 class BlenderImporter : public BaseImporter, public LogFunctions<BlenderImporter>
96 {
97 public:
98 BlenderImporter();
99 ~BlenderImporter();
102 public:
104 // --------------------
105 bool CanRead( const std::string& pFile,
106 IOSystem* pIOHandler,
107 bool checkSig
108 ) const;
110 protected:
112 // --------------------
113 const aiImporterDesc* GetInfo () const;
115 // --------------------
116 void GetExtensionList(std::set<std::string>& app);
118 // --------------------
119 void SetupProperties(const Importer* pImp);
121 // --------------------
122 void InternReadFile( const std::string& pFile,
123 aiScene* pScene,
124 IOSystem* pIOHandler
125 );
127 // --------------------
128 void ParseBlendFile(Blender::FileDatabase& out,
129 boost::shared_ptr<IOStream> stream
130 );
132 // --------------------
133 void ExtractScene(Blender::Scene& out,
134 const Blender::FileDatabase& file
135 );
137 // --------------------
138 void ConvertBlendFile(aiScene* out,
139 const Blender::Scene& in,
140 const Blender::FileDatabase& file
141 );
143 private:
145 // --------------------
146 aiNode* ConvertNode(const Blender::Scene& in,
147 const Blender::Object* obj,
148 Blender::ConversionData& conv_info,
149 const aiMatrix4x4& parentTransform
150 );
152 // --------------------
153 void ConvertMesh(const Blender::Scene& in,
154 const Blender::Object* obj,
155 const Blender::Mesh* mesh,
156 Blender::ConversionData& conv_data,
157 Blender::TempArray<std::vector,aiMesh>& temp
158 );
160 // --------------------
161 aiLight* ConvertLight(const Blender::Scene& in,
162 const Blender::Object* obj,
163 const Blender::Lamp* mesh,
164 Blender::ConversionData& conv_data
165 );
167 // --------------------
168 aiCamera* ConvertCamera(const Blender::Scene& in,
169 const Blender::Object* obj,
170 const Blender::Camera* mesh,
171 Blender::ConversionData& conv_data
172 );
174 // --------------------
175 void BuildMaterials(
176 Blender::ConversionData& conv_data
177 ) ;
179 // --------------------
180 void ResolveTexture(
181 aiMaterial* out,
182 const Blender::Material* mat,
183 const Blender::MTex* tex,
184 Blender::ConversionData& conv_data
185 );
187 // --------------------
188 void ResolveImage(
189 aiMaterial* out,
190 const Blender::Material* mat,
191 const Blender::MTex* tex,
192 const Blender::Image* img,
193 Blender::ConversionData& conv_data
194 );
196 void AddSentinelTexture(
197 aiMaterial* out,
198 const Blender::Material* mat,
199 const Blender::MTex* tex,
200 Blender::ConversionData& conv_data
201 );
203 private: // static stuff, mostly logging and error reporting.
205 // --------------------
206 static void CheckActualType(const Blender::ElemBase* dt,
207 const char* check
208 );
210 // --------------------
211 static void NotSupportedObjectType(const Blender::Object* obj,
212 const char* type
213 );
216 private:
218 Blender::BlenderModifierShowcase* modifier_cache;
220 }; // !class BlenderImporter
222 } // end of namespace Assimp
223 #endif // AI_UNREALIMPORTER_H_INC