00001 /* 00002 ----------------------------------------------------------------------------- 00003 This source file is part of OGRE 00004 (Object-oriented Graphics Rendering Engine) 00005 For the latest info, see http://ogre.sourceforge.net/ 00006 00007 Copyright © 2000-2002 The OGRE Team 00008 Also see acknowledgements in Readme.html 00009 00010 This program is free software; you can redistribute it and/or modify it under 00011 the terms of the GNU Lesser General Public License as published by the Free Software 00012 Foundation; either version 2 of the License, or (at your option) any later 00013 version. 00014 00015 This program is distributed in the hope that it will be useful, but WITHOUT 00016 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 00017 FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. 00018 00019 You should have received a copy of the GNU Lesser General Public License along with 00020 this program; if not, write to the Free Software Foundation, Inc., 59 Temple 00021 Place - Suite 330, Boston, MA 02111-1307, USA, or go to 00022 http://www.gnu.org/copyleft/lesser.txt. 00023 ----------------------------------------------------------------------------- 00024 */ 00025 #ifndef __MATERIALMANAGER_H__ 00026 #define __MATERIALMANAGER_H__ 00027 00028 #include "OgrePrerequisites.h" 00029 00030 #include "OgreSingleton.h" 00031 #include "OgreResourceManager.h" 00032 #include "OgreMaterial.h" 00033 #include "OgreStringVector.h" 00034 00035 namespace Ogre { 00036 00038 typedef void (*MATERIAL_ATTRIB_PARSER)(StringVector::iterator&, int, Material*); 00040 typedef void (*TEXLAYER_ATTRIB_PARSER)(StringVector::iterator&, int, Material*, Material::TextureLayer*); 00041 00057 class _OgreExport MaterialManager : public ResourceManager, public Singleton<MaterialManager> 00058 { 00059 protected: 00060 void parseNewTextureLayer( DataChunk& chunk, Material* pMat ); 00061 void parseAttrib( const String& line, Material* pMat); 00062 void parseLayerAttrib( const String& line, Material* pMat, Material::TextureLayer* pLayer ); 00063 00065 //typedef std::map<String, MATERIAL_ATTRIB_PARSER> MatAttribParserList; 00066 typedef std::map<String, MATERIAL_ATTRIB_PARSER> MatAttribParserList; 00067 MatAttribParserList mMatAttribParsers; 00069 typedef std::map<String, TEXLAYER_ATTRIB_PARSER> LayerAttribParserList; 00070 //typedef HashMap<String, TEXLAYER_ATTRIB_PARSER, std::hash<String>> LayerAttribParserList; 00071 LayerAttribParserList mLayerAttribParsers; 00072 00073 typedef HashMap<int, Material*> MaterialHandleList; 00074 00076 MaterialHandleList mHandles; 00077 00078 00079 public: 00082 MaterialManager(); 00083 00086 virtual ~MaterialManager(); 00087 00097 Material* add(const Material& mat); 00098 00099 00106 Material* getByHandle(int handle); 00107 00110 void parseScript(DataChunk& chunk); 00111 00114 void parseAllSources(const String& extension = ".material"); 00115 00118 Resource* create( const String& name ); 00119 00123 Material* createDeferred( const String& name ); 00124 00136 static MaterialManager& getSingleton(void); 00137 }; 00138 00139 } 00140 00141 #endif
Copyright © 2002 by The OGRE Team