Документ взят из кэша поисковой машины. Адрес оригинального документа : http://astro.uni-altai.ru/~aw/stellarium/api/StelSkyDrawer_8hpp_source.html
Дата изменения: Unknown
Дата индексирования: Fri Feb 28 07:46:11 2014
Кодировка:

Поисковые слова: п п п п п п п п п п п п п п п п п п п п п п п п п п п п п п п
Stellarium: core/StelSkyDrawer.hpp Source File
Stellarium 0.12.3
StelSkyDrawer.hpp
1 /*
2  * Stellarium
3  * Copyright (C) 2007 Fabien Chereau
4  *
5  * This program is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU General Public License
7  * as published by the Free Software Foundation; either version 2
8  * of the License, or (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA.
18  */
19 
20 #ifndef _STELSKYDRAWER_HPP_
21 #define _STELSKYDRAWER_HPP_
22 
23 #include "StelProjectorType.hpp"
24 #include "VecMath.hpp"
25 #include "RefractionExtinction.hpp"
26 
27 #include "renderer/StelIndexBuffer.hpp"
28 #include "renderer/StelVertexBuffer.hpp"
29 
30 #include <QObject>
31 
32 
33 class StelToneReproducer;
34 class StelCore;
35 
39 class StelSkyDrawer : public QObject
40 {
41  Q_OBJECT
42 public:
44  StelSkyDrawer(StelCore* core, class StelRenderer* renderer);
47 
49  void init();
50 
53  void update(double deltaTime);
54 
56  void preDrawPointSource();
57 
59  void postDrawPointSource(StelProjectorP projector);
60 
61 
75  bool pointSourceVisible(StelProjector* projector, const Vec3f& v, const float rcMag[2],
76  bool checkInScreen, Vec3f& outWindowCoordinates)
77  {
78  // If radius is negative
79  if (rcMag[0] <= 0.0f){return false;}
80  return checkInScreen ? projector->projectCheck(v, outWindowCoordinates)
81  : projector->project(v, outWindowCoordinates);
82  }
83 
103  void drawPointSource(const Vec3f& win, const float rcMag[2], unsigned int bV)
104  {
105  return drawPointSource(win, rcMag, colorTable[bV]);
106  }
107 
108  void drawPointSource(const Vec3f& win, const float rcMag[2], const Vec3f& bcolor);
109 
111  void drawSunCorona(StelProjectorP projector, const Vec3d& v, float radius, float alpha);
112 
119  void postDrawSky3dModel(StelProjectorP projector, const Vec3d& v, float illuminatedArea, float mag, const Vec3f& color = Vec3f(1.f,1.f,1.f));
120 
125  bool computeRCMag(float mag, float rcMag[2]) const;
126 
132  void reportLuminanceInFov(float lum, bool fastAdaptation=false);
133 
135  void preDraw();
136 
140  static float surfacebrightnessToLuminance(float sb);
144  static float luminanceToSurfacebrightness(float lum);
145 
147  static inline float indexToBV(unsigned char bV)
148  {
149  return (float)bV*(4.f/127.f)-0.5f;
150  }
151 
153  static inline const Vec3f& indexToColor(unsigned char bV)
154  {
155  return colorTable[bV];
156  }
157 
158 public slots:
160  void setRelativeStarScale(double b=1.0) {starRelativeScale=b;}
162  float getRelativeStarScale() const {return starRelativeScale;}
163 
165  void setAbsoluteStarScale(double b=1.0) {starAbsoluteScaleF=b;}
167  float getAbsoluteStarScale() const {return starAbsoluteScaleF;}
168 
170  void setTwinkleAmount(double b) {twinkleAmount=b;}
172  float getTwinkleAmount() const {return twinkleAmount;}
173 
175  void setFlagTwinkle(bool b) {flagStarTwinkle=b;}
177  bool getFlagTwinkle() const {return flagStarTwinkle;}
178 
180  void setDrawStarsAsPoints(bool b) {drawStarsAsPoints=b;}
182  bool getDrawStarsAsPoints() const {return drawStarsAsPoints;}
183 
187  void setBortleScale(int index);
189  int getBortleScale() const {return bortleScaleIndex;}
190 
194  float getLimitMagnitude() const {return limitMagnitude;}
195 
199  // FIXME: Exposed to scripts - make sure it synchs with the GUI. --BM
200  void setFlagStarMagnitudeLimit(bool b) {flagStarMagnitudeLimit = b;}
204  // FIXME: Exposed to scripts - make sure it synchs with the GUI. --BM
205  void setFlagNebulaMagnitudeLimit(bool b) {flagNebulaMagnitudeLimit = b;}
207  bool getFlagStarMagnitudeLimit() const {return flagStarMagnitudeLimit;}
209  bool getFlagNebulaMagnitudeLimit() const {return flagNebulaMagnitudeLimit;}
210 
212  float getCustomStarMagnitudeLimit() const {return customStarMagLimit;}
215  void setCustomStarMagnitudeLimit(double limit) {customStarMagLimit=limit;}
217  float getCustomNebulaMagnitudeLimit() const {return customNebulaMagLimit;}
220  void setCustomNebulaMagnitudeLimit(double limit) {customNebulaMagLimit=limit;}
221 
225  float getLimitLuminance() const {return limitLuminance;}
226 
228  void setFlagLuminanceAdaptation(bool b) {flagLuminanceAdaptation=b;}
230  bool getFlagLuminanceAdaptation() const {return flagLuminanceAdaptation;}
231 
234  void setFlagHasAtmosphere(bool b) {flagHasAtmosphere=b;}
236  bool getFlagHasAtmosphere() const {return flagHasAtmosphere;}
237 
239  void setExtinctionCoefficient(double extCoeff) {extinction.setExtinctionCoefficient(extCoeff);}
241  double getExtinctionCoefficient() const {return extinction.getExtinctionCoefficient();}
243  void setAtmosphereTemperature(double celsius) {refraction.setTemperature(celsius);}
245  double getAtmosphereTemperature() const {return refraction.getTemperature();}
247  void setAtmospherePressure(double mbar) {refraction.setPressure(mbar);}
249  double getAtmospherePressure() const {return refraction.getPressure();}
250 
252  const Extinction& getExtinction() const {return extinction;}
254  const Refraction& getRefraction() const {return refraction;}
255 
257  float getBig3dModelHaloRadius() const {return big3dModelHaloRadius;}
259  void setBig3dModelHaloRadius(float r) {big3dModelHaloRadius=r;}
260 
261 private:
262  // Debug
263  float reverseComputeRCMag(float rmag) const;
264 
266  float computeLimitMagnitude() const;
267 
269  float computeLimitLuminance() const;
270 
272  float getMaxAdaptFov(void) const {return maxAdaptFov;}
277  void setMaxAdaptFov(float fov) {maxAdaptFov = (fov < 60.f) ? 60.f : fov;}
278 
280  float getMinAdaptFov(void) const {return minAdaptFov;}
285  void setMinAdaptFov(float fov) {minAdaptFov = (fov > 60.f) ? 60.f : fov;}
286 
288  void setInputScale(float in) {inScale = in;}
290  float getInputScale() const {return inScale;}
291 
295  inline float pointSourceMagToLuminance(float mag) const {return std::exp(pointSourceMagToLnLuminance(mag));}
296 
300  float pointSourceLuminanceToMag(float lum);
301 
305  float pointSourceMagToLnLuminance(float mag) const;
306 
309  float findWorldLumForMag(float mag, float targetRadius);
310 
311  StelCore* core;
312 
314  class StelRenderer* renderer;
315  StelToneReproducer* eye;
316 
317  Extinction extinction;
318  Refraction refraction;
319 
320  float maxAdaptFov, minAdaptFov, lnfovFactor;
321  bool drawStarsAsPoints;
322  bool flagStarTwinkle;
323  float twinkleAmount;
324 
327  bool flagHasAtmosphere;
328 
331  bool flagStarMagnitudeLimit;
334  bool flagNebulaMagnitudeLimit;
335 
336  float starRelativeScale;
337  float starAbsoluteScaleF;
338 
339  float starLinearScale; // optimization variable
340 
342  float limitMagnitude;
343 
345  float limitLuminance;
346 
351  float customStarMagLimit;
357  float customNebulaMagLimit;
358 
360  class StelTextureNew* texHalo;
361 
363  void initColorTableFromConfigFile(class QSettings* conf);
364 
366  static Vec3f colorTable[128];
367 
369  int bortleScaleIndex;
370 
372  float inScale;
373 
375  struct ColoredVertex
376  {
377  Vec2f position;
378  Vec3f color;
379  ColoredVertex(Vec2f position, Vec3f color):position(position), color(color){}
380 
381  VERTEX_ATTRIBUTES(Vec2f Position, Vec3f Color);
382  };
383 
385  struct ColoredTexturedVertex
386  {
387  Vec2f position;
388  Vec3f color;
389  Vec2f texCoord;
390  ColoredTexturedVertex(Vec2f position, Vec3f color, Vec2f texCoord)
391  :position(position), color(color), texCoord(texCoord){}
392 
393  VERTEX_ATTRIBUTES(Vec2f Position, Vec3f Color, Vec2f TexCoord);
394  };
395 
397  StelVertexBuffer<ColoredVertex>* starPointBuffer;
398 
400  StelVertexBuffer<ColoredTexturedVertex>* starSpriteBuffer;
401 
404 
407 
410 
412  bool drawing;
413 
415  float maxLum;
417  float oldLum;
418 
420  class StelTextureNew* texBigHalo;
421  class StelTextureNew* texSunHalo;
422  class StelTextureNew* texCorona;
423 
424  bool flagLuminanceAdaptation;
425 
426  float big3dModelHaloRadius;
427 
428 
430  bool statisticsInitialized;
431 
433  int bigHaloStatID;
435  int sunHaloStatID;
437  int starStatID;
438 };
439 
440 #endif // _STELSKYDRAWER_HPP_