Stellarium 0.15.2
Comet.hpp
1 /*
2  * Stellarium
3  * Copyright (C) 2010 Bogdan Marinov
4  * Copyright (C) 2014 Georg Zotti (orbit fix, tails, speedup)
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License
8  * as published by the Free Software Foundation; either version 2
9  * of the License, or (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA.
19  */
20 
21 #ifndef _COMET_HPP_
22 #define _COMET_HPP_
23 
24 #include "Planet.hpp"
25 
38 class Comet : public Planet
39 {
40 public:
41  friend class SolarSystem; // Solar System initializes static constants.
42  Comet(const QString& englishName,
43  int flagLighting,
44  double radius,
45  double oblateness,
46  Vec3f halocolor,
47  float albedo,
48  const QString& texMapName,
49  posFuncType _coordFunc,
50  void* userDataPtr,
51  OsculatingFunctType *osculatingFunc,
52  bool closeOrbit,
53  bool hidden,
54  const QString &pTypeStr,
55  float dustTailWidthFact=1.5f,
56  float dustTailLengthFact=0.4f,
57  float dustTailBrightnessFact=1.5f
58  );
59 
60  virtual ~Comet();
61 
62  //Inherited from StelObject via Planet
71  // - Size <- Size of what?
75  virtual QString getInfoString(const StelCore *core, const InfoStringGroup &flags) const;
80  virtual QVariantMap getInfoMap(const StelCore *core) const;
81  //The Comet class inherits the "Planet" type because the SolarSystem class
82  //was not designed to handle different types of objects.
83  //virtual QString getType() const {return "Comet";}
85  virtual float getVMagnitude(const StelCore* core) const;
88  virtual void translateName(const StelTranslator& trans);
89  virtual QString getEnglishName(void) const {return englishName;}
90  virtual QString getNameI18n(void) const {return nameI18;}
91 
97  void setAbsoluteMagnitudeAndSlope(const double magnitude, const double slope);
98 
100  void setSemiMajorAxis(const double value);
101 
103  virtual double getSiderealPeriod() const;
104 
106  virtual void draw(StelCore* core, float maxMagLabels, const QFont& planetNameFont);
107 
108  // re-implementation of Planet's update() to prepare tails (extinction etc). @param deltaTime: ms (since last call)
109  virtual void update(int deltaTime);
110 
111 private:
114  Vec2f getComaDiameterAndTailLengthAU();
115  void drawTail(StelCore* core, StelProjector::ModelViewTranformP transfo, bool gas);
116  void drawComa(StelCore* core, StelProjector::ModelViewTranformP transfo);
117 
120  void computeComa(const float diameter);
121 
132  void computeParabola(const float parameter, const float topradius, const float zshift, QVector<Vec3d>& vertexArr, QVector<float>& texCoordArr, QVector<unsigned short>& indices, const float xOffset=0.0f);
133 
134  double absoluteMagnitude;
135  double slopeParameter;
136  double semiMajorAxis;
137  bool isCometFragment;
138  bool nameIsProvisionalDesignation;
139 
140  //GZ Tail additions
141  Vec2f tailFactors; // result of latest call to getComaDiameterAndTailLengthAU(); Results cached here for infostring. [0]=Coma diameter, [1] gas tail length.
142  bool tailActive;
143  bool tailBright;
144  double deltaJDEtail;
145  double lastJDEtail;
146  Mat4d gasTailRot;
147  Mat4d dustTailRot;
148  float dustTailWidthFactor;
149  float dustTailLengthFactor;
150  float dustTailBrightnessFactor;
151  QVector<double> comaVertexArr;
152  QVector<float> comaTexCoordArr; // --> 2014-08: could also be declared static, but it is filled by StelPainter...
153 
154  // These are to avoid having index arrays for each comet when all are equal.
155  static bool createTailIndices;
156  static bool createTailTextureCoords;
157 
158  QVector<Vec3d> gastailVertexArr; // computed frequently, describes parabolic shape (along z axis) of gas tail.
159  QVector<Vec3d> dusttailVertexArr; // computed frequently, describes parabolic shape (along z axis) of dust tail.
160  QVector<Vec3f> gastailColorArr; // NEW computed for every 5 mins, modulates gas tail brightness for extinction
161  QVector<Vec3f> dusttailColorArr; // NEW computed for every 5 mins, modulates dust tail brightness for extinction
162  static QVector<float> tailTexCoordArr; // computed only once for all comets!
163  static QVector<unsigned short> tailIndices; // computed only once for all comets!
164  static StelTextureSP comaTexture;
165  static StelTextureSP tailTexture; // it seems not really necessary to have different textures. gas tail is just painted blue.
166 };
167 
168 #endif //_COMET_HPP_
virtual void update(double deltaTime)
Update time-varying components.
virtual float getVMagnitude(const StelCore *core) const
Class used to translate strings to any language.
virtual QString getInfoString(const StelCore *core, const InfoStringGroup &flags) const
Get a string with data about the Comet.
virtual QString getEnglishName(void) const
Return object&#39;s name in english.
Definition: Comet.hpp:89
virtual void draw(StelCore *core, float maxMagLabels, const QFont &planetNameFont)
re-implementation of Planet&#39;s draw()
Main class for Stellarium core processing.
Definition: StelCore.hpp:48
This StelObjectModule derivative is used to model SolarSystem bodies.
Definition: SolarSystem.hpp:47
Definition: Comet.hpp:38
virtual QVariantMap getInfoMap(const StelCore *core) const
In addition to Planet::getInfoMap(), Comets provides estimates for.
void setAbsoluteMagnitudeAndSlope(const double magnitude, const double slope)
sets absolute magnitude and slope parameter.
virtual QString getNameI18n(void) const
Return translated object&#39;s name.
Definition: Comet.hpp:90
virtual void translateName(const StelTranslator &trans)
sets the nameI18 property with the appropriate translation.
virtual double getSiderealPeriod() const
get sidereal period for comet, days, or returns 0 if not possible (paraboloid, hyperboloid orbit) ...
QSharedPointer< ModelViewTranform > ModelViewTranformP
Shared pointer on a ModelViewTranform instance (implement reference counting)
QSharedPointer< StelTexture > StelTextureSP
Use shared pointer to simplify memory managment.
void setSemiMajorAxis(const double value)
set value for semi-major axis in AU