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:
58  {
59  IPS_COMPILE_DISABLED = -1,
60  IPS_NOT_COMPILED = 0,
61  IPS_COMPILED = 1
62  };
63 
69  // Raw pointer since we don't want child to stop parent's destruction
74  unsigned short mLodIndex;
78  unsigned short mSchemeIndex;
81 
83  void clearIlluminationPasses(void);
85  bool checkManuallyOrganisedIlluminationPasses();
86 
87 
108 
109  // User objects binding.
111 
112  public:
117  {
119  INCLUDE = 0,
121  EXCLUDE = 1
122  };
125  {
129  : vendor(GPU_UNKNOWN), includeOrExclude(EXCLUDE) {}
131  : vendor(v), includeOrExclude(ie) {}
132  };
135  {
140  : includeOrExclude(EXCLUDE), caseSensitive(false) {}
141  GPUDeviceNameRule(const String& pattern, IncludeOrExclude ie, bool caseSen)
142  : devicePattern(pattern), includeOrExclude(ie), caseSensitive(caseSen) {}
143  };
146  protected:
149  public:
151  Technique(Material* parent);
153  Technique(Material* parent, const Technique& oth);
154  ~Technique();
160  bool isSupported(void) const;
164  String _compile(bool autoManageTextureUnits);
166  bool checkGPURules(StringUtil::StrStreamType& errors);
168  bool checkHardwareSupport(bool autoManageTextureUnits, StringUtil::StrStreamType& compileErrors);
170  void _compileIlluminationPasses(void);
171  size_t calculateSize(void) const;
172 
183  Pass* createPass(void);
185  Pass* getPass(unsigned short index);
189  Pass* getPass(const String& name);
191  unsigned short getNumPasses(void) const;
193  void removePass(unsigned short index);
195  void removeAllPasses(void);
199  bool movePass(const unsigned short sourceIndex, const unsigned short destinationIndex);
202  const PassIterator getPassIterator(void);
205  const IlluminationPassIterator getIlluminationPassIterator(void);
207  Material* getParent(void) const { return mParent; }
208 
210  Technique& operator=(const Technique& rhs);
211 
213  const String& getResourceGroup(void) const;
214 
223  bool isTransparent(void) const;
224 
230  bool isTransparentSortingEnabled(void) const;
231 
237  bool isTransparentSortingForced(void) const;
238 
240  void _prepare(void);
242  void _unprepare(void);
244  void _load(void);
246  void _unload(void);
247 
249  bool isLoaded(void) const;
250 
252  void _notifyNeedsRecompile(void);
253 
256  Ogre::MaterialPtr getShadowCasterMaterial() const;
259  void setShadowCasterMaterial(Ogre::MaterialPtr val);
262  void setShadowCasterMaterial(const Ogre::String &name);
265  Ogre::MaterialPtr getShadowReceiverMaterial() const;
268  void setShadowReceiverMaterial(Ogre::MaterialPtr val);
271  void setShadowReceiverMaterial(const Ogre::String &name);
272 
273  // -------------------------------------------------------------------------------
274  // The following methods are to make migration from previous versions simpler
275  // and to make code easier to write when dealing with simple materials
276  // They set the properties which have been moved to Pass for all Techniques and all Passes
277 
286  void setPointSize(Real ps);
287 
296  void setAmbient(Real red, Real green, Real blue);
297 
306  void setAmbient(const ColourValue& ambient);
307 
316  void setDiffuse(Real red, Real green, Real blue, Real alpha);
317 
326  void setDiffuse(const ColourValue& diffuse);
327 
336  void setSpecular(Real red, Real green, Real blue, Real alpha);
337 
346  void setSpecular(const ColourValue& specular);
347 
356  void setShininess(Real val);
357 
366  void setSelfIllumination(Real red, Real green, Real blue);
367 
376  void setSelfIllumination(const ColourValue& selfIllum);
377 
386  void setDepthCheckEnabled(bool enabled);
387 
396  void setDepthWriteEnabled(bool enabled);
397 
406  void setDepthFunction( CompareFunction func );
407 
416  void setColourWriteEnabled(bool enabled);
417 
426  void setCullingMode( CullingMode mode );
427 
436  void setManualCullingMode( ManualCullingMode mode );
437 
446  void setLightingEnabled(bool enabled);
447 
456  void setShadingMode( ShadeOptions mode );
457 
466  void setFog(
467  bool overrideScene,
468  FogMode mode = FOG_NONE,
469  const ColourValue& colour = ColourValue::White,
470  Real expDensity = 0.001, Real linearStart = 0.0, Real linearEnd = 1.0 );
471 
480  void setDepthBias(float constantBias, float slopeScaleBias);
481 
490  void setTextureFiltering(TextureFilterOptions filterType);
499  void setTextureAnisotropy(unsigned int maxAniso);
500 
509  void setSceneBlending( const SceneBlendType sbt );
510 
519  void setSeparateSceneBlending( const SceneBlendType sbt, const SceneBlendType sbta );
520 
529  void setSceneBlending( const SceneBlendFactor sourceFactor, const SceneBlendFactor destFactor);
530 
539  void setSeparateSceneBlending( const SceneBlendFactor sourceFactor, const SceneBlendFactor destFactor, const SceneBlendFactor sourceFactorAlpha, const SceneBlendFactor destFactorAlpha);
540 
557  void setLodIndex(unsigned short index);
559  unsigned short getLodIndex(void) const { return mLodIndex; }
560 
578  void setSchemeName(const String& schemeName);
582  const String& getSchemeName(void) const;
583 
585  unsigned short _getSchemeIndex(void) const;
586 
588  bool isDepthWriteEnabled(void) const;
589 
591  bool isDepthCheckEnabled(void) const;
592 
594  bool hasColourWriteDisabled(void) const;
595 
601  void setName(const String& name);
603  const String& getName(void) const { return mName; }
604 
616  bool applyTextureAliases(const AliasTextureNamePairList& aliasList, const bool apply = true) const;
617 
618 
634  void addGPUVendorRule(GPUVendor vendor, IncludeOrExclude includeOrExclude);
648  void addGPUVendorRule(const GPUVendorRule& rule);
652  void removeGPUVendorRule(GPUVendor vendor);
655  GPUVendorRuleIterator getGPUVendorRuleIterator() const;
656 
674  void addGPUDeviceNameRule(const String& devicePattern, IncludeOrExclude includeOrExclude, bool caseSensitive = false);
689  void addGPUDeviceNameRule(const GPUDeviceNameRule& rule);
693  void removeGPUDeviceNameRule(const String& devicePattern);
696  GPUDeviceNameRuleIterator getGPUDeviceNameRuleIterator() const;
697 
702  UserObjectBindings& getUserObjectBindings() { return mUserObjectBindings; }
703 
708  const UserObjectBindings& getUserObjectBindings() const { return mUserObjectBindings; }
709 
710  };
711 
715 }
716 #endif
IncludeOrExclude includeOrExclude
IlluminationPassesState mIlluminationPassesCompilationPhase
Definition: OgreTechnique.h:72
Concrete IteratorWrapper for nonconst access to the underlying container.
FogMode
Fog modes.
Definition: OgreCommon.h:121
Class defining a single pass of a Technique (of a Material), i.e.
Definition: OgrePass.h:80
#define _OgreExport
Definition: OgrePlatform.h:257
String mName
Optional name for the technique.
Definition: OgreTechnique.h:80
TextureFilterOptions
High-level filtering options providing shortcuts to settings the minification, magnification and mip ...
Definition: OgreCommon.h:78
Passes mPasses
List of primary passes.
Definition: OgreTechnique.h:66
GPUDeviceNameRuleList mGPUDeviceNameRules
String mShadowCasterMaterialName
When casting shadow, if not using default Ogre shadow casting material, or nor using fixed function c...
Definition: OgreTechnique.h:97
GPUVendorRuleList mGPUVendorRules
Class representing colour.
float Real
Software floating point type.
SceneBlendType
Types of blending that you can specify between an object and the existing contents of the scene...
IlluminationPassList mIlluminationPasses
List of derived passes, categorised into IlluminationStage (ordered)
Definition: OgreTechnique.h:68
StringStream StrStreamType
Definition: OgreString.h:78
unsigned short mSchemeIndex
Scheme index, derived from scheme name but the names are held on MaterialManager, for speed an index ...
Definition: OgreTechnique.h:78
IlluminationPassesState
Illumination pass state type.
Definition: OgreTechnique.h:57
VectorIterator< IlluminationPassList > IlluminationPassIterator
static const ColourValue White
vector< IlluminationPass * >::type IlluminationPassList
Definition: OgrePass.h:1872
vector< Pass * >::type Passes
Definition: OgreTechnique.h:64
vector< GPUDeviceNameRule >::type GPUDeviceNameRuleList
IncludeOrExclude
Directive used to manually control technique support based on the inclusion or exclusion of some fact...
CullingMode
Hardware culling modes based on vertex winding.
Definition: OgreCommon.h:135
Rule controlling whether technique is deemed supported based on GPU device name.
map< String, String >::type AliasTextureNamePairList
Alias / Texture name pair (first = alias, second = texture name)
Definition: OgreCommon.h:553
Material * mParent
Definition: OgreTechnique.h:70
VectorIterator< Passes > PassIterator
MaterialPtr mShadowCasterMaterial
When casting shadow, if not using default Ogre shadow casting material, or nor using fixed function c...
Definition: OgreTechnique.h:92
CompareFunction
Comparison functions used for the depth/stencil buffer operations and others.
Definition: OgreCommon.h:64
unsigned short getLodIndex(void) const
Gets the level-of-detail index assigned to this Technique.
UserObjectBindings mUserObjectBindings
unsigned short mLodIndex
LOD level.
Definition: OgreTechnique.h:74
_StringBase String
UserObjectBindings & getUserObjectBindings()
Return an instance of user objects binding associated with this class.
ConstVectorIterator< GPUVendorRuleList > GPUVendorRuleIterator
MaterialPtr mShadowReceiverMaterial
When receiving shadow, if not using default Ogre shadow receiving material, or nor using fixed functi...
String mShadowReceiverMaterialName
When receiving shadow, if not using default Ogre shadow receiving material, or nor using fixed functi...
GPUVendorRule(GPUVendor v, IncludeOrExclude ie)
ManualCullingMode
Manual culling modes based on vertex normals.
Definition: OgreCommon.h:150
const String & getName(void) const
Gets the name of the technique.
SceneBlendFactor
Blending factors for manually blending objects with the scene.
Class encapsulates rendering properties of an object.
Definition: OgreMaterial.h:88
No fog. Duh.
Definition: OgreCommon.h:124
Concrete IteratorWrapper for const access to the underlying container.
GPUVendor
Enumeration of GPU vendors.
Class that provides convenient interface to establish a linkage between custom user application obje...
const UserObjectBindings & getUserObjectBindings() const
Return an instance of user objects binding associated with this class.
Class representing an approach to rendering this particular Material.
Definition: OgreTechnique.h:53
ShadeOptions
Light shading modes.
Definition: OgreCommon.h:113
Rule controlling whether technique is deemed supported based on GPU vendor.
Material * getParent(void) const
Gets the parent Material.
GPUDeviceNameRule(const String &pattern, IncludeOrExclude ie, bool caseSen)
vector< GPUVendorRule >::type GPUVendorRuleList
Superclass for all objects that wish to use custom memory allocators when their new / delete operator...
ConstVectorIterator< GPUDeviceNameRuleList > GPUDeviceNameRuleIterator

Copyright © 2012 Torus Knot Software Ltd
Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.
Last modified Fri Dec 20 2013 11:13:45