Stellarium  0.16.1
Planet.hpp
1 /*
2  * Stellarium
3  * Copyright (C) 2002 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 _PLANET_HPP_
21 #define _PLANET_HPP_
22 
23 #include "StelObject.hpp"
24 #include "StelProjector.hpp"
25 #include "VecMath.hpp"
26 #include "GeomMath.hpp"
27 #include "StelFader.hpp"
28 #include "StelTextureTypes.hpp"
29 #include "StelProjectorType.hpp"
30 
31 #include <QString>
32 
33 // The callback type for the external position computation function
34 // The last variable is the userData pointer.
35 typedef void (*posFuncType)(double, double*, void*);
36 
37 typedef void (OsculatingFunctType)(double jde0,double jde,double xyz[3]);
38 
39 // epoch J2000: 12 UT on 1 Jan 2000
40 #define J2000 2451545.0
41 #define ORBIT_SEGMENTS 360
42 
43 class StelFont;
44 class StelPainter;
45 class StelTranslator;
46 class StelOBJ;
47 class StelOpenGLArray;
48 template <class T> class QFuture;
49 class QOpenGLBuffer;
50 class QOpenGLFunctions;
51 class QOpenGLShaderProgram;
52 class QOpenGLTexture;
53 #ifdef DEBUG_SHADOWMAP
54 class QOpenGLFramebufferObject;
55 #endif
56 
57 // Class used to store rotational elements, i.e. axis orientation for the planetary body.
59 {
60 public:
61  RotationElements(void) : period(1.), offset(0.), epoch(J2000), obliquity(0.), ascendingNode(0.), precessionRate(0.), siderealPeriod(0.) {}
62  float period; // (sidereal) rotation period [earth days]
63  float offset; // rotation at epoch [degrees]
64  double epoch; // JDE (JD TT) of epoch for these elements
65  float obliquity; // tilt of rotation axis w.r.t. ecliptic [radians]
66  float ascendingNode; // long. of ascending node of equator on the ecliptic [radians]
67  float precessionRate; // rate of precession of rotation axis in [rads/JulianCentury(36525d)]
68  double siderealPeriod; // sidereal period (Planet year in earth days) [earth days]
69 };
70 
71 // Class to manage rings for planets like saturn
72 class Ring
73 {
74 public:
75  Ring(float radiusMin, float radiusMax,const QString &texname);
76  double getSize(void) const {return radiusMax;}
77  const float radiusMin;
78  const float radiusMax;
79  StelTextureSP tex;
80 };
81 
82 
83 class Planet : public StelObject
84 {
85 public:
86  static const QString PLANET_TYPE;
87  friend class SolarSystem;
88 
89  Q_ENUMS(PlanetType)
90  Q_ENUMS(PlanetOrbitColorStyle)
91  Q_ENUMS(ApparentMagnitudeAlgorithm)
93  // GZ: Until 0.13 QStrings were used for types.
94  // GZ: Enums are slightly faster than string comparisons in time-critical comparisons.
95  // GZ: If other types are introduced, add here and the string in init().
96  // GZ TODO for 0.16: Preferably convert this into a bitfield and allow several bits set:
97  // Cubewanos, SDO, OCO, Sednoids are Asteroids, Pluto is a Plutino and DwarfPlanet, Ceres is Asteroid and DwarfPlanet etc.!
98  // Maybe even add queries like Planet::isAsteroid() { return (planetType & Planet::isAsteroid);}
100  {
101  isStar, // ssystem.ini: type="star"
102  isPlanet, // ssystem.ini: type="planet"
103  isMoon, // ssystem.ini: type="moon"
104  isObserver, // ssystem.ini: type="observer"
105  isArtificial, // Used in transitions from planet to planet.
106  isAsteroid, // ssystem.ini: type="asteroid". all types >= isAsteroid are "Minor Bodies".
107  // Put other things (spacecraft etc) before isAsteroid.
108  isPlutino, // ssystem.ini: type="plutino"
109  isComet, // ssystem.ini: type="comet"
110  isDwarfPlanet, // ssystem.ini: type="dwarf planet"
111  isCubewano, // ssystem.ini: type="cubewano"
112  isSDO, // ssystem.ini: type="scattered disc object"
113  isOCO, // ssystem.ini: type="oco"
114  isSednoid, // ssystem.ini: type="sednoid"
115  isUNDEFINED // ssystem.ini: type=<anything else>. THIS IS ONLY IN CASE OF ERROR!
116  };
117 
118  enum PlanetOrbitColorStyle
119  {
120  ocsOneColor, // One color for all orbits
121  ocsGroups, // Separate colors for each group of Solar system bodies
122  ocsMajorPlanets // Separate colors for each of major planets of Solar system
123  };
124 
125  enum ApparentMagnitudeAlgorithm
126  {
127  Mueller_1893, // G. Mueller, based on visual observations 1877-91. [Expl.Suppl.1961]
128  Astr_Alm_1984, // Astronomical Almanac 1984 and later. These give V (instrumental) magnitudes (allegedly from D.L. Harris, but this is wrong!)
129  Expl_Sup_1992, // Algorithm provided by Pere Planesas (Observatorio Astronomico Nacional) (Was called "Planesas")
130  Expl_Sup_2013, // Explanatory Supplement to the Astronomical Almanac, 3rd edition 2013
131  UndefinedAlgorithm,
132  Generic // Visual magnitude based on phase angle and albedo. The formula source for this is totally unknown!
133  };
134 
135 
136  Planet(const QString& englishName,
137  double radius,
138  double oblateness,
139  Vec3f halocolor,
140  float albedo,
141  float roughness,
142  const QString& texMapName,
143  const QString& normalMapName,
144  const QString& objModelName,
145  posFuncType _coordFunc,
146  void* anOrbitPtr,
147  OsculatingFunctType *osculatingFunc,
148  bool closeOrbit,
149  bool hidden,
150  bool hasAtmosphere,
151  bool hasHalo,
152  const QString &pTypeStr);
153 
154  virtual ~Planet();
155 
157  // Currently ensured by SolarSystem::init()
158  static void init();
159 
161  // Methods inherited from StelObject
175  virtual QString getInfoString(const StelCore *core, const InfoStringGroup& flags) const;
187  virtual QVariantMap getInfoMap(const StelCore *core) const;
188  virtual double getCloseViewFov(const StelCore* core) const;
189  virtual double getSatellitesFov(const StelCore* core) const;
190  virtual double getParentSatellitesFov(const StelCore* core) const;
191  virtual float getVMagnitude(const StelCore* core) const;
192  virtual float getSelectPriority(const StelCore* core) const;
193  virtual Vec3f getInfoColor(void) const;
194  virtual QString getType(void) const {return PLANET_TYPE;}
195  virtual QString getID(void) const { return englishName; }
196  virtual Vec3d getJ2000EquatorialPos(const StelCore *core) const;
197  virtual QString getEnglishName(void) const;
198  virtual QString getNameI18n(void) const;
199  QString getCommonEnglishName(void) const {return englishName;}
200  QString getCommonNameI18n(void) const {return nameI18;}
202  virtual double getAngularSize(const StelCore* core) const;
203  virtual bool hasAtmosphere(void) {return atmosphere;}
204  virtual bool hasHalo(void) {return halo;}
205 
207  // Methods of SolarSystem object
209  virtual void translateName(const StelTranslator &trans);
210 
211  // Draw the Planet
212  // GZ Made that virtual to allow comets having their own draw().
213  virtual void draw(StelCore* core, float maxMagLabels, const QFont& planetNameFont);
214 
216  // Methods specific to Planet
219  double getRadius(void) const {return radius;}
221  double getOneMinusOblateness(void) const {return oneMinusOblateness;}
223  double getSiderealDay(void) const {return re.period;}
225  // must be virtual for Comets.
226  virtual double getSiderealPeriod(void) const { return re.siderealPeriod; }
228  double getMeanSolarDay(void) const;
230  double getAlbedo(void) const { return albedo; }
231 
232  const QString& getTextMapName() const {return texMapName;}
233  const QString getPlanetTypeString() const {return pTypeMap.value(pType);}
234  PlanetType getPlanetType() const {return pType;}
235 
236  void setNativeName(QString planet) { nativeName = planet; }
237 
239  void setIAUMoonNumber(QString designation);
240 
242  float getAbsoluteMagnitude() const {return absoluteMagnitude;}
245  float getMeanOppositionMagnitude() const;
246  //
247  static ApparentMagnitudeAlgorithm getApparentMagnitudeAlgorithm() { return vMagAlgorithm; }
248  static const QString getApparentMagnitudeAlgorithmString() { return vMagAlgorithmMap.value(vMagAlgorithm); }
249  static void setApparentMagnitudeAlgorithm(QString algorithm);
250  static void setApparentMagnitudeAlgorithm(ApparentMagnitudeAlgorithm algorithm){ vMagAlgorithm=algorithm; }
251 
255  double getSiderealTime(double JD, double JDE) const;
256  Mat4d getRotEquatorialToVsop87(void) const;
257  void setRotEquatorialToVsop87(const Mat4d &m);
258 
259  const RotationElements &getRotationElements(void) const {return re;}
260  // Set the orbital elements
261  void setRotationElements(float _period, float _offset, double _epoch,
262  float _obliquity, float _ascendingNode,
263  float _precessionRate, double _siderealPeriod);
264  double getRotAscendingNode(void) const {return re.ascendingNode;}
265  // return angle between axis and normal of ecliptic plane (or, for a moon, equatorial/reference plane defined by parent).
266  // TODO: decide if this is always angle between axis and J2000 ecliptic, or should be axis//current ecliptic!
267  double getRotObliquity(double JDE) const;
268 
269 
270 
272  void computePositionWithoutOrbits(const double dateJDE);
273  virtual void computePosition(const double dateJDE);
274 
277  void computeTransMatrix(double JD, double JDE);
278 
280  double getPhaseAngle(const Vec3d& obsPos) const;
282  double getElongation(const Vec3d& obsPos) const;
284  double getSpheroidAngularSize(const StelCore* core) const;
286  float getPhase(const Vec3d& obsPos) const;
287 
289  Vec3d getEclipticPos() const;
290 
291  // Return the heliocentric ecliptical position
292  Vec3d getHeliocentricEclipticPos() const {return getHeliocentricPos(eclipticPos);}
293 
294  // Return the heliocentric transformation for local coordinate
295  Vec3d getHeliocentricPos(Vec3d) const;
296  void setHeliocentricEclipticPos(const Vec3d &pos);
297 
298  // Compute the distance to the given position in heliocentric coordinate (in AU)
299  double computeDistance(const Vec3d& obsHelioPos);
300  double getDistance(void) const {return distance;}
301 
302  void setRings(Ring* r) {rings = r;}
303 
304  void setSphereScale(float s) { if(s!=sphereScale) { sphereScale = s; if(objModel) objModel->needsRescale=true; } }
305 
306  const QSharedPointer<Planet> getParent(void) const {return parent;}
307 
308  static void setLabelColor(const Vec3f& lc) {labelColor = lc;}
309  static const Vec3f& getLabelColor(void) {return labelColor;}
310 
311  // update displayed elements. @param deltaTime: ms (since last call)
312  virtual void update(int deltaTime);
313 
314  void setFlagHints(bool b){hintFader = b;}
315  bool getFlagHints(void) const {return hintFader;}
316 
317  void setFlagLabels(bool b){flagLabels = b;}
318  bool getFlagLabels(void) const {return flagLabels;}
319 
320  bool flagNativeName;
321  void setFlagNativeName(bool b) { flagNativeName = b; }
322  bool getFlagNativeName(void) { return flagNativeName; }
323 
324  bool flagTranslatedName;
325  void setFlagTranslatedName(bool b) { flagTranslatedName = b; }
326  bool getFlagTranslatedName(void) { return flagTranslatedName; }
327 
329  // DEPRECATED
331  // Should move to an OrbitPath class which works on a SolarSystemObject, not a Planet
332  void setFlagOrbits(bool b){orbitFader = b;}
333  bool getFlagOrbits(void) const {return orbitFader;}
334  LinearFader orbitFader;
335  // draw orbital path of Planet
336  void drawOrbit(const StelCore*);
337  Vec3d orbit[ORBIT_SEGMENTS+1]; // store heliocentric coordinates for drawing the orbit
338  Vec3d orbitP[ORBIT_SEGMENTS+1]; // store local coordinate for orbit
339  double lastOrbitJDE;
340  double deltaJDE; // time difference between positional updates.
341  double deltaOrbitJDE;
342  bool orbitCached; // whether orbit calculations are cached for drawing orbit yet
343  bool closeOrbit; // whether to connect the beginning of the orbit line to
344  // the end: good for elliptical orbits, bad for parabolic
345  // and hyperbolic orbits
346 
347  static Vec3f orbitColor;
348  static void setOrbitColor(const Vec3f& oc) {orbitColor = oc;}
349  static const Vec3f& getOrbitColor() {return orbitColor;}
350 
351  static Vec3f orbitMajorPlanetsColor;
352  static void setMajorPlanetOrbitColor(const Vec3f& oc) { orbitMajorPlanetsColor = oc;}
353  static const Vec3f& getMajorPlanetOrbitColor() {return orbitMajorPlanetsColor;}
354 
355  static Vec3f orbitMoonsColor;
356  static void setMoonOrbitColor(const Vec3f& oc) { orbitMoonsColor = oc;}
357  static const Vec3f& getMoonOrbitColor() {return orbitMoonsColor;}
358 
359  static Vec3f orbitMinorPlanetsColor;
360  static void setMinorPlanetOrbitColor(const Vec3f& oc) { orbitMinorPlanetsColor = oc;}
361  static const Vec3f& getMinorPlanetOrbitColor() {return orbitMinorPlanetsColor;}
362 
363  static Vec3f orbitDwarfPlanetsColor;
364  static void setDwarfPlanetOrbitColor(const Vec3f& oc) { orbitDwarfPlanetsColor = oc;}
365  static const Vec3f& getDwarfPlanetOrbitColor() {return orbitDwarfPlanetsColor;}
366 
367  static Vec3f orbitCubewanosColor;
368  static void setCubewanoOrbitColor(const Vec3f& oc) { orbitCubewanosColor = oc;}
369  static const Vec3f& getCubewanoOrbitColor() {return orbitCubewanosColor;}
370 
371  static Vec3f orbitPlutinosColor;
372  static void setPlutinoOrbitColor(const Vec3f& oc) { orbitPlutinosColor = oc;}
373  static const Vec3f& getPlutinoOrbitColor() {return orbitPlutinosColor;}
374 
375  static Vec3f orbitScatteredDiscObjectsColor;
376  static void setScatteredDiscObjectOrbitColor(const Vec3f& oc) { orbitScatteredDiscObjectsColor = oc;}
377  static const Vec3f& getScatteredDiscObjectOrbitColor() {return orbitScatteredDiscObjectsColor;}
378 
379  static Vec3f orbitOortCloudObjectsColor;
380  static void setOortCloudObjectOrbitColor(const Vec3f& oc) { orbitOortCloudObjectsColor = oc;}
381  static const Vec3f& getOortCloudObjectOrbitColor() {return orbitOortCloudObjectsColor;}
382 
383  static Vec3f orbitCometsColor;
384  static void setCometOrbitColor(const Vec3f& oc) { orbitCometsColor = oc;}
385  static const Vec3f& getCometOrbitColor() {return orbitCometsColor;}
386 
387  static Vec3f orbitSednoidsColor;
388  static void setSednoidOrbitColor(const Vec3f& oc) { orbitSednoidsColor = oc;}
389  static const Vec3f& getSednoidOrbitColor() {return orbitSednoidsColor;}
390 
391  static Vec3f orbitMercuryColor;
392  static void setMercuryOrbitColor(const Vec3f& oc) { orbitMercuryColor = oc;}
393  static const Vec3f& getMercuryOrbitColor() {return orbitMercuryColor;}
394 
395  static Vec3f orbitVenusColor;
396  static void setVenusOrbitColor(const Vec3f& oc) { orbitVenusColor = oc;}
397  static const Vec3f& getVenusOrbitColor() {return orbitVenusColor;}
398 
399  static Vec3f orbitEarthColor;
400  static void setEarthOrbitColor(const Vec3f& oc) { orbitEarthColor = oc;}
401  static const Vec3f& getEarthOrbitColor() {return orbitEarthColor;}
402 
403  static Vec3f orbitMarsColor;
404  static void setMarsOrbitColor(const Vec3f& oc) { orbitMarsColor = oc;}
405  static const Vec3f& getMarsOrbitColor() {return orbitMarsColor;}
406 
407  static Vec3f orbitJupiterColor;
408  static void setJupiterOrbitColor(const Vec3f& oc) { orbitJupiterColor = oc;}
409  static const Vec3f& getJupiterOrbitColor() {return orbitJupiterColor;}
410 
411  static Vec3f orbitSaturnColor;
412  static void setSaturnOrbitColor(const Vec3f& oc) { orbitSaturnColor = oc;}
413  static const Vec3f& getSaturnOrbitColor() {return orbitSaturnColor;}
414 
415  static Vec3f orbitUranusColor;
416  static void setUranusOrbitColor(const Vec3f& oc) { orbitUranusColor = oc;}
417  static const Vec3f& getUranusOrbitColor() {return orbitUranusColor;}
418 
419  static Vec3f orbitNeptuneColor;
420  static void setNeptuneOrbitColor(const Vec3f& oc) { orbitNeptuneColor = oc;}
421  static const Vec3f& getNeptuneOrbitColor() {return orbitNeptuneColor;}
422 
423  static bool permanentDrawingOrbits;
424  static PlanetOrbitColorStyle orbitColorStyle;
425 
427  QVector<const Planet*> getCandidatesForShadow() const;
428 
429 protected:
431  {
432  PlanetOBJModel();
433  ~PlanetOBJModel();
434 
436  bool loadGL();
437 
438  void performScaling(double scale);
439 
443  QVector<Vec3f> posArray;
447  QVector<Vec3f> scaledArray;
449  QVector<Vec3f> projectedPosArray;
451  QOpenGLBuffer* projPosBuffer;
458 
459  };
460 
461  static StelTextureSP texEarthShadow; // for lunar eclipses
462 
463  void computeModelMatrix(Mat4d &result) const;
464 
465  Vec3f getCurrentOrbitColor() const;
466 
467  // Return the information string "ready to print" :)
468  QString getSkyLabel(const StelCore* core) const;
469 
470  // Draw the 3d model. Call the proper functions if there are rings etc..
471  void draw3dModel(StelCore* core, StelProjector::ModelViewTranformP transfo, float screenSz, bool drawOnlyRing=false);
472 
473  // Draws the OBJ model, assuming it is available
474  // @return false if the model can currently not be drawn (not loaded)
475  bool drawObjModel(StelPainter* painter, float screenSz);
476 
477  bool drawObjShadowMap(StelPainter* painter, QMatrix4x4 &shadowMatrix);
478 
481  bool ensureObjLoaded();
482 
483  // Draw the 3D sphere
484  void drawSphere(StelPainter* painter, float screenSz, bool drawOnlyRing=false);
485 
486  // Draw the circle and name of the Planet
487  void drawHints(const StelCore* core, const QFont& planetNameFont);
488 
489  PlanetOBJModel* loadObjModel() const;
490 
491  QString englishName; // english planet name
492  QString nameI18; // International translated name
493  QString nativeName; // Can be used in a skyculture
494  QString texMapName; // Texture file path
495  QString normalMapName; // Texture file path
496  //int flagLighting; // Set whether light computation has to be proceed. NO LONGER USED (always on!)
497  RotationElements re; // Rotation param
498  double radius; // Planet radius in AU
499  double oneMinusOblateness; // (polar radius)/(equatorial radius)
500  Vec3d eclipticPos; // Position in AU in the rectangular ecliptic coordinate system around the parent body. To get heliocentric coordinates, use getHeliocentricEclipticPos()
501  // centered on the parent Planet
502  Vec3d screenPos; // Used to store temporarily the 2D position on screen
503 // Vec3d previousScreenPos; // The position of this planet in the previous frame. 0.16pre: DEAD CODE!
504  Vec3f haloColor; // used for drawing the planet halo. Also, when non-spherical (OBJ) model without texture is used, its color is derived from haloColour*albedo.
505 
506  float absoluteMagnitude; // since 2017 this moved to the Planet class: V(1,0) from Explanatory Supplement or WGCCRE2009 paper for the planets, H in the H,G magnitude system for Minor planets, H10 for comets.
507  // This is the apparent visual magnitude when 1AU from sun and observer, with zero phase angle.
508  float albedo; // Planet albedo. Used for magnitude computation when no other formula in use. Also, when non-spherical (OBJ) model without texture is used, its color is derived from haloColour*albedo.
509  float roughness; // Oren-Nayar roughness for Moon and OBJ-based models
510  float outgas_intensity; // The intensity of a pseudo-outgas effect, based on an inverse exponential Lambert shading, with the light at the viewing position
511  // Non-null only for Comets, but we use one shader for all Planets and derivatives, so we need a placeholder here.
512  float outgas_falloff; // Exponent for falloff of outgas effect, should probably be < 1
513  // Non-null only for Comets, but we use one shader for all Planets and derivatives, so we need a placeholder here.
514  Mat4d rotLocalToParent; // GZ2015: was undocumented.
515  // Apparently this is the axis orientation with respect to the parent body. For planets, this is axis orientation w.r.t. VSOP87A/J2000 ecliptical system.
516  float axisRotation; // Rotation angle of the Planet on its axis.
517  // For Earth, this should be Greenwich Mean Sidereal Time GMST.
518  StelTextureSP texMap; // Planet map texture
519  StelTextureSP normalMap; // Planet normal map texture
520 
521  PlanetOBJModel* objModel; // Planet model (when it has been loaded)
522  QFuture<PlanetOBJModel*>* objModelLoader;// For async loading of the OBJ file
523 
524  QString objModelPath;
525 
526  Ring* rings; // Planet rings
527  double distance; // Temporary variable used to store the distance to a given point
528  // it is used for sorting while drawing
529  float sphereScale; // Artificial scaling for better viewing.
530  double lastJDE; // caches JDE of last positional computation
531  // The callback for the calculation of the equatorial rect heliocentric position at time JDE.
532  posFuncType coordFunc;
533  void* orbitPtr; // this is always used with an Orbit object.
534 
535  OsculatingFunctType *const osculatingFunc;
536  QSharedPointer<Planet> parent; // Planet parent i.e. sun for earth
537  QList<QSharedPointer<Planet> > satellites; // satellites of the Planet
538  LinearFader hintFader;
539  LinearFader labelsFader; // Store the current state of the label for this planet
540  bool flagLabels; // Define whether labels should be displayed
541  bool hidden; // useful for fake planets used as observation positions - not drawn or labeled
542  bool atmosphere; // Does the planet have an atmosphere?
543  bool halo; // Does the planet have a halo?
544  PlanetType pType; // Type of body
545 
546  static ApparentMagnitudeAlgorithm vMagAlgorithm;
547 
548  QOpenGLFunctions* gl;
549 
550  static bool shaderError; // True if loading shaders caused errors
551 
552  static Vec3f labelColor;
553  static StelTextureSP hintCircleTex;
554  static QMap<PlanetType, QString> pTypeMap; // Maps fast type to english name.
555  static QMap<ApparentMagnitudeAlgorithm, QString> vMagAlgorithmMap;
556 
557  static bool flagCustomGrsSettings; // Is enabled usage of custom settings for calculation of position of Great Red Spot?
558  static double customGrsJD; // Initial JD for calculation of position of Great Red Spot
559  static int customGrsLongitude; // Longitude of Great Red Spot (System II, degrees)
560  static double customGrsDrift; // Annual drift of Great Red Spot position (degrees)
561 
562 private:
563  QString iauMoonNumber;
564 
565  // Shader-related variables
566  struct PlanetShaderVars {
567  // Vertex attributes
568  int texCoord;
569  int unprojectedVertex;
570  int vertex;
571  int normalIn;
572 
573  // Common uniforms
574  int projectionMatrix;
575  int tex;
576  int lightDirection;
577  int eyeDirection;
578  int diffuseLight;
579  int ambientLight;
580  int shadowCount;
581  int shadowData;
582  int sunInfo;
583  int skyBrightness;
584  int orenNayarParameters;
585  int outgasParameters;
586 
587  // Moon-specific variables
588  int earthShadow;
589  int normalMap;
590 
591  // Rings-specific variables
592  int isRing;
593  int ring;
594  int outerRadius;
595  int innerRadius;
596  int ringS;
597 
598  // Shadowmap variables
599  int shadowMatrix;
600  int shadowTex;
601  int poissonDisk;
602 
603  void initLocations(QOpenGLShaderProgram*);
604  };
605 
607  struct RenderData
608  {
609  Mat4d modelMatrix;
610  Mat4d mTarget;
611  QVector<const Planet*> shadowCandidates;
612  QMatrix4x4 shadowCandidatesData;
613  Vec3d eyePos;
614  };
615 
617  RenderData setCommonShaderUniforms(const StelPainter &painter, QOpenGLShaderProgram* shader, const PlanetShaderVars& shaderVars) const;
618 
619  static PlanetShaderVars planetShaderVars;
620  static QOpenGLShaderProgram* planetShaderProgram;
621 
622  static PlanetShaderVars ringPlanetShaderVars;
623  static QOpenGLShaderProgram* ringPlanetShaderProgram;
624 
625  static PlanetShaderVars moonShaderVars;
626  static QOpenGLShaderProgram* moonShaderProgram;
627 
628  static PlanetShaderVars objShaderVars;
629  static QOpenGLShaderProgram* objShaderProgram;
630 
631  static PlanetShaderVars objShadowShaderVars;
632  static QOpenGLShaderProgram* objShadowShaderProgram;
633 
634  static PlanetShaderVars transformShaderVars;
635  static QOpenGLShaderProgram* transformShaderProgram;
636 
637  static bool shadowInitialized;
638  static Vec2f shadowPolyOffset;
639 #ifdef DEBUG_SHADOWMAP
640  static QOpenGLFramebufferObject* shadowFBO;
641 #else
642  static unsigned int shadowFBO;
643 #endif
644  static unsigned int shadowTex;
645 
646 
647  static void initShader();
648  static void deinitShader();
649  static bool initFBO();
650  static void deinitFBO();
651 
652  static QOpenGLShaderProgram* createShader(const QString& name,
653  PlanetShaderVars& vars,
654  const QByteArray& vSrc,
655  const QByteArray& fSrc,
656  const QByteArray& prefix=QByteArray(),
657  const QMap<QByteArray,int>& fixedAttributeLocations=QMap<QByteArray,int>());
658 };
659 
660 #endif // _PLANET_HPP_
661 
double getAlbedo(void) const
Get albedo.
Definition: Planet.hpp:230
virtual void update(double deltaTime)
Update time-varying components.
StelOBJ * obj
The original StelOBJ data, deleted after loading to GL.
Definition: Planet.hpp:455
void setFlagOrbits(bool b)
Set flag which determines if planet orbits are drawn or hidden.
virtual double getSiderealPeriod(void) const
Get duration of sidereal year.
Definition: Planet.hpp:226
Encapsulates vertex data stored in the OpenGL server memory, which can be used for fast drawing comma...
Class used to translate strings to any language.
Implementation of StelFader which implements a linear transition.
Definition: StelFader.hpp:77
The base abstract class for sky objects used in Stellarium like Stars, Planets, Constellations etc...
Definition: StelObject.hpp:36
Define the StelTextureSP type.
Vec3f getNeptuneOrbitColor(void) const
Get the current color used to draw Neptune orbit line.
PlanetType
numeric typecodes for the type descriptions in ssystem.ini
Definition: Planet.hpp:99
Vec3f getSaturnOrbitColor(void) const
Get the current color used to draw Saturn orbit line.
void setEarthOrbitColor(const Vec3f &c)
Set the color used to draw Earth orbit line.
Main class for Stellarium core processing.
Definition: StelCore.hpp:48
StelTextureSP texture
The single texture to use.
Definition: Planet.hpp:453
void setFlagHints(bool b)
Set flag which determines if planet hints are drawn or hidden along labels.
bool needsRescale
True when the positions need to be rescaled before drawing.
Definition: Planet.hpp:445
void setFlagLabels(bool b)
Set flag which determines if planet labels are drawn or hidden.
Vec3f getUranusOrbitColor(void) const
Get the current color used to draw Uranus orbit line.
Vec3f getMercuryOrbitColor(void) const
Get the current color used to draw Mercury orbit line.
bool getFlagLabels() const
Get the current value of the flag which determines if planet labels are drawn or hidden.
double getRadius(void) const
Get the equator radius of the planet in AU.
Definition: Planet.hpp:219
StelOpenGLArray * arr
The opengl array, created by loadObjModel() but filled later in main thread.
Definition: Planet.hpp:457
void setVenusOrbitColor(const Vec3f &c)
Set the color used to draw Venus orbit line.
void setJupiterOrbitColor(const Vec3f &c)
Set the color used to draw Jupiter orbit line.
This StelObjectModule derivative is used to model SolarSystem bodies.
Definition: SolarSystem.hpp:47
Definition: Planet.hpp:72
void setNeptuneOrbitColor(const Vec3f &c)
Set the color used to draw Neptune orbit line.
double getSiderealDay(void) const
Get duration of sidereal day.
Definition: Planet.hpp:223
Vec3f getJupiterOrbitColor(void) const
Get the current color used to draw Jupiter orbit line.
Provides functions for performing openGL drawing operations.
Definition: StelPainter.hpp:40
QVector< Vec3f > scaledArray
Contains the scaled positions (sphere scale in AU), need StelProjector transformation for display...
Definition: Planet.hpp:447
virtual QString getID(void) const
Returns a unique identifier for this object.
Definition: Planet.hpp:195
QOpenGLBuffer * projPosBuffer
An OpenGL buffer for the projected positions.
Definition: Planet.hpp:451
virtual void init()
Initialize the SolarSystem.
Representation of a custom subset of a Wavefront .obj file, including only triangle data and material...
Definition: StelOBJ.hpp:37
Vec3f getVenusOrbitColor(void) const
Get the current color used to draw Venus orbit line.
void setMarsOrbitColor(const Vec3f &c)
Set the color used to draw Mars orbit line.
QSharedPointer< ModelViewTranform > ModelViewTranformP
Shared pointer on a ModelViewTranform instance (implement reference counting)
Vec3f getMarsOrbitColor(void) const
Get the current color used to draw Mars orbit line.
AABBox bbox
The BBox of the original model before any transformations.
Definition: Planet.hpp:441
double getOneMinusOblateness(void) const
Get the value (1-f) for oblateness f.
Definition: Planet.hpp:221
bool getFlagOrbits() const
Get the current value of the flag which determines if planet orbits are drawn or hidden.
A templatized 3d vector compatible with openGL.
Definition: VecMath.hpp:33
Define the StelProjectorP type.
void setSaturnOrbitColor(const Vec3f &c)
Set the color used to draw Saturn orbit line.
virtual QString getType(void) const
Return object&#39;s type. It should be the name of the class.
Definition: Planet.hpp:194
float getAbsoluteMagnitude() const
Return the absolute magnitude (read from file ssystem.ini)
Definition: Planet.hpp:242
QSharedPointer< StelTexture > StelTextureSP
Use shared pointer to simplify memory managment.
void setMercuryOrbitColor(const Vec3f &c)
Set the color used to draw Mercury orbit line.
bool getFlagHints() const
Get the current value of the flag which determines if planet hints are drawn or hidden along labels...
An axis-aligned bounding-box class.
Definition: GeomMath.hpp:31
QString getPlanetType(QString planetName) const
Get type for Solar system bodies from scripts.
QVector< Vec3f > posArray
Contains the original positions in model space in km, they need scaling and projection.
Definition: Planet.hpp:443
This header contains useful classes for common geometric operations that are useful for 3D rendering...
Vec3f getEarthOrbitColor(void) const
Get the current color used to draw Earth orbit line.
void setUranusOrbitColor(const Vec3f &c)
Set the color used to draw Uranus orbit line.
QVector< Vec3f > projectedPosArray
Used to store the projected array data, avoids re-allocation each frame.
Definition: Planet.hpp:449
virtual void draw(StelCore *core)
Draw SolarSystem objects (planets).