Meteor.hpp   Meteor.hpp 
/* /*
* Stellarium * Stellarium
* Copyright (C) 2004 Robert Spearman * Copyright (C) 2014-2015 Marcos Cardinot
* Copyright (C) 2014 Marcos Cardinot
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2 * as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version. * of the License, or (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
skipping to change at line 33 skipping to change at line 32
#include "StelTextureTypes.hpp" #include "StelTextureTypes.hpp"
#include "VecMath.hpp" #include "VecMath.hpp"
#include <QList> #include <QList>
#include <QPair> #include <QPair>
class StelCore; class StelCore;
class StelPainter; class StelPainter;
// all in km - altitudes make up meteor range #define EARTH_RADIUS 6378.f //! earth_radius in km
#define EARTH_RADIUS 6369.f #define EARTH_RADIUS2 40678884.f //! earth_radius^2 in km
#define HIGH_ALTITUDE 115.f #define MAX_ALTITUDE 120.f //! max meteor altitude in km
#define LOW_ALTITUDE 70.f #define MIN_ALTITUDE 80.f //! min meteor altitude in km
#define VISIBLE_RADIUS 457.8f
//! @class Meteor //! @class Meteor
//! Models a single meteor. //! Models a single meteor.
//! Control of the meteor rate is performed in the MeteorMgr class. Once //! Once created, a meteor object only lasts for some amount of time,
//! created, a meteor object only lasts for some amount of time, and then //! and then "dies", after which, the update() member returns false.
//! "dies", after which, the update() member returns false. //! @author Marcos Cardinot <mcardinot@gmail.com>
class Meteor class Meteor
{ {
public: public:
struct MeteorModel //! <colorName, intensity>
{ typedef QPair<QString, int> ColorPair;
Vec3d obs; //! observer position
Vec3d position; //! equatorial coordinate position
Vec3d posTrain; //! end of train
float xydistance; //! Distance in XY plane (orthogonal to me
teor path) from observer to meteor
float minDist; //! Nearest point to observer along path
float startH; //! Start height above center of earth
float endH; //! End height
float mag; //! Apparent magnitude at head, 0-1
int firstBrightSegment; //! First bright segment of the trai
n
};
//! Create a Meteor object. //! Create a Meteor object.
//! @param v the velocity of the meteor in km/s. Meteor(const StelCore* core, const StelTextureSP &bolideTexture);
Meteor(const StelCore*, float v);
virtual ~Meteor(); virtual ~Meteor();
//! Initialize meteor
void init(const float& radiantAlpha, const float& radiantDelta,
const float& speed, const QList<ColorPair> colors);
//! Updates the position of the meteor, and expires it if necessary. //! Updates the position of the meteor, and expires it if necessary.
//! @param deltaTime the time increment in seconds since the last ca ll.
//! @return true of the meteor is still alive, else false. //! @return true of the meteor is still alive, else false.
bool update(double deltaTime); virtual bool update(double deltaTime);
//! Draws the meteor. //! Draws the meteor.
void draw(const StelCore* core, StelPainter& sPainter); virtual void draw(const StelCore* core, StelPainter& sPainter);
//! Draws the meteor train. (useful to be reused in MeteorShowers pl //! Indicate if the meteor still visible.
ugin) bool isAlive() { return m_alive; }
static void drawTrain(const StelCore* core, StelPainter& sPainter, c //! Set meteor absolute magnitude.
onst MeteorModel& mm, void setAbsMag(float mag) { m_absMag = mag; }
const Mat4d& viewMatrix, const float thickness //! Get meteor absolute magnitude.
, const int segments, float absMag() { return m_absMag; }
QList<Vec4f> lineColorArray, QList<Vec4f> trai
nColorArray);
//! Draws the meteor bolide. (useful to be reused in MeteorShowers p
lugin)
static void drawBolide(const StelCore* core, StelPainter &sPainter,
const MeteorModel& mm,
const Mat4d& viewMatrix, const float bolideSi
ze);
//! Calculates the train thickness and bolide size. private:
static void calculateThickness(const StelCore* core, float &thicknes //! Determine color vectors of line and prism used to draw meteor tr
s, float &bolideSize); ain.
void buildColorVectors(const QList<ColorPair> colors);
//! <colorName, intensity> //! get RGB from color name
typedef QPair<QString, int> colorPair; Vec4f getColorFromName(QString colorName);
//! Updates parameters of meteor model. (useful to be reused in Mete //! Calculates the train thickness and bolide size.
orShowers plugin) void calculateThickness(const StelCore* core, float &thickness, floa
//! @return true of the meteor is still alive, else false. t &bolideSize);
static bool updateMeteorModel(double deltaTime, double speed, Meteor
Model &mm);
//! Builds Meteor Model //! Draws the meteor bolide.
//! @return true if alive, else false. void drawBolide(StelPainter &sPainter, const float &bolideSize);
static bool initMeteorModel(const StelCore *core, const int segments
,
const Mat4d viewMatrix, MeteorModel &mm)
;
//! Determine color arrays of line and prism used to draw meteor tra
in.
static void buildColorArrays(const int segments,
const QList<colorPair> colors,
QList<Vec4f> &lineColorArray,
QList<Vec4f> &trainColorArray);
static StelTextureSP bolideTexture; //! Draws the meteor train.
void drawTrain(StelPainter& sPainter, const float &thickness);
private: //! Calculates the z-component of a meteor as a function of meteor z
static void insertVertex(const StelCore* core, const Mat4d& viewMatr enith angle
ix, float meteorZ(float zenithAngle, float altitude);
QVector<Vec3d> &vertexArray, Vec3d vertex);
static Vec4f getColorFromName(QString colorName); //! find meteor position in horizontal coordinate system
QList<colorPair> getRandColor(); Vec3d radiantToAltAz(Vec3d position);
bool m_alive; //! Indicate if the meteor it still visible //! find meteor position in radiant coordinate system
Vec3d altAzToRadiant(Vec3d position);
float m_speed; //! Velocity of meteor in km/s
Mat4d m_viewMatrix; //! tranformation matrix to align radiant with const StelCore* m_core; //! The associated StelCore instance
earth direction of travel .
MeteorModel meteor; //! Parameters of meteor model
double m_distMultiplier; //! Scale magnitude due to changes in dist bool m_alive; //! Indicates if the meteor it still
ance visible.
float m_speed; //! Velocity of meteor in km/s.
QList<Vec4f> m_trainColorArray; Mat4d m_matAltAzToRadiant; //! Rotation matrix to convert from
QList<Vec4f> m_lineColorArray; horizontal to radiant coordinate system.
const int m_segments; //! Number of segments along the train (us Vec3d m_position; //! Meteor position in radiant coord
eful to curve along projection distortions) inate system.
Vec3d m_posTrain; //! End of train in radiant coordina
te system.
float m_initialZ; //! Initial z-component of the meteo
r in radiant coordinates.
float m_finalZ; //! Final z-compoenent of the meteor
in radiant coordinates.
float m_minDist; //! Shortest distance between meteor
and observer.
float m_absMag; //! Absolute magnitude [0, 1]
float m_aptMag; //! Apparent magnitude [0, 1]
StelTextureSP m_bolideTexture; //! Meteor bolide texture
const int m_segments; //! Number of segments along the tra
in (useful to curve along projection distortions)
QVector<Vec4f> m_trainColorVector;
QVector<Vec4f> m_lineColorVector;
}; };
#endif // _METEOR_HPP_ #endif // _METEOR_HPP_
 End of changes. 16 change blocks. 
87 lines changed or deleted 73 lines changed or added

This html diff was produced by rfcdiff 1.41. The latest version is available from http://tools.ietf.org/tools/rfcdiff/