Visualization Library 2.1.0

A lightweight C++ OpenGL middleware for 2D/3D graphics

VL     Star     Watch     Fork     Issue

[Download] [Tutorials] [All Classes] [Grouped Classes]
DaeLoader.hpp
Go to the documentation of this file.
1 /**************************************************************************************/
2 /* */
3 /* Visualization Library */
4 /* http://visualizationlibrary.org */
5 /* */
6 /* Copyright (c) 2005-2020, Michele Bosi */
7 /* All rights reserved. */
8 /* */
9 /* Redistribution and use in source and binary forms, with or without modification, */
10 /* are permitted provided that the following conditions are met: */
11 /* */
12 /* - Redistributions of source code must retain the above copyright notice, this */
13 /* list of conditions and the following disclaimer. */
14 /* */
15 /* - Redistributions in binary form must reproduce the above copyright notice, this */
16 /* list of conditions and the following disclaimer in the documentation and/or */
17 /* other materials provided with the distribution. */
18 /* */
19 /* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND */
20 /* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED */
21 /* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE */
22 /* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR */
23 /* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES */
24 /* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; */
25 /* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON */
26 /* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT */
27 /* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS */
28 /* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */
29 /* */
30 /**************************************************************************************/
31 
32 #ifndef DaeHelpers_INCLUDE_ONCE
33 #define DaeHelpers_INCLUDE_ONCE
34 
37 
38 namespace vl
39 {
41  class DaeLoader
42  {
43  public:
44  DaeLoader();
45 
46  bool load(VirtualFile* file);
47 
48  const ResourceDatabase* resources() const { return mResources.get(); }
49 
50  ResourceDatabase* resources() { return mResources.get(); }
51 
52  // --- options ---
53 
54  void setLoadOptions(const LoadWriterDae::LoadOptions* options) { mLoadOptions = options; }
55 
57 
58  // --- internal logic ---
59  protected:
60 
61  void reset();
62 
63  void parseInputs(Dae::Primitive* dae_primitive, const domInputLocalOffset_Array& input_arr, const std::vector< ref<Dae::Input> >& vertex_inputs);
64 
65  ref<Dae::Mesh> parseGeometry(daeElement* geometry);
66 
67  Dae::Source* getSource(daeElement* source_el);
68 
69  void bindMaterials(Dae::Node* dae_node, Dae::Mesh* dae_mesh, domBind_materialRef bind_material);
70 
71  void parseNode(daeElement* el, Dae::Node* parent);
72 
73  void parseAsset(domElement* root);
74 
75  void loadImages(const domImage_Array& images);
76 
77  void parseImages(daeElement* library);
78 
79  void parseEffects(daeElement* library);
80 
81  void prepareTexture2D(Dae::Sampler2D* sampler2D);
82 
83  void parseMaterials(daeElement* library);
84 
85  ref<Light> parseLight(domLight*, Transform*);
86 
87  void setupLights();
88 
90 
91  static std::string percentDecode(const char* uri);
92 
93  static Dae::EInputSemantic getSemantic(const char* semantic);
94 
95  static const char* getSemanticString(Dae::EInputSemantic semantic);
96 
97  static ETexParamFilter translateSampleFilter(domFx_sampler_filter_common filter);
98 
99  static ETexParamWrap translateWrapMode(domFx_sampler_wrap_common wrap);
100 
101  // template required becase Transparent is implemented as something different from domCommon_color_or_texture_typeRef!!!
102  template<class T_color_or_texture>
103  void parseColor(const domProfile_COMMON* common, const T_color_or_texture& color_or_texture, Dae::ColorOrTexture* out_col);
104 
105  void generateGeometry(Dae::Primitive* primitive, const char* name);
106 
107  protected:
109 
110  protected:
112  std::vector< ref<Light> > mLights;
113  std::map< daeElementRef, ref<Dae::Material> > mMaterials;
114  std::map< daeElementRef, ref<Dae::Effect> > mEffects;
115  std::map< daeElementRef, ref<Dae::Mesh> > mMeshes; // daeElement* -> <geometry>
116  std::vector< ref<Dae::Node> > mNodes;
117  std::map< daeElementRef, ref<Dae::Source> > mSources; // daeElement* -> <source>
118  std::map< daeElementRef, ref<Image> > mImages;
119  std::map< daeElementRef, ref<Dae::NewParam> > mDaeNewParams;
122  DAE mDAE;
127  };
128 }
129 
130 #endif
COLLADA sampler2D.
Definition: DaeHelpers.hpp:304
static Dae::EInputSemantic getSemantic(const char *semantic)
Definition: DaeLoader.cpp:1526
ResourceDatabase * resources()
Definition: DaeLoader.hpp:50
Implements a 4x4 matrix transform used to define the position and orientation of an Actor...
Definition: Transform.hpp:72
An abstract class representing a file.
Definition: VirtualFile.hpp:60
void bindMaterials(Dae::Node *dae_node, Dae::Mesh *dae_mesh, domBind_materialRef bind_material)
Definition: DaeLoader.cpp:527
void parseImages(daeElement *library)
Definition: DaeLoader.cpp:927
ETexParamFilter
The String class implements an advanced UTF16 (Unicode BMP) string manipulation engine.
Definition: String.hpp:62
void loadImages(const domImage_Array &images)
Definition: DaeLoader.cpp:910
COLLADA data source.
Definition: DaeHelpers.hpp:123
ref< Light > parseLight(domLight *, Transform *)
Definition: DaeLoader.cpp:1324
Dae::Source * getSource(daeElement *source_el)
Definition: DaeLoader.cpp:385
std::map< daeElementRef, ref< Dae::NewParam > > mDaeNewParams
Definition: DaeLoader.hpp:119
ref< Dae::Node > mScene
Definition: DaeLoader.hpp:121
COLLADA loader.
Definition: DaeLoader.hpp:41
COLLADA node.
Definition: DaeHelpers.hpp:283
void parseEffects(daeElement *library)
Definition: DaeLoader.cpp:936
std::map< daeElementRef, ref< Dae::Mesh > > mMeshes
Definition: DaeLoader.hpp:115
const LoadWriterDae::LoadOptions * mLoadOptions
Definition: DaeLoader.hpp:108
const LoadWriterDae::LoadOptions * loadOptions() const
Definition: DaeLoader.hpp:56
COLLADA material.
Definition: DaeHelpers.hpp:396
COLLADA mesh.
Definition: DaeHelpers.hpp:276
ref< ResourceDatabase > mResources
Definition: DaeLoader.hpp:111
void setLoadOptions(const LoadWriterDae::LoadOptions *options)
Definition: DaeLoader.hpp:54
Visualization Library main namespace.
static std::string percentDecode(const char *uri)
Definition: DaeLoader.cpp:859
std::map< daeElementRef, ref< Dae::Source > > mSources
Definition: DaeLoader.hpp:117
void reset()
Definition: DaeLoader.cpp:91
COLLADA color or texture input.
Definition: DaeHelpers.hpp:333
COLLADA primitive.
Definition: DaeHelpers.hpp:257
void generateGeometry(Dae::Primitive *primitive, const char *name)
Definition: DaeLoader.cpp:1626
bool mInvertTransparency
Definition: DaeLoader.hpp:125
void parseAsset(domElement *root)
Definition: DaeLoader.cpp:1872
std::map< daeElementRef, ref< Dae::Material > > mMaterials
Definition: DaeLoader.hpp:113
void parseInputs(Dae::Primitive *dae_primitive, const domInputLocalOffset_Array &input_arr, const std::vector< ref< Dae::Input > > &vertex_inputs)
Definition: DaeLoader.cpp:99
ref< Dae::Mesh > parseGeometry(daeElement *geometry)
Definition: DaeLoader.cpp:149
void prepareTexture2D(Dae::Sampler2D *sampler2D)
Definition: DaeLoader.cpp:1267
static const char * getSemanticString(Dae::EInputSemantic semantic)
Definition: DaeLoader.cpp:1537
const ResourceDatabase * resources() const
Definition: DaeLoader.hpp:48
void parseMaterials(daeElement *library)
Definition: DaeLoader.cpp:1293
bool mAssumeOpaque
Definition: DaeLoader.hpp:126
Loading options used by LoadWriterDae and DaeLoader.
Definition: ioDae.hpp:54
void setupLights()
Definition: DaeLoader.cpp:1430
std::vector< ref< Light > > mLights
Definition: DaeLoader.hpp:112
bool load(VirtualFile *file)
Definition: DaeLoader.cpp:726
ETexParamWrap
std::map< daeElementRef, ref< Image > > mImages
Definition: DaeLoader.hpp:118
The ref<> class is used to reference-count an Object.
Definition: Object.hpp:55
ref< Effect > setup_vl_Effect(Dae::Material *mat)
Definition: DaeLoader.cpp:431
void parseNode(daeElement *el, Dae::Node *parent)
Definition: DaeLoader.cpp:590
static ETexParamWrap translateWrapMode(domFx_sampler_wrap_common wrap)
Definition: DaeLoader.cpp:1562
std::vector< ref< Dae::Node > > mNodes
Definition: DaeLoader.hpp:116
std::map< daeElementRef, ref< Dae::Effect > > mEffects
Definition: DaeLoader.hpp:114
ref< Effect > mDefaultFX
Definition: DaeLoader.hpp:120
The ResourceDatabase class contains and manipulates a set of resources.
static ETexParamFilter translateSampleFilter(domFx_sampler_filter_common filter)
Definition: DaeLoader.cpp:1548
String mFilePath
Definition: DaeLoader.hpp:123
void parseColor(const domProfile_COMMON *common, const T_color_or_texture &color_or_texture, Dae::ColorOrTexture *out_col)
Definition: DaeLoader.cpp:1575