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
00054 void preDrawPointSource(StelPainter* p);
00055
00057 void postDrawPointSource(StelPainter* sPainter);
00058
00066 bool drawPointSource(StelPainter* sPainter, const Vec3f& v, const float rcMag[2], unsigned int bV, bool checkInScreen=false)
00067 {return drawPointSource(sPainter, v, rcMag, colorTable[bV], checkInScreen);}
00068
00069 bool drawPointSource(StelPainter* sPainter,const Vec3f& v, const float rcMag[2], const Vec3f& color, bool checkInScreen=false);
00070
00077 void postDrawSky3dModel(StelPainter* p, const Vec3f& v, float illuminatedArea, float mag, const Vec3f& color = Vec3f(1.f,1.f,1.f));
00078
00083 bool computeRCMag(float mag, float rcMag[2]) const;
00084
00090 void reportLuminanceInFov(float lum, bool fastAdaptation=false);
00091
00093 void preDraw();
00094
00098 static float surfacebrightnessToLuminance(float sb);
00102 static float luminanceToSurfacebrightness(float lum);
00103
00105 static inline float indexToBV(unsigned char bV)
00106 {
00107 return (float)bV*(4.f/127.f)-0.5f;
00108 }
00109
00111 static inline const Vec3f& indexToColor(unsigned char bV)
00112 {
00113 return colorTable[bV];
00114 }
00115
00116 public slots:
00118 void setRelativeStarScale(double b=1.0) {starRelativeScale=b;}
00120 float getRelativeStarScale() const {return starRelativeScale;}
00121
00123 void setAbsoluteStarScale(double b=1.0) {starAbsoluteScaleF=b;}
00125 float getAbsoluteStarScale() const {return starAbsoluteScaleF;}
00126
00128 void setTwinkleAmount(double b) {twinkleAmount=b;}
00130 float getTwinkleAmount() const {return twinkleAmount;}
00131
00133 void setFlagTwinkle(bool b) {flagStarTwinkle=b;}
00135 bool getFlagTwinkle() const {return flagStarTwinkle;}
00136
00138 void setFlagPointStar(bool b) {flagPointStar=b;}
00140 bool getFlagPointStar() const {return flagPointStar;}
00141
00145 void setBortleScale(int index);
00147 int getBortleScale() const {return bortleScaleIndex;}
00148
00152 float getLimitMagnitude() const {return limitMagnitude;}
00153
00157 float getLimitLuminance() const {return limitLuminance;}
00158
00160 void setFlagLuminanceAdaptation(bool b) {flagLuminanceAdaptation=b;}
00162 bool getFlagLuminanceAdaptation(void) const {return flagLuminanceAdaptation;}
00163
00166 void setFlagHasAtmosphere(bool b) {flagHasAtmosphere=b;}
00167
00169 float getBig3dModelHaloRadius() const {return big3dModelHaloRadius;}
00171 void setBig3dModelHaloRadius(float r) {big3dModelHaloRadius=r;}
00172
00173 private:
00174
00175 float reverseComputeRCMag(float rmag) const;
00176
00178 float computeLimitMagnitude() const;
00179
00181 float computeLimitLuminance() const;
00182
00184 float getMaxAdaptFov(void) const {return maxAdaptFov;}
00189 void setMaxAdaptFov(float fov) {maxAdaptFov = (fov < 60.f) ? 60.f : fov;}
00190
00192 float getMinAdaptFov(void) const {return minAdaptFov;}
00197 void setMinAdaptFov(float fov) {minAdaptFov = (fov > 60.f) ? 60.f : fov;}
00198
00200 void setInputScale(float in) {inScale = in;}
00202 float getInputScale() const {return inScale;}
00203
00207 inline float pointSourceMagToLuminance(float mag) const {return std::exp(pointSourceMagToLnLuminance(mag));}
00208
00212 float pointSourceLuminanceToMag(float lum);
00213
00217 float pointSourceMagToLnLuminance(float mag) const;
00218
00221 float findWorldLumForMag(float mag, float targetRadius);
00222
00223 StelCore* core;
00224 StelToneReproducer* eye;
00225
00226 float maxAdaptFov, minAdaptFov, lnfovFactor;
00227 bool flagPointStar;
00228 bool flagStarTwinkle;
00229 float twinkleAmount;
00230
00233 bool flagHasAtmosphere;
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 float 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 bool useShader;
00285 class QGLShaderProgram* starsShaderProgram;
00286
00287 float big3dModelHaloRadius;
00288 };
00289
00290 #endif // _STELSKYDRAWER_HPP_