Stellarium 0.14.3
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 halocolor,
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 draw(StelCore* core, float maxMagLabels, const QFont& planetNameFont);
101 
102  // re-implementation of Planet's update() to prepare tails (extinction etc). @param deltaTime: ms (since last call)
103  virtual void update(int deltaTime);
104 
105 private:
108  Vec2f getComaDiameterAndTailLengthAU();
109  void drawTail(StelCore* core, StelProjector::ModelViewTranformP transfo, bool gas);
110  void drawComa(StelCore* core, StelProjector::ModelViewTranformP transfo);
111 
114  void computeComa(const float diameter);
115 
126  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);
127 
128  double absoluteMagnitude;
129  double slopeParameter;
130  double semiMajorAxis;
131  bool isCometFragment;
132  bool nameIsProvisionalDesignation;
133 
134  //GZ Tail additions
135  Vec2f tailFactors; // result of latest call to getComaDiameterAndTailLengthAU(); Results cached here for infostring. [0]=Coma diameter, [1] gas tail length.
136  bool tailActive;
137  bool tailBright;
138  double deltaJDEtail;
139  double lastJDEtail;
140  Mat4d gasTailRot;
141  Mat4d dustTailRot;
142  float dustTailWidthFactor;
143  float dustTailLengthFactor;
144  float dustTailBrightnessFactor;
145  QVector<double> comaVertexArr;
146  QVector<float> comaTexCoordArr; // --> 2014-08: could also be declared static, but it is filled by StelPainter...
147 
148  // These are to avoid having index arrays for each comet when all are equal.
149  static bool createTailIndices;
150  static bool createTailTextureCoords;
151 
152  QVector<Vec3d> gastailVertexArr; // computed frequently, describes parabolic shape (along z axis) of gas tail.
153  QVector<Vec3d> dusttailVertexArr; // computed frequently, describes parabolic shape (along z axis) of dust tail.
154  QVector<Vec3f> gastailColorArr; // NEW computed for every 5 mins, modulates gas tail brightness for extinction
155  QVector<Vec3f> dusttailColorArr; // NEW computed for every 5 mins, modulates dust tail brightness for extinction
156  static QVector<float> tailTexCoordArr; // computed only once for all comets!
157  static QVector<unsigned short> tailIndices; // computed only once for all comets!
158  static StelTextureSP comaTexture;
159  static StelTextureSP tailTexture; // it seems not really necessary to have different textures. gas tail is just painted blue.
160 };
161 
162 #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)
re-implementation of Planet's draw()
A templatized 2d vector compatible with openGL.
Definition: VecMath.hpp:32
Main class for Stellarium core processing.
Definition: StelCore.hpp:48
This StelObjectModule derivative is used to model SolarSystem bodies.
Definition: SolarSystem.hpp:46
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