Stellarium 0.15.2
Meteor.hpp
1 /*
2  * Stellarium
3  * Copyright (C) 2014-2015 Marcos Cardinot
4  *
5  * This program is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU General Public License
7  * as published by the Free Software Foundation; either version 2
8  * of the License, or (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA.
18  */
19 
20 #ifndef _METEOR_HPP_
21 #define _METEOR_HPP_
22 
23 #include "StelTextureTypes.hpp"
24 #include "VecMath.hpp"
25 
26 #include <QList>
27 #include <QPair>
28 
29 class StelCore;
30 class StelPainter;
31 
32 #define EARTH_RADIUS 6378.f
33 #define EARTH_RADIUS2 40678884.f
34 #define MAX_ALTITUDE 120.f
35 #define MIN_ALTITUDE 80.f
36 
37 class Meteor
43 {
44 public:
46  typedef QPair<QString, int> ColorPair;
47 
49  Meteor(const StelCore* core, const StelTextureSP &bolideTexture);
50  virtual ~Meteor();
51 
53  void init(const float& radiantAlpha, const float& radiantDelta,
54  const float& speed, const QList<ColorPair> colors);
55 
59  virtual bool update(double deltaTime);
60 
62  virtual void draw(const StelCore* core, StelPainter& sPainter);
63 
65  bool isAlive() { return m_alive; }
67  void setAbsMag(float mag) { m_absMag = mag; }
69  float absMag() { return m_absMag; }
70 
71 private:
73  void buildColorVectors(const QList<ColorPair> colors);
74 
76  Vec4f getColorFromName(QString colorName);
77 
79  void calculateThickness(const StelCore* core, float &thickness, float &bolideSize);
80 
82  void drawBolide(StelPainter &sPainter, const float &bolideSize);
83 
85  void drawTrain(StelPainter& sPainter, const float &thickness);
86 
88  float meteorZ(float zenithAngle, float altitude);
89 
91  Vec3d radiantToAltAz(Vec3d position);
92 
94  Vec3d altAzToRadiant(Vec3d position);
95 
96  const StelCore* m_core;
97 
98  bool m_alive;
99  float m_speed;
100  Mat4d m_matAltAzToRadiant;
101  Vec3d m_position;
102  Vec3d m_posTrain;
103  float m_initialZ;
104  float m_finalZ;
105  float m_minDist;
106  float m_absMag;
107  float m_aptMag;
108 
109  StelTextureSP m_bolideTexture;
110  const int m_segments;
111  QVector<Vec4f> m_trainColorVector;
112  QVector<Vec4f> m_lineColorVector;
113 };
114 
115 #endif // _METEOR_HPP_
Meteor(const StelCore *core, const StelTextureSP &bolideTexture)
Create a Meteor object.
Define the StelTextureSP type.
Main class for Stellarium core processing.
Definition: StelCore.hpp:48
virtual void draw(const StelCore *core, StelPainter &sPainter)
Draws the meteor.
void setAbsMag(float mag)
Set meteor absolute magnitude.
Definition: Meteor.hpp:67
Provides functions for performing openGL drawing operations.
Definition: StelPainter.hpp:40
virtual bool update(double deltaTime)
Updates the position of the meteor, and expires it if necessary.
bool isAlive()
Indicate if the meteor still visible.
Definition: Meteor.hpp:65
float absMag()
Get meteor absolute magnitude.
Definition: Meteor.hpp:69
QPair< QString, int > ColorPair
<colorName, intensity>
Definition: Meteor.hpp:46
void init(const float &radiantAlpha, const float &radiantDelta, const float &speed, const QList< ColorPair > colors)
Initialize meteor.
QSharedPointer< StelTexture > StelTextureSP
Use shared pointer to simplify memory managment.
Models a single meteor.
Definition: Meteor.hpp:42