All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
WaterMaterial2.h
1 // Copyright eeGeo Ltd (2012-2014), All Rights Reserved
2 
3 #pragma once
4 
5 #include "Types.h"
6 #include "IMaterial.h"
7 #include "IdTypes.h"
8 #include "Lighting.h"
9 #include "Rendering.h"
10 #include "WaterShader.h"
11 #include "TextureMinifyType.h"
12 #include "VectorMath.h"
13 #include <string>
14 
15 namespace Eegeo
16 {
17  namespace Rendering
18  {
19  namespace Materials
20  {
21  class WaterMaterial2 : protected Eegeo::NonCopyable, public IMaterial
22  {
23  public:
25  const TMaterialId materialId,
26  const std::string& name,
27  Shaders::WaterShader& shader,
28  const Lighting::GlobalLighting& lighting,
29  const Lighting::GlobalFogging& fogging,
30  AsyncTexturing::IAsyncTexture& diffuseTextureId,
31  AsyncTexturing::IAsyncTexture& normalMapTextureId,
32  AsyncTexturing::IAsyncTexture& reflectionTextureId,
33  Rendering::TextureMinifyType textureMinifyType,
34  bool useAlternativeAmbient,
35  bool textureRepeat,
36  Eegeo::v2 animationScaleUV,
37  Eegeo::v2 animationWrapUV,
38  float envMapFadeoutAltitude
39  );
40 
41  bool IsUsingAlternativeAmbient() const { return m_useAlternativeAmbient; }
42  void UseAlternativeAmbient(bool useAlternativeAmbient) { m_useAlternativeAmbient = useAlternativeAmbient; }
43 
44  const TMaterialId GetId() const { return m_id; }
45  const Shader& GetShader() const { return m_shader; }
46  const std::string& GetName() const { return m_name; }
47 
48  void SetDiffuseTexture(AsyncTexturing::IAsyncTexture& textureId) { m_diffuseTextureId = &textureId; }
49  AsyncTexturing::IAsyncTexture& GetDiffuseTextureId() const { return *m_diffuseTextureId; }
50 
51  void SetNormalMapTexture(AsyncTexturing::IAsyncTexture& textureId) { m_normalMapTextureId = &textureId; }
52  AsyncTexturing::IAsyncTexture& GetNormalMapTextureId() const { return *m_normalMapTextureId; }
53 
54  void SetReflectionTexture(AsyncTexturing::IAsyncTexture* textureId) { m_reflectionMapTextureId = textureId; }
55  AsyncTexturing::IAsyncTexture* GetReflectionTextureId() const { return m_reflectionMapTextureId; }
56 
57  void UpdateMaterial(float deltaTime, const dv3& ecefCameraPosition);
58 
59  void SetState(Rendering::GLState& glState) const;
60 
61  void SetStatePerRenderable(const Rendering::RenderableBase* renderableBase, Rendering::GLState& glState) const;
62 
63  static m44 CalculateViewToCubeMapMatrix(const Renderables::WaterRenderable& waterRenderable);
64 
65  protected:
66  const TMaterialId m_id;
67  const std::string m_name;
68  Shaders::WaterShader& m_shader;
69  const Lighting::GlobalLighting& m_lighting;
70  const Lighting::GlobalFogging& m_fogging;
71  Rendering::AsyncTexturing::IAsyncTexture* m_diffuseTextureId;
72  Rendering::AsyncTexturing::IAsyncTexture* m_normalMapTextureId;
73  Rendering::AsyncTexturing::IAsyncTexture* m_reflectionMapTextureId;
74  Rendering::AsyncTexturing::IAsyncTexture* m_defaultReflectionCubeMapTextureId;
75  Rendering::TextureMinifyType m_textureMinifyType;
76  bool m_textureRepeat;
77  bool m_useAlternativeAmbient;
78  float m_altitudeScale;
79  Eegeo::v2 m_animationScaleUV;
80  Eegeo::v2 m_animationWrapUV;
81  Eegeo::v4 m_animationStateUV;
82  const float m_envMapFadeoutAltitude;
83  };
84  }
85  }
86 }