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-2012 Torus Knot Software Ltd 00008 00009 Permission is hereby granted, free of charge, to any person obtaining a copy 00010 of this software and associated documentation files (the "Software"), to deal 00011 in the Software without restriction, including without limitation the rights 00012 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 00013 copies of the Software, and to permit persons to whom the Software is 00014 furnished to do so, subject to the following conditions: 00015 00016 The above copyright notice and this permission notice shall be included in 00017 all copies or substantial portions of the Software. 00018 00019 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 00020 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 00021 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 00022 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 00023 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 00024 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 00025 THE SOFTWARE. 00026 ----------------------------------------------------------------------------- 00027 */ 00028 #ifndef __Technique_H__ 00029 #define __Technique_H__ 00030 00031 #include "OgrePrerequisites.h" 00032 #include "OgreIteratorWrappers.h" 00033 #include "OgreBlendMode.h" 00034 #include "OgreCommon.h" 00035 #include "OgrePass.h" 00036 #include "OgreIteratorWrappers.h" 00037 #include "OgreRenderSystemCapabilities.h" 00038 #include "OgreUserObjectBindings.h" 00039 00040 namespace Ogre { 00053 class _OgreExport Technique : public TechniqueAlloc 00054 { 00055 protected: 00056 // illumination pass state type 00057 enum IlluminationPassesState 00058 { 00059 IPS_COMPILE_DISABLED = -1, 00060 IPS_NOT_COMPILED = 0, 00061 IPS_COMPILED = 1 00062 }; 00063 00064 typedef vector<Pass*>::type Passes; 00066 Passes mPasses; 00068 IlluminationPassList mIlluminationPasses; 00069 Material* mParent; // raw pointer since we don't want child to stop parent's destruction 00070 bool mIsSupported; 00071 IlluminationPassesState mIlluminationPassesCompilationPhase; 00073 unsigned short mLodIndex; 00077 unsigned short mSchemeIndex; 00078 String mName; // optional name for the technique 00079 00081 void clearIlluminationPasses(void); 00083 bool checkManuallyOrganisedIlluminationPasses(); 00084 00085 00090 MaterialPtr mShadowCasterMaterial; 00095 String mShadowCasterMaterialName; 00100 MaterialPtr mShadowReceiverMaterial; 00105 String mShadowReceiverMaterialName; 00106 00107 // User objects binding. 00108 UserObjectBindings mUserObjectBindings; 00109 00110 public: 00114 enum IncludeOrExclude 00115 { 00117 INCLUDE = 0, 00119 EXCLUDE = 1 00120 }; 00122 struct GPUVendorRule 00123 { 00124 GPUVendor vendor; 00125 IncludeOrExclude includeOrExclude; 00126 GPUVendorRule() 00127 : vendor(GPU_UNKNOWN), includeOrExclude(EXCLUDE) {} 00128 GPUVendorRule(GPUVendor v, IncludeOrExclude ie) 00129 : vendor(v), includeOrExclude(ie) {} 00130 }; 00132 struct GPUDeviceNameRule 00133 { 00134 String devicePattern; 00135 IncludeOrExclude includeOrExclude; 00136 bool caseSensitive; 00137 GPUDeviceNameRule() 00138 : includeOrExclude(EXCLUDE), caseSensitive(false) {} 00139 GPUDeviceNameRule(const String& pattern, IncludeOrExclude ie, bool caseSen) 00140 : devicePattern(pattern), includeOrExclude(ie), caseSensitive(caseSen) {} 00141 }; 00142 typedef vector<GPUVendorRule>::type GPUVendorRuleList; 00143 typedef vector<GPUDeviceNameRule>::type GPUDeviceNameRuleList; 00144 protected: 00145 GPUVendorRuleList mGPUVendorRules; 00146 GPUDeviceNameRuleList mGPUDeviceNameRules; 00147 public: 00149 Technique(Material* parent); 00151 Technique(Material* parent, const Technique& oth); 00152 ~Technique(); 00158 bool isSupported(void) const; 00162 String _compile(bool autoManageTextureUnits); 00164 bool checkGPURules(StringUtil::StrStreamType& errors); 00166 bool checkHardwareSupport(bool autoManageTextureUnits, StringUtil::StrStreamType& compileErrors); 00168 void _compileIlluminationPasses(void); 00169 00170 00181 Pass* createPass(void); 00183 Pass* getPass(unsigned short index); 00187 Pass* getPass(const String& name); 00189 unsigned short getNumPasses(void) const; 00191 void removePass(unsigned short index); 00193 void removeAllPasses(void); 00197 bool movePass(const unsigned short sourceIndex, const unsigned short destinationIndex); 00198 typedef VectorIterator<Passes> PassIterator; 00200 const PassIterator getPassIterator(void); 00201 typedef VectorIterator<IlluminationPassList> IlluminationPassIterator; 00203 const IlluminationPassIterator getIlluminationPassIterator(void); 00205 Material* getParent(void) const { return mParent; } 00206 00208 Technique& operator=(const Technique& rhs); 00209 00211 const String& getResourceGroup(void) const; 00212 00221 bool isTransparent(void) const; 00222 00228 bool isTransparentSortingEnabled(void) const; 00229 00235 bool isTransparentSortingForced(void) const; 00236 00238 void _prepare(void); 00240 void _unprepare(void); 00242 void _load(void); 00244 void _unload(void); 00245 00246 // Is this loaded? 00247 bool isLoaded(void) const; 00248 00250 void _notifyNeedsRecompile(void); 00251 00254 Ogre::MaterialPtr getShadowCasterMaterial() const; 00257 void setShadowCasterMaterial(Ogre::MaterialPtr val); 00260 void setShadowCasterMaterial(const Ogre::String &name); 00263 Ogre::MaterialPtr getShadowReceiverMaterial() const; 00266 void setShadowReceiverMaterial(Ogre::MaterialPtr val); 00269 void setShadowReceiverMaterial(const Ogre::String &name); 00270 00271 // ------------------------------------------------------------------------------- 00272 // The following methods are to make migration from previous versions simpler 00273 // and to make code easier to write when dealing with simple materials 00274 // They set the properties which have been moved to Pass for all Techniques and all Passes 00275 00284 void setPointSize(Real ps); 00285 00294 void setAmbient(Real red, Real green, Real blue); 00295 00304 void setAmbient(const ColourValue& ambient); 00305 00314 void setDiffuse(Real red, Real green, Real blue, Real alpha); 00315 00324 void setDiffuse(const ColourValue& diffuse); 00325 00334 void setSpecular(Real red, Real green, Real blue, Real alpha); 00335 00344 void setSpecular(const ColourValue& specular); 00345 00354 void setShininess(Real val); 00355 00364 void setSelfIllumination(Real red, Real green, Real blue); 00365 00374 void setSelfIllumination(const ColourValue& selfIllum); 00375 00384 void setDepthCheckEnabled(bool enabled); 00385 00394 void setDepthWriteEnabled(bool enabled); 00395 00404 void setDepthFunction( CompareFunction func ); 00405 00414 void setColourWriteEnabled(bool enabled); 00415 00424 void setCullingMode( CullingMode mode ); 00425 00434 void setManualCullingMode( ManualCullingMode mode ); 00435 00444 void setLightingEnabled(bool enabled); 00445 00454 void setShadingMode( ShadeOptions mode ); 00455 00464 void setFog( 00465 bool overrideScene, 00466 FogMode mode = FOG_NONE, 00467 const ColourValue& colour = ColourValue::White, 00468 Real expDensity = 0.001, Real linearStart = 0.0, Real linearEnd = 1.0 ); 00469 00478 void setDepthBias(float constantBias, float slopeScaleBias); 00479 00488 void setTextureFiltering(TextureFilterOptions filterType); 00497 void setTextureAnisotropy(unsigned int maxAniso); 00498 00507 void setSceneBlending( const SceneBlendType sbt ); 00508 00517 void setSeparateSceneBlending( const SceneBlendType sbt, const SceneBlendType sbta ); 00518 00527 void setSceneBlending( const SceneBlendFactor sourceFactor, const SceneBlendFactor destFactor); 00528 00537 void setSeparateSceneBlending( const SceneBlendFactor sourceFactor, const SceneBlendFactor destFactor, const SceneBlendFactor sourceFactorAlpha, const SceneBlendFactor destFactorAlpha); 00538 00555 void setLodIndex(unsigned short index); 00557 unsigned short getLodIndex(void) const { return mLodIndex; } 00558 00576 void setSchemeName(const String& schemeName); 00580 const String& getSchemeName(void) const; 00581 00583 unsigned short _getSchemeIndex(void) const; 00584 00586 bool isDepthWriteEnabled(void) const; 00587 00589 bool isDepthCheckEnabled(void) const; 00590 00592 bool hasColourWriteDisabled(void) const; 00593 00599 void setName(const String& name); 00601 const String& getName(void) const { return mName; } 00602 00614 bool applyTextureAliases(const AliasTextureNamePairList& aliasList, const bool apply = true) const; 00615 00616 00632 void addGPUVendorRule(GPUVendor vendor, IncludeOrExclude includeOrExclude); 00646 void addGPUVendorRule(const GPUVendorRule& rule); 00650 void removeGPUVendorRule(GPUVendor vendor); 00651 typedef ConstVectorIterator<GPUVendorRuleList> GPUVendorRuleIterator; 00653 GPUVendorRuleIterator getGPUVendorRuleIterator() const; 00654 00672 void addGPUDeviceNameRule(const String& devicePattern, IncludeOrExclude includeOrExclude, bool caseSensitive = false); 00687 void addGPUDeviceNameRule(const GPUDeviceNameRule& rule); 00691 void removeGPUDeviceNameRule(const String& devicePattern); 00692 typedef ConstVectorIterator<GPUDeviceNameRuleList> GPUDeviceNameRuleIterator; 00694 GPUDeviceNameRuleIterator getGPUDeviceNameRuleIterator() const; 00695 00700 UserObjectBindings& getUserObjectBindings() { return mUserObjectBindings; } 00701 00706 const UserObjectBindings& getUserObjectBindings() const { return mUserObjectBindings; } 00707 00708 }; 00709 00713 } 00714 #endif
Copyright © 2012 Torus Knot Software Ltd
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.
Last modified Fri May 25 23:36:28 2012