Stellarium 0.12.4
Atmosphere.hpp
1 /*
2  * Stellarium
3  * Copyright (C) 2003 Fabien Chereau
4  * Copyright (C) 2012 Timothy Reaves
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License
8  * as published by the Free Software Foundation; either version 2
9  * of the License, or (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA.
19  */
20 
21 #ifndef _ATMOSTPHERE_HPP_
22 #define _ATMOSTPHERE_HPP_
23 
24 #include "Skylight.hpp"
25 #include "VecMath.hpp"
26 
27 #include "renderer/StelIndexBuffer.hpp"
28 #include "renderer/StelVertexBuffer.hpp"
29 #include "Skybright.hpp"
30 #include "StelFader.hpp"
31 #include "StelProjector.hpp"
32 
33 class StelProjector;
34 class StelToneReproducer;
35 class StelCore;
36 
41 {
42 public:
43  Atmosphere(void);
44  virtual ~Atmosphere(void);
45 
50  void computeColor(double JD, Vec3d _sunPos, Vec3d moonPos, float moonPhase, StelCore* core,
51  float eclipseFac, float latitude = 45.f, float altitude = 200.f,
52  float temperature = 15.f, float relativeHumidity = 40.f);
53  void draw(StelCore* core, class StelRenderer* renderer);
54  void update(double deltaTime) {fader.update((int)(deltaTime*1000));}
55 
57  void setFadeDuration(float duration) {fader.setDuration((int)(duration*1000.f));}
59  float getFadeDuration() {return (float)fader.getDuration()/1000.f;}
60 
62  void setFlagShow(bool b){fader = b;}
64  bool getFlagShow() const {return fader;}
65 
68  float getRealDisplayIntensityFactor(void) const {return fader.getInterstate()*eclipseFactor;}
69 
70  // let's you know how far faded in or out the atm is (0-1)
71  float getFadeIntensity(void) const {return fader.getInterstate();}
72 
77  float getAverageLuminance(void) const {return averageLuminance;}
78 
80  void setLightPollutionLuminance(float f) { lightPollutionLuminance = f; }
82  float getLightPollutionLuminance() const { return lightPollutionLuminance; }
83 
84 private:
85  // Vertex with a 2D position and a color.
86  struct Vertex
87  {
88  Vec2f position;
89  Vec4f color;
90  Vertex(const Vec2f position, const Vec4f& color) : position(position), color(color) {}
91  VERTEX_ATTRIBUTES(Vec2f Position, Vec4f Color);
92  };
93 
94  Vec4i viewport;
95  Skylight sky;
96  Skybright skyb;
97  int skyResolutionY, skyResolutionX;
98 
100  float averageLuminance;
101  float eclipseFactor;
102  LinearFader fader;
103  float lightPollutionLuminance;
104 
106  class StelGLSLShader* shader;
107 
109  StelVertexBuffer<Vertex>* vertexGrid;
110 
112  QVector<StelIndexBuffer*> rowIndices;
113 
117  class StelRenderer* renderer;
118 
126  bool lazyLoadShader(class StelRenderer* renderer);
127 
131  void updateGrid(const StelProjectorP projector);
132 };
133 
134 #endif // _ATMOSTPHERE_HPP_