OGRE  1.9.0
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 "OgreMaterial.h"
36 #include "OgreStringVector.h"
37 #include "OgreMaterialSerializer.h"
38 #include "OgreHeaderPrefix.h"
39 
40 namespace Ogre {
41 
42 
64  class _OgreExport MaterialManager : public ResourceManager, public Singleton<MaterialManager>
65  {
66  public:
70  class Listener
71  {
72  public:
74  virtual ~Listener() { }
104  virtual Technique* handleSchemeNotFound(unsigned short schemeIndex,
105  const String& schemeName, Material* originalMaterial, unsigned short lodIndex,
106  const Renderable* rend) = 0;
107 
112  virtual bool afterIlluminationPassesCreated(Technique* technique) { return false; }
113 
118  virtual bool beforeIlluminationPassesCleared(Technique* technique) { return false; }
119  };
120 
121  protected:
122 
131 
134 
136  unsigned int mDefaultMaxAniso;
141 
143  Resource* createImpl(const String& name, ResourceHandle handle,
144  const String& group, bool isManual, ManualResourceLoader* loader,
145  const NameValuePairList* params);
146 
154  unsigned short mActiveSchemeIndex;
155 
160 
161  public:
164 
167  MaterialPtr create (const String& name, const String& group,
168  bool isManual = false, ManualResourceLoader* loader = 0,
169  const NameValuePairList* createParams = 0);
170 
173  MaterialPtr getByName(const String& name, const String& groupName = ResourceGroupManager::AUTODETECT_RESOURCE_GROUP_NAME);
174 
177  MaterialManager();
178 
181  virtual ~MaterialManager();
182 
185  void initialise(void);
186 
189  void parseScript(DataStreamPtr& stream, const String& groupName);
190 
191 
198  virtual void setDefaultTextureFiltering(TextureFilterOptions fo);
203  virtual void setDefaultTextureFiltering(FilterType ftype, FilterOptions opts);
208  virtual void setDefaultTextureFiltering(FilterOptions minFilter, FilterOptions magFilter, FilterOptions mipFilter);
209 
211  virtual FilterOptions getDefaultTextureFiltering(FilterType ftype) const;
212 
219  void setDefaultAnisotropy(unsigned int maxAniso);
221  unsigned int getDefaultAnisotropy() const;
222 
253  virtual MaterialPtr getDefaultSettings(void) const { return mDefaultSettings; }
254 
258  virtual unsigned short _getSchemeIndex(const String& name);
262  virtual const String& _getSchemeName(unsigned short index);
266  virtual unsigned short _getActiveSchemeIndex(void) const;
267 
271  virtual const String& getActiveScheme(void) const;
272 
276  virtual void setActiveScheme(const String& schemeName);
277 
282  virtual void addListener(Listener* l, const Ogre::String& schemeName = StringUtil::BLANK);
283 
288  virtual void removeListener(Listener* l, const Ogre::String& schemeName = StringUtil::BLANK);
289 
291  virtual Technique* _arbitrateMissingTechniqueForActiveScheme(
292  Material* mat, unsigned short lodIndex, const Renderable* rend);
293 
295  virtual void _notifyAfterIlluminationPassesCreated(Technique* mat);
296 
298  virtual void _notifyBeforeIlluminationPassesCleared(Technique* mat);
299 
300 
316  static MaterialManager& getSingleton(void);
332  static MaterialManager* getSingletonPtr(void);
333 
334  };
338 }
339 
340 #include "OgreHeaderSuffix.h"
341 
342 #endif
unsigned short mActiveSchemeIndex
Current material scheme.
virtual bool beforeIlluminationPassesCleared(Technique *technique)
Called right before illuminated passes would be removed, so that owner of runtime generated technique...
CompareFunction mDefaultCompareFunction
Abstract class defining the interface all renderable objects must implement.
Class for serializing Materials to / from a .material script.
#define _OgreExport
Definition: OgrePlatform.h:260
TextureFilterOptions
High-level filtering options providing shortcuts to settings the minification, magnification and mip ...
Definition: OgreCommon.h:78
#define OGRE_THREAD_POINTER(T, var)
virtual bool afterIlluminationPassesCreated(Technique *technique)
Called right after illuminated passes were created, so that owner of runtime generated technique can ...
static String DEFAULT_SCHEME_NAME
Default material scheme.
static String AUTODETECT_RESOURCE_GROUP_NAME
Special resource group name which causes resource group to be automatically determined based on searc...
Abstract class representing a loadable resource (e.g.
Definition: OgreResource.h:79
Interface describing a manual resource loader.
Definition: OgreResource.h:514
unsigned long long int ResourceHandle
Definition: OgreResource.h:41
Class for managing Material settings for Ogre.
FilterOptions mDefaultCompare
Default Texture filtering - comparison.
virtual MaterialPtr getDefaultSettings(void) const
Returns a pointer to the default Material settings.
Listener on any general material events.
String mActiveSchemeName
Current material scheme.
map< String, String >::type NameValuePairList
Name / value parameter pair (first = name, second = value)
Definition: OgreCommon.h:550
CompareFunction
Comparison functions used for the depth/stencil buffer operations and others.
Definition: OgreCommon.h:64
SchemeMap mSchemes
List of material schemes.
_StringBase String
virtual ~Listener()
Virtual destructor needed as class has virtual methods.
Defines a generic resource handler.
map< String, unsigned short >::type SchemeMap
Scheme name -> index. Never shrinks! Should be pretty static anyway.
FilterOptions
Filtering options for textures / mipmaps.
Definition: OgreCommon.h:100
Class encapsulates rendering properties of an object.
Definition: OgreMaterial.h:88
FilterOptions mDefaultMinFilter
Default Texture filtering - minification.
FilterOptions mDefaultMagFilter
Default Texture filtering - magnification.
FilterOptions mDefaultMipFilter
Default Texture filtering - mipmapping.
Template class for creating single-instance global classes.
Definition: OgreSingleton.h:64
Class representing an approach to rendering this particular Material.
Definition: OgreTechnique.h:53
map< String, ListenerList >::type ListenerMap
MaterialPtr mDefaultSettings
Default settings.
unsigned int mDefaultMaxAniso
Default Texture anisotropy.
static const String BLANK
Constant blank string, useful for returning by ref where local does not exist.
Definition: OgreString.h:196
list< Listener * >::type ListenerList
The list of per-scheme (and general) material listeners.
FilterType
Definition: OgreCommon.h:90