SuperTuxKart
model_definition_loader.hpp
1 //
2 // SuperTuxKart - a fun racing game with go-kart
3 // Copyright (C) 2007-2015 Joerg Henrichs
4 //
5 // This program is free software; you can redistribute it and/or
6 // modify it under the terms of the GNU General Public License
7 // as published by the Free Software Foundation; either version 3
8 // of the License, or (at your option) any later version.
9 //
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTe ABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
14 //
15 // You should have received a copy of the GNU General Public License
16 // along with this program; if not, write to the Free Software
17 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 
19 #ifndef HEADER_LOD_NODE_LOADER_HPP
20 #define HEADER_LOD_NODE_LOADER_HPP
21 
22 class LODNode;
23 class STKInstancedSceneNode;
24 class RenderInfo;
25 class Track;
26 
27 #include <cassert>
28 #include <map>
29 #include <vector>
30 #include <string>
31 #include <memory>
32 #include <irrlicht.h>
33 #include "io/xml_node.hpp"
34 
35 namespace irr
36 {
37  namespace scene
38  {
39  class IMesh;
40  class ISceneNode;
41  }
42 }
43 
45 {
46  std::string m_model_file;
47  bool m_tangent; // obsolete, TODO remove
48  const XMLNode* m_xml;
49 
52 
53  bool m_skeletal_animation;
54 
57  {
58  m_tangent = false;
59  m_skeletal_animation = false;
60  m_distance = 0;
61  m_xml = NULL;
62  }
63 
64  ModelDefinition(const XMLNode* xml, int distance, std::string& model, bool tangent, bool skeletal_animation)
65  {
66  m_model_file = model;
67  m_tangent = tangent;
68  m_xml = xml;
69  m_distance = distance;
70  m_skeletal_animation = skeletal_animation;
71  }
72 
74  {
75  }
76 };
77 
82 {
83 private:
84  std::map<std::string, XMLNode*> m_library_nodes;
85  std::map< std::string, std::vector< ModelDefinition > > m_lod_groups;
86  std::map< std::string, STKInstancedSceneNode* > m_instancing_nodes;
87  Track* m_track;
88 
89 public:
91 
92  void addModelDefinition(const XMLNode* xml);
93  LODNode* instanciateAsLOD(const XMLNode* xml_node,
94  scene::ISceneNode* parent,
95  std::shared_ptr<RenderInfo> ri);
96 
97  void clear();
98 
99  scene::IMesh* getFirstMeshFor(const std::string& name);
100 
101  std::map<std::string, XMLNode*>& getLibraryNodes()
102  {
103  return m_library_nodes;
104  }
105 
106  void cleanLibraryNodesAfterLoad();
107 
108  bool containsLibraryNode(const std::string& name) const
109  {
110  return m_library_nodes.find(name) != m_library_nodes.end();
111  }
112 
113  void addToLibrary(const std::string& name, XMLNode* xml)
114  {
115  assert(xml != NULL);
116  m_library_nodes[name] = xml;
117  }
118 }; // ModelDefinitionLoader
119 
120 #endif // HEADER_LOD_NODE_LOADER_HPP
int m_distance
For LOD.
Definition: model_definition_loader.hpp:51
manages level-of-detail
Definition: lod_node.hpp:48
ModelDefinition()
Constructor to allow storing this in STL containers.
Definition: model_definition_loader.hpp:56
Definition: model_definition_loader.hpp:44
utility class used to parse XML files
Definition: xml_node.hpp:47
Definition: render_info.hpp:27
Definition: track.hpp:96
Utility class to load level-of-detail nodes and library nodes.
Definition: model_definition_loader.hpp:81