23 #include "StelObject.hpp" 24 #include "StelProjector.hpp" 25 #include "VecMath.hpp" 27 #include "StelFader.hpp" 35 typedef void (*posFuncType)(double,
double*,
void*);
37 typedef void (OsculatingFunctType)(
double jde0,
double jde,
double xyz[3]);
40 #define J2000 2451545.0 41 #define ORBIT_SEGMENTS 360 50 class QOpenGLFunctions;
51 class QOpenGLShaderProgram;
53 #ifdef DEBUG_SHADOWMAP 54 class QOpenGLFramebufferObject;
61 RotationElements(
void) : period(1.), offset(0.), epoch(J2000), obliquity(0.), ascendingNode(0.), precessionRate(0.), siderealPeriod(0.) {}
68 double siderealPeriod;
75 Ring(
float radiusMin,
float radiusMax,
const QString &texname);
76 double getSize(
void)
const {
return radiusMax;}
77 const float radiusMin;
78 const float radiusMax;
86 static const QString PLANET_TYPE;
90 Q_ENUMS(PlanetOrbitColorStyle)
91 Q_ENUMS(ApparentMagnitudeAlgorithm)
118 enum PlanetOrbitColorStyle
125 enum ApparentMagnitudeAlgorithm
136 Planet(
const QString& englishName,
142 const QString& texMapName,
143 const QString& normalMapName,
144 const QString& objModelName,
145 posFuncType _coordFunc,
147 OsculatingFunctType *osculatingFunc,
152 const QString &pTypeStr);
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;}
213 virtual void draw(
StelCore* core,
float maxMagLabels,
const QFont& planetNameFont);
228 double getMeanSolarDay(
void)
const;
232 const QString& getTextMapName()
const {
return texMapName;}
233 const QString getPlanetTypeString()
const {
return pTypeMap.value(pType);}
236 void setNativeName(QString planet) { nativeName = planet; }
239 void setIAUMoonNumber(QString designation);
245 float getMeanOppositionMagnitude()
const;
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; }
255 double getSiderealTime(
double JD,
double JDE)
const;
256 Mat4d getRotEquatorialToVsop87(
void)
const;
257 void setRotEquatorialToVsop87(
const Mat4d &m);
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;}
267 double getRotObliquity(
double JDE)
const;
272 void computePositionWithoutOrbits(
const double dateJDE);
273 virtual void computePosition(
const double dateJDE);
277 void computeTransMatrix(
double JD,
double JDE);
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;
289 Vec3d getEclipticPos()
const;
292 Vec3d getHeliocentricEclipticPos()
const {
return getHeliocentricPos(eclipticPos);}
296 void setHeliocentricEclipticPos(
const Vec3d &pos);
299 double computeDistance(
const Vec3d& obsHelioPos);
300 double getDistance(
void)
const {
return distance;}
302 void setRings(
Ring* r) {rings = r;}
304 void setSphereScale(
float s) {
if(s!=sphereScale) { sphereScale = s;
if(objModel) objModel->needsRescale=
true; } }
306 const QSharedPointer<Planet> getParent(
void)
const {
return parent;}
308 static void setLabelColor(
const Vec3f& lc) {labelColor = lc;}
309 static const Vec3f& getLabelColor(
void) {
return labelColor;}
312 virtual void update(
int deltaTime);
321 void setFlagNativeName(
bool b) { flagNativeName = b; }
322 bool getFlagNativeName(
void) {
return flagNativeName; }
324 bool flagTranslatedName;
325 void setFlagTranslatedName(
bool b) { flagTranslatedName = b; }
326 bool getFlagTranslatedName(
void) {
return flagTranslatedName; }
337 Vec3d orbit[ORBIT_SEGMENTS+1];
338 Vec3d orbitP[ORBIT_SEGMENTS+1];
341 double deltaOrbitJDE;
347 static Vec3f orbitColor;
348 static void setOrbitColor(
const Vec3f& oc) {orbitColor = oc;}
349 static const Vec3f& getOrbitColor() {
return orbitColor;}
351 static Vec3f orbitMajorPlanetsColor;
352 static void setMajorPlanetOrbitColor(
const Vec3f& oc) { orbitMajorPlanetsColor = oc;}
353 static const Vec3f& getMajorPlanetOrbitColor() {
return orbitMajorPlanetsColor;}
355 static Vec3f orbitMoonsColor;
356 static void setMoonOrbitColor(
const Vec3f& oc) { orbitMoonsColor = oc;}
357 static const Vec3f& getMoonOrbitColor() {
return orbitMoonsColor;}
359 static Vec3f orbitMinorPlanetsColor;
360 static void setMinorPlanetOrbitColor(
const Vec3f& oc) { orbitMinorPlanetsColor = oc;}
361 static const Vec3f& getMinorPlanetOrbitColor() {
return orbitMinorPlanetsColor;}
363 static Vec3f orbitDwarfPlanetsColor;
364 static void setDwarfPlanetOrbitColor(
const Vec3f& oc) { orbitDwarfPlanetsColor = oc;}
365 static const Vec3f& getDwarfPlanetOrbitColor() {
return orbitDwarfPlanetsColor;}
367 static Vec3f orbitCubewanosColor;
368 static void setCubewanoOrbitColor(
const Vec3f& oc) { orbitCubewanosColor = oc;}
369 static const Vec3f& getCubewanoOrbitColor() {
return orbitCubewanosColor;}
371 static Vec3f orbitPlutinosColor;
372 static void setPlutinoOrbitColor(
const Vec3f& oc) { orbitPlutinosColor = oc;}
373 static const Vec3f& getPlutinoOrbitColor() {
return orbitPlutinosColor;}
375 static Vec3f orbitScatteredDiscObjectsColor;
376 static void setScatteredDiscObjectOrbitColor(
const Vec3f& oc) { orbitScatteredDiscObjectsColor = oc;}
377 static const Vec3f& getScatteredDiscObjectOrbitColor() {
return orbitScatteredDiscObjectsColor;}
379 static Vec3f orbitOortCloudObjectsColor;
380 static void setOortCloudObjectOrbitColor(
const Vec3f& oc) { orbitOortCloudObjectsColor = oc;}
381 static const Vec3f& getOortCloudObjectOrbitColor() {
return orbitOortCloudObjectsColor;}
383 static Vec3f orbitCometsColor;
384 static void setCometOrbitColor(
const Vec3f& oc) { orbitCometsColor = oc;}
385 static const Vec3f& getCometOrbitColor() {
return orbitCometsColor;}
387 static Vec3f orbitSednoidsColor;
388 static void setSednoidOrbitColor(
const Vec3f& oc) { orbitSednoidsColor = oc;}
389 static const Vec3f& getSednoidOrbitColor() {
return orbitSednoidsColor;}
391 static Vec3f orbitMercuryColor;
395 static Vec3f orbitVenusColor;
399 static Vec3f orbitEarthColor;
403 static Vec3f orbitMarsColor;
407 static Vec3f orbitJupiterColor;
411 static Vec3f orbitSaturnColor;
415 static Vec3f orbitUranusColor;
419 static Vec3f orbitNeptuneColor;
423 static bool permanentDrawingOrbits;
424 static PlanetOrbitColorStyle orbitColorStyle;
427 QVector<const Planet*> getCandidatesForShadow()
const;
438 void performScaling(
double scale);
463 void computeModelMatrix(
Mat4d &result)
const;
465 Vec3f getCurrentOrbitColor()
const;
468 QString getSkyLabel(
const StelCore* core)
const;
475 bool drawObjModel(
StelPainter* painter,
float screenSz);
477 bool drawObjShadowMap(
StelPainter* painter, QMatrix4x4 &shadowMatrix);
481 bool ensureObjLoaded();
484 void drawSphere(
StelPainter* painter,
float screenSz,
bool drawOnlyRing=
false);
487 void drawHints(
const StelCore* core,
const QFont& planetNameFont);
495 QString normalMapName;
499 double oneMinusOblateness;
506 float absoluteMagnitude;
510 float outgas_intensity;
512 float outgas_falloff;
514 Mat4d rotLocalToParent;
524 QString objModelPath;
532 posFuncType coordFunc;
535 OsculatingFunctType *
const osculatingFunc;
536 QSharedPointer<Planet> parent;
537 QList<QSharedPointer<Planet> > satellites;
546 static ApparentMagnitudeAlgorithm vMagAlgorithm;
548 QOpenGLFunctions* gl;
550 static bool shaderError;
552 static Vec3f labelColor;
554 static QMap<PlanetType, QString> pTypeMap;
555 static QMap<ApparentMagnitudeAlgorithm, QString> vMagAlgorithmMap;
557 static bool flagCustomGrsSettings;
558 static double customGrsJD;
559 static int customGrsLongitude;
560 static double customGrsDrift;
563 QString iauMoonNumber;
566 struct PlanetShaderVars {
569 int unprojectedVertex;
574 int projectionMatrix;
584 int orenNayarParameters;
585 int outgasParameters;
603 void initLocations(QOpenGLShaderProgram*);
611 QVector<const Planet*> shadowCandidates;
612 QMatrix4x4 shadowCandidatesData;
617 RenderData setCommonShaderUniforms(
const StelPainter &painter, QOpenGLShaderProgram* shader,
const PlanetShaderVars& shaderVars)
const;
619 static PlanetShaderVars planetShaderVars;
620 static QOpenGLShaderProgram* planetShaderProgram;
622 static PlanetShaderVars ringPlanetShaderVars;
623 static QOpenGLShaderProgram* ringPlanetShaderProgram;
625 static PlanetShaderVars moonShaderVars;
626 static QOpenGLShaderProgram* moonShaderProgram;
628 static PlanetShaderVars objShaderVars;
629 static QOpenGLShaderProgram* objShaderProgram;
631 static PlanetShaderVars objShadowShaderVars;
632 static QOpenGLShaderProgram* objShadowShaderProgram;
634 static PlanetShaderVars transformShaderVars;
635 static QOpenGLShaderProgram* transformShaderProgram;
637 static bool shadowInitialized;
638 static Vec2f shadowPolyOffset;
639 #ifdef DEBUG_SHADOWMAP 640 static QOpenGLFramebufferObject* shadowFBO;
642 static unsigned int shadowFBO;
644 static unsigned int shadowTex;
647 static void initShader();
648 static void deinitShader();
649 static bool initFBO();
650 static void deinitFBO();
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>());
660 #endif // _PLANET_HPP_ double getAlbedo(void) const
Get albedo.
virtual void update(double deltaTime)
Update time-varying components.
StelOBJ * obj
The original StelOBJ data, deleted after loading to GL.
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.
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.
The base abstract class for sky objects used in Stellarium like Stars, Planets, Constellations etc...
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
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.
StelTextureSP texture
The single texture to use.
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.
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.
StelOpenGLArray * arr
The opengl array, created by loadObjModel() but filled later in main thread.
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.
void setNeptuneOrbitColor(const Vec3f &c)
Set the color used to draw Neptune orbit line.
double getSiderealDay(void) const
Get duration of sidereal day.
Vec3f getJupiterOrbitColor(void) const
Get the current color used to draw Jupiter orbit line.
Provides functions for performing openGL drawing operations.
QVector< Vec3f > scaledArray
Contains the scaled positions (sphere scale in AU), need StelProjector transformation for display...
virtual QString getID(void) const
Returns a unique identifier for this object.
QOpenGLBuffer * projPosBuffer
An OpenGL buffer for the projected positions.
virtual void init()
Initialize the SolarSystem.
Representation of a custom subset of a Wavefront .obj file, including only triangle data and material...
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.
double getOneMinusOblateness(void) const
Get the value (1-f) for oblateness f.
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.
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's type. It should be the name of the class.
float getAbsoluteMagnitude() const
Return the absolute magnitude (read from file ssystem.ini)
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.
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.
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.
virtual void draw(StelCore *core)
Draw SolarSystem objects (planets).