Landscape.hpp   Landscape.hpp 
/* /* class
* Stellarium * Stellarium
* Copyright (C) 2003 Fabien Chereau * Copyright (C) 2003 Fabien Chereau
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2 * as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version. * of the License, or (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
skipping to change at line 30 skipping to change at line 30
#ifndef _LANDSCAPE_HPP_ #ifndef _LANDSCAPE_HPP_
#define _LANDSCAPE_HPP_ #define _LANDSCAPE_HPP_
#include <QMap> #include <QMap>
#include "VecMath.hpp" #include "VecMath.hpp"
#include "StelToneReproducer.hpp" #include "StelToneReproducer.hpp"
#include "StelProjector.hpp" #include "StelProjector.hpp"
#include "StelFader.hpp" #include "StelFader.hpp"
#include "StelUtils.hpp" #include "StelUtils.hpp"
#include "StelTextureTypes.hpp" #include "renderer/GenericVertexTypes.hpp"
#include "renderer/StelIndexBuffer.hpp"
#include "renderer/StelVertexBuffer.hpp"
#include "StelLocation.hpp" #include "StelLocation.hpp"
class QSettings; class QSettings;
class StelLocation; class StelLocation;
class StelCore; class StelCore;
class StelPainter;
//! @class Landscape //! @class Landscape
//! Store and manages the displaying of the Landscape. //! Store and manages the displaying of the Landscape.
//! Don't use this class direcly, use the LandscapeMgr. //! Don't use this class direcly, use the LandscapeMgr.
class Landscape class Landscape
{ {
public: public:
Landscape(float _radius = 2.f); Landscape(float _radius = 2.f);
virtual ~Landscape(); virtual ~Landscape();
virtual void load(const QSettings& landscapeIni, const QString& land scapeId) = 0; virtual void load(const QSettings& landscapeIni, const QString& land scapeId) = 0;
virtual void draw(StelCore* core) = 0;
//! Draw the landscape.
//!
//! @param core The StelCore object.
//! @param renderer The renderer to draw with.
virtual void draw(StelCore* core, class StelRenderer* renderer) = 0;
void update(double deltaTime) void update(double deltaTime)
{ {
landFader.update((int)(deltaTime*1000)); landFader.update((int)(deltaTime*1000));
fogFader.update((int)(deltaTime*1000)); fogFader.update((int)(deltaTime*1000));
} }
//! Set the brightness of the landscape //! Set the brightness of the landscape
void setBrightness(const float b) {skyBrightness = b;} void setBrightness(const float b) {skyBrightness = b;}
//! Set whether landscape is displayed (does not concern fog) //! Set whether landscape is displayed (does not concern fog)
skipping to change at line 100 skipping to change at line 107
//! Load attributes common to all landscapes //! Load attributes common to all landscapes
//! @param landscapeIni A reference to an existant QSettings object which describes the landscape //! @param landscapeIni A reference to an existant QSettings object which describes the landscape
//! @param landscapeId The name of the directory for the landscape f iles (e.g. "ocean") //! @param landscapeId The name of the directory for the landscape f iles (e.g. "ocean")
void loadCommon(const QSettings& landscapeIni, const QString& landsc apeId); void loadCommon(const QSettings& landscapeIni, const QString& landsc apeId);
//! search for a texture in landscape directory, else global texture s directory //! search for a texture in landscape directory, else global texture s directory
//! @param basename The name of a texture file, e.g. "fog.png" //! @param basename The name of a texture file, e.g. "fog.png"
//! @param landscapeId The landscape ID (directory name) to which th e texture belongs //! @param landscapeId The landscape ID (directory name) to which th e texture belongs
//! @exception misc possibility of throwing "file not found" excepti ons //! @exception misc possibility of throwing "file not found" excepti ons
const QString getTexturePath(const QString& basename, const QString& landscapeId); const QString getTexturePath(const QString& basename, const QString& landscapeId);
float radius; const float radius;
QString name; QString name;
float skyBrightness; float skyBrightness;
float nightBrightness; float nightBrightness;
bool validLandscape; // was a landscape loaded properly? bool validLandscape; // was a landscape loaded properly?
LinearFader landFader; LinearFader landFader;
LinearFader fogFader; LinearFader fogFader;
QString author; QString author;
QString description; QString description;
// Currently, rows and cols do not change after initialization.
// If, in future, these values can be modified, cached vertex/index
buffers
// will have to be regenerated after the change.
// GZ patched, these can now be set in landscape.ini: // GZ patched, these can now be set in landscape.ini:
int rows; // horizontal rows int rows; // horizontal rows
int cols; // vertical columns int cols; // vertical columns
int defaultBortleIndex; // light pollution from landscape.ini, or - int defaultBortleIndex; // light pollution from landscape.ini, or -1
1(no change) (no change)
int defaultFogSetting; // fog flag setting from landscape.ini: -1(n int defaultFogSetting; // fog flag setting from landscape.ini: -1(no
o change), 0(off), 1(on) change), 0(off), 1(on)
double defaultExtinctionCoefficient; // atmospheric_extinction_coef double defaultExtinctionCoefficient; // atmospheric_extinction_coeff
ficient from landscape.ini or -1 icient from landscape.ini or -1
double defaultTemperature; // atmospheric_temperature from landscap double defaultTemperature; // atmospheric_temperature from landscape
e.ini or -1000.0 .ini or -1000.0
double defaultPressure; // atmospheric_pressure from landscape.ini double defaultPressure; // atmospheric_pressure from landscape.ini o
or -1.0 r -1.0
typedef struct typedef struct
{ {
StelTextureSP tex; class StelTextureNew* tex;
float texCoords[4]; float texCoords[4];
} landscapeTexCoord; } landscapeTexCoord;
StelLocation location; StelLocation location;
float angleRotateZ; float angleRotateZ;
float angleRotateZOffset; float angleRotateZOffset;
}; };
class LandscapeOldStyle : public Landscape class LandscapeOldStyle : public Landscape
{ {
public: public:
LandscapeOldStyle(float radius = 2.f); LandscapeOldStyle(float radius = 2.f);
virtual ~LandscapeOldStyle(); virtual ~LandscapeOldStyle();
virtual void load(const QSettings& landscapeIni, const QString& land scapeId); virtual void load(const QSettings& landscapeIni, const QString& land scapeId);
virtual void draw(StelCore* core); virtual void draw(StelCore* core, class StelRenderer* renderer);
void create(bool _fullpath, QMap<QString, QString> param); void create(bool _fullpath, QMap<QString, QString> param);
private: private:
void drawFog(StelCore* core, StelPainter&) const; //! Draw the fog around the landscape.
void drawDecor(StelCore* core, StelPainter&) const; //!
void drawGround(StelCore* core, StelPainter&) const; //! @param core The StelCore object.
QVector<double> groundVertexArr; //! @param renderer Renderer to draw with.
QVector<float> groundTexCoordArr; void drawFog(StelCore* core, class StelRenderer* renderer);
StelTextureSP* sideTexs;
//! Draw the landscape decoration.
//!
//! @param core The StelCore object.
//! @param renderer Renderer to draw with.
void drawDecor(StelCore* core, class StelRenderer* renderer);
//! Draw the ground.
//!
//! @param core The StelCore object.
//! @param renderer Renderer to draw with.
void drawGround(StelCore* core, class StelRenderer* renderer);
//! Generate groundFanDisk and groundFanDiskIndices.
//!
//! Called lazily, once needed.
//!
//! @param renderer Renderer used to create the vertex/index buffers
.
void generateGroundFanDisk(class StelRenderer* renderer);
//! Used to lazily initialize textures at the first draw.
//!
//! @param renderer Renderer used to create the textures.
void lazyInitTextures(class StelRenderer* renderer);
//! Generate precomputedSides.
//!
//! Called lazily, once needed.
//!
//! @param renderer Renderer used to create the vertex/index buffers
.
void generatePrecomputedSides(class StelRenderer* renderer);
struct SideTexture
{
QString path;
class StelTextureNew* texture;
};
SideTexture* sideTexs;
bool texturesInitialized;
int nbSideTexs; int nbSideTexs;
int nbSide; int nbSide;
landscapeTexCoord* sides; landscapeTexCoord* sides;
StelTextureSP fogTex; class StelTextureNew* fogTex;
QString fogTexPath;
landscapeTexCoord fogTexCoord; landscapeTexCoord fogTexCoord;
StelTextureSP groundTex; class StelTextureNew* groundTex;
QString groundTexPath;
landscapeTexCoord groundTexCoord; landscapeTexCoord groundTexCoord;
int nbDecorRepeat; int nbDecorRepeat;
float fogAltAngle; float fogAltAngle;
float fogAngleShift; float fogAngleShift;
float decorAltAngle; float decorAltAngle;
float decorAngleShift; float decorAngleShift;
float groundAngleShift; float groundAngleShift;
float groundAngleRotateZ; float groundAngleRotateZ;
int drawGroundFirst; int drawGroundFirst;
bool tanMode; // Whether the angles should be converted us ing tan instead of sin bool tanMode; // Whether the angles should be converted us ing tan instead of sin
bool calibrated; // if true, the documented altitudes are ind ed correct (the original code is buggy!) bool calibrated; // if true, the documented altitudes are ind ed correct (the original code is buggy!)
//! Side of a LandscapeOldStyle decoration.
struct LOSSide struct LOSSide
{ {
StelVertexArray arr; //! Vertex buffer (triangles) to draw the side.
StelTextureSP tex; StelVertexBuffer<VertexP3T2>* vertices;
//! Index buffer specifying triangles to draw.
StelIndexBuffer* indices;
//! Texture of the decoration.
class StelTextureNew* tex;
}; };
QList<LOSSide> precomputedSides; QList<LOSSide> precomputedSides;
//! This seems to map sides to their textures in sideTexs.
//!
//! This should probably be replaced by something that makes more se
nse.
QMap<int, int> texToSide;
//! Used to draw the fog cylinder.
StelVertexBuffer<VertexP3T2>* fogCylinderBuffer;
//! Height of the for cylinder on previous draw.
float previousFogHeight;
//! Disk used to draw the ground.
StelVertexBuffer<VertexP3T2>* groundFanDisk;
//! Index buffer used to draw groundFanDisk.
StelIndexBuffer* groundFanDiskIndices;
}; };
class LandscapeFisheye : public Landscape class LandscapeFisheye : public Landscape
{ {
public: public:
LandscapeFisheye(float radius = 1.f); LandscapeFisheye(float radius = 1.f);
virtual ~LandscapeFisheye(); virtual ~LandscapeFisheye();
virtual void load(const QSettings& landscapeIni, const QString& land scapeId); virtual void load(const QSettings& landscapeIni, const QString& land scapeId);
virtual void draw(StelCore* core); virtual void draw(StelCore* core, class StelRenderer* renderer);
void create(const QString name, const QString& maptex, float texture fov, float angleRotateZ); void create(const QString name, const QString& maptex, float texture fov, float angleRotateZ);
private: private:
StelTextureSP mapTex; class StelTextureNew* mapTex;
QString mapTexPath;
// Currently, this does not change after initialization.
// If, in future, this value can be modified, cached vertex/index bu
ffers
// will have to be regenerated after the change.
float texFov; float texFov;
//! Sphere used to draw the landscape.
class StelGeometrySphere* fisheyeSphere;
}; };
class LandscapeSpherical : public Landscape class LandscapeSpherical : public Landscape
{ {
public: public:
LandscapeSpherical(float radius = 1.f); LandscapeSpherical(float radius = 1.f);
virtual ~LandscapeSpherical(); virtual ~LandscapeSpherical();
virtual void load(const QSettings& landscapeIni, const QString& land scapeId); virtual void load(const QSettings& landscapeIni, const QString& land scapeId);
virtual void draw(StelCore* core); virtual void draw(StelCore* core, class StelRenderer* renderer);
void create(const QString name, const QString& maptex, float angleRo tateZ); void create(const QString name, const QString& maptex, float angleRo tateZ);
private: private:
StelTextureSP mapTex; class StelTextureNew* mapTex;
QString mapTexPath;
//! Sphere used to draw the landscape.
class StelGeometrySphere* landscapeSphere;
}; };
#endif // _LANDSCAPE_HPP_ #endif // _LANDSCAPE_HPP_
 End of changes. 21 change blocks. 
31 lines changed or deleted 123 lines changed or added

This html diff was produced by rfcdiff 1.41. The latest version is available from http://tools.ietf.org/tools/rfcdiff/