MilkyWay.cpp   MilkyWay.cpp 
skipping to change at line 21 skipping to change at line 21
* 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 "MilkyWay.hpp" #include "MilkyWay.hpp"
#include "Fader.hpp" #include "StelFader.hpp"
#include "STexture.hpp" #include "StelTexture.hpp"
#include "StelUtils.hpp" #include "StelUtils.hpp"
#include "Navigator.hpp" #include "StelNavigator.hpp"
#include "Projector.hpp" #include "StelProjector.hpp"
#include "ToneReproducer.hpp" #include "StelToneReproducer.hpp"
#include "StelApp.hpp" #include "StelApp.hpp"
#include "StelTextureMgr.hpp" #include "StelTextureMgr.hpp"
#include "StelCore.hpp" #include "StelCore.hpp"
#include "SkyDrawer.hpp" #include "StelSkyDrawer.hpp"
#include "StelPainter.hpp"
#include <QDebug> #include <QDebug>
#include <QSettings> #include <QSettings>
// Class which manages the displaying of the Milky Way // Class which manages the displaying of the Milky Way
MilkyWay::MilkyWay() : radius(1.f), color(1.f, 1.f, 1.f) MilkyWay::MilkyWay() : radius(1.f), color(1.f, 1.f, 1.f)
{ {
setObjectName("MilkyWay"); setObjectName("MilkyWay");
fader = new LinearFader(); fader = new LinearFader();
} }
MilkyWay::~MilkyWay() MilkyWay::~MilkyWay()
{ {
delete fader; delete fader;
fader = NULL; fader = NULL;
} }
void MilkyWay::init() void MilkyWay::init()
{ {
QSettings* conf = StelApp::getInstance().getSettings(); QSettings* conf = StelApp::getInstance().getSettings();
assert(conf); Q_ASSERT(conf);
setTexture("milkyway.png"); setTexture("milkyway.png");
setFlagShow(conf->value("astro/flag_milky_way").toBool()); setFlagShow(conf->value("astro/flag_milky_way").toBool());
setIntensity(conf->value("astro/milky_way_intensity",1.).toDouble()) ; setIntensity(conf->value("astro/milky_way_intensity",1.).toDouble()) ;
} }
void MilkyWay::setTexture(const QString& texFile) void MilkyWay::setTexture(const QString& texFile)
{ {
StelApp::getInstance().getTextureManager().setDefaultParams(); StelApp::getInstance().getTextureManager().setDefaultParams();
tex = StelApp::getInstance().getTextureManager().createTexture(texFi le); tex = StelApp::getInstance().getTextureManager().createTexture(texFi le);
} }
void MilkyWay::update(double deltaTime) {fader->update((int)(deltaTime*1000 ));} void MilkyWay::update(double deltaTime) {fader->update((int)(deltaTime*1000 ));}
void MilkyWay::setFlagShow(bool b){*fader = b;} void MilkyWay::setFlagShow(bool b){*fader = b;}
bool MilkyWay::getFlagShow(void) const {return *fader;} bool MilkyWay::getFlagShow(void) const {return *fader;}
void MilkyWay::draw(StelCore* core) void MilkyWay::draw(StelCore* core)
{ {
Navigator* nav = core->getNavigation(); StelNavigator* nav = core->getNavigator();
Projector* prj = core->getProjection(); const StelProjectorP prj = core->getProjection(nav->getJ2000ModelVie
ToneReproducer* eye = core->getToneReproducer(); wMat()*
Mat4d::xrotation(M_PI/180*23)*
Mat4d::yrotation(M_PI/180*120)*
Mat4d::zrotation(M_PI/180*7));
StelToneReproducer* eye = core->getToneReproducer();
assert(tex); // A texture must be loaded before calling this Q_ASSERT(tex); // A texture must be loaded before calling this
// This RGB color corresponds to the night blue scotopic color = 0.2 5, 0.25 in xyY mode. // This RGB color corresponds to the night blue scotopic color = 0.2 5, 0.25 in xyY mode.
// since milky way is always seen white RGB value in the texture (1. 0,1.0,1.0) // since milky way is always seen white RGB value in the texture (1. 0,1.0,1.0)
Vec3f c(0.34165, 0.429666, 0.63586); Vec3f c;
if (StelApp::getInstance().getVisionModeNight())
c = Vec3f(0.34165, 0, 0);
else
c = Vec3f(0.34165, 0.429666, 0.63586);
float lum = core->getSkyDrawer()->surfacebrightnessToLuminance(13.5) ; float lum = core->getSkyDrawer()->surfacebrightnessToLuminance(13.5) ;
// 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.38, aLum*2.); aLum = qMin(0.38, aLum*2.);
c*=aLum; c*=aLum;
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;
StelPainter sPainter(prj);
glColor3fv(c); glColor3fv(c);
glEnable(GL_CULL_FACE); glEnable(GL_CULL_FACE);
glEnable(GL_TEXTURE_2D); glEnable(GL_TEXTURE_2D);
glDisable(GL_BLEND); glDisable(GL_BLEND);
tex->bind(); tex->bind();
sPainter.sSphere(radius,1.0,20,20,1);
prj->setCustomFrame(nav->getJ2000ToEyeMat()*
Mat4d::xrotation(M_PI/180*23)*
Mat4d::yrotation(M_PI/180*120)*
Mat4d::zrotation(M_PI/180*7));
prj->sSphere(radius,1.0,20,20,1);
glDisable(GL_CULL_FACE); glDisable(GL_CULL_FACE);
} }
 End of changes. 9 change blocks. 
19 lines changed or deleted 26 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/