MilkyWay.cpp   MilkyWay.cpp 
skipping to change at line 22 skipping to change at line 22
* 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., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA. * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA.
*/ */
#include "MilkyWay.hpp" #include "MilkyWay.hpp"
#include "StelFader.hpp" #include "StelFader.hpp"
#include "renderer/StelGeometryBuilder.hpp" #include "StelTexture.hpp"
#include "renderer/StelRenderer.hpp"
#include "renderer/StelTextureNew.hpp"
#include "StelUtils.hpp" #include "StelUtils.hpp"
#include "StelFileMgr.hpp"
#include "StelProjector.hpp" #include "StelProjector.hpp"
#include "StelToneReproducer.hpp" #include "StelToneReproducer.hpp"
#include "StelApp.hpp" #include "StelApp.hpp"
#include "StelTextureMgr.hpp"
#include "StelCore.hpp" #include "StelCore.hpp"
#include "StelSkyDrawer.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() MilkyWay::MilkyWay()
: tex(NULL) : color(1.f, 1.f, 1.f)
, color(1.f, 1.f, 1.f) , intensity(1.)
, skySphere(NULL) , vertexArray()
{ {
setObjectName("MilkyWay"); setObjectName("MilkyWay");
fader = new LinearFader(); fader = new LinearFader();
} }
MilkyWay::~MilkyWay() MilkyWay::~MilkyWay()
{ {
delete fader; delete fader;
fader = NULL; fader = NULL;
if(NULL != tex) delete vertexArray;
{ vertexArray = NULL;
delete tex;
tex = NULL;
}
if(NULL != skySphere)
{
delete skySphere;
skySphere = NULL;
}
} }
void MilkyWay::init() void MilkyWay::init()
{ {
QSettings* conf = StelApp::getInstance().getSettings(); QSettings* conf = StelApp::getInstance().getSettings();
Q_ASSERT(conf); Q_ASSERT(conf);
tex = StelApp::getInstance().getTextureManager().createTexture(StelF ileMgr::getInstallationDir()+"/textures/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.f).toFloat()) ; setIntensity(conf->value("astro/milky_way_intensity",1.f).toFloat()) ;
const SphereParams params = SphereParams(1.0f).resolution(20, 20).or vertexArray = new StelVertexArray(StelPainter::computeSphereNoLight(
ientInside(); 1.f,1.f,20,20,1));
skySphere = StelGeometryBuilder().buildSphereUnlit(params);
} }
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() const {return *fader;} bool MilkyWay::getFlagShow() const {return *fader;}
void MilkyWay::draw(StelCore* core, class StelRenderer* renderer) void MilkyWay::draw(StelCore* core)
{ {
if (!getFlagShow()) if (!getFlagShow())
return; return;
StelProjector::ModelViewTranformP transfo = core->getJ2000ModelViewT ransform(); StelProjector::ModelViewTranformP transfo = core->getJ2000ModelViewT ransform();
transfo->combine(Mat4d::xrotation(M_PI/180.*23.)* transfo->combine(Mat4d::xrotation(M_PI/180.*23.)*
Mat4d::yrotation(M_PI/180.*120.)* Mat4d::yrotation(M_PI/180.*120.)*
Mat4d::zrotation(M_PI/180.*7.)); Mat4d::zrotation(M_PI/180.*7.));
if(NULL == tex)
{
tex = renderer->createTexture("textures/milkyway.png");
}
const StelProjectorP prj = core->getProjection(transfo); const StelProjectorP prj = core->getProjection(transfo);
StelToneReproducer* eye = core->getToneReproducer(); StelToneReproducer* eye = core->getToneReproducer();
Q_ASSERT_X(NULL != tex, Q_FUNC_INFO, "A texture must be loaded befor e calling this"); Q_ASSERT(tex); // A texture must be loaded before calling this
// This color corresponds to the night blue scotopic color = 0.25, 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)
Vec4f c = StelApp::getInstance().getVisionModeNight() Vec3f c = Vec3f(0.34165f, 0.429666f, 0.63586f);
? Vec4f(0.34165f, 0.0f, 0.0f, 1.0f)
: Vec4f(0.34165f, 0.429666f, 0.63586f, 1.0f);
const float lum = core->getSkyDrawer()->surfacebrightnessToLuminance (13.5f); float lum = core->getSkyDrawer()->surfacebrightnessToLuminance(13.5f );
// 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.38f, aLum * 2.0f); aLum = qMin(0.38f, aLum*2.f);
// 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;
c[0] = std::max(c[0], 0.0f); if (c[0]<0) c[0]=0;
c[1] = std::max(c[1], 0.0f); if (c[1]<0) c[1]=0;
c[2] = std::max(c[2], 0.0f); if (c[2]<0) c[2]=0;
c[3] = 1.0f;
StelPainter sPainter(prj);
renderer->setGlobalColor(c[0], c[1], c[2]); sPainter.setColor(c[0],c[1],c[2]);
renderer->setCulledFaces(CullFace_Back); glEnable(GL_CULL_FACE);
renderer->setBlendMode(BlendMode_None); sPainter.enableTexture2d(true);
glDisable(GL_BLEND);
tex->bind(); tex->bind();
sPainter.drawStelVertexArray(*vertexArray);
skySphere->draw(renderer, prj); glDisable(GL_CULL_FACE);
renderer->setCulledFaces(CullFace_None);
} }
 End of changes. 19 change blocks. 
47 lines changed or deleted 33 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/