OGRE  1.9
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 {
41 
42  // Forward declaration
43  class LodStrategy;
44 
88  class _OgreExport Material : public Resource
89  {
90  friend class SceneManager;
91  friend class MaterialManager;
92 
93  public:
97  protected:
98 
99 
102  void applyDefaults(void);
103 
116 
126 
128  void insertSupportedTechnique(Technique* t);
129 
132  void clearBestTechniqueList(void);
133 
136  void prepareImpl(void);
137 
140  void unprepareImpl(void);
141 
144  void loadImpl(void);
145 
150  void unloadImpl(void);
152  size_t calculateSize(void) const;
153  public:
154 
157  Material(ResourceManager* creator, const String& name, ResourceHandle handle,
158  const String& group, bool isManual = false, ManualResourceLoader* loader = 0);
159 
160  ~Material();
163  Material& operator=( const Material& rhs );
164 
168  bool isTransparent(void) const;
169 
183  void setReceiveShadows(bool enabled) { mReceiveShadows = enabled; }
185  bool getReceiveShadows(void) const { return mReceiveShadows; }
186 
195  void setTransparencyCastsShadows(bool enabled) { mTransparencyCastsShadows = enabled; }
197  bool getTransparencyCastsShadows(void) const { return mTransparencyCastsShadows; }
198 
213  Technique* createTechnique(void);
215  Technique* getTechnique(unsigned short index);
219  Technique* getTechnique(const String& name);
221  unsigned short getNumTechniques(void) const;
223  void removeTechnique(unsigned short index);
225  void removeAllTechniques(void);
228  TechniqueIterator getTechniqueIterator(void);
235  TechniqueIterator getSupportedTechniqueIterator(void);
236 
238  Technique* getSupportedTechnique(unsigned short index);
240  unsigned short getNumSupportedTechniques(void) const;
242  const String& getUnsupportedTechniquesExplanation() const { return mUnsupportedReasons; }
243 
249  unsigned short getNumLodLevels(unsigned short schemeIndex) const;
255  unsigned short getNumLodLevels(const String& schemeName) const;
256 
272  Technique* getBestTechnique(unsigned short lodIndex = 0, const Renderable* rend = 0);
273 
274 
280  MaterialPtr clone(const String& newName, bool changeGroup = false,
281  const String& newGroup = StringUtil::BLANK) const;
282 
287  void copyDetailsTo(MaterialPtr& mat) const;
288 
304  void compile(bool autoManageTextureUnits = true);
305 
306  // -------------------------------------------------------------------------------
307  // The following methods are to make migration from previous versions simpler
308  // and to make code easier to write when dealing with simple materials
309  // They set the properties which have been moved to Pass for all Techniques and all Passes
310 
320  void setPointSize(Real ps);
321 
331  void setAmbient(Real red, Real green, Real blue);
332 
342  void setAmbient(const ColourValue& ambient);
343 
353  void setDiffuse(Real red, Real green, Real blue, Real alpha);
354 
364  void setDiffuse(const ColourValue& diffuse);
365 
375  void setSpecular(Real red, Real green, Real blue, Real alpha);
376 
386  void setSpecular(const ColourValue& specular);
387 
397  void setShininess(Real val);
398 
408  void setSelfIllumination(Real red, Real green, Real blue);
409 
419  void setSelfIllumination(const ColourValue& selfIllum);
420 
430  void setDepthCheckEnabled(bool enabled);
431 
441  void setDepthWriteEnabled(bool enabled);
442 
452  void setDepthFunction( CompareFunction func );
453 
463  void setColourWriteEnabled(bool enabled);
464 
474  void setCullingMode( CullingMode mode );
475 
485  void setManualCullingMode( ManualCullingMode mode );
486 
496  void setLightingEnabled(bool enabled);
497 
507  void setShadingMode( ShadeOptions mode );
508 
518  void setFog(
519  bool overrideScene,
520  FogMode mode = FOG_NONE,
521  const ColourValue& colour = ColourValue::White,
522  Real expDensity = 0.001, Real linearStart = 0.0, Real linearEnd = 1.0 );
523 
533  void setDepthBias(float constantBias, float slopeScaleBias);
534 
543  void setTextureFiltering(TextureFilterOptions filterType);
552  void setTextureAnisotropy(int maxAniso);
553 
563  void setSceneBlending( const SceneBlendType sbt );
564 
574  void setSeparateSceneBlending( const SceneBlendType sbt, const SceneBlendType sbta );
575 
585  void setSceneBlending( const SceneBlendFactor sourceFactor, const SceneBlendFactor destFactor);
586 
596  void setSeparateSceneBlending( const SceneBlendFactor sourceFactor, const SceneBlendFactor destFactor, const SceneBlendFactor sourceFactorAlpha, const SceneBlendFactor destFactorAlpha);
597 
599  void _notifyNeedsRecompile(void);
600 
615  void setLodLevels(const LodValueList& lodValues);
616 
624  LodValueIterator getLodValueIterator(void) const;
625 
633  LodValueIterator getUserLodValueIterator(void) const;
634 
640  ushort getLodIndex(Real value) const;
641 
643  const LodStrategy *getLodStrategy() const;
645  void setLodStrategy(LodStrategy *lodStrategy);
646 
649  void touch(void)
650  {
651  if (mCompilationRequired)
652  compile();
653  // call superclass
654  Resource::touch();
655  }
656 
668  bool applyTextureAliases(const AliasTextureNamePairList& aliasList, const bool apply = true) const;
669 
674  {
675  return mCompilationRequired;
676  }
677 
678 
679  };
683 } //namespace
684 
685 #include "OgreHeaderSuffix.h"
686 
687 #endif
Techniques mSupportedTechniques
Supported techniques of any sort.
Definition: OgreMaterial.h:108
String mUnsupportedReasons
Text description of why any techniques are not supported.
Definition: OgreMaterial.h:125
const String & getUnsupportedTechniquesExplanation() const
Gets a string explaining why any techniques are not supported.
Definition: OgreMaterial.h:242
ManualCullingMode
Manual culling modes based on vertex normals.
Definition: OgreCommon.h:150
float Real
Software floating point type.
#define _OgreExport
Definition: OgrePlatform.h:260
FogMode
Fog modes.
Definition: OgreCommon.h:121
Class representing colour.
static const ColourValue White
Manages the organisation and rendering of a 'scene' i.e.
vector< Technique * >::type Techniques
Definition: OgreMaterial.h:104
VectorIterator< Techniques > TechniqueIterator
Definition: OgreMaterial.h:226
void setReceiveShadows(bool enabled)
Sets whether objects using this material will receive shadows.
Definition: OgreMaterial.h:183
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:88
const LodStrategy * mLodStrategy
Definition: OgreMaterial.h:119
Interface describing a manual resource loader.
Definition: OgreResource.h:514
Class representing an approach to rendering this particular Material.
Definition: OgreTechnique.h:53
Strategy for determining level of detail.
vector< Real >::type LodValueList
distance list used to specify LOD
Definition: OgreMaterial.h:95
SceneBlendFactor
Blending factors for manually blending objects with the scene.
LodValueList mLodValues
Definition: OgreMaterial.h:118
ConstVectorIterator< LodValueList > LodValueIterator
Definition: OgreMaterial.h:96
CullingMode
Hardware culling modes based on vertex winding.
Definition: OgreCommon.h:135
Abstract class defining the interface all renderable objects must implement.
No fog. Duh.
Definition: OgreCommon.h:124
bool getTransparencyCastsShadows(void) const
Returns whether or not objects using this material be classified as opaque to the shadow caster syste...
Definition: OgreMaterial.h:197
Class for managing Material settings for Ogre.
bool mTransparencyCastsShadows
Definition: OgreMaterial.h:121
virtual void touch(void)
'Touches' the resource to indicate it has been used.
ShadeOptions
Light shading modes.
Definition: OgreCommon.h:113
void setTransparencyCastsShadows(bool enabled)
Sets whether objects using this material be classified as opaque to the shadow caster system...
Definition: OgreMaterial.h:195
Concrete IteratorWrapper for const access to the underlying container.
std::map< K, V, P, A > type
unsigned short ushort
Abstract class representing a loadable resource (e.g.
Definition: OgreResource.h:79
unsigned long long int ResourceHandle
Definition: OgreResource.h:41
static const String BLANK
Constant blank string, useful for returning by ref where local does not exist.
Definition: OgreString.h:196
Defines a generic resource handler.
void touch(void)
'Touches' the resource to indicate it has been used.
Definition: OgreMaterial.h:649
LodValueList mUserLodValues
Definition: OgreMaterial.h:117
_StringBase String
Techniques mTechniques
All techniques, supported and unsupported.
Definition: OgreMaterial.h:106
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:553
CompareFunction
Comparison functions used for the depth/stencil buffer operations and others.
Definition: OgreCommon.h:64
map< unsigned short, LodTechniques * >::type BestTechniquesBySchemeList
Definition: OgreMaterial.h:110
BestTechniquesBySchemeList mBestTechniquesBySchemeList
Map of scheme -> list of LOD techniques.
Definition: OgreMaterial.h:115
bool getCompilationRequired() const
Gets the compilation status of the material.
Definition: OgreMaterial.h:673
bool getReceiveShadows(void) const
Returns whether or not objects using this material will receive shadows.
Definition: OgreMaterial.h:185
TextureFilterOptions
High-level filtering options providing shortcuts to settings the minification, magnification and mip ...
Definition: OgreCommon.h:78
bool mCompilationRequired
Does this material require compilation?
Definition: OgreMaterial.h:123
map< unsigned short, Technique * >::type LodTechniques
Definition: OgreMaterial.h:109