OgreTechnique.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 __Technique_H__
#define __Technique_H__
#include "OgrePrerequisites.h"
#include "OgreIteratorWrappers.h"
#include "OgreBlendMode.h"
#include "OgreCommon.h"
#include "OgrePass.h"
#include "OgreIteratorWrappers.h"
#include "OgreRenderSystemCapabilities.h"
#include "OgreUserObjectBindings.h"
namespace Ogre {
class _OgreExport Technique : public TechniqueAlloc
{
protected:
enum IlluminationPassesState
{
IPS_COMPILE_DISABLED = -1,
IPS_NOT_COMPILED = 0,
IPS_COMPILED = 1
};
typedef vector<Pass*>::type Passes;
Passes mPasses;
IlluminationPassList mIlluminationPasses;
// Raw pointer since we don't want child to stop parent's destruction
Material* mParent;
bool mIsSupported;
IlluminationPassesState mIlluminationPassesCompilationPhase;
unsigned short mLodIndex;
unsigned short mSchemeIndex;
String mName;
void clearIlluminationPasses(void);
bool checkManuallyOrganisedIlluminationPasses();
MaterialPtr mShadowCasterMaterial;
String mShadowCasterMaterialName;
MaterialPtr mShadowReceiverMaterial;
String mShadowReceiverMaterialName;
// User objects binding.
UserObjectBindings mUserObjectBindings;
public:
enum IncludeOrExclude
{
INCLUDE = 0,
EXCLUDE = 1
};
struct GPUVendorRule
{
GPUVendor vendor;
IncludeOrExclude includeOrExclude;
GPUVendorRule()
: vendor(GPU_UNKNOWN), includeOrExclude(EXCLUDE) {}
GPUVendorRule(GPUVendor v, IncludeOrExclude ie)
: vendor(v), includeOrExclude(ie) {}
};
struct GPUDeviceNameRule
{
String devicePattern;
IncludeOrExclude includeOrExclude;
bool caseSensitive;
GPUDeviceNameRule()
: includeOrExclude(EXCLUDE), caseSensitive(false) {}
GPUDeviceNameRule(const String& pattern, IncludeOrExclude ie, bool caseSen)
: devicePattern(pattern), includeOrExclude(ie), caseSensitive(caseSen) {}
};
typedef vector<GPUVendorRule>::type GPUVendorRuleList;
typedef vector<GPUDeviceNameRule>::type GPUDeviceNameRuleList;
protected:
GPUVendorRuleList mGPUVendorRules;
GPUDeviceNameRuleList mGPUDeviceNameRules;
public:
Technique(Material* parent);
Technique(Material* parent, const Technique& oth);
~Technique();
bool isSupported(void) const;
String _compile(bool autoManageTextureUnits);
bool checkGPURules(StringUtil::StrStreamType& errors);
bool checkHardwareSupport(bool autoManageTextureUnits, StringUtil::StrStreamType& compileErrors);
void _compileIlluminationPasses(void);
size_t calculateSize(void) const;
Pass* createPass(void);
Pass* getPass(unsigned short index);
Pass* getPass(const String& name);
unsigned short getNumPasses(void) const;
void removePass(unsigned short index);
void removeAllPasses(void);
bool movePass(const unsigned short sourceIndex, const unsigned short destinationIndex);
typedef VectorIterator<Passes> PassIterator;
const PassIterator getPassIterator(void);
typedef VectorIterator<IlluminationPassList> IlluminationPassIterator;
const IlluminationPassIterator getIlluminationPassIterator(void);
Material* getParent(void) const { return mParent; }
Technique& operator=(const Technique& rhs);
const String& getResourceGroup(void) const;
bool isTransparent(void) const;
bool isTransparentSortingEnabled(void) const;
bool isTransparentSortingForced(void) const;
void _prepare(void);
void _unprepare(void);
void _load(void);
void _unload(void);
bool isLoaded(void) const;
void _notifyNeedsRecompile(void);
Ogre::MaterialPtr getShadowCasterMaterial() const;
void setShadowCasterMaterial(Ogre::MaterialPtr val);
void setShadowCasterMaterial(const Ogre::String &name);
Ogre::MaterialPtr getShadowReceiverMaterial() const;
void setShadowReceiverMaterial(Ogre::MaterialPtr val);
void setShadowReceiverMaterial(const Ogre::String &name);
// -------------------------------------------------------------------------------
// 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(unsigned 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 setLodIndex(unsigned short index);
unsigned short getLodIndex(void) const { return mLodIndex; }
void setSchemeName(const String& schemeName);
const String& getSchemeName(void) const;
unsigned short _getSchemeIndex(void) const;
bool isDepthWriteEnabled(void) const;
bool isDepthCheckEnabled(void) const;
bool hasColourWriteDisabled(void) const;
void setName(const String& name);
const String& getName(void) const { return mName; }
bool applyTextureAliases(const AliasTextureNamePairList& aliasList, const bool apply = true) const;
void addGPUVendorRule(GPUVendor vendor, IncludeOrExclude includeOrExclude);
void addGPUVendorRule(const GPUVendorRule& rule);
void removeGPUVendorRule(GPUVendor vendor);
typedef ConstVectorIterator<GPUVendorRuleList> GPUVendorRuleIterator;
GPUVendorRuleIterator getGPUVendorRuleIterator() const;
void addGPUDeviceNameRule(const String& devicePattern, IncludeOrExclude includeOrExclude, bool caseSensitive = false);
void addGPUDeviceNameRule(const GPUDeviceNameRule& rule);
void removeGPUDeviceNameRule(const String& devicePattern);
typedef ConstVectorIterator<GPUDeviceNameRuleList> GPUDeviceNameRuleIterator;
GPUDeviceNameRuleIterator getGPUDeviceNameRuleIterator() const;
UserObjectBindings& getUserObjectBindings() { return mUserObjectBindings; }
const UserObjectBindings& getUserObjectBindings() const { return mUserObjectBindings; }
};
}
#endif
Ogre::Technique::GPUVendorRule::includeOrExclude
IncludeOrExclude includeOrExclude
Definition: OgreTechnique.h:127
Ogre::Technique::mIlluminationPassesCompilationPhase
IlluminationPassesState mIlluminationPassesCompilationPhase
Definition: OgreTechnique.h:72
Ogre::VectorIterator
Concrete IteratorWrapper for nonconst access to the underlying container.
Definition: OgreIteratorWrapper.h:186
Ogre::FogMode
FogMode
Fog modes.
Definition: OgreCommon.h:121
Ogre::Pass
Class defining a single pass of a Technique (of a Material), i.e.
Definition: OgrePass.h:80
_OgreExport
#define _OgreExport
Definition: OgrePlatform.h:257
Ogre::Technique::mName
String mName
Optional name for the technique.
Definition: OgreTechnique.h:80
Ogre::TextureFilterOptions
TextureFilterOptions
High-level filtering options providing shortcuts to settings the minification, magnification and mip ...
Definition: OgreCommon.h:78
Ogre::Technique::mPasses
Passes mPasses
List of primary passes.
Definition: OgreTechnique.h:66
Ogre::Technique::getUserObjectBindings
const UserObjectBindings & getUserObjectBindings() const
Return an instance of user objects binding associated with this class.
Definition: OgreTechnique.h:708
Ogre::Technique::mGPUDeviceNameRules
GPUDeviceNameRuleList mGPUDeviceNameRules
Definition: OgreTechnique.h:148
Ogre::Technique::mShadowCasterMaterialName
String mShadowCasterMaterialName
When casting shadow, if not using default Ogre shadow casting material, or nor using fixed function c...
Definition: OgreTechnique.h:97
Ogre::Technique::mGPUVendorRules
GPUVendorRuleList mGPUVendorRules
Definition: OgreTechnique.h:147
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::Technique::getParent
Material * getParent(void) const
Gets the parent Material.
Definition: OgreTechnique.h:207
Ogre::Technique::mIlluminationPasses
IlluminationPassList mIlluminationPasses
List of derived passes, categorised into IlluminationStage (ordered)
Definition: OgreTechnique.h:68
Ogre::StringUtil::StrStreamType
StringStream StrStreamType
Definition: OgreString.h:78
Ogre::Technique::mSchemeIndex
unsigned short mSchemeIndex
Scheme index, derived from scheme name but the names are held on MaterialManager, for speed an index ...
Definition: OgreTechnique.h:78
Ogre::Technique::getName
const String & getName(void) const
Gets the name of the technique.
Definition: OgreTechnique.h:603
Ogre::Technique::IlluminationPassesState
IlluminationPassesState
Illumination pass state type.
Definition: OgreTechnique.h:57
Ogre::Technique::IlluminationPassIterator
VectorIterator< IlluminationPassList > IlluminationPassIterator
Definition: OgreTechnique.h:203
Ogre::Technique::GPUDeviceNameRule::GPUDeviceNameRule
GPUDeviceNameRule()
Definition: OgreTechnique.h:139
Ogre::Technique::GPUDeviceNameRule::caseSensitive
bool caseSensitive
Definition: OgreTechnique.h:138
Ogre::ColourValue::White
static const ColourValue White
Definition: OgreColourValue.h:62
Ogre::IlluminationPassList
vector< IlluminationPass * >::type IlluminationPassList
Definition: OgrePass.h:1872
OgreCommon.h
OgrePass.h
OgreRenderSystemCapabilities.h
Ogre::Technique::Passes
vector< Pass * >::type Passes
Definition: OgreTechnique.h:64
Ogre::Technique::GPUDeviceNameRuleList
vector< GPUDeviceNameRule >::type GPUDeviceNameRuleList
Definition: OgreTechnique.h:145
Ogre::Technique::IncludeOrExclude
IncludeOrExclude
Directive used to manually control technique support based on the inclusion or exclusion of some fact...
Definition: OgreTechnique.h:116
Ogre::Technique::GPUDeviceNameRule::includeOrExclude
IncludeOrExclude includeOrExclude
Definition: OgreTechnique.h:137
OgreUserObjectBindings.h
Ogre::CullingMode
CullingMode
Hardware culling modes based on vertex winding.
Definition: OgreCommon.h:135
OgrePrerequisites.h
Ogre::Technique::GPUDeviceNameRule
Rule controlling whether technique is deemed supported based on GPU device name.
Definition: OgreTechnique.h:134
Ogre::AliasTextureNamePairList
map< String, String >::type AliasTextureNamePairList
Alias / Texture name pair (first = alias, second = texture name)
Definition: OgreCommon.h:553
Ogre::Technique::mParent
Material * mParent
Definition: OgreTechnique.h:70
Ogre::Technique::PassIterator
VectorIterator< Passes > PassIterator
Definition: OgreTechnique.h:200
Ogre::Technique::mShadowCasterMaterial
MaterialPtr mShadowCasterMaterial
When casting shadow, if not using default Ogre shadow casting material, or nor using fixed function c...
Definition: OgreTechnique.h:92
Ogre::Technique::getLodIndex
unsigned short getLodIndex(void) const
Gets the level-of-detail index assigned to this Technique.
Definition: OgreTechnique.h:559
Ogre::CompareFunction
CompareFunction
Comparison functions used for the depth/stencil buffer operations and others.
Definition: OgreCommon.h:64
Ogre::Technique::mUserObjectBindings
UserObjectBindings mUserObjectBindings
Definition: OgreTechnique.h:110
Ogre::Technique::mLodIndex
unsigned short mLodIndex
LOD level.
Definition: OgreTechnique.h:74
Ogre::String
_StringBase String
Definition: OgrePrerequisites.h:439
Ogre::Technique::getUserObjectBindings
UserObjectBindings & getUserObjectBindings()
Return an instance of user objects binding associated with this class.
Definition: OgreTechnique.h:702
Ogre::Technique::GPUVendorRuleIterator
ConstVectorIterator< GPUVendorRuleList > GPUVendorRuleIterator
Definition: OgreTechnique.h:653
Ogre::Technique::mShadowReceiverMaterial
MaterialPtr mShadowReceiverMaterial
When receiving shadow, if not using default Ogre shadow receiving material, or nor using fixed functi...
Definition: OgreTechnique.h:102
Ogre::Technique::mShadowReceiverMaterialName
String mShadowReceiverMaterialName
When receiving shadow, if not using default Ogre shadow receiving material, or nor using fixed functi...
Definition: OgreTechnique.h:107
Ogre::Technique::GPUVendorRule::vendor
GPUVendor vendor
Definition: OgreTechnique.h:126
Ogre::Technique::GPUVendorRule::GPUVendorRule
GPUVendorRule(GPUVendor v, IncludeOrExclude ie)
Definition: OgreTechnique.h:130
Ogre::ManualCullingMode
ManualCullingMode
Manual culling modes based on vertex normals.
Definition: OgreCommon.h:150
Ogre::Technique::GPUVendorRule::GPUVendorRule
GPUVendorRule()
Definition: OgreTechnique.h:128
OgreIteratorWrappers.h
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::FOG_NONE
No fog. Duh.
Definition: OgreCommon.h:124
Ogre::SharedPtr< Material >
Ogre::ConstVectorIterator
Concrete IteratorWrapper for const access to the underlying container.
Definition: OgreIteratorWrapper.h:217
Ogre::vector
Definition: OgrePrerequisites.h:491
Ogre::GPUVendor
GPUVendor
Enumeration of GPU vendors.
Definition: OgreRenderSystemCapabilities.h:252
Ogre::UserObjectBindings
Class that provides convenient interface to establish a linkage between custom user application objec...
Definition: OgreUserObjectBindings.h:49
OgreBlendMode.h
Ogre::Technique
Class representing an approach to rendering this particular Material.
Definition: OgreTechnique.h:53
Ogre::ShadeOptions
ShadeOptions
Light shading modes.
Definition: OgreCommon.h:113
Ogre::Technique::GPUVendorRule
Rule controlling whether technique is deemed supported based on GPU vendor.
Definition: OgreTechnique.h:124
Ogre::Technique::GPUDeviceNameRule::GPUDeviceNameRule
GPUDeviceNameRule(const String &pattern, IncludeOrExclude ie, bool caseSen)
Definition: OgreTechnique.h:141
Ogre::Technique::GPUVendorRuleList
vector< GPUVendorRule >::type GPUVendorRuleList
Definition: OgreTechnique.h:144
Ogre::Technique::GPUDeviceNameRule::devicePattern
String devicePattern
Definition: OgreTechnique.h:136
Ogre::Technique::mIsSupported
bool mIsSupported
Definition: OgreTechnique.h:71
Ogre::AllocatedObject
Superclass for all objects that wish to use custom memory allocators when their new / delete operator...
Definition: OgreMemoryAllocatedObject.h:58
Ogre::Technique::GPUDeviceNameRuleIterator
ConstVectorIterator< GPUDeviceNameRuleList > GPUDeviceNameRuleIterator
Definition: OgreTechnique.h:694
Ogre::GPU_UNKNOWN
Definition: OgreRenderSystemCapabilities.h:254

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