OGRE  2.0
Object-Oriented Graphics Rendering Engine
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
OgreMaterial.h
Go to the documentation of this file.
1 /*
2 -----------------------------------------------------------------------------
3 This source file is part of OGRE
4 (Object-oriented Graphics Rendering Engine)
5 For the latest info, see http://www.ogre3d.org/
6 
7 Copyright (c) 2000-2014 Torus Knot Software Ltd
8 
9 Permission is hereby granted, free of charge, to any person obtaining a copy
10 of this software and associated documentation files (the "Software"), to deal
11 in the Software without restriction, including without limitation the rights
12 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 copies of the Software, and to permit persons to whom the Software is
14 furnished to do so, subject to the following conditions:
15 
16 The above copyright notice and this permission notice shall be included in
17 all copies or substantial portions of the Software.
18 
19 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25 THE SOFTWARE.
26 -----------------------------------------------------------------------------
27 */
28 #ifndef _Material_H__
29 #define _Material_H__
30 
31 #include "OgrePrerequisites.h"
32 
33 #include "OgreResource.h"
34 #include "OgreIteratorWrappers.h"
35 #include "OgreCommon.h"
36 #include "OgreColourValue.h"
37 #include "OgreBlendMode.h"
38 #include "OgreHeaderPrefix.h"
39 
40 namespace Ogre {
84  class _OgreExport Material : public Resource
85  {
86  friend class SceneManager;
87  friend class MaterialManager;
88 
89  public:
93  protected:
94 
95 
98  void applyDefaults(void);
99 
112 
121 
123  void insertSupportedTechnique(Technique* t);
124 
127  void clearBestTechniqueList(void);
128 
131  void prepareImpl(void);
132 
135  void unprepareImpl(void);
136 
139  void loadImpl(void);
140 
145  void unloadImpl(void);
147  size_t calculateSize(void) const;
148  public:
149 
152  Material(ResourceManager* creator, const String& name, ResourceHandle handle,
153  const String& group, bool isManual = false, ManualResourceLoader* loader = 0);
154 
155  ~Material();
158  Material& operator=( const Material& rhs );
159 
163  bool isTransparent(void) const;
164 
178  void setReceiveShadows(bool enabled) { mReceiveShadows = enabled; }
180  bool getReceiveShadows(void) const { return mReceiveShadows; }
181 
190  void setTransparencyCastsShadows(bool enabled) { mTransparencyCastsShadows = enabled; }
192  bool getTransparencyCastsShadows(void) const { return mTransparencyCastsShadows; }
193 
208  Technique* createTechnique(void);
210  Technique* getTechnique(unsigned short index);
214  Technique* getTechnique(const String& name);
216  unsigned short getNumTechniques(void) const;
218  void removeTechnique(unsigned short index);
220  void removeAllTechniques(void);
223  TechniqueIterator getTechniqueIterator(void);
230  TechniqueIterator getSupportedTechniqueIterator(void);
231 
233  Technique* getSupportedTechnique(unsigned short index);
235  unsigned short getNumSupportedTechniques(void) const;
237  const String& getUnsupportedTechniquesExplanation() const { return mUnsupportedReasons; }
238 
244  unsigned short getNumLodLevels(unsigned short schemeIndex) const;
250  unsigned short getNumLodLevels(const String& schemeName) const;
251 
267  Technique* getBestTechnique(unsigned short lodIndex = 0, const Renderable* rend = 0);
268 
269 
275  MaterialPtr clone(const String& newName, bool changeGroup = false,
276  const String& newGroup = BLANKSTRING) const;
277 
282  void copyDetailsTo(MaterialPtr& mat) const;
283 
299  void compile(bool autoManageTextureUnits = true);
300 
301  // -------------------------------------------------------------------------------
302  // The following methods are to make migration from previous versions simpler
303  // and to make code easier to write when dealing with simple materials
304  // They set the properties which have been moved to Pass for all Techniques and all Passes
305 
315  void setPointSize(Real ps);
316 
326  void setAmbient(Real red, Real green, Real blue);
327 
337  void setAmbient(const ColourValue& ambient);
338 
348  void setDiffuse(Real red, Real green, Real blue, Real alpha);
349 
359  void setDiffuse(const ColourValue& diffuse);
360 
370  void setSpecular(Real red, Real green, Real blue, Real alpha);
371 
381  void setSpecular(const ColourValue& specular);
382 
392  void setShininess(Real val);
393 
403  void setSelfIllumination(Real red, Real green, Real blue);
404 
414  void setSelfIllumination(const ColourValue& selfIllum);
415 
425  void setDepthCheckEnabled(bool enabled);
426 
436  void setDepthWriteEnabled(bool enabled);
437 
447  void setDepthFunction( CompareFunction func );
448 
458  void setColourWriteEnabled(bool enabled);
459 
469  void setCullingMode( CullingMode mode );
470 
480  void setManualCullingMode( ManualCullingMode mode );
481 
491  void setLightingEnabled(bool enabled);
492 
502  void setShadingMode( ShadeOptions mode );
503 
513  void setFog(
514  bool overrideScene,
515  FogMode mode = FOG_NONE,
516  const ColourValue& colour = ColourValue::White,
517  Real expDensity = 0.001, Real linearStart = 0.0, Real linearEnd = 1.0 );
518 
528  void setDepthBias(float constantBias, float slopeScaleBias);
529 
538  void setTextureFiltering(TextureFilterOptions filterType);
547  void setTextureAnisotropy(int maxAniso);
548 
558  void setSceneBlending( const SceneBlendType sbt );
559 
569  void setSeparateSceneBlending( const SceneBlendType sbt, const SceneBlendType sbta );
570 
580  void setSceneBlending( const SceneBlendFactor sourceFactor, const SceneBlendFactor destFactor);
581 
591  void setSeparateSceneBlending( const SceneBlendFactor sourceFactor, const SceneBlendFactor destFactor, const SceneBlendFactor sourceFactorAlpha, const SceneBlendFactor destFactorAlpha);
592 
594  void _notifyNeedsRecompile(void);
595 
610  void setLodLevels(const LodValueArray& lodValues);
611 
612  const LodValueArray* _getLodValues(void) const { return &mLodValues; }
613 
621  LodValueIterator getLodValueIterator(void) const;
622 
630  LodValueIterator getUserLodValueIterator(void) const;
631 
634  void touch(void)
635  {
636  if (mCompilationRequired)
637  compile();
638  // call superclass
639  Resource::touch();
640  }
641 
653  bool applyTextureAliases(const AliasTextureNamePairList& aliasList, const bool apply = true) const;
654 
659  {
660  return mCompilationRequired;
661  }
662 
663 
664  };
668 } //namespace
669 
670 #include "OgreHeaderSuffix.h"
671 
672 #endif
Techniques mSupportedTechniques
Supported techniques of any sort.
Definition: OgreMaterial.h:104
String mUnsupportedReasons
Text description of why any techniques are not supported.
Definition: OgreMaterial.h:120
FastArray< Real > LodValueArray
distance list used to specify LOD
Definition: OgreMaterial.h:91
const String & getUnsupportedTechniquesExplanation() const
Gets a string explaining why any techniques are not supported.
Definition: OgreMaterial.h:237
ManualCullingMode
Manual culling modes based on vertex normals.
Definition: OgreCommon.h:181
float Real
Software floating point type.
#define _OgreExport
Definition: OgrePlatform.h:255
FogMode
Fog modes.
Definition: OgreCommon.h:152
Class representing colour.
static const ColourValue White
Manages the organisation and rendering of a 'scene' i.e.
ConstVectorIterator< LodValueArray > LodValueIterator
Definition: OgreMaterial.h:92
vector< Technique * >::type Techniques
Definition: OgreMaterial.h:100
VectorIterator< Techniques > TechniqueIterator
Definition: OgreMaterial.h:221
void setReceiveShadows(bool enabled)
Sets whether objects using this material will receive shadows.
Definition: OgreMaterial.h:178
SceneBlendType
Types of blending that you can specify between an object and the existing contents of the scene...
Class encapsulates rendering properties of an object.
Definition: OgreMaterial.h:84
Interface describing a manual resource loader.
Definition: OgreResource.h:498
Class representing an approach to rendering this particular Material.
Definition: OgreTechnique.h:50
const LodValueArray * _getLodValues(void) const
Definition: OgreMaterial.h:612
SceneBlendFactor
Blending factors for manually blending objects with the scene.
const String BLANKSTRING
Constant blank string, useful for returning by ref where local does not exist.
Definition: OgreCommon.h:574
CullingMode
Hardware culling modes based on vertex winding.
Definition: OgreCommon.h:166
Abstract class defining the interface all renderable objects must implement.
No fog. Duh.
Definition: OgreCommon.h:155
bool getTransparencyCastsShadows(void) const
Returns whether or not objects using this material be classified as opaque to the shadow caster syste...
Definition: OgreMaterial.h:192
Class for managing Material settings for Ogre.
bool mTransparencyCastsShadows
Definition: OgreMaterial.h:116
virtual void touch(void)
'Touches' the resource to indicate it has been used.
ShadeOptions
Light shading modes.
Definition: OgreCommon.h:144
void setTransparencyCastsShadows(bool enabled)
Sets whether objects using this material be classified as opaque to the shadow caster system...
Definition: OgreMaterial.h:190
Concrete IteratorWrapper for const access to the underlying container.
LodValueArray mLodValues
Definition: OgreMaterial.h:114
LodValueArray mUserLodValues
Definition: OgreMaterial.h:113
std::map< K, V, P, A > type
Abstract class representing a loadable resource (e.g.
Definition: OgreResource.h:77
unsigned long long int ResourceHandle
Definition: OgreResource.h:39
Defines a generic resource handler.
void touch(void)
'Touches' the resource to indicate it has been used.
Definition: OgreMaterial.h:634
_StringBase String
Definition: OgreCommon.h:53
Techniques mTechniques
All techniques, supported and unsupported.
Definition: OgreMaterial.h:102
Concrete IteratorWrapper for nonconst access to the underlying container.
map< String, String >::type AliasTextureNamePairList
Alias / Texture name pair (first = alias, second = texture name)
Definition: OgreCommon.h:583
CompareFunction
Comparison functions used for the depth/stencil buffer operations and others.
Definition: OgreCommon.h:74
map< unsigned short, LodTechniques * >::type BestTechniquesBySchemeList
Definition: OgreMaterial.h:106
BestTechniquesBySchemeList mBestTechniquesBySchemeList
Map of scheme -> list of LOD techniques.
Definition: OgreMaterial.h:111
bool getCompilationRequired() const
Gets the compilation status of the material.
Definition: OgreMaterial.h:658
bool getReceiveShadows(void) const
Returns whether or not objects using this material will receive shadows.
Definition: OgreMaterial.h:180
TextureFilterOptions
High-level filtering options providing shortcuts to settings the minification, magnification and mip ...
Definition: OgreCommon.h:109
bool mCompilationRequired
Does this material require compilation?
Definition: OgreMaterial.h:118
map< unsigned short, Technique * >::type LodTechniques
Definition: OgreMaterial.h:105