Stellarium 0.13.2
Landscape.hpp
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
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 _LANDSCAPE_HPP_
21 #define _LANDSCAPE_HPP_
22 
23 #include "VecMath.hpp"
24 #include "StelToneReproducer.hpp"
25 #include "StelProjector.hpp"
26 
27 #include "StelFader.hpp"
28 #include "StelUtils.hpp"
29 #include "StelTextureTypes.hpp"
30 #include "StelLocation.hpp"
31 
32 #include <QMap>
33 #include <QImage>
34 
35 class QSettings;
36 class StelLocation;
37 class StelCore;
38 class StelPainter;
39 
60 class Landscape
61 {
62 public:
63  Landscape(float _radius = 2.f);
64  virtual ~Landscape();
68  virtual void load(const QSettings& landscapeIni, const QString& landscapeId) = 0;
69  virtual void draw(StelCore* core) = 0;
70  void update(double deltaTime)
71  {
72  landFader.update((int)(deltaTime*1000));
73  fogFader.update((int)(deltaTime*1000));
74  }
75 
78  void setBrightness(const float b, const float pollutionBrightness=0.0f) {landscapeBrightness = b; lightScapeBrightness=pollutionBrightness; }
79 
81  void setFlagShow(const bool b) {landFader=b;}
83  bool getFlagShow() const {return (bool)landFader;}
85  void setFlagShowFog(const bool b) {fogFader=b;}
87  bool getFlagShowFog() const {return (bool)fogFader;}
89  QString getName() const {return name;}
91  QString getAuthorName() const {return author;}
93  QString getDescription() const {return description;}
94 
96  const StelLocation& getLocation() const {return location;}
98  bool hasLocation() const {return (location.planetName.length() > 0);}
113 
120  void setZRotation(float d) {angleRotateZOffset = d * M_PI/180.0f;}
121 
123  bool getIsFullyVisible() const {return landFader.getInterstate() >= 0.999f;}
124 
125  // GZ: NEW FUNCTION:
128  virtual float getOpacity(Vec3d azalt) const {return (azalt[2]<0 ? 1.0f : 0.0f); }
131  azDeg_altDeg = 0,
137  };
138 
139 protected:
143  void loadCommon(const QSettings& landscapeIni, const QString& landscapeId);
148  void createPolygonalHorizon(const QString& lineFileName, const float polyAngleRotateZ=0.0f, const QString &listMode="azDeg_altDeg");
149 
154  const QString getTexturePath(const QString& basename, const QString& landscapeId) const;
155  float radius;
156  QString name;
157  QString author;
158  QString description;
159 
166  int rows;
167  int cols;
168  float angleRotateZ;
170 
178 
179  // Optional elements which, if present, describe a horizon polygon. They can be used to render a line or a filled region, esp. in LandscapePolygonal
184 };
186 
203 {
204 public:
205  LandscapeOldStyle(float radius = 2.f);
206  virtual ~LandscapeOldStyle();
207  virtual void load(const QSettings& landscapeIni, const QString& landscapeId);
208  virtual void draw(StelCore* core);
209  //void create(bool _fullpath, QMap<QString, QString> param); // still not implemented
210  virtual float getOpacity(Vec3d azalt) const;
211 protected:
212  typedef struct
213  {
214  StelTextureSP tex;
215  StelTextureSP tex_illum; // optional light texture.
216  float texCoords[4];
218 
219 private:
220  void drawFog(StelCore* core, StelPainter&) const;
221  // GZ NEW: drawLight selects only the self-illuminating panels.
222  void drawDecor(StelCore* core, StelPainter&, const bool drawLight=false) const;
223  void drawGround(StelCore* core, StelPainter&) const;
224  QVector<double> groundVertexArr;
225  QVector<float> groundTexCoordArr;
226  StelTextureSP* sideTexs;
227  int nbSideTexs;
228  int nbSide;
229  landscapeTexCoord* sides;
230  StelTextureSP fogTex;
231  //landscapeTexCoord fogTexCoord; // GZ: UNUSED!
232  StelTextureSP groundTex;
233  QVector<QImage*> sidesImages; // GZ: Required for opacity lookup
234  //landscapeTexCoord groundTexCoord; // GZ: UNUSED!
235  int nbDecorRepeat;
236  float fogAltAngle;
237  float fogAngleShift;
238  float decorAltAngle; // vertical extent of the side panels
239  float decorAngleShift;
240  float groundAngleShift;
241  float groundAngleRotateZ;
242  int drawGroundFirst;
243  bool tanMode; // Whether the angles should be converted using tan instead of sin, i.e., for a cylindrical pano
244  bool calibrated; // if true, the documented altitudes are indeed correct (the original code is buggy!)
245  struct LOSSide
246  {
247  StelVertexArray arr;
248  StelTextureSP tex;
249  bool light; // GZ NEW: true if texture is self-lighting.
250  };
251 
252  QList<LOSSide> precomputedSides;
253 };
254 
265 {
266 public:
267  LandscapePolygonal(float radius = 1.f);
268  virtual ~LandscapePolygonal();
269  virtual void load(const QSettings& landscapeIni, const QString& landscapeId);
270  virtual void draw(StelCore* core);
271  virtual float getOpacity(Vec3d azalt) const;
272 private:
273  // we have inherited: horizonFileName, horizonPolygon, horizonPolygonLineColor
274  Vec3f groundColor;
275 };
276 
284 {
285 public:
286  LandscapeFisheye(float radius = 1.f);
287  virtual ~LandscapeFisheye();
288  virtual void load(const QSettings& landscapeIni, const QString& landscapeId);
289  virtual void draw(StelCore* core);
292  virtual float getOpacity(Vec3d azalt) const;
299  void create(const QString name, const QString& maptex, float texturefov, float angleRotateZ);
300  void create(const QString name, float texturefov, const QString& maptex, const QString &_maptexFog="", const QString& _maptexIllum="", const float angleRotateZ=0.0f);
301 private:
302 
303  StelTextureSP mapTex;
304  StelTextureSP mapTexFog;
305  StelTextureSP mapTexIllum;
307  QImage *mapImage;
309 
310  float texFov;
311 };
312 
324 {
325 public:
326  LandscapeSpherical(float radius = 1.f);
327  virtual ~LandscapeSpherical();
328  virtual void load(const QSettings& landscapeIni, const QString& landscapeId);
329  virtual void draw(StelCore* core);
333  virtual float getOpacity(Vec3d azalt) const;
345  void create(const QString name, const QString& maptex, const QString &_maptexFog="", const QString& _maptexIllum="", const float _angleRotateZ=0.0f,
346  const float _mapTexTop=90.0f, const float _mapTexBottom=-90.0f,
347  const float _fogTexTop=90.0f, const float _fogTexBottom=-90.0f,
348  const float _illumTexTop=90.0f, const float _illumTexBottom=-90.0f);
349 private:
350 
351  StelTextureSP mapTex;
352  StelTextureSP mapTexFog;
353  StelTextureSP mapTexIllum;
355  // 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°,
357  // light pollution may cover -5° (street lamps slightly below) plus parts of or even the whole sky. All have default values to simplify life.
358  float mapTexTop;
359  float mapTexBottom;
360  float fogTexTop;
361  float fogTexBottom;
362  float illumTexTop;
363  float illumTexBottom;
364  QImage *mapImage;
365 };
366 
367 #endif // _LANDSCAPE_HPP_
float getDefaultAtmosphericExtinction() const
Return default atmosperic extinction [mag/airmass], or -1 (no change)
Definition: Landscape.hpp:104
int rows
Used to slowly fade in/out fog painting.
Definition: Landscape.hpp:166
bool getFlagShow() const
Get whether landscape is displayed (does not concern fog)
Definition: Landscape.hpp:83
Store the informations for a location on a planet.
virtual float getOpacity(Vec3d azalt) const
Sample landscape texture for transparency/opacity.
int defaultBortleIndex
OPTIONAL. If present, can be used to set location.
Definition: Landscape.hpp:173
float minBrightness
Read from landscape.ini:[landscape]description.
Definition: Landscape.hpp:160
Store and manages the displaying of the Landscape.
Definition: Landscape.hpp:60
int defaultFogSetting
May be given in landscape.ini:[location]light_pollution. Default: -1 (no change). ...
Definition: Landscape.hpp:174
Implementation of StelFader which implements a linear transition.
Definition: StelFader.hpp:79
int getDefaultBortleIndex() const
Return default Bortle index (light pollution value) or -1 (unknown/no change)
Definition: Landscape.hpp:100
virtual void load(const QSettings &landscapeIni, const QString &landscapeId)
Load landscape.
virtual float getOpacity(Vec3d azalt) const
can be used to find sunrise or visibility questions on the real-world landscape horizon.
float defaultExtinctionCoefficient
May be given in landscape.ini:[location]display_fog: -1(no change), 0(off), 1(on). Default: -1.
Definition: Landscape.hpp:175
QString description
Read from landscape.ini:[landscape]author.
Definition: Landscape.hpp:158
A shared pointer on a SphericalRegion.
Define the StelTextureSP type.
void setFlagShow(const bool b)
Set whether landscape is displayed (does not concern fog)
Definition: Landscape.hpp:81
This was the original landscape, introduced for decorative purposes.
Definition: Landscape.hpp:202
This uses a single image in fisheye projection.
Definition: Landscape.hpp:283
int cols
horizontal rows. May be given in landscape.ini:[landscape]tesselate_rows. More indicates higher accur...
Definition: Landscape.hpp:167
QString author
Read from landscape.ini:[landscape]name.
Definition: Landscape.hpp:157
virtual void load(const QSettings &landscapeIni, const QString &landscapeId)
Load landscape.
azimuth[degrees] altitude[degrees]
Definition: Landscape.hpp:132
Main class for Stellarium core processing.
Definition: StelCore.hpp:46
void create(const QString name, const QString &maptex, float texturefov, float angleRotateZ)
create a fisheye landscape from basic parameters (no ini file needed).
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:183
void create(const QString name, const QString &maptex, const QString &_maptexFog="", const QString &_maptexIllum="", const float _angleRotateZ=0.0f, const float _mapTexTop=90.0f, const float _mapTexBottom=-90.0f, const float _fogTexTop=90.0f, const float _fogTexBottom=-90.0f, const float _illumTexTop=90.0f, const float _illumTexBottom=-90.0f)
create a spherical landscape from basic parameters (no ini file needed).
azimuth[radians] altitude[radians]
Definition: Landscape.hpp:134
QString getDescription() const
Get landscape description.
Definition: Landscape.hpp:93
float defaultTemperature
May be given in landscape.ini:[location]atmospheric_extinction_coefficient. Default -1 (no change)...
Definition: Landscape.hpp:176
LinearFader fogFader
Used to slowly fade in/out landscape painting.
Definition: Landscape.hpp:165
float getDefaultAtmosphericTemperature() const
Return configured atmospheric temperature [degrees Celsius], for refraction computation, or -1000 for "unknown/no change".
Definition: Landscape.hpp:106
float landscapeBrightness
Read from landscape.ini:[landscape]minimal_brightness. Allows minimum visibility that cannot be under...
Definition: Landscape.hpp:161
bool hasLocation() const
Return if the location is valid (a valid location has a valid planetName!)
Definition: Landscape.hpp:98
QString planetName
English planet name.
bool getIsFullyVisible() const
Get whether the landscape is currently fully visible (i.e. opaque).
Definition: Landscape.hpp:123
float lightScapeBrightness
brightness [0..1] to draw the landscape. Computed by the LandscapeMgr.
Definition: Landscape.hpp:162
This uses a single panorama image in spherical (equirectangular) projection.
Definition: Landscape.hpp:323
Provides functions for performing openGL drawing operations.
Definition: StelPainter.hpp:40
virtual float getOpacity(Vec3d azalt) const
can be used to find sunrise or visibility questions on the real-world landscape horizon.
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:112
float angleRotateZOffset
[radians] if pano does not have its left border in the east, rotate in azimuth. Configured in landsca...
Definition: Landscape.hpp:169
QString getName() const
Get landscape name.
Definition: Landscape.hpp:89
LinearFader landFader
was a landscape loaded properly?
Definition: Landscape.hpp:164
int getDefaultFogSetting() const
Return default fog setting (0/1) or -1 (no change)
Definition: Landscape.hpp:102
virtual void load(const QSettings &landscapeIni, const QString &landscapeId)
Load landscape.
SphericalRegionP horizonPolygon
[mbar] May be given in landscape.ini:[location]atmospheric_pressure. Default -1.0 (compute from [loca...
Definition: Landscape.hpp:180
azimuth[degrees] zenithDistance[degrees]
Definition: Landscape.hpp:133
This uses the list of (usually measured) horizon altitudes to define the horizon. ...
Definition: Landscape.hpp:264
azimuth[new_degrees] altitude[new_degrees] (may be found on theodolites)
Definition: Landscape.hpp:136
float defaultPressure
[Celsius] May be given in landscape.ini:[location]atmospheric_temperature. default: -1000...
Definition: Landscape.hpp:177
virtual void load(const QSettings &landscapeIni, const QString &landscapeId)
Load landscape.
virtual float getOpacity(Vec3d azalt) const
Sample landscape texture for transparency/opacity.
azimuth[radians] zenithDistance[radians]
Definition: Landscape.hpp:135
virtual float getOpacity(Vec3d azalt) const
can be used to find sunrise or visibility questions on the real-world landscape horizon.
Definition: Landscape.hpp:128
bool getFlagShowFog() const
Get whether fog is displayed.
Definition: Landscape.hpp:87
void setFlagShowFog(const bool b)
Set whether fog is displayed.
Definition: Landscape.hpp:85
const QString getTexturePath(const QString &basename, const QString &landscapeId) const
search for a texture in landscape directory, else global textures directory
void setZRotation(float d)
Set an additional z-axis (azimuth) rotation after landscape has been loaded.
Definition: Landscape.hpp:120
QSharedPointer< StelTexture > StelTextureSP
Use shared pointer to simplify memory managment.
float getDefaultAtmosphericPressure() const
Return configured atmospheric pressure [mbar], for refraction computation.
Definition: Landscape.hpp:109
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:78
const StelLocation & getLocation() const
Return the associated location (may be empty!)
Definition: Landscape.hpp:96
StelLocation location
[radians] This is a rotation changeable at runtime via setZRotation (called by LandscapeMgr::setZRota...
Definition: Landscape.hpp:172
bool validLandscape
can be used to draw nightscape texture (e.g. city light pollution), if available. Computed by the Lan...
Definition: Landscape.hpp:163
QString getAuthorName() const
Get landscape author name.
Definition: Landscape.hpp:91
void createPolygonalHorizon(const QString &lineFileName, const float polyAngleRotateZ=0.0f, const QString &listMode="azDeg_altDeg")
Create a StelSphericalPolygon that describes a measured horizon line.
float angleRotateZ
vertical columns. May be given in landscape.ini:[landscape]tesselate_cols. More indicates higher accu...
Definition: Landscape.hpp:168
horizonListMode
The list of azimuths and altitudes can come in various formats. We read the first two elements...
Definition: Landscape.hpp:130