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 // Vertex program details 00124 GpuProgramUsage *mShadowCasterVertexProgramUsage; 00125 // Vertex program details 00126 GpuProgramUsage *mShadowReceiverVertexProgramUsage; 00127 // Fragment program details 00128 GpuProgramUsage *mFragmentProgramUsage; 00129 // Is this pass queued for deletion? 00130 bool mQueuedForDeletion; 00131 public: 00132 typedef std::set<Pass*> PassSet; 00133 protected: 00135 static PassSet msDirtyHashList; 00137 static PassSet msPassGraveyard; 00138 public: 00140 Pass(Technique* parent, unsigned short index); 00142 Pass(Technique* parent, unsigned short index, const Pass& oth ); 00144 Pass& operator=(const Pass& oth); 00145 ~Pass(); 00146 00148 bool isProgrammable(void) const { return mVertexProgramUsage || mFragmentProgramUsage; } 00149 00151 bool hasVertexProgram(void) const { return mVertexProgramUsage != NULL; } 00152 00154 bool hasFragmentProgram(void) const { return mFragmentProgramUsage != NULL; } 00155 00157 unsigned short getIndex(void) const { return mIndex; } 00169 void setAmbient(Real red, Real green, Real blue); 00170 00183 void setAmbient(const ColourValue& ambient); 00184 00195 void setDiffuse(Real red, Real green, Real blue); 00196 00207 void setDiffuse(const ColourValue& diffuse); 00208 00221 void setSpecular(Real red, Real green, Real blue); 00222 00235 void setSpecular(const ColourValue& specular); 00236 00242 void setShininess(Real val); 00243 00253 void setSelfIllumination(Real red, Real green, Real blue); 00254 00264 void setSelfIllumination(const ColourValue& selfIllum); 00265 00268 const ColourValue& getAmbient(void) const; 00269 00272 const ColourValue& getDiffuse(void) const; 00273 00276 const ColourValue& getSpecular(void) const; 00277 00280 const ColourValue& getSelfIllumination(void) const; 00281 00284 Real getShininess(void) const; 00285 00290 TextureUnitState* createTextureUnitState(void); 00301 TextureUnitState* createTextureUnitState( const String& textureName, unsigned short texCoordSet = 0); 00303 void addTextureUnitState(TextureUnitState* state); 00306 TextureUnitState* getTextureUnitState(unsigned short index); 00307 00308 typedef VectorIterator<TextureUnitStates> TextureUnitStateIterator; 00310 TextureUnitStateIterator getTextureUnitStateIterator(void); 00311 00316 void removeTextureUnitState(unsigned short index); 00317 00320 void removeAllTextureUnitStates(void); 00321 00324 size_t getNumTextureUnitStates(void) const 00325 { 00326 return mTextureUnitStates.size(); 00327 } 00328 00345 void setSceneBlending( const SceneBlendType sbt ); 00346 00369 void setSceneBlending( const SceneBlendFactor sourceFactor, const SceneBlendFactor destFactor); 00370 00373 SceneBlendFactor getSourceBlendFactor() const; 00374 00377 SceneBlendFactor getDestBlendFactor() const; 00378 00380 bool isTransparent(void) const; 00381 00393 void setDepthCheckEnabled(bool enabled); 00394 00399 bool getDepthCheckEnabled(void) const; 00400 00411 void setDepthWriteEnabled(bool enabled); 00412 00417 bool getDepthWriteEnabled(void) const; 00418 00426 void setDepthFunction( CompareFunction func ); 00431 CompareFunction getDepthFunction(void) const; 00432 00443 void setColourWriteEnabled(bool enabled); 00445 bool getColourWriteEnabled(void) const; 00446 00460 void setCullingMode( CullingMode mode ); 00461 00464 CullingMode getCullingMode(void) const; 00465 00479 void setManualCullingMode( ManualCullingMode mode ); 00480 00485 ManualCullingMode getManualCullingMode(void) const; 00486 00495 void setLightingEnabled(bool enabled); 00496 00499 bool getLightingEnabled(void) const; 00500 00509 void setMaxSimultaneousLights(unsigned short maxLights); 00511 unsigned short getMaxSimultaneousLights(void) const; 00512 00517 void setShadingMode( ShadeOptions mode ); 00518 00521 ShadeOptions getShadingMode(void) const; 00522 00523 00553 void setFog( 00554 bool overrideScene, 00555 FogMode mode = FOG_NONE, 00556 const ColourValue& colour = ColourValue::White, 00557 Real expDensity = 0.001, Real linearStart = 0.0, Real linearEnd = 1.0 ); 00558 00561 bool getFogOverride(void) const; 00562 00567 FogMode getFogMode(void) const; 00568 00571 const ColourValue& getFogColour(void) const; 00572 00577 Real getFogStart(void) const; 00578 00583 Real getFogEnd(void) const; 00584 00589 Real getFogDensity(void) const; 00590 00603 void setDepthBias(ushort bias); 00604 00606 ushort getDepthBias(void) const; 00607 00643 void setRunOncePerLight(bool enabled, 00644 bool onlyForOneLightType = true, Light::LightTypes lightType = Light::LT_POINT); 00645 00647 bool getRunOncePerLight(void) const { return mRunOncePerLight; } 00649 bool getRunOnlyForOneLightType(void) const { return mRunOnlyForOneLightType; } 00652 Light::LightTypes getOnlyLightType() const { return mOnlyLightType; } 00653 00655 Technique* getParent(void) { return mParent; } 00656 00673 void setVertexProgram(const String& name, bool resetParams = true); 00680 void setVertexProgramParameters(GpuProgramParametersSharedPtr params); 00682 const String& getVertexProgramName(void) const; 00684 GpuProgramParametersSharedPtr getVertexProgramParameters(void); 00686 GpuProgram* getVertexProgram(void); 00687 00688 00718 void setShadowCasterVertexProgram(const String& name); 00725 void setShadowCasterVertexProgramParameters(GpuProgramParametersSharedPtr params); 00727 const String& getShadowCasterVertexProgramName(void) const; 00729 GpuProgramParametersSharedPtr getShadowCasterVertexProgramParameters(void); 00732 GpuProgram* getShadowCasterVertexProgram(void); 00733 00759 void setShadowReceiverVertexProgram(const String& name); 00766 void setShadowReceiverVertexProgramParameters(GpuProgramParametersSharedPtr params); 00768 const String& getShadowReceiverVertexProgramName(void) const; 00770 GpuProgramParametersSharedPtr getShadowReceiverVertexProgramParameters(void); 00773 GpuProgram* getShadowReceiverVertexProgram(void); 00774 00775 00792 void setFragmentProgram(const String& name, bool resetParams = true); 00797 void setFragmentProgramParameters(GpuProgramParametersSharedPtr params); 00799 const String& getFragmentProgramName(void) const; 00801 GpuProgramParametersSharedPtr getFragmentProgramParameters(void); 00803 GpuProgram* getFragmentProgram(void); 00804 00816 Pass* _split(unsigned short numUnits); 00817 00819 void _load(void); 00821 void _unload(void); 00822 // Is this loaded? 00823 bool isLoaded(void) const; 00824 00831 unsigned long getHash(void) const; 00833 void _dirtyHash(void); 00840 void _recalculateHash(void); 00842 void _notifyNeedsRecompile(void); 00843 00845 void _updateAutoParamsNoLights(const AutoParamDataSource& source); 00847 void _updateAutoParamsLightsOnly(const AutoParamDataSource& source); 00848 00857 void setTextureFiltering(TextureFilterOptions filterType); 00866 void setTextureAnisotropy(unsigned int maxAniso); 00870 static const PassSet& getDirtyHashList(void) 00871 { return msDirtyHashList; } 00874 static const PassSet& getPassGraveyard(void) 00875 { return msPassGraveyard; } 00883 static void clearDirtyHashList(void) { msDirtyHashList.clear(); } 00884 00886 static void processPendingPassUpdates(void); 00887 00889 void queueForDeletion(void); 00890 00893 bool isAmbientOnly(void) const; 00894 00895 00896 }; 00897 00898 enum IlluminationStage 00899 { 00901 IS_AMBIENT, 00903 IS_PER_LIGHT, 00905 IS_DECAL 00906 }; 00916 struct IlluminationPass 00917 { 00918 IlluminationStage stage; 00920 Pass* pass; 00922 bool destroyOnShutdown; 00924 Pass* originalPass; 00925 }; 00926 00927 typedef std::vector<IlluminationPass*> IlluminationPassList; 00928 00929 00930 } 00931 00932 #endif
Copyright © 2002-2003 by The OGRE Team
Last modified Fri May 14 23:22:32 2004