00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef _ATMOSTPHERE_HPP_
00022 #define _ATMOSTPHERE_HPP_
00023
00024 #include "Skylight.hpp"
00025 #include "VecMath.hpp"
00026
00027 #include "Skybright.hpp"
00028 #include "StelFader.hpp"
00029
00030 #ifdef USE_OPENGL_ES2
00031 #include "GLES2/gl2.h"
00032 #else
00033 #include <QtOpenGL>
00034 #endif
00035
00036 class StelProjector;
00037 class StelToneReproducer;
00038 class StelCore;
00039
00043 class Atmosphere
00044 {
00045 public:
00046 Atmosphere(void);
00047 virtual ~Atmosphere(void);
00048 void computeColor(double JD, Vec3d _sunPos, Vec3d moonPos, float moonPhase, StelCore* core,
00049 float latitude = 45.f, float altitude = 200.f,
00050 float temperature = 15.f, float relativeHumidity = 40.f);
00051 void draw(StelCore* core);
00052 void update(double deltaTime) {fader.update((int)(deltaTime*1000));}
00053
00055 void setFadeDuration(float duration) {fader.setDuration((int)(duration*1000.f));}
00057 float getFadeDuration() {return (float)fader.getDuration()/1000.f;}
00058
00060 void setFlagShow(bool b){fader = b;}
00062 bool getFlagShow() const {return fader;}
00063
00066 float getRealDisplayIntensityFactor(void) const {return fader.getInterstate()*eclipseFactor;}
00067
00068
00069 float getFadeIntensity(void) const {return fader.getInterstate();}
00070
00075 float getAverageLuminance(void) const {return averageLuminance;}
00076
00078 void setLightPollutionLuminance(float f) { lightPollutionLuminance = f; }
00080 float getLightPollutionLuminance() const { return lightPollutionLuminance; }
00081
00082 private:
00083 Vec4i viewport;
00084 Skylight sky;
00085 Skybright skyb;
00086 int skyResolutionY,skyResolutionX;
00087
00088 Vec2f* posGrid;
00089 Vec4f* colorGrid;
00090 unsigned int* indices;
00091
00093 float averageLuminance;
00094 float eclipseFactor;
00095 LinearFader fader;
00096 float lightPollutionLuminance;
00097
00099 bool useShader;
00100
00102 class QGLShaderProgram* atmoShaderProgram;
00103 struct {
00104 int alphaWaOverAlphaDa;
00105 int oneOverGamma;
00106 int term2TimesOneOverMaxdLpOneOverGamma;
00107 int brightnessScale;
00108 int sunPos;
00109 int term_x, Ax, Bx, Cx, Dx, Ex;
00110 int term_y, Ay, By, Cy, Dy, Ey;
00111 int projectionMatrix;
00112 int skyVertex;
00113 int skyColor;
00114 } shaderAttribLocations;
00115 };
00116
00117 #endif // _ATMOSTPHERE_HPP_