ZodiacalLight.cpp   ZodiacalLight.cpp 
skipping to change at line 35 skipping to change at line 35
#include "StelUtils.hpp" #include "StelUtils.hpp"
#include "StelFileMgr.hpp" #include "StelFileMgr.hpp"
#include "StelModuleMgr.hpp" #include "StelModuleMgr.hpp"
#include "LandscapeMgr.hpp" #include "LandscapeMgr.hpp"
#include "StelProjector.hpp" #include "StelProjector.hpp"
#include "StelToneReproducer.hpp" #include "StelToneReproducer.hpp"
#include "StelApp.hpp" #include "StelApp.hpp"
#include "StelTextureMgr.hpp" #include "StelTextureMgr.hpp"
#include "StelCore.hpp" #include "StelCore.hpp"
#include "StelMovementMgr.hpp"
#include "StelSkyDrawer.hpp" #include "StelSkyDrawer.hpp"
#include "StelPainter.hpp" #include "StelPainter.hpp"
#include "StelTranslator.hpp" #include "StelTranslator.hpp"
#include "precession.h"
#include <QDebug> #include <QDebug>
#include <QSettings> #include <QSettings>
// Class which manages the displaying of the Zodiacal Light // Class which manages the displaying of the Zodiacal Light
ZodiacalLight::ZodiacalLight() ZodiacalLight::ZodiacalLight()
: color(1.f, 1.f, 1.f) : color(1.f, 1.f, 1.f)
, intensity(1.) , intensity(1.)
, intensityFovScale(1.0f)
, intensityMinFov(0.25f) // when zooming in further, Z.L. is no long
er visible.
, intensityMaxFov(2.5f) // when zooming out further, Z.L. is fully v
isible (when enabled).
, lastJD(-1.0E6) , lastJD(-1.0E6)
, vertexArray() , vertexArray()
{ {
setObjectName("ZodiacalLight"); setObjectName("ZodiacalLight");
fader = new LinearFader(); fader = new LinearFader();
} }
ZodiacalLight::~ZodiacalLight() ZodiacalLight::~ZodiacalLight()
{ {
delete fader; delete fader;
fader = NULL; fader = Q_NULLPTR;
delete vertexArray; delete vertexArray;
vertexArray = NULL; vertexArray = Q_NULLPTR;
} }
void ZodiacalLight::init() void ZodiacalLight::init()
{ {
QSettings* conf = StelApp::getInstance().getSettings(); QSettings* conf = StelApp::getInstance().getSettings();
Q_ASSERT(conf); Q_ASSERT(conf);
// The Paper describes brightness values over the complete sky, so a lso the texture covers the full sky. // The Paper describes brightness values over the complete sky, so a lso the texture covers the full sky.
// The data hole around the sun has been filled by useful values. // The data hole around the sun has been filled by useful values.
tex = StelApp::getInstance().getTextureManager().createTexture(StelF ileMgr::getInstallationDir()+"/textures/zodiacallight_2004.png"); tex = StelApp::getInstance().getTextureManager().createTexture(StelF ileMgr::getInstallationDir()+"/textures/zodiacallight_2004.png");
skipping to change at line 101 skipping to change at line 106
lastJD=-1e12; lastJD=-1e12;
} }
void ZodiacalLight::update(double deltaTime) void ZodiacalLight::update(double deltaTime)
{ {
fader->update((int)(deltaTime*1000)); fader->update((int)(deltaTime*1000));
if (!getFlagShow() || (getIntensity()<0.01) ) if (!getFlagShow() || (getIntensity()<0.01) )
return; return;
//calculate FOV fade value, linear fade between intensityMaxFov and
intensityMinFov
double fov = StelApp::getInstance().getCore()->getMovementMgr()->get
CurrentFov();
intensityFovScale = qBound(0.0,(fov - intensityMinFov) / (intensityM
axFov - intensityMinFov),1.0);
StelCore* core=StelApp::getInstance().getCore(); StelCore* core=StelApp::getInstance().getCore();
// Test if we are not on Earth or Moon. Texture would not fit, so do n't draw then. // Test if we are not on Earth or Moon. Texture would not fit, so do n't draw then.
if (! QString("Earth Moon").contains(core->getCurrentLocation().plan etName)) return; if (! QString("Earth Moon").contains(core->getCurrentLocation().plan etName)) return;
double currentJD=core->getJD(); double currentJD=core->getJD();
if (qAbs(currentJD - lastJD) > 0.25f) // should be enough to update position every 6 hours. if (qAbs(currentJD - lastJD) > 0.25f) // should be enough to update position every 6 hours.
{ {
// Allowed locations are only Earth or Moon. For Earth, we c an compute ZL along ecliptic of date. // Allowed locations are only Earth or Moon. For Earth, we c an compute ZL along ecliptic of date.
// For the Moon, we can only show ZL along J2000 ecliptic. // For the Moon, we can only show ZL along J2000 ecliptic.
// In draw() we have different projector frames. But we also need separate solar longitude computations here. // In draw() we have different projector frames. But we also need separate solar longitude computations here.
skipping to change at line 123 skipping to change at line 132
double lambdaSun; double lambdaSun;
if (core->getCurrentLocation().planetName=="Earth") if (core->getCurrentLocation().planetName=="Earth")
{ {
double eclJDE = GETSTELMODULE(SolarSystem)->getEarth ()->getRotObliquity(core->getJDE()); double eclJDE = GETSTELMODULE(SolarSystem)->getEarth ()->getRotObliquity(core->getJDE());
double ra_equ, dec_equ, betaJDE; double ra_equ, dec_equ, betaJDE;
StelUtils::rectToSphe(&ra_equ,&dec_equ,GETSTELMODULE (SolarSystem)->getSun()->getEquinoxEquatorialPos(core)); StelUtils::rectToSphe(&ra_equ,&dec_equ,GETSTELMODULE (SolarSystem)->getSun()->getEquinoxEquatorialPos(core));
StelUtils::equToEcl(ra_equ, dec_equ, eclJDE, &lambda Sun, &betaJDE); StelUtils::equToEcl(ra_equ, dec_equ, eclJDE, &lambda Sun, &betaJDE);
lambdaSun+= M_PI*0.5; lambdaSun+= M_PI*0.5;
} }
else else // currently Moon only...
{ {
Vec3d obsPos=core->getObserverHeliocentricEclipticPo s(); Vec3d obsPos=core->getObserverHeliocentricEclipticPo s();
lambdaSun=atan2(obsPos[1], obsPos[0]) -M_PI*0.5; lambdaSun=atan2(obsPos[1], obsPos[0]) -M_PI*0.5;
} }
Mat4d rotMat=Mat4d::zrotation(lambdaSun); Mat4d rotMat=Mat4d::zrotation(lambdaSun);
for (int i=0; i<eclipticalVertices.size(); ++i) for (int i=0; i<eclipticalVertices.size(); ++i)
{ {
Vec3d tmp=eclipticalVertices.at(i); Vec3d tmp=eclipticalVertices.at(i);
vertexArray->vertex.replace(i, rotMat * tmp); vertexArray->vertex.replace(i, rotMat * tmp);
skipping to change at line 151 skipping to change at line 160
*************************************************************************/ *************************************************************************/
double ZodiacalLight::getCallOrder(StelModuleActionName actionName) const double ZodiacalLight::getCallOrder(StelModuleActionName actionName) const
{ {
if (actionName==StelModule::ActionDraw) if (actionName==StelModule::ActionDraw)
return 8; return 8;
return 0; return 0;
} }
void ZodiacalLight::setFlagShow(bool b) void ZodiacalLight::setFlagShow(bool b)
{ {
*fader = b; if (*fader != b)
emit zodiacalLightDisplayedChanged(b); {
*fader = b;
emit zodiacalLightDisplayedChanged(b);
}
} }
bool ZodiacalLight::getFlagShow() const bool ZodiacalLight::getFlagShow() const
{ {
return *fader; return *fader;
} }
void ZodiacalLight::draw(StelCore* core) void ZodiacalLight::draw(StelCore* core)
{ {
if (!getFlagShow() || (getIntensity()<0.01) ) if (!getFlagShow() || (getIntensity()<0.01) )
skipping to change at line 189 skipping to change at line 201
const StelProjectorP prj = core->getProjection(transfo); const StelProjectorP prj = core->getProjection(transfo);
StelToneReproducer* eye = core->getToneReproducer(); StelToneReproducer* eye = core->getToneReproducer();
Q_ASSERT(tex); // A texture must be loaded before calling this Q_ASSERT(tex); // A texture must be loaded before calling this
// Default ZL color is white (sunlight), or whatever has been set e. g. by script. // Default ZL color is white (sunlight), or whatever has been set e. g. by script.
Vec3f c = color; Vec3f c = color;
// ZL is quite sensitive to light pollution. I scale to make it less visible. // ZL is quite sensitive to light pollution. I scale to make it less visible.
float lum = drawer->surfacebrightnessToLuminance(13.5f + 0.5f*bortle ); // (8.0f + 0.5*bortle); float lum = drawer->surfaceBrightnessToLuminance(13.5f + 0.5f*bortle ); // (8.0f + 0.5*bortle);
// Get the luminance scaled between 0 and 1 // Get the luminance scaled between 0 and 1
float aLum =eye->adaptLuminanceScaled(lum*fader->getInterstate()); float aLum =eye->adaptLuminanceScaled(lum*fader->getInterstate());
// Bound a maximum luminance // Bound a maximum luminance
aLum = qMin(0.15f, aLum*2.f); // 2*aLum at dark sky with mag13.5 at Bortle=1 gives 0.13 aLum = qMin(0.15f, aLum*2.f); // 2*aLum at dark sky with mag13.5 at Bortle=1 gives 0.13
//qDebug() << "aLum=" << aLum; //qDebug() << "aLum=" << aLum;
// intensity of 1.0 is "proper", but allow boost for dim screens // intensity of 1.0 is "proper", but allow boost for dim screens
c*=aLum*intensity; c*=aLum*intensity*intensityFovScale;
// Better: adapt brightness by atmospheric brightness // Better: adapt brightness by atmospheric brightness
const float atmLum = GETSTELMODULE(LandscapeMgr)->getAtmosphereAvera geLuminance(); const float atmLum = GETSTELMODULE(LandscapeMgr)->getAtmosphereAvera geLuminance();
if (atmLum>0.05f) return; // 10cd/m^2 at sunset, 3.3 at civil twilig ht (sun at -6deg). 0.0145 sun at -12, 0.0004 sun at -18, 0.01 at Full Moon !? if (atmLum>0.05f) return; // 10cd/m^2 at sunset, 3.3 at civil twilig ht (sun at -6deg). 0.0145 sun at -12, 0.0004 sun at -18, 0.01 at Full Moon !?
//qDebug() << "AtmLum: " << atmLum; //qDebug() << "AtmLum: " << atmLum;
float atmFactor=20.0f*(0.05f-atmLum); float atmFactor=20.0f*(0.05f-atmLum);
Q_ASSERT(atmFactor<=1.0f); Q_ASSERT(atmFactor<=1.0f);
Q_ASSERT(atmFactor>=0.0f); Q_ASSERT(atmFactor>=0.0f);
c*=atmFactor*atmFactor; c*=atmFactor*atmFactor;
if (c[0]<0) c[0]=0; if (c[0]<0) c[0]=0;
if (c[1]<0) c[1]=0; if (c[1]<0) c[1]=0;
if (c[2]<0) c[2]=0; if (c[2]<0) c[2]=0;
const bool withExtinction=(drawer->getFlagHasAtmosphere() && drawer- >getExtinction().getExtinctionCoefficient()>=0.01f); const bool withExtinction=(drawer->getFlagHasAtmosphere() && drawer- >getExtinction().getExtinctionCoefficient()>=0.01f);
if (withExtinction) if ((withExtinction) && (core->getCurrentLocation().planetName=="Ear th")) // If anybody switches on atmosphere on the moon, there will be no ex tinction.
{ {
// We must process the vertices to find geometric altitudes in order to compute vertex colors. // We must process the vertices to find geometric altitudes in order to compute vertex colors.
const Extinction& extinction=drawer->getExtinction(); const Extinction& extinction=drawer->getExtinction();
const double epsDate=getPrecessionAngleVondrakCurrentEpsilon A();
vertexArray->colors.clear(); vertexArray->colors.clear();
for (int i=0; i<vertexArray->vertex.size(); ++i) for (int i=0; i<vertexArray->vertex.size(); ++i)
{ {
Vec3d vertAltAz=core->j2000ToAltAz(vertexArray->vert Vec3d eclPos=vertexArray->vertex.at(i);
ex.at(i), StelCore::RefractionOn); Q_ASSERT(fabs(eclPos.lengthSquared()-1.0) < 0.001f);
double ecLon, ecLat, ra, dec;
StelUtils::rectToSphe(&ecLon, &ecLat, eclPos);
StelUtils::eclToEqu(ecLon, ecLat, epsDate, &ra, &dec
);
Vec3d eqPos;
StelUtils::spheToRect(ra, dec, eqPos);
Vec3d vertAltAz=core->equinoxEquToAltAz(eqPos, StelC
ore::RefractionOn);
Q_ASSERT(fabs(vertAltAz.lengthSquared()-1.0) < 0.001 f); Q_ASSERT(fabs(vertAltAz.lengthSquared()-1.0) < 0.001 f);
float oneMag=0.0f; float oneMag=0.0f;
extinction.forward(vertAltAz, &oneMag); extinction.forward(vertAltAz, &oneMag);
float extinctionFactor=std::pow(0.4f , oneMag)/bortl e; // drop of one magnitude: factor 2.5 or 40%, and further reduced by ligh t pollution float extinctionFactor=std::pow(0.4f , oneMag)/bortl e; // drop of one magnitude: factor 2.5 or 40%, and further reduced by ligh t pollution
Vec3f thisColor=Vec3f(c[0]*extinctionFactor, c[1]*ex tinctionFactor, c[2]*extinctionFactor); Vec3f thisColor=Vec3f(c[0]*extinctionFactor, c[1]*ex tinctionFactor, c[2]*extinctionFactor);
vertexArray->colors.append(thisColor); vertexArray->colors.append(thisColor);
} }
} }
else else
 End of changes. 13 change blocks. 
10 lines changed or deleted 36 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/