StelSkyDrawer.cpp   StelSkyDrawer.cpp 
skipping to change at line 69 skipping to change at line 69
limitMagnitude(-100.f), limitMagnitude(-100.f),
limitLuminance(0.f), limitLuminance(0.f),
bortleScaleIndex(3), bortleScaleIndex(3),
inScale(1.f), inScale(1.f),
starShaderProgram(NULL), starShaderProgram(NULL),
starShaderVars(StarShaderVars()), starShaderVars(StarShaderVars()),
maxLum(0.f), maxLum(0.f),
oldLum(-1.f), oldLum(-1.f),
big3dModelHaloRadius(150.f) big3dModelHaloRadius(150.f)
{ {
qsrand (QDateTime::currentMSecsSinceEpoch()); setObjectName("StelSkyDrawer");
QSettings* conf = StelApp::getInstance().getSettings(); QSettings* conf = StelApp::getInstance().getSettings();
initColorTableFromConfigFile(conf); initColorTableFromConfigFile(conf);
setFlagHasAtmosphere(conf->value("landscape/flag_atmosphere", true). toBool()); setFlagHasAtmosphere(conf->value("landscape/flag_atmosphere", true). toBool());
setTwinkleAmount(conf->value("stars/star_twinkle_amount",0.3).toFloa t()); setTwinkleAmount(conf->value("stars/star_twinkle_amount",0.3).toFloa t());
setFlagTwinkle(conf->value("stars/flag_star_twinkle",true).toBool()) ; setFlagTwinkle(conf->value("stars/flag_star_twinkle",true).toBool()) ;
setMaxAdaptFov(conf->value("stars/mag_converter_max_fov",70.0).toFlo at()); setMaxAdaptFov(conf->value("stars/mag_converter_max_fov",70.0).toFlo at());
setMinAdaptFov(conf->value("stars/mag_converter_min_fov",0.1).toFloa t()); setMinAdaptFov(conf->value("stars/mag_converter_min_fov",0.1).toFloa t());
setFlagLuminanceAdaptation(conf->value("viewing/use_luminance_adapta tion",true).toBool()); setFlagLuminanceAdaptation(conf->value("viewing/use_luminance_adapta tion",true).toBool());
setFlagStarMagnitudeLimit((conf->value("astro/flag_star_magnitude_li mit", false).toBool())); setFlagStarMagnitudeLimit((conf->value("astro/flag_star_magnitude_li mit", false).toBool()));
setCustomStarMagnitudeLimit(conf->value("astro/star_magnitude_limit" , 6.5).toFloat()); setCustomStarMagnitudeLimit(conf->value("astro/star_magnitude_limit" , 6.5).toFloat());
setFlagPlanetMagnitudeLimit((conf->value("astro/flag_planet_magnitud e_limit", false).toBool())); setFlagPlanetMagnitudeLimit((conf->value("astro/flag_planet_magnitud e_limit", false).toBool()));
setCustomPlanetMagnitudeLimit(conf->value("astro/planet_magnitude_li mit", 6.5).toFloat()); setCustomPlanetMagnitudeLimit(conf->value("astro/planet_magnitude_li mit", 6.5).toFloat());
setFlagNebulaMagnitudeLimit((conf->value("astro/flag_nebula_magnitud e_limit", false).toBool())); setFlagNebulaMagnitudeLimit((conf->value("astro/flag_nebula_magnitud e_limit", false).toBool()));
setCustomNebulaMagnitudeLimit(conf->value("astro/nebula_magnitude_li mit", 8.5).toFloat()); setCustomNebulaMagnitudeLimit(conf->value("astro/nebula_magnitude_li mit", 8.5).toFloat());
bool ok=true; bool ok=true;
setBortleScaleIndex(conf->value("stars/init_bortle_scale",2).toInt(& ok)); setBortleScaleIndex(conf->value("stars/init_bortle_scale",3).toInt(& ok));
if (!ok) if (!ok)
setBortleScaleIndex(2); setBortleScaleIndex(3);
setRelativeStarScale(conf->value("stars/relative_scale",1.0).toFloat (&ok)); setRelativeStarScale(conf->value("stars/relative_scale",1.0).toFloat (&ok));
if (!ok) if (!ok)
setRelativeStarScale(1.0); setRelativeStarScale(1.0);
setAbsoluteStarScale(conf->value("stars/absolute_scale",1.0).toFloat (&ok)); setAbsoluteStarScale(conf->value("stars/absolute_scale",1.0).toFloat (&ok));
if (!ok) if (!ok)
setAbsoluteStarScale(1.0); setAbsoluteStarScale(1.0);
setExtinctionCoefficient(conf->value("landscape/atmospheric_extincti on_coefficient",0.13).toDouble(&ok)); setExtinctionCoefficient(conf->value("landscape/atmospheric_extincti on_coefficient",0.13).toDouble(&ok));
skipping to change at line 214 skipping to change at line 214
else else
{ {
if (fov < minAdaptFov) if (fov < minAdaptFov)
fov = minAdaptFov; fov = minAdaptFov;
} }
// GZ: Light pollution must take global atmosphere setting into acou nt! // GZ: Light pollution must take global atmosphere setting into acou nt!
// moved parts from setBortleScale() here // moved parts from setBortleScale() here
// These value have been calibrated by hand, looking at the faintest star in stellarium at around 40 deg FOV // These value have been calibrated by hand, looking at the faintest star in stellarium at around 40 deg FOV
// They should roughly match the scale described at http://en.wikipe dia.org/wiki/Bortle_Dark-Sky_Scale // They should roughly match the scale described at http://en.wikipe dia.org/wiki/Bortle_Dark-Sky_Scale
static const float bortleToInScale[9] = {2.45, 1.55, 1.0, 0.63, 0.40 , 0.24, 0.23, 0.145, 0.09}; static const float bortleToInScale[9] = {2.45f, 1.55f, 1.0f, 0.63f, 0.40f, 0.24f, 0.23f, 0.145f, 0.09f};
if (getFlagHasAtmosphere()) if (getFlagHasAtmosphere())
setInputScale(bortleToInScale[bortleScaleIndex-1]); setInputScale(bortleToInScale[bortleScaleIndex-1]);
else else
setInputScale(bortleToInScale[0]); setInputScale(bortleToInScale[0]);
// This factor is fully arbitrary. It corresponds to the collecting area x exposure time of the instrument // This factor is fully arbitrary. It corresponds to the collecting area x exposure time of the instrument
// It is based on a power law, so that it varies progressively with the FOV to smoothly switch from human // It is based on a power law, so that it varies progressively with the FOV to smoothly switch from human
// vision to binocculares/telescope. Use a max of 0.7 because after that the atmosphere starts to glow too much! // vision to binocculares/telescope. Use a max of 0.7 because after that the atmosphere starts to glow too much!
float powFactor = std::pow(60.f/qMax(0.7f,fov), 0.8f); float powFactor = std::pow(60.f/qMax(0.7f,fov), 0.8f);
eye->setInputScale(inScale*powFactor); eye->setInputScale(inScale*powFactor);
skipping to change at line 416 skipping to change at line 416
starShaderProgram->disableAttributeArray(starShaderVars.pos); starShaderProgram->disableAttributeArray(starShaderVars.pos);
starShaderProgram->disableAttributeArray(starShaderVars.color); starShaderProgram->disableAttributeArray(starShaderVars.color);
starShaderProgram->disableAttributeArray(starShaderVars.texCoord); starShaderProgram->disableAttributeArray(starShaderVars.texCoord);
starShaderProgram->release(); starShaderProgram->release();
nbPointSources = 0; nbPointSources = 0;
} }
// Draw a point source halo. // Draw a point source halo.
bool StelSkyDrawer::drawPointSource(StelPainter* sPainter, const Vec3f& v, const RCMag& rcMag, const Vec3f& color, bool checkInScreen) bool StelSkyDrawer::drawPointSource(StelPainter* sPainter, const Vec3f& v, const RCMag& rcMag, const Vec3f& color, bool checkInScreen, float twinkleFa ctor)
{ {
Q_ASSERT(sPainter); Q_ASSERT(sPainter);
if (rcMag.radius<=0.f) if (rcMag.radius<=0.f)
return false; return false;
Vec3d win; // Why do we need Vec3d here? Try with Vec3f win.
if (!(checkInScreen ? sPainter->getProjector()->projectCheck(Vec3d(v // Vec3d win;
[0],v[1],v[2]), win) : sPainter->getProjector()->project(Vec3d(v[0],v[1],v[ // if (!(checkInScreen ? sPainter->getProjector()->projectCheck(Vec3d(v
2]), win))) [0],v[1],v[2]), win) : sPainter->getProjector()->project(Vec3d(v[0],v[1],v[
2]), win)))
// return false;
Vec3f win;
if (!(checkInScreen ? sPainter->getProjector()->projectCheck(v, win)
: sPainter->getProjector()->project(v, win)))
return false; return false;
const float radius = rcMag.radius; const float radius = rcMag.radius;
// Random coef for star twinkling // Random coef for star twinkling. twinkleFactor can introduce heigh
const float tw = (flagStarTwinkle && flagHasAtmosphere) ? (1.f-twink t-dependent twinkling.
leAmount*qrand()/RAND_MAX)*rcMag.luminance : rcMag.luminance; const float tw = (flagStarTwinkle && flagHasAtmosphere) ? (1.f-twink
leFactor*twinkleAmount*qrand()/RAND_MAX)*rcMag.luminance : rcMag.luminance;
// If the rmag is big, draw a big halo // If the rmag is big, draw a big halo
if (radius>MAX_LINEAR_RADIUS+5.f) if (radius>MAX_LINEAR_RADIUS+5.f)
{ {
float cmag = qMin(rcMag.luminance,(float)(radius-(MAX_LINEAR _RADIUS+5.f))/30.f); float cmag = qMin(rcMag.luminance,(float)(radius-(MAX_LINEAR _RADIUS+5.f))/30.f);
float rmag = 150.f; float rmag = 150.f;
if (cmag>1.f) if (cmag>1.f)
cmag = 1.f; cmag = 1.f;
texBigHalo->bind(); texBigHalo->bind();
skipping to change at line 526 skipping to change at line 530
bool save = flagStarTwinkle; bool save = flagStarTwinkle;
flagStarTwinkle = false; flagStarTwinkle = false;
RCMag rcm; RCMag rcm;
computeRCMag(mag, &rcm); computeRCMag(mag, &rcm);
// We now have the radius and luminosity of the small halo // We now have the radius and luminosity of the small halo
// If the disk of the planet is big enough to be visible, we should adjust the eye adaptation luminance // If the disk of the planet is big enough to be visible, we should adjust the eye adaptation luminance
// so that the radius of the halo is small enough to be not visible (so that we see the disk) // so that the radius of the halo is small enough to be not visible (so that we see the disk)
float tStart = 2.f; // TODO: Change drawing halo to more realistic view of stars and pla
nets
float tStart = 3.f; // Was 2.f: planet's halo is too dim
float tStop = 6.f; float tStop = 6.f;
bool truncated=false; bool truncated=false;
float maxHaloRadius = qMax(tStart*3., pixRadius*3.); float maxHaloRadius = qMax(tStart*3., pixRadius*3.);
if (rcm.radius>maxHaloRadius) if (rcm.radius>maxHaloRadius)
{ {
truncated = true; truncated = true;
rcm.radius=maxHaloRadius+std::sqrt(rcm.radius-maxHaloRadius) ; rcm.radius=maxHaloRadius+std::sqrt(rcm.radius-maxHaloRadius) ;
} }
skipping to change at line 645 skipping to change at line 650
eye->setWorldAdaptationLuminance(maxLum); eye->setWorldAdaptationLuminance(maxLum);
// Re-initialize for next stage // Re-initialize for next stage
oldLum = maxLum; oldLum = maxLum;
maxLum = 0; maxLum = 0;
} }
// Set the parameters so that the stars disappear at about the limit given by the bortle scale // Set the parameters so that the stars disappear at about the limit given by the bortle scale
// See http://en.wikipedia.org/wiki/Bortle_Dark-Sky_Scale // See http://en.wikipedia.org/wiki/Bortle_Dark-Sky_Scale
void StelSkyDrawer::setBortleScaleIndex(int bIndex) void StelSkyDrawer::setBortleScaleIndex(int bIndex)
{ {
// Associate the Bortle index (1 to 9) to inScale value if(bortleScaleIndex!=bIndex)
if (bIndex<1)
{
qWarning() << "WARNING: Bortle scale index range is [1;9], g
iven" << bIndex;
bIndex = 1;
}
if (bIndex>9)
{ {
qWarning() << "WARNING: Bortle scale index range is [1;9], g // Associate the Bortle index (1 to 9) to inScale value
iven" << bIndex; if (bIndex<1)
bIndex = 9; {
} qWarning() << "WARNING: Bortle scale index range is
[1;9], given" << bIndex;
bIndex = 1;
}
if (bIndex>9)
{
qWarning() << "WARNING: Bortle scale index range is
[1;9], given" << bIndex;
bIndex = 9;
}
bortleScaleIndex = bIndex; bortleScaleIndex = bIndex;
// GZ: I moved this block to update() emit bortleScaleIndexChanged(bortleScaleIndex);
// These value have been calibrated by hand, looking at the faintest // GZ: I moved this block to update()
star in stellarium at around 40 deg FOV // These value have been calibrated by hand, looking at the
// They should roughly match the scale described at http://en.wikipe faintest star in stellarium at around 40 deg FOV
dia.org/wiki/Bortle_Dark-Sky_Scale // They should roughly match the scale described at http://e
// static const float bortleToInScale[9] = {2.45, 1.55, 1.0, 0.63, 0 n.wikipedia.org/wiki/Bortle_Dark-Sky_Scale
.40, 0.24, 0.23, 0.145, 0.09}; // static const float bortleToInScale[9] = {2.45, 1.55, 1.0,
// setInputScale(bortleToInScale[bIndex-1]); 0.63, 0.40, 0.24, 0.23, 0.145, 0.09};
// setInputScale(bortleToInScale[bIndex-1]);
}
} }
// New colors // New colors
Vec3f StelSkyDrawer::colorTable[128] = { Vec3f StelSkyDrawer::colorTable[128] = {
Vec3f(0.602745,0.713725,1.000000), Vec3f(0.602745,0.713725,1.000000),
Vec3f(0.604902,0.715294,1.000000), Vec3f(0.604902,0.715294,1.000000),
Vec3f(0.607059,0.716863,1.000000), Vec3f(0.607059,0.716863,1.000000),
Vec3f(0.609215,0.718431,1.000000), Vec3f(0.609215,0.718431,1.000000),
Vec3f(0.611372,0.720000,1.000000), Vec3f(0.611372,0.720000,1.000000),
Vec3f(0.613529,0.721569,1.000000), Vec3f(0.613529,0.721569,1.000000),
 End of changes. 11 change blocks. 
34 lines changed or deleted 46 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/