Planet.cpp   Planet.cpp 
skipping to change at line 28 skipping to change at line 28
*/ */
#include "StelApp.hpp" #include "StelApp.hpp"
#include "StelCore.hpp" #include "StelCore.hpp"
#include "StelFileMgr.hpp" #include "StelFileMgr.hpp"
#include "StelTexture.hpp" #include "StelTexture.hpp"
#include "StelSkyDrawer.hpp" #include "StelSkyDrawer.hpp"
#include "SolarSystem.hpp" #include "SolarSystem.hpp"
#include "LandscapeMgr.hpp" #include "LandscapeMgr.hpp"
#include "Planet.hpp" #include "Planet.hpp"
#include "Orbit.hpp"
#include "planetsephems/precession.h" #include "planetsephems/precession.h"
#include "StelObserver.hpp" #include "StelObserver.hpp"
#include "StelProjector.hpp" #include "StelProjector.hpp"
#include "sidereal_time.h" #include "sidereal_time.h"
#include "StelTextureMgr.hpp" #include "StelTextureMgr.hpp"
#include "StelModuleMgr.hpp" #include "StelModuleMgr.hpp"
#include "StarMgr.hpp" #include "StarMgr.hpp"
#include "StelMovementMgr.hpp" #include "StelMovementMgr.hpp"
#include "StelPainter.hpp" #include "StelPainter.hpp"
#include "StelTranslator.hpp" #include "StelTranslator.hpp"
skipping to change at line 60 skipping to change at line 61
Vec3f Planet::labelColor = Vec3f(0.4f,0.4f,0.8f); Vec3f Planet::labelColor = Vec3f(0.4f,0.4f,0.8f);
Vec3f Planet::orbitColor = Vec3f(1.0f,0.6f,1.0f); Vec3f Planet::orbitColor = Vec3f(1.0f,0.6f,1.0f);
Vec3f Planet::orbitMajorPlanetsColor = Vec3f(1.0f,0.6f,1.0f); Vec3f Planet::orbitMajorPlanetsColor = Vec3f(1.0f,0.6f,1.0f);
Vec3f Planet::orbitMoonsColor = Vec3f(1.0f,0.6f,1.0f); Vec3f Planet::orbitMoonsColor = Vec3f(1.0f,0.6f,1.0f);
Vec3f Planet::orbitMinorPlanetsColor = Vec3f(1.0f,0.6f,1.0f); Vec3f Planet::orbitMinorPlanetsColor = Vec3f(1.0f,0.6f,1.0f);
Vec3f Planet::orbitDwarfPlanetsColor = Vec3f(1.0f,0.6f,1.0f); Vec3f Planet::orbitDwarfPlanetsColor = Vec3f(1.0f,0.6f,1.0f);
Vec3f Planet::orbitCubewanosColor = Vec3f(1.0f,0.6f,1.0f); Vec3f Planet::orbitCubewanosColor = Vec3f(1.0f,0.6f,1.0f);
Vec3f Planet::orbitPlutinosColor = Vec3f(1.0f,0.6f,1.0f); Vec3f Planet::orbitPlutinosColor = Vec3f(1.0f,0.6f,1.0f);
Vec3f Planet::orbitScatteredDiscObjectsColor = Vec3f(1.0f,0.6f,1.0f); Vec3f Planet::orbitScatteredDiscObjectsColor = Vec3f(1.0f,0.6f,1.0f);
Vec3f Planet::orbitOortCloudObjectsColor = Vec3f(1.0f,0.6f,1.0f); Vec3f Planet::orbitOortCloudObjectsColor = Vec3f(1.0f,0.6f,1.0f);
Vec3f Planet::orbitSednoidsColor = Vec3f(1.0f,0.6f,1.0f);
Vec3f Planet::orbitCometsColor = Vec3f(1.0f,0.6f,1.0f); Vec3f Planet::orbitCometsColor = Vec3f(1.0f,0.6f,1.0f);
Vec3f Planet::orbitMercuryColor = Vec3f(1.0f,0.6f,1.0f); Vec3f Planet::orbitMercuryColor = Vec3f(1.0f,0.6f,1.0f);
Vec3f Planet::orbitVenusColor = Vec3f(1.0f,0.6f,1.0f); Vec3f Planet::orbitVenusColor = Vec3f(1.0f,0.6f,1.0f);
Vec3f Planet::orbitEarthColor = Vec3f(1.0f,0.6f,1.0f); Vec3f Planet::orbitEarthColor = Vec3f(1.0f,0.6f,1.0f);
Vec3f Planet::orbitMarsColor = Vec3f(1.0f,0.6f,1.0f); Vec3f Planet::orbitMarsColor = Vec3f(1.0f,0.6f,1.0f);
Vec3f Planet::orbitJupiterColor = Vec3f(1.0f,0.6f,1.0f); Vec3f Planet::orbitJupiterColor = Vec3f(1.0f,0.6f,1.0f);
Vec3f Planet::orbitSaturnColor = Vec3f(1.0f,0.6f,1.0f); Vec3f Planet::orbitSaturnColor = Vec3f(1.0f,0.6f,1.0f);
Vec3f Planet::orbitUranusColor = Vec3f(1.0f,0.6f,1.0f); Vec3f Planet::orbitUranusColor = Vec3f(1.0f,0.6f,1.0f);
Vec3f Planet::orbitNeptuneColor = Vec3f(1.0f,0.6f,1.0f); Vec3f Planet::orbitNeptuneColor = Vec3f(1.0f,0.6f,1.0f);
StelTextureSP Planet::hintCircleTex; StelTextureSP Planet::hintCircleTex;
skipping to change at line 121 skipping to change at line 123
orbitCached(false), orbitCached(false),
closeOrbit(acloseOrbit), closeOrbit(acloseOrbit),
englishName(englishName), englishName(englishName),
nameI18(englishName), nameI18(englishName),
nativeName(""), nativeName(""),
texMapName(atexMapName), texMapName(atexMapName),
normalMapName(anormalMapName), normalMapName(anormalMapName),
flagLighting(flagLighting), flagLighting(flagLighting),
radius(radius), radius(radius),
oneMinusOblateness(1.0-oblateness), oneMinusOblateness(1.0-oblateness),
eclipticPos(0.,0.,0.),
haloColor(halocolor), haloColor(halocolor),
albedo(albedo), albedo(albedo),
absoluteMagnitude(-99.0f),
rotLocalToParent(Mat4d::identity()),
axisRotation(0.), axisRotation(0.),
rings(NULL), rings(NULL),
distance(0.0), distance(0.0),
sphereScale(1.f), sphereScale(1.f),
lastJDE(J2000), lastJDE(J2000),
coordFunc(coordFunc), coordFunc(coordFunc),
userDataPtr(auserDataPtr), userDataPtr(auserDataPtr),
osculatingFunc(osculatingFunc), osculatingFunc(osculatingFunc),
parent(NULL), parent(NULL),
flagLabels(true), flagLabels(true),
hidden(hidden), hidden(hidden),
atmosphere(hasAtmosphere), atmosphere(hasAtmosphere),
halo(hasHalo) halo(hasHalo),
vMagAlgorithm(Planet::UndefinedAlgorithm)
{ {
// Initialize pType with the key found in pTypeMap, or mark planet t ype as undefined. // Initialize pType with the key found in pTypeMap, or mark planet t ype as undefined.
// The latter condition should obviously never happen. // The latter condition should obviously never happen.
pType = pTypeMap.key(pTypeStr, Planet::isUNDEFINED); pType = pTypeMap.key(pTypeStr, Planet::isUNDEFINED);
vMagAlgorithm = Planet::UndefinedAlgorithm;
eclipticPos = Vec3d(0.,0.,0.);
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));
normalMap = StelApp::getInstance().getTextureManager().createTexture Thread(StelFileMgr::getInstallationDir()+"/textures/"+normalMapName, StelTe xture::StelTextureParams(true, GL_LINEAR, GL_REPEAT)); normalMap = StelApp::getInstance().getTextureManager().createTexture Thread(StelFileMgr::getInstallationDir()+"/textures/"+normalMapName, StelTe xture::StelTextureParams(true, GL_LINEAR, GL_REPEAT));
if (englishName!="Pluto") if (englishName!="Pluto")
{ {
deltaJDE = 0.001*StelCore::JD_SECOND; deltaJDE = 0.001*StelCore::JD_SECOND;
} }
} }
skipping to change at line 173 skipping to change at line 176
pTypeMap.insert(Planet::isStar, "star"); pTypeMap.insert(Planet::isStar, "star");
pTypeMap.insert(Planet::isPlanet, "planet"); pTypeMap.insert(Planet::isPlanet, "planet");
pTypeMap.insert(Planet::isMoon, "moon"); pTypeMap.insert(Planet::isMoon, "moon");
pTypeMap.insert(Planet::isAsteroid, "asteroid"); pTypeMap.insert(Planet::isAsteroid, "asteroid");
pTypeMap.insert(Planet::isPlutino, "plutino"); pTypeMap.insert(Planet::isPlutino, "plutino");
pTypeMap.insert(Planet::isComet, "comet"); pTypeMap.insert(Planet::isComet, "comet");
pTypeMap.insert(Planet::isDwarfPlanet, "dwarf planet"); pTypeMap.insert(Planet::isDwarfPlanet, "dwarf planet");
pTypeMap.insert(Planet::isCubewano, "cubewano"); pTypeMap.insert(Planet::isCubewano, "cubewano");
pTypeMap.insert(Planet::isSDO, "scattered disc object"); pTypeMap.insert(Planet::isSDO, "scattered disc object");
pTypeMap.insert(Planet::isOCO, "Oort cloud object"); pTypeMap.insert(Planet::isOCO, "Oort cloud object");
pTypeMap.insert(Planet::isSednoid, "sednoid");
pTypeMap.insert(Planet::isUNDEFINED, "UNDEFINED"); // something m ust be broken before we ever see this! pTypeMap.insert(Planet::isUNDEFINED, "UNDEFINED"); // something m ust be broken before we ever see this!
if (vMagAlgorithmMap.count() > 0) if (vMagAlgorithmMap.count() > 0)
{ {
qDebug() << "Planet::init(): Non-empty static map. This is a programming error, but we can fix that."; qDebug() << "Planet::init(): Non-empty static map. This is a programming error, but we can fix that.";
vMagAlgorithmMap.clear(); vMagAlgorithmMap.clear();
} }
vMagAlgorithmMap.insert(Planet::Planesas, "planesas"); vMagAlgorithmMap.insert(Planet::Expl_Sup_2013, "ExpSup2013");
vMagAlgorithmMap.insert(Planet::Mueller, "mueller"); vMagAlgorithmMap.insert(Planet::Expl_Sup_1992, "planesas"); // depr
vMagAlgorithmMap.insert(Planet::Harris, "harris"); ecate in 0.16, remove later. TODO: Rename the other strings. BETTER: Use th
e metaobject!
vMagAlgorithmMap.insert(Planet::Expl_Sup_1992, "ExpSup1992");
vMagAlgorithmMap.insert(Planet::Mueller_1893, "mueller"); // d
eprecate in 0.16, remove later.
vMagAlgorithmMap.insert(Planet::Mueller_1893, "Mueller1893"); // b
etter name
vMagAlgorithmMap.insert(Planet::Astr_Alm_1984, "harris"); // d
eprecate in 0.16, remove later
vMagAlgorithmMap.insert(Planet::Astr_Alm_1984, "AstrAlm1984"); // c
onsistent name
vMagAlgorithmMap.insert(Planet::Generic, "generic"), vMagAlgorithmMap.insert(Planet::Generic, "generic"),
vMagAlgorithmMap.insert(Planet::UndefinedAlgorithm, ""); vMagAlgorithmMap.insert(Planet::UndefinedAlgorithm, "");
} }
Planet::~Planet() Planet::~Planet()
{ {
if (rings) if (rings)
delete rings; delete rings;
} }
skipping to change at line 255 skipping to change at line 263
} }
if (flags&Magnitude && getVMagnitude(core)!=std::numeric_limits<floa t>::infinity()) if (flags&Magnitude && getVMagnitude(core)!=std::numeric_limits<floa t>::infinity())
{ {
if (core->getSkyDrawer()->getFlagHasAtmosphere() && (alt_app >-3.0*M_PI/180.0)) // Don't show extincted magnitude much below horizon whe re model is meaningless. if (core->getSkyDrawer()->getFlagHasAtmosphere() && (alt_app >-3.0*M_PI/180.0)) // Don't show extincted magnitude much below horizon whe re model is meaningless.
oss << q_("Magnitude: <b>%1</b> (after extinction: < b>%2</b>)").arg(QString::number(getVMagnitude(core), 'f', 2), oss << q_("Magnitude: <b>%1</b> (after extinction: < 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>";
} }
if (flags&AbsoluteMagnitude && getVMagnitude(core)!=std::numeric_lim if (flags&AbsoluteMagnitude && (getAbsoluteMagnitude() > -99.))
its<float>::infinity()) {
oss << q_("Absolute Magnitude: %1").arg(getVMagnitude(core)- oss << q_("Absolute Magnitude: %1").arg(getAbsoluteMagnitude
5.*(std::log10(distanceAu*AU/PARSEC)-1.), 0, 'f', 2) << "<br>"; (), 0, 'f', 2) << "<br>";
const float moMag=getMeanOppositionMagnitude();
if (moMag<50.f)
oss << q_("Mean Opposition Magnitude: %1").arg(moMag
, 0, 'f', 2) << "<br>";
}
oss << getPositionInfoString(core, flags); oss << getPositionInfoString(core, flags);
// GZ This is mostly for debugging. Maybe also useful for letting pe ople use our results to cross-check theirs, but we should not act as refere nce, currently... // GZ This is mostly for debugging. Maybe also useful for letting pe ople use our results to cross-check theirs, but we should not act as refere nce, currently...
// TODO: maybe separate this out into: // TODO: maybe separate this out into:
//if (flags&EclipticCoordXYZ) //if (flags&EclipticCoordXYZ)
// For now: add to EclipticCoord // For now: add to EclipticCoord
//if (flags&EclipticCoord) //if (flags&EclipticCoord)
// oss << q_("Ecliptical XYZ (VSOP87A): %1/%2/%3").arg(QString: :number(eclipticPos[0], 'f', 3), QString::number(eclipticPos[1], 'f', 3), Q String::number(eclipticPos[2], 'f', 3)) << "<br>"; // oss << q_("Ecliptical XYZ (VSOP87A): %1/%2/%3").arg(QString: :number(eclipticPos[0], 'f', 3), QString::number(eclipticPos[1], 'f', 3), Q String::number(eclipticPos[2], 'f', 3)) << "<br>";
skipping to change at line 417 skipping to change at line 430
{ {
oss << QString(q_("Phase Angle: %1")).arg(St elUtils::radToDmsStr(getPhaseAngle(observerHelioPos), true)) << "<br>"; oss << QString(q_("Phase Angle: %1")).arg(St elUtils::radToDmsStr(getPhaseAngle(observerHelioPos), true)) << "<br>";
oss << QString(q_("Elongation: %1")).arg(Ste lUtils::radToDmsStr(elongation, true)) << "<br>"; oss << QString(q_("Elongation: %1")).arg(Ste lUtils::radToDmsStr(elongation, true)) << "<br>";
} }
oss << QString(q_("Phase: %1")).arg(getPhase(observe rHelioPos), 0, 'f', 2); oss << QString(q_("Phase: %1")).arg(getPhase(observe rHelioPos), 0, 'f', 2);
if (!moonPhase.isEmpty()) if (!moonPhase.isEmpty())
oss << " (" << moonPhase << ")"; oss << " (" << moonPhase << ")";
oss << "<br>"; oss << "<br>";
oss << QString(q_("Illuminated: %1%")).arg(getPhase( observerHelioPos) * 100, 0, 'f', 1) << "<br>"; oss << QString(q_("Illuminated: %1%")).arg(getPhase( observerHelioPos) * 100, 0, 'f', 1) << "<br>";
oss << QString(q_("Albedo: %1")).arg(QString::number (getAlbedo(), 'f', 3)) << "<br>";
} }
if (englishName=="Sun") if (englishName=="Sun")
{ {
// Only show during eclipse, show percent? // Only show during eclipse, show percent?
static SolarSystem *ssystem=GETSTELMODULE(SolarSyste m); static SolarSystem *ssystem=GETSTELMODULE(SolarSyste m);
// Debug solution: // Debug solution:
// float eclipseFactor = ssystem->getEclipseFactor(core ); // float eclipseFactor = ssystem->getEclipseFactor(core );
// oss << QString(q_("Eclipse Factor: %1 alpha: %2")).a rg(eclipseFactor).arg(-0.1f*qMax(-10.0f, (float) std::log10(eclipseFactor)) ) << "<br>"; // oss << QString(q_("Eclipse Factor: %1 alpha: %2")).a rg(eclipseFactor).arg(-0.1f*qMax(-10.0f, (float) std::log10(eclipseFactor)) ) << "<br>";
// Release version: // Release version:
float eclipseFactor = 100.f*(1.f-ssystem->getEclipse Factor(core)); float eclipseFactor = 100.f*(1.f-ssystem->getEclipse Factor(core));
skipping to change at line 438 skipping to change at line 452
oss << QString(q_("Eclipse Factor: %1%")).ar g(eclipseFactor) << "<br>"; oss << QString(q_("Eclipse Factor: %1%")).ar g(eclipseFactor) << "<br>";
} }
} }
postProcessInfoString(str, flags); postProcessInfoString(str, flags);
return str; return str;
} }
QVariantMap Planet::getInfoMap(const StelCore *core) const
{
QVariantMap map = StelObject::getInfoMap(core);
if (getEnglishName()!="Sun")
{
const Vec3d& observerHelioPos = core->getObserverHeliocentri
cEclipticPos();
map.insert("distance", getJ2000EquatorialPos(core).length())
;
double phase=getPhase(observerHelioPos);
map.insert("phase", phase);
map.insert("illumination", 100.*phase);
double phaseAngle = getPhaseAngle(observerHelioPos);
map.insert("phase-angle", phaseAngle);
map.insert("phase-angle-dms", StelUtils::radToDmsStr(phaseAn
gle));
map.insert("phase-angle-deg", StelUtils::radToDecDegStr(phas
eAngle));
double elongation = getElongation(observerHelioPos);
map.insert("elongation", elongation);
map.insert("elongation-dms", StelUtils::radToDmsStr(elongati
on));
map.insert("elongation-deg", StelUtils::radToDecDegStr(elong
ation));
map.insert("type", getPlanetTypeString()); // replace existi
ng "type=Planet" by something more detailed.
// TBD: Is there ANY reason to keep "type"="Planet" and add
a "ptype"=getPlanetTypeString() field?
}
return map;
}
//! Get sky label (sky translation) //! Get sky label (sky translation)
QString Planet::getSkyLabel(const StelCore*) const QString Planet::getSkyLabel(const StelCore*) const
{ {
QString str; QString str;
QTextStream oss(&str); QTextStream oss(&str);
oss.setRealNumberPrecision(2); oss.setRealNumberPrecision(2);
oss << getNameI18n(); oss << getNameI18n();
if (sphereScale != 1.f) if (sphereScale != 1.f)
{ {
skipping to change at line 846 skipping to change at line 886
} }
else else
return remainder * 360. + re.offset; return remainder * 360. + re.offset;
} }
double Planet::getMeanSolarDay() const double Planet::getMeanSolarDay() const
{ {
double msd = 0.; double msd = 0.;
if (englishName=="Sun") if (englishName=="Sun")
return msd; {
// A mean solar day (equals to Earth's day) has been added h
ere for educational purposes
// Details: https://sourceforge.net/p/stellarium/discussion/
278769/thread/fbe282db/
return 1.;
}
double sday = getSiderealDay(); double sday = getSiderealDay();
double coeff = qAbs(sday/getSiderealPeriod()); double coeff = qAbs(sday/getSiderealPeriod());
float sign = 1; float sign = 1;
// planets with retrograde rotation // planets with retrograde rotation
if (englishName=="Venus" || englishName=="Uranus" || englishName=="P luto") if (englishName=="Venus" || englishName=="Uranus" || englishName=="P luto")
sign = -1; sign = -1;
if (pType==Planet::isMoon) if (pType==Planet::isMoon)
{ {
skipping to change at line 947 skipping to change at line 991
// Get the elongation angle (radians) for an observer at pos obsPos in heli ocentric coordinates (dist in AU) // Get the elongation angle (radians) for an observer at pos obsPos in heli ocentric coordinates (dist in AU)
double Planet::getElongation(const Vec3d& obsPos) const double Planet::getElongation(const Vec3d& obsPos) const
{ {
const double observerRq = obsPos.lengthSquared(); const double observerRq = obsPos.lengthSquared();
const Vec3d& planetHelioPos = getHeliocentricEclipticPos(); const Vec3d& planetHelioPos = getHeliocentricEclipticPos();
const double planetRq = planetHelioPos.lengthSquared(); const double planetRq = planetHelioPos.lengthSquared();
const double observerPlanetRq = (obsPos - planetHelioPos).lengthSqua red(); const double observerPlanetRq = (obsPos - planetHelioPos).lengthSqua red();
return std::acos((observerPlanetRq + observerRq - planetRq)/(2.0*sq rt(observerPlanetRq*observerRq))); return std::acos((observerPlanetRq + observerRq - planetRq)/(2.0*sq rt(observerPlanetRq*observerRq)));
} }
// Source: Explanatory Supplement 2013, Table 10.6 and formula (10.5) with
semimajorAxis a from Table 8.7.
float Planet::getMeanOppositionMagnitude() const
{
if (absoluteMagnitude==-99.)
return 100.;
if (englishName=="Sun")
return 100;
double semimajorAxis=0.;
if (englishName=="Moon")
return -12.74f;
else if (englishName=="Mars")
return -2.01f;
else if (englishName=="Jupiter")
return -2.7f;
else if (englishName=="Saturn")
return 0.67f;
else if (englishName=="Uranus")
return 5.52f;
else if (englishName=="Neptune")
return 7.84f;
else if (englishName=="Pluto")
return 15.12f;
else if (englishName=="Io")
return 5.02f;
else if (englishName=="Europa")
return 5.29f;
else if (englishName=="Ganymede")
return 4.61f;
else if (englishName=="Callisto")
return 5.65f;
else if (parent->englishName=="Mars")
semimajorAxis=1.52371034;
else if (parent->englishName=="Jupiter")
semimajorAxis=5.202887;
else if (parent->englishName=="Saturn")
semimajorAxis=9.53667594;
else if (parent->englishName=="Uranus")
semimajorAxis=19.18916464;
else if (parent->englishName=="Neptune")
semimajorAxis=30.06992276;
else if (parent->englishName=="Pluto")
semimajorAxis=39.48211675;
else if (pType>= isAsteroid)
{
if (userDataPtr)
semimajorAxis=((CometOrbit*)userDataPtr)->getSemimaj
orAxis();
}
if (semimajorAxis>0.)
return absoluteMagnitude+5*log10(semimajorAxis*(semimajorAxi
s-1));
return 100.;
}
// Computation of the visual magnitude (V band) of the planet. // Computation of the visual magnitude (V band) of the planet.
float Planet::getVMagnitude(const StelCore* core) const float Planet::getVMagnitude(const StelCore* core) const
{ {
if (parent == 0) if (parent == 0)
{ {
// Sun, compute the apparent magnitude for the absolute mag (V: 4.83) and observer's distance // Sun, compute the apparent magnitude for the absolute mag (V: 4.83) and observer's distance
// Hint: Absolute Magnitude of the Sun in Several Bands: htt p://mips.as.arizona.edu/~cnaw/sun.html // Hint: Absolute Magnitude of the Sun in Several Bands: htt p://mips.as.arizona.edu/~cnaw/sun.html
const double distParsec = std::sqrt(core->getObserverHelioce ntricEclipticPos().lengthSquared())*AU/PARSEC; const double distParsec = std::sqrt(core->getObserverHelioce ntricEclipticPos().lengthSquared())*AU/PARSEC;
// check how much of it is visible // check how much of it is visible
const SolarSystem* ssm = GETSTELMODULE(SolarSystem); const SolarSystem* ssm = GETSTELMODULE(SolarSystem);
double shadowFactor = ssm->getEclipseFactor(core); double shadowFactor = ssm->getEclipseFactor(core);
// See: Hughes, D. W., Brightness during a solar eclipse // Journal of the British Astronomical Association, vol.110, no.4, p.203-205 // See: Hughes, D. W., Brightness during a solar eclipse // Journal of the British Astronomical Association, vol.110, no.4, p.203-205
// URL: http://adsabs.harvard.edu/abs/2000JBAA..110..203H // URL: http://adsabs.harvard.edu/abs/2000JBAA..110..203H
if(shadowFactor < 0.000128) if(shadowFactor < 0.000128)
shadowFactor = 0.000128; shadowFactor = 0.000128;
return 4.83 + 5.*(std::log10(distParsec)-1.) - 2.5*(std::log 10(shadowFactor)); return 4.83 + 5.*(std::log10(distParsec)-1.) - 2.5*(std::log 10(shadowFactor));
} }
// Compute the angular phase // Compute the phase angle i. We need the intermediate results also below, therefore we don't just call getPhaseAngle.
const Vec3d& observerHelioPos = core->getObserverHeliocentricEclipti cPos(); const Vec3d& observerHelioPos = core->getObserverHeliocentricEclipti cPos();
const double observerRq = observerHelioPos.lengthSquared(); const double observerRq = observerHelioPos.lengthSquared();
const Vec3d& planetHelioPos = getHeliocentricEclipticPos(); const Vec3d& planetHelioPos = getHeliocentricEclipticPos();
const double planetRq = planetHelioPos.lengthSquared(); const double planetRq = planetHelioPos.lengthSquared();
const double observerPlanetRq = (observerHelioPos - planetHelioPos). lengthSquared(); const double observerPlanetRq = (observerHelioPos - planetHelioPos). lengthSquared();
const double cos_chi = (observerPlanetRq + planetRq - observerRq)/(2 .0*std::sqrt(observerPlanetRq*planetRq)); const double cos_chi = (observerPlanetRq + planetRq - observerRq)/(2 .0*std::sqrt(observerPlanetRq*planetRq));
const double phase = std::acos(cos_chi); const double phaseAngle = std::acos(cos_chi);
double shadowFactor = 1.; double shadowFactor = 1.;
// Check if the satellite is inside the inner shadow of the parent p lanet: // Check if the satellite is inside the inner shadow of the parent p lanet:
if (parent->parent != 0) if (parent->parent != 0)
{ {
const Vec3d& parentHeliopos = parent->getHeliocentricEclipti cPos(); const Vec3d& parentHeliopos = parent->getHeliocentricEclipti cPos();
const double parent_Rq = parentHeliopos.lengthSquared(); const double parent_Rq = parentHeliopos.lengthSquared();
const double pos_times_parent_pos = planetHelioPos * parentH eliopos; const double pos_times_parent_pos = planetHelioPos * parentH eliopos;
if (pos_times_parent_pos > parent_Rq) if (pos_times_parent_pos > parent_Rq)
{ {
skipping to change at line 1019 skipping to change at line 1118
// compute a fantasy value for the magnitude : // compute a fantasy value for the magnitude :
d /= radius; d /= radius;
shadowFactor = (0.5 - (std::asin(d)+d*std::s qrt(1.0-d*d))/M_PI); shadowFactor = (0.5 - (std::asin(d)+d*std::s qrt(1.0-d*d))/M_PI);
} }
} }
} }
// Use empirical formulae for main planets when seen from earth // Use empirical formulae for main planets when seen from earth
if (core->getCurrentLocation().planetName=="Earth") if (core->getCurrentLocation().planetName=="Earth")
{ {
const double phaseDeg=phase*180./M_PI; const double phaseDeg=phaseAngle*180./M_PI;
const double d = 5. * log10(std::sqrt(observerPlanetRq*plane tRq)); const double d = 5. * log10(std::sqrt(observerPlanetRq*plane tRq));
// GZ: I prefer the values given by Meeus, Astronomical Algo rithms (1992). // GZ: I prefer the values given by Meeus, Astronomical Algo rithms (1992).
// There are two solutions: // There are three solutions:
// (1) G. Mueller, based on visual observations 1877-91. [Ex // (0) "Planesas": original solution in Stellarium, present
pl.Suppl.1961] around 2010.
// (1) G. Mueller, based on visual observations 1877-91. [Ex
pl.Suppl.1961 p.312ff]
// (2) Astronomical Almanac 1984 and later. These give V (in strumental) magnitudes. // (2) Astronomical Almanac 1984 and later. These give V (in strumental) magnitudes.
// The structure is almost identical, just the numbers are d ifferent! // The structure is almost identical, just the numbers are d ifferent!
// I activate (1) for now, because we want to simulate the e ye's impression. (Esp. Venus!) // I activate (1) for now, because we want to simulate the e ye's impression. (Esp. Venus!)
// AW: (2) activated by default // AW: (2) activated by default
// GZ Note that calling (2) "Harris" is an absolute misnomer
. Meeus clearly describes this in AstrAlg1998 p.286.
// The values should likely be named:
// Planesas --> Expl_Suppl_1992 AND THIS SHOULD BECOME DEFA
ULT
// Mueller --> Mueller_1893
// Harris --> Astr_Eph_1984
switch (core->getCurrentPlanet()->getApparentMagnitudeAlgori thm()) switch (core->getCurrentPlanet()->getApparentMagnitudeAlgori thm())
{ {
case Planesas: case UndefinedAlgorithm: // The most recent s
olution should be activated by default
case Expl_Sup_2013:
{
// GZ2017: This is taken straight from the E
xplanatory Supplement to the Astronomical Ephemeris 2013 (chap. 10.3)
// AW2017: Updated data from Errata in The E
xplanatory Supplement to the Astronomical Almanac (3rd edition, 1st printin
g)
// http://aa.usno.navy.mil/publicati
ons/docs/exp_supp_errata.pdf (Last update: 1 December 2016)
if (englishName=="Mercury")
return -0.6 + d + (((3.02e-6*phaseDe
g - 0.000488)*phaseDeg + 0.0498)*phaseDeg);
if (englishName=="Venus")
{ // there are two regions strongly enclosed
per phaseDeg (2.7..163.6..170.2). However, we must deliver a solution for
every case.
if (phaseDeg<163.6)
return -4.47 + d + ((0.13e-6
*phaseDeg + 0.000057)*phaseDeg + 0.0103)*phaseDeg;
else
return 0.98 + d -0.0102*phas
eDeg;
}
if (englishName=="Earth")
return -3.87 + d + (((0.48e-6*phaseD
eg + 0.000019)*phaseDeg + 0.0130)*phaseDeg);
if (englishName=="Mars")
return -1.52 + d + 0.016*phaseDeg;
if (englishName=="Jupiter")
return -9.40 + d + 0.005*phaseDeg;
if (englishName=="Saturn")
{
// add rings computation
// implemented from Meeus, Astr.Alg.
1992
const double jde=core->getJDE();
const double T=(jde-2451545.0)/36525
.0;
const double i=((0.000004*T-0.012998
)*T+28.075216)*M_PI/180.0;
const double Omega=((0.000412*T+1.39
4681)*T+169.508470)*M_PI/180.0;
static SolarSystem *ssystem=GETSTELM
ODULE(SolarSystem);
const Vec3d saturnEarth=getHeliocent
ricEclipticPos() - ssystem->getEarth()->getHeliocentricEclipticPos();
double lambda=atan2(saturnEarth[1],
saturnEarth[0]);
double beta=atan2(saturnEarth[2], st
d::sqrt(saturnEarth[0]*saturnEarth[0]+saturnEarth[1]*saturnEarth[1]));
const double sinx=sin(i)*cos(beta)*s
in(lambda-Omega)-cos(i)*sin(beta);
double rings = -2.6*fabs(sinx) + 1.2
5*sinx*sinx; // ExplSup2013: added term as (10.81)
return -8.88 + d + 0.044*phaseDeg +
rings;
}
if (englishName=="Uranus")
return -7.19 + d + 0.002*phaseDeg;
if (englishName=="Neptune")
return -6.87 + d;
if (englishName=="Pluto")
return -1.01 + d;
if (englishName=="Io")
return -1.68 + d + phaseDeg*(0.46
- 0.0010*phaseDeg);
if (englishName=="Europa")
return -1.41 + d + phaseDeg*(0.0312
- 0.00125*phaseDeg);
if (englishName=="Ganymede")
return -2.09 + d + phaseDeg*(0.323
- 0.00066*phaseDeg);
if (englishName=="Callisto")
return -1.05 + d + phaseDeg*(0.078
- 0.00274*phaseDeg);
if ((absoluteMagnitude!=-99.) && (englishNam
e!="Moon"))
return absoluteMagnitude+d;
break;
}
case Expl_Sup_1992:
{ {
// Algorithm provided by Pere Planesas (Obse rvatorio Astronomico Nacional) // Algorithm provided by Pere Planesas (Obse rvatorio Astronomico Nacional)
// GZ2016: Actually, this is taken straight
from the Explanatory Supplement to the Astronomical Ephemeris 1992! (chap.
7.12)
// The value -8.88 for Saturn V(1,0) seems t
o be a correction of a typo, where Suppl.Astr. gives -7.19 just like for Ur
anus.
double f1 = phaseDeg/100.; double f1 = phaseDeg/100.;
if (englishName=="Mercury") if (englishName=="Mercury")
{ {
if ( phaseDeg > 150. ) f1 = 1.5; if ( phaseDeg > 150. ) f1 = 1.5;
return -0.36 + d + 3.8*f1 - 2.73*f1* f1 + 2*f1*f1*f1; return -0.36 + d + 3.8*f1 - 2.73*f1* f1 + 2*f1*f1*f1;
} }
if (englishName=="Venus") if (englishName=="Venus")
return -4.29 + d + 0.09*f1 + 2.39*f1 *f1 - 0.65*f1*f1*f1; return -4.29 + d + 0.09*f1 + 2.39*f1 *f1 - 0.65*f1*f1*f1;
if (englishName=="Mars") if (englishName=="Mars")
skipping to change at line 1061 skipping to change at line 1225
// implemented from Meeus, Astr.Alg. 1992 // implemented from Meeus, Astr.Alg. 1992
const double jde=core->getJDE(); const double jde=core->getJDE();
const double T=(jde-2451545.0)/36525 .0; const double T=(jde-2451545.0)/36525 .0;
const double i=((0.000004*T-0.012998 )*T+28.075216)*M_PI/180.0; const double i=((0.000004*T-0.012998 )*T+28.075216)*M_PI/180.0;
const double Omega=((0.000412*T+1.39 4681)*T+169.508470)*M_PI/180.0; const double Omega=((0.000412*T+1.39 4681)*T+169.508470)*M_PI/180.0;
static SolarSystem *ssystem=GETSTELM ODULE(SolarSystem); static SolarSystem *ssystem=GETSTELM ODULE(SolarSystem);
const Vec3d saturnEarth=getHeliocent ricEclipticPos() - ssystem->getEarth()->getHeliocentricEclipticPos(); const Vec3d saturnEarth=getHeliocent ricEclipticPos() - ssystem->getEarth()->getHeliocentricEclipticPos();
double lambda=atan2(saturnEarth[1], saturnEarth[0]); double lambda=atan2(saturnEarth[1], saturnEarth[0]);
double beta=atan2(saturnEarth[2], st d::sqrt(saturnEarth[0]*saturnEarth[0]+saturnEarth[1]*saturnEarth[1])); double beta=atan2(saturnEarth[2], st d::sqrt(saturnEarth[0]*saturnEarth[0]+saturnEarth[1]*saturnEarth[1]));
const double sinx=sin(i)*cos(beta)*s in(lambda-Omega)-cos(i)*sin(beta); const double sinx=sin(i)*cos(beta)*s in(lambda-Omega)-cos(i)*sin(beta);
double rings = -2.6*sinx + 1.25*sinx *sinx; double rings = -2.6*fabs(sinx) + 1.2 5*sinx*sinx;
return -8.88 + d + 0.044*phaseDeg + rings; return -8.88 + d + 0.044*phaseDeg + rings;
} }
if (englishName=="Uranus") if (englishName=="Uranus")
return -7.19 + d + 0.0028*phaseDeg; return -7.19 + d + 0.0028*phaseDeg;
if (englishName=="Neptune") if (englishName=="Neptune")
return -6.87 + d; return -6.87 + d;
if (englishName=="Pluto") if (englishName=="Pluto")
return -1.01 + d + 0.041*phaseDeg; return -1.01 + d + 0.041*phaseDeg;
break; break;
} }
case Mueller: case Mueller_1893:
{ {
// (1) // (1)
if (englishName=="Mercury") if (englishName=="Mercury")
{ {
double ph50=phaseDeg-50.0; double ph50=phaseDeg-50.0;
return 1.16 + d + 0.02838*ph50 + 0.0 001023*ph50*ph50; return 1.16 + d + 0.02838*ph50 + 0.0 001023*ph50*ph50;
} }
if (englishName=="Venus") if (englishName=="Venus")
return -4.0 + d + 0.01322*phaseDeg + 0.0000004247*phaseDeg*phaseDeg*phaseDeg; return -4.00 + d + 0.01322*phaseDeg + 0.0000004247*phaseDeg*phaseDeg*phaseDeg;
if (englishName=="Mars") if (englishName=="Mars")
return -1.3 + d + 0.01486*phaseDeg; return -1.30 + d + 0.01486*phaseDeg;
if (englishName=="Jupiter") if (englishName=="Jupiter")
return -8.93 + d; return -8.93 + d;
if (englishName=="Saturn") if (englishName=="Saturn")
{ {
// add rings computation // add rings computation
// implemented from Meeus, Astr.Alg. 1992 // implemented from Meeus, Astr.Alg. 1992
const double jde=core->getJDE(); const double jde=core->getJDE();
const double T=(jde-2451545.0)/36525 .0; const double T=(jde-2451545.0)/36525 .0;
const double i=((0.000004*T-0.012998 )*T+28.075216)*M_PI/180.0; const double i=((0.000004*T-0.012998 )*T+28.075216)*M_PI/180.0;
const double Omega=((0.000412*T+1.39 4681)*T+169.508470)*M_PI/180.0; const double Omega=((0.000412*T+1.39 4681)*T+169.508470)*M_PI/180.0;
skipping to change at line 1107 skipping to change at line 1271
double lambda=atan2(saturnEarth[1], saturnEarth[0]); double lambda=atan2(saturnEarth[1], saturnEarth[0]);
double beta=atan2(saturnEarth[2], st d::sqrt(saturnEarth[0]*saturnEarth[0]+saturnEarth[1]*saturnEarth[1])); double beta=atan2(saturnEarth[2], st d::sqrt(saturnEarth[0]*saturnEarth[0]+saturnEarth[1]*saturnEarth[1]));
const double sinB=sin(i)*cos(beta)*s in(lambda-Omega)-cos(i)*sin(beta); const double sinB=sin(i)*cos(beta)*s in(lambda-Omega)-cos(i)*sin(beta);
double rings = -2.6*fabs(sinB) + 1.2 5*sinB*sinB; // sinx=sinB, saturnicentric latitude of earth. longish, see M eeus. double rings = -2.6*fabs(sinB) + 1.2 5*sinB*sinB; // sinx=sinB, saturnicentric latitude of earth. longish, see M eeus.
return -8.68 + d + 0.044*phaseDeg + rings; return -8.68 + d + 0.044*phaseDeg + rings;
} }
if (englishName=="Uranus") if (englishName=="Uranus")
return -6.85 + d; return -6.85 + d;
if (englishName=="Neptune") if (englishName=="Neptune")
return -7.05 + d; return -7.05 + d;
// Original formulae doesn't have equeation for Pluto // Original formulae doesn't have equation f or Pluto
if (englishName=="Pluto") if (englishName=="Pluto")
return -1.0 + d; return -1.0 + d;
break; break;
} }
case Harris: case Astr_Alm_1984:
case UndefinedAlgorithm: // activated by defa
ult
{ {
// (2) // (2)
if (englishName=="Mercury") if (englishName=="Mercury")
return -0.42 + d + .038*phaseDeg - 0 .000273*phaseDeg*phaseDeg + 0.000002*phaseDeg*phaseDeg*phaseDeg; return -0.42 + d + .038*phaseDeg - 0 .000273*phaseDeg*phaseDeg + 0.000002*phaseDeg*phaseDeg*phaseDeg;
if (englishName=="Venus") if (englishName=="Venus")
return -4.40 + d + 0.0009*phaseDeg + 0.000239*phaseDeg*phaseDeg - 0.00000065*phaseDeg*phaseDeg*phaseDeg; return -4.40 + d + 0.0009*phaseDeg + 0.000239*phaseDeg*phaseDeg - 0.00000065*phaseDeg*phaseDeg*phaseDeg;
if (englishName=="Mars") if (englishName=="Mars")
return -1.52 + d + 0.016*phaseDeg; return -1.52 + d + 0.016*phaseDeg;
if (englishName=="Jupiter") if (englishName=="Jupiter")
return -9.40 + d + 0.005*phaseDeg; return -9.40 + d + 0.005*phaseDeg;
skipping to change at line 1152 skipping to change at line 1315
return -7.19f + d; return -7.19f + d;
if (englishName=="Neptune") if (englishName=="Neptune")
return -6.87f + d; return -6.87f + d;
if (englishName=="Pluto") if (englishName=="Pluto")
return -1.00f + d; return -1.00f + d;
break; break;
} }
case Generic: case Generic:
{ {
// Calculation visual magnitude from phase a ngle and albedo of the planet // drop down to calculation of visual magnit ude from phase angle and albedo of the planet
break; break;
} }
} }
} }
// This formula seems to give wrong results // This formula source is unknown. But this is actually used even fo
const double p = (1.0 - phase/M_PI) * cos_chi + std::sqrt(1.0 - cos_ r the Moon!
chi*cos_chi) / M_PI; const double p = (1.0 - phaseAngle/M_PI) * cos_chi + std::sqrt(1.0 -
cos_chi*cos_chi) / M_PI;
double F = 2.0 * albedo * radius * radius * p / (3.0*observerPlanetR q*planetRq) * shadowFactor; double F = 2.0 * albedo * radius * radius * p / (3.0*observerPlanetR q*planetRq) * shadowFactor;
return -26.73 - 2.5 * std::log10(F); return -26.73 - 2.5 * std::log10(F);
} }
double Planet::getAngularSize(const StelCore* core) const double Planet::getAngularSize(const StelCore* core) const
{ {
double rad = radius; double rad = radius;
if (rings) if (rings)
rad = rings->getSize(); rad = rings->getSize();
return std::atan2(rad*sphereScale,getJ2000EquatorialPos(core).length ()) * 180./M_PI; return std::atan2(rad*sphereScale,getJ2000EquatorialPos(core).length ()) * 180./M_PI;
skipping to change at line 1598 skipping to change at line 1761
{ {
float fov=core->getProjection(transfo)->getF ov(); float fov=core->getProjection(transfo)->getF ov();
float fovFactor=1.6f; float fovFactor=1.6f;
// scale brightness to reduce if fov smaller than 5 degrees. Min brightness (to avoid glare) if fov=2deg. // scale brightness to reduce if fov smaller than 5 degrees. Min brightness (to avoid glare) if fov=2deg.
if (fov<5.0f) if (fov<5.0f)
{ {
fovFactor -= 0.1f*(5.0f-qMax(2.0f, f ov)); fovFactor -= 0.1f*(5.0f-qMax(2.0f, f ov));
} }
// Special case for the Moon. Was 1.6, but t his often is too bright. // Special case for the Moon. Was 1.6, but t his often is too bright.
light.diffuse = Vec4f(fovFactor,magFactorGre en*fovFactor,magFactorBlue*fovFactor,1.f); light.diffuse = Vec4f(fovFactor,magFactorGre en*fovFactor,magFactorBlue*fovFactor,1.f);
} }
} }
else else
{ {
sPainter->setColor(albedo,magFactorGreen*albedo,magF actorBlue*albedo); sPainter->setColor(albedo,magFactorGreen*albedo,magF actorBlue*albedo);
} }
// possibly tint sun's color from extinction. This should de liberately cause stronger reddening than for the other objects. // possibly tint sun's color from extinction. This should de liberately cause stronger reddening than for the other objects.
if (this==ssm->getSun()) if (this==ssm->getSun())
sPainter->setColor(2.f, pow(0.75f, extinctedMag)*2.f {
, pow(0.42f, 0.9f*extinctedMag)*2.f); // when we zoom in, reduce the overbrightness. (LP:#
1421173)
const float fov=core->getProjection(transfo)->getFov
();
const float overbright=qMin(2.0f, qMax(0.85f,0.5f*fo
v)); // scale full brightness to 0.85...2. (<2 when fov gets under 4 degree
s)
sPainter->setColor(overbright, pow(0.75f, extinctedM
ag)*overbright, pow(0.42f, 0.9f*extinctedMag)*overbright);
}
if (rings) if (rings)
{ {
// The planet has rings, we need to use depth buffer and adjust the clipping planes to avoid // The planet has rings, we need to use depth buffer and adjust the clipping planes to avoid
// reaching the maximum resolution of the depth buff er // reaching the maximum resolution of the depth buff er
const double dist = getEquinoxEquatorialPos(core).le ngth(); const double dist = getEquinoxEquatorialPos(core).le ngth();
double z_near = 0.9*(dist - rings->getSize()); double z_near = 0.9*(dist - rings->getSize());
double z_far = 1.1*(dist + rings->getSize()); double z_far = 1.1*(dist + rings->getSize());
if (z_near < 0.0) z_near = 0.0; if (z_near < 0.0) z_near = 0.0;
double n,f; double n,f;
skipping to change at line 1800 skipping to change at line 1967
void Planet::drawSphere(StelPainter* painter, float screenSz, bool drawOnly Ring) void Planet::drawSphere(StelPainter* painter, float screenSz, bool drawOnly Ring)
{ {
if (texMap) if (texMap)
{ {
// For lazy loading, return if texture not yet loaded // For lazy loading, return if texture not yet loaded
if (!texMap->bind(0)) if (!texMap->bind(0))
{ {
return; return;
} }
} }
painter->enableTexture2d(true);
glDisable(GL_BLEND); painter->setBlending(false);
glEnable(GL_CULL_FACE); painter->setCullFace(true);
// Draw the spheroid itself // Draw the spheroid itself
// Adapt the number of facets according with the size of the sphere for optimization // Adapt the number of facets according with the size of the sphere for optimization
int nb_facet = (int)(screenSz * 40.f/50.f); // 40 facets for 102 4 pixels diameter on screen int nb_facet = (int)(screenSz * 40.f/50.f); // 40 facets for 102 4 pixels diameter on screen
if (nb_facet<10) nb_facet = 10; if (nb_facet<10) nb_facet = 10;
if (nb_facet>100) nb_facet = 100; if (nb_facet>100) nb_facet = 100;
// Generates the vertice // Generates the vertice
Planet3DModel model; Planet3DModel model;
sSphere(&model, radius*sphereScale, oneMinusOblateness, nb_facet, nb _facet); sSphere(&model, radius*sphereScale, oneMinusOblateness, nb_facet, nb _facet);
skipping to change at line 1933 skipping to change at line 2100
} }
} }
GL(shader->setAttributeArray(shaderVars->vertex, (const GLfloat*)pro jectedVertexArr.constData(), 3)); GL(shader->setAttributeArray(shaderVars->vertex, (const GLfloat*)pro jectedVertexArr.constData(), 3));
GL(shader->enableAttributeArray(shaderVars->vertex)); GL(shader->enableAttributeArray(shaderVars->vertex));
GL(shader->setAttributeArray(shaderVars->unprojectedVertex, (const G Lfloat*)model.vertexArr.constData(), 3)); GL(shader->setAttributeArray(shaderVars->unprojectedVertex, (const G Lfloat*)model.vertexArr.constData(), 3));
GL(shader->enableAttributeArray(shaderVars->unprojectedVertex)); GL(shader->enableAttributeArray(shaderVars->unprojectedVertex));
GL(shader->setAttributeArray(shaderVars->texCoord, (const GLfloat*)m odel.texCoordArr.constData(), 2)); GL(shader->setAttributeArray(shaderVars->texCoord, (const GLfloat*)m odel.texCoordArr.constData(), 2));
GL(shader->enableAttributeArray(shaderVars->texCoord)); GL(shader->enableAttributeArray(shaderVars->texCoord));
QOpenGLFunctions* gl = painter->glFuncs();
if (rings) if (rings)
{ {
glDepthMask(GL_TRUE); painter->setDepthMask(true);
glClear(GL_DEPTH_BUFFER_BIT); painter->setDepthTest(true);
glEnable(GL_DEPTH_TEST); gl->glClear(GL_DEPTH_BUFFER_BIT);
} }
if (!drawOnlyRing) if (!drawOnlyRing)
GL(glDrawElements(GL_TRIANGLES, model.indiceArr.size(), GL_U NSIGNED_SHORT, model.indiceArr.constData())); GL(gl->glDrawElements(GL_TRIANGLES, model.indiceArr.size(), GL_UNSIGNED_SHORT, model.indiceArr.constData()));
if (rings) if (rings)
{ {
// Draw the rings just after the planet // Draw the rings just after the planet
glDepthMask(GL_FALSE); painter->setDepthMask(false);
// Normal transparency mode // Normal transparency mode
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); painter->setBlending(true);
glEnable(GL_BLEND);
Ring3DModel ringModel; Ring3DModel ringModel;
sRing(&ringModel, rings->radiusMin, rings->radiusMax, 128, 3 2); sRing(&ringModel, rings->radiusMin, rings->radiusMax, 128, 3 2);
GL(ringPlanetShaderProgram->setUniformValue(ringPlanetShader Vars.isRing, true)); GL(ringPlanetShaderProgram->setUniformValue(ringPlanetShader Vars.isRing, true));
GL(ringPlanetShaderProgram->setUniformValue(ringPlanetShader Vars.texture, 2)); GL(ringPlanetShaderProgram->setUniformValue(ringPlanetShader Vars.texture, 2));
GL(ringPlanetShaderProgram->setUniformValue(ringPlanetShader Vars.ringS, 1)); GL(ringPlanetShaderProgram->setUniformValue(ringPlanetShader Vars.ringS, 1));
computeModelMatrix(modelMatrix); computeModelMatrix(modelMatrix);
const Vec4d position = mTarget * modelMatrix.getColumn(3); const Vec4d position = mTarget * modelMatrix.getColumn(3);
skipping to change at line 1980 skipping to change at line 2148
painter->getProjector()->project(*((Vec3f*)(ringMode l.vertexArr.constData()+i*3)), *((Vec3f*)(projectedVertexArr.data()+i*3))); painter->getProjector()->project(*((Vec3f*)(ringMode l.vertexArr.constData()+i*3)), *((Vec3f*)(projectedVertexArr.data()+i*3)));
GL(ringPlanetShaderProgram->setAttributeArray(ringPlanetShad erVars.vertex, (const GLfloat*)projectedVertexArr.constData(), 3)); GL(ringPlanetShaderProgram->setAttributeArray(ringPlanetShad erVars.vertex, (const GLfloat*)projectedVertexArr.constData(), 3));
GL(ringPlanetShaderProgram->enableAttributeArray(ringPlanetS haderVars.vertex)); GL(ringPlanetShaderProgram->enableAttributeArray(ringPlanetS haderVars.vertex));
GL(ringPlanetShaderProgram->setAttributeArray(ringPlanetShad erVars.unprojectedVertex, (const GLfloat*)ringModel.vertexArr.constData(), 3)); GL(ringPlanetShaderProgram->setAttributeArray(ringPlanetShad erVars.unprojectedVertex, (const GLfloat*)ringModel.vertexArr.constData(), 3));
GL(ringPlanetShaderProgram->enableAttributeArray(ringPlanetS haderVars.unprojectedVertex)); GL(ringPlanetShaderProgram->enableAttributeArray(ringPlanetS haderVars.unprojectedVertex));
GL(ringPlanetShaderProgram->setAttributeArray(ringPlanetShad erVars.texCoord, (const GLfloat*)ringModel.texCoordArr.constData(), 2)); GL(ringPlanetShaderProgram->setAttributeArray(ringPlanetShad erVars.texCoord, (const GLfloat*)ringModel.texCoordArr.constData(), 2));
GL(ringPlanetShaderProgram->enableAttributeArray(ringPlanetS haderVars.texCoord)); GL(ringPlanetShaderProgram->enableAttributeArray(ringPlanetS haderVars.texCoord));
if (eyePos[2]<0) if (eyePos[2]<0)
glCullFace(GL_FRONT); gl->glCullFace(GL_FRONT);
GL(glDrawElements(GL_TRIANGLES, ringModel.indiceArr.size(), GL_UNSIGNED_SHORT, ringModel.indiceArr.constData())); GL(gl->glDrawElements(GL_TRIANGLES, ringModel.indiceArr.size (), GL_UNSIGNED_SHORT, ringModel.indiceArr.constData()));
if (eyePos[2]<0) if (eyePos[2]<0)
glCullFace(GL_BACK); gl->glCullFace(GL_BACK);
glDisable(GL_DEPTH_TEST); painter->setDepthTest(false);
} }
GL(shader->release()); GL(shader->release());
glDisable(GL_CULL_FACE); painter->setCullFace(false);
} }
void Planet::drawHints(const StelCore* core, const QFont& planetNameFont) void Planet::drawHints(const StelCore* core, const QFont& planetNameFont)
{ {
if (labelsFader.getInterstate()<=0.f) if (labelsFader.getInterstate()<=0.f)
return; return;
const StelProjectorP prj = core->getProjection(StelCore::FrameJ2000) ; const StelProjectorP prj = core->getProjection(StelCore::FrameJ2000) ;
StelPainter sPainter(prj); StelPainter sPainter(prj);
sPainter.setFont(planetNameFont); sPainter.setFont(planetNameFont);
skipping to change at line 2016 skipping to change at line 2184
sPainter.drawText(screenPos[0],screenPos[1], getSkyLabel(core), 0, t mp, tmp, false); sPainter.drawText(screenPos[0],screenPos[1], getSkyLabel(core), 0, t mp, tmp, false);
// hint disappears smoothly on close view // hint disappears smoothly on close view
if (hintFader.getInterstate()<=0) if (hintFader.getInterstate()<=0)
return; return;
tmp -= 10.f; tmp -= 10.f;
if (tmp<1) tmp=1; if (tmp<1) tmp=1;
sPainter.setColor(labelColor[0], labelColor[1], labelColor[2],labels Fader.getInterstate()*hintFader.getInterstate()/tmp*0.7f); sPainter.setColor(labelColor[0], labelColor[1], labelColor[2],labels Fader.getInterstate()*hintFader.getInterstate()/tmp*0.7f);
// Draw the 2D small circle // Draw the 2D small circle
glEnable(GL_BLEND); sPainter.setBlending(true);
sPainter.enableTexture2d(true);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
Planet::hintCircleTex->bind(); Planet::hintCircleTex->bind();
sPainter.drawSprite2dMode(screenPos[0], screenPos[1], 11); sPainter.drawSprite2dMode(screenPos[0], screenPos[1], 11);
} }
Ring::Ring(float radiusMin, float radiusMax, const QString &texname) Ring::Ring(float radiusMin, float radiusMax, const QString &texname)
:radiusMin(radiusMin),radiusMax(radiusMax) :radiusMin(radiusMin),radiusMax(radiusMax)
{ {
tex = StelApp::getInstance().getTextureManager().createTexture(StelF ileMgr::getInstallationDir()+"/textures/"+texname); tex = StelApp::getInstance().getTextureManager().createTexture(StelF ileMgr::getInstallationDir()+"/textures/"+texname);
} }
skipping to change at line 2065 skipping to change at line 2231
break; break;
case isSDO: case isSDO:
orbColor = orbitScatteredDiscObjects Color; orbColor = orbitScatteredDiscObjects Color;
break; break;
case isOCO: case isOCO:
orbColor = orbitOortCloudObjectsColo r; orbColor = orbitOortCloudObjectsColo r;
break; break;
case isComet: case isComet:
orbColor = orbitCometsColor; orbColor = orbitCometsColor;
break; break;
case isSednoid:
orbColor = orbitSednoidsColor;
break;
default: default:
orbColor = orbitColor; orbColor = orbitColor;
} }
break; break;
} }
case ocsMajorPlanets: case ocsMajorPlanets:
{ {
QString pName = getEnglishName().toLower(); QString pName = getEnglishName().toLower();
if (pName=="mercury") if (pName=="mercury")
orbColor = orbitMercuryColor; orbColor = orbitMercuryColor;
skipping to change at line 2116 skipping to change at line 2285
if (!orbitFader.getInterstate()) if (!orbitFader.getInterstate())
return; return;
if (!re.siderealPeriod) if (!re.siderealPeriod)
return; return;
const StelProjectorP prj = core->getProjection(StelCore::FrameHelioc entricEclipticJ2000); const StelProjectorP prj = core->getProjection(StelCore::FrameHelioc entricEclipticJ2000);
StelPainter sPainter(prj); StelPainter sPainter(prj);
// Normal transparency mode // Normal transparency mode
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); sPainter.setBlending(true);
glEnable(GL_BLEND);
Vec3f orbColor = getCurrentOrbitColor(); Vec3f orbColor = getCurrentOrbitColor();
sPainter.setColor(orbColor[0], orbColor[1], orbColor[2], orbitFader. getInterstate()); sPainter.setColor(orbColor[0], orbColor[1], orbColor[2], orbitFader. getInterstate());
Vec3d onscreen; Vec3d onscreen;
// special case - use current Planet position as center vertex so th at draws // special case - use current Planet position as center vertex so th at draws
// on its orbit all the time (since segmented rather than smooth cur ve) // on its orbit all the time (since segmented rather than smooth cur ve)
Vec3d savePos = orbit[ORBIT_SEGMENTS/2]; Vec3d savePos = orbit[ORBIT_SEGMENTS/2];
orbit[ORBIT_SEGMENTS/2]=getHeliocentricEclipticPos(); orbit[ORBIT_SEGMENTS/2]=getHeliocentricEclipticPos();
orbit[ORBIT_SEGMENTS]=orbit[0]; orbit[ORBIT_SEGMENTS]=orbit[0];
 End of changes. 45 change blocks. 
54 lines changed or deleted 279 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/