OgreMaterialManager.h
Go to the documentation of this file.
1/*
2-----------------------------------------------------------------------------
3This source file is part of OGRE
4 (Object-oriented Graphics Rendering Engine)
5For the latest info, see http://www.ogre3d.org/
6
7Copyright (c) 2000-2013 Torus Knot Software Ltd
8
9Permission is hereby granted, free of charge, to any person obtaining a copy
10of this software and associated documentation files (the "Software"), to deal
11in the Software without restriction, including without limitation the rights
12to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13copies of the Software, and to permit persons to whom the Software is
14furnished to do so, subject to the following conditions:
15
16The above copyright notice and this permission notice shall be included in
17all copies or substantial portions of the Software.
18
19THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25THE 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"
38#include "OgreHeaderPrefix.h"
39
40namespace Ogre {
41
42
64 class _OgreExport MaterialManager : public ResourceManager, public Singleton<MaterialManager>
65 {
66 public:
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
108 };
109
110 protected:
111
120
123
125 unsigned int mDefaultMaxAniso;
130
133 const String& group, bool isManual, ManualResourceLoader* loader,
134 const NameValuePairList* params);
135
143 unsigned short mActiveSchemeIndex;
144
149
150 public:
153
156 MaterialPtr create (const String& name, const String& group,
157 bool isManual = false, ManualResourceLoader* loader = 0,
158 const NameValuePairList* createParams = 0);
159
163
167
171
174 void initialise(void);
175
178 void parseScript(DataStreamPtr& stream, const String& groupName);
179
180
197 virtual void setDefaultTextureFiltering(FilterOptions minFilter, FilterOptions magFilter, FilterOptions mipFilter);
198
201
208 void setDefaultAnisotropy(unsigned int maxAniso);
210 unsigned int getDefaultAnisotropy() const;
211
242 virtual MaterialPtr getDefaultSettings(void) const { return mDefaultSettings; }
243
247 virtual unsigned short _getSchemeIndex(const String& name);
251 virtual const String& _getSchemeName(unsigned short index);
255 virtual unsigned short _getActiveSchemeIndex(void) const;
256
260 virtual const String& getActiveScheme(void) const;
261
265 virtual void setActiveScheme(const String& schemeName);
266
271 virtual void addListener(Listener* l, const Ogre::String& schemeName = StringUtil::BLANK);
272
277 virtual void removeListener(Listener* l, const Ogre::String& schemeName = StringUtil::BLANK);
278
281 Material* mat, unsigned short lodIndex, const Renderable* rend);
282
315
316 };
320}
321
322#include "OgreHeaderSuffix.h"
323
324#endif
#define _OgreExport
Definition: OgrePlatform.h:257
Interface describing a manual resource loader.
Definition: OgreResource.h:515
Listener on any general material events.
virtual ~Listener()
Virtual destructor needed as class has virtual methods.
virtual Technique * handleSchemeNotFound(unsigned short schemeIndex, const String &schemeName, Material *originalMaterial, unsigned short lodIndex, const Renderable *rend)=0
Called if a technique for a given scheme is not found within a material, allows the application to sp...
Class for managing Material settings for Ogre.
String mActiveSchemeName
Current material scheme.
virtual unsigned short _getActiveSchemeIndex(void) const
Internal method - returns the active scheme index.
void setDefaultAnisotropy(unsigned int maxAniso)
Sets the default anisotropy level to be used for loaded textures, for when textures are loaded automa...
map< String, ListenerList >::type ListenerMap
static String DEFAULT_SCHEME_NAME
Default material scheme.
MaterialPtr create(const String &name, const String &group, bool isManual=false, ManualResourceLoader *loader=0, const NameValuePairList *createParams=0)
Create a new material.
FilterOptions mDefaultMipFilter
Default Texture filtering - mipmapping.
void initialise(void)
Initialises the material manager, which also triggers it to parse all available .program and ....
virtual const String & getActiveScheme(void) const
Returns the name of the active material scheme.
FilterOptions mDefaultMagFilter
Default Texture filtering - magnification.
virtual const String & _getSchemeName(unsigned short index)
Internal method - returns name for a given material scheme index.
virtual void removeListener(Listener *l, const Ogre::String &schemeName=StringUtil::BLANK)
Remove a listener handling material events.
static MaterialManager * getSingletonPtr(void)
Override standard Singleton retrieval.
unsigned short mActiveSchemeIndex
Current material scheme.
CompareFunction mDefaultCompareFunction
virtual void setDefaultTextureFiltering(FilterType ftype, FilterOptions opts)
Sets the default texture filtering to be used for loaded textures, for when textures are loaded autom...
map< String, unsignedshort >::type SchemeMap
Scheme name -> index. Never shrinks! Should be pretty static anyway.
void parseScript(DataStreamPtr &stream, const String &groupName)
virtual Technique * _arbitrateMissingTechniqueForActiveScheme(Material *mat, unsigned short lodIndex, const Renderable *rend)
Internal method for sorting out missing technique for a scheme.
MaterialPtr getByName(const String &name, const String &groupName=ResourceGroupManager::AUTODETECT_RESOURCE_GROUP_NAME)
Get a resource by name.
virtual void setActiveScheme(const String &schemeName)
Sets the name of the active material scheme.
virtual void setDefaultTextureFiltering(TextureFilterOptions fo)
Sets the default texture filtering to be used for loaded textures, for when textures are loaded autom...
unsigned int getDefaultAnisotropy() const
Get the default maxAnisotropy.
SchemeMap mSchemes
List of material schemes.
virtual ~MaterialManager()
Default destructor.
MaterialPtr mDefaultSettings
Default settings.
virtual MaterialPtr getDefaultSettings(void) const
Returns a pointer to the default Material settings.
virtual void addListener(Listener *l, const Ogre::String &schemeName=StringUtil::BLANK)
Add a listener to handle material events.
list< Listener * >::type ListenerList
The list of per-scheme (and general) material listeners.
OGRE_THREAD_POINTER(MaterialSerializer, mSerializer)
Serializer - Hold instance per thread if necessary.
FilterOptions mDefaultMinFilter
Default Texture filtering - minification.
virtual void setDefaultTextureFiltering(FilterOptions minFilter, FilterOptions magFilter, FilterOptions mipFilter)
Sets the default texture filtering to be used for loaded textures, for when textures are loaded autom...
unsigned int mDefaultMaxAniso
Default Texture anisotropy.
static MaterialManager & getSingleton(void)
Override standard Singleton retrieval.
virtual unsigned short _getSchemeIndex(const String &name)
Internal method - returns index for a given material scheme name.
MaterialManager()
Default constructor.
virtual FilterOptions getDefaultTextureFiltering(FilterType ftype) const
Get the default texture filtering.
Resource * createImpl(const String &name, ResourceHandle handle, const String &group, bool isManual, ManualResourceLoader *loader, const NameValuePairList *params)
Overridden from ResourceManager.
FilterOptions mDefaultCompare
Default Texture filtering - comparison.
Class for serializing Materials to / from a .material script.
Class encapsulates rendering properties of an object.
Definition: OgreMaterial.h:89
Abstract class defining the interface all renderable objects must implement.
static String AUTODETECT_RESOURCE_GROUP_NAME
Special resource group name which causes resource group to be automatically determined based on searc...
Defines a generic resource handler.
Abstract class representing a loadable resource (e.g.
Definition: OgreResource.h:80
Template class for creating single-instance global classes.
Definition: OgreSingleton.h:65
static const String BLANK
Constant blank string, useful for returning by ref where local does not exist.
Definition: OgreString.h:196
Class representing an approach to rendering this particular Material.
Definition: OgreTechnique.h:54
CompareFunction
Comparison functions used for the depth/stencil buffer operations and others.
Definition: OgreCommon.h:65
FilterOptions
Filtering options for textures / mipmaps.
Definition: OgreCommon.h:101
map< String, String >::type NameValuePairList
Name / value parameter pair (first = name, second = value)
Definition: OgreCommon.h:550
TextureFilterOptions
High-level filtering options providing shortcuts to settings the minification, magnification and mip ...
Definition: OgreCommon.h:79
FilterType
Definition: OgreCommon.h:91
unsigned long long int ResourceHandle
Definition: OgreResource.h:41
_StringBase String
std::map< K, V, P, A > type

Copyright © 2012 Torus Knot Software Ltd
Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.