aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/libraries/irrlicht-1.8/include/IColladaMeshWriter.h
diff options
context:
space:
mode:
authorDavid Walter Seikel2013-01-13 17:24:39 +1000
committerDavid Walter Seikel2013-01-13 17:24:39 +1000
commit393b5cd1dc438872af89d334ef6e5fcc59f27d47 (patch)
tree6a14521219942a08a1b95cb2f5a923a9edd60f63 /libraries/irrlicht-1.8/include/IColladaMeshWriter.h
parentAdd a note about rasters suggested start up code. (diff)
downloadSledjHamr-393b5cd1dc438872af89d334ef6e5fcc59f27d47.zip
SledjHamr-393b5cd1dc438872af89d334ef6e5fcc59f27d47.tar.gz
SledjHamr-393b5cd1dc438872af89d334ef6e5fcc59f27d47.tar.bz2
SledjHamr-393b5cd1dc438872af89d334ef6e5fcc59f27d47.tar.xz
Added Irrlicht 1.8, but without all the Windows binaries.
Diffstat (limited to '')
-rw-r--r--libraries/irrlicht-1.8/include/IColladaMeshWriter.h404
1 files changed, 404 insertions, 0 deletions
diff --git a/libraries/irrlicht-1.8/include/IColladaMeshWriter.h b/libraries/irrlicht-1.8/include/IColladaMeshWriter.h
new file mode 100644
index 0000000..90691f5
--- /dev/null
+++ b/libraries/irrlicht-1.8/include/IColladaMeshWriter.h
@@ -0,0 +1,404 @@
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 {
210 }
211
212 //! Destructor
213 virtual ~IColladaMeshWriter()
214 {
215 if ( Properties )
216 Properties->drop();
217 if ( DefaultProperties )
218 DefaultProperties->drop();
219 if ( NameGenerator )
220 NameGenerator->drop();
221 if ( DefaultNameGenerator )
222 DefaultNameGenerator->drop();
223 }
224
225 //! writes a scene starting with the given node
226 virtual bool writeScene(io::IWriteFile* file, scene::ISceneNode* root) = 0;
227
228
229 //! Set if texture information should be written
230 virtual void setWriteTextures(bool write)
231 {
232 WriteTextures = write;
233 }
234
235 //! Get if texture information should be written
236 virtual bool getWriteTextures() const
237 {
238 return WriteTextures;
239 }
240
241 //! Set if a default scene should be written when writing meshes.
242 /** Many collada readers fail to read a mesh if the collada files doesn't contain a scene as well.
243 The scene is doing an instantiation of the mesh.
244 When using writeScene this flag is ignored (as we have scene there already)
245 */
246 virtual void setWriteDefaultScene(bool write)
247 {
248 WriteDefaultScene = write;
249 }
250
251 //! Get if a default scene should be written
252 virtual bool getWriteDefaultScene() const
253 {
254 return WriteDefaultScene;
255 }
256
257 //! Sets ambient color of the scene to write
258 virtual void setAmbientLight(const video::SColorf &ambientColor)
259 {
260 AmbientLight = ambientColor;
261 }
262
263 //! Return ambient light of the scene which is written
264 virtual video::SColorf getAmbientLight() const
265 {
266 return AmbientLight;
267 }
268
269 //! Control when and how often a mesh is written
270 /** Optimally ECGI_PER_MESH would be always sufficent - writing geometry once per mesh.
271 Unfortunately many tools (at the time of writing this nearly all of them) have trouble
272 on import when different materials are used per node. So when you override materials
273 per node and importing the resuling collada has materials problems in other tools try
274 using other values here.
275 \param writeStyle One of the E_COLLADA_GEOMETRY_WRITING settings.
276 */
277 virtual void setGeometryWriting(E_COLLADA_GEOMETRY_WRITING writeStyle)
278 {
279 GeometryWriting = writeStyle;
280 }
281
282 //! Get the current style of geometry writing.
283 virtual E_COLLADA_GEOMETRY_WRITING getGeometryWriting() const
284 {
285 return GeometryWriting;
286 }
287
288 //! Make certain there is only one collada material generated per Irrlicht material
289 /** Checks before creating a collada material-name if an identical
290 irr:::video::SMaterial has been exported already. If so don't export it with
291 another name. This is set by default and leads to way smaller .dae files.
292 Note that if you need to disable this flag for some reason you can still
293 get a similar effect using the IColladaMeshWriterNames::nameForMaterial
294 by returning identical names for identical materials there.
295 */
296 virtual void setExportSMaterialsOnlyOnce(bool exportOnce)
297 {
298 ExportSMaterialOnce = exportOnce;
299 }
300
301 virtual bool getExportSMaterialsOnlyOnce() const
302 {
303 return ExportSMaterialOnce;
304 }
305
306 //! Set properties to use by the meshwriter instead of it's default properties.
307 /** Overloading properties with an own class allows modifying the writing process in certain ways.
308 By default properties are set to the DefaultProperties. */
309 virtual void setProperties(IColladaMeshWriterProperties * p)
310 {
311 if ( p == Properties )
312 return;
313 if ( p )
314 p->grab();
315 if ( Properties )
316 Properties->drop();
317 Properties = p;
318 }
319
320 //! Get properties which are currently used.
321 virtual IColladaMeshWriterProperties * getProperties() const
322 {
323 return Properties;
324 }
325
326 //! Return the original default properties of the writer.
327 /** You can use this pointer in your own properties to access and return default values. */
328 IColladaMeshWriterProperties * getDefaultProperties() const
329 {
330 return DefaultProperties;
331 }
332
333 //! Install a generator to create custom names on export.
334 virtual void setNameGenerator(IColladaMeshWriterNames * nameGenerator)
335 {
336 if ( nameGenerator == NameGenerator )
337 return;
338 if ( nameGenerator )
339 nameGenerator->grab();
340 if ( NameGenerator )
341 NameGenerator->drop();
342 NameGenerator = nameGenerator;
343 }
344
345 //! Get currently used name generator
346 virtual IColladaMeshWriterNames * getNameGenerator() const
347 {
348 return NameGenerator;
349 }
350
351 //! Return the original default name generator of the writer.
352 /** You can use this pointer in your own generator to access and return default values. */
353 IColladaMeshWriterNames * getDefaultNameGenerator() const
354 {
355 return DefaultNameGenerator;
356 }
357
358 //! Restrict the characters of oldString a set of allowed characters in xs::NCName and add the prefix.
359 /** A tool function to help when using a custom name generator to generative valid names for collada names and id's. */
360 virtual irr::core::stringw toNCName(const irr::core::stringw& oldString, const irr::core::stringw& prefix=irr::core::stringw(L"_NC_")) const = 0;
361
362
363 protected:
364 // NOTE: You usually should also call setProperties with the same paraemter when using setDefaultProperties
365 virtual void setDefaultProperties(IColladaMeshWriterProperties * p)
366 {
367 if ( p == DefaultProperties )
368 return;
369 if ( p )
370 p->grab();
371 if ( DefaultProperties )
372 DefaultProperties->drop();
373 DefaultProperties = p;
374 }
375
376 // NOTE: You usually should also call setNameGenerator with the same paraemter when using setDefaultProperties
377 virtual void setDefaultNameGenerator(IColladaMeshWriterNames * p)
378 {
379 if ( p == DefaultNameGenerator )
380 return;
381 if ( p )
382 p->grab();
383 if ( DefaultNameGenerator )
384 DefaultNameGenerator->drop();
385 DefaultNameGenerator = p;
386 }
387
388 private:
389 IColladaMeshWriterProperties * Properties;
390 IColladaMeshWriterProperties * DefaultProperties;
391 IColladaMeshWriterNames * NameGenerator;
392 IColladaMeshWriterNames * DefaultNameGenerator;
393 bool WriteTextures;
394 bool WriteDefaultScene;
395 bool ExportSMaterialOnce;
396 video::SColorf AmbientLight;
397 E_COLLADA_GEOMETRY_WRITING GeometryWriting;
398 };
399
400
401} // end namespace
402} // end namespace
403
404#endif