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-2013 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

Copyright © 2012 Torus Knot Software Ltd
Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.
Last modified Wed Oct 23 2013 06:57:24