OgreMaterial.h
Go to the documentation of this file.
/*
-----------------------------------------------------------------------------
This source file is part of OGRE
(Object-oriented Graphics Rendering Engine)
For the latest info, see http://www.ogre3d.org/
Copyright (c) 2000-2013 Torus Knot Software Ltd
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
-----------------------------------------------------------------------------
*/
#ifndef _Material_H__
#define _Material_H__
#include "OgrePrerequisites.h"
#include "OgreResource.h"
#include "OgreIteratorWrappers.h"
#include "OgreCommon.h"
#include "OgreColourValue.h"
#include "OgreBlendMode.h"
#include "OgreHeaderPrefix.h"
namespace Ogre {
// Forward declaration
class LodStrategy;
class _OgreExport Material : public Resource
{
friend class SceneManager;
friend class MaterialManager;
public:
typedef vector<Real>::type LodValueList;
typedef ConstVectorIterator<LodValueList> LodValueIterator;
protected:
void applyDefaults(void);
typedef vector<Technique*>::type Techniques;
Techniques mTechniques;
Techniques mSupportedTechniques;
typedef map<unsigned short, Technique*>::type LodTechniques;
typedef map<unsigned short, LodTechniques*>::type BestTechniquesBySchemeList;
BestTechniquesBySchemeList mBestTechniquesBySchemeList;
LodValueList mUserLodValues;
LodValueList mLodValues;
const LodStrategy *mLodStrategy;
bool mReceiveShadows;
bool mTransparencyCastsShadows;
bool mCompilationRequired;
String mUnsupportedReasons;
void insertSupportedTechnique(Technique* t);
void clearBestTechniqueList(void);
void prepareImpl(void);
void unprepareImpl(void);
void loadImpl(void);
void unloadImpl(void);
size_t calculateSize(void) const;
public:
Material(ResourceManager* creator, const String& name, ResourceHandle handle,
const String& group, bool isManual = false, ManualResourceLoader* loader = 0);
~Material();
Material& operator=( const Material& rhs );
bool isTransparent(void) const;
void setReceiveShadows(bool enabled) { mReceiveShadows = enabled; }
bool getReceiveShadows(void) const { return mReceiveShadows; }
void setTransparencyCastsShadows(bool enabled) { mTransparencyCastsShadows = enabled; }
bool getTransparencyCastsShadows(void) const { return mTransparencyCastsShadows; }
Technique* createTechnique(void);
Technique* getTechnique(unsigned short index);
Technique* getTechnique(const String& name);
unsigned short getNumTechniques(void) const;
void removeTechnique(unsigned short index);
void removeAllTechniques(void);
typedef VectorIterator<Techniques> TechniqueIterator;
TechniqueIterator getTechniqueIterator(void);
TechniqueIterator getSupportedTechniqueIterator(void);
Technique* getSupportedTechnique(unsigned short index);
unsigned short getNumSupportedTechniques(void) const;
const String& getUnsupportedTechniquesExplanation() const { return mUnsupportedReasons; }
unsigned short getNumLodLevels(unsigned short schemeIndex) const;
unsigned short getNumLodLevels(const String& schemeName) const;
Technique* getBestTechnique(unsigned short lodIndex = 0, const Renderable* rend = 0);
MaterialPtr clone(const String& newName, bool changeGroup = false,
const String& newGroup = StringUtil::BLANK) const;
void copyDetailsTo(MaterialPtr& mat) const;
void compile(bool autoManageTextureUnits = true);
// -------------------------------------------------------------------------------
// The following methods are to make migration from previous versions simpler
// and to make code easier to write when dealing with simple materials
// They set the properties which have been moved to Pass for all Techniques and all Passes
void setPointSize(Real ps);
void setAmbient(Real red, Real green, Real blue);
void setAmbient(const ColourValue& ambient);
void setDiffuse(Real red, Real green, Real blue, Real alpha);
void setDiffuse(const ColourValue& diffuse);
void setSpecular(Real red, Real green, Real blue, Real alpha);
void setSpecular(const ColourValue& specular);
void setShininess(Real val);
void setSelfIllumination(Real red, Real green, Real blue);
void setSelfIllumination(const ColourValue& selfIllum);
void setDepthCheckEnabled(bool enabled);
void setDepthWriteEnabled(bool enabled);
void setDepthFunction( CompareFunction func );
void setColourWriteEnabled(bool enabled);
void setCullingMode( CullingMode mode );
void setManualCullingMode( ManualCullingMode mode );
void setLightingEnabled(bool enabled);
void setShadingMode( ShadeOptions mode );
void setFog(
bool overrideScene,
FogMode mode = FOG_NONE,
const ColourValue& colour = ColourValue::White,
Real expDensity = 0.001, Real linearStart = 0.0, Real linearEnd = 1.0 );
void setDepthBias(float constantBias, float slopeScaleBias);
void setTextureFiltering(TextureFilterOptions filterType);
void setTextureAnisotropy(int maxAniso);
void setSceneBlending( const SceneBlendType sbt );
void setSeparateSceneBlending( const SceneBlendType sbt, const SceneBlendType sbta );
void setSceneBlending( const SceneBlendFactor sourceFactor, const SceneBlendFactor destFactor);
void setSeparateSceneBlending( const SceneBlendFactor sourceFactor, const SceneBlendFactor destFactor, const SceneBlendFactor sourceFactorAlpha, const SceneBlendFactor destFactorAlpha);
void _notifyNeedsRecompile(void);
void setLodLevels(const LodValueList& lodValues);
LodValueIterator getLodValueIterator(void) const;
LodValueIterator getUserLodValueIterator(void) const;
ushort getLodIndex(Real value) const;
const LodStrategy *getLodStrategy() const;
void setLodStrategy(LodStrategy *lodStrategy);
void touch(void)
{
if (mCompilationRequired)
compile();
// call superclass
Resource::touch();
}
bool applyTextureAliases(const AliasTextureNamePairList& aliasList, const bool apply = true) const;
bool getCompilationRequired() const
{
return mCompilationRequired;
}
};
} //namespace
#include "OgreHeaderSuffix.h"
#endif
Ogre::VectorIterator
Concrete IteratorWrapper for nonconst access to the underlying container.
Definition: OgreIteratorWrapper.h:186
Ogre::Material::setTransparencyCastsShadows
void setTransparencyCastsShadows(bool enabled)
Sets whether objects using this material be classified as opaque to the shadow caster system...
Definition: OgreMaterial.h:195
Ogre::FogMode
FogMode
Fog modes.
Definition: OgreCommon.h:121
Ogre::Renderable
Abstract class defining the interface all renderable objects must implement.
Definition: OgreRenderable.h:63
_OgreExport
#define _OgreExport
Definition: OgrePlatform.h:257
OgreResource.h
Ogre::LodStrategy
Strategy for determining level of detail.
Definition: OgreLodStrategy.h:54
Ogre::TextureFilterOptions
TextureFilterOptions
High-level filtering options providing shortcuts to settings the minification, magnification and mip ...
Definition: OgreCommon.h:78
Ogre::Material::BestTechniquesBySchemeList
map< unsigned short, LodTechniques * >::type BestTechniquesBySchemeList
Definition: OgreMaterial.h:110
Ogre::Material::mUserLodValues
LodValueList mUserLodValues
Definition: OgreMaterial.h:117
Ogre::Material::LodValueList
vector< Real >::type LodValueList
distance list used to specify LOD
Definition: OgreMaterial.h:95
Ogre::ColourValue
Class representing colour.
Definition: OgreColourValue.h:57
Ogre::Real
float Real
Software floating point type.
Definition: OgrePrerequisites.h:70
Ogre::SceneBlendType
SceneBlendType
Types of blending that you can specify between an object and the existing contents of the scene...
Definition: OgreBlendMode.h:215
Ogre::Material::mTechniques
Techniques mTechniques
All techniques, supported and unsupported.
Definition: OgreMaterial.h:106
Ogre::Resource
Abstract class representing a loadable resource (e.g.
Definition: OgreResource.h:79
Ogre::Material::mLodValues
LodValueList mLodValues
Definition: OgreMaterial.h:118
Ogre::ManualResourceLoader
Interface describing a manual resource loader.
Definition: OgreResource.h:514
Ogre::Material::Techniques
vector< Technique * >::type Techniques
Definition: OgreMaterial.h:104
Ogre::ResourceHandle
unsigned long long int ResourceHandle
Definition: OgreResource.h:41
Ogre::MaterialManager
Class for managing Material settings for Ogre.
Definition: OgreMaterialManager.h:64
Ogre::Material::mBestTechniquesBySchemeList
BestTechniquesBySchemeList mBestTechniquesBySchemeList
Map of scheme -> list of LOD techniques.
Definition: OgreMaterial.h:115
Ogre::ColourValue::White
static const ColourValue White
Definition: OgreColourValue.h:62
OgreCommon.h
Ogre::CullingMode
CullingMode
Hardware culling modes based on vertex winding.
Definition: OgreCommon.h:135
OgrePrerequisites.h
Ogre::map::type
std::map< K, V, P, A > type
Definition: OgrePrerequisites.h:536
Ogre::Material::mUnsupportedReasons
String mUnsupportedReasons
Text description of why any techniques are not supported.
Definition: OgreMaterial.h:125
Ogre::AliasTextureNamePairList
map< String, String >::type AliasTextureNamePairList
Alias / Texture name pair (first = alias, second = texture name)
Definition: OgreCommon.h:553
Ogre::Material::TechniqueIterator
VectorIterator< Techniques > TechniqueIterator
Definition: OgreMaterial.h:226
Ogre::Material::LodValueIterator
ConstVectorIterator< LodValueList > LodValueIterator
Definition: OgreMaterial.h:96
Ogre::Material::touch
void touch(void)
&#39;Touches&#39; the resource to indicate it has been used.
Definition: OgreMaterial.h:649
Ogre::CompareFunction
CompareFunction
Comparison functions used for the depth/stencil buffer operations and others.
Definition: OgreCommon.h:64
Ogre::String
_StringBase String
Definition: OgrePrerequisites.h:439
Ogre::Material::getUnsupportedTechniquesExplanation
const String & getUnsupportedTechniquesExplanation() const
Gets a string explaining why any techniques are not supported.
Definition: OgreMaterial.h:242
OgreHeaderSuffix.h
Ogre::Material::mLodStrategy
const LodStrategy * mLodStrategy
Definition: OgreMaterial.h:119
Ogre::ManualCullingMode
ManualCullingMode
Manual culling modes based on vertex normals.
Definition: OgreCommon.h:150
Ogre::Material::getCompilationRequired
bool getCompilationRequired() const
Gets the compilation status of the material.
Definition: OgreMaterial.h:673
Ogre::ResourceManager
Defines a generic resource handler.
Definition: OgreResourceManager.h:122
Ogre::Resource::touch
virtual void touch(void)
&#39;Touches&#39; the resource to indicate it has been used.
OgreIteratorWrappers.h
Ogre::Material::mCompilationRequired
bool mCompilationRequired
Does this material require compilation?
Definition: OgreMaterial.h:123
Ogre::SceneBlendFactor
SceneBlendFactor
Blending factors for manually blending objects with the scene.
Definition: OgreBlendMode.h:234
Ogre
Definition: OgreAndroidLogListener.h:34
Ogre::Material
Class encapsulates rendering properties of an object.
Definition: OgreMaterial.h:88
Ogre::Material::mReceiveShadows
bool mReceiveShadows
Definition: OgreMaterial.h:120
Ogre::Material::mSupportedTechniques
Techniques mSupportedTechniques
Supported techniques of any sort.
Definition: OgreMaterial.h:108
Ogre::FOG_NONE
No fog. Duh.
Definition: OgreCommon.h:124
Ogre::SharedPtr< Material >
Ogre::Material::getTransparencyCastsShadows
bool getTransparencyCastsShadows(void) const
Returns whether or not objects using this material be classified as opaque to the shadow caster syste...
Definition: OgreMaterial.h:197
Ogre::ConstVectorIterator
Concrete IteratorWrapper for const access to the underlying container.
Definition: OgreIteratorWrapper.h:217
Ogre::vector
Definition: OgrePrerequisites.h:491
OgreColourValue.h
OgreHeaderPrefix.h
OgreBlendMode.h
Ogre::Material::mTransparencyCastsShadows
bool mTransparencyCastsShadows
Definition: OgreMaterial.h:121
Ogre::Technique
Class representing an approach to rendering this particular Material.
Definition: OgreTechnique.h:53
Ogre::map
Definition: OgrePrerequisites.h:533
Ogre::ushort
unsigned short ushort
Definition: OgrePrerequisites.h:113
Ogre::ShadeOptions
ShadeOptions
Light shading modes.
Definition: OgreCommon.h:113
Ogre::Material::LodTechniques
map< unsigned short, Technique * >::type LodTechniques
Definition: OgreMaterial.h:109
Ogre::SceneManager
Manages the organisation and rendering of a &#39;scene&#39; i.e.
Definition: OgreSceneManager.h:143
Ogre::StringUtil::BLANK
static const String BLANK
Constant blank string, useful for returning by ref where local does not exist.
Definition: OgreString.h:196
Ogre::Material::setReceiveShadows
void setReceiveShadows(bool enabled)
Sets whether objects using this material will receive shadows.
Definition: OgreMaterial.h:183
Ogre::Material::getReceiveShadows
bool getReceiveShadows(void) const
Returns whether or not objects using this material will receive shadows.
Definition: OgreMaterial.h:185

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