All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
WeatherOverlayController.h
1 // Copyright eeGeo Ltd (2012-2014), All Rights Reserved
2 
3 #pragma once
4 
5 #include "Types.h"
6 #include "VectorMath.h"
7 #include "Rendering.h"
8 #include "Location.h"
9 
10 namespace Eegeo
11 {
12  namespace Weather
13  {
15  {
17  : uvOffset(v2::Zero())
18  , uvVelocity(v2::Zero())
19  , uvScale(v2::Zero())
20  , inverseScale(0.f)
21  , alpha(0.f)
22  {
23  }
24  WeatherEffectLayer2(v2 uvOffset, v2 uvVelocity, float alpha, float inverseScale)
25  : uvOffset(uvOffset)
26  , uvVelocity(uvVelocity)
27  , uvScale(v2::Zero())
28  , inverseScale(inverseScale)
29  , alpha(alpha)
30  {
31  Eegeo_ASSERT(inverseScale > 0.0f);
32  }
33 
34  float GetAlpha() const { return alpha; }
35  v2 GetUVOffset() const { return uvOffset; }
36  v2 GetUVScale() const { return uvScale; }
37 
38  void Update(float dt, float viewportAspectRatio)
39  {
40  uvOffset += uvVelocity * (inverseScale * dt);
41  uvOffset.x -= (int)uvOffset.x;
42  uvOffset.y -= (int)uvOffset.y;
43 
44  uvScale = inverseScale * ((viewportAspectRatio >= 1.f) ? v2(viewportAspectRatio, 1.f) : v2(1.f, 1.f/viewportAspectRatio));
45  }
46  private:
47  v2 uvOffset;
48  v2 uvVelocity;
49  v2 uvScale;
50  float inverseScale;
51  float alpha;
52 
53  };
54 
56  {
57  public:
59 
61 
62  void Update(float dt, const dv3& ecefInterestPoint, float cameraAltitude, float viewportAspectRatio);
63 
64  void SetIntensity(float value) { m_globalIntensity = Clamp(value, 0.0f, 1.0f); }
65 
66  WeatherEffectLayer2& GetWeatherEffectLayerOne(){ return m_effectLayerOne;}
67  WeatherEffectLayer2& GetWeatherEffectLayerTwo(){ return m_effectLayerTwo;}
68  float GetCurrentIntensity(){return m_currentIntensity;}
69 
70  void SetWeatherLayersParameters(bool hasOverlayEffect,
71  v2 uvOffsetOne, v2 uvVelocityOne, float alphaOne, float scaleOne,
72  v2 uvOffsetTwo, v2 uvVelocityTwo, float alphaTwo, float scaleTwo);
73 
74  bool HasOverlayEffect() const;
75 
76  private:
77  float CalculateIntensityAtCameraAltitude(float cameraAltitude) const;
78 
79  WeatherEffectLayer2 m_effectLayerOne;
80  WeatherEffectLayer2 m_effectLayerTwo;
81 
82  bool m_hasOverlayEffect;
83  float m_globalIntensity;
84  float m_currentIntensity;
85  };
86  }
87 }