Пример #1
0
// returns true if visible
// Assumes that we are in local frame
void MeteorStream::draw(const StelCore* core, StelPainter& sPainter)
{
	if(!alive)
		return;

	Vec3d spos = position;
	Vec3d epos = posTrain;

	// convert to equ
	spos.transfo4d(viewMatrix);
	epos.transfo4d(viewMatrix);

	// convert to local and correct for earth radius
	//[since equ and local coordinates in stellarium use same 0 point!]
	spos = core->j2000ToAltAz(spos);
	epos = core->j2000ToAltAz(epos);
	spos[2] -= EARTH_RADIUS;
	epos[2] -= EARTH_RADIUS;
	// 1216 is to scale down under 1 for desktop version
	spos/=1216;
	epos/=1216;

	// connect this point with last drawn point
	double tmag = mag*distMultiplier;

	QVector<Vec4f> colorArray;
	QVector<Vec3d> vertexArray;
	// last point - dark
	colorArray.push_back(Vec4f(0,0,0,0));
	vertexArray.push_back(epos);
	// compute intermediate points to curve along projection distortions
	int segments = 10;
	for (int i=1; i<segments; i++) {
		Vec3d posi = posInternal;
		posi[2] = posTrain[2] + i*(position[2] - posTrain[2])/segments;
		posi.transfo4d(viewMatrix);
		posi = core->j2000ToAltAz(posi);
		posi[2] -= EARTH_RADIUS;
		posi/=1216;

		colorArray.push_back(Vec4f(1,1,1,i*tmag/segments));
		vertexArray.push_back(posi);
	}
	// first point - light
	colorArray.push_back(Vec4f(1,1,1,tmag));
	vertexArray.push_back(spos);

	sPainter.setColorPointer(4, GL_FLOAT, colorArray.constData());
	sPainter.setVertexPointer(3, GL_DOUBLE, vertexArray.constData());
	sPainter.enableClientStates(true, false, true);
	sPainter.drawFromArray(StelPainter::LineStrip, vertexArray.size(), 0, true);
	sPainter.enableClientStates(false);
}
Пример #2
0
// returns true if visible
// Assumes that we are in local frame
void Meteor::draw(const StelCore* core, StelPainter& sPainter)
{
    if (!alive)
        return;

    const StelProjectorP proj = sPainter.getProjector();

    Vec3d spos = position;
    Vec3d epos = posTrain;

    // convert to equ
    spos.transfo4d(mmat);
    epos.transfo4d(mmat);

    // convert to local and correct for earth radius [since equ and local coordinates in stellarium use same 0 point!]
    spos = core->equinoxEquToAltAz( spos );
    epos = core->equinoxEquToAltAz( epos );
    spos[2] -= EARTH_RADIUS;
    epos[2] -= EARTH_RADIUS;
    // 1216 is to scale down under 1 for desktop version
    spos/=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]);

    if (train)
    {
        // connect this point with last drawn point
        double tmag = mag*distMultiplier;

        // compute an intermediate point so can curve slightly along projection distortions
        Vec3d posi = posInternal;
        posi[2] = position[2] + (posTrain[2] - position[2])/2;
        posi.transfo4d(mmat);
        posi = core->equinoxEquToAltAz( posi );
        posi[2] -= EARTH_RADIUS;
        posi/=1216;

        // draw dark to light
        Vec4f colorArray[3];
        colorArray[0].set(0,0,0,0);
        colorArray[1].set(1,1,1,tmag*0.5);
        colorArray[2].set(1,1,1,tmag);
        Vec3d vertexArray[3];
        vertexArray[0]=epos;
        vertexArray[1]=posi;
        vertexArray[2]=spos;
        sPainter.setColorPointer(4, GL_FLOAT, colorArray);
        sPainter.setVertexPointer(3, GL_DOUBLE, vertexArray);
        // TODO the crash doesn't appear when the last true is set to false
        sPainter.enableClientStates(true, false, true);
        sPainter.drawFromArray(StelPainter::LineStrip, 3, 0, true);
        sPainter.enableClientStates(false);
    }
    else
    {
        sPainter.setPointSize(1.f);
        Vec3d start;
        proj->project(spos, start);
        sPainter.drawPoint2d(start[0],start[1]);
    }

    train = 1;
}