Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound 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 © 2000-2003 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         //-------------------------------------------------------------------------
00069 
00070         //-------------------------------------------------------------------------
00071         // Blending factors
00072         SceneBlendFactor mSourceBlendFactor;    
00073         SceneBlendFactor mDestBlendFactor;
00074         //-------------------------------------------------------------------------
00075 
00076         //-------------------------------------------------------------------------    
00077         // Depth buffer settings
00078         bool mDepthCheck;
00079         bool mDepthWrite;
00080         CompareFunction mDepthFunc;
00081         ushort mDepthBias;
00082 
00083         // Colour buffer settings
00084         bool mColourWrite;
00085 
00086         //-------------------------------------------------------------------------    
00087 
00088         //-------------------------------------------------------------------------
00089         // Culling mode
00090         CullingMode mCullMode;
00091         ManualCullingMode mManualCullMode;
00092         //-------------------------------------------------------------------------
00093 
00095         bool mLightingEnabled;
00097         unsigned short mMaxSimultaneousLights;
00099         bool mRunOncePerLight;
00100         // Should it only be run for a certain light type?
00101         bool mRunOnlyForOneLightType;
00102         Light::LightTypes mOnlyLightType;
00103 
00105         ShadeOptions mShadeOptions;
00106 
00107         //-------------------------------------------------------------------------    
00108         // Fog
00109         bool mFogOverride;
00110         FogMode mFogMode;
00111         ColourValue mFogColour;
00112         Real mFogStart;
00113         Real mFogEnd;
00114         Real mFogDensity;
00115         //-------------------------------------------------------------------------    
00116 
00118         typedef std::vector<TextureUnitState*> TextureUnitStates;
00119         TextureUnitStates mTextureUnitStates;    
00120 
00121         // Vertex program details
00122         GpuProgramUsage *mVertexProgramUsage;
00123         // Fragment program details
00124         GpuProgramUsage *mFragmentProgramUsage;
00125     public:
00127         Pass(Technique* parent, unsigned short index);
00129         Pass(Technique* parent, unsigned short index, const Pass& oth );
00131         Pass& operator=(const Pass& oth);
00132         ~Pass();
00133 
00135         bool isProgrammable(void) const { return mVertexProgramUsage || mFragmentProgramUsage; }
00136 
00138         bool hasVertexProgram(void) { return mVertexProgramUsage != NULL; }
00139 
00141         bool hasFragmentProgram(void) { return mFragmentProgramUsage != NULL; }
00142 
00144         unsigned short getIndex(void) const { return mIndex; }
00156         void setAmbient(Real red, Real green, Real blue);
00157 
00170         void setAmbient(const ColourValue& ambient);
00171 
00182         void setDiffuse(Real red, Real green, Real blue);
00183 
00194         void setDiffuse(const ColourValue& diffuse);
00195 
00208         void setSpecular(Real red, Real green, Real blue);
00209 
00222         void setSpecular(const ColourValue& specular);
00223 
00229         void setShininess(Real val);
00230 
00240         void setSelfIllumination(Real red, Real green, Real blue);
00241 
00251         void setSelfIllumination(const ColourValue& selfIllum);
00252 
00255         const ColourValue& getAmbient(void) const;
00256 
00259         const ColourValue& getDiffuse(void) const;
00260 
00263         const ColourValue& getSpecular(void) const;
00264 
00267         const ColourValue& getSelfIllumination(void) const;
00268 
00271         Real getShininess(void) const;
00272 
00277         TextureUnitState* createTextureUnitState(void);
00288         TextureUnitState* createTextureUnitState( const String& textureName, unsigned short texCoordSet = 0);
00290         void addTextureUnitState(TextureUnitState* state);
00293         TextureUnitState* getTextureUnitState(unsigned short index);
00294 
00295         typedef VectorIterator<TextureUnitStates> TextureUnitStateIterator;
00297         TextureUnitStateIterator getTextureUnitStateIterator(void);
00298 
00303         void removeTextureUnitState(unsigned short index);
00304 
00307         void removeAllTextureUnitStates(void);
00308 
00311         size_t getNumTextureUnitStates(void) const
00312         {
00313             return mTextureUnitStates.size();
00314         }
00315 
00332         void setSceneBlending( const SceneBlendType sbt );
00333 
00356         void setSceneBlending( const SceneBlendFactor sourceFactor, const SceneBlendFactor destFactor);
00357 
00360         SceneBlendFactor getSourceBlendFactor() const;
00361 
00364         SceneBlendFactor getDestBlendFactor() const;
00365 
00367         bool isTransparent(void) const;
00368 
00380         void setDepthCheckEnabled(bool enabled);
00381 
00386         bool getDepthCheckEnabled(void) const;
00387 
00398         void setDepthWriteEnabled(bool enabled);
00399 
00404         bool getDepthWriteEnabled(void) const;
00405 
00413         void setDepthFunction( CompareFunction func );
00418         CompareFunction getDepthFunction(void) const;
00419 
00430         void setColourWriteEnabled(bool enabled);
00432         bool getColourWriteEnabled(void) const;
00433 
00447         void setCullingMode( CullingMode mode );
00448 
00451         CullingMode getCullingMode(void) const;
00452 
00466         void setManualCullingMode( ManualCullingMode mode );
00467 
00472         ManualCullingMode getManualCullingMode(void) const;
00473 
00482         void setLightingEnabled(bool enabled);
00483 
00486         bool getLightingEnabled(void) const;
00487 
00496         void setMaxSimultaneousLights(unsigned short maxLights);
00498         unsigned short getMaxSimultaneousLights(void) const;
00499 
00504         void setShadingMode( ShadeOptions mode );
00505 
00508         ShadeOptions getShadingMode(void) const;
00509 
00510 
00540         void setFog(
00541             bool overrideScene,
00542             FogMode mode = FOG_NONE,
00543             const ColourValue& colour = ColourValue::White,
00544             Real expDensity = 0.001, Real linearStart = 0.0, Real linearEnd = 1.0 );
00545 
00548         bool getFogOverride(void) const;
00549 
00554         FogMode getFogMode(void) const;
00555 
00558         const ColourValue& getFogColour(void) const;
00559 
00564         Real getFogStart(void) const;
00565 
00570         Real getFogEnd(void) const;
00571 
00576         Real getFogDensity(void) const;
00577 
00590         void setDepthBias(ushort bias);
00591 
00593         ushort getDepthBias(void) const;
00594 
00630         void setRunOncePerLight(bool enabled, 
00631             bool onlyForOneLightType = true, Light::LightTypes lightType = Light::LT_POINT);
00632 
00634         bool getRunOncePerLight(void) const { return mRunOncePerLight; }
00636         bool getRunOnlyForOneLightType(void) const { return mRunOnlyForOneLightType; }
00639         Light::LightTypes getOnlyLightType() const { return mOnlyLightType; }
00640         
00642         Technique* getParent(void) { return mParent; }
00643 
00653         void setVertexProgram(const String& name);
00660         void setVertexProgramParameters(GpuProgramParametersSharedPtr params);
00662         const String& getVertexProgramName(void);
00664         GpuProgramParametersSharedPtr getVertexProgramParameters(void);
00666         GpuProgram* getVertexProgram(void);
00676         void setFragmentProgram(const String& name);
00681         void setFragmentProgramParameters(GpuProgramParametersSharedPtr params);
00683         const String& getFragmentProgramName(void);
00685         GpuProgramParametersSharedPtr getFragmentProgramParameters(void);
00687         GpuProgram* getFragmentProgram(void);
00688 
00700         Pass* _split(unsigned short numUnits);
00701 
00703         void _load(void);
00705         void _unload(void);
00706         // Is this loaded?
00707         bool isLoaded(void) const;
00708 
00715         unsigned long getHash(void) const;
00716 
00718         void _recalculateHash(void);
00720         void _notifyNeedsRecompile(void);
00721 
00723         void _updateAutoParamsNoLights(const AutoParamDataSource& source);
00725         void _updateAutoParamsLightsOnly(const AutoParamDataSource& source);
00726 
00735         void setTextureFiltering(TextureFilterOptions filterType);
00744         void setTextureAnisotropy(unsigned int maxAniso);
00745         // --------------------------------------------------------------------
00746     };
00747 
00748 
00749 }
00750 
00751 #endif

Copyright © 2002-2003 by The OGRE Team
Last modified Wed Jan 21 00:10:21 2004