aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/src/others/irrlicht-1.8.1/include/IColladaMeshWriter.h
diff options
context:
space:
mode:
authorDavid Walter Seikel2016-03-28 22:28:34 +1000
committerDavid Walter Seikel2016-03-28 22:28:34 +1000
commit7028cbe09c688437910a25623098762bf0fa592d (patch)
tree10b5af58277d9880380c2251f109325542c4e6eb /src/others/irrlicht-1.8.1/include/IColladaMeshWriter.h
parentMove lemon to the src/others directory. (diff)
downloadSledjHamr-7028cbe09c688437910a25623098762bf0fa592d.zip
SledjHamr-7028cbe09c688437910a25623098762bf0fa592d.tar.gz
SledjHamr-7028cbe09c688437910a25623098762bf0fa592d.tar.bz2
SledjHamr-7028cbe09c688437910a25623098762bf0fa592d.tar.xz
Move Irrlicht to src/others.
Diffstat (limited to 'src/others/irrlicht-1.8.1/include/IColladaMeshWriter.h')
-rw-r--r--src/others/irrlicht-1.8.1/include/IColladaMeshWriter.h405
1 files changed, 405 insertions, 0 deletions
diff --git a/src/others/irrlicht-1.8.1/include/IColladaMeshWriter.h b/src/others/irrlicht-1.8.1/include/IColladaMeshWriter.h
new file mode 100644
index 0000000..e3f48a7
--- /dev/null
+++ b/src/others/irrlicht-1.8.1/include/IColladaMeshWriter.h
@@ -0,0 +1,405 @@
1// Copyright (C) 2002-2012 Nikolaus Gebhardt
2// This file is part of the "Irrlicht Engine".
3// For conditions of distribution and use, see copyright notice in irrlicht.h
4
5#ifndef __IRR_I_COLLADA_MESH_WRITER_H_INCLUDED__
6#define __IRR_I_COLLADA_MESH_WRITER_H_INCLUDED__
7
8#include "IMeshWriter.h"
9#include "ISceneNode.h"
10#include "IAnimatedMesh.h"
11#include "SMaterial.h"
12
13namespace irr
14{
15namespace io
16{
17 class IWriteFile;
18} // end namespace io
19
20namespace scene
21{
22 //! Lighting models - more or less the way Collada categorizes materials
23 enum E_COLLADA_TECHNIQUE_FX
24 {
25 //! Blinn-phong which is default for opengl and dx fixed function pipelines.
26 //! But several well-known renderers don't support it and prefer phong.
27 ECTF_BLINN,
28 //! Phong shading, default in many external renderers.
29 ECTF_PHONG,
30 //! diffuse shaded surface that is independent of lighting.
31 ECTF_LAMBERT,
32 // constantly shaded surface that is independent of lighting.
33 ECTF_CONSTANT
34 };
35
36 //! How to interpret the opacity in collada
37 enum E_COLLADA_TRANSPARENT_FX
38 {
39 //! default - only alpha channel of color or texture is used.
40 ECOF_A_ONE = 0,
41
42 //! Alpha values for each RGB channel of color or texture are used.
43 ECOF_RGB_ZERO = 1
44 };
45
46 //! Color names collada uses in it's color samplers
47 enum E_COLLADA_COLOR_SAMPLER
48 {
49 ECCS_DIFFUSE,
50 ECCS_AMBIENT,
51 ECCS_EMISSIVE,
52 ECCS_SPECULAR,
53 ECCS_TRANSPARENT,
54 ECCS_REFLECTIVE
55 };
56
57 //! Irrlicht colors which can be mapped to E_COLLADA_COLOR_SAMPLER values
58 enum E_COLLADA_IRR_COLOR
59 {
60 //! Don't write this element at all
61 ECIC_NONE,
62
63 //! Check IColladaMeshWriterProperties for custom color
64 ECIC_CUSTOM,
65
66 //! Use SMaterial::DiffuseColor
67 ECIC_DIFFUSE,
68
69 //! Use SMaterial::AmbientColor
70 ECIC_AMBIENT,
71
72 //! Use SMaterial::EmissiveColor
73 ECIC_EMISSIVE,
74
75 //! Use SMaterial::SpecularColor
76 ECIC_SPECULAR
77 };
78
79 //! Control when geometry elements are created
80 enum E_COLLADA_GEOMETRY_WRITING
81 {
82 //! Default - write each mesh exactly once to collada. Optimal but will not work with many tools.
83 ECGI_PER_MESH,
84
85 //! Write each mesh as often as it's used with different materials-names in the scene.
86 //! Material names which are used here are created on export, so using the IColladaMeshWriterNames
87 //! interface you have some control over how many geometries are written.
88 ECGI_PER_MESH_AND_MATERIAL
89 };
90
91 //! Callback interface for properties which can be used to influence collada writing
92 class IColladaMeshWriterProperties : public virtual IReferenceCounted
93 {
94 public:
95 virtual ~IColladaMeshWriterProperties () {}
96
97 //! Which lighting model should be used in the technique (FX) section when exporting effects (materials)
98 virtual E_COLLADA_TECHNIQUE_FX getTechniqueFx(const video::SMaterial& material) const = 0;
99
100 //! Which texture index should be used when writing the texture of the given sampler color.
101 /** \return the index to the texture-layer or -1 if that texture should never be exported
102 Note: for ECCS_TRANSPARENT by default the alpha channel is used, if you want to use RGB you have to set
103 also the ECOF_RGB_ZERO flag in getTransparentFx. */
104 virtual s32 getTextureIdx(const video::SMaterial & material, E_COLLADA_COLOR_SAMPLER cs) const = 0;
105
106 //! Return which color from Irrlicht should be used for the color requested by collada
107 /** Note that collada allows exporting either texture or color, not both.
108 So color mapping is only checked if we have no valid texture already.
109 By default we try to return best fits when possible. For example ECCS_DIFFUSE is mapped to ECIC_DIFFUSE.
110 When ECIC_CUSTOM is returned then the result of getCustomColor will be used. */
111 virtual E_COLLADA_IRR_COLOR getColorMapping(const video::SMaterial & material, E_COLLADA_COLOR_SAMPLER cs) const = 0;
112
113 //! Return custom colors for certain color types requested by collada.
114 /** Only used when getColorMapping returns ECIC_CUSTOM for the same paramters. */
115 virtual video::SColor getCustomColor(const video::SMaterial & material, E_COLLADA_COLOR_SAMPLER cs) const = 0;
116
117 //! Return the transparence color interpretation.
118 /** Not this is only about ECCS_TRANSPARENT and does not affect getTransparency. */
119 virtual E_COLLADA_TRANSPARENT_FX getTransparentFx(const video::SMaterial& material) const = 0;
120
121 //! Transparency value for that material.
122 /** This value is additional to transparent settings, if both are set they will be multiplicated.
123 \return 1.0 for fully transparent, 0.0 for not transparent and not written at all when < 0.f */
124 virtual f32 getTransparency(const video::SMaterial& material) const = 0;
125
126 //! Reflectivity value for that material
127 /** The amount of perfect mirror reflection to be added to the reflected light
128 \return 0.0 - 1.0 for reflectivity and element is not written at all when < 0.f */
129 virtual f32 getReflectivity(const video::SMaterial& material) const = 0;
130
131 //! Return index of refraction for that material
132 /** By default we don't write that.
133 \return a value greater equal 0.f to write \<index_of_refraction\> when it is lesser than 0 nothing will be written */
134 virtual f32 getIndexOfRefraction(const video::SMaterial& material) const = 0;
135
136 //! Should node be used in scene export? (only needed for scene-writing, ignored in mesh-writing)
137 //! By default all visible nodes are exported.
138 virtual bool isExportable(const irr::scene::ISceneNode * node) const = 0;
139
140 //! Return the mesh for the given node. If it has no mesh or shouldn't export it's mesh
141 //! you can return 0 in which case only the transformation matrix of the node will be used.
142 // Note: Function is not const because there is no const getMesh() function.
143 virtual IMesh* getMesh(irr::scene::ISceneNode * node) = 0;
144
145 //! Return if the node has it's own material overwriting the mesh-materials
146 /** Usually true except for mesh-nodes which have isReadOnlyMaterials set.
147 This is mostly important for naming (as ISceneNode::getMaterial() already returns the correct material).
148 You have to override it when exporting custom scenenodes with own materials.
149 \return true => The node's own material is used, false => ignore node material and use the one from the mesh */
150 virtual bool useNodeMaterial(const scene::ISceneNode* node) const = 0;
151
152 };
153
154 //! Callback interface to use custom names on collada writing.
155 /** You can either modify names and id's written to collada or you can use
156 this interface to just find out which names are used on writing.
157 */
158 class IColladaMeshWriterNames : public virtual IReferenceCounted
159 {
160 public:
161
162 virtual ~IColladaMeshWriterNames () {}
163
164 //! Return a unique name for the given mesh
165 /** Note that names really must be unique here per mesh-pointer, so
166 mostly it's a good idea to return the nameForMesh from
167 IColladaMeshWriter::getDefaultNameGenerator(). Also names must follow
168 the xs::NCName standard to be valid, you can run them through
169 IColladaMeshWriter::toNCName to ensure that.
170 \param mesh Pointer to the mesh which needs a name
171 \param instance When E_COLLADA_GEOMETRY_WRITING is not ECGI_PER_MESH then
172 several instances of the same mesh can be written and this counts them.
173 */
174 virtual irr::core::stringw nameForMesh(const scene::IMesh* mesh, int instance) = 0;
175
176 //! Return a unique name for the given node
177 /** Note that names really must be unique here per node-pointer, so
178 mostly it's a good idea to return the nameForNode from
179 IColladaMeshWriter::getDefaultNameGenerator(). Also names must follow
180 the xs::NCName standard to be valid, you can run them through
181 IColladaMeshWriter::toNCName to ensure that.
182 */
183 virtual irr::core::stringw nameForNode(const scene::ISceneNode* node) = 0;
184
185 //! Return a name for the material
186 /** There is one material created in the writer for each unique name.
187 So you can use this to control the number of materials which get written.
188 For example Irrlicht does by default write one material for each material
189 instanced by a node. So if you know that in your application material
190 instances per node are identical between different nodes you can reduce
191 the number of exported materials using that knowledge by using identical
192 names for such shared materials.
193 Names must follow the xs::NCName standard to be valid, you can run them
194 through IColladaMeshWriter::toNCName to ensure that.
195 */
196 virtual irr::core::stringw nameForMaterial(const video::SMaterial & material, int materialId, const scene::IMesh* mesh, const scene::ISceneNode* node) = 0;
197 };
198
199
200 //! Interface for writing meshes
201 class IColladaMeshWriter : public IMeshWriter
202 {
203 public:
204
205 IColladaMeshWriter()
206 : Properties(0), DefaultProperties(0), NameGenerator(0), DefaultNameGenerator(0)
207 , WriteTextures(true), WriteDefaultScene(true), ExportSMaterialOnce(true)
208 , AmbientLight(0.f, 0.f, 0.f, 1.f)
209 , GeometryWriting(ECGI_PER_MESH)
210 {
211 }
212
213 //! Destructor
214 virtual ~IColladaMeshWriter()
215 {
216 if ( Properties )
217 Properties->drop();
218 if ( DefaultProperties )
219 DefaultProperties->drop();
220 if ( NameGenerator )
221 NameGenerator->drop();
222 if ( DefaultNameGenerator )
223 DefaultNameGenerator->drop();
224 }
225
226 //! writes a scene starting with the given node
227 virtual bool writeScene(io::IWriteFile* file, scene::ISceneNode* root) = 0;
228
229
230 //! Set if texture information should be written
231 virtual void setWriteTextures(bool write)
232 {
233 WriteTextures = write;
234 }
235
236 //! Get if texture information should be written
237 virtual bool getWriteTextures() const
238 {
239 return WriteTextures;
240 }
241
242 //! Set if a default scene should be written when writing meshes.
243 /** Many collada readers fail to read a mesh if the collada files doesn't contain a scene as well.
244 The scene is doing an instantiation of the mesh.
245 When using writeScene this flag is ignored (as we have scene there already)
246 */
247 virtual void setWriteDefaultScene(bool write)
248 {
249 WriteDefaultScene = write;
250 }
251
252 //! Get if a default scene should be written
253 virtual bool getWriteDefaultScene() const
254 {
255 return WriteDefaultScene;
256 }
257
258 //! Sets ambient color of the scene to write
259 virtual void setAmbientLight(const video::SColorf &ambientColor)
260 {
261 AmbientLight = ambientColor;
262 }
263
264 //! Return ambient light of the scene which is written
265 virtual video::SColorf getAmbientLight() const
266 {
267 return AmbientLight;
268 }
269
270 //! Control when and how often a mesh is written
271 /** Optimally ECGI_PER_MESH would be always sufficent - writing geometry once per mesh.
272 Unfortunately many tools (at the time of writing this nearly all of them) have trouble
273 on import when different materials are used per node. So when you override materials
274 per node and importing the resuling collada has materials problems in other tools try
275 using other values here.
276 \param writeStyle One of the E_COLLADA_GEOMETRY_WRITING settings.
277 */
278 virtual void setGeometryWriting(E_COLLADA_GEOMETRY_WRITING writeStyle)
279 {
280 GeometryWriting = writeStyle;
281 }
282
283 //! Get the current style of geometry writing.
284 virtual E_COLLADA_GEOMETRY_WRITING getGeometryWriting() const
285 {
286 return GeometryWriting;
287 }
288
289 //! Make certain there is only one collada material generated per Irrlicht material
290 /** Checks before creating a collada material-name if an identical
291 irr:::video::SMaterial has been exported already. If so don't export it with
292 another name. This is set by default and leads to way smaller .dae files.
293 Note that if you need to disable this flag for some reason you can still
294 get a similar effect using the IColladaMeshWriterNames::nameForMaterial
295 by returning identical names for identical materials there.
296 */
297 virtual void setExportSMaterialsOnlyOnce(bool exportOnce)
298 {
299 ExportSMaterialOnce = exportOnce;
300 }
301
302 virtual bool getExportSMaterialsOnlyOnce() const
303 {
304 return ExportSMaterialOnce;
305 }
306
307 //! Set properties to use by the meshwriter instead of it's default properties.
308 /** Overloading properties with an own class allows modifying the writing process in certain ways.
309 By default properties are set to the DefaultProperties. */
310 virtual void setProperties(IColladaMeshWriterProperties * p)
311 {
312 if ( p == Properties )
313 return;
314 if ( p )
315 p->grab();
316 if ( Properties )
317 Properties->drop();
318 Properties = p;
319 }
320
321 //! Get properties which are currently used.
322 virtual IColladaMeshWriterProperties * getProperties() const
323 {
324 return Properties;
325 }
326
327 //! Return the original default properties of the writer.
328 /** You can use this pointer in your own properties to access and return default values. */
329 IColladaMeshWriterProperties * getDefaultProperties() const
330 {
331 return DefaultProperties;
332 }
333
334 //! Install a generator to create custom names on export.
335 virtual void setNameGenerator(IColladaMeshWriterNames * nameGenerator)
336 {
337 if ( nameGenerator == NameGenerator )
338 return;
339 if ( nameGenerator )
340 nameGenerator->grab();
341 if ( NameGenerator )
342 NameGenerator->drop();
343 NameGenerator = nameGenerator;
344 }
345
346 //! Get currently used name generator
347 virtual IColladaMeshWriterNames * getNameGenerator() const
348 {
349 return NameGenerator;
350 }
351
352 //! Return the original default name generator of the writer.
353 /** You can use this pointer in your own generator to access and return default values. */
354 IColladaMeshWriterNames * getDefaultNameGenerator() const
355 {
356 return DefaultNameGenerator;
357 }
358
359 //! Restrict the characters of oldString a set of allowed characters in xs::NCName and add the prefix.
360 /** A tool function to help when using a custom name generator to generative valid names for collada names and id's. */
361 virtual irr::core::stringw toNCName(const irr::core::stringw& oldString, const irr::core::stringw& prefix=irr::core::stringw(L"_NC_")) const = 0;
362
363
364 protected:
365 // NOTE: You usually should also call setProperties with the same paraemter when using setDefaultProperties
366 virtual void setDefaultProperties(IColladaMeshWriterProperties * p)
367 {
368 if ( p == DefaultProperties )
369 return;
370 if ( p )
371 p->grab();
372 if ( DefaultProperties )
373 DefaultProperties->drop();
374 DefaultProperties = p;
375 }
376
377 // NOTE: You usually should also call setNameGenerator with the same paraemter when using setDefaultProperties
378 virtual void setDefaultNameGenerator(IColladaMeshWriterNames * p)
379 {
380 if ( p == DefaultNameGenerator )
381 return;
382 if ( p )
383 p->grab();
384 if ( DefaultNameGenerator )
385 DefaultNameGenerator->drop();
386 DefaultNameGenerator = p;
387 }
388
389 private:
390 IColladaMeshWriterProperties * Properties;
391 IColladaMeshWriterProperties * DefaultProperties;
392 IColladaMeshWriterNames * NameGenerator;
393 IColladaMeshWriterNames * DefaultNameGenerator;
394 bool WriteTextures;
395 bool WriteDefaultScene;
396 bool ExportSMaterialOnce;
397 video::SColorf AmbientLight;
398 E_COLLADA_GEOMETRY_WRITING GeometryWriting;
399 };
400
401
402} // end namespace
403} // end namespace
404
405#endif