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 "StelToneReproducer.hpp"
00027 #include "VecMath.hpp"
00028 #include "callbacks.hpp"
00029 #include "StelFader.hpp"
00030 #include "StelTranslator.hpp"
00031 #include "StelTextureTypes.hpp"
00032 #include "StelProjectorType.hpp"
00033
00034
00035 typedef boost::callback<void, double, double*> posFuncType;
00036
00037 typedef void (OsulatingFunctType)(double jd0,double jd,double xyz[3]);
00038
00039
00040 #define J2000 2451545.0
00041 #define ORBIT_SEGMENTS 72
00042
00043 class StelFont;
00044 class StelPainter;
00045
00046 struct TrailPoint
00047 {
00048 Vec3d point;
00049 double date;
00050 };
00051
00052
00053
00054 class RotationElements
00055 {
00056 public:
00057 RotationElements(void) : period(1.), offset(0.), epoch(J2000), obliquity(0.), ascendingNode(0.), precessionRate(0.) {}
00058 float period;
00059 float offset;
00060 double epoch;
00061 float obliquity;
00062 float ascendingNode;
00063 float precessionRate;
00064 double siderealPeriod;
00065 };
00066
00067
00068 class Ring
00069 {
00070 public:
00071 Ring(double radiusMin,double radiusMax,const QString &texname);
00072 ~Ring(void);
00073 void draw(const StelPainter* painter,const Mat4d& mat,double screenSz);
00074 double getSize(void) const {return radiusMax;}
00075 private:
00076 const double radiusMin;
00077 const double radiusMax;
00078 StelTextureSP tex;
00079 };
00080
00081
00082 class Planet : public StelObject
00083 {
00084 public:
00085 friend class SolarSystem;
00086 Planet(const QString& englishName,
00087 int flagLighting,
00088 double radius,
00089 double oblateness,
00090 Vec3f color,
00091 float albedo,
00092 const QString& texMapName,
00093 const QString& texHaloName,
00094 posFuncType _coordFunc,
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) {nameI18 = trans.qtranslate(englishName);}
00134
00135
00136 void draw(StelCore* core, float maxMagLabels);
00137
00139
00141 void setParent(Planet* parent);
00142
00145 double getRadius(void) const {return radius;}
00146 double getSiderealDay(void) const {return re.period;}
00147
00148 const QString& getTextMapName() const {return texMapName;}
00149
00150
00151 double getSiderealTime(double jd) const;
00152 Mat4d getRotEquatorialToVsop87(void) const;
00153 void setRotEquatorialToVsop87(const Mat4d &m);
00154
00155 const RotationElements &getRotationElements(void) const {return re;}
00156
00157
00158 void computePositionWithoutOrbits(const double date);
00159 void computePosition(const double date);
00160
00161
00162 void computeTransMatrix(double date);
00163
00164
00165 double getPhase(Vec3d obsPos) const;
00166
00167 double getSpheroidAngularSize(const StelCore* core) const;
00168
00169
00170 void setRotationElements(float _period, float _offset, double _epoch,
00171 float _obliquity, float _ascendingNode, float _precessionRate, double _siderealPeriod);
00172 double getRotAscendingnode(void) const {return re.ascendingNode;}
00173 double getRotObliquity(void) const {return re.obliquity;}
00174
00176 Vec3d getEclipticPos() const;
00177
00178
00179 Vec3d getHeliocentricEclipticPos() const;
00180 void setHeliocentricEclipticPos(const Vec3d &pos);
00181
00182
00183 double computeDistance(const Vec3d& obsHelioPos);
00184 double getDistance(void) const {return distance;}
00185
00186 void setRings(Ring* r) {rings = r;}
00187
00188 void setSphereScale(float s) {sphereScale = s;}
00189 float getSphereScale(void) const {return sphereScale;}
00190
00191 const Planet* getParent(void) const {return parent;}
00192
00193 static void setFont(StelFont* f) {planetNameFont = f;}
00194
00195 static void setLabelColor(const Vec3f& lc) {labelColor = lc;}
00196 static const Vec3f& getLabelColor(void) {return labelColor;}
00197
00198 void update(int deltaTime);
00199
00200 void setFlagHints(bool b){hintFader = b;}
00201 bool getFlagHints(void) const {return hintFader;}
00202
00203 void setFlagLabels(bool b){flagLabels = b;}
00204 bool getFlagLabels(void) const {return flagLabels;}
00205
00207
00208
00210
00211 void updateTrail(const StelNavigator* nav);
00212 void drawTrail(const StelCore* core);
00214 void startTrail(bool b);
00215 void setFlagTrail(bool b){if(b == trailFader) return; trailFader = b; startTrail(b);}
00216 bool getFlagTrail(void) const {return trailFader;}
00217 static void setTrailColor(const Vec3f& c) { trailColor = c; }
00218 static const Vec3f& getTrailColor() { return trailColor; }
00219 static Vec3f trailColor;
00220 std::list<TrailPoint>trail;
00221 bool trailOn;
00222 double DeltaTrail;
00223 int MaxTrail;
00224 double lastTrailJD;
00225 bool firstPoint;
00226 LinearFader trailFader;
00227
00229
00230 void setFlagOrbits(bool b){orbitFader = b;}
00231 bool getFlagOrbits(void) const {return orbitFader;}
00232 LinearFader orbitFader;
00233
00234 void drawOrbit(const StelCore*);
00235 Vec3d orbit[ORBIT_SEGMENTS];
00236 double lastOrbitJD;
00237 double deltaJD;
00238 double deltaOrbitJD;
00239 bool orbitCached;
00240 bool closeOrbit;
00241
00242
00243
00244 static Vec3f orbitColor;
00245 static void setOrbitColor(const Vec3f& oc) {orbitColor = oc;}
00246 static const Vec3f& getOrbitColor() {return orbitColor;}
00247
00248 protected:
00249 static StelTextureSP texEarthShadow;
00250
00251
00252 void drawEarthShadow(StelCore* core);
00253
00254
00255 QString getSkyLabel(const StelNavigator * nav) const;
00256
00257
00258 void draw3dModel(StelCore* core, const Mat4d& mat, float screenSz);
00259
00260
00261 void drawSphere(const StelPainter* painter, float screenSz);
00262
00263
00264 void drawHints(const StelCore* core);
00265
00266 QString englishName;
00267 QString nameI18;
00268 QString texMapName;
00269 int flagLighting;
00270 RotationElements re;
00271 double radius;
00272 double oneMinusOblateness;
00273 Vec3d eclipticPos;
00274
00275 Vec3d screenPos;
00276 Vec3d previousScreenPos;
00277 Vec3f color;
00278 float albedo;
00279 Mat4d rotLocalToParent;
00280 float axisRotation;
00281 StelTextureSP texMap;
00282 Ring* rings;
00283 double distance;
00284
00285 float sphereScale;
00286 double lastJD;
00287
00288 posFuncType coordFunc;
00289 OsulatingFunctType *const osculatingFunc;
00290 const Planet *parent;
00291 QList<Planet*> satellites;
00292 LinearFader hintFader;
00293 LinearFader labelsFader;
00294 bool flagLabels;
00295 bool hidden;
00296 bool atmosphere;
00297
00298 static StelFont* planetNameFont;
00299 static Vec3f labelColor;
00300 static StelTextureSP hintCircleTex;
00301 };
00302
00303 #endif // _PLANET_HPP_
00304