SuperTuxKart
Loading...
Searching...
No Matches
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
22class LODNode;
23class STKInstancedSceneNode;
24namespace GE { class GERenderInfo; }
25class Track;
26
27#include <cassert>
28#include <map>
29#include <vector>
30#include <string>
31#include <memory>
32#include "io/xml_node.hpp"
33
34namespace irr
35{
36 namespace scene
37 {
38 class IMesh;
39 class ISceneNode;
40 }
41}
42
44{
45 std::string m_model_file;
46 bool m_tangent; // obsolete, TODO remove
47 const XMLNode* m_xml;
48
51
52 bool m_skeletal_animation;
53
56 {
57 m_tangent = false;
58 m_skeletal_animation = false;
59 m_distance = 0;
60 m_xml = NULL;
61 }
62
63 ModelDefinition(const XMLNode* xml, int distance, std::string& model, bool tangent, bool skeletal_animation)
64 {
65 m_model_file = model;
66 m_tangent = tangent;
67 m_xml = xml;
68 m_distance = distance;
69 m_skeletal_animation = skeletal_animation;
70 }
71
73 {
74 }
75};
76
81{
82private:
83 std::map<std::string, XMLNode*> m_library_nodes;
84 std::map< std::string, std::vector< ModelDefinition > > m_lod_groups;
85 std::map< std::string, STKInstancedSceneNode* > m_instancing_nodes;
86 Track* m_track;
87
88public:
90
91 void addModelDefinition(const XMLNode* xml);
92 LODNode* instanciateAsLOD(const XMLNode* xml_node,
93 scene::ISceneNode* parent,
94 std::shared_ptr<GE::GERenderInfo> ri);
95
96 void clear();
97
98 scene::IMesh* getFirstMeshFor(const std::string& name);
99
100 std::map<std::string, XMLNode*>& getLibraryNodes()
101 {
102 return m_library_nodes;
103 }
104
105 void cleanLibraryNodesAfterLoad();
106
107 bool containsLibraryNode(const std::string& name) const
108 {
109 return m_library_nodes.find(name) != m_library_nodes.end();
110 }
111
112 void addToLibrary(const std::string& name, XMLNode* xml)
113 {
114 assert(xml != NULL);
115 m_library_nodes[name] = xml;
116 }
117}; // ModelDefinitionLoader
118
119#endif // HEADER_LOD_NODE_LOADER_HPP
manages level-of-detail
Definition: lod_node.hpp:50
Utility class to load level-of-detail nodes and library nodes.
Definition: model_definition_loader.hpp:81
Definition: track.hpp:114
utility class used to parse XML files
Definition: xml_node.hpp:48
Definition: model_definition_loader.hpp:44
ModelDefinition()
Constructor to allow storing this in STL containers.
Definition: model_definition_loader.hpp:55
int m_distance
For LOD.
Definition: model_definition_loader.hpp:50