00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef _PLANET_HPP_
00021 #define _PLANET_HPP_
00022
00023 #include <QString>
00024
00025 #include "StelObject.hpp"
00026 #include "VecMath.hpp"
00027 #include "StelFader.hpp"
00028 #include "StelTextureTypes.hpp"
00029 #include "StelProjectorType.hpp"
00030
00031
00032
00033 typedef void (*posFuncType)(double, double*, void*);
00034
00035 typedef void (OsulatingFunctType)(double jd0,double jd,double xyz[3]);
00036
00037
00038 #define J2000 2451545.0
00039 #define ORBIT_SEGMENTS 72
00040
00041 class StelFont;
00042 class StelPainter;
00043 class StelTranslator;
00044
00045 struct TrailPoint
00046 {
00047 Vec3d point;
00048 double date;
00049 };
00050
00051
00052
00053 class RotationElements
00054 {
00055 public:
00056 RotationElements(void) : period(1.), offset(0.), epoch(J2000), obliquity(0.), ascendingNode(0.), precessionRate(0.) {}
00057 float period;
00058 float offset;
00059 double epoch;
00060 float obliquity;
00061 float ascendingNode;
00062 float precessionRate;
00063 double siderealPeriod;
00064 };
00065
00066
00067 class Ring
00068 {
00069 public:
00070 Ring(double radiusMin,double radiusMax,const QString &texname);
00071 ~Ring(void);
00072 void draw(StelPainter* painter,const Mat4d& mat,double screenSz);
00073 double getSize(void) const {return radiusMax;}
00074 private:
00075 const double radiusMin;
00076 const double radiusMax;
00077 StelTextureSP tex;
00078 };
00079
00080
00081 class Planet : public StelObject
00082 {
00083 public:
00084 friend class SolarSystem;
00085 Planet(const QString& englishName,
00086 int flagLighting,
00087 double radius,
00088 double oblateness,
00089 Vec3f color,
00090 float albedo,
00091 const QString& texMapName,
00092 const QString& texHaloName,
00093 posFuncType _coordFunc,
00094 void* userDataPtr,
00095 OsulatingFunctType *osculatingFunc,
00096 bool closeOrbit,
00097 bool hidden,
00098 bool hasAtmosphere);
00099
00100 ~Planet();
00101
00103
00116 virtual QString getInfoString(const StelCore *core, const InfoStringGroup& flags) const;
00117 virtual double getCloseViewFov(const StelNavigator * nav) const;
00118 virtual double getSatellitesFov(const StelNavigator * nav) const;
00119 virtual double getParentSatellitesFov(const StelNavigator * nav) const;
00120 virtual float getVMagnitude(const StelNavigator * nav) const;
00121 virtual float getSelectPriority(const StelNavigator *nav) const;
00122 virtual Vec3f getInfoColor(void) const;
00123 virtual QString getType(void) const {return "Planet";}
00124 virtual Vec3d getJ2000EquatorialPos(const StelNavigator *nav) const;
00125 virtual QString getEnglishName(void) const {return englishName;}
00126 virtual QString getNameI18n(void) const {return nameI18;}
00127 virtual double getAngularSize(const StelCore* core) const;
00128 virtual bool hasAtmosphere(void) {return atmosphere;}
00129
00131
00133 void translateName(StelTranslator& trans);
00134
00135
00136 void draw(StelCore* core, float maxMagLabels, const QFont& planetNameFont);
00137
00139
00142 double getRadius(void) const {return radius;}
00143 double getSiderealDay(void) const {return re.period;}
00144
00145 const QString& getTextMapName() const {return texMapName;}
00146
00147
00148 double getSiderealTime(double jd) const;
00149 Mat4d getRotEquatorialToVsop87(void) const;
00150 void setRotEquatorialToVsop87(const Mat4d &m);
00151
00152 const RotationElements &getRotationElements(void) const {return re;}
00153
00154
00155 void computePositionWithoutOrbits(const double date);
00156 void computePosition(const double date);
00157
00158
00159 void computeTransMatrix(double date);
00160
00161
00162 double getPhase(const Vec3d& obsPos) const;
00163
00164 double getSpheroidAngularSize(const StelCore* core) const;
00165
00166
00167 void setRotationElements(float _period, float _offset, double _epoch,
00168 float _obliquity, float _ascendingNode, float _precessionRate, double _siderealPeriod);
00169 double getRotAscendingnode(void) const {return re.ascendingNode;}
00170 double getRotObliquity(void) const {return re.obliquity;}
00171
00173 Vec3d getEclipticPos() const;
00174
00175
00176 Vec3d getHeliocentricEclipticPos() const;
00177 void setHeliocentricEclipticPos(const Vec3d &pos);
00178
00179
00180 double computeDistance(const Vec3d& obsHelioPos);
00181 double getDistance(void) const {return distance;}
00182
00183 void setRings(Ring* r) {rings = r;}
00184
00185 void setSphereScale(float s) {sphereScale = s;}
00186 float getSphereScale(void) const {return sphereScale;}
00187
00188 const QSharedPointer<Planet> getParent(void) const {return parent;}
00189
00190 static void setLabelColor(const Vec3f& lc) {labelColor = lc;}
00191 static const Vec3f& getLabelColor(void) {return labelColor;}
00192
00193 void update(int deltaTime);
00194
00195 void setFlagHints(bool b){hintFader = b;}
00196 bool getFlagHints(void) const {return hintFader;}
00197
00198 void setFlagLabels(bool b){flagLabels = b;}
00199 bool getFlagLabels(void) const {return flagLabels;}
00200
00202
00204
00205 void setFlagOrbits(bool b){orbitFader = b;}
00206 bool getFlagOrbits(void) const {return orbitFader;}
00207 LinearFader orbitFader;
00208
00209 void drawOrbit(const StelCore*);
00210 Vec3d orbit[ORBIT_SEGMENTS+1];
00211 double lastOrbitJD;
00212 double deltaJD;
00213 double deltaOrbitJD;
00214 bool orbitCached;
00215 bool closeOrbit;
00216
00217
00218
00219 static Vec3f orbitColor;
00220 static void setOrbitColor(const Vec3f& oc) {orbitColor = oc;}
00221 static const Vec3f& getOrbitColor() {return orbitColor;}
00222
00223 protected:
00224 static StelTextureSP texEarthShadow;
00225
00226
00227 void drawEarthShadow(StelCore* core, StelPainter* sPainter);
00228
00229
00230 QString getSkyLabel(const StelNavigator * nav) const;
00231
00232
00233 void draw3dModel(StelCore* core, const Mat4d& mat, float screenSz);
00234
00235
00236 void drawSphere(StelPainter* painter, float screenSz);
00237
00238
00239 void drawHints(const StelCore* core, const QFont& planetNameFont);
00240
00241 QString englishName;
00242 QString nameI18;
00243 QString texMapName;
00244 int flagLighting;
00245 RotationElements re;
00246 double radius;
00247 double oneMinusOblateness;
00248 Vec3d eclipticPos;
00249
00250 Vec3d screenPos;
00251 Vec3d previousScreenPos;
00252 Vec3f color;
00253 float albedo;
00254 Mat4d rotLocalToParent;
00255 float axisRotation;
00256 StelTextureSP texMap;
00257 Ring* rings;
00258 double distance;
00259
00260 float sphereScale;
00261 double lastJD;
00262
00263 posFuncType coordFunc;
00264 void* userDataPtr;
00265
00266 OsulatingFunctType *const osculatingFunc;
00267 QSharedPointer<Planet> parent;
00268 QList<QSharedPointer<Planet> > satellites;
00269 LinearFader hintFader;
00270 LinearFader labelsFader;
00271 bool flagLabels;
00272 bool hidden;
00273 bool atmosphere;
00274
00275 static Vec3f labelColor;
00276 static StelTextureSP hintCircleTex;
00277 };
00278
00279 #endif // _PLANET_HPP_
00280