Stellarium 0.11.3
Home · All Namespaces · All Classes · Functions · Coding Style · Scripting · Plugins · File Structure

core/modules/Atmosphere.hpp

00001 /*
00002  * Stellarium
00003  * Copyright (C) 2003 Fabien Chereau
00004  * Copyright (C) 2012 Timothy Reaves
00005  *
00006  * This program is free software; you can redistribute it and/or
00007  * modify it under the terms of the GNU General Public License
00008  * as published by the Free Software Foundation; either version 2
00009  * of the License, or (at your option) any later version.
00010  *
00011  * This program is distributed in the hope that it will be useful,
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014  * GNU General Public License for more details.
00015  *
00016  * You should have received a copy of the GNU General Public License
00017  * along with this program; if not, write to the Free Software
00018  * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA  02110-1335, USA.
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     // let's you know how far faded in or out the atm is (0-1)
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_
Generated on Thu May 31 10:37:17 2012 for Stellarium by  doxygen 1.6.3