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  *
00005  * This program is free software; you can redistribute it and/or
00006  * modify it under the terms of the GNU General Public License
00007  * as published by the Free Software Foundation; either version 2
00008  * of the License, or (at your option) any later version.
00009  *
00010  * This program is distributed in the hope that it will be useful,
00011  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013  * GNU General Public License for more details.
00014  *
00015  * You should have received a copy of the GNU General Public License
00016  * along with this program; if not, write to the Free Software
00017  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00018  */
00019 
00020 #ifndef _ATMOSTPHERE_HPP_
00021 #define _ATMOSTPHERE_HPP_
00022 
00023 #include "Skylight.hpp"
00024 #include "VecMath.hpp"
00025 #include "StelNavigator.hpp"
00026 #include "Skybright.hpp"
00027 #include "StelFader.hpp"
00028 
00029 #ifdef USE_OPENGL_ES2
00030  #include "GLES2/gl2.h"
00031 #else
00032  #include <QtOpenGL>
00033 #endif
00034 
00035 class StelProjector;
00036 class StelToneReproducer;
00037 class StelCore;
00038 
00042 class Atmosphere
00043 {
00044 public:
00045     Atmosphere(void);
00046     virtual ~Atmosphere(void);
00047     void computeColor(double JD, Vec3d _sunPos, Vec3d moonPos, float moonPhase, StelCore* core,
00048         float latitude = 45.f, float altitude = 200.f,
00049         float temperature = 15.f, float relativeHumidity = 40.f);
00050     void draw(StelCore* core);
00051     void update(double deltaTime) {fader.update((int)(deltaTime*1000));}
00052 
00054     void setFadeDuration(float duration) {fader.setDuration((int)(duration*1000.f));}
00056     float getFadeDuration() {return (float)fader.getDuration()/1000.f;}
00057 
00059     void setFlagShow(bool b){fader = b;}
00061     bool getFlagShow() const {return fader;}
00062 
00065     float getRealDisplayIntensityFactor(void) const {return fader.getInterstate()*eclipseFactor;}
00066 
00067     // let's you know how far faded in or out the atm is (0-1)
00068     float getFadeIntensity(void) const {return fader.getInterstate();}
00069 
00074     float getAverageLuminance(void) const {return averageLuminance;}
00075 
00077     void setLightPollutionLuminance(float f) { lightPollutionLuminance = f; }
00079     float getLightPollutionLuminance() const { return lightPollutionLuminance; }
00080 
00081 private:
00082     Vec4i viewport;
00083     Skylight sky;
00084     Skybright skyb;
00085     int skyResolutionY,skyResolutionX;
00086 
00087     Vec2f* posGrid;
00088     Vec4f* colorGrid;
00089     unsigned int* indices;
00090 
00092     float averageLuminance;
00093     float eclipseFactor;
00094     LinearFader fader;
00095     float lightPollutionLuminance;
00096 
00098     bool useShader;
00099 
00101     class QGLShaderProgram* atmoShaderProgram;
00102     struct {
00103         int alphaWaOverAlphaDa;
00104         int oneOverGamma;
00105         int term2TimesOneOverMaxdLpOneOverGamma;
00106         int brightnessScale;
00107         int sunPos;
00108         int term_x, Ax, Bx, Cx, Dx, Ex;
00109         int term_y, Ay, By, Cy, Dy, Ey;
00110         int projectionMatrix;
00111         int skyVertex;
00112         int skyColor;
00113     } shaderAttribLocations;
00114 };
00115 
00116 #endif // _ATMOSTPHERE_HPP_

Generated on Wed Jun 2 13:11:13 2010 for Stellarium by  doxygen 1.5.5