# 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-2006 Torus Knot Software Ltd
    00008 Also see acknowledgements in Readme.html
    00009
    00010 This program is free software; you can redistribute it and/or modify it under
    00011 the terms of the GNU Lesser General Public License as published by the Free Software
    00012 Foundation; either version 2 of the License, or (at your option) any later
    00013 version.
    00014
    00015 This program is distributed in the hope that it will be useful, but WITHOUT
    00016 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
    00017 FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
    00018
    00019 You should have received a copy of the GNU Lesser General Public License along with
    00020 this program; if not, write to the Free Software Foundation, Inc., 59 Temple
    00021 Place - Suite 330, Boston, MA 02111-1307, USA, or go to
    00022 http://www.gnu.org/copyleft/lesser.txt.
    00023
    00024 You may alternatively use this source under the terms of a specific version of
    00025 the OGRE Unrestricted License provided you have obtained such a license from
    00026 Torus Knot Software Ltd.
    00027 -----------------------------------------------------------------------------
    00028 */
    00029 #ifndef __Technique_H__
    00030 #define __Technique_H__
    00031
    00032 #include "OgrePrerequisites.h"
    00033 #include "OgreIteratorWrappers.h"
    00034 #include "OgreBlendMode.h"
    00035 #include "OgreCommon.h"
    00036 #include "OgrePass.h"
    00037 #include "OgreIteratorWrappers.h"
    00038 #include "OgreRenderSystemCapabilities.h"
    00039
    00040 namespace Ogre {
    00047     class _OgreExport Technique : public TechniqueAlloc
    00048     {
    00049     protected:
    00050         // illumination pass state type
    00051         enum IlluminationPassesState
    00052         {
    00053             IPS_COMPILE_DISABLED = -1,
    00054             IPS_NOT_COMPILED = 0,
    00055             IPS_COMPILED = 1
    00056         };
    00057
    00058         typedef std::vector<Pass*> Passes;
    00060         Passes mPasses;
    00062         IlluminationPassList mIlluminationPasses;
    00063         Material* mParent; // raw pointer since we don't want child to stop parent's destruction
    00064         bool mIsSupported;
    00065         IlluminationPassesState mIlluminationPassesCompilationPhase;
    00067         unsigned short mLodIndex;
    00071         unsigned short mSchemeIndex;
    00072         String mName; // optional name for the technique
    00073
    00075         void clearIlluminationPasses(void);
    00077         bool checkManuallyOrganisedIlluminationPasses();
    00078
    00079
    00084         MaterialPtr mShadowCasterMaterial;
    00089         String mShadowCasterMaterialName;
    00094         MaterialPtr mShadowReceiverMaterial;
    00099         String mShadowReceiverMaterialName;
    00100
    00101     public:
    00105         enum IncludeOrExclude
    00106         {
    00108             INCLUDE = 0,
    00110             EXCLUDE = 1
    00111         };
    00113         struct GPUVendorRule
    00114         {
    00115             GPUVendor vendor;
    00116             IncludeOrExclude includeOrExclude;
    00117             GPUVendorRule()
    00118                 : vendor(GPU_UNKNOWN), includeOrExclude(EXCLUDE) {}
    00119             GPUVendorRule(GPUVendor v, IncludeOrExclude ie)
    00120                 : vendor(v), includeOrExclude(ie) {}
    00121         };
    00123         struct GPUDeviceNameRule
    00124         {
    00125             String devicePattern;
    00126             IncludeOrExclude includeOrExclude;
    00127             bool caseSensitive;
    00128             GPUDeviceNameRule()
    00129                 : includeOrExclude(EXCLUDE), caseSensitive(false) {}
    00130             GPUDeviceNameRule(const String& pattern, IncludeOrExclude ie, bool caseSen)
    00131                 : devicePattern(pattern), includeOrExclude(ie), caseSensitive(caseSen) {}
    00132         };
    00133         typedef std::vector<GPUVendorRule> GPUVendorRuleList;
    00134         typedef std::vector<GPUDeviceNameRule> GPUDeviceNameRuleList;
    00135     protected:
    00136         GPUVendorRuleList mGPUVendorRules;
    00137         GPUDeviceNameRuleList mGPUDeviceNameRules;
    00138     public:
    00140         Technique(Material* parent);
    00142         Technique(Material* parent, const Technique& oth);
    00143         ~Technique();
    00149         bool isSupported(void) const;
    00153         String _compile(bool autoManageTextureUnits);
    00155         bool checkGPURules(StringUtil::StrStreamType& errors);
    00157         bool checkHardwareSupport(bool autoManageTextureUnits, StringUtil::StrStreamType& compileErrors);
    00159         void _compileIlluminationPasses(void);
    00160
    00161
    00172         Pass* createPass(void);
    00174         Pass* getPass(unsigned short index);
    00178         Pass* getPass(const String& name);
    00180         unsigned short getNumPasses(void) const;
    00182         void removePass(unsigned short index);
    00184         void removeAllPasses(void);
    00188         bool movePass(const unsigned short sourceIndex, const unsigned short destinationIndex);
    00189         typedef VectorIterator<Passes> PassIterator;
    00191         const PassIterator getPassIterator(void);
    00192         typedef VectorIterator<IlluminationPassList> IlluminationPassIterator;
    00194         const IlluminationPassIterator getIlluminationPassIterator(void);
    00196         Material* getParent(void) const { return mParent; }
    00197
    00199         Technique& operator=(const Technique& rhs);
    00200
    00202         const String& getResourceGroup(void) const;
    00203
    00212         bool isTransparent(void) const;
    00213
    00219         bool isTransparentSortingEnabled(void) const;
    00220
    00222         void _prepare(void);
    00224         void _unprepare(void);
    00226         void _load(void);
    00228         void _unload(void);
    00229
    00230         // Is this loaded?
    00231         bool isLoaded(void) const;
    00232
    00234         void _notifyNeedsRecompile(void);
    00235
    00238         Ogre::MaterialPtr getShadowCasterMaterial() const;
    00241         void setShadowCasterMaterial(Ogre::MaterialPtr val);
    00244         void setShadowCasterMaterial(const Ogre::String &name);
    00247         Ogre::MaterialPtr getShadowReceiverMaterial() const;
    00250         void setShadowReceiverMaterial(Ogre::MaterialPtr val);
    00253         void setShadowReceiverMaterial(const Ogre::String &name);
    00254
    00255         // -------------------------------------------------------------------------------
    00256         // The following methods are to make migration from previous versions simpler
    00257         // and to make code easier to write when dealing with simple materials
    00258         // They set the properties which have been moved to Pass for all Techniques and all Passes
    00259
    00268         void setPointSize(Real ps);
    00269
    00278         void setAmbient(Real red, Real green, Real blue);
    00279
    00288         void setAmbient(const ColourValue& ambient);
    00289
    00298         void setDiffuse(Real red, Real green, Real blue, Real alpha);
    00299
    00308         void setDiffuse(const ColourValue& diffuse);
    00309
    00318         void setSpecular(Real red, Real green, Real blue, Real alpha);
    00319
    00328         void setSpecular(const ColourValue& specular);
    00329
    00338         void setShininess(Real val);
    00339
    00348         void setSelfIllumination(Real red, Real green, Real blue);
    00349
    00358         void setSelfIllumination(const ColourValue& selfIllum);
    00359
    00368         void setDepthCheckEnabled(bool enabled);
    00369
    00378         void setDepthWriteEnabled(bool enabled);
    00379
    00388         void setDepthFunction( CompareFunction func );
    00389
    00398         void setColourWriteEnabled(bool enabled);
    00399
    00408         void setCullingMode( CullingMode mode );
    00409
    00418         void setManualCullingMode( ManualCullingMode mode );
    00419
    00428         void setLightingEnabled(bool enabled);
    00429
    00438         void setShadingMode( ShadeOptions mode );
    00439
    00448         void setFog(
    00449             bool overrideScene,
    00450             FogMode mode = FOG_NONE,
    00451             const ColourValue& colour = ColourValue::White,
    00452             Real expDensity = 0.001, Real linearStart = 0.0, Real linearEnd = 1.0 );
    00453
    00462         void setDepthBias(float constantBias, float slopeScaleBias);
    00463
    00472         void setTextureFiltering(TextureFilterOptions filterType);
    00481         void setTextureAnisotropy(unsigned int maxAniso);
    00482
    00491         void setSceneBlending( const SceneBlendType sbt );
    00492
    00501         void setSeparateSceneBlending( const SceneBlendType sbt, const SceneBlendType sbta );
    00502
    00511         void setSceneBlending( const SceneBlendFactor sourceFactor, const SceneBlendFactor destFactor);
    00512
    00521         void setSeparateSceneBlending( const SceneBlendFactor sourceFactor, const SceneBlendFactor destFactor, const SceneBlendFactor sourceFactorAlpha, const SceneBlendFactor destFactorAlpha);
    00522
    00539         void setLodIndex(unsigned short index);
    00541         unsigned short getLodIndex(void) const { return mLodIndex; }
    00542
    00560         void setSchemeName(const String& schemeName);
    00564         const String& getSchemeName(void) const;
    00565
    00567         unsigned short _getSchemeIndex(void) const;
    00568
    00570         bool isDepthWriteEnabled(void) const;
    00571
    00573         bool isDepthCheckEnabled(void) const;
    00574
    00576         bool hasColourWriteDisabled(void) const;
    00577
    00583         void setName(const String& name);
    00585         const String& getName(void) const { return mName; }
    00586
    00598         bool applyTextureAliases(const AliasTextureNamePairList& aliasList, const bool apply = true) const;
    00599
    00600
    00616         void addGPUVendorRule(GPUVendor vendor, IncludeOrExclude includeOrExclude);
    00630         void addGPUVendorRule(const GPUVendorRule& rule);
    00634         void removeGPUVendorRule(GPUVendor vendor);
    00635         typedef ConstVectorIterator<GPUVendorRuleList> GPUVendorRuleIterator;
    00637         GPUVendorRuleIterator getGPUVendorRuleIterator() const;
    00638
    00656         void addGPUDeviceNameRule(const String& devicePattern, IncludeOrExclude includeOrExclude, bool caseSensitive = false);
    00671         void addGPUDeviceNameRule(const GPUDeviceNameRule& rule);
    00675         void removeGPUDeviceNameRule(const String& devicePattern);
    00676         typedef ConstVectorIterator<GPUDeviceNameRuleList> GPUDeviceNameRuleIterator;
    00678         GPUDeviceNameRuleIterator getGPUDeviceNameRuleIterator() const;
    00679
    00680     };
    00681
    00682
    00683 }
    00684 #endif

Copyright © 2008 Torus Knot Software Ltd
This work is licensed under a Creative Commons Attribution-ShareAlike 2.5 License.
Last modified Sun Jul 26 11:32:20 2009