SkyDrawer.cpp   StelSkyDrawer.cpp 
skipping to change at line 20 skipping to change at line 20
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, U SA. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, U SA.
*/ */
#include "SkyDrawer.hpp" #include "StelSkyDrawer.hpp"
#include "Projector.hpp" #include "StelProjector.hpp"
#include "Navigator.hpp" #include "StelNavigator.hpp"
#include "ToneReproducer.hpp" #include "StelToneReproducer.hpp"
#include "StelTextureMgr.hpp" #include "StelTextureMgr.hpp"
#include "StelApp.hpp" #include "StelApp.hpp"
#include "StelCore.hpp" #include "StelCore.hpp"
#include "StelUtils.hpp" #include "StelUtils.hpp"
#include "StelMovementMgr.hpp"
#include "StelPainter.hpp"
#include <QStringList> #include <QStringList>
#include <QSettings> #include <QSettings>
#include <QDebug> #include <QDebug>
#include <QtGlobal> #include <QtGlobal>
// The 0.025 corresponds to the maximum eye resolution in degree // The 0.025 corresponds to the maximum eye resolution in degree
#define EYE_RESOLUTION (0.25) #define EYE_RESOLUTION (0.25)
#define MAX_LINEAR_RADIUS 8.f #define MAX_LINEAR_RADIUS 8.f
SkyDrawer::SkyDrawer(StelCore* acore) : core(acore) StelSkyDrawer::StelSkyDrawer(StelCore* acore) : core(acore)
{ {
prj = core->getProjection();
eye = core->getToneReproducer(); eye = core->getToneReproducer();
sPainter = NULL;
inScale = 1.; inScale = 1.;
bortleScaleIndex = 3; bortleScaleIndex = 3;
limitMagnitude = -100.f; limitMagnitude = -100.f;
limitLuminance = 0; limitLuminance = 0;
oldLum=-1.f; oldLum=-1.f;
maxLum = 0.f; maxLum = 0.f;
setMaxFov(180.f); setMaxAdaptFov(180.f);
setMinFov(0.1f); setMinAdaptFov(0.1f);
starAbsoluteScaleF = 1.f; starAbsoluteScaleF = 1.f;
starRelativeScale = 1.f; starRelativeScale = 1.f;
starLinearScale = 19.569f; starLinearScale = 19.569f;
update(0);
QSettings* conf = StelApp::getInstance().getSettings(); QSettings* conf = StelApp::getInstance().getSettings();
initColorTableFromConfigFile(conf); initColorTableFromConfigFile(conf);
setTwinkleAmount(conf->value("stars/star_twinkle_amount",0.3).toDoub le()); setTwinkleAmount(conf->value("stars/star_twinkle_amount",0.3).toDoub le());
setFlagTwinkle(conf->value("stars/flag_star_twinkle",true).toBool()) ; setFlagTwinkle(conf->value("stars/flag_star_twinkle",true).toBool()) ;
setFlagPointStar(conf->value("stars/flag_point_star",false).toBool() ); setFlagPointStar(conf->value("stars/flag_point_star",false).toBool() );
setMaxFov(conf->value("stars/mag_converter_max_fov",70.0).toDouble() setMaxAdaptFov(conf->value("stars/mag_converter_max_fov",70.0).toDou
); ble());
setMinFov(conf->value("stars/mag_converter_min_fov",0.1).toDouble()) setMinAdaptFov(conf->value("stars/mag_converter_min_fov",0.1).toDoub
; le());
setFlagLuminanceAdaptation(conf->value("viewing/use_luminance_adapta tion",true).toBool()); setFlagLuminanceAdaptation(conf->value("viewing/use_luminance_adapta tion",true).toBool());
bool ok=true; bool ok=true;
setBortleScale(conf->value("stars/init_bortle_scale",3).toInt(&ok)); setBortleScale(conf->value("stars/init_bortle_scale",3).toInt(&ok));
if (!ok) if (!ok)
{ {
conf->setValue("stars/init_bortle_scale",3); conf->setValue("stars/init_bortle_scale",3);
setBortleScale(3); setBortleScale(3);
ok = true; ok = true;
skipping to change at line 109 skipping to change at line 110
textureGrid = new Vec2f[maxPointSources*4]; textureGrid = new Vec2f[maxPointSources*4];
for (unsigned int i=0;i<maxPointSources; ++i) for (unsigned int i=0;i<maxPointSources; ++i)
{ {
textureGrid[i*4].set(0,0); textureGrid[i*4].set(0,0);
textureGrid[i*4+1].set(1,0); textureGrid[i*4+1].set(1,0);
textureGrid[i*4+2].set(1,1); textureGrid[i*4+2].set(1,1);
textureGrid[i*4+3].set(0,1); textureGrid[i*4+3].set(0,1);
} }
} }
SkyDrawer::~SkyDrawer() StelSkyDrawer::~StelSkyDrawer()
{ {
if (verticesGrid) if (verticesGrid)
delete[] verticesGrid; delete[] verticesGrid;
verticesGrid = NULL; verticesGrid = NULL;
if (colorGrid) if (colorGrid)
delete[] colorGrid; delete[] colorGrid;
colorGrid = NULL; colorGrid = NULL;
if (textureGrid) if (textureGrid)
delete[] textureGrid; delete[] textureGrid;
textureGrid = NULL; textureGrid = NULL;
} }
// Init parameters from config file // Init parameters from config file
void SkyDrawer::init() void StelSkyDrawer::init()
{ {
StelApp::getInstance().getTextureManager().setDefaultParams(); StelApp::getInstance().getTextureManager().setDefaultParams();
// Load star texture no mipmap: // Load star texture no mipmap:
texHalo = StelApp::getInstance().getTextureManager().createTexture(" star16x16.png"); texHalo = StelApp::getInstance().getTextureManager().createTexture(" star16x16.png");
texBigHalo = StelApp::getInstance().getTextureManager().createTextur e("haloLune.png"); texBigHalo = StelApp::getInstance().getTextureManager().createTextur e("haloLune.png");
texSunHalo = StelApp::getInstance().getTextureManager().createTextur e("halo.png"); texSunHalo = StelApp::getInstance().getTextureManager().createTextur e("halo.png");
update(0);
} }
void SkyDrawer::update(double deltaTime) void StelSkyDrawer::update(double deltaTime)
{ {
float fov = prj->getFov(); float fov = core->getMovementMgr()->getCurrentFov();
if (fov > maxFov) if (fov > maxAdaptFov)
{ {
fov = maxFov; fov = maxAdaptFov;
} }
else else
{ {
if (fov < minFov) if (fov < minAdaptFov)
fov = minFov; fov = minAdaptFov;
} }
// 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./qMax(0.7f,fov), 0.8); float powFactor = std::pow(60./qMax(0.7f,fov), 0.8);
eye->setInputScale(inScale*powFactor); eye->setInputScale(inScale*powFactor);
// Set the fov factor for point source luminance computation // Set the fov factor for point source luminance computation
// the division by powFactor should in principle not be here, but it doesn't look nice if removed // the division by powFactor should in principle not be here, but it doesn't look nice if removed
skipping to change at line 166 skipping to change at line 168
starLinearScale = std::pow(35.f*2.0f*starAbsoluteScaleF, 1.40f/2.f*s tarRelativeScale); starLinearScale = std::pow(35.f*2.0f*starAbsoluteScaleF, 1.40f/2.f*s tarRelativeScale);
// update limit mag // update limit mag
limitMagnitude = computeLimitMagnitude(); limitMagnitude = computeLimitMagnitude();
// update limit luminance // update limit luminance
limitLuminance = computeLimitLuminance(); limitLuminance = computeLimitLuminance();
} }
// Compute the current limit magnitude by dichotomy // Compute the current limit magnitude by dichotomy
float SkyDrawer::computeLimitMagnitude() const float StelSkyDrawer::computeLimitMagnitude() const
{ {
float a=-26.f; float a=-26.f;
float b=30.f; float b=30.f;
float rcmag[2]; float rcmag[2];
float lim = 0.f; float lim = 0.f;
int safety=0; int safety=0;
while (std::fabs(lim-a)>0.05) while (std::fabs(lim-a)>0.05)
{ {
computeRCMag(lim, rcmag); computeRCMag(lim, rcmag);
if (rcmag[0]<=0.f) if (rcmag[0]<=0.f)
skipping to change at line 199 skipping to change at line 201
if (safety>20) if (safety>20)
{ {
lim=-99; lim=-99;
break; break;
} }
} }
return lim; return lim;
} }
// Compute the current limit luminance by dichotomy // Compute the current limit luminance by dichotomy
float SkyDrawer::computeLimitLuminance() const float StelSkyDrawer::computeLimitLuminance() const
{ {
float a=0.f; float a=0.f;
float b=500000.f; float b=500000.f;
float lim=40.f; float lim=40.f;
int safety=0; int safety=0;
float adaptL; float adaptL;
while (std::fabs(lim-a)>0.05) while (std::fabs(lim-a)>0.05)
{ {
adaptL = eye->adaptLuminanceScaled(lim); adaptL = eye->adaptLuminanceScaled(lim);
if (adaptL<=0.05f) // Object considered not visible if its a dapted scaled luminance<0.05 if (adaptL<=0.05f) // Object considered not visible if its a dapted scaled luminance<0.05
skipping to change at line 232 skipping to change at line 234
if (safety>30) if (safety>30)
{ {
lim=500000; lim=500000;
break; break;
} }
} }
return lim; return lim;
} }
// Compute the ln of the luminance for a point source with the given mag fo r the current FOV // Compute the ln of the luminance for a point source with the given mag fo r the current FOV
float SkyDrawer::pointSourceMagToLnLuminance(float mag) const float StelSkyDrawer::pointSourceMagToLnLuminance(float mag) const
{ {
return -0.92103f*(mag + 12.12331f) + lnfovFactor; return -0.92103f*(mag + 12.12331f) + lnfovFactor;
} }
float SkyDrawer::pointSourceLuminanceToMag(float lum) float StelSkyDrawer::pointSourceLuminanceToMag(float lum)
{ {
return (std::log(lum) - lnfovFactor)/-0.92103f - 12.12331f; return (std::log(lum) - lnfovFactor)/-0.92103f - 12.12331f;
} }
// Compute the luminance for an extended source with the given surface brig htness in Vmag/arcmin^2 // Compute the luminance for an extended source with the given surface brig htness in Vmag/arcmin^2
float SkyDrawer::surfacebrightnessToLuminance(float sb) float StelSkyDrawer::surfacebrightnessToLuminance(float sb)
{ {
return 2.*2025000.f*std::exp(-0.92103f*(sb + 12.12331f))/(1./60.*1./ 60.); return 2.*2025000.f*std::exp(-0.92103f*(sb + 12.12331f))/(1./60.*1./ 60.);
} }
// Compute the surface brightness from the luminance of an extended source
float StelSkyDrawer::luminanceToSurfacebrightness(float lum)
{
return std::log(lum*(1./60.*1./60.)/(2.*2025000.f))/-0.92103f - 12.1
2331f;
}
// Compute RMag and CMag from magnitude for a point source. // Compute RMag and CMag from magnitude for a point source.
bool SkyDrawer::computeRCMag(float mag, float rcMag[2]) const bool StelSkyDrawer::computeRCMag(float mag, float rcMag[2]) const
{ {
rcMag[0] = eye->adaptLuminanceScaledLn(pointSourceMagToLnLuminance(m ag), starRelativeScale*1.40f/2.f); rcMag[0] = eye->adaptLuminanceScaledLn(pointSourceMagToLnLuminance(m ag), starRelativeScale*1.40f/2.f);
rcMag[0]*=starLinearScale; rcMag[0]*=starLinearScale;
// Use now statically min_rmag = 0.5, because higher and too small v alues look bad // Use now statically min_rmag = 0.5, because higher and too small v alues look bad
if (rcMag[0] < 0.5f) if (rcMag[0] < 0.5f)
{ {
rcMag[0] = rcMag[1] = 0.f; rcMag[0] = rcMag[1] = 0.f;
return false; return false;
} }
skipping to change at line 285 skipping to change at line 293
// cmag: // cmag:
rcMag[1] = 1.0f; rcMag[1] = 1.0f;
if (rcMag[0]>MAX_LINEAR_RADIUS) if (rcMag[0]>MAX_LINEAR_RADIUS)
{ {
rcMag[0]=MAX_LINEAR_RADIUS+std::sqrt(1.f+rcMag[0]-MA X_LINEAR_RADIUS)-1.f; rcMag[0]=MAX_LINEAR_RADIUS+std::sqrt(1.f+rcMag[0]-MA X_LINEAR_RADIUS)-1.f;
} }
} }
return true; return true;
} }
void SkyDrawer::preDrawPointSource() void StelSkyDrawer::preDrawPointSource(const StelPainter* p)
{ {
assert(nbPointSources==0); Q_ASSERT(p);
Q_ASSERT(sPainter==NULL);
sPainter=p;
Q_ASSERT(nbPointSources==0);
glDisable(GL_LIGHTING); glDisable(GL_LIGHTING);
// Blending is really important. Otherwise faint stars in the vicini ty of // Blending is really important. Otherwise faint stars in the vicini ty of
// bright star will cause tiny black squares on the bright star, e.g . see Procyon. // bright star will cause tiny black squares on the bright star, e.g . see Procyon.
glEnable(GL_BLEND); glEnable(GL_BLEND);
glBlendFunc(GL_ONE, GL_ONE); glBlendFunc(GL_ONE, GL_ONE);
if (getFlagPointStar()) if (getFlagPointStar())
{ {
glDisable(GL_TEXTURE_2D); glDisable(GL_TEXTURE_2D);
glPointSize(0.1); glPointSize(0.1);
} }
else else
{ {
glEnable(GL_TEXTURE_2D); glEnable(GL_TEXTURE_2D);
} }
} }
// Finalize the drawing of point sources // Finalize the drawing of point sources
void SkyDrawer::postDrawPointSource() void StelSkyDrawer::postDrawPointSource()
{ {
Q_ASSERT(sPainter);
sPainter = NULL;
if (nbPointSources==0) if (nbPointSources==0)
return; return;
texHalo->bind(); texHalo->bind();
glEnableClientState(GL_VERTEX_ARRAY); glEnableClientState(GL_VERTEX_ARRAY);
glEnableClientState(GL_COLOR_ARRAY); glEnableClientState(GL_COLOR_ARRAY);
glEnableClientState(GL_TEXTURE_COORD_ARRAY); glEnableClientState(GL_TEXTURE_COORD_ARRAY);
// Load the color components // Load the color components
skipping to change at line 335 skipping to change at line 350
glDrawArrays(GL_QUADS, 0, nbPointSources*4); glDrawArrays(GL_QUADS, 0, nbPointSources*4);
glDisableClientState(GL_VERTEX_ARRAY); glDisableClientState(GL_VERTEX_ARRAY);
glDisableClientState(GL_COLOR_ARRAY); glDisableClientState(GL_COLOR_ARRAY);
glDisableClientState(GL_TEXTURE_COORD_ARRAY); glDisableClientState(GL_TEXTURE_COORD_ARRAY);
nbPointSources = 0; nbPointSources = 0;
} }
// Draw a point source halo. // Draw a point source halo.
bool SkyDrawer::drawPointSource(double x, double y, const float rcMag[2], c onst Vec3f& color) bool StelSkyDrawer::drawPointSource(double x, double y, const float rcMag[2 ], const Vec3f& color)
{ {
Q_ASSERT(sPainter);
if (rcMag[0]<=0.f) if (rcMag[0]<=0.f)
return false; return false;
// Random coef for star twinkling // Random coef for star twinkling
const float tw = flagStarTwinkle ? (1.f-twinkleAmount*rand()/RAND_MA X) : 1.f; const float tw = flagStarTwinkle ? (1.f-twinkleAmount*rand()/RAND_MA X) : 1.f;
if (flagPointStar) if (flagPointStar)
{ {
// Draw the star rendered as GLpoint. This may be faster but it is not so nice // Draw the star rendered as GLpoint. This may be faster but it is not so nice
glColor3fv(color*(rcMag[1]*tw)); glColor3fv(color*(rcMag[1]*tw));
prj->drawPoint2d(x, y); sPainter->drawPoint2d(x, y);
} }
else else
{ {
// Store the drawing instructions in the vertex arrays // Store the drawing instructions in the vertex arrays
colorGrid[nbPointSources*4+3] = color*(rcMag[1]*tw); colorGrid[nbPointSources*4+3] = color*(rcMag[1]*tw);
const double radius = rcMag[0]; const double radius = rcMag[0];
Vec2f* v = &(verticesGrid[nbPointSources*4]); Vec2f* v = &(verticesGrid[nbPointSources*4]);
v->set(x-radius,y-radius); ++v; v->set(x-radius,y-radius); ++v;
v->set(x+radius,y-radius); ++v; v->set(x+radius,y-radius); ++v;
v->set(x+radius,y+radius); ++v; v->set(x+radius,y+radius); ++v;
skipping to change at line 384 skipping to change at line 401
glTexCoord2i(1,0); glVertex2f(x+rmag,y-rmag) ; glTexCoord2i(1,0); glVertex2f(x+rmag,y-rmag) ;
glTexCoord2i(1,1); glVertex2f(x+rmag,y+rmag) ; glTexCoord2i(1,1); glVertex2f(x+rmag,y+rmag) ;
glTexCoord2i(0,1); glVertex2f(x-rmag,y+rmag) ; glTexCoord2i(0,1); glVertex2f(x-rmag,y+rmag) ;
glEnd(); glEnd();
} }
++nbPointSources; ++nbPointSources;
if (nbPointSources>=maxPointSources) if (nbPointSources>=maxPointSources)
{ {
// Flush the buffer (draw all buffered stars) // Flush the buffer (draw all buffered stars)
const StelPainter* savePainter = sPainter;
postDrawPointSource(); postDrawPointSource();
sPainter = savePainter;
} }
} }
return true; return true;
} }
void SkyDrawer::preDrawSky3dModel(double illuminatedArea, float mag, bool l
ighting)
{
// Set the main source of light to be the sun
const Vec3d sunPos = core->getNavigation()->getHelioToEyeMat()*Vec3d
(0,0,0);
glLightfv(GL_LIGHT0,GL_POSITION,Vec4f(sunPos[0],sunPos[1],sunPos[2],
1.f));
if (lighting)
{
glEnable(GL_LIGHTING);
const float diffuse[4] = {2.,2.,2.,1};
glLightfv(GL_LIGHT0,GL_DIFFUSE, diffuse);
}
else
{
glDisable(GL_LIGHTING);
glColor3fv(Vec3f(1.f,1.f,1.f));
}
}
// Terminate drawing of a 3D model, draw the halo // Terminate drawing of a 3D model, draw the halo
void SkyDrawer::postDrawSky3dModel(double x, double y, double illuminatedAr ea, float mag, const Vec3f& color) void StelSkyDrawer::postDrawSky3dModel(double x, double y, double illuminat edArea, float mag, const StelPainter* painter, const Vec3f& color)
{ {
Q_ASSERT(painter);
Q_ASSERT(sPainter==NULL);
glDisable(GL_LIGHTING); glDisable(GL_LIGHTING);
const float pixPerRad = core->getProjection()->getPixelPerRadAtCente r(); const float pixPerRad = core->getProjection(StelCore::FrameJ2000)->g etPixelPerRadAtCenter();
// Assume a disk shape // Assume a disk shape
float pixRadius = std::sqrt(illuminatedArea/(60.*60.)*M_PI/180.*M_PI /180.*(pixPerRad*pixPerRad))/M_PI; float pixRadius = std::sqrt(illuminatedArea/(60.*60.)*M_PI/180.*M_PI /180.*(pixPerRad*pixPerRad))/M_PI;
bool noStarHalo = false; bool noStarHalo = false;
if (mag<-15.f) if (mag<-15.f)
{ {
// Sun, halo size varies in function of the magnitude becaus e sun as seen from pluto should look dimmer // Sun, halo size varies in function of the magnitude becaus e sun as seen from pluto should look dimmer
// as the sun as seen from earth // as the sun as seen from earth
texSunHalo->bind(); texSunHalo->bind();
skipping to change at line 480 skipping to change at line 482
if (pixRadius>tStart && pixRadius<tStop) if (pixRadius>tStart && pixRadius<tStop)
{ {
rcm[1]=(tStop-pixRadius)/(tStop-tStart); rcm[1]=(tStop-pixRadius)/(tStop-tStart);
} }
if (truncated && flagLuminanceAdaptation) if (truncated && flagLuminanceAdaptation)
{ {
float wl = findWorldLumForMag(mag, rcm[0]); float wl = findWorldLumForMag(mag, rcm[0]);
if (wl>0) if (wl>0)
{ {
reportLuminanceInFov(qMin(700., qMin((double)wl/50, const double f = core->getMovementMgr()->getCurrentF
(60.*60.)/(prj->getFov()*prj->getFov())*6.))); ov();
reportLuminanceInFov(qMin(700., qMin((double)wl/50,
(60.*60.)/(f*f)*6.)));
} }
} }
if (!noStarHalo) if (!noStarHalo)
{ {
preDrawPointSource(); preDrawPointSource(painter);
drawPointSource(x,y,rcm,color); drawPointSource(x,y,rcm,color);
postDrawPointSource(); postDrawPointSource();
} }
flagStarTwinkle=save; flagStarTwinkle=save;
} }
float SkyDrawer::findWorldLumForMag(float mag, float targetRadius) float StelSkyDrawer::findWorldLumForMag(float mag, float targetRadius)
{ {
const float saveLum = eye->getWorldAdaptationLuminance(); // s ave const float saveLum = eye->getWorldAdaptationLuminance(); // s ave
// Compute the luminance by dichotomy // Compute the luminance by dichotomy
float a=0.001f; float a=0.001f;
float b=500000.f; float b=500000.f;
float rcmag[2]; float rcmag[2];
rcmag[0]=-99; rcmag[0]=-99;
float curLum = 500.f; float curLum = 500.f;
int safety=0; int safety=0;
skipping to change at line 541 skipping to change at line 544
break; break;
} }
} }
eye->setWorldAdaptationLuminance(saveLum); // restore eye->setWorldAdaptationLuminance(saveLum); // restore
return curLum; return curLum;
} }
// Report that an object of luminance lum is currently displayed // Report that an object of luminance lum is currently displayed
void SkyDrawer::reportLuminanceInFov(double lum, bool fastAdaptation) void StelSkyDrawer::reportLuminanceInFov(double lum, bool fastAdaptation)
{ {
if (lum > maxLum) if (lum > maxLum)
{ {
if (oldLum<0) if (oldLum<0)
oldLum=lum; oldLum=lum;
// Use a log law for smooth transitions // Use a log law for smooth transitions
if (fastAdaptation==true && lum>oldLum) if (fastAdaptation==true && lum>oldLum)
{ {
maxLum = lum; maxLum = lum;
} }
else else
{ {
float transitionSpeed = 0.2f; float transitionSpeed = 0.2f;
maxLum = std::exp(std::log(oldLum)+(std::log(lum)-st d::log(oldLum))* qMin(1.f, 1.f/StelApp::getInstance().getFps()/transitionSp eed)); maxLum = std::exp(std::log(oldLum)+(std::log(lum)-st d::log(oldLum))* qMin(1.f, 1.f/StelApp::getInstance().getFps()/transitionSp eed));
} }
} }
} }
void SkyDrawer::preDraw() void StelSkyDrawer::preDraw()
{ {
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 disapear at about the limit given b y the bortle scale // Set the parameters so that the stars disapear at about the limit given b y the bortle scale
// See http://en.wikipedia.org/wiki/Bortle_Dark-Sky_Scale // See http://en.wikipedia.org/wiki/Bortle_Dark-Sky_Scale
void SkyDrawer::setBortleScale(int bIndex) void StelSkyDrawer::setBortleScale(int bIndex)
{ {
// Associate the Bortle index (1 to 9) to inScale value // Associate the Bortle index (1 to 9) to inScale value
if (bIndex<1) if (bIndex<1)
{ {
qWarning() << "WARING: Bortle scale index range is [1;9], gi ven" << bIndex; qWarning() << "WARING: Bortle scale index range is [1;9], gi ven" << bIndex;
bIndex = 1; bIndex = 1;
} }
if (bIndex>9) if (bIndex>9)
{ {
qWarning() << "WARING: Bortle scale index range is [1;9], gi ven" << bIndex; qWarning() << "WARING: Bortle scale index range is [1;9], gi ven" << bIndex;
skipping to change at line 593 skipping to change at line 596
bortleScaleIndex = bIndex; bortleScaleIndex = bIndex;
// 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.45, 1.55, 1.0, 0.63, 0.40 , 0.24, 0.23, 0.145, 0.09};
setInputScale(bortleToInScale[bIndex-1]); setInputScale(bortleToInScale[bIndex-1]);
} }
// Old colors // Old colors
// Vec3f SkyDrawer::colorTable[128] = { // Vec3f StelSkyDrawer::colorTable[128] = {
// Vec3f(0.587877,0.755546,1.000000), // Vec3f(0.587877,0.755546,1.000000),
// Vec3f(0.609856,0.750638,1.000000), // Vec3f(0.609856,0.750638,1.000000),
// Vec3f(0.624467,0.760192,1.000000), // Vec3f(0.624467,0.760192,1.000000),
// Vec3f(0.639299,0.769855,1.000000), // Vec3f(0.639299,0.769855,1.000000),
// Vec3f(0.654376,0.779633,1.000000), // Vec3f(0.654376,0.779633,1.000000),
// Vec3f(0.669710,0.789527,1.000000), // Vec3f(0.669710,0.789527,1.000000),
// Vec3f(0.685325,0.799546,1.000000), // Vec3f(0.685325,0.799546,1.000000),
// Vec3f(0.701229,0.809688,1.000000), // Vec3f(0.701229,0.809688,1.000000),
// Vec3f(0.717450,0.819968,1.000000), // Vec3f(0.717450,0.819968,1.000000),
// Vec3f(0.733991,0.830383,1.000000), // Vec3f(0.733991,0.830383,1.000000),
skipping to change at line 725 skipping to change at line 728
// Vec3f(1.000000,0.384653,0.000000), // Vec3f(1.000000,0.384653,0.000000),
// Vec3f(1.000000,0.380818,0.000000), // Vec3f(1.000000,0.380818,0.000000),
// Vec3f(1.000000,0.376979,0.000000), // Vec3f(1.000000,0.376979,0.000000),
// Vec3f(1.000000,0.373166,0.000000), // Vec3f(1.000000,0.373166,0.000000),
// Vec3f(1.000000,0.369322,0.000000), // Vec3f(1.000000,0.369322,0.000000),
// Vec3f(1.000000,0.365506,0.000000), // Vec3f(1.000000,0.365506,0.000000),
// Vec3f(1.000000,0.361692,0.000000), // Vec3f(1.000000,0.361692,0.000000),
// }; // };
// New colors // New colors
Vec3f SkyDrawer::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),
Vec3f(0.635490,0.737255,1.000000), Vec3f(0.635490,0.737255,1.000000),
Vec3f(0.651059,0.749673,1.000000), Vec3f(0.651059,0.749673,1.000000),
Vec3f(0.666627,0.762092,1.000000), Vec3f(0.666627,0.762092,1.000000),
Vec3f(0.682196,0.774510,1.000000), Vec3f(0.682196,0.774510,1.000000),
skipping to change at line 867 skipping to change at line 870
{ {
return ((x<=0.0) ? 0.0 : exp(gamma*log(x))); return ((x<=0.0) ? 0.0 : exp(gamma*log(x)));
} }
static Vec3f Gamma(double gamma,const Vec3f &x) static Vec3f Gamma(double gamma,const Vec3f &x)
{ {
return Vec3f(Gamma(gamma,x[0]),Gamma(gamma,x[1]),Gamma(gamma,x[2])); return Vec3f(Gamma(gamma,x[0]),Gamma(gamma,x[1]),Gamma(gamma,x[2]));
} }
// Load B-V conversion parameters from config file // Load B-V conversion parameters from config file
void SkyDrawer::initColorTableFromConfigFile(QSettings* conf) void StelSkyDrawer::initColorTableFromConfigFile(QSettings* conf)
{ {
std::map<float,Vec3f> color_map; std::map<float,Vec3f> color_map;
for (float bV=-0.5f;bV<=4.0f;bV+=0.01) for (float bV=-0.5f;bV<=4.0f;bV+=0.01)
{ {
char entry[256]; char entry[256];
sprintf(entry,"bv_color_%+5.2f",bV); sprintf(entry,"bv_color_%+5.2f",bV);
const QStringList s(conf->value(QString("stars/") + entry).t oStringList()); const QStringList s(conf->value(QString("stars/") + entry).t oStringList());
if (!s.isEmpty()) if (!s.isEmpty())
{ {
Vec3f c; Vec3f c;
skipping to change at line 890 skipping to change at line 893
else else
c =StelUtils::strToVec3f(s); c =StelUtils::strToVec3f(s);
color_map[bV] = Gamma(eye->getDisplayGamma(),c); color_map[bV] = Gamma(eye->getDisplayGamma(),c);
} }
} }
if (color_map.size() > 1) if (color_map.size() > 1)
{ {
for (int i=0;i<128;i++) for (int i=0;i<128;i++)
{ {
const float bV = SkyDrawer::indexToBV(i); const float bV = StelSkyDrawer::indexToBV(i);
std::map<float,Vec3f>::const_iterator greater(color_ map.upper_bound(bV)); std::map<float,Vec3f>::const_iterator greater(color_ map.upper_bound(bV));
if (greater == color_map.begin()) if (greater == color_map.begin())
{ {
colorTable[i] = greater->second; colorTable[i] = greater->second;
} }
else else
{ {
std::map<float,Vec3f>::const_iterator less(g reater);--less; std::map<float,Vec3f>::const_iterator less(g reater);--less;
if (greater == color_map.end()) if (greater == color_map.end())
{ {
 End of changes. 45 change blocks. 
68 lines changed or deleted 70 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/