Planet.hpp   Planet.hpp 
skipping to change at line 26 skipping to change at line 26
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA. * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA.
*/ */
#ifndef _PLANET_HPP_ #ifndef _PLANET_HPP_
#define _PLANET_HPP_ #define _PLANET_HPP_
#include "StelObject.hpp" #include "StelObject.hpp"
#include "StelProjector.hpp" #include "StelProjector.hpp"
#include "VecMath.hpp" #include "VecMath.hpp"
#include "GeomMath.hpp"
#include "StelFader.hpp" #include "StelFader.hpp"
#include "StelTextureTypes.hpp" #include "StelTextureTypes.hpp"
#include "StelProjectorType.hpp" #include "StelProjectorType.hpp"
#include <QString> #include <QString>
// The callback type for the external position computation function // The callback type for the external position computation function
// The last variable is the userData pointer. // The last variable is the userData pointer.
typedef void (*posFuncType)(double, double*, void*); typedef void (*posFuncType)(double, double*, void*);
typedef void (OsculatingFunctType)(double jde0,double jde,double xyz[3]); typedef void (OsculatingFunctType)(double jde0,double jde,double xyz[3]);
// epoch J2000: 12 UT on 1 Jan 2000 // epoch J2000: 12 UT on 1 Jan 2000
#define J2000 2451545.0 #define J2000 2451545.0
#define ORBIT_SEGMENTS 360 #define ORBIT_SEGMENTS 360
class StelFont; class StelFont;
class StelPainter; class StelPainter;
class StelTranslator; class StelTranslator;
class StelOBJ;
class StelOpenGLArray;
template <class T> class QFuture;
class QOpenGLBuffer;
class QOpenGLFunctions;
class QOpenGLShaderProgram; class QOpenGLShaderProgram;
class QOpenGLTexture;
#ifdef DEBUG_SHADOWMAP
class QOpenGLFramebufferObject;
#endif
// Class used to store rotational elements, i.e. axis orientation for the p lanetary body. // Class used to store rotational elements, i.e. axis orientation for the p lanetary body.
class RotationElements class RotationElements
{ {
public: public:
RotationElements(void) : period(1.), offset(0.), epoch(J2000), obliq uity(0.), ascendingNode(0.), precessionRate(0.), siderealPeriod(0.) {} RotationElements(void) : period(1.), offset(0.), epoch(J2000), obliq uity(0.), ascendingNode(0.), precessionRate(0.), siderealPeriod(0.) {}
float period; // (sidereal) rotation period [earth days] float period; // (sidereal) rotation period [earth days]
float offset; // rotation at epoch [degrees] float offset; // rotation at epoch [degrees]
double epoch; // JDE (JD TT) of epoch for these elements double epoch; // JDE (JD TT) of epoch for these elements
float obliquity; // tilt of rotation axis w.r.t. ecliptic [rad ians] float obliquity; // tilt of rotation axis w.r.t. ecliptic [rad ians]
skipping to change at line 75 skipping to change at line 85
Ring(float radiusMin, float radiusMax,const QString &texname); Ring(float radiusMin, float radiusMax,const QString &texname);
double getSize(void) const {return radiusMax;} double getSize(void) const {return radiusMax;}
const float radiusMin; const float radiusMin;
const float radiusMax; const float radiusMax;
StelTextureSP tex; StelTextureSP tex;
}; };
class Planet : public StelObject class Planet : public StelObject
{ {
public: public:
static const QString PLANET_TYPE;
friend class SolarSystem; friend class SolarSystem;
Q_ENUMS(PlanetType) Q_ENUMS(PlanetType)
Q_ENUMS(PlanetOrbitColorStyle) Q_ENUMS(PlanetOrbitColorStyle)
Q_ENUMS(ApparentMagnitudeAlgorithm) Q_ENUMS(ApparentMagnitudeAlgorithm)
//! numeric typecodes for the type descriptions in ssystem.ini //! numeric typecodes for the type descriptions in ssystem.ini
// GZ: Until 0.13 QStrings were used for types. // GZ: Until 0.13 QStrings were used for types.
// GZ: Enums are slightly faster than string comparisons in time-cri tical comparisons. // GZ: Enums are slightly faster than string comparisons in time-cri tical comparisons.
// GZ: If other types are introduced, add here and the string in ini t(). // GZ: If other types are introduced, add here and the string in ini t().
// GZ TODO for 0.16: Preferably convert this into a bitfield and all
ow several bits set:
// Cubewanos, SDO, OCO, Sednoids are Asteroids, Pluto is a Plutino a
nd DwarfPlanet, Ceres is Asteroid and DwarfPlanet etc.!
// Maybe even add queries like Planet::isAsteroid() { return (planet
Type & Planet::isAsteroid);}
enum PlanetType enum PlanetType
{ {
isStar, // ssystem.ini: type="star" isStar, // ssystem.ini: type="star"
isPlanet, // ssystem.ini: type="planet" isPlanet, // ssystem.ini: type="planet"
isMoon, // ssystem.ini: type="moon" isMoon, // ssystem.ini: type="moon"
isAsteroid, // ssystem.ini: type="asteroid" isObserver, // ssystem.ini: type="observer"
isArtificial, // Used in transitions from planet t
o planet.
isAsteroid, // ssystem.ini: type="asteroid". all
types >= isAsteroid are "Minor Bodies".
// Put other things (spacecraft etc)
before isAsteroid.
isPlutino, // ssystem.ini: type="plutino" isPlutino, // ssystem.ini: type="plutino"
isComet, // ssystem.ini: type="comet" isComet, // ssystem.ini: type="comet"
isDwarfPlanet, // ssystem.ini: type="dwarf planet" isDwarfPlanet, // ssystem.ini: type="dwarf planet"
isCubewano, // ssystem.ini: type="cubewano" isCubewano, // ssystem.ini: type="cubewano"
isSDO, // ssystem.ini: type="scattered disc object" isSDO, // ssystem.ini: type="scattered disc object"
isOCO, // ssystem.ini: type="oco" isOCO, // ssystem.ini: type="oco"
isSednoid, // ssystem.ini: type="sednoid" isSednoid, // ssystem.ini: type="sednoid"
isUNDEFINED // ssystem.ini: type=<anything else> isUNDEFINED // ssystem.ini: type=<anything else> . THIS IS ONLY IN CASE OF ERROR!
}; };
enum PlanetOrbitColorStyle enum PlanetOrbitColorStyle
{ {
ocsOneColor, // One color for all orbits ocsOneColor, // One color for all orbits
ocsGroups, // Separate colors for each group of Solar system bodies ocsGroups, // Separate colors for each group of Solar system bodies
ocsMajorPlanets // Separate colors for each of major planets of Solar system ocsMajorPlanets // Separate colors for each of major planets of Solar system
}; };
/* enum ApparentMagnitudeAlgorithm
{
Planesas, // Algorithm provided by Pere Planes
as (Observatorio Astronomico Nacional)
Mueller, // G. Mueller, based on visual obser
vations 1877-91. [Expl.Suppl.1961]
Harris, // Astronomical Almanac 1984 and lat
er. These give V (instrumental) magnitudes (D.L. Harris)
UndefinedAlgorithm,
Generic // Visual magnitude based on phase a
ngle and albedo
};
*/
enum ApparentMagnitudeAlgorithm enum ApparentMagnitudeAlgorithm
{ {
Mueller_1893, // G. Mueller, based on visual observations Mueller_1893, // G. Mueller, based on visual obser
1877-91. [Expl.Suppl.1961] vations 1877-91. [Expl.Suppl.1961]
Astr_Alm_1984, // Astronomical Almanac 1984 and later. Thes Astr_Alm_1984, // Astronomical Almanac 1984 and lat
e give V (instrumental) magnitudes (allegedly from D.L. Harris, but this is er. These give V (instrumental) magnitudes (allegedly from D.L. Harris, but
wrong!) this is wrong!)
Expl_Sup_1992, // Algorithm provided by Pere Planesas (Obse Expl_Sup_1992, // Algorithm provided by Pere Planes
rvatorio Astronomico Nacional) (Was called "Planesas") as (Observatorio Astronomico Nacional) (Was called "Planesas")
Expl_Sup_2013, // Explanatory Supplement to the Astronomica Expl_Sup_2013, // Explanatory Supplement to the Ast
l Almanac, 3rd edition 2013 ronomical Almanac, 3rd edition 2013
// Planesas, // Algorithm provided by Pere Planes
as (Observatorio Astronomico Nacional)
// Mueller, // G. Mueller, based on visual obser
vations 1877-91. [Expl.Suppl.1961]
// Harris, // Astronomical Almanac 1984 and lat
er. These give V (instrumental) magnitudes (D.L. Harris)
UndefinedAlgorithm, UndefinedAlgorithm,
Generic // Visual magnitude based on phase angle and albedo. The formula source for this is totally unknown! Generic // Visual magnitude based on phase a ngle and albedo. The formula source for this is totally unknown!
}; };
Planet(const QString& englishName, Planet(const QString& englishName,
int flagLighting,
double radius, double radius,
double oblateness, double oblateness,
Vec3f halocolor, Vec3f halocolor,
float albedo, float albedo,
float roughness,
const QString& texMapName, const QString& texMapName,
const QString& normalMapName, const QString& normalMapName,
const QString& objModelName,
posFuncType _coordFunc, posFuncType _coordFunc,
void* userDataPtr, void* anOrbitPtr,
OsculatingFunctType *osculatingFunc, OsculatingFunctType *osculatingFunc,
bool closeOrbit, bool closeOrbit,
bool hidden, bool hidden,
bool hasAtmosphere, bool hasAtmosphere,
bool hasHalo, bool hasHalo,
const QString &pTypeStr); const QString &pTypeStr);
virtual ~Planet(); virtual ~Planet();
//! Initializes static vars. Must be called before creating first pl anet. //! Initializes static vars. Must be called before creating first pl anet.
skipping to change at line 186 skipping to change at line 192
//! - elongation-dms (formatted string) //! - elongation-dms (formatted string)
//! - elongation-deg (formatted string) //! - elongation-deg (formatted string)
//! - type (object type description) //! - type (object type description)
virtual QVariantMap getInfoMap(const StelCore *core) const; virtual QVariantMap getInfoMap(const StelCore *core) const;
virtual double getCloseViewFov(const StelCore* core) const; virtual double getCloseViewFov(const StelCore* core) const;
virtual double getSatellitesFov(const StelCore* core) const; virtual double getSatellitesFov(const StelCore* core) const;
virtual double getParentSatellitesFov(const StelCore* core) const; virtual double getParentSatellitesFov(const StelCore* core) const;
virtual float getVMagnitude(const StelCore* core) const; virtual float getVMagnitude(const StelCore* core) const;
virtual float getSelectPriority(const StelCore* core) const; virtual float getSelectPriority(const StelCore* core) const;
virtual Vec3f getInfoColor(void) const; virtual Vec3f getInfoColor(void) const;
virtual QString getType(void) const {return "Planet";} virtual QString getType(void) const {return PLANET_TYPE;}
virtual QString getID(void) const { return englishName; }
virtual Vec3d getJ2000EquatorialPos(const StelCore *core) const; virtual Vec3d getJ2000EquatorialPos(const StelCore *core) const;
virtual QString getEnglishName(void) const; virtual QString getEnglishName(void) const;
virtual QString getNameI18n(void) const; virtual QString getNameI18n(void) const;
//! Get angular semidiameter, degrees. If planet display is artifici ally enlarged (e.g. Moon upscale), value will also be increased. //! Get angular semidiameter, degrees. If planet display is artifici ally enlarged (e.g. Moon upscale), value will also be increased.
virtual double getAngularSize(const StelCore* core) const; virtual double getAngularSize(const StelCore* core) const;
virtual bool hasAtmosphere(void) {return atmosphere;} virtual bool hasAtmosphere(void) {return atmosphere;}
virtual bool hasHalo(void) {return halo;} virtual bool hasHalo(void) {return halo;}
//////////////////////////////////////////////////////////////////// /////// //////////////////////////////////////////////////////////////////// ///////
// Methods of SolarSystem object // Methods of SolarSystem object
//! Translate planet name using the passed translator //! Translate planet name using the passed translator
virtual void translateName(const StelTranslator &trans); virtual void translateName(const StelTranslator &trans);
// Draw the Planet // Draw the Planet
// GZ Made that virtual to allow comets having their own draw(). // GZ Made that virtual to allow comets having their own draw().
virtual void draw(StelCore* core, float maxMagLabels, const QFont& p lanetNameFont); virtual void draw(StelCore* core, float maxMagLabels, const QFont& p lanetNameFont);
//////////////////////////////////////////////////////////////////// /////// //////////////////////////////////////////////////////////////////// ///////
// Methods specific to Planet // Methods specific to Planet
//! Get the radius of the planet in AU. //! Get the equator radius of the planet in AU.
//! @return the radius of the planet in astronomical units. //! @return the equator radius of the planet in astronomical units.
double getRadius(void) const {return radius;} double getRadius(void) const {return radius;}
//! Get the value (1-f) for oblateness f. //! Get the value (1-f) for oblateness f.
double getOneMinusOblateness(void) const {return oneMinusOblateness; } double getOneMinusOblateness(void) const {return oneMinusOblateness; }
//! Get duration of sidereal day //! Get duration of sidereal day
double getSiderealDay(void) const {return re.period;} double getSiderealDay(void) const {return re.period;}
//! Get duration of sidereal year //! Get duration of sidereal year
// must be virtual for Comets. // must be virtual for Comets.
virtual double getSiderealPeriod(void) const { return re.siderealPer iod; } virtual double getSiderealPeriod(void) const { return re.siderealPer iod; }
//! Get duration of mean solar day //! Get duration of mean solar day
double getMeanSolarDay(void) const; double getMeanSolarDay(void) const;
skipping to change at line 232 skipping to change at line 239
const QString getPlanetTypeString() const {return pTypeMap.value(pTy pe);} const QString getPlanetTypeString() const {return pTypeMap.value(pTy pe);}
PlanetType getPlanetType() const {return pType;} PlanetType getPlanetType() const {return pType;}
void setNativeName(QString planet) { nativeName = planet; } void setNativeName(QString planet) { nativeName = planet; }
//! Return the absolute magnitude (read from file ssystem.ini) //! Return the absolute magnitude (read from file ssystem.ini)
float getAbsoluteMagnitude() const {return absoluteMagnitude;} float getAbsoluteMagnitude() const {return absoluteMagnitude;}
//! Return the mean opposition magnitude, defined as V(1,0)+5log10(a (a-1)) //! Return the mean opposition magnitude, defined as V(1,0)+5log10(a (a-1))
//! A return value of 100 signals invalid result. //! A return value of 100 signals invalid result.
float getMeanOppositionMagnitude() const; float getMeanOppositionMagnitude() const;
ApparentMagnitudeAlgorithm getApparentMagnitudeAlgorithm() const { r //
eturn vMagAlgorithm; } static ApparentMagnitudeAlgorithm getApparentMagnitudeAlgorithm() {
const QString getApparentMagnitudeAlgorithmString() const { return v return vMagAlgorithm; }
MagAlgorithmMap.value(vMagAlgorithm); } static const QString getApparentMagnitudeAlgorithmString() { return
void setApparentMagnitudeAlgorithm(QString algorithm); vMagAlgorithmMap.value(vMagAlgorithm); }
static void setApparentMagnitudeAlgorithm(QString algorithm);
static void setApparentMagnitudeAlgorithm(ApparentMagnitudeAlgorithm
algorithm){ vMagAlgorithm=algorithm; }
//! Compute the z rotation to use from equatorial to geographic coor dinates. For general applicability we need both time flavours: //! Compute the z rotation to use from equatorial to geographic coor dinates. For general applicability we need both time flavours:
//! @param JD is JD(UT) for Earth //! @param JD is JD(UT) for Earth
//! @param JDE is used for other locations //! @param JDE is used for other locations
double getSiderealTime(double JD, double JDE) const; double getSiderealTime(double JD, double JDE) const;
Mat4d getRotEquatorialToVsop87(void) const; Mat4d getRotEquatorialToVsop87(void) const;
void setRotEquatorialToVsop87(const Mat4d &m); void setRotEquatorialToVsop87(const Mat4d &m);
const RotationElements &getRotationElements(void) const {return re;} const RotationElements &getRotationElements(void) const {return re;}
// Set the orbital elements // Set the orbital elements
void setRotationElements(float _period, float _offset, double _epoch , void setRotationElements(float _period, float _offset, double _epoch ,
float _obliquity, float _ascendingNode, float _obliquity, float _ascendingNode,
float _precessionRate, double _siderealPeri od); float _precessionRate, double _siderealPeri od);
double getRotAscendingnode(void) const {return re.ascendingNode;} double getRotAscendingNode(void) const {return re.ascendingNode;}
// return angle between axis and normal of ecliptic plane (or, for a moon, equatorial/reference plane defined by parent). // return angle between axis and normal of ecliptic plane (or, for a moon, equatorial/reference plane defined by parent).
// TODO: decide if this is always angle between axis and J2000 eclip tic, or should be axis//current ecliptic! // TODO: decide if this is always angle between axis and J2000 eclip tic, or should be axis//current ecliptic!
double getRotObliquity(double JDE) const; double getRotObliquity(double JDE) const;
//! Compute the position in the parent Planet coordinate system //! Compute the position in the parent Planet coordinate system
void computePositionWithoutOrbits(const double dateJDE); void computePositionWithoutOrbits(const double dateJDE);
void computePosition(const double dateJDE); void computePosition(const double dateJDE);
//! Compute the transformation matrix from the local Planet coordina te to the parent Planet coordinate. //! Compute the transformation matrix from the local Planet coordina te to the parent Planet coordinate.
//! This requires both flavours of JD in cases involving Earth. //! This requires both flavours of JD in cases involving Earth.
void computeTransMatrix(double JD, double JDE); void computeTransMatrix(double JD, double JDE);
//! Get the phase angle (rad) for an observer at pos obsPos in helio centric coordinates (in AU) //! Get the phase angle (rad) for an observer at pos obsPos in helio centric coordinates (in AU)
double getPhaseAngle(const Vec3d& obsPos) const; double getPhaseAngle(const Vec3d& obsPos) const;
//! Get the elongation angle (rad) for an observer at pos obsPos in heliocentric coordinates (in AU) //! Get the elongation angle (rad) for an observer at pos obsPos in heliocentric coordinates (in AU)
double getElongation(const Vec3d& obsPos) const; double getElongation(const Vec3d& obsPos) const;
//! Get the angular size of the spheroid of the planet (i.e. without the rings) //! Get the angular size of the spheroid of the planet (i.e. without the rings)
double getSpheroidAngularSize(const StelCore* core) const; double getSpheroidAngularSize(const StelCore* core) const;
//! Get the planet phase for an observer at pos obsPos in heliocentr ic coordinates (in AU) //! Get the planet phase [0=dark..1=full] for an observer at pos obs Pos in heliocentric coordinates (in AU)
float getPhase(const Vec3d& obsPos) const; float getPhase(const Vec3d& obsPos) const;
//! Get the Planet position in the parent Planet ecliptic coordinate in AU //! Get the Planet position in the parent Planet ecliptic coordinate in AU
Vec3d getEclipticPos() const; Vec3d getEclipticPos() const;
// Return the heliocentric ecliptical position // Return the heliocentric ecliptical position
Vec3d getHeliocentricEclipticPos() const {return getHeliocentricPos( eclipticPos);} Vec3d getHeliocentricEclipticPos() const {return getHeliocentricPos( eclipticPos);}
// Return the heliocentric transformation for local coordinate // Return the heliocentric transformation for local coordinate
Vec3d getHeliocentricPos(Vec3d) const; Vec3d getHeliocentricPos(Vec3d) const;
void setHeliocentricEclipticPos(const Vec3d &pos); void setHeliocentricEclipticPos(const Vec3d &pos);
// Compute the distance to the given position in heliocentric coordi nate (in AU) // Compute the distance to the given position in heliocentric coordi nate (in AU)
double computeDistance(const Vec3d& obsHelioPos); double computeDistance(const Vec3d& obsHelioPos);
double getDistance(void) const {return distance;} double getDistance(void) const {return distance;}
void setRings(Ring* r) {rings = r;} void setRings(Ring* r) {rings = r;}
void setSphereScale(float s) {sphereScale = s;} void setSphereScale(float s) { if(s!=sphereScale) { sphereScale = s;
float getSphereScale(void) const {return sphereScale;} if(objModel) objModel->needsRescale=true; } }
const QSharedPointer<Planet> getParent(void) const {return parent;} const QSharedPointer<Planet> getParent(void) const {return parent;}
static void setLabelColor(const Vec3f& lc) {labelColor = lc;} static void setLabelColor(const Vec3f& lc) {labelColor = lc;}
static const Vec3f& getLabelColor(void) {return labelColor;} static const Vec3f& getLabelColor(void) {return labelColor;}
// update displayed elements. @param deltaTime: ms (since last call) // update displayed elements. @param deltaTime: ms (since last call)
virtual void update(int deltaTime); virtual void update(int deltaTime);
void setFlagHints(bool b){hintFader = b;} void setFlagHints(bool b){hintFader = b;}
skipping to change at line 320 skipping to change at line 328
//////////////////////////////////////////////////////////////////// /////// //////////////////////////////////////////////////////////////////// ///////
// DEPRECATED // DEPRECATED
///// Orbit related code ///// Orbit related code
// Should move to an OrbitPath class which works on a SolarSystemObj ect, not a Planet // Should move to an OrbitPath class which works on a SolarSystemObj ect, not a Planet
void setFlagOrbits(bool b){orbitFader = b;} void setFlagOrbits(bool b){orbitFader = b;}
bool getFlagOrbits(void) const {return orbitFader;} bool getFlagOrbits(void) const {return orbitFader;}
LinearFader orbitFader; LinearFader orbitFader;
// draw orbital path of Planet // draw orbital path of Planet
void drawOrbit(const StelCore*); void drawOrbit(const StelCore*);
Vec3d orbit[ORBIT_SEGMENTS+1]; // store heliocentric coordinates f Vec3d orbit[ORBIT_SEGMENTS+1]; // store heliocentric coordinates fo
or drawing the orbit r drawing the orbit
Vec3d orbitP[ORBIT_SEGMENTS+1]; // store local coordinate for orbit Vec3d orbitP[ORBIT_SEGMENTS+1]; // store local coordinate for orbit
double lastOrbitJDE; double lastOrbitJDE;
double deltaJDE; // time difference between position al updates. double deltaJDE; // time difference between positiona l updates.
double deltaOrbitJDE; double deltaOrbitJDE;
bool orbitCached; // whether orbit calculations are c bool orbitCached; // whether orbit calculations are ca
ached for drawing orbit yet ched for drawing orbit yet
bool closeOrbit; // whether to connect the beginning bool closeOrbit; // whether to connect the beginning
of the orbit line to of the orbit line to
// the end: good for elliptical orb // the end: good for elliptical orbi
its, bad for parabolic ts, bad for parabolic
// and hyperbolic orbits // and hyperbolic orbits
static Vec3f orbitColor; static Vec3f orbitColor;
static void setOrbitColor(const Vec3f& oc) {orbitColor = oc;} static void setOrbitColor(const Vec3f& oc) {orbitColor = oc;}
static const Vec3f& getOrbitColor() {return orbitColor;} static const Vec3f& getOrbitColor() {return orbitColor;}
static Vec3f orbitMajorPlanetsColor; static Vec3f orbitMajorPlanetsColor;
static void setMajorPlanetOrbitColor(const Vec3f& oc) { orbitMajorPl anetsColor = oc;} static void setMajorPlanetOrbitColor(const Vec3f& oc) { orbitMajorPl anetsColor = oc;}
static const Vec3f& getMajorPlanetOrbitColor() {return orbitMajorPla netsColor;} static const Vec3f& getMajorPlanetOrbitColor() {return orbitMajorPla netsColor;}
static Vec3f orbitMoonsColor; static Vec3f orbitMoonsColor;
skipping to change at line 413 skipping to change at line 421
static void setNeptuneOrbitColor(const Vec3f& oc) { orbitNeptuneColo r = oc;} static void setNeptuneOrbitColor(const Vec3f& oc) { orbitNeptuneColo r = oc;}
static const Vec3f& getNeptuneOrbitColor() {return orbitNeptuneColor ;} static const Vec3f& getNeptuneOrbitColor() {return orbitNeptuneColor ;}
static bool permanentDrawingOrbits; static bool permanentDrawingOrbits;
static PlanetOrbitColorStyle orbitColorStyle; static PlanetOrbitColorStyle orbitColorStyle;
//! Return the list of planets which project some shadow on this pla net //! Return the list of planets which project some shadow on this pla net
QVector<const Planet*> getCandidatesForShadow() const; QVector<const Planet*> getCandidatesForShadow() const;
protected: protected:
struct PlanetOBJModel
{
PlanetOBJModel();
~PlanetOBJModel();
//! Loads the data from the StelOBJ into the StelOpenGLArray
bool loadGL();
void performScaling(double scale);
//! The BBox of the original model before any transformation
s
AABBox bbox;
//! Contains the original positions in model space in km, th
ey need scaling and projection
QVector<Vec3f> posArray;
//! True when the positions need to be rescaled before drawi
ng
bool needsRescale;
//! Contains the scaled positions (sphere scale in AU), need
StelProjector transformation for display
QVector<Vec3f> scaledArray;
//! Used to store the projected array data, avoids re-alloca
tion each frame
QVector<Vec3f> projectedPosArray;
//! An OpenGL buffer for the projected positions
QOpenGLBuffer* projPosBuffer;
//! The single texture to use
StelTextureSP texture;
//! The original StelOBJ data, deleted after loading to GL
StelOBJ* obj;
//! The opengl array, created by loadObjModel() but filled l
ater in main thread
StelOpenGLArray* arr;
};
static StelTextureSP texEarthShadow; // for lunar eclipses static StelTextureSP texEarthShadow; // for lunar eclipses
void computeModelMatrix(Mat4d &result) const; void computeModelMatrix(Mat4d &result) const;
Vec3f getCurrentOrbitColor(); Vec3f getCurrentOrbitColor() const;
// Return the information string "ready to print" :) // Return the information string "ready to print" :)
QString getSkyLabel(const StelCore* core) const; QString getSkyLabel(const StelCore* core) const;
// Draw the 3d model. Call the proper functions if there are rings e tc.. // Draw the 3d model. Call the proper functions if there are rings e tc..
void draw3dModel(StelCore* core, StelProjector::ModelViewTranformP t ransfo, float screenSz, bool drawOnlyRing=false); void draw3dModel(StelCore* core, StelProjector::ModelViewTranformP t ransfo, float screenSz, bool drawOnlyRing=false);
// Draws the OBJ model, assuming it is available
// @return false if the model can currently not be drawn (not loaded
)
bool drawObjModel(StelPainter* painter, float screenSz);
bool drawObjShadowMap(StelPainter* painter, QMatrix4x4 &shadowMatrix
);
//! Starts the OBJ loading process, if it has not been done yet.
//! Returns true when the OBJ is ready to draw
bool ensureObjLoaded();
// Draw the 3D sphere // Draw the 3D sphere
void drawSphere(StelPainter* painter, float screenSz, bool drawOnlyR ing=false); void drawSphere(StelPainter* painter, float screenSz, bool drawOnlyR ing=false);
// Draw the circle and name of the Planet // Draw the circle and name of the Planet
void drawHints(const StelCore* core, const QFont& planetNameFont); void drawHints(const StelCore* core, const QFont& planetNameFont);
PlanetOBJModel* loadObjModel() const;
QString englishName; // english planet name QString englishName; // english planet name
QString nameI18; // International translated name QString nameI18; // International translated name
QString nativeName; // Can be used in a skyculture QString nativeName; // Can be used in a skyculture
QString texMapName; // Texture file path QString texMapName; // Texture file path
QString normalMapName; // Texture file path QString normalMapName; // Texture file path
int flagLighting; // Set whether light computation ha s to be proceed //int flagLighting; // Set whether light computation has to be proceed. NO LONGER USED (always on!)
RotationElements re; // Rotation param RotationElements re; // Rotation param
double radius; // Planet radius in AU double radius; // Planet radius in AU
double oneMinusOblateness; // (polar radius)/(equatorial radiu s) double oneMinusOblateness; // (polar radius)/(equatorial radiu s)
Vec3d eclipticPos; // Position in AU in the rectangula Vec3d eclipticPos; // Position in AU in the rectangula
r ecliptic coordinate system r ecliptic coordinate system around the parent body. To get heliocentric co
// centered on the parent Planet ordinates, use getHeliocentricEclipticPos()
// centered on the parent Planet
Vec3d screenPos; // Used to store temporarily the 2D position on screen Vec3d screenPos; // Used to store temporarily the 2D position on screen
Vec3d previousScreenPos; // The position of this planet in t // Vec3d previousScreenPos; // The position of this planet in t
he previous frame. he previous frame. 0.16pre: DEAD CODE!
Vec3f haloColor; // exclusively used for drawing the Vec3f haloColor; // used for drawing the planet halo
planet halo . Also, when non-spherical (OBJ) model without texture is used, its color i
s derived from haloColour*albedo.
float albedo; // Planet albedo. Used for magnitud float absoluteMagnitude; // since 2017 this moved to the Pla
e computation (but formula dubious!) net class: V(1,0) from Explanatory Supplement or WGCCRE2009 paper for the p
float absoluteMagnitude; // since 2017: V(1,0) from Explanat lanets, H in the H,G magnitude system for Minor planets, H10 for comets.
ory Supplement or WGCCRE2009 paper for the planets, H in the H,G magnitude
system for Minor planets, H10 for comets.
// This is the apparent visual magn itude when 1AU from sun and observer, with zero phase angle. // This is the apparent visual magn itude when 1AU from sun and observer, with zero phase angle.
float albedo; // Planet albedo. Used for magnitud
e computation when no other formula in use. Also, when non-spherical (OBJ)
model without texture is used, its color is derived from haloColour*albedo.
float roughness; // Oren-Nayar roughness for Moon an
d OBJ-based models
float outgas_intensity; // The intensity of a pseudo-outgas
effect, based on an inverse exponential Lambert shading, with the light at
the viewing position
// Non-null only for Comets, but we
use one shader for all Planets and derivatives, so we need a placeholder h
ere.
float outgas_falloff; // Exponent for falloff of outgas e
ffect, should probably be < 1
// Non-null only for Comets, but we
use one shader for all Planets and derivatives, so we need a placeholder h
ere.
Mat4d rotLocalToParent; // GZ2015: was undocumented. Mat4d rotLocalToParent; // GZ2015: was undocumented.
// Apparently this is the axis orie ntation with respect to the parent body. For planets, this is axis orientat ion w.r.t. VSOP87A/J2000 ecliptical system. // Apparently this is the axis orientation with respect to the paren t body. For planets, this is axis orientation w.r.t. VSOP87A/J2000 ecliptic al system.
float axisRotation; // Rotation angle of the Planet on its axis. float axisRotation; // Rotation angle of the Planet on its axis.
// For Earth, this should be Greenw ich Mean Sidereal Time GMST. // For Earth, this should be Greenwich Mean Sidereal Time GMST.
StelTextureSP texMap; // Planet map texture StelTextureSP texMap; // Planet map texture
StelTextureSP normalMap; // Planet normal map texture StelTextureSP normalMap; // Planet normal map texture
PlanetOBJModel* objModel; // Planet model (when it has
been loaded)
QFuture<PlanetOBJModel*>* objModelLoader;// For async loading of the
OBJ file
QString objModelPath;
Ring* rings; // Planet rings Ring* rings; // Planet rings
double distance; // Temporary variable used to store the distance to a given point double distance; // Temporary variable used to store the distance to a given point
// it is used for sorting while dra // it is used for sorting while drawing
wing float sphereScale; // Artificial scaling for better vi
float sphereScale; // Artificial scaling for better vi ewing.
ewing
double lastJDE; // caches JDE of last positional co mputation double lastJDE; // caches JDE of last positional co mputation
// The callback for the calculation of the equatorial rect heliocent ric position at time JDE. // The callback for the calculation of the equatorial rect heliocent ric position at time JDE.
posFuncType coordFunc; posFuncType coordFunc;
void* userDataPtr; // this is always used with an Orbi t object. void* orbitPtr; // this is always used with an Orbit o bject.
OsculatingFunctType *const osculatingFunc; OsculatingFunctType *const osculatingFunc;
QSharedPointer<Planet> parent; // Planet parent i.e. sun f or earth QSharedPointer<Planet> parent; // Planet parent i.e. sun f or earth
QList<QSharedPointer<Planet> > satellites; // satellites of the Planet QList<QSharedPointer<Planet> > satellites; // satellites of the Planet
LinearFader hintFader; LinearFader hintFader;
LinearFader labelsFader; // Store the current state of the l abel for this planet LinearFader labelsFader; // Store the current state of the l abel for this planet
bool flagLabels; // Define whether labels should be displayed bool flagLabels; // Define whether labels should be displayed
bool hidden; // useful for fake planets used as observation positions - not drawn or labeled bool hidden; // useful for fake planets used as observation positions - not drawn or labeled
bool atmosphere; // Does the planet have an atmosphe re? bool atmosphere; // Does the planet have an atmosphe re?
bool halo; // Does the planet have a halo? bool halo; // Does the planet have a halo?
PlanetType pType; // Type of body PlanetType pType; // Type of body
ApparentMagnitudeAlgorithm vMagAlgorithm; static ApparentMagnitudeAlgorithm vMagAlgorithm;
QOpenGLFunctions* gl;
static bool shaderError; // True if loading shaders c
aused errors
static Vec3f labelColor; static Vec3f labelColor;
static StelTextureSP hintCircleTex; static StelTextureSP hintCircleTex;
static QMap<PlanetType, QString> pTypeMap; // Maps fast type to engl ish name. static QMap<PlanetType, QString> pTypeMap; // Maps fast type to engl ish name.
static QMap<ApparentMagnitudeAlgorithm, QString> vMagAlgorithmMap; static QMap<ApparentMagnitudeAlgorithm, QString> vMagAlgorithmMap;
static bool flagCustomGrsSettings; // Is enabled usage of custo m settings for calculation of position of Great Red Spot? static bool flagCustomGrsSettings; // Is enabled usage of custo m settings for calculation of position of Great Red Spot?
static double customGrsJD; // Initial JD for calculatio n of position of Great Red Spot static double customGrsJD; // Initial JD for calculatio n of position of Great Red Spot
static int customGrsLongitude; // Longitude of Great Red Sp ot (System II, degrees) static int customGrsLongitude; // Longitude of Great Red Sp ot (System II, degrees)
static double customGrsDrift; // Annual drift of Great Red Spot position (degrees) static double customGrsDrift; // Annual drift of Great Red Spot position (degrees)
private:
// Shader-related variables // Shader-related variables
struct PlanetShaderVars { struct PlanetShaderVars {
int projectionMatrix; // Vertex attributes
int texCoord; int texCoord;
int unprojectedVertex; int unprojectedVertex;
int vertex; int vertex;
int texture; int normalIn;
// Common uniforms
int projectionMatrix;
int tex;
int lightDirection; int lightDirection;
int eyeDirection; int eyeDirection;
int diffuseLight; int diffuseLight;
int ambientLight; int ambientLight;
int shadowCount; int shadowCount;
int shadowData; int shadowData;
int sunInfo; int sunInfo;
int skyBrightness; int skyBrightness;
int orenNayarParameters;
int outgasParameters;
void initLocations(QOpenGLShaderProgram*); // Moon-specific variables
}; int earthShadow;
static PlanetShaderVars planetShaderVars; int normalMap;
static QOpenGLShaderProgram* planetShaderProgram;
// Shader-related variables
struct RingPlanetShaderVars : public PlanetShaderVars {
// Rings-specific variables // Rings-specific variables
int isRing; int isRing;
int ring; int ring;
int outerRadius; int outerRadius;
int innerRadius; int innerRadius;
int ringS; int ringS;
// Shadowmap variables
int shadowMatrix;
int shadowTex;
int poissonDisk;
void initLocations(QOpenGLShaderProgram*);
}; };
static RingPlanetShaderVars ringPlanetShaderVars;
static QOpenGLShaderProgram* ringPlanetShaderProgram;
struct MoonShaderVars : public PlanetShaderVars { //! Encapsulates some calculated information used for rendering
// Moon-specific variables struct RenderData
int earthShadow; {
int normalMap; Mat4d modelMatrix;
Mat4d mTarget;
QVector<const Planet*> shadowCandidates;
QMatrix4x4 shadowCandidatesData;
Vec3d eyePos;
}; };
static MoonShaderVars moonShaderVars;
//! Calculates and uploads the common shader uniforms (projection ma
trix, texture, lighting&shadow data)
RenderData setCommonShaderUniforms(const StelPainter &painter, QOpen
GLShaderProgram* shader, const PlanetShaderVars& shaderVars) const;
static PlanetShaderVars planetShaderVars;
static QOpenGLShaderProgram* planetShaderProgram;
static PlanetShaderVars ringPlanetShaderVars;
static QOpenGLShaderProgram* ringPlanetShaderProgram;
static PlanetShaderVars moonShaderVars;
static QOpenGLShaderProgram* moonShaderProgram; static QOpenGLShaderProgram* moonShaderProgram;
static PlanetShaderVars objShaderVars;
static QOpenGLShaderProgram* objShaderProgram;
static PlanetShaderVars objShadowShaderVars;
static QOpenGLShaderProgram* objShadowShaderProgram;
static PlanetShaderVars transformShaderVars;
static QOpenGLShaderProgram* transformShaderProgram;
static bool shadowInitialized;
static Vec2f shadowPolyOffset;
#ifdef DEBUG_SHADOWMAP
static QOpenGLFramebufferObject* shadowFBO;
#else
static unsigned int shadowFBO;
#endif
static unsigned int shadowTex;
static void initShader(); static void initShader();
static void deinitShader(); static void deinitShader();
static bool initFBO();
static void deinitFBO();
static QOpenGLShaderProgram* createShader(const QString& name, Plane
tShaderVars& vars, const QByteArray& vSrc, const QByteArray& fSrc, const QB
yteArray& prefix=QByteArray(), const QMap<QByteArray,int>& fixedAttributeLo
cations=QMap<QByteArray,int>());
}; };
#endif // _PLANET_HPP_ #endif // _PLANET_HPP_
 End of changes. 50 change blocks. 
93 lines changed or deleted 230 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/