Home · All Namespaces · All Classes · Functions · Coding Style · 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., 59 Temple Place - Suite 330, Boston, MA  02111-1307, 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 
00027 #include <QObject>
00028 
00029 class StelToneReproducer;
00030 class StelCore;
00031 class StelPainter;
00032 
00036 class StelSkyDrawer : public QObject
00037 {
00038     Q_OBJECT
00039 public:
00041     StelSkyDrawer(StelCore* core);
00043     ~StelSkyDrawer();
00044 
00046     void init();
00047     
00050     void update(double deltaTime);
00051     
00053     const StelPainter* getPainter() {return sPainter;}
00054     
00057     void preDrawPointSource(const StelPainter* p);
00058         
00060     void postDrawPointSource();
00061     
00068     bool drawPointSource(double x, double y, const float rcMag[2], unsigned int bV)
00069         {return drawPointSource(x, y, rcMag, colorTable[bV]);}
00070     
00071     bool drawPointSource(double x, double y, const float rcMag[2], const Vec3f& color);
00072     
00081     bool drawDiskSource(double x, double y, double r, float mag, const Vec3f& color);
00082     
00090     void postDrawSky3dModel(double x, double y, double illuminatedArea, float mag, const StelPainter* p, const Vec3f& color = Vec3f(1.f,1.f,1.f));
00091     
00096     bool computeRCMag(float mag, float rcMag[2]) const;
00097     
00103     void reportLuminanceInFov(double lum, bool fastAdaptation=false);
00104     
00106     void preDraw();
00107     
00111     static float surfacebrightnessToLuminance(float sb);
00115     static float luminanceToSurfacebrightness(float lum);
00116     
00118     static inline float indexToBV(unsigned char bV)
00119     {
00120         return (float)bV*(4.f/127.f)-0.5f;
00121     }
00122     
00124     static inline const Vec3f& indexToColor(unsigned char bV)
00125     {
00126         return colorTable[bV];
00127     }
00128     
00129 public slots:
00131     void setRelativeStarScale(double b=1.0) {starRelativeScale=b;}
00133     double getRelativeStarScale(void) const {return starRelativeScale;}
00134     
00136     void setAbsoluteStarScale(double b=1.0) {starAbsoluteScaleF=b;}
00138     double getAbsoluteStarScale(void) const {return starAbsoluteScaleF;}
00139     
00141     void setTwinkleAmount(double b) {twinkleAmount=b;}
00143     double getTwinkleAmount(void) const {return twinkleAmount;}
00144     
00146     void setFlagTwinkle(bool b) {flagStarTwinkle=b;}
00148     bool getFlagTwinkle(void) const {return flagStarTwinkle;}
00149     
00151     void setFlagPointStar(bool b) {flagPointStar=b;}
00153     bool getFlagPointStar(void) const {return flagPointStar;}
00154     
00158     void setBortleScale(int index);
00160     int getBortleScale() const {return bortleScaleIndex;}
00161     
00165     float getLimitMagnitude() const {return limitMagnitude;}
00166     
00170     float getLimitLuminance() const {return limitLuminance;}
00171     
00173     void setFlagLuminanceAdaptation(bool b) {flagLuminanceAdaptation=b;}
00175     bool getFlagLuminanceAdaptation(void) const {return flagLuminanceAdaptation;}
00176 
00177 private:
00178     // Debug
00179     float reverseComputeRCMag(float rmag) const;
00180     
00182     float computeLimitMagnitude() const;
00183             
00185     float computeLimitLuminance() const;
00186     
00188     float getMaxAdaptFov(void) const {return maxAdaptFov;}
00193     void setMaxAdaptFov(float fov) {maxAdaptFov = (fov < 60.f) ? 60.f : fov;}
00194     
00196     float getMinAdaptFov(void) const {return minAdaptFov;}
00201     void setMinAdaptFov(float fov) {minAdaptFov = (fov > 60.f) ? 60.f : fov;}
00202     
00204     void setInputScale(double in) {inScale = in;}
00206     float getInputScale() const {return inScale;}
00207     
00211     inline float pointSourceMagToLuminance(float mag) const {return std::exp(pointSourceMagToLnLuminance(mag));}
00212     
00216     float pointSourceLuminanceToMag(float lum);
00217     
00221     float pointSourceMagToLnLuminance(float mag) const;
00222     
00225     float findWorldLumForMag(float mag, float targetRadius);
00226             
00227     StelCore* core;
00228     StelToneReproducer* eye;
00229     
00230     float maxAdaptFov, minAdaptFov, lnfovFactor;
00231     bool flagPointStar;
00232     bool flagStarTwinkle;
00233     float twinkleAmount;
00234     
00235     float starRelativeScale;
00236     float starAbsoluteScaleF;
00237     
00238     float starLinearScale;  // optimization variable
00239     
00241     float limitMagnitude;
00242     
00244     float limitLuminance;
00245     
00247     StelTextureSP texHalo;
00248     
00250     void initColorTableFromConfigFile(class QSettings* conf);
00251     
00253     static Vec3f colorTable[128];
00254     
00256     int bortleScaleIndex;
00257     
00259     double inScale;
00260     
00261     // Variables used for GL optimization when displaying point sources
00263     Vec2f* verticesGrid;
00265     Vec3f* colorGrid;
00267     Vec2f* textureGrid;
00269     unsigned int nbPointSources;
00271     unsigned int maxPointSources;
00272     
00274     float maxLum;
00276     float oldLum;
00277     
00279     StelTextureSP texBigHalo;
00280     StelTextureSP texSunHalo;
00281 
00282     bool flagLuminanceAdaptation;
00283     
00284     const StelPainter* sPainter;
00285 };
00286 
00287 #endif // _STELSKYDRAWER_HPP_

Generated on Mon Mar 9 16:16:16 2009 for Stellarium by  doxygen 1.5.5