OgreTechnique.h
Go to the documentation of this file.
00001 /*
00002 -----------------------------------------------------------------------------
00003 This source file is part of OGRE
00004 (Object-oriented Graphics Rendering Engine)
00005 For the latest info, see http://www.ogre3d.org/
00006 
00007 Copyright (c) 2000-2013 Torus Knot Software Ltd
00008 
00009 Permission is hereby granted, free of charge, to any person obtaining a copy
00010 of this software and associated documentation files (the "Software"), to deal
00011 in the Software without restriction, including without limitation the rights
00012 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
00013 copies of the Software, and to permit persons to whom the Software is
00014 furnished to do so, subject to the following conditions:
00015 
00016 The above copyright notice and this permission notice shall be included in
00017 all copies or substantial portions of the Software.
00018 
00019 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
00020 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
00021 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
00022 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
00023 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
00024 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
00025 THE SOFTWARE.
00026 -----------------------------------------------------------------------------
00027 */
00028 #ifndef __Technique_H__
00029 #define __Technique_H__
00030 
00031 #include "OgrePrerequisites.h"
00032 #include "OgreIteratorWrappers.h"
00033 #include "OgreBlendMode.h"
00034 #include "OgreCommon.h"
00035 #include "OgrePass.h"
00036 #include "OgreIteratorWrappers.h"
00037 #include "OgreRenderSystemCapabilities.h"
00038 #include "OgreUserObjectBindings.h"
00039 
00040 namespace Ogre {
00053     class _OgreExport Technique : public TechniqueAlloc
00054     {
00055     protected:
00057         enum IlluminationPassesState
00058         {
00059             IPS_COMPILE_DISABLED = -1,
00060             IPS_NOT_COMPILED = 0,
00061             IPS_COMPILED = 1
00062         };
00063 
00064         typedef vector<Pass*>::type Passes;
00066         Passes mPasses;
00068         IlluminationPassList mIlluminationPasses;
00069         // Raw pointer since we don't want child to stop parent's destruction
00070         Material* mParent;
00071         bool mIsSupported;
00072         IlluminationPassesState mIlluminationPassesCompilationPhase;
00074         unsigned short mLodIndex;
00078         unsigned short mSchemeIndex;
00080         String mName;
00081 
00083         void clearIlluminationPasses(void);
00085         bool checkManuallyOrganisedIlluminationPasses();
00086 
00087 
00092         MaterialPtr mShadowCasterMaterial;
00097         String mShadowCasterMaterialName;
00102         MaterialPtr mShadowReceiverMaterial;
00107         String mShadowReceiverMaterialName; 
00108 
00109         // User objects binding.
00110         UserObjectBindings  mUserObjectBindings;
00111 
00112     public:
00116         enum IncludeOrExclude
00117         {
00119             INCLUDE = 0,
00121             EXCLUDE = 1
00122         };
00124         struct GPUVendorRule
00125         {
00126             GPUVendor vendor;
00127             IncludeOrExclude includeOrExclude;
00128             GPUVendorRule()
00129                 : vendor(GPU_UNKNOWN), includeOrExclude(EXCLUDE) {}
00130             GPUVendorRule(GPUVendor v, IncludeOrExclude ie)
00131                 : vendor(v), includeOrExclude(ie) {}
00132         };
00134         struct GPUDeviceNameRule
00135         {
00136             String devicePattern;
00137             IncludeOrExclude includeOrExclude;
00138             bool caseSensitive;
00139             GPUDeviceNameRule()
00140                 : includeOrExclude(EXCLUDE), caseSensitive(false) {}
00141             GPUDeviceNameRule(const String& pattern, IncludeOrExclude ie, bool caseSen)
00142                 : devicePattern(pattern), includeOrExclude(ie), caseSensitive(caseSen) {}
00143         };
00144         typedef vector<GPUVendorRule>::type GPUVendorRuleList;
00145         typedef vector<GPUDeviceNameRule>::type GPUDeviceNameRuleList;
00146     protected:
00147         GPUVendorRuleList mGPUVendorRules;
00148         GPUDeviceNameRuleList mGPUDeviceNameRules;
00149     public:
00151         Technique(Material* parent);
00153         Technique(Material* parent, const Technique& oth);
00154         ~Technique();
00160         bool isSupported(void) const;
00164         String _compile(bool autoManageTextureUnits);
00166         bool checkGPURules(StringUtil::StrStreamType& errors);
00168         bool checkHardwareSupport(bool autoManageTextureUnits, StringUtil::StrStreamType& compileErrors);
00170         void _compileIlluminationPasses(void);
00171         size_t calculateSize(void) const;
00172 
00183         Pass* createPass(void);
00185         Pass* getPass(unsigned short index);
00189         Pass* getPass(const String& name);
00191         unsigned short getNumPasses(void) const;
00193         void removePass(unsigned short index);
00195         void removeAllPasses(void);
00199         bool movePass(const unsigned short sourceIndex, const unsigned short destinationIndex);
00200         typedef VectorIterator<Passes> PassIterator;
00202         const PassIterator getPassIterator(void);
00203         typedef VectorIterator<IlluminationPassList> IlluminationPassIterator;
00205         const IlluminationPassIterator getIlluminationPassIterator(void);
00207         Material* getParent(void) const { return mParent; }
00208 
00210         Technique& operator=(const Technique& rhs);
00211 
00213         const String& getResourceGroup(void) const;
00214 
00223         bool isTransparent(void) const;
00224 
00230         bool isTransparentSortingEnabled(void) const;
00231 
00237         bool isTransparentSortingForced(void) const;
00238 
00240         void _prepare(void);
00242         void _unprepare(void);
00244         void _load(void);
00246         void _unload(void);
00247 
00249         bool isLoaded(void) const;
00250 
00252         void _notifyNeedsRecompile(void);
00253 
00256         Ogre::MaterialPtr getShadowCasterMaterial() const;
00259         void setShadowCasterMaterial(Ogre::MaterialPtr val);
00262         void setShadowCasterMaterial(const Ogre::String &name);
00265         Ogre::MaterialPtr getShadowReceiverMaterial() const;
00268         void setShadowReceiverMaterial(Ogre::MaterialPtr val);
00271         void setShadowReceiverMaterial(const Ogre::String &name);
00272 
00273         // -------------------------------------------------------------------------------
00274         // The following methods are to make migration from previous versions simpler
00275         // and to make code easier to write when dealing with simple materials
00276         // They set the properties which have been moved to Pass for all Techniques and all Passes
00277 
00286         void setPointSize(Real ps);
00287 
00296         void setAmbient(Real red, Real green, Real blue);
00297 
00306         void setAmbient(const ColourValue& ambient);
00307 
00316         void setDiffuse(Real red, Real green, Real blue, Real alpha);
00317 
00326         void setDiffuse(const ColourValue& diffuse);
00327 
00336         void setSpecular(Real red, Real green, Real blue, Real alpha);
00337 
00346         void setSpecular(const ColourValue& specular);
00347 
00356         void setShininess(Real val);
00357 
00366         void setSelfIllumination(Real red, Real green, Real blue);
00367 
00376         void setSelfIllumination(const ColourValue& selfIllum);
00377 
00386         void setDepthCheckEnabled(bool enabled);
00387 
00396         void setDepthWriteEnabled(bool enabled);
00397 
00406         void setDepthFunction( CompareFunction func );
00407 
00416         void setColourWriteEnabled(bool enabled);
00417 
00426         void setCullingMode( CullingMode mode );
00427 
00436         void setManualCullingMode( ManualCullingMode mode );
00437 
00446         void setLightingEnabled(bool enabled);
00447 
00456         void setShadingMode( ShadeOptions mode );
00457 
00466         void setFog(
00467             bool overrideScene,
00468             FogMode mode = FOG_NONE,
00469             const ColourValue& colour = ColourValue::White,
00470             Real expDensity = 0.001, Real linearStart = 0.0, Real linearEnd = 1.0 );
00471 
00480         void setDepthBias(float constantBias, float slopeScaleBias);
00481 
00490         void setTextureFiltering(TextureFilterOptions filterType);
00499         void setTextureAnisotropy(unsigned int maxAniso);
00500 
00509         void setSceneBlending( const SceneBlendType sbt );
00510 
00519         void setSeparateSceneBlending( const SceneBlendType sbt, const SceneBlendType sbta );
00520 
00529         void setSceneBlending( const SceneBlendFactor sourceFactor, const SceneBlendFactor destFactor);
00530 
00539         void setSeparateSceneBlending( const SceneBlendFactor sourceFactor, const SceneBlendFactor destFactor, const SceneBlendFactor sourceFactorAlpha, const SceneBlendFactor destFactorAlpha);
00540 
00557         void setLodIndex(unsigned short index);
00559         unsigned short getLodIndex(void) const { return mLodIndex; }
00560 
00578         void setSchemeName(const String& schemeName);
00582         const String& getSchemeName(void) const;
00583         
00585         unsigned short _getSchemeIndex(void) const;
00586             
00588         bool isDepthWriteEnabled(void) const;
00589 
00591         bool isDepthCheckEnabled(void) const;
00592 
00594         bool hasColourWriteDisabled(void) const;
00595 
00601         void setName(const String& name);
00603         const String& getName(void) const { return mName; }
00604 
00616         bool applyTextureAliases(const AliasTextureNamePairList& aliasList, const bool apply = true) const;
00617 
00618 
00634         void addGPUVendorRule(GPUVendor vendor, IncludeOrExclude includeOrExclude);
00648         void addGPUVendorRule(const GPUVendorRule& rule);
00652         void removeGPUVendorRule(GPUVendor vendor);
00653         typedef ConstVectorIterator<GPUVendorRuleList> GPUVendorRuleIterator;
00655         GPUVendorRuleIterator getGPUVendorRuleIterator() const;
00656 
00674         void addGPUDeviceNameRule(const String& devicePattern, IncludeOrExclude includeOrExclude, bool caseSensitive = false);
00689         void addGPUDeviceNameRule(const GPUDeviceNameRule& rule);
00693         void removeGPUDeviceNameRule(const String& devicePattern);
00694         typedef ConstVectorIterator<GPUDeviceNameRuleList> GPUDeviceNameRuleIterator;
00696         GPUDeviceNameRuleIterator getGPUDeviceNameRuleIterator() const;
00697 
00702         UserObjectBindings& getUserObjectBindings() { return mUserObjectBindings; }
00703 
00708         const UserObjectBindings& getUserObjectBindings() const { return mUserObjectBindings; }
00709 
00710     };
00711 
00715 }
00716 #endif

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 Mon Jul 27 2020 13:40:48