OGRE  1.8
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-2013 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 "OgreIteratorWrappers.h"
33 #include "OgreBlendMode.h"
34 #include "OgreCommon.h"
35 #include "OgrePass.h"
36 #include "OgreIteratorWrappers.h"
38 #include "OgreUserObjectBindings.h"
39 
40 namespace Ogre {
54  {
55  protected:
56  // illumination pass state type
58  {
59  IPS_COMPILE_DISABLED = -1,
60  IPS_NOT_COMPILED = 0,
61  IPS_COMPILED = 1
62  };
63 
69  Material* mParent; // raw pointer since we don't want child to stop parent's destruction
73  unsigned short mLodIndex;
77  unsigned short mSchemeIndex;
78  String mName; // optional name for the technique
79 
81  void clearIlluminationPasses(void);
83  bool checkManuallyOrganisedIlluminationPasses();
84 
85 
106 
107  // User objects binding.
109 
110  public:
115  {
117  INCLUDE = 0,
119  EXCLUDE = 1
120  };
123  {
127  : vendor(GPU_UNKNOWN), includeOrExclude(EXCLUDE) {}
129  : vendor(v), includeOrExclude(ie) {}
130  };
133  {
138  : includeOrExclude(EXCLUDE), caseSensitive(false) {}
139  GPUDeviceNameRule(const String& pattern, IncludeOrExclude ie, bool caseSen)
140  : devicePattern(pattern), includeOrExclude(ie), caseSensitive(caseSen) {}
141  };
144  protected:
147  public:
149  Technique(Material* parent);
151  Technique(Material* parent, const Technique& oth);
152  ~Technique();
158  bool isSupported(void) const;
162  String _compile(bool autoManageTextureUnits);
164  bool checkGPURules(StringUtil::StrStreamType& errors);
166  bool checkHardwareSupport(bool autoManageTextureUnits, StringUtil::StrStreamType& compileErrors);
168  void _compileIlluminationPasses(void);
169 
170 
181  Pass* createPass(void);
183  Pass* getPass(unsigned short index);
187  Pass* getPass(const String& name);
189  unsigned short getNumPasses(void) const;
191  void removePass(unsigned short index);
193  void removeAllPasses(void);
197  bool movePass(const unsigned short sourceIndex, const unsigned short destinationIndex);
200  const PassIterator getPassIterator(void);
203  const IlluminationPassIterator getIlluminationPassIterator(void);
205  Material* getParent(void) const { return mParent; }
206 
208  Technique& operator=(const Technique& rhs);
209 
211  const String& getResourceGroup(void) const;
212 
221  bool isTransparent(void) const;
222 
228  bool isTransparentSortingEnabled(void) const;
229 
235  bool isTransparentSortingForced(void) const;
236 
238  void _prepare(void);
240  void _unprepare(void);
242  void _load(void);
244  void _unload(void);
245 
246  // Is this loaded?
247  bool isLoaded(void) const;
248 
250  void _notifyNeedsRecompile(void);
251 
254  Ogre::MaterialPtr getShadowCasterMaterial() const;
257  void setShadowCasterMaterial(Ogre::MaterialPtr val);
260  void setShadowCasterMaterial(const Ogre::String &name);
263  Ogre::MaterialPtr getShadowReceiverMaterial() const;
266  void setShadowReceiverMaterial(Ogre::MaterialPtr val);
269  void setShadowReceiverMaterial(const Ogre::String &name);
270 
271  // -------------------------------------------------------------------------------
272  // The following methods are to make migration from previous versions simpler
273  // and to make code easier to write when dealing with simple materials
274  // They set the properties which have been moved to Pass for all Techniques and all Passes
275 
284  void setPointSize(Real ps);
285 
294  void setAmbient(Real red, Real green, Real blue);
295 
304  void setAmbient(const ColourValue& ambient);
305 
314  void setDiffuse(Real red, Real green, Real blue, Real alpha);
315 
324  void setDiffuse(const ColourValue& diffuse);
325 
334  void setSpecular(Real red, Real green, Real blue, Real alpha);
335 
344  void setSpecular(const ColourValue& specular);
345 
354  void setShininess(Real val);
355 
364  void setSelfIllumination(Real red, Real green, Real blue);
365 
374  void setSelfIllumination(const ColourValue& selfIllum);
375 
384  void setDepthCheckEnabled(bool enabled);
385 
394  void setDepthWriteEnabled(bool enabled);
395 
404  void setDepthFunction( CompareFunction func );
405 
414  void setColourWriteEnabled(bool enabled);
415 
424  void setCullingMode( CullingMode mode );
425 
434  void setManualCullingMode( ManualCullingMode mode );
435 
444  void setLightingEnabled(bool enabled);
445 
454  void setShadingMode( ShadeOptions mode );
455 
464  void setFog(
465  bool overrideScene,
466  FogMode mode = FOG_NONE,
467  const ColourValue& colour = ColourValue::White,
468  Real expDensity = 0.001, Real linearStart = 0.0, Real linearEnd = 1.0 );
469 
478  void setDepthBias(float constantBias, float slopeScaleBias);
479 
488  void setTextureFiltering(TextureFilterOptions filterType);
497  void setTextureAnisotropy(unsigned int maxAniso);
498 
507  void setSceneBlending( const SceneBlendType sbt );
508 
517  void setSeparateSceneBlending( const SceneBlendType sbt, const SceneBlendType sbta );
518 
527  void setSceneBlending( const SceneBlendFactor sourceFactor, const SceneBlendFactor destFactor);
528 
537  void setSeparateSceneBlending( const SceneBlendFactor sourceFactor, const SceneBlendFactor destFactor, const SceneBlendFactor sourceFactorAlpha, const SceneBlendFactor destFactorAlpha);
538 
555  void setLodIndex(unsigned short index);
557  unsigned short getLodIndex(void) const { return mLodIndex; }
558 
576  void setSchemeName(const String& schemeName);
580  const String& getSchemeName(void) const;
581 
583  unsigned short _getSchemeIndex(void) const;
584 
586  bool isDepthWriteEnabled(void) const;
587 
589  bool isDepthCheckEnabled(void) const;
590 
592  bool hasColourWriteDisabled(void) const;
593 
599  void setName(const String& name);
601  const String& getName(void) const { return mName; }
602 
614  bool applyTextureAliases(const AliasTextureNamePairList& aliasList, const bool apply = true) const;
615 
616 
632  void addGPUVendorRule(GPUVendor vendor, IncludeOrExclude includeOrExclude);
646  void addGPUVendorRule(const GPUVendorRule& rule);
650  void removeGPUVendorRule(GPUVendor vendor);
653  GPUVendorRuleIterator getGPUVendorRuleIterator() const;
654 
672  void addGPUDeviceNameRule(const String& devicePattern, IncludeOrExclude includeOrExclude, bool caseSensitive = false);
687  void addGPUDeviceNameRule(const GPUDeviceNameRule& rule);
691  void removeGPUDeviceNameRule(const String& devicePattern);
694  GPUDeviceNameRuleIterator getGPUDeviceNameRuleIterator() const;
695 
700  UserObjectBindings& getUserObjectBindings() { return mUserObjectBindings; }
701 
706  const UserObjectBindings& getUserObjectBindings() const { return mUserObjectBindings; }
707 
708  };
709 
713 }
714 #endif
ConstVectorIterator< GPUVendorRuleList > GPUVendorRuleIterator
ManualCullingMode
Manual culling modes based on vertex normals.
Definition: OgreCommon.h:153
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:233
FogMode
Fog modes.
Definition: OgreCommon.h:124
GPUVendorRuleList mGPUVendorRules
MaterialPtr mShadowCasterMaterial
When casting shadow, if not using default Ogre shadow casting material, or nor using fixed function c...
Definition: OgreTechnique.h:90
IlluminationPassList mIlluminationPasses
List of derived passes, categorised into IlluminationStage (ordered)
Definition: OgreTechnique.h:68
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:95
StringStream StrStreamType
Definition: OgreString.h:78
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:89
Class representing an approach to rendering this particular Material.
Definition: OgreTechnique.h:53
SceneBlendFactor
Blending factors for manually blending objects with the scene.
Class defining a single pass of a Technique (of a Material), i.e.
Definition: OgrePass.h:80
CullingMode
Hardware culling modes based on vertex winding.
Definition: OgreCommon.h:138
vector< GPUVendorRule >::type GPUVendorRuleList
No fog. Duh.
Definition: OgreCommon.h:127
GPUVendorRule(GPUVendor v, IncludeOrExclude ie)
IlluminationPassesState mIlluminationPassesCompilationPhase
Definition: OgreTechnique.h:71
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:77
ShadeOptions
Light shading modes.
Definition: OgreCommon.h:116
VectorIterator< Passes > PassIterator
String mShadowReceiverMaterialName
When receiving shadow, if not using default Ogre shadow receiving material, or nor using fixed functi...
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:66
GPUVendor
Enumeration of GPU vendors.
Material * getParent(void) const
Gets the parent Material.
UserObjectBindings mUserObjectBindings
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:64
vector< GPUDeviceNameRule >::type GPUDeviceNameRuleList
Rule controlling whether technique is deemed supported based on GPU device name.
vector< IlluminationPass * >::type IlluminationPassList
Definition: OgrePass.h:1768
VectorIterator< IlluminationPassList > IlluminationPassIterator
unsigned short mLodIndex
LOD level.
Definition: OgreTechnique.h:73
_StringBase String
Specialisation of SharedPtr to allow SharedPtr to be assigned to MaterialPtr.
Definition: OgreMaterial.h:688
MaterialPtr mShadowReceiverMaterial
When receiving shadow, if not using default Ogre shadow receiving material, or nor using fixed functi...
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:556
CompareFunction
Comparison functions used for the depth/stencil buffer operations and others.
Definition: OgreCommon.h:67
const UserObjectBindings & getUserObjectBindings() const
Return an instance of user objects binding associated with this class.
Material * mParent
Definition: OgreTechnique.h:69
unsigned short getLodIndex(void) const
Gets the level-of-detail index assigned to this Technique.
Class that provide convenient interface to establish a linkage between custom user application object...
TextureFilterOptions
High-level filtering options providing shortcuts to settings the minification, magnification and mip ...
Definition: OgreCommon.h:81
GPUDeviceNameRuleList mGPUDeviceNameRules