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., 59 Temple Place - Suite 330, Boston, MA  02111-1307, 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 #include "StelNavigator.hpp"
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(float b) {skyBrightness = b;}
00056 
00058     void setFlagShow(bool b) {landFader=b;}
00060     bool getFlagShow() const {return (bool)landFader;}
00062     void setFlagShowFog(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;}
00074 
00076     void setZRotation(float d) {angleRotateZOffset = d;}
00077 
00078 protected:
00082     void loadCommon(const QSettings& landscapeIni, const QString& landscapeId);
00083 
00088     const QString getTexturePath(const QString& basename, const QString& landscapeId);
00089     float radius;
00090     QString name;
00091     float skyBrightness;
00092     bool validLandscape;   // was a landscape loaded properly?
00093     LinearFader landFader;
00094     LinearFader fogFader;
00095     QString author;
00096     QString description;
00097     // GZ patched, these can now be set in landscape.ini:
00098     int rows; // horizontal rows
00099     int cols; // vertical columns
00100 
00101     typedef struct
00102     {
00103         StelTextureSP tex;
00104         float texCoords[4];
00105     } landscapeTexCoord;
00106 
00107     StelLocation location;
00108     float angleRotateZ;
00109     float angleRotateZOffset;
00110 };
00111 
00112 
00113 class LandscapeOldStyle : public Landscape
00114 {
00115 public:
00116     LandscapeOldStyle(float radius = 2.f);
00117     virtual ~LandscapeOldStyle();
00118     virtual void load(const QSettings& landscapeIni, const QString& landscapeId);
00119     virtual void draw(StelCore* core);
00120     void create(bool _fullpath, QMap<QString, QString> param);
00121 private:
00122     void drawFog(StelCore* core, StelPainter&) const;
00123     void drawDecor(StelCore* core, StelPainter&) const;
00124     void drawGround(StelCore* core, StelPainter&) const;
00125     QVector<double> groundVertexArr;
00126     QVector<float> groundTexCoordArr;
00127     StelTextureSP* sideTexs;
00128     int nbSideTexs;
00129     int nbSide;
00130     landscapeTexCoord* sides;
00131     StelTextureSP fogTex;
00132     landscapeTexCoord fogTexCoord;
00133     StelTextureSP groundTex;
00134     landscapeTexCoord groundTexCoord;
00135     int nbDecorRepeat;
00136     float fogAltAngle;
00137     float fogAngleShift;
00138     float decorAltAngle;
00139     float decorAngleShift;
00140     float groundAngleShift;
00141     float groundAngleRotateZ;
00142     int drawGroundFirst;
00143     bool tanMode;       // Whether the angles should be converted using tan instead of sin
00144     bool calibrated;    // if true, the documented altitudes are inded correct (the original code is buggy!)
00145     struct LOSSide
00146     {
00147         StelVertexArray arr;
00148         StelTextureSP tex;
00149     };
00150 
00151     QList<LOSSide> precomputedSides;
00152 };
00153 
00154 class LandscapeFisheye : public Landscape
00155 {
00156 public:
00157     LandscapeFisheye(float radius = 1.f);
00158     virtual ~LandscapeFisheye();
00159     virtual void load(const QSettings& landscapeIni, const QString& landscapeId);
00160     virtual void draw(StelCore* core);
00161     void create(const QString name, const QString& maptex, float texturefov, float angleRotateZ);
00162 private:
00163 
00164     StelTextureSP mapTex;
00165     float texFov;
00166 };
00167 
00168 
00169 class LandscapeSpherical : public Landscape
00170 {
00171 public:
00172     LandscapeSpherical(float radius = 1.f);
00173     virtual ~LandscapeSpherical();
00174     virtual void load(const QSettings& landscapeIni, const QString& landscapeId);
00175     virtual void draw(StelCore* core);
00176     void create(const QString name, const QString& maptex, float angleRotateZ);
00177 private:
00178 
00179     StelTextureSP mapTex;
00180 };
00181 
00182 #endif // _LANDSCAPE_HPP_

Generated on Wed Jun 2 13:11:13 2010 for Stellarium by  doxygen 1.5.5