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 String mName; // optional name for the pass 00061 uint32 mHash; // pass hash 00062 //------------------------------------------------------------------------- 00063 // Colour properties, only applicable in fixed-function passes 00064 ColourValue mAmbient; 00065 ColourValue mDiffuse; 00066 ColourValue mSpecular; 00067 ColourValue mEmissive; 00068 Real mShininess; 00069 TrackVertexColourType mTracking; 00070 //------------------------------------------------------------------------- 00071 00072 //------------------------------------------------------------------------- 00073 // Blending factors 00074 SceneBlendFactor mSourceBlendFactor; 00075 SceneBlendFactor mDestBlendFactor; 00076 //------------------------------------------------------------------------- 00077 00078 //------------------------------------------------------------------------- 00079 // Depth buffer settings 00080 bool mDepthCheck; 00081 bool mDepthWrite; 00082 CompareFunction mDepthFunc; 00083 ushort mDepthBias; 00084 00085 // Colour buffer settings 00086 bool mColourWrite; 00087 00088 // Alpha reject settings 00089 CompareFunction mAlphaRejectFunc; 00090 unsigned char mAlphaRejectVal; 00091 //------------------------------------------------------------------------- 00092 00093 //------------------------------------------------------------------------- 00094 // Culling mode 00095 CullingMode mCullMode; 00096 ManualCullingMode mManualCullMode; 00097 //------------------------------------------------------------------------- 00098 00100 bool mLightingEnabled; 00102 unsigned short mMaxSimultaneousLights; 00104 bool mIteratePerLight; 00105 // Should it only be run for a certain light type? 00106 bool mRunOnlyForOneLightType; 00107 Light::LightTypes mOnlyLightType; 00108 00110 ShadeOptions mShadeOptions; 00112 PolygonMode mPolygonMode; 00113 00114 //------------------------------------------------------------------------- 00115 // Fog 00116 bool mFogOverride; 00117 FogMode mFogMode; 00118 ColourValue mFogColour; 00119 Real mFogStart; 00120 Real mFogEnd; 00121 Real mFogDensity; 00122 //------------------------------------------------------------------------- 00123 00125 typedef std::vector<TextureUnitState*> TextureUnitStates; 00126 TextureUnitStates mTextureUnitStates; 00127 00128 // Vertex program details 00129 GpuProgramUsage *mVertexProgramUsage; 00130 // Vertex program details 00131 GpuProgramUsage *mShadowCasterVertexProgramUsage; 00132 // Vertex program details 00133 GpuProgramUsage *mShadowReceiverVertexProgramUsage; 00134 // Fragment program details 00135 GpuProgramUsage *mFragmentProgramUsage; 00136 // Fragment program details 00137 GpuProgramUsage *mShadowReceiverFragmentProgramUsage; 00138 // Is this pass queued for deletion? 00139 bool mQueuedForDeletion; 00140 // number of pass iterations to perform 00141 size_t mPassIterationCount; 00142 // point size, applies when not using per-vertex point size 00143 Real mPointSize; 00144 Real mPointMinSize; 00145 Real mPointMaxSize; 00146 bool mPointSpritesEnabled; 00147 bool mPointAttenuationEnabled; 00148 // constant, linear, quadratic coeffs 00149 Real mPointAttenuationCoeffs[3]; 00150 public: 00151 typedef std::set<Pass*> PassSet; 00152 protected: 00154 static PassSet msDirtyHashList; 00156 static PassSet msPassGraveyard; 00157 public: 00159 Pass(Technique* parent, unsigned short index); 00161 Pass(Technique* parent, unsigned short index, const Pass& oth ); 00163 Pass& operator=(const Pass& oth); 00164 ~Pass(); 00165 00167 bool isProgrammable(void) const { return mVertexProgramUsage || mFragmentProgramUsage; } 00169 bool hasVertexProgram(void) const { return mVertexProgramUsage != NULL; } 00171 bool hasFragmentProgram(void) const { return mFragmentProgramUsage != NULL; } 00173 bool hasShadowCasterVertexProgram(void) const { return mShadowCasterVertexProgramUsage != NULL; } 00175 bool hasShadowReceiverVertexProgram(void) const { return mShadowReceiverVertexProgramUsage != NULL; } 00177 bool hasShadowReceiverFragmentProgram(void) const { return mShadowReceiverFragmentProgramUsage != NULL; } 00178 00179 00181 unsigned short getIndex(void) const { return mIndex; } 00182 /* Set the name of the pass 00183 @remarks 00184 The name of the pass is optional. Its usefull in material scripts where a material could inherit 00185 from another material and only want to modify a particalar pass. 00186 */ 00187 void setName(const String& name); 00189 const String& getName(void) const { return mName; } 00190 00202 void setAmbient(Real red, Real green, Real blue); 00203 00216 void setAmbient(const ColourValue& ambient); 00217 00228 void setDiffuse(Real red, Real green, Real blue, Real alpha); 00229 00240 void setDiffuse(const ColourValue& diffuse); 00241 00254 void setSpecular(Real red, Real green, Real blue, Real alpha); 00255 00268 void setSpecular(const ColourValue& specular); 00269 00275 void setShininess(Real val); 00276 00286 void setSelfIllumination(Real red, Real green, Real blue); 00287 00297 void setSelfIllumination(const ColourValue& selfIllum); 00298 00301 void setVertexColourTracking(TrackVertexColourType tracking); 00302 00308 Real getPointSize(void) const; 00309 00325 void setPointSize(Real ps); 00326 00332 void setPointSpritesEnabled(bool enabled); 00333 00337 bool getPointSpritesEnabled(void) const; 00338 00355 void setPointAttenuation(bool enabled, 00356 Real constant = 0.0f, Real linear = 1.0f, Real quadratic = 0.0f); 00357 00359 bool isPointAttenuationEnabled(void) const; 00360 00362 Real getPointAttenuationConstant(void) const; 00364 Real getPointAttenuationLinear(void) const; 00366 Real getPointAttenuationQuadratic(void) const; 00367 00369 void setPointMinSize(Real min); 00371 Real getPointMinSize(void) const; 00375 void setPointMaxSize(Real max); 00379 Real getPointMaxSize(void) const; 00380 00383 const ColourValue& getAmbient(void) const; 00384 00387 const ColourValue& getDiffuse(void) const; 00388 00391 const ColourValue& getSpecular(void) const; 00392 00395 const ColourValue& getSelfIllumination(void) const; 00396 00399 Real getShininess(void) const; 00400 00403 TrackVertexColourType getVertexColourTracking(void) const; 00404 00409 TextureUnitState* createTextureUnitState(void); 00420 TextureUnitState* createTextureUnitState( const String& textureName, unsigned short texCoordSet = 0); 00426 void addTextureUnitState(TextureUnitState* state); 00429 TextureUnitState* getTextureUnitState(unsigned short index); 00433 TextureUnitState* getTextureUnitState(const String& name); 00436 const TextureUnitState* getTextureUnitState(unsigned short index) const; 00440 const TextureUnitState* getTextureUnitState(const String& name) const; 00441 00448 unsigned short getTextureUnitStateIndex(const TextureUnitState* state); 00449 00450 typedef VectorIterator<TextureUnitStates> TextureUnitStateIterator; 00452 TextureUnitStateIterator getTextureUnitStateIterator(void); 00453 00454 typedef ConstVectorIterator<TextureUnitStates> ConstTextureUnitStateIterator; 00456 ConstTextureUnitStateIterator getTextureUnitStateIterator(void) const; 00457 00462 void removeTextureUnitState(unsigned short index); 00463 00466 void removeAllTextureUnitStates(void); 00467 00470 size_t getNumTextureUnitStates(void) const 00471 { 00472 return mTextureUnitStates.size(); 00473 } 00474 00491 void setSceneBlending( const SceneBlendType sbt ); 00492 00515 void setSceneBlending( const SceneBlendFactor sourceFactor, const SceneBlendFactor destFactor); 00516 00519 SceneBlendFactor getSourceBlendFactor() const; 00520 00523 SceneBlendFactor getDestBlendFactor() const; 00524 00526 bool isTransparent(void) const; 00527 00539 void setDepthCheckEnabled(bool enabled); 00540 00545 bool getDepthCheckEnabled(void) const; 00546 00557 void setDepthWriteEnabled(bool enabled); 00558 00563 bool getDepthWriteEnabled(void) const; 00564 00572 void setDepthFunction( CompareFunction func ); 00577 CompareFunction getDepthFunction(void) const; 00578 00589 void setColourWriteEnabled(bool enabled); 00591 bool getColourWriteEnabled(void) const; 00592 00606 void setCullingMode( CullingMode mode ); 00607 00610 CullingMode getCullingMode(void) const; 00611 00625 void setManualCullingMode( ManualCullingMode mode ); 00626 00631 ManualCullingMode getManualCullingMode(void) const; 00632 00641 void setLightingEnabled(bool enabled); 00642 00645 bool getLightingEnabled(void) const; 00646 00655 void setMaxSimultaneousLights(unsigned short maxLights); 00657 unsigned short getMaxSimultaneousLights(void) const; 00658 00663 void setShadingMode( ShadeOptions mode ); 00664 00667 ShadeOptions getShadingMode(void) const; 00668 00673 void setPolygonMode( PolygonMode mode ); 00674 00677 PolygonMode getPolygonMode(void) const; 00678 00708 void setFog( 00709 bool overrideScene, 00710 FogMode mode = FOG_NONE, 00711 const ColourValue& colour = ColourValue::White, 00712 Real expDensity = 0.001, Real linearStart = 0.0, Real linearEnd = 1.0 ); 00713 00716 bool getFogOverride(void) const; 00717 00722 FogMode getFogMode(void) const; 00723 00726 const ColourValue& getFogColour(void) const; 00727 00732 Real getFogStart(void) const; 00733 00738 Real getFogEnd(void) const; 00739 00744 Real getFogDensity(void) const; 00745 00758 void setDepthBias(ushort bias); 00759 00761 ushort getDepthBias(void) const; 00762 00771 void setAlphaRejectSettings(CompareFunction func, unsigned char value); 00772 00775 void setAlphaRejectFunction(CompareFunction func); 00776 00779 void setAlphaRejectValue(unsigned char val); 00780 00783 CompareFunction getAlphaRejectFunction(void) const { return mAlphaRejectFunc; } 00784 00787 unsigned char getAlphaRejectValue(void) const { return mAlphaRejectVal; } 00825 void setIteratePerLight(bool enabled, 00826 bool onlyForOneLightType = true, Light::LightTypes lightType = Light::LT_POINT); 00827 00829 bool getIteratePerLight(void) const { return mIteratePerLight; } 00831 bool getRunOnlyForOneLightType(void) const { return mRunOnlyForOneLightType; } 00834 Light::LightTypes getOnlyLightType() const { return mOnlyLightType; } 00835 00837 Technique* getParent(void) { return mParent; } 00838 00840 const String& getResourceGroup(void) const; 00841 00858 void setVertexProgram(const String& name, bool resetParams = true); 00865 void setVertexProgramParameters(GpuProgramParametersSharedPtr params); 00867 const String& getVertexProgramName(void) const; 00869 GpuProgramParametersSharedPtr getVertexProgramParameters(void) const; 00871 const GpuProgramPtr& getVertexProgram(void) const; 00872 00873 00903 void setShadowCasterVertexProgram(const String& name); 00910 void setShadowCasterVertexProgramParameters(GpuProgramParametersSharedPtr params); 00912 const String& getShadowCasterVertexProgramName(void) const; 00914 GpuProgramParametersSharedPtr getShadowCasterVertexProgramParameters(void) const; 00917 const GpuProgramPtr& getShadowCasterVertexProgram(void) const; 00918 00944 void setShadowReceiverVertexProgram(const String& name); 00951 void setShadowReceiverVertexProgramParameters(GpuProgramParametersSharedPtr params); 00952 00973 void setShadowReceiverFragmentProgram(const String& name); 00980 void setShadowReceiverFragmentProgramParameters(GpuProgramParametersSharedPtr params); 00981 00983 const String& getShadowReceiverVertexProgramName(void) const; 00985 GpuProgramParametersSharedPtr getShadowReceiverVertexProgramParameters(void) const; 00988 const GpuProgramPtr& getShadowReceiverVertexProgram(void) const; 00989 00991 const String& getShadowReceiverFragmentProgramName(void) const; 00993 GpuProgramParametersSharedPtr getShadowReceiverFragmentProgramParameters(void) const; 00996 const GpuProgramPtr& getShadowReceiverFragmentProgram(void) const; 00997 01014 void setFragmentProgram(const String& name, bool resetParams = true); 01019 void setFragmentProgramParameters(GpuProgramParametersSharedPtr params); 01021 const String& getFragmentProgramName(void) const; 01023 GpuProgramParametersSharedPtr getFragmentProgramParameters(void) const; 01025 const GpuProgramPtr& getFragmentProgram(void) const; 01026 01038 Pass* _split(unsigned short numUnits); 01039 01041 void _notifyIndex(unsigned short index); 01042 01044 void _load(void); 01046 void _unload(void); 01047 // Is this loaded? 01048 bool isLoaded(void) const; 01049 01056 uint32 getHash(void) const; 01058 void _dirtyHash(void); 01065 void _recalculateHash(void); 01067 void _notifyNeedsRecompile(void); 01068 01070 void _updateAutoParamsNoLights(const AutoParamDataSource& source) const; 01072 void _updateAutoParamsLightsOnly(const AutoParamDataSource& source) const; 01073 01082 void setTextureFiltering(TextureFilterOptions filterType); 01091 void setTextureAnisotropy(unsigned int maxAniso); 01095 static const PassSet& getDirtyHashList(void) 01096 { return msDirtyHashList; } 01099 static const PassSet& getPassGraveyard(void) 01100 { return msPassGraveyard; } 01108 static void clearDirtyHashList(void) { msDirtyHashList.clear(); } 01109 01111 static void processPendingPassUpdates(void); 01112 01114 void queueForDeletion(void); 01115 01118 bool isAmbientOnly(void) const; 01119 01133 void setPassIterationCount(const size_t count) { mPassIterationCount = count; } 01134 01137 size_t getPassIterationCount(void) const { return mPassIterationCount; } 01138 01150 bool applyTextureAliases(const AliasTextureNamePairList& aliasList, const bool apply = true) const; 01151 01152 }; 01153 01154 enum IlluminationStage 01155 { 01157 IS_AMBIENT, 01159 IS_PER_LIGHT, 01161 IS_DECAL 01162 }; 01172 struct IlluminationPass 01173 { 01174 IlluminationStage stage; 01176 Pass* pass; 01178 bool destroyOnShutdown; 01180 Pass* originalPass; 01181 }; 01182 01183 typedef std::vector<IlluminationPass*> IlluminationPassList; 01184 01185 01186 } 01187 01188 #endif
Copyright © 2000-2005 by The OGRE Team
This work is licensed under a Creative Commons Attribution-ShareAlike 2.5 License.
Last modified Sun Mar 12 14:37:46 2006