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 © 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 _Material_H__ 00026 #define _Material_H__ 00027 00028 #include "OgrePrerequisites.h" 00029 00030 #include "OgreResource.h" 00031 #include "OgreIteratorWrappers.h" 00032 #include "OgreCommon.h" 00033 #include "OgreColourValue.h" 00034 #include "OgreBlendMode.h" 00035 00036 00037 namespace Ogre { 00038 00076 class _OgreExport Material : public Resource 00077 { 00078 friend class SceneManager; 00079 friend class MaterialManager; 00080 00081 public: 00083 typedef std::vector<Real> LodDistanceList; 00084 typedef ConstVectorIterator<LodDistanceList> LodDistanceIterator; 00085 protected: 00086 00088 static Material* mDefaultSettings; 00089 00092 void applyDefaults(void); 00093 00094 typedef std::vector<Technique*> Techniques; 00095 Techniques mTechniques; 00096 Techniques mSupportedTechniques; 00097 typedef std::map<unsigned short, Technique*> BestTechniqueList; 00098 BestTechniqueList mBestTechniqueList; 00099 00101 bool mCompilationRequired; 00102 LodDistanceList mLodDistances; 00103 bool mReceiveShadows; 00104 bool mTransparencyCastsShadows; 00105 00106 public: 00107 00115 Material( const String& name); 00116 00119 Material(); 00120 00121 ~Material(); 00124 Material& operator=( const Material& rhs ); 00125 00128 const String& getName(void) const; 00129 00133 bool isTransparent(void) const; 00134 00148 void setReceiveShadows(bool enabled) { mReceiveShadows = enabled; } 00150 bool getReceiveShadows(void) const { return mReceiveShadows; } 00151 00160 void setTransparencyCastsShadows(bool enabled) { mTransparencyCastsShadows = enabled; } 00162 bool getTransparencyCastsShadows(void) const { return mTransparencyCastsShadows; } 00163 00178 Technique* createTechnique(void); 00180 Technique* getTechnique(unsigned short index); 00182 unsigned short getNumTechniques(void) const; 00184 void removeTechnique(unsigned short index); 00186 void removeAllTechniques(void); 00187 typedef VectorIterator<Techniques> TechniqueIterator; 00189 TechniqueIterator getTechniqueIterator(void); 00196 TechniqueIterator getSupportedTechniqueIterator(void); 00197 00199 Technique* getSupportedTechnique(unsigned short index); 00201 unsigned short getNumSupportedTechniques(void) const; 00202 00208 unsigned short getNumLodLevels(void) const { 00209 return static_cast<unsigned short>(mBestTechniqueList.size()); } 00210 00222 Technique* getBestTechnique(unsigned short lodIndex = 0); 00223 00231 void load(void); 00232 00237 void unload(void); 00238 00241 Material* clone(const String& newName) const; 00242 00247 void copyDetailsTo(Material* mat) const; 00248 00264 void compile(bool autoManageTextureUnits = true); 00265 00266 // ------------------------------------------------------------------------------- 00267 // The following methods are to make migration from previous versions simpler 00268 // and to make code easier to write when dealing with simple materials 00269 // They set the properties which have been moved to Pass for all Techniques and all Passes 00270 00280 void setAmbient(Real red, Real green, Real blue); 00281 00291 void setAmbient(const ColourValue& ambient); 00292 00302 void setDiffuse(Real red, Real green, Real blue, Real alpha); 00303 00313 void setDiffuse(const ColourValue& diffuse); 00314 00324 void setSpecular(Real red, Real green, Real blue, Real alpha); 00325 00335 void setSpecular(const ColourValue& specular); 00336 00346 void setShininess(Real val); 00347 00357 void setSelfIllumination(Real red, Real green, Real blue); 00358 00368 void setSelfIllumination(const ColourValue& selfIllum); 00369 00379 void setDepthCheckEnabled(bool enabled); 00380 00390 void setDepthWriteEnabled(bool enabled); 00391 00401 void setDepthFunction( CompareFunction func ); 00402 00412 void setColourWriteEnabled(bool enabled); 00413 00423 void setCullingMode( CullingMode mode ); 00424 00434 void setManualCullingMode( ManualCullingMode mode ); 00435 00445 void setLightingEnabled(bool enabled); 00446 00456 void setShadingMode( ShadeOptions mode ); 00457 00467 void setFog( 00468 bool overrideScene, 00469 FogMode mode = FOG_NONE, 00470 const ColourValue& colour = ColourValue::White, 00471 Real expDensity = 0.001, Real linearStart = 0.0, Real linearEnd = 1.0 ); 00472 00482 void setDepthBias(ushort bias); 00483 00492 void setTextureFiltering(TextureFilterOptions filterType); 00501 void setTextureAnisotropy(int maxAniso); 00502 00512 void setSceneBlending( const SceneBlendType sbt ); 00513 00523 void setSceneBlending( const SceneBlendFactor sourceFactor, const SceneBlendFactor destFactor); 00524 00525 00527 void _notifyNeedsRecompile(void); 00528 00541 void setLodLevels(const LodDistanceList& lodDistances); 00549 LodDistanceIterator getLodDistanceIterator(void) const; 00550 00552 unsigned short getLodIndex(Real d) const; 00554 unsigned short getLodIndexSquaredDepth(Real squaredDepth) const; 00555 00558 void touch(void) 00559 { 00560 if (mCompilationRequired) 00561 compile(); 00562 // call superclass 00563 Resource::touch(); 00564 } 00565 00566 00567 }; 00568 00569 } //namespace 00570 00571 #endif
Copyright © 2002-2003 by The OGRE Team
Last modified Sun Nov 28 19:48:31 2004