All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
LightmappedPackedDiffuseMaterial.h
1 // Copyright eeGeo Ltd (2012-2014), All Rights Reserved
2 
3 #pragma once
4 
5 #include "Types.h"
6 #include "IDiffuseMaterial.h"
7 #include "IdTypes.h"
8 #include "Lighting.h"
9 #include "Rendering.h"
10 #include "GLHelpers.h"
11 #include "LightmappedPackedDiffuseShader.h"
12 #include <string>
13 
14 namespace Eegeo
15 {
16  namespace Rendering
17  {
18  namespace Materials
19  {
21  {
22  public:
24  const TMaterialId materialId,
25  const std::string& name,
27  const Lighting::GlobalLighting& lighting,
28  const Lighting::GlobalFogging& fogging,
30  Rendering::TextureMinifyType textureMinifyType,
31  bool useAlternativeAmbient,
32  bool textureRepeat
33  );
34 
35  bool IsUsingAlternativeAmbient() const { return m_useAlternativeAmbient; }
36  void UseAlternativeAmbient(bool useAlternativeAmbient) { m_useAlternativeAmbient = useAlternativeAmbient; }
37 
38  const TMaterialId GetId() const { return m_id; }
39  const Shader& GetShader() const { return m_shader; }
40  const std::string& GetName() const { return m_name; }
41 
42  void SetDiffuseTexture(Rendering::AsyncTexturing::IAsyncTexture& textureId) { m_textureId = &textureId; }
43  Rendering::AsyncTexturing::IAsyncTexture& GetTextureId() const { return *m_textureId; }
44 
45  void SetState(Rendering::GLState& glState) const;
46 
47  void SetStatePerRenderable(const Rendering::RenderableBase* renderableBase, Rendering::GLState& glState) const;
48  protected:
49  void BindLightmapTexture(Rendering::GLState& glState, TTextureId lightmapId) const
50  {
51  Helpers::GLHelpers::BindTexture2D(glState, m_shader.GetLightmapSamplerId(), lightmapId, Rendering::TextureMinify_Nearest, false);
52  }
53 
54  const TMaterialId m_id;
55  const std::string m_name;
57  const Lighting::GlobalLighting& m_lighting;
58  const Lighting::GlobalFogging& m_fogging;
60  Rendering::TextureMinifyType m_textureMinifyType;
61  bool m_textureRepeat;
62  bool m_useAlternativeAmbient;
63  };
64  }
65  }
66 }