OGRE  2.0
Object-Oriented Graphics Rendering Engine
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
OgreMaterialManager.h
Go to the documentation of this file.
1 /*
2 -----------------------------------------------------------------------------
3 This source file is part of OGRE
4  (Object-oriented Graphics Rendering Engine)
5 For the latest info, see http://www.ogre3d.org/
6 
7 Copyright (c) 2000-2014 Torus Knot Software Ltd
8 
9 Permission is hereby granted, free of charge, to any person obtaining a copy
10 of this software and associated documentation files (the "Software"), to deal
11 in the Software without restriction, including without limitation the rights
12 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 copies of the Software, and to permit persons to whom the Software is
14 furnished to do so, subject to the following conditions:
15 
16 The above copyright notice and this permission notice shall be included in
17 all copies or substantial portions of the Software.
18 
19 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25 THE SOFTWARE.
26 -----------------------------------------------------------------------------
27 */
28 #ifndef __MATERIALMANAGER_H__
29 #define __MATERIALMANAGER_H__
30 
31 #include "OgrePrerequisites.h"
32 
33 #include "OgreSingleton.h"
34 #include "OgreResourceManager.h"
35 #include "OgreHeaderPrefix.h"
36 
37 namespace Ogre {
38 
39  class MaterialSerializer;
40 
41 
63  class _OgreExport MaterialManager : public ResourceManager, public Singleton<MaterialManager>
64  {
65  public:
69  class Listener
70  {
71  public:
73  virtual ~Listener() { }
103  virtual Technique* handleSchemeNotFound(unsigned short schemeIndex,
104  const String& schemeName, Material* originalMaterial, unsigned short lodIndex,
105  const Renderable* rend) = 0;
106 
107  };
108 
109  protected:
110 
119 
122 
124  unsigned int mDefaultMaxAniso;
129 
131  Resource* createImpl(const String& name, ResourceHandle handle,
132  const String& group, bool isManual, ManualResourceLoader* loader,
133  const NameValuePairList* params);
134 
142  unsigned short mActiveSchemeIndex;
143 
148 
149  public:
152 
155  MaterialPtr create (const String& name, const String& group,
156  bool isManual = false, ManualResourceLoader* loader = 0,
157  const NameValuePairList* createParams = 0);
158 
161  MaterialPtr getByName(const String& name, const String& groupName = ResourceGroupManager::AUTODETECT_RESOURCE_GROUP_NAME);
162 
165  MaterialManager();
166 
169  virtual ~MaterialManager();
170 
173  void initialise(void);
174 
177  void parseScript(DataStreamPtr& stream, const String& groupName);
178 
179 
186  virtual void setDefaultTextureFiltering(TextureFilterOptions fo);
191  virtual void setDefaultTextureFiltering(FilterType ftype, FilterOptions opts);
196  virtual void setDefaultTextureFiltering(FilterOptions minFilter, FilterOptions magFilter, FilterOptions mipFilter);
197 
199  virtual FilterOptions getDefaultTextureFiltering(FilterType ftype) const;
200 
207  void setDefaultAnisotropy(unsigned int maxAniso);
209  unsigned int getDefaultAnisotropy() const;
210 
241  virtual MaterialPtr getDefaultSettings(void) const { return mDefaultSettings; }
242 
246  virtual unsigned short _getSchemeIndex(const String& name);
250  virtual const String& _getSchemeName(unsigned short index);
254  virtual unsigned short _getActiveSchemeIndex(void) const;
255 
259  virtual const String& getActiveScheme(void) const;
260 
264  virtual void setActiveScheme(const String& schemeName);
265 
270  virtual void addListener(Listener* l, const Ogre::String& schemeName = BLANKSTRING);
271 
276  virtual void removeListener(Listener* l, const Ogre::String& schemeName = BLANKSTRING);
277 
279  virtual Technique* _arbitrateMissingTechniqueForActiveScheme(
280  Material* mat, unsigned short lodIndex, const Renderable* rend);
281 
297  static MaterialManager& getSingleton(void);
313  static MaterialManager* getSingletonPtr(void);
314 
315  };
319 }
320 
321 #include "OgreHeaderSuffix.h"
322 
323 #endif
#define _OgreExport
Definition: OgrePlatform.h:255
Listener on any general material events.
String mActiveSchemeName
Current material scheme.
#define OGRE_THREAD_POINTER(T, var)
map< String, String >::type NameValuePairList
Name / value parameter pair (first = name, second = value)
Definition: OgreCommon.h:580
Template class for creating single-instance global classes.
Definition: OgreSingleton.h:64
static String AUTODETECT_RESOURCE_GROUP_NAME
Special resource group name which causes resource group to be automatically determined based on searc...
map< String, ListenerList >::type ListenerMap
Class encapsulates rendering properties of an object.
Definition: OgreMaterial.h:84
FilterType
Definition: OgreCommon.h:121
Interface describing a manual resource loader.
Definition: OgreResource.h:498
FilterOptions mDefaultMipFilter
Default Texture filtering - mipmapping.
map< String, unsigned short >::type SchemeMap
Scheme name -> index. Never shrinks! Should be pretty static anyway.
Class representing an approach to rendering this particular Material.
Definition: OgreTechnique.h:50
MaterialPtr mDefaultSettings
Default settings.
FilterOptions mDefaultMinFilter
Default Texture filtering - minification.
const String BLANKSTRING
Constant blank string, useful for returning by ref where local does not exist.
Definition: OgreCommon.h:574
Abstract class defining the interface all renderable objects must implement.
Class for managing Material settings for Ogre.
Class for serializing Materials to / from a .material script.
unsigned short mActiveSchemeIndex
Current material scheme.
FilterOptions mDefaultCompare
Default Texture filtering - comparison.
unsigned int mDefaultMaxAniso
Default Texture anisotropy.
FilterOptions mDefaultMagFilter
Default Texture filtering - magnification.
Abstract class representing a loadable resource (e.g.
Definition: OgreResource.h:77
unsigned long long int ResourceHandle
Definition: OgreResource.h:39
virtual ~Listener()
Virtual destructor needed as class has virtual methods.
Defines a generic resource handler.
_StringBase String
Definition: OgreCommon.h:53
static String DEFAULT_SCHEME_NAME
Default material scheme.
list< Listener * >::type ListenerList
The list of per-scheme (and general) material listeners.
SchemeMap mSchemes
List of material schemes.
FilterOptions
Filtering options for textures / mipmaps.
Definition: OgreCommon.h:131
CompareFunction mDefaultCompareFunction
CompareFunction
Comparison functions used for the depth/stencil buffer operations and others.
Definition: OgreCommon.h:74
virtual MaterialPtr getDefaultSettings(void) const
Returns a pointer to the default Material settings.
TextureFilterOptions
High-level filtering options providing shortcuts to settings the minification, magnification and mip ...
Definition: OgreCommon.h:109