Meteor.cpp   Meteor.cpp 
skipping to change at line 35 skipping to change at line 35
In reality, individual meteor streams have varying velocity vectors and the refore radiants In reality, individual meteor streams have varying velocity vectors and the refore radiants
which are generally not at the apex of the Earth's way, such as the Perseid s shower. which are generally not at the apex of the Earth's way, such as the Perseid s shower.
*/ */
// Improved realism and efficiency 2004-12 // Improved realism and efficiency 2004-12
#include <QtOpenGL> #include <QtOpenGL>
#include <cstdlib> #include <cstdlib>
#include "Meteor.hpp" #include "Meteor.hpp"
#include "StelCore.hpp" #include "StelCore.hpp"
#include "StelNavigator.hpp"
#include "StelToneReproducer.hpp" #include "StelToneReproducer.hpp"
#include "StelMovementMgr.hpp" #include "StelMovementMgr.hpp"
#include "StelPainter.hpp" #include "StelPainter.hpp"
Meteor::Meteor(const StelCore* core, double v) Meteor::Meteor(const StelCore* core, double v)
{ {
const StelNavigator* nav = core->getNavigator();
const StelToneReproducer* eye = core->getToneReproducer(); const StelToneReproducer* eye = core->getToneReproducer();
// velocity = 11+(double)rand()/((double)RAND_MAX+1)*v; // abs range 11 -72 km/s // velocity = 11+(double)rand()/((double)RAND_MAX+1)*v; // abs range 11 -72 km/s
velocity=v; velocity=v;
maxMag = 1; maxMag = 1;
// determine meteor model view matrix (want z in dir of travel of earth, z=0 at center of earth) // determine meteor model view matrix (want z in dir of travel of earth, z=0 at center of earth)
// meteor life is so short, no need to recalculate // meteor life is so short, no need to recalculate
double equ_rotation; // rotation needed to align with path of earth double equ_rotation; // rotation needed to align with path of earth
Vec3d sun_dir = nav->heliocentricEclipticToEquinoxEqu( Vec3d(0,0,0) ); Vec3d sun_dir = core->heliocentricEclipticToEquinoxEqu( Vec3d(0,0,0) );
Mat4d tmat = Mat4d::xrotation(-23.45f*M_PI/180.f); // ecliptical tilt Mat4d tmat = Mat4d::xrotation(-23.45f*M_PI/180.f); // ecliptical tilt
sun_dir.transfo4d(tmat); // convert to ecliptical coordinates sun_dir.transfo4d(tmat); // convert to ecliptical coordinates
sun_dir.normalize(); sun_dir.normalize();
equ_rotation = acos( sun_dir.dot( Vec3d(1,0,0) ) ); equ_rotation = acos( sun_dir.dot( Vec3d(1,0,0) ) );
if( sun_dir[1] < 0 ) equ_rotation = 2*M_PI - equ_rotation; if( sun_dir[1] < 0 ) equ_rotation = 2*M_PI - equ_rotation;
equ_rotation -= M_PI_2; equ_rotation -= M_PI_2;
mmat = Mat4d::xrotation(23.45f*M_PI/180.f) * Mat4d::zrotation(equ_rotatio n) * Mat4d::yrotation(M_PI_2); mmat = Mat4d::xrotation(23.45f*M_PI/180.f) * Mat4d::zrotation(equ_rotatio n) * Mat4d::yrotation(M_PI_2);
// select random trajectory using polar coordinates in XY plane, centered on observer // select random trajectory using polar coordinates in XY plane, centered on observer
xydistance = (double)rand()/((double)RAND_MAX+1)*(VISIBLE_RADIUS); xydistance = (double)rand()/((double)RAND_MAX+1)*(VISIBLE_RADIUS);
double angle = (double)rand()/((double)RAND_MAX+1)*2*M_PI; double angle = (double)rand()/((double)RAND_MAX+1)*2*M_PI;
// find observer position in meteor coordinate system // find observer position in meteor coordinate system
obs = nav->altAzToEquinoxEqu(Vec3d(0,0,EARTH_RADIUS)); obs = core->altAzToEquinoxEqu(Vec3d(0,0,EARTH_RADIUS));
obs.transfo4d(mmat.transpose()); obs.transfo4d(mmat.transpose());
// set meteor start x,y // set meteor start x,y
posInternal[0] = posTrain[0] = position[0] = xydistance*cos(angle) +obs[0 ]; posInternal[0] = posTrain[0] = position[0] = xydistance*cos(angle) +obs[0 ];
posInternal[1] = posTrain[1] = position[1] = xydistance*sin(angle) +obs[1 ]; posInternal[1] = posTrain[1] = position[1] = xydistance*sin(angle) +obs[1 ];
// determine life of meteor (start and end z value based on atmosphere bu rn altitudes) // determine life of meteor (start and end z value based on atmosphere bu rn altitudes)
// D is distance from center of earth // D is distance from center of earth
double D = sqrt( position[0]*position[0] + position[1]*position[1] ); double D = sqrt( position[0]*position[0] + position[1]*position[1] );
skipping to change at line 207 skipping to change at line 206
return(alive); return(alive);
} }
// returns true if visible // returns true if visible
// Assumes that we are in local frame // Assumes that we are in local frame
void Meteor::draw(const StelCore* core, StelPainter& sPainter) void Meteor::draw(const StelCore* core, StelPainter& sPainter)
{ {
if (!alive) if (!alive)
return; return;
const StelNavigator* nav = core->getNavigator();
const StelProjectorP proj = sPainter.getProjector(); const StelProjectorP proj = sPainter.getProjector();
Vec3d spos = position; Vec3d spos = position;
Vec3d epos = posTrain; Vec3d epos = posTrain;
// convert to equ // convert to equ
spos.transfo4d(mmat); spos.transfo4d(mmat);
epos.transfo4d(mmat); epos.transfo4d(mmat);
// convert to local and correct for earth radius [since equ and loca l coordinates in stellarium use same 0 point!] // convert to local and correct for earth radius [since equ and loca l coordinates in stellarium use same 0 point!]
spos = nav->equinoxEquToAltAz( spos ); spos = core->equinoxEquToAltAz( spos );
epos = nav->equinoxEquToAltAz( epos ); epos = core->equinoxEquToAltAz( epos );
spos[2] -= EARTH_RADIUS; spos[2] -= EARTH_RADIUS;
epos[2] -= EARTH_RADIUS; epos[2] -= EARTH_RADIUS;
// 1216 is to scale down under 1 for desktop version // 1216 is to scale down under 1 for desktop version
spos/=1216; spos/=1216;
epos/=1216; epos/=1216;
// qDebug("[%f %f %f] (%d, %d) (%d, %d)\n", position[0], position[1 ], position[2], (int)start[0], (int)start[1], (int)end[0], (int)end[1]); // qDebug("[%f %f %f] (%d, %d) (%d, %d)\n", position[0], position[1 ], position[2], (int)start[0], (int)start[1], (int)end[0], (int)end[1]);
if (train) if (train)
{ {
// connect this point with last drawn point // connect this point with last drawn point
double tmag = mag*distMultiplier; double tmag = mag*distMultiplier;
// compute an intermediate point so can curve slightly along projection distortions // compute an intermediate point so can curve slightly along projection distortions
Vec3d posi = posInternal; Vec3d posi = posInternal;
posi[2] = position[2] + (posTrain[2] - position[2])/2; posi[2] = position[2] + (posTrain[2] - position[2])/2;
posi.transfo4d(mmat); posi.transfo4d(mmat);
posi = nav->equinoxEquToAltAz( posi ); posi = core->equinoxEquToAltAz( posi );
posi[2] -= EARTH_RADIUS; posi[2] -= EARTH_RADIUS;
posi/=1216; posi/=1216;
// draw dark to light // draw dark to light
Vec4f colorArray[3]; Vec4f colorArray[3];
colorArray[0].set(0,0,0,0); colorArray[0].set(0,0,0,0);
colorArray[1].set(1,1,1,tmag*0.5); colorArray[1].set(1,1,1,tmag*0.5);
colorArray[2].set(1,1,1,tmag); colorArray[2].set(1,1,1,tmag);
Vec3d vertexArray[3]; Vec3d vertexArray[3];
vertexArray[0]=epos; vertexArray[0]=epos;
 End of changes. 7 change blocks. 
8 lines changed or deleted 6 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/