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     protected:
00085 
00087         static Material* mDefaultSettings;
00088 
00091         void applyDefaults(void);
00092 
00093         typedef std::vector<Technique*> Techniques;
00094         Techniques mTechniques;
00095         Techniques mSupportedTechniques;
00096         typedef std::map<unsigned short, Technique*> BestTechniqueList;
00097         BestTechniqueList mBestTechniqueList;
00098 
00100         bool mCompilationRequired;
00101         LodDistanceList mLodDistances;
00102 
00103     public:
00104 
00112         Material( const String& name);
00113 
00116         Material();
00117 
00118         ~Material();
00121         Material& operator=( const Material& rhs );
00122 
00125         const String& getName(void) const;
00126 
00130         bool isTransparent(void) const;
00131 
00146         Technique* createTechnique(void);
00148         Technique* getTechnique(unsigned short index);
00150         void removeTechnique(unsigned short index);
00152         void removeAllTechniques(void);
00153         typedef VectorIterator<Techniques> TechniqueIterator;
00155         TechniqueIterator getTechniqueIterator(void);
00162         TechniqueIterator getSupportedTechniqueIterator(void);
00163 
00169         unsigned short getNumLodLevels(void) const { 
00170             return static_cast<unsigned short>(mBestTechniqueList.size()); }
00171 
00183         Technique* getBestTechnique(unsigned short lodIndex = 0);
00184 
00192         void load(void);
00193 
00198         void unload(void);
00199 
00202         Material* clone(const String& newName) const;
00203 
00208         void copyDetailsTo(Material* mat) const;
00209 
00225         void compile(bool autoManageTextureUnits = true);
00226 
00227         // -------------------------------------------------------------------------------
00228         // The following methods are to make migration from previous versions simpler
00229         // and to make code easier to write when dealing with simple materials
00230         // They set the properties which have been moved to Pass for all Techniques and all Passes
00231 
00241         void setAmbient(Real red, Real green, Real blue);
00242 
00252         void setAmbient(const ColourValue& ambient);
00253 
00263         void setDiffuse(Real red, Real green, Real blue);
00264 
00274         void setDiffuse(const ColourValue& diffuse);
00275 
00285         void setSpecular(Real red, Real green, Real blue);
00286 
00296         void setSpecular(const ColourValue& specular);
00297 
00307         void setShininess(Real val);
00308 
00318         void setSelfIllumination(Real red, Real green, Real blue);
00319 
00329         void setSelfIllumination(const ColourValue& selfIllum);
00330 
00340         void setDepthCheckEnabled(bool enabled);
00341 
00351         void setDepthWriteEnabled(bool enabled);
00352 
00362         void setDepthFunction( CompareFunction func );
00363 
00373         void setColourWriteEnabled(bool enabled);
00374 
00384         void setCullingMode( CullingMode mode );
00385 
00395         void setManualCullingMode( ManualCullingMode mode );
00396 
00406         void setLightingEnabled(bool enabled);
00407 
00417         void setShadingMode( ShadeOptions mode );
00418 
00428         void setFog(
00429             bool overrideScene,
00430             FogMode mode = FOG_NONE,
00431             const ColourValue& colour = ColourValue::White,
00432             Real expDensity = 0.001, Real linearStart = 0.0, Real linearEnd = 1.0 );
00433 
00443         void setDepthBias(ushort bias);
00444 
00453         void setTextureFiltering(TextureFilterOptions filterType);
00462         void setTextureAnisotropy(int maxAniso);
00463 
00473         void setSceneBlending( const SceneBlendType sbt );
00474 
00484         void setSceneBlending( const SceneBlendFactor sourceFactor, const SceneBlendFactor destFactor);
00485 
00486 
00488         void _notifyNeedsRecompile(void);
00489 
00502         void setLodLevels(const LodDistanceList& lodDistances);
00503 
00505         unsigned short getLodIndex(Real d) const;
00507         unsigned short getLodIndexSquaredDepth(Real squaredDepth) const;
00508 
00511         void touch(void) 
00512         { 
00513             if (mCompilationRequired) 
00514                 compile();
00515             // call superclass
00516             Resource::touch();
00517         }
00518 
00519 
00520     };
00521 
00522 } //namespace 
00523 
00524 #endif

Copyright © 2002-2003 by The OGRE Team
Last modified Wed Jan 21 00:10:15 2004