Stellarium 0.13.1
Meteor.hpp
1 /*
2  * Stellarium
3  * Copyright (C) 2004 Robert Spearman
4  * Copyright (C) 2014 Marcos Cardinot
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 _METEOR_HPP_
22 #define _METEOR_HPP_
23 
24 #include "StelTextureTypes.hpp"
25 #include "VecMath.hpp"
26 
27 #include <QList>
28 #include <QPair>
29 
30 class StelCore;
31 class StelPainter;
32 
33 // all in km - altitudes make up meteor range
34 #define EARTH_RADIUS 6369.f
35 #define HIGH_ALTITUDE 115.f
36 #define LOW_ALTITUDE 70.f
37 #define VISIBLE_RADIUS 457.8f
38 
44 class Meteor
45 {
46 public:
47  struct MeteorModel
48  {
49  Vec3d obs;
52  float xydistance;
53  float minDist;
54  float startH;
55  float endH;
56  float mag;
58  };
59 
62  Meteor(const StelCore*, float v);
63  virtual ~Meteor();
64 
67  bool update(double deltaTime);
68 
70  void draw(const StelCore* core, StelPainter& sPainter);
71 
73  static void drawTrain(const StelCore* core, StelPainter& sPainter, const MeteorModel& mm,
74  const Mat4d& viewMatrix, const float thickness, const int segments,
75  QList<Vec4f> lineColorArray, QList<Vec4f> trainColorArray);
76 
78  static void drawBolide(const StelCore* core, StelPainter &sPainter, const MeteorModel& mm,
79  const Mat4d& viewMatrix, const float bolideSize);
80 
82  static void calculateThickness(const StelCore* core, float &thickness, float &bolideSize);
83 
85  typedef QPair<QString, int> colorPair;
86 
89  static bool updateMeteorModel(double deltaTime, double speed, MeteorModel &mm);
90 
93  static bool initMeteorModel(const StelCore *core, const int segments,
94  const Mat4d viewMatrix, MeteorModel &mm);
95 
97  static void buildColorArrays(const int segments,
98  const QList<colorPair> colors,
99  QList<Vec4f> &lineColorArray,
100  QList<Vec4f> &trainColorArray);
101 
102  static StelTextureSP bolideTexture;
103 
104 private:
105  static void insertVertex(const StelCore* core, const Mat4d& viewMatrix,
106  QVector<Vec3d> &vertexArray, Vec3d vertex);
107  static Vec4f getColorFromName(QString colorName);
108  QList<colorPair> getRandColor();
109 
110  bool m_alive;
111 
112  float m_speed;
113  Mat4d m_viewMatrix;
114  MeteorModel meteor;
115  double m_distMultiplier;
116 
117  QList<Vec4f> m_trainColorArray;
118  QList<Vec4f> m_lineColorArray;
119  const int m_segments;
120 };
121 
122 
123 #endif // _METEOR_HPP_
Meteor(const StelCore *, float v)
Create a Meteor object.
static void buildColorArrays(const int segments, const QList< colorPair > colors, QList< Vec4f > &lineColorArray, QList< Vec4f > &trainColorArray)
Determine color arrays of line and prism used to draw meteor train.
Define the StelTextureSP type.
Main class for Stellarium core processing.
Definition: StelCore.hpp:46
int firstBrightSegment
Apparent magnitude at head, 0-1.
Definition: Meteor.hpp:57
static void drawTrain(const StelCore *core, StelPainter &sPainter, const MeteorModel &mm, const Mat4d &viewMatrix, const float thickness, const int segments, QList< Vec4f > lineColorArray, QList< Vec4f > trainColorArray)
Draws the meteor train. (useful to be reused in MeteorShowers plugin)
void draw(const StelCore *core, StelPainter &sPainter)
Draws the meteor.
float startH
Nearest point to observer along path.
Definition: Meteor.hpp:54
QPair< QString, int > colorPair
Definition: Meteor.hpp:85
Vec3d position
observer position
Definition: Meteor.hpp:50
Provides functions for performing openGL drawing operations.
Definition: StelPainter.hpp:40
bool update(double deltaTime)
Updates the position of the meteor, and expires it if necessary.
static void calculateThickness(const StelCore *core, float &thickness, float &bolideSize)
Calculates the train thickness and bolide size.
static bool initMeteorModel(const StelCore *core, const int segments, const Mat4d viewMatrix, MeteorModel &mm)
Builds Meteor Model.
float xydistance
end of train
Definition: Meteor.hpp:52
static void drawBolide(const StelCore *core, StelPainter &sPainter, const MeteorModel &mm, const Mat4d &viewMatrix, const float bolideSize)
Draws the meteor bolide. (useful to be reused in MeteorShowers plugin)
float mag
End height.
Definition: Meteor.hpp:56
QSharedPointer< StelTexture > StelTextureSP
Use shared pointer to simplify memory managment.
Vec3d posTrain
equatorial coordinate position
Definition: Meteor.hpp:51
Models a single meteor.
Definition: Meteor.hpp:44
float endH
Start height above center of earth.
Definition: Meteor.hpp:55
float minDist
Distance in XY plane (orthogonal to meteor path) from observer to meteor.
Definition: Meteor.hpp:53
static bool updateMeteorModel(double deltaTime, double speed, MeteorModel &mm)
Updates parameters of meteor model.