Meteor.hpp   Meteor.hpp 
/* /*
* Stellarium * Stellarium
* This file Copyright (C) 2004 Robert Spearman * Copyright (C) 2004 Robert Spearman
* 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.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA. * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA.
*/ */
#ifndef _METEOR_HPP_ #ifndef _METEOR_HPP_
#define _METEOR_HPP_ #define _METEOR_HPP_
#include "renderer/StelVertexAttribute.hpp" #include "StelTextureTypes.hpp"
#include "renderer/StelVertexBuffer.hpp"
#include "StelProjector.hpp"
#include "VecMath.hpp" #include "VecMath.hpp"
#include <QList>
#include <QPair>
class StelCore; class StelCore;
class StelPainter;
// all in km - altitudes make up meteor range // all in km - altitudes make up meteor range
#define EARTH_RADIUS 6369.f #define EARTH_RADIUS 6369.f
#define HIGH_ALTITUDE 115.f #define HIGH_ALTITUDE 115.f
#define LOW_ALTITUDE 70.f #define LOW_ALTITUDE 70.f
#define VISIBLE_RADIUS 457.8f #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 //! Control of the meteor rate is performed in the MeteorMgr class. Once
//! created, a meteor object only lasts for some amount of time, and then //! created, a meteor object only lasts for some amount of time, and then
//! "dies", after which, the update() member returns false. The live/dead //! "dies", after which, the update() member returns false.
//! status of a meteor may also be determined using the isAlive member.
class Meteor class Meteor
{ {
public: public:
struct MeteorModel
{
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. //! @param v the velocity of the meteor in km/s.
Meteor(const StelCore*, double v); Meteor(const StelCore*, float v);
virtual ~Meteor(); virtual ~Meteor();
//! Updates the position of the meteor, and expires it if necessary. //! Updates the position of the meteor, and expires it if necessary.
//! @return true of the meteor is still alive, else false. //! @return true of the meteor is still alive, else false.
bool update(double deltaTime); bool update(double deltaTime);
//! Draws the meteor. //! Draws the meteor.
void draw(const StelCore* core, StelProjectorP projector, class Stel void draw(const StelCore* core, StelPainter& sPainter);
Renderer* renderer);
//! Draws the meteor train. (useful to be reused in MeteorShowers pl
ugin)
static void drawTrain(const StelCore* core, StelPainter& sPainter, c
onst MeteorModel& mm,
const Mat4d& viewMatrix, const float thickness
, const int segments,
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.
static void calculateThickness(const StelCore* core, float &thicknes
s, float &bolideSize);
//! Determine if a meteor is alive or has burned out. //! <colorName, intensity>
typedef QPair<QString, int> colorPair;
//! Updates parameters of meteor model. (useful to be reused in Mete
orShowers plugin)
//! @return true of the meteor is still alive, else false.
static bool updateMeteorModel(double deltaTime, double speed, Meteor
Model &mm);
//! Builds Meteor Model
//! @return true if alive, else false. //! @return true if alive, else false.
bool isAlive(void); static bool initMeteorModel(const StelCore *core, const int segments
,
const Mat4d viewMatrix, MeteorModel &mm)
;
private: //! Determine color arrays of line and prism used to draw meteor tra
//! Vertex with a 3D position and a color. in.
struct Vertex static void buildColorArrays(const int segments,
{ const QList<colorPair> colors,
Vec3f position; QList<Vec4f> &lineColorArray,
Vec4f color; QList<Vec4f> &trainColorArray);
Vertex(const Vec3d& pos, const Vec4f& color)
: position(Vec3f(pos[0], pos[1], pos[2])), color(col
or) {}
VERTEX_ATTRIBUTES(Vec3f Position, Vec4f Color);
};
//! Vertex buffer used for drawing. static StelTextureSP bolideTexture;
StelVertexBuffer<Vertex>* vertexBuffer;
Mat4d mmat; // tranformation matrix to align radiant with earth dire private:
ction of travel static void insertVertex(const StelCore* core, const Mat4d& viewMatr
Vec3d obs; // observer position in meteor coord. system ix,
Vec3d position; // equatorial coordinate position QVector<Vec3d> &vertexArray, Vec3d vertex);
Vec3d posInternal; // middle of train static Vec4f getColorFromName(QString colorName);
Vec3d posTrain; // end of train QList<colorPair> getRandColor();
bool train; // point or train visible?
double startH; // start height above center of earth bool m_alive; //! Indicate if the meteor it still visible
double endH; // end height
double velocity; // km/s float m_speed; //! Velocity of meteor in km/s
bool alive; // is it still visible? Mat4d m_viewMatrix; //! tranformation matrix to align radiant with
float mag; // Apparent magnitude at head, 0-1 earth direction of travel
float maxMag; // 0-1 MeteorModel meteor; //! Parameters of meteor model
float absMag; // absolute magnitude double m_distMultiplier; //! Scale magnitude due to changes in dist
float visMag; // visual magnitude at observer ance
double xydistance; // distance in XY plane (orthogonal to meteor pat
h) from observer to meteor QList<Vec4f> m_trainColorArray;
double initDist; // initial distance from observer QList<Vec4f> m_lineColorArray;
double minDist; // nearest point to observer along path const int m_segments; //! Number of segments along the train (us
double distMultiplier; // scale magnitude due to changes in distanc eful to curve along projection distortions)
e
}; };
#endif // _METEOR_HPP_ #endif // _METEOR_HPP_
 End of changes. 13 change blocks. 
45 lines changed or deleted 87 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/