SuperTuxKart
Loading...
Searching...
No Matches
material_manager.hpp
1//
2// SuperTuxKart - a fun racing game with go-kart
3// Copyright (C) 2004-2015 Steve Baker <sjbaker1@airmail.net>
4// Copyright (C) 2010-2015 Steve Baker, Joerg Henrichs
5//
6// This program is free software; you can redistribute it and/or
7// modify it under the terms of the GNU General Public License
8// as published by the Free Software Foundation; either version 3
9// of the License, or (at your option) any later version.
10//
11// This program is distributed in the hope that it will be useful,
12// but WITHOUT ANY WARRANTY; without even the implied warranty of
13// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14// GNU General Public License for more details.
15//
16// You should have received a copy of the GNU General Public License
17// along with this program; if not, write to the Free Software
18// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19
20#ifndef HEADER_MATERIAL_MANAGER_HPP
21#define HEADER_MATERIAL_MANAGER_HPP
22
23#include "utils/no_copy.hpp"
24
25namespace irr
26{
27 namespace video { class ITexture; }
28 namespace scene { class IMeshBuffer; class ISceneNode; }
29}
30using namespace irr;
31
32#include <string>
33#include <vector>
34#include <map>
35#include <EMaterialTypes.h>
36
37class Material;
38class XMLReader;
39class XMLNode;
40
44class MaterialManager : public NoCopy
45{
46private:
47
48 void parseMaterialFile(const std::string& filename);
49 int m_shared_material_index;
50
51 std::vector<Material*> m_materials;
52
53 std::map<std::string, Material*> m_default_sp_materials;
54
55public:
58 void loadMaterial ();
59 Material* getMaterialFor(video::ITexture* t,
60 scene::IMeshBuffer *mb);
61 Material* getMaterialFor(video::ITexture* t,
62 video::E_MATERIAL_TYPE material_type);
63 Material* getMaterialFor(video::ITexture* t);
64 Material* getMaterialSPM(std::string lay_one_tex_lc,
65 std::string lay_two_tex_lc,
66 const std::string& def_shader_name = "solid");
67 void setAllMaterialFlags(video::ITexture* t,
68 scene::IMeshBuffer *mb);
69 void setAllUntexturedMaterialFlags(scene::IMeshBuffer *mb);
70
71 int addEntity (Material *m);
72 Material *getMaterial (const std::string& t,
73 bool is_full_path=false,
74 bool make_permanent=false,
75 bool complain_if_not_found=true,
76 bool strip_path=true, bool install=true, bool create_if_not_found=true);
77 void addSharedMaterial(const std::string& filename, bool deprecated = false);
78 bool pushTempMaterial (const std::string& filename, bool deprecated = false);
79 bool pushTempMaterial (const XMLNode *root, const std::string& filename, bool deprecated = false);
80 void popTempMaterial ();
82 bool hasMaterial(const std::string& fname);
83
84 void unloadAllTextures();
85
86 Material* getDefaultSPMaterial(const std::string& shader_name,
87 const std::string& layer_one_lc = "",
88 bool full_path = false);
89 Material* getLatestMaterial() { return m_materials[m_materials.size()-1]; }
90}; // MaterialManager
91
92extern MaterialManager *material_manager;
93
94#endif
95
96/* EOF */
Definition: material_manager.hpp:45
~MaterialManager()
Frees all allocated data structures.
Definition: material_manager.cpp:58
void setAllMaterialFlags(video::ITexture *t, scene::IMeshBuffer *mb)
Searches for the material in the given texture, and calls a function in the material to set the irrli...
Definition: material_manager.cpp:205
void makeMaterialsPermanent()
Makes all materials permanent.
Definition: material_manager.cpp:414
Material * getMaterial(const std::string &t, bool is_full_path=false, bool make_permanent=false, bool complain_if_not_found=true, bool strip_path=true, bool install=true, bool create_if_not_found=true)
Returns the material of a given name, if it doesn't exist, it is loaded.
Definition: material_manager.cpp:362
Definition: material.hpp:48
Utility class, you can inherit from this class to disallow the assignment operator and copy construct...
Definition: no_copy.hpp:26
utility class used to parse XML files
Definition: xml_node.hpp:48