Irrlicht 3D Engine
IColladaMeshWriter.h
Go to the documentation of this file.
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 
13 namespace irr
14 {
15 namespace io
16 {
17  class IWriteFile;
18 } // end namespace io
19 
20 namespace scene
21 {
24  {
32  // constantly shaded surface that is independent of lighting.
34  };
35 
38  {
41 
44  };
45 
48  {
55  };
56 
59  {
62 
65 
68 
71 
74 
77  };
78 
81  {
84 
89  };
90 
93  {
94  public:
96 
98  virtual E_COLLADA_TECHNIQUE_FX getTechniqueFx(const video::SMaterial& material) const = 0;
99 
101 
104  virtual s32 getTextureIdx(const video::SMaterial & material, E_COLLADA_COLOR_SAMPLER cs) const = 0;
105 
107 
111  virtual E_COLLADA_IRR_COLOR getColorMapping(const video::SMaterial & material, E_COLLADA_COLOR_SAMPLER cs) const = 0;
112 
114 
115  virtual video::SColor getCustomColor(const video::SMaterial & material, E_COLLADA_COLOR_SAMPLER cs) const = 0;
116 
118 
119  virtual E_COLLADA_TRANSPARENT_FX getTransparentFx(const video::SMaterial& material) const = 0;
120 
122 
124  virtual f32 getTransparency(const video::SMaterial& material) const = 0;
125 
127 
129  virtual f32 getReflectivity(const video::SMaterial& material) const = 0;
130 
132 
134  virtual f32 getIndexOfRefraction(const video::SMaterial& material) const = 0;
135 
138  virtual bool isExportable(const irr::scene::ISceneNode * node) const = 0;
139 
142  // TODO: Function is not const because there is no const getMesh() function for several Irrlicht nodes.
143  virtual IMesh* getMesh(irr::scene::ISceneNode * node) = 0;
144 
146 
150  virtual bool useNodeMaterial(const scene::ISceneNode* node) const = 0;
151 
152  };
153 
155 
160  {
161  public:
162 
164 
166 
175  virtual irr::core::stringc nameForMesh(const scene::IMesh* mesh, int instance) = 0;
176 
178 
184  virtual irr::core::stringc nameForNode(const scene::ISceneNode* node) = 0;
185 
187 
197  virtual irr::core::stringc nameForMaterial(const video::SMaterial & material, int materialId, const scene::IMesh* mesh, const scene::ISceneNode* node) = 0;
198  };
199 
200 
203  {
204  public:
205 
207  : Properties(0), DefaultProperties(0), NameGenerator(0), DefaultNameGenerator(0)
208  , WriteTextures(true), WriteDefaultScene(true), ExportSMaterialOnce(true)
209  , AmbientLight(0.f, 0.f, 0.f, 1.f)
210  , UnitMeter(1.f), UnitName("meter")
211  , GeometryWriting(ECGI_PER_MESH)
212  {
213  ParamNamesUV[0] = "U";
214  ParamNamesUV[1] = "V";
215  }
216 
219  {
220  if ( Properties )
221  Properties->drop();
222  if ( DefaultProperties )
223  DefaultProperties->drop();
224  if ( NameGenerator )
225  NameGenerator->drop();
226  if ( DefaultNameGenerator )
227  DefaultNameGenerator->drop();
228  }
229 
231  //\param writeRoot: 0 = no, 1=yes unless root is scenemanager, 2=yes
232  virtual bool writeScene(io::IWriteFile* file, scene::ISceneNode* root, int writeRoot=1) = 0;
233 
234 
236  virtual void setWriteTextures(bool write)
237  {
238  WriteTextures = write;
239  }
240 
242  virtual bool getWriteTextures() const
243  {
244  return WriteTextures;
245  }
246 
248 
252  virtual void setWriteDefaultScene(bool write)
253  {
254  WriteDefaultScene = write;
255  }
256 
258  virtual bool getWriteDefaultScene() const
259  {
260  return WriteDefaultScene;
261  }
262 
264  virtual void setAmbientLight(const video::SColorf &ambientColor)
265  {
266  AmbientLight = ambientColor;
267  }
268 
271  {
272  return AmbientLight;
273  }
274 
276 
279  virtual void setUnit(irr::f32 meter, const irr::core::stringc& name)
280  {
281  UnitMeter = meter;
282  UnitName = name;
283  }
284 
286  virtual irr::f32 getUnitMeter() const
287  {
288  return UnitMeter;
289  }
290 
293  {
294  return UnitName;
295  }
296 
298 
306  {
307  GeometryWriting = writeStyle;
308  }
309 
312  {
313  return GeometryWriting;
314  }
315 
317 
324  virtual void setExportSMaterialsOnlyOnce(bool exportOnce)
325  {
326  ExportSMaterialOnce = exportOnce;
327  }
328 
329  virtual bool getExportSMaterialsOnlyOnce() const
330  {
331  return ExportSMaterialOnce;
332  }
333 
335 
338  {
339  if ( p == Properties )
340  return;
341  if ( p )
342  p->grab();
343  if ( Properties )
344  Properties->drop();
345  Properties = p;
346  }
347 
350  {
351  return Properties;
352  }
353 
355 
357  {
358  return DefaultProperties;
359  }
360 
362  virtual void setNameGenerator(IColladaMeshWriterNames * nameGenerator)
363  {
364  if ( nameGenerator == NameGenerator )
365  return;
366  if ( nameGenerator )
367  nameGenerator->grab();
368  if ( NameGenerator )
369  NameGenerator->drop();
370  NameGenerator = nameGenerator;
371  }
372 
375  {
376  return NameGenerator;
377  }
378 
380 
382  {
383  return DefaultNameGenerator;
384  }
385 
387 
388  virtual irr::core::stringc toNCName(const irr::core::stringc& oldString, const irr::core::stringc& prefix=irr::core::stringc("_NC_")) const = 0;
389 
391 
393  // TODO: Function is not const because there is no const getMesh() function for several Irrlicht nodes.
394  virtual const irr::core::stringc* findGeometryNameForNode(ISceneNode* node) = 0;
395 
397 
403  void SetParamNamesUV(const core::stringc& u, const core::stringc& v)
404  {
405  ParamNamesUV[0] = u;
406  ParamNamesUV[1] = v;
407  }
408 
409 
410  protected:
411  // NOTE: You usually should also call setProperties with the same parameter when using setDefaultProperties
413  {
414  if ( p == DefaultProperties )
415  return;
416  if ( p )
417  p->grab();
418  if ( DefaultProperties )
419  DefaultProperties->drop();
420  DefaultProperties = p;
421  }
422 
423  // NOTE: You usually should also call setNameGenerator with the same parameter when using setDefaultProperties
425  {
426  if ( p == DefaultNameGenerator )
427  return;
428  if ( p )
429  p->grab();
430  if ( DefaultNameGenerator )
431  DefaultNameGenerator->drop();
432  DefaultNameGenerator = p;
433  }
434 
435  protected:
437 
438  private:
439  IColladaMeshWriterProperties * Properties;
440  IColladaMeshWriterProperties * DefaultProperties;
441  IColladaMeshWriterNames * NameGenerator;
442  IColladaMeshWriterNames * DefaultNameGenerator;
443  bool WriteTextures;
444  bool WriteDefaultScene;
445  bool ExportSMaterialOnce;
446  video::SColorf AmbientLight;
447  irr::f32 UnitMeter;
448  irr::core::stringc UnitName;
449  E_COLLADA_GEOMETRY_WRITING GeometryWriting;
450  };
451 
452 
453 } // end namespace
454 } // end namespace
455 
456 #endif
Use SMaterial::EmissiveColor.
bool drop() const
Drops the object. Decrements the reference counter by one.
Use SMaterial::DiffuseColor.
default - only alpha channel of color or texture is used.
virtual E_COLLADA_GEOMETRY_WRITING getGeometryWriting() const
Get the current style of geometry writing.
E_COLLADA_GEOMETRY_WRITING
Control when geometry elements are created.
virtual irr::f32 getUnitMeter() const
Return real world meters to use per unit for all elements and objects.
float f32
32 bit floating point variable.
Definition: irrTypes.h:108
virtual f32 getIndexOfRefraction(const video::SMaterial &material) const =0
Return index of refraction for that material.
irr::core::stringc ParamNamesUV[2]
virtual void setDefaultNameGenerator(IColladaMeshWriterNames *p)
virtual s32 getTextureIdx(const video::SMaterial &material, E_COLLADA_COLOR_SAMPLER cs) const =0
Which texture index should be used when writing the texture of the given sampler color.
IColladaMeshWriterProperties * getDefaultProperties() const
Return the original default properties of the writer.
Don't write this element at all.
Scene node interface.
Definition: ISceneNode.h:40
Alpha values for each RGB channel of color or texture are used.
virtual E_COLLADA_TRANSPARENT_FX getTransparentFx(const video::SMaterial &material) const =0
Return the transparence color interpretation.
virtual bool getWriteDefaultScene() const
Get if a default scene should be written.
virtual video::SColorf getAmbientLight() const
Return ambient light of the scene which is written.
virtual irr::core::stringc nameForMaterial(const video::SMaterial &material, int materialId, const scene::IMesh *mesh, const scene::ISceneNode *node)=0
Return a name for the material.
Everything in the Irrlicht Engine can be found in this namespace.
Definition: aabbox3d.h:12
Use SMaterial::SpecularColor.
virtual ~IColladaMeshWriter()
Destructor.
virtual bool getWriteTextures() const
Get if texture information should be written.
Interface providing write access to a file.
Definition: IWriteFile.h:17
virtual void setGeometryWriting(E_COLLADA_GEOMETRY_WRITING writeStyle)
Control when and how often a mesh is written.
Very simple string class with some useful features.
Definition: irrString.h:37
Interface for writing meshes.
Definition: IMeshWriter.h:23
Class which holds the geometry of an object.
Definition: IMesh.h:71
Default - write each mesh exactly once to collada. Optimal but will not work with many tools.
virtual IColladaMeshWriterNames * getNameGenerator() const
Get currently used name generator.
Interface for writing meshes.
virtual IColladaMeshWriterProperties * getProperties() const
Get properties which are currently used.
virtual void setNameGenerator(IColladaMeshWriterNames *nameGenerator)
Install a generator to create custom names on export.
E_COLLADA_TECHNIQUE_FX
Lighting models - more or less the way Collada categorizes materials.
signed int s32
32 bit signed variable.
Definition: irrTypes.h:70
virtual irr::core::stringc toNCName(const irr::core::stringc &oldString, const irr::core::stringc &prefix=irr::core::stringc("_NC_")) const =0
Restrict the characters of oldString a set of allowed characters in xs:NCName and add the prefix.
IColladaMeshWriterNames * getDefaultNameGenerator() const
Return the original default name generator of the writer.
virtual void setWriteTextures(bool write)
Set if texture information should be written.
virtual void setWriteDefaultScene(bool write)
Set if a default scene should be written when writing meshes.
E_COLLADA_TRANSPARENT_FX
How to interpret the opacity in collada.
diffuse shaded surface that is independent of lighting.
Callback interface for properties which can be used to influence collada writing.
Callback interface to use custom names on collada writing.
virtual bool isExportable(const irr::scene::ISceneNode *node) const =0
virtual void setProperties(IColladaMeshWriterProperties *p)
Set properties to use by the meshwriter instead of it's default properties.
E_COLLADA_IRR_COLOR
Irrlicht colors which can be mapped to E_COLLADA_COLOR_SAMPLER values.
virtual void setExportSMaterialsOnlyOnce(bool exportOnce)
Make certain there is only one collada material generated per Irrlicht material.
virtual const irr::core::stringc * findGeometryNameForNode(ISceneNode *node)=0
After export you can find out which name had been used for writing the geometry for this node.
Class representing a 32 bit ARGB color.
Definition: SColor.h:314
virtual irr::core::stringc getUnitName() const
Return name to use for distance units. Like p.E. "meter".
virtual f32 getTransparency(const video::SMaterial &material) const =0
Transparency value for that material.
virtual video::SColor getCustomColor(const video::SMaterial &material, E_COLLADA_COLOR_SAMPLER cs) const =0
Return custom colors for certain color types requested by collada.
virtual void setAmbientLight(const video::SColorf &ambientColor)
Sets ambient color of the scene to write.
virtual bool useNodeMaterial(const scene::ISceneNode *node) const =0
Return if the node has it's own material overwriting the mesh-materials.
void grab() const
Grabs the object. Increments the reference counter by one.
Phong shading, default in many external renderers.
virtual irr::core::stringc nameForNode(const scene::ISceneNode *node)=0
Return a unique name for the given node.
virtual bool getExportSMaterialsOnlyOnce() const
Base class of most objects of the Irrlicht Engine.
E_COLLADA_COLOR_SAMPLER
Color names collada uses in it's color samplers.
virtual bool writeScene(io::IWriteFile *file, scene::ISceneNode *root, int writeRoot=1)=0
writes a scene starting with the given node
virtual E_COLLADA_IRR_COLOR getColorMapping(const video::SMaterial &material, E_COLLADA_COLOR_SAMPLER cs) const =0
Return which color from Irrlicht should be used for the color requested by collada.
virtual E_COLLADA_TECHNIQUE_FX getTechniqueFx(const video::SMaterial &material) const =0
Which lighting model should be used in the technique (FX) section when exporting effects (materials)
virtual void setUnit(irr::f32 meter, const irr::core::stringc &name)
Set the unit distances for all elements and objects.
Class representing a color with four floats.
Definition: SColor.h:571
Check IColladaMeshWriterProperties for custom color.
Struct for holding parameters for a material renderer.
Definition: SMaterial.h:286
virtual f32 getReflectivity(const video::SMaterial &material) const =0
Reflectivity value for that material.
virtual irr::core::stringc nameForMesh(const scene::IMesh *mesh, int instance)=0
Return a unique name for the given mesh.
Use SMaterial::AmbientColor.
void SetParamNamesUV(const core::stringc &u, const core::stringc &v)
Change param name used for UV's.
virtual void setDefaultProperties(IColladaMeshWriterProperties *p)
virtual IMesh * getMesh(irr::scene::ISceneNode *node)=0