Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages  

OgreMaterial.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://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 
00105     public:
00106 
00114         Material( const String& name);
00115 
00118         Material();
00119 
00120         ~Material();
00123         Material& operator=( const Material& rhs );
00124 
00127         const String& getName(void) const;
00128 
00132         bool isTransparent(void) const;
00133 
00147         void setReceiveShadows(bool enabled) { mReceiveShadows = enabled; }
00149         bool getReceiveShadows(void) const { return mReceiveShadows; }
00150 
00165         Technique* createTechnique(void);
00167         Technique* getTechnique(unsigned short index);
00169         void removeTechnique(unsigned short index);
00171         void removeAllTechniques(void);
00172         typedef VectorIterator<Techniques> TechniqueIterator;
00174         TechniqueIterator getTechniqueIterator(void);
00181         TechniqueIterator getSupportedTechniqueIterator(void);
00182 
00188         unsigned short getNumLodLevels(void) const { 
00189             return static_cast<unsigned short>(mBestTechniqueList.size()); }
00190 
00202         Technique* getBestTechnique(unsigned short lodIndex = 0);
00203 
00211         void load(void);
00212 
00217         void unload(void);
00218 
00221         Material* clone(const String& newName) const;
00222 
00227         void copyDetailsTo(Material* mat) const;
00228 
00244         void compile(bool autoManageTextureUnits = true);
00245 
00246         // -------------------------------------------------------------------------------
00247         // The following methods are to make migration from previous versions simpler
00248         // and to make code easier to write when dealing with simple materials
00249         // They set the properties which have been moved to Pass for all Techniques and all Passes
00250 
00260         void setAmbient(Real red, Real green, Real blue);
00261 
00271         void setAmbient(const ColourValue& ambient);
00272 
00282         void setDiffuse(Real red, Real green, Real blue);
00283 
00293         void setDiffuse(const ColourValue& diffuse);
00294 
00304         void setSpecular(Real red, Real green, Real blue);
00305 
00315         void setSpecular(const ColourValue& specular);
00316 
00326         void setShininess(Real val);
00327 
00337         void setSelfIllumination(Real red, Real green, Real blue);
00338 
00348         void setSelfIllumination(const ColourValue& selfIllum);
00349 
00359         void setDepthCheckEnabled(bool enabled);
00360 
00370         void setDepthWriteEnabled(bool enabled);
00371 
00381         void setDepthFunction( CompareFunction func );
00382 
00392         void setColourWriteEnabled(bool enabled);
00393 
00403         void setCullingMode( CullingMode mode );
00404 
00414         void setManualCullingMode( ManualCullingMode mode );
00415 
00425         void setLightingEnabled(bool enabled);
00426 
00436         void setShadingMode( ShadeOptions mode );
00437 
00447         void setFog(
00448             bool overrideScene,
00449             FogMode mode = FOG_NONE,
00450             const ColourValue& colour = ColourValue::White,
00451             Real expDensity = 0.001, Real linearStart = 0.0, Real linearEnd = 1.0 );
00452 
00462         void setDepthBias(ushort bias);
00463 
00472         void setTextureFiltering(TextureFilterOptions filterType);
00481         void setTextureAnisotropy(int maxAniso);
00482 
00492         void setSceneBlending( const SceneBlendType sbt );
00493 
00503         void setSceneBlending( const SceneBlendFactor sourceFactor, const SceneBlendFactor destFactor);
00504 
00505 
00507         void _notifyNeedsRecompile(void);
00508 
00521         void setLodLevels(const LodDistanceList& lodDistances);
00529         LodDistanceIterator getLodDistanceIterator(void) const;
00530 
00532         unsigned short getLodIndex(Real d) const;
00534         unsigned short getLodIndexSquaredDepth(Real squaredDepth) const;
00535 
00538         void touch(void) 
00539         { 
00540             if (mCompilationRequired) 
00541                 compile();
00542             // call superclass
00543             Resource::touch();
00544         }
00545 
00546 
00547     };
00548 
00549 } //namespace 
00550 
00551 #endif

Copyright © 2002-2003 by The OGRE Team
Last modified Fri May 14 23:22:20 2004