Meteor.cpp   Meteor.cpp 
skipping to change at line 31 skipping to change at line 31
// Could use a simple ablation physics model in the future // Could use a simple ablation physics model in the future
/* /*
NOTE: Here the radiant is always along the ecliptic at the apex of the Eart h's way. NOTE: Here the radiant is always along the ecliptic at the apex of the Eart h's way.
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 <cstdlib> #include <cstdlib>
#include "Meteor.hpp" #include "Meteor.hpp"
#include "StelCore.hpp" #include "StelCore.hpp"
#include "StelNavigator.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)
{ {
skipping to change at line 201 skipping to change at line 202
if( dist == 0 ) dist = .01; // just to be cautious (meteor hits observer !) if( dist == 0 ) dist = .01; // just to be cautious (meteor hits observer !)
distMultiplier = minDist*minDist / (dist*dist); distMultiplier = minDist*minDist / (dist*dist);
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
bool Meteor::draw(const StelCore* core, const StelPainter& sPainter) void Meteor::draw(const StelCore* core, StelPainter& sPainter)
{ {
if (!alive) if (!alive)
return(0); return;
const StelNavigator* nav = core->getNavigator(); 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 = nav->equinoxEquToAltAz( spos );
epos = nav->equinoxEquToAltAz( epos ); epos = nav->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
Vec3d start, end; spos/=1216;
int t1 = proj->projectCheck(spos/1216, start); // 1216 is to scale epos/=1216;
down under 1 for desktop version
int t2 = proj->projectCheck(epos/1216, end);
// don't draw if not visible (but may come into view)
if( t1 + t2 == 0 ) return 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]); // 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 = nav->equinoxEquToAltAz( posi );
posi[2] -= EARTH_RADIUS; posi[2] -= EARTH_RADIUS;
Vec3d intpos; posi/=1216;
proj->project(posi/1216, intpos);
// draw dark to light // draw dark to light
glBegin(GL_LINE_STRIP); Vec4f colorArray[3];
glColor4f(0,0,0,0); colorArray[0].set(0,0,0,0);
glVertex3f(end[0],end[1],0); colorArray[1].set(1,1,1,tmag*0.5);
glColor4f(1,1,1,tmag/2); colorArray[2].set(1,1,1,tmag);
glVertex3f(intpos[0],intpos[1],0); Vec3d vertexArray[3];
glColor4f(1,1,1,tmag); vertexArray[0]=epos;
glVertex3f(start[0],start[1],0); vertexArray[1]=posi;
glEnd(); vertexArray[2]=spos;
} else { sPainter.setColorPointer(4, GL_FLOAT, colorArray);
glPointSize(1); sPainter.setVertexPointer(3, GL_DOUBLE, vertexArray);
sPainter.drawPoint2d(start[0],start[1]); // TODO the crash doesn't appear when the last true is set t
o false
sPainter.enableClientStates(true, false, true);
sPainter.drawFromArray(StelPainter::LineStrip, 3, 0, true);
sPainter.enableClientStates(false);
} }
else
/* {
// TEMP - show radiant sPainter.setPointSize(1.f);
Vec3d radiant = Vec3d(0,0,0.5f); Vec3d start;
radiant.transfo4d(mmat); proj->project(spos, start);
if( projection->project_earth_equ(radiant, start) ) { sPainter.drawPoint2d(start[0],start[1]);
glColor3f(1,0,1);
glBegin(GL_LINES);
glVertex3f(start[0]-10,start[1],0);
glVertex3f(start[0]+10,start[1],0);
glEnd();
glBegin(GL_LINES);
glVertex3f(start[0],start[1]-10,0);
glVertex3f(start[0],start[1]+10,0);
glEnd();
} }
*/
train = 1; train = 1;
return(1);
} }
bool Meteor::isAlive(void) bool Meteor::isAlive(void)
{ {
return(alive); return(alive);
} }
 End of changes. 11 change blocks. 
44 lines changed or deleted 30 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/