Comet.cpp   Comet.cpp 
skipping to change at line 45 skipping to change at line 45
#include "StelModuleMgr.hpp" #include "StelModuleMgr.hpp"
#include "LandscapeMgr.hpp" #include "LandscapeMgr.hpp"
#include <QRegExp> #include <QRegExp>
#include <QDebug> #include <QDebug>
// for compute tail shape // for compute tail shape
#define COMET_TAIL_SLICES 16 // segments around the perimeter #define COMET_TAIL_SLICES 16 // segments around the perimeter
#define COMET_TAIL_STACKS 16 // cuts along the rotational axis #define COMET_TAIL_STACKS 16 // cuts along the rotational axis
// These are to avoid having index arrays for each comet when all are equal
.
bool Comet::createTailIndices=true;
bool Comet::createTailTextureCoords=true;
StelTextureSP Comet::comaTexture;
StelTextureSP Comet::tailTexture;
QVector<float> Comet::tailTexCoordArr; // computed only once for all Comets
.
QVector<unsigned short> Comet::tailIndices; // computed only once for all C
omets.
Comet::Comet(const QString& englishName, Comet::Comet(const QString& englishName,
int flagLighting, int flagLighting,
double radius, double radius,
double oblateness, double oblateness,
Vec3f color, Vec3f color,
float albedo, float albedo,
const QString& atexMapName, const QString& atexMapName,
posFuncType coordFunc, posFuncType coordFunc,
void* auserDataPtr, void* auserDataPtr,
OsculatingFunctType *osculatingFunc, OsculatingFunctType *osculatingFunc,
bool acloseOrbit, bool acloseOrbit,
bool hidden, bool hidden,
const QString& pTypeStr, const QString& pTypeStr,
float dustTailWidthFact, float dustTailLengthFact, float du float dustTailWidthFact,
stTailBrightnessFact) float dustTailLengthFact,
float dustTailBrightnessFact)
: Planet (englishName, : Planet (englishName,
flagLighting, flagLighting,
radius, radius,
oblateness, oblateness,
color, color,
albedo, albedo,
atexMapName, atexMapName,
"", "",
coordFunc, coordFunc,
auserDataPtr, auserDataPtr,
skipping to change at line 93 skipping to change at line 103
deltaJD = StelCore::JD_SECOND; deltaJD = StelCore::JD_SECOND;
deltaJDtail=15.0*StelCore::JD_MINUTE; // update tail geometry every 15 minutes only deltaJDtail=15.0*StelCore::JD_MINUTE; // update tail geometry every 15 minutes only
lastJDtail=0.0; lastJDtail=0.0;
orbitCached = 0; orbitCached = 0;
closeOrbit = acloseOrbit; closeOrbit = acloseOrbit;
eclipticPos=Vec3d(0.,0.,0.); eclipticPos=Vec3d(0.,0.,0.);
rotLocalToParent = Mat4d::identity(); rotLocalToParent = Mat4d::identity();
texMap = StelApp::getInstance().getTextureManager().createTextureThr ead(StelFileMgr::getInstallationDir()+"/textures/"+texMapName, StelTexture: :StelTextureParams(true, GL_LINEAR, GL_REPEAT)); texMap = StelApp::getInstance().getTextureManager().createTextureThr ead(StelFileMgr::getInstallationDir()+"/textures/"+texMapName, StelTexture: :StelTextureParams(true, GL_LINEAR, GL_REPEAT));
tailFactors[0]=-1.0f; tailFactors[1]=-1.0f; // mark "invalid"
gastailVertexArr.clear(); gastailVertexArr.clear();
dusttailVertexArr.clear(); dusttailVertexArr.clear();
comaVertexArr.clear(); comaVertexArr.clear();
gastailColorArr.clear(); gastailColorArr.clear();
dusttailColorArr.clear(); dusttailColorArr.clear();
//Comet specific members //Comet specific members
absoluteMagnitude = 0; absoluteMagnitude = 0;
slopeParameter = -1;//== uninitialized: used in getVMagnitude() slopeParameter = -1;//== uninitialized: used in getVMagnitude()
skipping to change at line 156 skipping to change at line 167
oss << getNameI18n(); // UI translation can differ from sky translation oss << getNameI18n(); // UI translation can differ from sky translation
oss.setRealNumberNotation(QTextStream::FixedNotation); oss.setRealNumberNotation(QTextStream::FixedNotation);
oss.setRealNumberPrecision(1); oss.setRealNumberPrecision(1);
if (sphereScale != 1.f) if (sphereScale != 1.f)
oss << QString::fromUtf8(" (\xC3\x97") << sphereScal e << ")"; oss << QString::fromUtf8(" (\xC3\x97") << sphereScal e << ")";
oss << "</h2>"; oss << "</h2>";
} }
if (flags&ObjectType && getPlanetType()!=isUNDEFINED) if (flags&ObjectType && getPlanetType()!=isUNDEFINED)
{ {
oss << q_("Type: <b>%1</b>").arg(q_(getPlanetTypeString())) QString cometType = qc_("non-periodic", "type of comet");
<< "<br />"; if (semiMajorAxis>0.0)
{
// Parabolic and hyperbolic comets doesn't have semi
-major axis of the orbit. We have comet with elliptic orbit.
cometType = qc_("periodic", "type of comet");
}
oss << q_("Type: <b>%1</b> (%2)").arg(q_(getPlanetTypeString
())).arg(cometType) << "<br />";
} }
if (flags&Magnitude) if (flags&Magnitude)
{ {
if (core->getSkyDrawer()->getFlagHasAtmosphere()) if (core->getSkyDrawer()->getFlagHasAtmosphere())
oss << q_("Magnitude: <b>%1</b> (extincted to: <b>%2</b>)"). arg(QString::number(getVMagnitude(core), 'f', 2), oss << q_("Magnitude: <b>%1</b> (extincted to: <b>%2</b>)"). arg(QString::number(getVMagnitude(core), 'f', 2),
QString::number(getVMagnitudeWithExtinction(core), 'f', 2)) << "<br>"; QString::number(getVMagnitudeWithExtinction(core), 'f', 2)) << "<br>";
else else
oss << q_("Magnitude: <b>%1</b>").arg(getVMagnitude(core), 0 , 'f', 2) << "<br>"; oss << q_("Magnitude: <b>%1</b>").arg(getVMagnitude(core), 0 , 'f', 2) << "<br>";
} }
skipping to change at line 219 skipping to change at line 236
{ {
// xgettext:no-c-format // xgettext:no-c-format
oss << QString(q_("Distance: %1AU (%2 Mio km)")) oss << QString(q_("Distance: %1AU (%2 Mio km)"))
.arg(distanceAu, 0, 'f', 3) .arg(distanceAu, 0, 'f', 3)
.arg(distanceKm / 1.0e6, 0, 'f', 3); .arg(distanceKm / 1.0e6, 0, 'f', 3);
} }
oss << "<br>"; oss << "<br>";
} }
if (flags&Extra) if (flags&Extra)
{ {
// If semi-major axis not zero then calculate and display or
bital period for comet in days
double siderealPeriod = getSiderealPeriod();
if (siderealPeriod>0)
{
// TRANSLATORS: Sidereal (orbital) period for comets
in Julian years (symbol: a)
oss << q_("Sidereal period: %1 a").arg(QString::numb
er(siderealPeriod/365.25, 'f', 3)) << "<br>";
}
// GZ: Add speed. I don't know where else to place that bit of information. // GZ: Add speed. I don't know where else to place that bit of information.
// xgettext:no-c-format // xgettext:no-c-format
oss << QString(q_("Speed: %1 km/s")) oss << QString(q_("Speed: %1 km/s"))
.arg(((CometOrbit*)userDataPtr)->getVelocity().le ngth()*AU/86400.0, 0, 'f', 3); .arg(((CometOrbit*)userDataPtr)->getVelocity().le ngth()*AU/86400.0, 0, 'f', 3);
oss << "<br>"; oss << "<br>";
} }
if (flags&Size) if ((flags&Size) && (tailFactors[0]>0.0f))
{ {
// GZ: Add estimates for coma diameter and tail length. // GZ: Add estimates for coma diameter and tail length.
// xgettext:no-c-format // xgettext:no-c-format
oss << QString(q_("Coma diameter (estimate): %1 km")) oss << QString(q_("Coma diameter (estimate): %1 km"))
.arg(floor(tailFactors[0]*AU/1000.0f)*1000.0f, 0, 'f', 0); .arg(floor(tailFactors[0]*AU/1000.0f)*1000.0f, 0, 'f', 0);
oss << "<br>"; oss << "<br>";
// xgettext:no-c-format // xgettext:no-c-format
oss << QString(q_("Gas tail length (estimate): %1 Mio km")) oss << QString(q_("Gas tail length (estimate): %1 Mio km"))
.arg(tailFactors[1]*AU*1e-6, 0, 'G', 3); .arg(tailFactors[1]*AU*1e-6, 0, 'G', 3);
oss << "<br>"; oss << "<br>";
} }
// If semi-major axis not zero then calculate and display orbital pe
riod for comet in days
double siderealPeriod = getSiderealPeriod();
if ((flags&Extra) && (siderealPeriod>0))
{
// TRANSLATORS: Sidereal (orbital) period for solar system b
odies in days and in Julian years (symbol: a)
oss << q_("Sidereal period: %1 days (%2 a)").arg(QString::nu
mber(siderealPeriod, 'f', 2)).arg(QString::number(siderealPeriod/365.25, 'f
', 3)) << "<br>";
}
postProcessInfoString(str, flags); postProcessInfoString(str, flags);
return str; return str;
} }
void Comet::setSemiMajorAxis(const double value) void Comet::setSemiMajorAxis(const double value)
{ {
semiMajorAxis = value; semiMajorAxis = value;
} }
skipping to change at line 537 skipping to change at line 555
if (gas) { if (gas) {
sPainter->setArrays((Vec3d*)gastailVertexArr.constData(), (V ec2f*)tailTexCoordArr.constData(), (Vec3f*)gastailColorArr.constData()); sPainter->setArrays((Vec3d*)gastailVertexArr.constData(), (V ec2f*)tailTexCoordArr.constData(), (Vec3f*)gastailColorArr.constData());
sPainter->drawFromArray(StelPainter::Triangles, tailIndices. size(), 0, true, tailIndices.constData()); sPainter->drawFromArray(StelPainter::Triangles, tailIndices. size(), 0, true, tailIndices.constData());
} else { } else {
sPainter->setArrays((Vec3d*)dusttailVertexArr.constData(), ( Vec2f*)tailTexCoordArr.constData(), (Vec3f*)dusttailColorArr.constData()); sPainter->setArrays((Vec3d*)dusttailVertexArr.constData(), ( Vec2f*)tailTexCoordArr.constData(), (Vec3f*)dusttailColorArr.constData());
sPainter->drawFromArray(StelPainter::Triangles, tailIndices. size(), 0, true, tailIndices.constData()); sPainter->drawFromArray(StelPainter::Triangles, tailIndices. size(), 0, true, tailIndices.constData());
} }
glDisable(GL_BLEND); glDisable(GL_BLEND);
if (sPainter) delete sPainter;
delete sPainter;
sPainter=NULL; sPainter=NULL;
} }
void Comet::drawComa(StelCore* core, StelProjector::ModelViewTranformP tran sfo) void Comet::drawComa(StelCore* core, StelProjector::ModelViewTranformP tran sfo)
{ {
// Find rotation matrix from 0/0/1 to viewdirection! crossproduct fo r axis (normal vector), dotproduct for angle. // Find rotation matrix from 0/0/1 to viewdirection! crossproduct fo r axis (normal vector), dotproduct for angle.
Vec3d eclposNrm=eclipticPos - core->getObserverHeliocentricEclipticP os() ; eclposNrm.normalize(); Vec3d eclposNrm=eclipticPos - core->getObserverHeliocentricEclipticP os() ; eclposNrm.normalize();
Mat4d comarot=Mat4d::rotation(Vec3d(0.0, 0.0, 1.0)^(eclposNrm), std: :acos(Vec3d(0.0, 0.0, 1.0).dot(eclposNrm)) ); Mat4d comarot=Mat4d::rotation(Vec3d(0.0, 0.0, 1.0)^(eclposNrm), std: :acos(Vec3d(0.0, 0.0, 1.0).dot(eclposNrm)) );
StelProjector::ModelViewTranformP transfo2 = transfo->clone(); StelProjector::ModelViewTranformP transfo2 = transfo->clone();
transfo2->combine(comarot); transfo2->combine(comarot);
skipping to change at line 567 skipping to change at line 584
// Get the luminance scaled between 0 and 1 // Get the luminance scaled between 0 and 1
float aLum =eye->adaptLuminanceScaled(lum); float aLum =eye->adaptLuminanceScaled(lum);
float magFactor=qMin(qMax(aLum, 0.25f), 2.0f); float magFactor=qMin(qMax(aLum, 0.25f), 2.0f);
comaTexture->bind(); comaTexture->bind();
sPainter->setColor(0.3f*magFactor,0.7*magFactor,magFactor); sPainter->setColor(0.3f*magFactor,0.7*magFactor,magFactor);
sPainter->setArrays((Vec3d*)comaVertexArr.constData(), (Vec2f*)comaT exCoordArr.constData()); sPainter->setArrays((Vec3d*)comaVertexArr.constData(), (Vec2f*)comaT exCoordArr.constData());
sPainter->drawFromArray(StelPainter::Triangles, comaVertexArr.size() /3); sPainter->drawFromArray(StelPainter::Triangles, comaVertexArr.size() /3);
glDisable(GL_BLEND); glDisable(GL_BLEND);
if (sPainter) delete sPainter;
delete sPainter;
sPainter=NULL; sPainter=NULL;
} }
// Formula found at http://www.projectpluto.com/update7b.htm#comet_tail_for mula // Formula found at http://www.projectpluto.com/update7b.htm#comet_tail_for mula
Vec2f Comet::getComaDiameterAndTailLengthAU() Vec2f Comet::getComaDiameterAndTailLengthAU()
{ {
float r = getHeliocentricEclipticPos().length(); float r = getHeliocentricEclipticPos().length();
float mhelio = absoluteMagnitude + slopeParameter * log10(r); float mhelio = absoluteMagnitude + slopeParameter * log10(r);
float Do = pow(10.0f, ((-0.0033f*mhelio - 0.07f) * mhelio + 3.25f)); float Do = pow(10.0f, ((-0.0033f*mhelio - 0.07f) * mhelio + 3.25f));
float common = 1.0f - pow(10.0f, (-2.0f*r)); float common = 1.0f - pow(10.0f, (-2.0f*r));
skipping to change at line 662 skipping to change at line 678
indices << first+1+i << first+COMET_TAIL_SLI CES+i << first+COMET_TAIL_SLICES+1+i; indices << first+1+i << first+COMET_TAIL_SLI CES+i << first+COMET_TAIL_SLICES+1+i;
} }
// closing slice: mesh with other indices... // closing slice: mesh with other indices...
indices << ring*COMET_TAIL_SLICES << (ring+1)*COMET_ TAIL_SLICES << first; indices << ring*COMET_TAIL_SLICES << (ring+1)*COMET_ TAIL_SLICES << first;
indices << first << (ring+1)*COMET_TAIL_SLICES << ri ng*COMET_TAIL_SLICES+1; indices << first << (ring+1)*COMET_TAIL_SLICES << ri ng*COMET_TAIL_SLICES+1;
} }
} }
createTailIndices=false; createTailIndices=false;
createTailTextureCoords=false; createTailTextureCoords=false;
} }
// These are to avoid having index arrays for each comet when all are equal
.
bool Comet::createTailIndices=true;
bool Comet::createTailTextureCoords=true;
StelTextureSP Comet::comaTexture;
StelTextureSP Comet::tailTexture;
QVector<float> Comet::tailTexCoordArr; // computed only once for all Comets
.
QVector<unsigned short> Comet::tailIndices; // computed only once for all C
omets.
 End of changes. 11 change blocks. 
33 lines changed or deleted 51 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/