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

core/StelSkyDrawer.hpp

00001 /*
00002  * Stellarium
00003  * Copyright (C) 2007 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., 51 Franklin Street, Suite 500, Boston, MA  02110-1335, USA.
00018  */
00019 
00020 #ifndef _STELSKYDRAWER_HPP_
00021 #define _STELSKYDRAWER_HPP_
00022 
00023 #include "StelTextureTypes.hpp"
00024 #include "StelProjectorType.hpp"
00025 #include "VecMath.hpp"
00026 #include "RefractionExtinction.hpp"
00027 
00028 #include <QObject>
00029 
00030 class StelToneReproducer;
00031 class StelCore;
00032 class StelPainter;
00033 
00037 class StelSkyDrawer : public QObject
00038 {
00039     Q_OBJECT
00040 public:
00042     StelSkyDrawer(StelCore* core);
00044     ~StelSkyDrawer();
00045 
00047     void init();
00048 
00051     void update(double deltaTime);
00052 
00055     void preDrawPointSource(StelPainter* p);
00056 
00058     void postDrawPointSource(StelPainter* sPainter);
00059 
00067     bool drawPointSource(StelPainter* sPainter, const Vec3d& v, const float rcMag[2], unsigned int bV, bool checkInScreen=false)
00068         {return drawPointSource(sPainter, v, rcMag, colorTable[bV], checkInScreen);}
00069 
00070     bool drawPointSource(StelPainter* sPainter, const Vec3d& v, const float rcMag[2], const Vec3f& bcolor, bool checkInScreen=false);
00071 
00078     void postDrawSky3dModel(StelPainter* p, const Vec3d& v, float illuminatedArea, float mag, const Vec3f& color = Vec3f(1.f,1.f,1.f));
00079 
00084     bool computeRCMag(float mag, float rcMag[2]) const;
00085 
00091     void reportLuminanceInFov(float lum, bool fastAdaptation=false);
00092 
00094     void preDraw();
00095 
00099     static float surfacebrightnessToLuminance(float sb);
00103     static float luminanceToSurfacebrightness(float lum);
00104 
00106     static inline float indexToBV(unsigned char bV)
00107     {
00108         return (float)bV*(4.f/127.f)-0.5f;
00109     }
00110 
00112     static inline const Vec3f& indexToColor(unsigned char bV)
00113     {
00114         return colorTable[bV];
00115     }
00116 
00117 public slots:
00119     void setRelativeStarScale(double b=1.0) {starRelativeScale=b;}
00121     float getRelativeStarScale() const {return starRelativeScale;}
00122 
00124     void setAbsoluteStarScale(double b=1.0) {starAbsoluteScaleF=b;}
00126     float getAbsoluteStarScale() const {return starAbsoluteScaleF;}
00127 
00129     void setTwinkleAmount(double b) {twinkleAmount=b;}
00131     float getTwinkleAmount() const {return twinkleAmount;}
00132 
00134     void setFlagTwinkle(bool b) {flagStarTwinkle=b;}
00136     bool getFlagTwinkle() const {return flagStarTwinkle;}
00137 
00139     void setFlagPointStar(bool b) {flagPointStar=b;}
00141     bool getFlagPointStar() const {return flagPointStar;}
00142 
00146     void setBortleScale(int index);
00148     int getBortleScale() const {return bortleScaleIndex;}
00149 
00153     float getLimitMagnitude() const {return limitMagnitude;}
00154 
00158     float getLimitLuminance() const {return limitLuminance;}
00159 
00161     void setFlagLuminanceAdaptation(bool b) {flagLuminanceAdaptation=b;}
00163     bool getFlagLuminanceAdaptation() const {return flagLuminanceAdaptation;}
00164 
00167     void setFlagHasAtmosphere(bool b) {flagHasAtmosphere=b;}
00169     bool getFlagHasAtmosphere() const {return flagHasAtmosphere;}
00170 
00172     void setExtinctionCoefficient(double extCoeff) {extinction.setExtinctionCoefficient(extCoeff);}
00174     double getExtinctionCoefficient() const {return extinction.getExtinctionCoefficient();}
00176     void setAtmosphereTemperature(double celsius) {refraction.setTemperature(celsius);}
00178     double getAtmosphereTemperature() const {return refraction.getTemperature();}
00180     void setAtmospherePressure(double mbar) {refraction.setPressure(mbar);}
00182     double getAtmospherePressure() const {return refraction.getPressure();}
00183 
00185     const Extinction& getExtinction() const {return extinction;}
00187     const Refraction& getRefraction() const {return refraction;}
00188 
00190     float getBig3dModelHaloRadius() const {return big3dModelHaloRadius;}
00192     void setBig3dModelHaloRadius(float r) {big3dModelHaloRadius=r;}
00193     
00194 private:
00195     // Debug
00196     float reverseComputeRCMag(float rmag) const;
00197 
00199     float computeLimitMagnitude() const;
00200 
00202     float computeLimitLuminance() const;
00203 
00205     float getMaxAdaptFov(void) const {return maxAdaptFov;}
00210     void setMaxAdaptFov(float fov) {maxAdaptFov = (fov < 60.f) ? 60.f : fov;}
00211 
00213     float getMinAdaptFov(void) const {return minAdaptFov;}
00218     void setMinAdaptFov(float fov) {minAdaptFov = (fov > 60.f) ? 60.f : fov;}
00219 
00221     void setInputScale(float in) {inScale = in;}
00223     float getInputScale() const {return inScale;}
00224 
00228     inline float pointSourceMagToLuminance(float mag) const {return std::exp(pointSourceMagToLnLuminance(mag));}
00229 
00233     float pointSourceLuminanceToMag(float lum);
00234 
00238     float pointSourceMagToLnLuminance(float mag) const;
00239 
00242     float findWorldLumForMag(float mag, float targetRadius);
00243 
00244     StelCore* core;
00245     StelToneReproducer* eye;
00246 
00247     Extinction extinction;
00248     Refraction refraction;
00249 
00250     float maxAdaptFov, minAdaptFov, lnfovFactor;
00251     bool flagPointStar;
00252     bool flagStarTwinkle;
00253     float twinkleAmount;
00254 
00257     bool flagHasAtmosphere;
00258 
00259 
00260     float starRelativeScale;
00261     float starAbsoluteScaleF;
00262 
00263     float starLinearScale;  // optimization variable
00264 
00266     float limitMagnitude;
00267 
00269     float limitLuminance;
00270 
00272     StelTextureSP texHalo;
00273 
00275     void initColorTableFromConfigFile(class QSettings* conf);
00276 
00278     static Vec3f colorTable[128];
00279 
00281     int bortleScaleIndex;
00282 
00284     float inScale;
00285 
00286     // Variables used for GL optimization when displaying point sources
00288     Vec2f* verticesGrid;
00290     Vec3f* colorGrid;
00292     Vec2f* textureGrid;
00294     unsigned int nbPointSources;
00296     unsigned int maxPointSources;
00297 
00299     float maxLum;
00301     float oldLum;
00302 
00304     StelTextureSP texBigHalo;
00305     StelTextureSP texSunHalo;
00306 
00307     bool flagLuminanceAdaptation;
00308 
00309     bool useShader;
00310     class QGLShaderProgram* starsShaderProgram;
00311     
00312     float big3dModelHaloRadius;
00313 };
00314 
00315 #endif // _STELSKYDRAWER_HPP_
Generated on Sat Aug 25 22:13:30 2012 for Stellarium by  doxygen 1.6.3