OGRE  2.0
Object-Oriented Graphics Rendering Engine
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
OgreTechnique.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 __Technique_H__
29 #define __Technique_H__
30 
31 #include "OgrePrerequisites.h"
32 #include "OgreCommon.h"
33 #include "OgrePass.h"
35 #include "OgreUserObjectBindings.h"
36 
37 namespace Ogre {
51  {
52  protected:
55  {
56  IPS_COMPILE_DISABLED = -1,
57  IPS_NOT_COMPILED = 0,
58  IPS_COMPILED = 1
59  };
60 
66  // Raw pointer since we don't want child to stop parent's destruction
71  unsigned short mLodIndex;
75  unsigned short mSchemeIndex;
78 
80  void clearIlluminationPasses(void);
82  bool checkManuallyOrganisedIlluminationPasses();
83 
84 
95 
96  // User objects binding.
98 
99  public:
104  {
106  INCLUDE = 0,
108  EXCLUDE = 1
109  };
112  {
116  : vendor(GPU_UNKNOWN), includeOrExclude(EXCLUDE) {}
118  : vendor(v), includeOrExclude(ie) {}
119  };
122  {
127  : includeOrExclude(EXCLUDE), caseSensitive(false) {}
128  GPUDeviceNameRule(const String& pattern, IncludeOrExclude ie, bool caseSen)
129  : devicePattern(pattern), includeOrExclude(ie), caseSensitive(caseSen) {}
130  };
133  protected:
136  public:
138  Technique(Material* parent);
140  Technique(Material* parent, const Technique& oth);
141  ~Technique();
147  bool isSupported(void) const;
151  String _compile(bool autoManageTextureUnits);
153  bool checkGPURules(StringStream& errors);
155  bool checkHardwareSupport(bool autoManageTextureUnits, StringStream& compileErrors);
157  void _compileIlluminationPasses(void);
158  size_t calculateSize(void) const;
159 
170  Pass* createPass(void);
172  Pass* getPass(unsigned short index);
176  Pass* getPass(const String& name);
178  unsigned short getNumPasses(void) const;
180  void removePass(unsigned short index);
182  void removeAllPasses(void);
186  bool movePass(const unsigned short sourceIndex, const unsigned short destinationIndex);
189  const PassIterator getPassIterator(void);
192  const IlluminationPassIterator getIlluminationPassIterator(void);
194  Material* getParent(void) const { return mParent; }
195 
197  Technique& operator=(const Technique& rhs);
198 
200  const String& getResourceGroup(void) const;
201 
210  bool isTransparent(void) const;
211 
217  bool isTransparentSortingEnabled(void) const;
218 
224  bool isTransparentSortingForced(void) const;
225 
227  void _prepare(void);
229  void _unprepare(void);
231  void _load(void);
233  void _unload(void);
234 
236  bool isLoaded(void) const;
237 
239  void _notifyNeedsRecompile(void);
240 
243  Ogre::MaterialPtr getShadowCasterMaterial() const;
246  void setShadowCasterMaterial(Ogre::MaterialPtr val);
249  void setShadowCasterMaterial(const Ogre::String &name);
250 
251  // -------------------------------------------------------------------------------
252  // The following methods are to make migration from previous versions simpler
253  // and to make code easier to write when dealing with simple materials
254  // They set the properties which have been moved to Pass for all Techniques and all Passes
255 
264  void setPointSize(Real ps);
265 
274  void setAmbient(Real red, Real green, Real blue);
275 
284  void setAmbient(const ColourValue& ambient);
285 
294  void setDiffuse(Real red, Real green, Real blue, Real alpha);
295 
304  void setDiffuse(const ColourValue& diffuse);
305 
314  void setSpecular(Real red, Real green, Real blue, Real alpha);
315 
324  void setSpecular(const ColourValue& specular);
325 
334  void setShininess(Real val);
335 
344  void setSelfIllumination(Real red, Real green, Real blue);
345 
354  void setSelfIllumination(const ColourValue& selfIllum);
355 
364  void setDepthCheckEnabled(bool enabled);
365 
374  void setDepthWriteEnabled(bool enabled);
375 
384  void setDepthFunction( CompareFunction func );
385 
394  void setColourWriteEnabled(bool enabled);
395 
404  void setCullingMode( CullingMode mode );
405 
414  void setManualCullingMode( ManualCullingMode mode );
415 
424  void setLightingEnabled(bool enabled);
425 
434  void setShadingMode( ShadeOptions mode );
435 
444  void setFog(
445  bool overrideScene,
446  FogMode mode = FOG_NONE,
447  const ColourValue& colour = ColourValue::White,
448  Real expDensity = 0.001, Real linearStart = 0.0, Real linearEnd = 1.0 );
449 
458  void setDepthBias(float constantBias, float slopeScaleBias);
459 
468  void setTextureFiltering(TextureFilterOptions filterType);
477  void setTextureAnisotropy(unsigned int maxAniso);
478 
487  void setSceneBlending( const SceneBlendType sbt );
488 
497  void setSeparateSceneBlending( const SceneBlendType sbt, const SceneBlendType sbta );
498 
507  void setSceneBlending( const SceneBlendFactor sourceFactor, const SceneBlendFactor destFactor);
508 
517  void setSeparateSceneBlending( const SceneBlendFactor sourceFactor, const SceneBlendFactor destFactor, const SceneBlendFactor sourceFactorAlpha, const SceneBlendFactor destFactorAlpha);
518 
535  void setLodIndex(unsigned short index);
537  unsigned short getLodIndex(void) const { return mLodIndex; }
538 
556  void setSchemeName(const String& schemeName);
560  const String& getSchemeName(void) const;
561 
563  unsigned short _getSchemeIndex(void) const;
564 
566  bool isDepthWriteEnabled(void) const;
567 
569  bool isDepthCheckEnabled(void) const;
570 
572  bool hasColourWriteDisabled(void) const;
573 
579  void setName(const String& name);
581  const String& getName(void) const { return mName; }
582 
594  bool applyTextureAliases(const AliasTextureNamePairList& aliasList, const bool apply = true) const;
595 
596 
612  void addGPUVendorRule(GPUVendor vendor, IncludeOrExclude includeOrExclude);
626  void addGPUVendorRule(const GPUVendorRule& rule);
630  void removeGPUVendorRule(GPUVendor vendor);
633  GPUVendorRuleIterator getGPUVendorRuleIterator() const;
634 
652  void addGPUDeviceNameRule(const String& devicePattern, IncludeOrExclude includeOrExclude, bool caseSensitive = false);
667  void addGPUDeviceNameRule(const GPUDeviceNameRule& rule);
671  void removeGPUDeviceNameRule(const String& devicePattern);
674  GPUDeviceNameRuleIterator getGPUDeviceNameRuleIterator() const;
675 
680  UserObjectBindings& getUserObjectBindings() { return mUserObjectBindings; }
681 
686  const UserObjectBindings& getUserObjectBindings() const { return mUserObjectBindings; }
687 
688  };
689 
693 }
694 #endif
ConstVectorIterator< GPUVendorRuleList > GPUVendorRuleIterator
ManualCullingMode
Manual culling modes based on vertex normals.
Definition: OgreCommon.h:181
float Real
Software floating point type.
IncludeOrExclude
Directive used to manually control technique support based on the inclusion or exclusion of some fact...
#define _OgreExport
Definition: OgrePlatform.h:255
FogMode
Fog modes.
Definition: OgreCommon.h:152
GPUVendorRuleList mGPUVendorRules
MaterialPtr mShadowCasterMaterial
When casting shadow, if not using default Ogre shadow casting material, or nor using fixed function c...
Definition: OgreTechnique.h:89
IlluminationPassList mIlluminationPasses
List of derived passes, categorised into IlluminationStage (ordered)
Definition: OgreTechnique.h:65
GPUDeviceNameRule(const String &pattern, IncludeOrExclude ie, bool caseSen)
Class representing colour.
static const ColourValue White
String mShadowCasterMaterialName
When casting shadow, if not using default Ogre shadow casting material, or nor using fixed function c...
Definition: OgreTechnique.h:94
SceneBlendType
Types of blending that you can specify between an object and the existing contents of the scene...
Class encapsulates rendering properties of an object.
Definition: OgreMaterial.h:84
Class representing an approach to rendering this particular Material.
Definition: OgreTechnique.h:50
SceneBlendFactor
Blending factors for manually blending objects with the scene.
IlluminationPassesState
Illumination pass state type.
Definition: OgreTechnique.h:54
_StringStreamBase StringStream
Class defining a single pass of a Technique (of a Material), i.e.
Definition: OgrePass.h:78
CullingMode
Hardware culling modes based on vertex winding.
Definition: OgreCommon.h:166
vector< GPUVendorRule >::type GPUVendorRuleList
No fog. Duh.
Definition: OgreCommon.h:155
GPUVendorRule(GPUVendor v, IncludeOrExclude ie)
IlluminationPassesState mIlluminationPassesCompilationPhase
Definition: OgreTechnique.h:69
IncludeOrExclude includeOrExclude
ConstVectorIterator< GPUDeviceNameRuleList > GPUDeviceNameRuleIterator
unsigned short mSchemeIndex
Scheme index, derived from scheme name but the names are held on MaterialManager, for speed an index ...
Definition: OgreTechnique.h:75
ShadeOptions
Light shading modes.
Definition: OgreCommon.h:144
VectorIterator< Passes > PassIterator
Concrete IteratorWrapper for const access to the underlying container.
Superclass for all objects that wish to use custom memory allocators when their new / delete operator...
Passes mPasses
List of primary passes.
Definition: OgreTechnique.h:63
GPUVendor
Enumeration of GPU vendors.
Material * getParent(void) const
Gets the parent Material.
UserObjectBindings mUserObjectBindings
Definition: OgreTechnique.h:97
Rule controlling whether technique is deemed supported based on GPU vendor.
UserObjectBindings & getUserObjectBindings()
Return an instance of user objects binding associated with this class.
const String & getName(void) const
Gets the name of the technique.
vector< Pass * >::type Passes
Definition: OgreTechnique.h:61
vector< GPUDeviceNameRule >::type GPUDeviceNameRuleList
Rule controlling whether technique is deemed supported based on GPU device name.
vector< IlluminationPass * >::type IlluminationPassList
Definition: OgrePass.h:1797
VectorIterator< IlluminationPassList > IlluminationPassIterator
unsigned short mLodIndex
LOD level.
Definition: OgreTechnique.h:71
String mName
Optional name for the technique.
Definition: OgreTechnique.h:77
_StringBase String
Definition: OgreCommon.h:53
Concrete IteratorWrapper for nonconst access to the underlying container.
map< String, String >::type AliasTextureNamePairList
Alias / Texture name pair (first = alias, second = texture name)
Definition: OgreCommon.h:583
CompareFunction
Comparison functions used for the depth/stencil buffer operations and others.
Definition: OgreCommon.h:74
const UserObjectBindings & getUserObjectBindings() const
Return an instance of user objects binding associated with this class.
Material * mParent
Definition: OgreTechnique.h:67
unsigned short getLodIndex(void) const
Gets the level-of-detail index assigned to this Technique.
Class that provides convenient interface to establish a linkage between custom user application objec...
TextureFilterOptions
High-level filtering options providing shortcuts to settings the minification, magnification and mip ...
Definition: OgreCommon.h:109
GPUDeviceNameRuleList mGPUDeviceNameRules