00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
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
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;
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
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_