RioEngine  0.1
My first attempt to create a 3D WYSIWYG Game Engine
clscene.h
Go to the documentation of this file.
1 //--------------------------------------------------------------- @License begins
2 // RioEngine: The late night Coke -without whores- debugging sessions
3 // 2012-2015 Leopoldo Lomas Flores. Torreon, Coahuila. MEXICO
4 // leopoldolomas [at] gmail
5 // www.rioengine.com
6 // www.leopoldolomas.info
7 // "You have a problem, you face it like a man."
8 //
9 // This is free and unencumbered software released into the public domain.
10 //
11 // Anyone is free to copy, modify, publish, use, compile, sell, or distribute this
12 // software, either in source code form or as a compiled binary, for any purpose,
13 // commercial or non-commercial, and by any means.
14 //
15 // In jurisdictions that recognize copyright laws, the author or authors of this
16 // software dedicate any and all copyright interest in the software to the public
17 // domain. We make this dedication for the benefit of the public at large and to
18 // the detriment of our heirs and successors. We intend this dedication to be
19 // an overt act of relinquishment in perpetuity of all present and future
20 // rights to this software under copyright law.
21 //
22 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
23 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,FITNESS
24 // FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS BE
25 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
26 // CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
27 // SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
28 //--------------------------------------------------------------- @License ends
29 
30 #ifndef RIOENGINE_CLENGINE_CLSCENE_H_
31 #define RIOENGINE_CLENGINE_CLSCENE_H_
32 
33 #include <map>
34 #include <string>
35 #include "typedefs.h"
36 #include "tinyxml/tinyxml.h"
37 #include "clengine/clgeometry.h"
38 #include "clengine/clmaterial.h"
39 #include "clengine/clnode.h"
40 #include "clengine/cleffect.h"
41 #include "clengine/clphong.h"
42 #include "clengine/clphong.h"
43 #include "clengine/clphongchild.h"
44 #include "cengine/cobject.h"
45 #include "cengine/carray.h"
46 
47 class CLScene : public CObject {
48 public:
49  CLScene(char* filename);
50 
51  std::vector<std::string> getNodeIdList();
52 
53  CLNode* getNodeHavingId (const std::string& node_id );
54  CLMaterial* getMaterialHavingId (const std::string& material_id );
55  CLMaterial* getMaterialHavingName (const std::string& material_name );
56  CLEffect* getEffectHavingId (const std::string& effect_id );
57  CLImageDetails* getImageDetailsHavingId(const std::string& image_id );
58  CLGeometry* getGeometryObjHavingId (const std::string& geometry_obj_id);
59 
60  void insertImagePair (const std::string& image_id, CLImageDetails* image_details);
61  void insertMaterialPair(const std::string& material_id, CLMaterial* material );
62  void insertEffectPair (const std::string& effect_id, CLEffect* effect );
63  void insertGeometryPair(const std::string& geometry_id, CLGeometry* geometry );
64  void insertNodesPair (const std::string& node_id, CLNode* node );
65 
66  bool loadImage (TiXmlElement* image_node );
67  bool loadMaterial(TiXmlElement* material_node);
68  bool loadNode (TiXmlElement* node );
69  bool loadScene (TiXmlElement* scene_node );
70  bool loadEffect (TiXmlElement* effect_node );
71 
72  const ImagesMapType* images() const;
73  const MaterialsMapType* materials() const;
74  const EffectsMapType* effects() const;
75  const GeometriesMapType* geometries() const;
76  const NodesMapType* nodes() const;
77  const CLImageDetails* imageDetails() const;
78 
79  bool reloadMaterials();
80  bool reloadImages();
81  bool reloadNodes();
82  bool reloadEffects();
83  bool reloadGeometries();
84 
87 
88  ~CLScene(void);
89 
90 protected:
91  CLScene();
92 
93 private:
94  bool loadGeometry(TiXmlElement* geometry_node);
95  void getFloatStdVecFromSourceNode(TiXmlElement* source_node, std::vector<btVector3*>* vector_dest);
96  CArray<btVector3>* getFloatCArrayFromSourceNode(TiXmlElement*);
97  CArray<TextureCoord>* getMapArrayFromSourceNode (TiXmlElement* source_node);
98 
99  TiXmlDocument* m_doc;
100  GeometriesMapType* m_geometries;
101  ImagesMapType* m_images;
102  EffectsMapType* m_effects;
103  MaterialsMapType* m_materials;
104  NodesMapType* m_nodes;
105  std::string m_md5;
106  std::vector<std::string>* m_nodesId;
107 };
108 
109 #endif // RIOENGINE_CLENGINE_CLSCENE_H_
const CLImageDetails * imageDetails() const
Definition: clscene.cpp:384
const GeometriesMapType * geometries() const
Definition: clscene.cpp:378
bool reloadImages()
Definition: clscene.cpp:415
const EffectsMapType * effects() const
Definition: clscene.cpp:372
bool loadEffect(TiXmlElement *effect_node)
Definition: clscene.cpp:275
CLPhongChild * getPhongChildFromNode(TiXmlElement *node)
Definition: clscene.cpp:795
const ImagesMapType * images() const
Definition: clscene.cpp:360
bool loadScene(TiXmlElement *scene_node)
Definition: clscene.cpp:261
bool loadNode(TiXmlElement *node)
Definition: clscene.cpp:214
std::map< std::string, CLEffect * > EffectsMapType
Definition: typedefs.h:71
void insertImagePair(const std::string &image_id, CLImageDetails *image_details)
Definition: clscene.cpp:141
Definition: clnode.h:37
void insertMaterialPair(const std::string &material_id, CLMaterial *material)
Definition: clscene.cpp:147
bool reloadEffects()
Definition: clscene.cpp:460
std::map< std::string, CLImageDetails * > ImagesMapType
Definition: typedefs.h:62
CLMaterial * getMaterialHavingName(const std::string &material_name)
Definition: clscene.cpp:505
void insertNodesPair(const std::string &node_id, CLNode *node)
Definition: clscene.cpp:165
bool reloadNodes()
Definition: clscene.cpp:440
const MaterialsMapType * materials() const
Definition: clscene.cpp:366
CLScene()
Definition: clscene.cpp:54
~CLScene(void)
Definition: clscene.cpp:820
std::map< std::string, CLGeometry * > GeometriesMapType
Definition: typedefs.h:68
bool loadImage(TiXmlElement *image_node)
Definition: clscene.cpp:171
bool loadMaterial(TiXmlElement *material_node)
Definition: clscene.cpp:191
std::map< std::string, CLMaterial * > MaterialsMapType
Definition: typedefs.h:74
CLGeometry * getGeometryObjHavingId(const std::string &geometry_obj_id)
Definition: clscene.cpp:135
CLNode * getNodeHavingId(const std::string &node_id)
Definition: clscene.cpp:111
CLEffect * getEffectHavingId(const std::string &effect_id)
Definition: clscene.cpp:123
CLMaterial * getMaterialHavingId(const std::string &material_id)
Definition: clscene.cpp:117
std::vector< std::string > getNodeIdList()
Definition: clscene.cpp:97
std::map< std::string, CLNode * > NodesMapType
Definition: typedefs.h:77
void insertGeometryPair(const std::string &geometry_id, CLGeometry *geometry)
Definition: clscene.cpp:159
void insertEffectPair(const std::string &effect_id, CLEffect *effect)
Definition: clscene.cpp:153
bool reloadMaterials()
Definition: clscene.cpp:390
CLInstanceGeometry getInstanceGeometryFromNode(TiXmlElement *instance_geometry_node)
Definition: clscene.cpp:739
const NodesMapType * nodes() const
Definition: clscene.cpp:354
CLImageDetails * getImageDetailsHavingId(const std::string &image_id)
Definition: clscene.cpp:129
bool reloadGeometries()
Definition: clscene.cpp:485