Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

OgrePass.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://ogre.sourceforge.net/
00006 
00007 Copyright (c) 2000-2005 The OGRE Team
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 */
00025 #ifndef __Pass_H__
00026 #define __Pass_H__
00027 
00028 #include "OgrePrerequisites.h"
00029 #include "OgreGpuProgram.h"
00030 #include "OgreColourValue.h"
00031 #include "OgreBlendMode.h"
00032 #include "OgreCommon.h"
00033 #include "OgreLight.h"
00034 
00035 namespace Ogre {
00055     class _OgreExport Pass
00056     {
00057     protected:
00058         Technique* mParent;
00059         unsigned short mIndex; // pass index
00060         unsigned long mHash; // pass hash
00061         //-------------------------------------------------------------------------
00062         // Colour properties, only applicable in fixed-function passes
00063         ColourValue mAmbient;
00064         ColourValue mDiffuse;
00065         ColourValue mSpecular;    
00066         ColourValue mEmissive;
00067         Real mShininess;
00068         TrackVertexColourType mTracking;
00069         //-------------------------------------------------------------------------
00070 
00071         //-------------------------------------------------------------------------
00072         // Blending factors
00073         SceneBlendFactor mSourceBlendFactor;    
00074         SceneBlendFactor mDestBlendFactor;
00075         //-------------------------------------------------------------------------
00076 
00077         //-------------------------------------------------------------------------    
00078         // Depth buffer settings
00079         bool mDepthCheck;
00080         bool mDepthWrite;
00081         CompareFunction mDepthFunc;
00082         ushort mDepthBias;
00083 
00084         // Colour buffer settings
00085         bool mColourWrite;
00086         
00087         // Alpha reject settings
00088         CompareFunction mAlphaRejectFunc;
00089         unsigned char mAlphaRejectVal;
00090         //-------------------------------------------------------------------------    
00091 
00092         //-------------------------------------------------------------------------
00093         // Culling mode
00094         CullingMode mCullMode;
00095         ManualCullingMode mManualCullMode;
00096         //-------------------------------------------------------------------------
00097 
00099         bool mLightingEnabled;
00101         unsigned short mMaxSimultaneousLights;
00103         bool mRunOncePerLight;
00104         // Should it only be run for a certain light type?
00105         bool mRunOnlyForOneLightType;
00106         Light::LightTypes mOnlyLightType;
00107 
00109         ShadeOptions mShadeOptions;
00110 
00111         //-------------------------------------------------------------------------    
00112         // Fog
00113         bool mFogOverride;
00114         FogMode mFogMode;
00115         ColourValue mFogColour;
00116         Real mFogStart;
00117         Real mFogEnd;
00118         Real mFogDensity;
00119         //-------------------------------------------------------------------------    
00120 
00122         typedef std::vector<TextureUnitState*> TextureUnitStates;
00123         TextureUnitStates mTextureUnitStates;    
00124 
00125         // Vertex program details
00126         GpuProgramUsage *mVertexProgramUsage;
00127         // Vertex program details
00128         GpuProgramUsage *mShadowCasterVertexProgramUsage;
00129         // Vertex program details
00130         GpuProgramUsage *mShadowReceiverVertexProgramUsage;
00131         // Fragment program details
00132         GpuProgramUsage *mFragmentProgramUsage;
00133         // Is this pass queued for deletion?
00134         bool mQueuedForDeletion;
00135     public:
00136         typedef std::set<Pass*> PassSet;
00137     protected:
00139         static PassSet msDirtyHashList;
00141         static PassSet msPassGraveyard;
00142     public:
00144         Pass(Technique* parent, unsigned short index);
00146         Pass(Technique* parent, unsigned short index, const Pass& oth );
00148         Pass& operator=(const Pass& oth);
00149         ~Pass();
00150 
00152         bool isProgrammable(void) const { return mVertexProgramUsage || mFragmentProgramUsage; }
00153 
00155         bool hasVertexProgram(void) const { return mVertexProgramUsage != NULL; }
00156 
00158         bool hasFragmentProgram(void) const { return mFragmentProgramUsage != NULL; }
00159 
00161         unsigned short getIndex(void) const { return mIndex; }
00173         void setAmbient(Real red, Real green, Real blue);
00174 
00187         void setAmbient(const ColourValue& ambient);
00188 
00199         void setDiffuse(Real red, Real green, Real blue, Real alpha);
00200 
00211         void setDiffuse(const ColourValue& diffuse);
00212 
00225         void setSpecular(Real red, Real green, Real blue, Real alpha);
00226 
00239         void setSpecular(const ColourValue& specular);
00240 
00246         void setShininess(Real val);
00247 
00257         void setSelfIllumination(Real red, Real green, Real blue);
00258 
00268         void setSelfIllumination(const ColourValue& selfIllum);
00269 
00272         void setVertexColourTracking(TrackVertexColourType tracking);
00273 
00276         const ColourValue& getAmbient(void) const;
00277 
00280         const ColourValue& getDiffuse(void) const;
00281 
00284         const ColourValue& getSpecular(void) const;
00285 
00288         const ColourValue& getSelfIllumination(void) const;
00289 
00292         Real getShininess(void) const;
00293         
00296         TrackVertexColourType getVertexColourTracking(void) const;
00297 
00302         TextureUnitState* createTextureUnitState(void);
00313         TextureUnitState* createTextureUnitState( const String& textureName, unsigned short texCoordSet = 0);
00315         void addTextureUnitState(TextureUnitState* state);
00318         TextureUnitState* getTextureUnitState(unsigned short index);
00319 
00320         typedef VectorIterator<TextureUnitStates> TextureUnitStateIterator;
00322         TextureUnitStateIterator getTextureUnitStateIterator(void);
00323 
00328         void removeTextureUnitState(unsigned short index);
00329 
00332         void removeAllTextureUnitStates(void);
00333 
00336         size_t getNumTextureUnitStates(void) const
00337         {
00338             return mTextureUnitStates.size();
00339         }
00340 
00357         void setSceneBlending( const SceneBlendType sbt );
00358 
00381         void setSceneBlending( const SceneBlendFactor sourceFactor, const SceneBlendFactor destFactor);
00382 
00385         SceneBlendFactor getSourceBlendFactor() const;
00386 
00389         SceneBlendFactor getDestBlendFactor() const;
00390 
00392         bool isTransparent(void) const;
00393 
00405         void setDepthCheckEnabled(bool enabled);
00406 
00411         bool getDepthCheckEnabled(void) const;
00412 
00423         void setDepthWriteEnabled(bool enabled);
00424 
00429         bool getDepthWriteEnabled(void) const;
00430 
00438         void setDepthFunction( CompareFunction func );
00443         CompareFunction getDepthFunction(void) const;
00444 
00455         void setColourWriteEnabled(bool enabled);
00457         bool getColourWriteEnabled(void) const;
00458 
00472         void setCullingMode( CullingMode mode );
00473 
00476         CullingMode getCullingMode(void) const;
00477 
00491         void setManualCullingMode( ManualCullingMode mode );
00492 
00497         ManualCullingMode getManualCullingMode(void) const;
00498 
00507         void setLightingEnabled(bool enabled);
00508 
00511         bool getLightingEnabled(void) const;
00512 
00521         void setMaxSimultaneousLights(unsigned short maxLights);
00523         unsigned short getMaxSimultaneousLights(void) const;
00524 
00529         void setShadingMode( ShadeOptions mode );
00530 
00533         ShadeOptions getShadingMode(void) const;
00534 
00535 
00565         void setFog(
00566             bool overrideScene,
00567             FogMode mode = FOG_NONE,
00568             const ColourValue& colour = ColourValue::White,
00569             Real expDensity = 0.001, Real linearStart = 0.0, Real linearEnd = 1.0 );
00570 
00573         bool getFogOverride(void) const;
00574 
00579         FogMode getFogMode(void) const;
00580 
00583         const ColourValue& getFogColour(void) const;
00584 
00589         Real getFogStart(void) const;
00590 
00595         Real getFogEnd(void) const;
00596 
00601         Real getFogDensity(void) const;
00602 
00615         void setDepthBias(ushort bias);
00616 
00618         ushort getDepthBias(void) const;
00619 
00628         void setAlphaRejectSettings(CompareFunction func, unsigned char value);
00629 
00632         void setAlphaRejectFunction(CompareFunction func);
00633 
00636         void setAlphaRejectValue(unsigned char val);
00637 
00640         CompareFunction getAlphaRejectFunction(void) const { return mAlphaRejectFunc; }
00641 
00644         unsigned char getAlphaRejectValue(void) const { return mAlphaRejectVal; }
00680         void setRunOncePerLight(bool enabled, 
00681             bool onlyForOneLightType = true, Light::LightTypes lightType = Light::LT_POINT);
00682 
00684         bool getRunOncePerLight(void) const { return mRunOncePerLight; }
00686         bool getRunOnlyForOneLightType(void) const { return mRunOnlyForOneLightType; }
00689         Light::LightTypes getOnlyLightType() const { return mOnlyLightType; }
00690         
00692         Technique* getParent(void) { return mParent; }
00693 
00695         const String& getResourceGroup(void) const;
00696 
00713         void setVertexProgram(const String& name, bool resetParams = true);
00720         void setVertexProgramParameters(GpuProgramParametersSharedPtr params);
00722         const String& getVertexProgramName(void) const;
00724         GpuProgramParametersSharedPtr getVertexProgramParameters(void);
00726         const GpuProgramPtr& getVertexProgram(void);
00727 
00728 
00758         void setShadowCasterVertexProgram(const String& name);
00765         void setShadowCasterVertexProgramParameters(GpuProgramParametersSharedPtr params);
00767         const String& getShadowCasterVertexProgramName(void) const;
00769         GpuProgramParametersSharedPtr getShadowCasterVertexProgramParameters(void);
00772         const GpuProgramPtr& getShadowCasterVertexProgram(void);
00773 
00799         void setShadowReceiverVertexProgram(const String& name);
00806         void setShadowReceiverVertexProgramParameters(GpuProgramParametersSharedPtr params);
00808         const String& getShadowReceiverVertexProgramName(void) const;
00810         GpuProgramParametersSharedPtr getShadowReceiverVertexProgramParameters(void);
00813         const GpuProgramPtr& getShadowReceiverVertexProgram(void);
00814 
00815 
00832         void setFragmentProgram(const String& name, bool resetParams = true);
00837         void setFragmentProgramParameters(GpuProgramParametersSharedPtr params);
00839         const String& getFragmentProgramName(void) const;
00841         GpuProgramParametersSharedPtr getFragmentProgramParameters(void);
00843         const GpuProgramPtr& getFragmentProgram(void);
00844 
00856         Pass* _split(unsigned short numUnits);
00857 
00859         void _notifyIndex(unsigned short index);
00860 
00862         void _load(void);
00864         void _unload(void);
00865         // Is this loaded?
00866         bool isLoaded(void) const;
00867 
00874         unsigned long getHash(void) const;
00876         void _dirtyHash(void);
00883         void _recalculateHash(void);
00885         void _notifyNeedsRecompile(void);
00886 
00888         void _updateAutoParamsNoLights(const AutoParamDataSource& source);
00890         void _updateAutoParamsLightsOnly(const AutoParamDataSource& source);
00891 
00900         void setTextureFiltering(TextureFilterOptions filterType);
00909         void setTextureAnisotropy(unsigned int maxAniso);
00913         static const PassSet& getDirtyHashList(void) 
00914         { return msDirtyHashList; }
00917         static const PassSet& getPassGraveyard(void) 
00918         { return msPassGraveyard; }
00926         static void clearDirtyHashList(void) { msDirtyHashList.clear(); }
00927 
00929         static void processPendingPassUpdates(void);
00930 
00932         void queueForDeletion(void);
00933 
00936         bool isAmbientOnly(void) const;
00937 
00938         
00939     };
00940 
00941     enum IlluminationStage
00942     {
00944         IS_AMBIENT,
00946         IS_PER_LIGHT,
00948         IS_DECAL
00949     };
00959     struct IlluminationPass
00960     {
00961         IlluminationStage stage;
00963         Pass* pass;
00965         bool destroyOnShutdown;
00967         Pass* originalPass;
00968     };
00969 
00970     typedef std::vector<IlluminationPass*> IlluminationPassList;
00971 
00972 
00973 }
00974 
00975 #endif

Copyright © 2000-2005 by The OGRE Team
Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 2.5 License.
Last modified Sun Feb 12 12:59:49 2006