Stellarium 0.13.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 
37 class Comet : public Planet
38 {
39 public:
40  friend class SolarSystem; // Solar System initializes static constants.
41  Comet(const QString& englishName,
42  int flagLighting,
43  double radius,
44  double oblateness,
45  Vec3f color,
46  float albedo,
47  const QString& texMapName,
48  posFuncType _coordFunc,
49  void* userDataPtr,
50  OsculatingFunctType *osculatingFunc,
51  bool closeOrbit,
52  bool hidden,
53  const QString &pTypeStr,
54  float dustTailWidthFact=1.5f,
55  float dustTailLengthFact=0.4f,
56  float dustTailBrightnessFact=1.5f
57  );
58 
59  virtual ~Comet();
60 
61  //Inherited from StelObject via Planet
70  // - Size <- Size of what?
74  virtual QString getInfoString(const StelCore *core, const InfoStringGroup &flags) const;
75  //The Comet class inherits the "Planet" type because the SolarSystem class
76  //was not designed to handle different types of objects.
77  //virtual QString getType() const {return "Comet";}
79  virtual float getVMagnitude(const StelCore* core) const;
82  virtual void translateName(const StelTranslator& trans);
83  virtual QString getEnglishName(void) const {return englishName;}
84  virtual QString getNameI18n(void) const {return nameI18;}
85 
91  void setAbsoluteMagnitudeAndSlope(const double magnitude, const double slope);
92 
94  void setSemiMajorAxis(const double value);
95 
97  virtual double getSiderealPeriod() const;
98 
100  //virtual void computePosition(const double date);
101 
103  virtual void draw(StelCore* core, float maxMagLabels, const QFont& planetNameFont);
104 
105  // re-implementation of Planet's update() to prepare tails (extinction etc). @param deltaTime: ms (since last call)
106  // TODO: computePosition can be removed and things added here!
107  virtual void update(int deltaTime);
108 
109 private:
112  Vec2f getComaDiameterAndTailLengthAU();
113  void drawTail(StelCore* core, StelProjector::ModelViewTranformP transfo, bool gas);
114  void drawComa(StelCore* core, StelProjector::ModelViewTranformP transfo);
115 
118  void computeComa(const float diameter);
119 
130  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);
131 
132  double absoluteMagnitude;
133  double slopeParameter;
134  double semiMajorAxis;
135  bool isCometFragment;
136  bool nameIsProvisionalDesignation;
137 
138  //GZ Tail additions
139  Vec2f tailFactors; // result of latest call to getComaDiameterAndTailLengthAU(); Results cached here for infostring. [0]=Coma diameter, [1] gas tail length.
140  bool tailActive;
141  bool tailBright;
142  double deltaJDtail;
143  double lastJDtail;
144  Mat4d gasTailRot;
145  Mat4d dustTailRot;
146  float dustTailWidthFactor;
147  float dustTailLengthFactor;
148  float dustTailBrightnessFactor;
149  QVector<double> comaVertexArr;
150  QVector<float> comaTexCoordArr; // --> 2014-08: could also be declared static, but it is filled by StelPainter...
151 
152  // These are to avoid having index arrays for each comet when all are equal.
153  static bool createTailIndices;
154  static bool createTailTextureCoords;
155 
156  QVector<Vec3d> gastailVertexArr; // computed frequently, describes parabolic shape (along z axis) of gas tail.
157  QVector<Vec3d> dusttailVertexArr; // computed frequently, describes parabolic shape (along z axis) of dust tail.
158  QVector<Vec3f> gastailColorArr; // NEW computed for every 5 mins, modulates gas tail brightness for extinction
159  QVector<Vec3f> dusttailColorArr; // NEW computed for every 5 mins, modulates dust tail brightness for extinction
160  static QVector<float> tailTexCoordArr; // computed only once for all comets!
161  static QVector<unsigned short> tailIndices; // computed only once for all comets!
162  static StelTextureSP comaTexture;
163  static StelTextureSP tailTexture; // it seems not really necessary to have different textures. gas tail is just painted blue.
164 };
165 
166 #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's name in english.
Definition: Comet.hpp:83
virtual void draw(StelCore *core, float maxMagLabels, const QFont &planetNameFont)
GZ: override from Planet: extend with tail details.
Main class for Stellarium core processing.
Definition: StelCore.hpp:46
This StelObjectModule derivative is used to model SolarSystem bodies.
Definition: SolarSystem.hpp:46
A templatized column-major 4x4 matrix compatible with openGL.
Definition: VecMath.hpp:33
Definition: Comet.hpp:37
void setAbsoluteMagnitudeAndSlope(const double magnitude, const double slope)
sets absolute magnitude and slope parameter.
virtual QString getNameI18n(void) const
Return translated object's name.
Definition: Comet.hpp:84
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