Stellarium 0.11.4
Home · All Namespaces · All Classes · Functions · Coding Style · Scripting · Plugins · File Structure

core/modules/Landscape.hpp

00001 /*
00002  * Stellarium
00003  * Copyright (C) 2003 Fabien Chereau
00004  *
00005  * This program is free software; you can redistribute it and/or
00006  * modify it under the terms of the GNU General Public License
00007  * as published by the Free Software Foundation; either version 2
00008  * of the License, or (at your option) any later version.
00009  *
00010  * This program is distributed in the hope that it will be useful,
00011  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013  * GNU General Public License for more details.
00014  *
00015  * You should have received a copy of the GNU General Public License
00016  * along with this program; if not, write to the Free Software
00017  * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA  02110-1335, USA.
00018  */
00019 
00020 #ifndef _LANDSCAPE_HPP_
00021 #define _LANDSCAPE_HPP_
00022 
00023 #include <QMap>
00024 #include "VecMath.hpp"
00025 #include "StelToneReproducer.hpp"
00026 #include "StelProjector.hpp"
00027 
00028 #include "StelFader.hpp"
00029 #include "StelUtils.hpp"
00030 #include "StelTextureTypes.hpp"
00031 #include "StelLocation.hpp"
00032 
00033 class QSettings;
00034 class StelLocation;
00035 class StelCore;
00036 class StelPainter;
00037 
00041 class Landscape
00042 {
00043 public:
00044     Landscape(float _radius = 2.f);
00045     virtual ~Landscape();
00046     virtual void load(const QSettings& landscapeIni, const QString& landscapeId) = 0;
00047     virtual void draw(StelCore* core) = 0;
00048     void update(double deltaTime)
00049     {
00050         landFader.update((int)(deltaTime*1000));
00051         fogFader.update((int)(deltaTime*1000));
00052     }
00053 
00055     void setBrightness(const float b) {skyBrightness = b;}
00056 
00058     void setFlagShow(const bool b) {landFader=b;}
00060     bool getFlagShow() const {return (bool)landFader;}
00062     void setFlagShowFog(const bool b) {fogFader=b;}
00064     bool getFlagShowFog() const {return (bool)fogFader;}
00066     QString getName() const {return name;}
00068     QString getAuthorName() const {return author;}
00070     QString getDescription() const {return description;}
00071 
00073     const StelLocation& getLocation() const {return location;}
00075     int getDefaultBortleIndex() const {return defaultBortleIndex;}
00077     int getDefaultFogSetting() const {return defaultFogSetting;}
00079     float getDefaultAtmosphericExtinction() const {return defaultExtinctionCoefficient;}
00081     float getDefaultAtmosphericTemperature() const {return defaultTemperature;}
00084     float getDefaultAtmosphericPressure() const {return defaultPressure;}
00085 
00087     void setZRotation(float d) {angleRotateZOffset = d;}
00088 
00089 protected:
00093     void loadCommon(const QSettings& landscapeIni, const QString& landscapeId);
00094 
00099     const QString getTexturePath(const QString& basename, const QString& landscapeId);
00100     float radius;
00101     QString name;
00102     float skyBrightness;
00103     float nightBrightness;
00104     bool validLandscape;   // was a landscape loaded properly?
00105     LinearFader landFader;
00106     LinearFader fogFader;
00107     QString author;
00108     QString description;
00109     // GZ patched, these can now be set in landscape.ini:
00110     int rows; // horizontal rows
00111     int cols; // vertical columns
00112         int defaultBortleIndex; // light pollution from landscape.ini, or -1(no change)
00113         int defaultFogSetting; // fog flag setting from landscape.ini: -1(no change), 0(off), 1(on)
00114         double defaultExtinctionCoefficient; // atmospheric_extinction_coefficient from landscape.ini or -1
00115         double defaultTemperature; // atmospheric_temperature from landscape.ini or -1000.0
00116         double defaultPressure; // atmospheric_pressure from landscape.ini or -1.0
00117 
00118     typedef struct
00119     {
00120         StelTextureSP tex;
00121         float texCoords[4];
00122     } landscapeTexCoord;
00123 
00124     StelLocation location;
00125     float angleRotateZ;
00126     float angleRotateZOffset;
00127 };
00128 
00129 
00130 class LandscapeOldStyle : public Landscape
00131 {
00132 public:
00133     LandscapeOldStyle(float radius = 2.f);
00134     virtual ~LandscapeOldStyle();
00135     virtual void load(const QSettings& landscapeIni, const QString& landscapeId);
00136     virtual void draw(StelCore* core);
00137     void create(bool _fullpath, QMap<QString, QString> param);
00138 private:
00139     void drawFog(StelCore* core, StelPainter&) const;
00140     void drawDecor(StelCore* core, StelPainter&) const;
00141     void drawGround(StelCore* core, StelPainter&) const;
00142     QVector<double> groundVertexArr;
00143     QVector<float> groundTexCoordArr;
00144     StelTextureSP* sideTexs;
00145     int nbSideTexs;
00146     int nbSide;
00147     landscapeTexCoord* sides;
00148     StelTextureSP fogTex;
00149     landscapeTexCoord fogTexCoord;
00150     StelTextureSP groundTex;
00151     landscapeTexCoord groundTexCoord;
00152     int nbDecorRepeat;
00153     float fogAltAngle;
00154     float fogAngleShift;
00155     float decorAltAngle;
00156     float decorAngleShift;
00157     float groundAngleShift;
00158     float groundAngleRotateZ;
00159     int drawGroundFirst;
00160     bool tanMode;       // Whether the angles should be converted using tan instead of sin
00161     bool calibrated;    // if true, the documented altitudes are inded correct (the original code is buggy!)
00162     struct LOSSide
00163     {
00164         StelVertexArray arr;
00165         StelTextureSP tex;
00166     };
00167 
00168     QList<LOSSide> precomputedSides;
00169 };
00170 
00171 class LandscapeFisheye : public Landscape
00172 {
00173 public:
00174     LandscapeFisheye(float radius = 1.f);
00175     virtual ~LandscapeFisheye();
00176     virtual void load(const QSettings& landscapeIni, const QString& landscapeId);
00177     virtual void draw(StelCore* core);
00178     void create(const QString name, const QString& maptex, float texturefov, float angleRotateZ);
00179 private:
00180 
00181     StelTextureSP mapTex;
00182     float texFov;
00183 };
00184 
00185 
00186 class LandscapeSpherical : public Landscape
00187 {
00188 public:
00189     LandscapeSpherical(float radius = 1.f);
00190     virtual ~LandscapeSpherical();
00191     virtual void load(const QSettings& landscapeIni, const QString& landscapeId);
00192     virtual void draw(StelCore* core);
00193     void create(const QString name, const QString& maptex, float angleRotateZ);
00194 private:
00195 
00196     StelTextureSP mapTex;
00197 };
00198 
00199 #endif // _LANDSCAPE_HPP_
Generated on Sat Aug 25 22:13:29 2012 for Stellarium by  doxygen 1.6.3