All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
ModelMaterial.h
1 // Copyright eeGeo Ltd (2012-2014), All Rights Reserved
2 
3 #pragma once
4 
5 #include "IDiffuseMaterial.h"
6 #include "Types.h"
7 #include "Rendering.h"
8 #include "GlobalLighting.h"
9 #include "GlobalFogging.h"
10 #include "TextureMinifyType.h"
11 #include "ModelShader.h"
12 #include <string>
13 
14 namespace Eegeo
15 {
16  namespace Rendering
17  {
18  namespace Materials
19  {
20  namespace
21  {
22  const float DefaultDepthRangeNear = 0.f;
23  const float DefaultDepthRangeFar = 1.f;
24  }
25 
27  {
28  public:
29  ModelMaterial(const TMaterialId materialId,
30  const std::string& name,
31  Shaders::ModelShader& shader,
32  const Lighting::GlobalLighting& lighting,
33  const Lighting::GlobalFogging& fogging,
35  Rendering::TextureMinifyType textureMinifyType,
36  bool textureRepeat,
37  bool usesAlternateAmbient);
38  ~ModelMaterial();
39 
40  const TMaterialId GetId() const { return m_id; }
41  const std::string& GetName() const { return m_name; }
42  const Shader& GetShader() const { return m_shader; }
43  const float GetAlpha() const { return m_alpha; }
44  void SetAlpha(float alpha);
45  void SetDepthTestingEnabled(bool enabled);
46  const bool GetDepthTestingEnabled() const { return m_depthTesting; }
47 
48  void SetDepthRange(float near, float far);
49 
50  void SetState(Rendering::GLState& glState) const;
51  virtual void SetStatePerRenderable(const Rendering::RenderableBase* renderableBase, Rendering::GLState& glState) const;
52 
53  virtual void SetDiffuseTexture(Rendering::AsyncTexturing::IAsyncTexture& textureId);
54 
55  virtual Rendering::AsyncTexturing::IAsyncTexture& GetTextureId() const { return *m_textureId; }
56 
57  protected:
58 
59  const TMaterialId m_id;
60  const std::string m_name;
61 
62  float m_alpha;
63  bool m_usesAlternateAmbient;
64 
65  Shaders::ModelShader& m_shader;
66  const Lighting::GlobalLighting& m_lighting;
67  const Lighting::GlobalFogging& m_fogging;
68  Rendering::TextureMinifyType m_textureMinifyType;
69  bool m_textureRepeat;
70  bool m_depthTesting;
72 
73  float m_depthRangeNear;
74  float m_depthRangeFar;
75  };
76  }
77  }
78 }