vrshoot
view libs/assimp/BlenderIntermediate.h @ 1:e7ca128b8713
looks nice :)
author | John Tsiombikas <nuclear@member.fsf.org> |
---|---|
date | Sun, 02 Feb 2014 00:35:22 +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 BlenderIntermediate.h
42 * @brief Internal utility structures for the BlenderLoader. It also serves
43 * as master include file for the whole (internal) Blender subsystem.
44 */
45 #ifndef INCLUDED_AI_BLEND_INTERMEDIATE_H
46 #define INCLUDED_AI_BLEND_INTERMEDIATE_H
48 #include "BlenderLoader.h"
49 #include "BlenderDNA.h"
50 #include "BlenderScene.h"
51 #include "BlenderSceneGen.h"
53 #define for_each(x,y) BOOST_FOREACH(x,y)
55 namespace Assimp {
56 namespace Blender {
58 // --------------------------------------------------------------------
59 /** Mini smart-array to avoid pulling in even more boost stuff. usable with vector and deque */
60 // --------------------------------------------------------------------
61 template <template <typename,typename> class TCLASS, typename T>
62 struct TempArray {
63 typedef TCLASS< T*,std::allocator<T*> > mywrap;
65 TempArray() {
66 }
68 ~TempArray () {
69 for_each(T* elem, arr) {
70 delete elem;
71 }
72 }
74 void dismiss() {
75 arr.clear();
76 }
78 mywrap* operator -> () {
79 return &arr;
80 }
82 operator mywrap& () {
83 return arr;
84 }
86 operator const mywrap& () const {
87 return arr;
88 }
90 mywrap& get () {
91 return arr;
92 }
94 const mywrap& get () const {
95 return arr;
96 }
98 T* operator[] (size_t idx) const {
99 return arr[idx];
100 }
102 T*& operator[] (size_t idx) {
103 return arr[idx];
104 }
106 private:
107 // no copy semantics
108 void operator= (const TempArray&) {
109 }
111 TempArray(const TempArray& arr) {
112 }
114 private:
115 mywrap arr;
116 };
118 #ifdef _MSC_VER
119 # pragma warning(disable:4351)
120 #endif
121 // --------------------------------------------------------------------
122 /** ConversionData acts as intermediate storage location for
123 * the various ConvertXXX routines in BlenderImporter.*/
124 // --------------------------------------------------------------------
125 struct ConversionData
126 {
127 ConversionData(const FileDatabase& db)
128 : sentinel_cnt()
129 , next_texture()
130 , db(db)
131 {}
133 std::set<const Object*> objects;
135 TempArray <std::vector, aiMesh> meshes;
136 TempArray <std::vector, aiCamera> cameras;
137 TempArray <std::vector, aiLight> lights;
138 TempArray <std::vector, aiMaterial> materials;
139 TempArray <std::vector, aiTexture> textures;
141 // set of all materials referenced by at least one mesh in the scene
142 std::deque< boost::shared_ptr< Material > > materials_raw;
144 // counter to name sentinel textures inserted as substitutes for procedural textures.
145 unsigned int sentinel_cnt;
147 // next texture ID for each texture type, respectively
148 unsigned int next_texture[aiTextureType_UNKNOWN+1];
150 // original file data
151 const FileDatabase& db;
152 };
153 #ifdef _MSC_VER
154 # pragma warning(default:4351)
155 #endif
157 // ------------------------------------------------------------------------------------------------
158 inline const char* GetTextureTypeDisplayString(Tex::Type t)
159 {
160 switch (t) {
161 case Tex::Type_CLOUDS : return "Clouds";
162 case Tex::Type_WOOD : return "Wood";
163 case Tex::Type_MARBLE : return "Marble";
164 case Tex::Type_MAGIC : return "Magic";
165 case Tex::Type_BLEND : return "Blend";
166 case Tex::Type_STUCCI : return "Stucci";
167 case Tex::Type_NOISE : return "Noise";
168 case Tex::Type_PLUGIN : return "Plugin";
169 case Tex::Type_MUSGRAVE : return "Musgrave";
170 case Tex::Type_VORONOI : return "Voronoi";
171 case Tex::Type_DISTNOISE : return "DistortedNoise";
172 case Tex::Type_ENVMAP : return "EnvMap";
173 case Tex::Type_IMAGE : return "Image";
174 default:
175 break;
176 }
177 return "<Unknown>";
178 }
180 } // ! Blender
181 } // ! Assimp
183 #endif // ! INCLUDED_AI_BLEND_INTERMEDIATE_H