Stellarium 0.90.0
1 /*
2  * Stellarium
3  * Copyright (C) 2003 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
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  */
20 #ifndef _LANDSCAPE_HPP_
21 #define _LANDSCAPE_HPP_
23 #include "VecMath.hpp"
24 #include "StelToneReproducer.hpp"
25 #include "StelProjector.hpp"
27 #include "StelFader.hpp"
28 #include "StelUtils.hpp"
29 #include "StelTextureTypes.hpp"
30 #include "StelLocation.hpp"
32 #include <QMap>
33 #include <QImage>
34 #include <QList>
35 #include <QFont>
37 class QSettings;
38 class StelLocation;
39 class StelCore;
40 class StelPainter;
62 class Landscape
63 {
64 public:
65  typedef struct
66  {
67  QString name;
68  Vec3d featurePoint; // start of the line: mountain peak, building, ...
69  Vec3d labelPoint; // end of the line, where the centered label best fits.
72  Landscape(float _radius = 2.f);
73  virtual ~Landscape();
77  virtual void load(const QSettings& landscapeIni, const QString& landscapeId) = 0;
78  virtual void draw(StelCore* core) = 0;
79  void update(double deltaTime)
80  {
81  landFader.update((int)(deltaTime*1000));
82  fogFader.update((int)(deltaTime*1000));
83  illumFader.update((int)(deltaTime*1000));
84  labelFader.update((int)(deltaTime*1000));
85  }
89  void setBrightness(const float b, const float pollutionBrightness=0.0f) {landscapeBrightness = b; lightScapeBrightness=pollutionBrightness; }
92  float getBrightness() const { return landscapeBrightness; }
98  float getEffectiveLightscapeBrightness() const { return lightScapeBrightness * illumFader.getInterstate(); }
101  void setFlagShow(const bool b) {landFader=b;}
103  bool getFlagShow() const {return (bool)landFader;}
105  float getEffectiveLandFadeValue() { return landFader.getInterstate(); }
107  void setFlagShowFog(const bool b) {fogFader=b;}
109  bool getFlagShowFog() const {return (bool)fogFader;}
111  void setFlagShowIllumination(const bool b) {illumFader=b;}
113  bool getFlagShowIllumination() const {return (bool)illumFader;}
115  void setFlagShowLabels(const bool b) {labelFader=b;}
117  bool getFlagShowLabels() const {return (bool)labelFader;}
119  void setLabelFontSize(const int size){fontSize=size;}
122  QString getName() const {return name;}
124  QString getAuthorName() const {return author;}
126  QString getDescription() const {return description;}
129  const StelLocation& getLocation() const {return location;}
131  bool hasLocation() const {return (!(location.planetName.isEmpty()));}
153  void setZRotation(float d) {angleRotateZOffset = d * M_PI/180.0f;}
156  bool getIsFullyVisible() const {return landFader.getInterstate() >= 0.999f;}
163  // TBD: Maybe change this to azalt[2]<sinMinAltitudeLimit ? (But never called in practice, reimplemented by the subclasses...)
164  virtual float getOpacity(Vec3d azalt) const { Q_ASSERT(0); return (azalt[2]<0 ? 1.0f : 0.0f); }
167  azDeg_altDeg = 0,
173  };
176  void loadLabels(const QString& landscapeId);
178 protected:
182  void loadCommon(const QSettings& landscapeIni, const QString& landscapeId);
185  void drawLabels(StelCore *core, StelPainter *painter);
194  void createPolygonalHorizon(const QString& lineFileName, const float polyAngleRotateZ=0.0f, const QString &listMode="azDeg_altDeg", const bool polygonInverted=false);
200  const QString getTexturePath(const QString& basename, const QString& landscapeId) const;
201  float radius;
202  QString name;
203  QString author;
204  QString description;
214  int rows;
215  int cols;
216  float angleRotateZ;
229  // Optional elements which, if present, describe a horizon polygon. They can be used to render a line or a filled region, esp. in LandscapePolygonal
234  // Optional element: labels for landscape features.
236  QList<LandscapeLabel> landscapeLabels;
237  int fontSize;
239 };
257 {
258 public:
259  LandscapeOldStyle(float radius = 2.f);
260  virtual ~LandscapeOldStyle();
261  virtual void load(const QSettings& landscapeIni, const QString& landscapeId);
262  virtual void draw(StelCore* core);
263  //void create(bool _fullpath, QMap<QString, QString> param); // still not implemented
264  virtual float getOpacity(Vec3d azalt) const;
265 protected:
266  typedef struct
267  {
268  StelTextureSP tex;
269  StelTextureSP tex_illum; // optional light texture.
270  float texCoords[4];
273 private:
274  void drawFog(StelCore* core, StelPainter&) const;
275  // drawLight==true for illumination layer, it then selects only the self-illuminating panels.
276  void drawDecor(StelCore* core, StelPainter&, const bool drawLight=false) const;
277  void drawGround(StelCore* core, StelPainter&) const;
278  QVector<double> groundVertexArr;
279  QVector<float> groundTexCoordArr;
280  StelTextureSP* sideTexs;
281  int nbSideTexs;
282  int nbSide;
283  landscapeTexCoord* sides;
284  StelTextureSP fogTex;
285  StelTextureSP groundTex;
286  QVector<QImage*> sidesImages; // Required for opacity lookup
287  int nbDecorRepeat;
288  float fogAltAngle;
289  float fogAngleShift;
290  float decorAltAngle; // vertical extent of the side panels
291  float decorAngleShift;
292  float groundAngleShift;
293  float groundAngleRotateZ;
294  int drawGroundFirst;
295  bool tanMode; // Whether the angles should be converted using tan instead of sin, i.e., for a cylindrical pano
296  bool calibrated; // if true, the documented altitudes are indeed correct (the original code is buggy!)
297  struct LOSSide
298  {
299  StelVertexArray arr;
300  StelTextureSP tex;
301  bool light; // GZ NEW: true if texture is self-lighting.
302  };
304  QList<LOSSide> precomputedSides;
305 };
317 {
318 public:
319  LandscapePolygonal(float radius = 1.f);
320  virtual ~LandscapePolygonal();
321  virtual void load(const QSettings& landscapeIni, const QString& landscapeId);
322  virtual void draw(StelCore* core);
323  virtual float getOpacity(Vec3d azalt) const;
324 private:
325  // we have inherited: horizonFileName, horizonPolygon, horizonPolygonLineColor
326  Vec3f groundColor;
327 };
336 {
337 public:
338  LandscapeFisheye(float radius = 1.f);
339  virtual ~LandscapeFisheye();
340  virtual void load(const QSettings& landscapeIni, const QString& landscapeId);
341  virtual void draw(StelCore* core);
344  virtual float getOpacity(Vec3d azalt) const;
351  void create(const QString name, const QString& maptex, float texturefov, float angleRotateZ);
352  void create(const QString name, float texturefov, const QString& maptex, const QString &_maptexFog="", const QString& _maptexIllum="", const float angleRotateZ=0.0f);
353 private:
355  StelTextureSP mapTex;
356  StelTextureSP mapTexFog;
357  StelTextureSP mapTexIllum;
359  QImage *mapImage;
362  float texFov;
363 };
376 {
377 public:
378  LandscapeSpherical(float radius = 1.f);
379  virtual ~LandscapeSpherical();
380  virtual void load(const QSettings& landscapeIni, const QString& landscapeId);
381  virtual void draw(StelCore* core);
385  virtual float getOpacity(Vec3d azalt) const;
397  void create(const QString name, const QString& maptex, const QString &_maptexFog="", const QString& _maptexIllum="", const float _angleRotateZ=0.0f,
398  const float _mapTexTop=90.0f, const float _mapTexBottom=-90.0f,
399  const float _fogTexTop=90.0f, const float _fogTexBottom=-90.0f,
400  const float _illumTexTop=90.0f, const float _illumTexBottom=-90.0f);
401 private:
403  StelTextureSP mapTex;
404  StelTextureSP mapTexFog;
405  StelTextureSP mapTexIllum;
407  // These vars are here to conserve texture memory. They must be allowed to be different: a landscape may have its highest elevations at 15°, fog may reach from -25 to +15°,
409  // light pollution may cover -5° (street lamps slightly below) plus parts of or even the whole sky. All have default values to simplify life.
410  float mapTexTop;
411  float mapTexBottom;
412  float fogTexTop;
413  float fogTexBottom;
414  float illumTexTop;
415  float illumTexBottom;
416  QImage *mapImage;
417 };
419 #endif // _LANDSCAPE_HPP_
float getDefaultAtmosphericExtinction() const
Return default atmosperic extinction [mag/airmass], or -1 (no change)
Definition: Landscape.hpp:137
int rows
Used to slowly fade in/out landscape feature labels.
Definition: Landscape.hpp:214
bool getFlagShow() const
Get whether landscape is displayed (does not concern fog)
Definition: Landscape.hpp:103
Store the informations for a location on a planet.
int defaultBortleIndex
OPTIONAL. If present, can be used to set location.
Definition: Landscape.hpp:223
float minBrightness
Read from landscape.ini:[landscape]description.
Definition: Landscape.hpp:206
Store and manages the displaying of the Landscape.
Definition: Landscape.hpp:62
int defaultFogSetting
May be given in landscape.ini:[location]light_pollution. Default: -1 (no change). ...
Definition: Landscape.hpp:224
Implementation of StelFader which implements a linear transition.
Definition: StelFader.hpp:77
int getDefaultBortleIndex() const
Return default Bortle index (light pollution value) or -1 (unknown/no change)
Definition: Landscape.hpp:133
float defaultExtinctionCoefficient
May be given in landscape.ini:[location]display_fog: -1(no change), 0(off), 1(on). Default: -1.
Definition: Landscape.hpp:225
QString description
Read from landscape.ini:[landscape]author.
Definition: Landscape.hpp:204
A shared pointer on a SphericalRegion.
Define the StelTextureSP type.
float getLightscapeBrightness() const
Returns the lightscape brightness.
Definition: Landscape.hpp:94
void setFlagShow(const bool b)
Set whether landscape is displayed (does not concern fog)
Definition: Landscape.hpp:101
This was the original landscape, introduced for decorative purposes.
Definition: Landscape.hpp:256
This uses a single image in fisheye projection.
Definition: Landscape.hpp:335
float sinMinAltitudeLimit
[radians] This is a rotation changeable at runtime via setZRotation (called by LandscapeMgr::setZRota...
Definition: Landscape.hpp:220
int cols
horizontal rows. May be given in landscape.ini:[landscape]tesselate_rows. More indicates higher accur...
Definition: Landscape.hpp:215
float getTargetLightscapeBrightness() const
Returns the lightscape brighness modulated with the fader&#39;s target state (i.e. binary on/off) ...
Definition: Landscape.hpp:96
QString author
Read from landscape.ini:[landscape]name.
Definition: Landscape.hpp:203
Vec3f labelColor
Used for landscape labels (optionally indicating landscape features)
Definition: Landscape.hpp:238
azimuth[degrees] altitude[degrees]
Definition: Landscape.hpp:168
Main class for Stellarium core processing.
Definition: StelCore.hpp:48
bool getFlagShowLabels() const
Get whether labels are displayed.
Definition: Landscape.hpp:117
QList< LandscapeLabel > landscapeLabels
for all horizon types, the horizonPolygon line, if specified, will be drawn in this color ...
Definition: Landscape.hpp:236
void loadCommon(const QSettings &landscapeIni, const QString &landscapeId)
Load attributes common to all landscapes.
Vec3f horizonPolygonLineColor
Optional element describing the horizon line.
Definition: Landscape.hpp:233
void drawLabels(StelCore *core, StelPainter *painter)
Draw optional labels on the landscape.
azimuth[radians] altitude[radians]
Definition: Landscape.hpp:170
QString getDescription() const
Get landscape description.
Definition: Landscape.hpp:126
float defaultTemperature
May be given in landscape.ini:[location]atmospheric_extinction_coefficient. Default -1 (no change)...
Definition: Landscape.hpp:226
LinearFader fogFader
Used to slowly fade in/out landscape painting.
Definition: Landscape.hpp:211
float getDefaultAtmosphericTemperature() const
Return configured atmospheric temperature [degrees Celsius], for refraction computation, or -1000 for "unknown/no change".
Definition: Landscape.hpp:139
float landscapeBrightness
Read from landscape.ini:[landscape]minimal_brightness. Allows minimum visibility that cannot be under...
Definition: Landscape.hpp:207
float getBrightness() const
Returns the current brightness level.
Definition: Landscape.hpp:92
bool hasLocation() const
Return if the location is valid (a valid location has a valid planetName!)
Definition: Landscape.hpp:131
LinearFader labelFader
Used to slowly fade in/out illumination painting.
Definition: Landscape.hpp:213
QString planetName
English planet name.
bool getIsFullyVisible() const
Get whether the landscape is currently fully visible (i.e. opaque).
Definition: Landscape.hpp:156
float getEffectiveLightscapeBrightness() const
Gets the currently effective lightscape brightness (modulated by the fader)
Definition: Landscape.hpp:98
bool getFlagShowIllumination() const
Get whether illumination is displayed.
Definition: Landscape.hpp:113
float lightScapeBrightness
brightness [0..1] to draw the landscape. Computed by the LandscapeMgr.
Definition: Landscape.hpp:208
This uses a single panorama image in spherical (equirectangular) projection.
Definition: Landscape.hpp:375
Provides functions for performing openGL drawing operations.
Definition: StelPainter.hpp:40
void setFlagShowLabels(const bool b)
Set whether labels are displayed.
Definition: Landscape.hpp:115
float getSinMinAltitudeLimit() const
Get the sine of the limiting altitude (can be used to short-cut drawing below horizon, like star fields). There is no set here, value is only from landscape.ini.
Definition: Landscape.hpp:158
virtual void load(const QSettings &landscapeIni, const QString &landscapeId)=0
Load landscape.
float getLandscapeMinimalBrightness() const
Return minimal brightness for landscape returns -1 to signal "standard conditions" (use default value...
Definition: Landscape.hpp:145
float angleRotateZOffset
[radians] if pano does not have its left border in the east, rotate in azimuth. Configured in landsca...
Definition: Landscape.hpp:217
QString getName() const
Get landscape name.
Definition: Landscape.hpp:122
LinearFader landFader
was a landscape loaded properly?
Definition: Landscape.hpp:210
int getDefaultFogSetting() const
Return default fog setting (0/1) or -1 (no change)
Definition: Landscape.hpp:135
LinearFader illumFader
Used to slowly fade in/out fog painting.
Definition: Landscape.hpp:212
SphericalRegionP horizonPolygon
[mbar] May be given in landscape.ini:[location]atmospheric_pressure. Default -1.0 (compute from [loca...
Definition: Landscape.hpp:230
azimuth[degrees] zenithDistance[degrees]
Definition: Landscape.hpp:169
This uses the list of (usually measured) horizon altitudes to define the horizon. ...
Definition: Landscape.hpp:316
void loadLabels(const QString &landscapeId)
Load descriptive labels from optional file gazetteer.LANG.utf8.
void setLabelFontSize(const int size)
change font and fontsize for landscape labels
Definition: Landscape.hpp:119
azimuth[new_degrees] altitude[new_degrees] (may be found on theodolites)
Definition: Landscape.hpp:172
float defaultPressure
[Celsius] May be given in landscape.ini:[location]atmospheric_temperature. default: -1000...
Definition: Landscape.hpp:227
void createPolygonalHorizon(const QString &lineFileName, const float polyAngleRotateZ=0.0f, const QString &listMode="azDeg_altDeg", const bool polygonInverted=false)
Create a StelSphericalPolygon that describes a measured horizon line.
azimuth[radians] zenithDistance[radians]
Definition: Landscape.hpp:171
virtual float getOpacity(Vec3d azalt) const
Find opacity in a certain direction.
Definition: Landscape.hpp:164
bool getFlagShowFog() const
Get whether fog is displayed.
Definition: Landscape.hpp:109
void setFlagShowFog(const bool b)
Set whether fog is displayed.
Definition: Landscape.hpp:107
const QString getTexturePath(const QString &basename, const QString &landscapeId) const
search for a texture in landscape directory, else global textures directory
void setFlagShowIllumination(const bool b)
Set whether illumination is displayed.
Definition: Landscape.hpp:111
void setZRotation(float d)
Set an additional z-axis (azimuth) rotation after landscape has been loaded.
Definition: Landscape.hpp:153
QSharedPointer< StelTexture > StelTextureSP
Use shared pointer to simplify memory managment.
float getDefaultAtmosphericPressure() const
Return configured atmospheric pressure [mbar], for refraction computation.
Definition: Landscape.hpp:142
void setBrightness(const float b, const float pollutionBrightness=0.0f)
Set the brightness of the landscape plus brightness of optional add-on night lightscape.
Definition: Landscape.hpp:89
const StelLocation & getLocation() const
Return the associated location (may be empty!)
Definition: Landscape.hpp:129
StelLocation location
Minimal altitude of landscape cover. Can be used to construct bounding caps, so that e...
Definition: Landscape.hpp:222
bool validLandscape
can be used to draw nightscape texture (e.g. city light pollution), if available. Computed by the Lan...
Definition: Landscape.hpp:209
QString getAuthorName() const
Get landscape author name.
Definition: Landscape.hpp:124
float angleRotateZ
vertical columns. May be given in landscape.ini:[landscape]tesselate_cols. More indicates higher accu...
Definition: Landscape.hpp:216
The list of azimuths (counted from True North towards East) and altitudes can come in various formats...
Definition: Landscape.hpp:166
float getEffectiveLandFadeValue()
Returns the currently effective land fade value.
Definition: Landscape.hpp:105