Landscape.cpp   Landscape.cpp 
skipping to change at line 29 skipping to change at line 29
*/ */
#include "Landscape.hpp" #include "Landscape.hpp"
#include "StelApp.hpp" #include "StelApp.hpp"
#include "StelTextureMgr.hpp" #include "StelTextureMgr.hpp"
#include "StelFileMgr.hpp" #include "StelFileMgr.hpp"
#include "StelIniParser.hpp" #include "StelIniParser.hpp"
#include "StelLocation.hpp" #include "StelLocation.hpp"
#include "StelCore.hpp" #include "StelCore.hpp"
#include "StelPainter.hpp" #include "StelPainter.hpp"
#include "StelLocaleMgr.hpp"
#include <QDebug> #include <QDebug>
#include <QSettings> #include <QSettings>
#include <QVarLengthArray> #include <QVarLengthArray>
#include <QFile> #include <QFile>
#include <QDir> #include <QDir>
#include <QtAlgorithms> #include <QtAlgorithms>
Landscape::Landscape(float _radius) Landscape::Landscape(float _radius)
: radius(_radius) : radius(_radius)
, minBrightness(-1.) , minBrightness(-1.)
, landscapeBrightness(1.) , landscapeBrightness(1.)
, lightScapeBrightness(0.) , lightScapeBrightness(0.)
, rows(20) , rows(20)
, cols(40) , cols(40)
, angleRotateZ(0.) , angleRotateZ(0.)
, angleRotateZOffset(0.) , angleRotateZOffset(0.)
, sinMinAltitudeLimit(-0.035) //sin(-2 degrees))
, defaultBortleIndex(-1) , defaultBortleIndex(-1)
, defaultFogSetting(-1) , defaultFogSetting(-1)
, defaultExtinctionCoefficient(-1.) , defaultExtinctionCoefficient(-1.)
, defaultTemperature(-1000.) , defaultTemperature(-1000.)
, defaultPressure(-2.) , defaultPressure(-2.)
, horizonPolygon(NULL) , horizonPolygon(NULL)
, fontSize(18)
{ {
validLandscape = 0; validLandscape = 0;
} }
Landscape::~Landscape() Landscape::~Landscape()
{} {}
// Load attributes common to all landscapes // Load attributes common to all landscapes
void Landscape::loadCommon(const QSettings& landscapeIni, const QString& la ndscapeId) void Landscape::loadCommon(const QSettings& landscapeIni, const QString& la ndscapeId)
{ {
skipping to change at line 117 skipping to change at line 120
defaultFogSetting = landscapeIni.value("location/display_fog ", -1).toInt(); defaultFogSetting = landscapeIni.value("location/display_fog ", -1).toInt();
defaultExtinctionCoefficient = landscapeIni.value("location/ atmospheric_extinction_coefficient", -1.0).toDouble(); defaultExtinctionCoefficient = landscapeIni.value("location/ atmospheric_extinction_coefficient", -1.0).toDouble();
defaultTemperature = landscapeIni.value("location/atmospheri c_temperature", -1000.0).toDouble(); defaultTemperature = landscapeIni.value("location/atmospheri c_temperature", -1000.0).toDouble();
defaultPressure = landscapeIni.value("location/atmospheric_p ressure", -2.0).toDouble(); // -2=no change! [-1=computeFromAltitude] defaultPressure = landscapeIni.value("location/atmospheric_p ressure", -2.0).toDouble(); // -2=no change! [-1=computeFromAltitude]
} }
// Set minimal brightness for landscape // Set minimal brightness for landscape
minBrightness = landscapeIni.value("landscape/minimal_brightness", - 1.0).toDouble(); minBrightness = landscapeIni.value("landscape/minimal_brightness", - 1.0).toDouble();
// set a minimal altitude which the landscape covers. (new in 0.14)
// This is to allow landscapes with "holes" in the ground (space sta
tion?) (Bug lp:1469407)
sinMinAltitudeLimit = (float) std::sin(M_PI/180.0 * landscapeIni.val
ue("landscape/minimal_altitude", -2.0).toDouble());
// This is now optional for all classes, for mixing with a photo hor izon: // This is now optional for all classes, for mixing with a photo hor izon:
// they may have different offsets, like a south-centered pano and a geographically-oriented polygon. // they may have different offsets, like a south-centered pano and a geographically-oriented polygon.
// In case they are aligned, we can use one value angle_rotatez, or define the polygon rotation individually. // In case they are aligned, we can use one value angle_rotatez, or define the polygon rotation individually.
if (landscapeIni.contains("landscape/polygonal_horizon_list")) if (landscapeIni.contains("landscape/polygonal_horizon_list"))
{ {
createPolygonalHorizon( createPolygonalHorizon(
StelFileMgr::findFile("landscapes/" + landscapeId + "/" + landscapeIni.value("landscape/polygonal_horizon_list" ).toString()), StelFileMgr::findFile("landscapes/" + landscapeId + "/" + landscapeIni.value("landscape/polygonal_horizon_list" ).toString()),
landscapeIni.value("landscape/polygo nal_angle_rotatez", 0.f).toFloat(), landscapeIni.value("landscape/polygo nal_angle_rotatez", 0.f).toFloat(),
landscapeIni.value("landscape/polygo nal_horizon_list_mode", "azDeg_altDeg").toString()); landscapeIni.value("landscape/polygo nal_horizon_list_mode", "azDeg_altDeg").toString());
// This line can then be drawn in all classes with the color specified here. If not specified, don't draw it! (flagged by negative red) // This line can then be drawn in all classes with the color specified here. If not specified, don't draw it! (flagged by negative red)
horizonPolygonLineColor=StelUtils::strToVec3f( landscapeIni. value("landscape/horizon_line_color", "-1,0,0" ).toString()); horizonPolygonLineColor=StelUtils::strToVec3f(landscapeIni.v alue("landscape/horizon_line_color", "-1,0,0" ).toString());
} }
// we must get label color, this is global. (No sense to make that p
er-landscape!)
QSettings *config = StelApp::getInstance().getSettings();
labelColor=StelUtils::strToVec3f(config->value("landscape/label_colo
r", "0.2,0.8,0.2").toString());
fontSize=config->value("landscape/label_font_size", 18).toInt();
loadLabels(landscapeId);
} }
void Landscape::createPolygonalHorizon(const QString& lineFileName, const f loat polyAngleRotateZ, const QString &listMode ) void Landscape::createPolygonalHorizon(const QString& lineFileName, const f loat polyAngleRotateZ, const QString &listMode )
{ {
// qDebug() << _name << " " << _fullpath << " " << _lineFileName ; // qDebug() << _name << " " << _fullpath << " " << _lineFileName ;
QStringList horizonModeList; QStringList horizonModeList;
horizonModeList << "azDeg_altDeg" << "azDeg_zdDeg" << "azRad_altRad" << "azRad_zdRad" << "azGrad_zdGrad" << "azGrad_zdGrad"; horizonModeList << "azDeg_altDeg" << "azDeg_zdDeg" << "azRad_altRad" << "azRad_zdRad" << "azGrad_zdGrad" << "azGrad_zdGrad";
const horizonListMode coordMode=(horizonListMode) horizonModeList.in dexOf(listMode); const horizonListMode coordMode=(horizonListMode) horizonModeList.in dexOf(listMode);
skipping to change at line 225 skipping to change at line 237
#include <iostream> #include <iostream>
const QString Landscape::getTexturePath(const QString& basename, const QStr ing& landscapeId) const const QString Landscape::getTexturePath(const QString& basename, const QStr ing& landscapeId) const
{ {
// look in the landscape directory first, and if not found default t o global textures directory // look in the landscape directory first, and if not found default t o global textures directory
QString path = StelFileMgr::findFile("landscapes/" + landscapeId + " /" + basename); QString path = StelFileMgr::findFile("landscapes/" + landscapeId + " /" + basename);
if (path.isEmpty()) if (path.isEmpty())
path = StelFileMgr::findFile("textures/" + basename); path = StelFileMgr::findFile("textures/" + basename);
return path; return path;
} }
// find optional file and fill landscapeLabels list.
void Landscape::loadLabels(const QString& landscapeId)
{
// in case we have labels and this is called for a retranslation, cl
ean list first.
landscapeLabels.clear();
QString lang, descFileName, locLabelFileName, engLabelFileName;
lang = StelApp::getInstance().getLocaleMgr().getAppLanguage();
locLabelFileName = StelFileMgr::findFile("landscapes/" + landscapeId
, StelFileMgr::Directory) + "/gazetteer." + lang + ".utf8";
engLabelFileName = StelFileMgr::findFile("landscapes/" + landscapeId
, StelFileMgr::Directory) + "/gazetteer.en.utf8";
// Check the file with full name of locale
if (!QFileInfo(locLabelFileName).exists())
{
// File not found. What about short name of locale?
lang = lang.split("_").at(0);
locLabelFileName = StelFileMgr::findFile("landscapes/" + lan
dscapeId, StelFileMgr::Directory) + "/gazetteer." + lang + ".utf8";
}
// Get localized or at least English description for landscape
if (QFileInfo(locLabelFileName).exists())
descFileName = locLabelFileName;
else if (QFileInfo(engLabelFileName).exists())
descFileName = engLabelFileName;
else
return;
// We have found some file now.
QFile file(descFileName);
if(file.open(QIODevice::ReadOnly | QIODevice::Text))
{
QTextStream in(&file);
in.setCodec("UTF-8");
while (!in.atEnd())
{
QString line=in.readLine();
// TODO: Read entries, construct vectors, put in lis
t.
if (line.startsWith('#'))
continue;
QStringList parts=line.split('|');
if (parts.count() != 5)
{
qWarning() << "Invalid line in landscape" <<
descFileName << ":" << line;
continue;
}
LandscapeLabel newLabel;
newLabel.name=parts.at(4).trimmed();
StelUtils::spheToRect((180.0f-parts.at(0).toFloat())
*M_PI/180.0, parts.at(1).toFloat()*M_PI/180.0, newLabel.featurePoint);
StelUtils::spheToRect((180.0f-parts.at(0).toFloat()
- parts.at(3).toFloat())*M_PI/180.0, (parts.at(1).toFloat() + parts.at(2).t
oFloat())*M_PI/180.0, newLabel.labelPoint);
landscapeLabels.append(newLabel);
//qDebug() << "Added landscape label " << newLabel.n
ame;
}
file.close();
}
}
void Landscape::drawLabels(StelCore* core, StelPainter *painter)
{
if (landscapeLabels.length()==0) // no labels
return;
if (labelFader.getInterstate() < 0.0001f) // switched off
return;
// We must reset painter to pure altaz coordinates without pano-base
d rotation
const StelProjectorP prj = core->getProjection(StelCore::FrameAltAz,
StelCore::RefractionOff);
painter->setProjector(prj);
QFont font;
font.setPixelSize(fontSize);
painter->setFont(font);
QFontMetrics fm(font);
painter->setColor(labelColor[0], labelColor[1], labelColor[2], label
Fader.getInterstate()*landFader.getInterstate());
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glEnable(GL_BLEND);
glDisable(GL_TEXTURE_2D);
// OpenGL ES 2.0 doesn't have GL_LINE_SMOOTH. But it looks much bett
er.
#ifdef GL_LINE_SMOOTH
if (QOpenGLContext::currentContext()->format().renderableType()==QSu
rfaceFormat::OpenGL)
glEnable(GL_LINE_SMOOTH);
#endif
for (int i = 0; i < landscapeLabels.size(); ++i)
{
// in case of gravityLabels, we cannot shift-adjust centered
placename, sorry!
if (prj->getFlagGravityLabels())
{
painter->drawText(landscapeLabels.at(i).labelPoint,
landscapeLabels.at(i).name, 0, 0, 0, false);
}
else
{
int textWidth=fm.width(landscapeLabels.at(i).name);
painter->drawText(landscapeLabels.at(i).labelPoint,
landscapeLabels.at(i).name, 0, -textWidth/2, 2, true);
}
painter->drawGreatCircleArc(landscapeLabels.at(i).featurePoi
nt, landscapeLabels.at(i).labelPoint, NULL);
}
#ifdef GL_LINE_SMOOTH
if (QOpenGLContext::currentContext()->format().renderableType()==QSu
rfaceFormat::OpenGL)
glDisable(GL_LINE_SMOOTH);
#endif
glDisable(GL_BLEND);
}
LandscapeOldStyle::LandscapeOldStyle(float _radius) LandscapeOldStyle::LandscapeOldStyle(float _radius)
: Landscape(_radius) : Landscape(_radius)
, sideTexs(NULL) , sideTexs(NULL)
, nbSideTexs(0) , nbSideTexs(0)
, nbSide(0) , nbSide(0)
, sides(NULL) , sides(NULL)
, nbDecorRepeat(0) , nbDecorRepeat(0)
, fogAltAngle(0.) , fogAltAngle(0.)
, fogAngleShift(0.) , fogAngleShift(0.)
, decorAltAngle(0.) , decorAltAngle(0.)
skipping to change at line 257 skipping to change at line 374
delete [] sideTexs; delete [] sideTexs;
sideTexs = NULL; sideTexs = NULL;
} }
if (sides) delete [] sides; if (sides) delete [] sides;
if (sidesImages.size()>0) if (sidesImages.size()>0)
{ {
qDeleteAll(sidesImages); qDeleteAll(sidesImages);
sidesImages.clear(); sidesImages.clear();
} }
landscapeLabels.clear();
} }
void LandscapeOldStyle::load(const QSettings& landscapeIni, const QString& landscapeId) void LandscapeOldStyle::load(const QSettings& landscapeIni, const QString& landscapeId)
{ {
// TODO: put values into hash and call create() method to consolidat e code // TODO: put values into hash and call create() method to consolidat e code
loadCommon(landscapeIni, landscapeId); loadCommon(landscapeIni, landscapeId);
// rows, cols have been loaded already, but with different defaults. // rows, cols have been loaded already, but with different defaults.
// GZ Hey, they are not used altogether! Resolution is constant, bel ow! // GZ Hey, they are not used altogether! Resolution is constant, bel ow!
//rows = landscapeIni.value("landscape/tesselate_rows", 8).toInt(); //rows = landscapeIni.value("landscape/tesselate_rows", 8).toInt();
//cols = landscapeIni.value("landscape/tesselate_cols", 16).toInt(); //cols = landscapeIni.value("landscape/tesselate_cols", 16).toInt();
skipping to change at line 538 skipping to change at line 656
//qDebug() << "drawing line"; //qDebug() << "drawing line";
StelProjector::ModelViewTranformP transfo = core->getAltAzMo delViewTransform(StelCore::RefractionOff); StelProjector::ModelViewTranformP transfo = core->getAltAzMo delViewTransform(StelCore::RefractionOff);
transfo->combine(Mat4d::zrotation(-angleRotateZOffset)); transfo->combine(Mat4d::zrotation(-angleRotateZOffset));
const StelProjectorP prj = core->getProjection(transfo); const StelProjectorP prj = core->getProjection(transfo);
painter.setProjector(prj); painter.setProjector(prj);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
painter.setColor(horizonPolygonLineColor[0], horizonPolygonL ineColor[1], horizonPolygonLineColor[2], landFader.getInterstate()); painter.setColor(horizonPolygonLineColor[0], horizonPolygonL ineColor[1], horizonPolygonLineColor[2], landFader.getInterstate());
painter.drawSphericalRegion(horizonPolygon.data(), StelPaint er::SphericalPolygonDrawModeBoundary); painter.drawSphericalRegion(horizonPolygon.data(), StelPaint er::SphericalPolygonDrawModeBoundary);
} }
//else qDebug() << "no polygon defined"; //else qDebug() << "no polygon defined";
drawLabels(core, &painter);
} }
// Draw the horizon fog // Draw the horizon fog
void LandscapeOldStyle::drawFog(StelCore* core, StelPainter& sPainter) cons t void LandscapeOldStyle::drawFog(StelCore* core, StelPainter& sPainter) cons t
{ {
if (!fogFader.getInterstate()) if (!fogFader.getInterstate())
return; return;
if(!landFader.getInterstate()) if(!landFader.getInterstate())
return; return;
if (!(core->getSkyDrawer()->getFlagHasAtmosphere())) if (!(core->getSkyDrawer()->getFlagHasAtmosphere()))
skipping to change at line 637 skipping to change at line 757
} }
// Else, sample the images... // Else, sample the images...
const float alt_rad = std::asin(azalt[2]); // sampled altitude, rad ians const float alt_rad = std::asin(azalt[2]); // sampled altitude, rad ians
if (alt_rad < decorAngleShift*M_PI/180.0f) return 1.0f; // below dec or, i.e. certainly opaque ground. if (alt_rad < decorAngleShift*M_PI/180.0f) return 1.0f; // below dec or, i.e. certainly opaque ground.
if (alt_rad > (decorAltAngle+decorAngleShift)*M_PI/180.0f) return 0. 0f; // above decor, i.e. certainly free sky. if (alt_rad > (decorAltAngle+decorAngleShift)*M_PI/180.0f) return 0. 0f; // above decor, i.e. certainly free sky.
if (!calibrated) // the result of this function has no real use here : just complain and return result for math. horizon. if (!calibrated) // the result of this function has no real use here : just complain and return result for math. horizon.
{ {
static QString lastLandscapeName; static QString lastLandscapeName;
if (lastLandscapeName != name) if (lastLandscapeName != name)
{ {
qWarning() << "Dubious result: Landscape \"" << name << "\" not calibrated. Opacity test represents mathematical horizon only." ; qWarning() << "Dubious result: Landscape " << name < < " not calibrated. Opacity test represents mathematical horizon only.";
lastLandscapeName=name; lastLandscapeName=name;
} }
return (azalt[2] > 0 ? 0.0f : 1.0f); return (azalt[2] > 0 ? 0.0f : 1.0f);
} }
float az=atan2(azalt[0], azalt[1]) / M_PI + 0.5f; // -0.5..+1.5 float az=atan2(azalt[0], azalt[1]) / M_PI + 0.5f; // -0.5..+1.5
if (az<0) az+=2.0f; // 0..2 = N.E.S. W.N if (az<0) az+=2.0f; // 0..2 = N.E.S. W.N
// we go to 0..1 domain, it's easier to think. // we go to 0..1 domain, it's easier to think.
const float xShift=angleRotateZ /(2.0f*M_PI); // shift value in -1.. 1 const float xShift=angleRotateZ /(2.0f*M_PI); // shift value in -1.. 1
Q_ASSERT(xShift >= -1.0f); Q_ASSERT(xShift >= -1.0f);
Q_ASSERT(xShift <= 1.0f); Q_ASSERT(xShift <= 1.0f);
skipping to change at line 684 skipping to change at line 804
if (alt_pm1>img_top_pm1) { Q_ASSERT(0); return 0.0f; } // sh ould have been caught above with alt_rad tests if (alt_pm1>img_top_pm1) { Q_ASSERT(0); return 0.0f; } // sh ould have been caught above with alt_rad tests
const float img_bot_pm1 = 1.0f-((90.0f-decorAngleShift) / 90 .0f); // the bottom line in -1..+1 (angular) const float img_bot_pm1 = 1.0f-((90.0f-decorAngleShift) / 90 .0f); // the bottom line in -1..+1 (angular)
if (alt_pm1<img_bot_pm1) { Q_ASSERT(0); return 1.0f; } // sh ould have been caught above with alt_rad tests if (alt_pm1<img_bot_pm1) { Q_ASSERT(0); return 1.0f; } // sh ould have been caught above with alt_rad tests
y_img_1=(alt_pm1-img_bot_pm1)/(img_top_pm1-img_bot_pm1); // the sampled altitude in 0..1 visible image height from bottom y_img_1=(alt_pm1-img_bot_pm1)/(img_top_pm1-img_bot_pm1); // the sampled altitude in 0..1 visible image height from bottom
} }
// x0/y0 is lower left, x1/y1 upper right corner. // x0/y0 is lower left, x1/y1 upper right corner.
float y_baseImg_1 = sides[currentSide].texCoords[1]+ y_img_1*(sides[ currentSide].texCoords[3]-sides[currentSide].texCoords[1]); float y_baseImg_1 = sides[currentSide].texCoords[1]+ y_img_1*(sides[ currentSide].texCoords[3]-sides[currentSide].texCoords[1]);
int y=(1.0-y_baseImg_1)*sidesImages[currentSide]->height(); // pixel Y from top. int y=(1.0-y_baseImg_1)*sidesImages[currentSide]->height(); // pixel Y from top.
QRgb pixVal=sidesImages[currentSide]->pixel(x, y); QRgb pixVal=sidesImages[currentSide]->pixel(x, y);
/*
#ifndef NDEBUG #ifndef NDEBUG
// GZ: please leave the comment available for further development! // GZ: please leave the comment available for further development!
qDebug() << "Oldstyle Landscape sampling: az=" << az*180.0 << "° alt =" << alt_rad*180.0f/M_PI qDebug() << "Oldstyle Landscape sampling: az=" << az*180.0 << "° alt =" << alt_rad*180.0f/M_PI
<< "°, xShift[-1..+1]=" << xShift << " az_phot[0..1 ]=" << az_phot << "°, xShift[-1..+1]=" << xShift << " az_phot[0..1 ]=" << az_phot
<< " --> current side panel " << currentSide << " --> current side panel " << currentSide
<< ", w=" << sidesImages[currentSide]->width() << " h=" << sidesImages[currentSide]->height() << ", w=" << sidesImages[currentSide]->width() << " h=" << sidesImages[currentSide]->height()
<< " --> x:" << x << " y:" << y << " alpha:" << qAl pha(pixVal)/255.0f; << " --> x:" << x << " y:" << y << " alpha:" << qAl pha(pixVal)/255.0f;
#endif #endif
*/
return qAlpha(pixVal)/255.0f; return qAlpha(pixVal)/255.0f;
} }
/////////////////////////////////////////////////////////////////////////// ///////////////////////// /////////////////////////////////////////////////////////////////////////// /////////////////////////
LandscapePolygonal::LandscapePolygonal(float _radius) : Landscape(_radius) LandscapePolygonal::LandscapePolygonal(float _radius) : Landscape(_radius)
{} {}
LandscapePolygonal::~LandscapePolygonal() LandscapePolygonal::~LandscapePolygonal()
{} {
landscapeLabels.clear();
}
void LandscapePolygonal::load(const QSettings& landscapeIni, const QString& landscapeId) void LandscapePolygonal::load(const QSettings& landscapeIni, const QString& landscapeId)
{ {
// loading the polygon has been moved to Landscape::loadCommon(), so that all Landscape classes can use a polygon line. // loading the polygon has been moved to Landscape::loadCommon(), so that all Landscape classes can use a polygon line.
loadCommon(landscapeIni, landscapeId); loadCommon(landscapeIni, landscapeId);
QString type = landscapeIni.value("landscape/type").toString(); QString type = landscapeIni.value("landscape/type").toString();
if(type != "polygonal") if(type != "polygonal")
{ {
qWarning() << "Landscape type mismatch for landscape "<< lan dscapeId << ", expected polygonal, found " << type << ". No landscape in u se.\n"; qWarning() << "Landscape type mismatch for landscape "<< lan dscapeId << ", expected polygonal, found " << type << ". No landscape in u se.\n";
validLandscape = 0; validLandscape = 0;
skipping to change at line 765 skipping to change at line 889
glEnable(GL_LINE_SMOOTH); glEnable(GL_LINE_SMOOTH);
#endif #endif
sPainter.setColor(horizonPolygonLineColor[0], horizonPolygon LineColor[1], horizonPolygonLineColor[2], landFader.getInterstate()); sPainter.setColor(horizonPolygonLineColor[0], horizonPolygon LineColor[1], horizonPolygonLineColor[2], landFader.getInterstate());
sPainter.drawSphericalRegion(horizonPolygon.data(), StelPain ter::SphericalPolygonDrawModeBoundary); sPainter.drawSphericalRegion(horizonPolygon.data(), StelPain ter::SphericalPolygonDrawModeBoundary);
#ifdef GL_LINE_SMOOTH #ifdef GL_LINE_SMOOTH
if (QOpenGLContext::currentContext()->format().renderableTyp e()==QSurfaceFormat::OpenGL) if (QOpenGLContext::currentContext()->format().renderableTyp e()==QSurfaceFormat::OpenGL)
glDisable(GL_LINE_SMOOTH); glDisable(GL_LINE_SMOOTH);
#endif #endif
} }
glDisable(GL_CULL_FACE); glDisable(GL_CULL_FACE);
drawLabels(core, &sPainter);
} }
float LandscapePolygonal::getOpacity(Vec3d azalt) const float LandscapePolygonal::getOpacity(Vec3d azalt) const
{ {
if (angleRotateZOffset!=0.0f) if (angleRotateZOffset!=0.0f)
azalt.transfo4d(Mat4d::zrotation(angleRotateZOffset)); azalt.transfo4d(Mat4d::zrotation(angleRotateZOffset));
if (horizonPolygon->contains(azalt) ) return 1.0f; else return 0 .0f; if (horizonPolygon->contains(azalt) ) return 1.0f; else return 0 .0f;
} }
skipping to change at line 788 skipping to change at line 913
LandscapeFisheye::LandscapeFisheye(float _radius) LandscapeFisheye::LandscapeFisheye(float _radius)
: Landscape(_radius) : Landscape(_radius)
, mapImage(NULL) , mapImage(NULL)
, texFov(360.) , texFov(360.)
{} {}
LandscapeFisheye::~LandscapeFisheye() LandscapeFisheye::~LandscapeFisheye()
{ {
if (mapImage) delete mapImage; if (mapImage) delete mapImage;
landscapeLabels.clear();
} }
void LandscapeFisheye::load(const QSettings& landscapeIni, const QString& l andscapeId) void LandscapeFisheye::load(const QSettings& landscapeIni, const QString& l andscapeId)
{ {
loadCommon(landscapeIni, landscapeId); loadCommon(landscapeIni, landscapeId);
QString type = landscapeIni.value("landscape/type").toString(); QString type = landscapeIni.value("landscape/type").toString();
if(type != "fisheye") if(type != "fisheye")
{ {
qWarning() << "Landscape type mismatch for landscape "<< lan dscapeId << ", expected fisheye, found " << type << ". No landscape in use .\n"; qWarning() << "Landscape type mismatch for landscape "<< lan dscapeId << ", expected fisheye, found " << type << ". No landscape in use .\n";
skipping to change at line 868 skipping to change at line 994
{ {
glBlendFunc(GL_SRC_ALPHA, GL_ONE); glBlendFunc(GL_SRC_ALPHA, GL_ONE);
sPainter.setColor(illumFader.getInterstate()*lightScapeBrigh tness, sPainter.setColor(illumFader.getInterstate()*lightScapeBrigh tness,
illumFader.getInterstate()*lightScapeBrigh tness, illumFader.getInterstate()*lightScapeBrigh tness,
illumFader.getInterstate()*lightScapeBrigh tness, landFader.getInterstate()); illumFader.getInterstate()*lightScapeBrigh tness, landFader.getInterstate());
mapTexIllum->bind(); mapTexIllum->bind();
sPainter.sSphereMap(radius, cols, rows, texFov, 1); sPainter.sSphereMap(radius, cols, rows, texFov, 1);
} }
glDisable(GL_CULL_FACE); glDisable(GL_CULL_FACE);
drawLabels(core, &sPainter);
} }
float LandscapeFisheye::getOpacity(Vec3d azalt) const float LandscapeFisheye::getOpacity(Vec3d azalt) const
{ {
if (angleRotateZOffset!=0.0f) if (angleRotateZOffset!=0.0f)
azalt.transfo4d(Mat4d::zrotation(angleRotateZOffset)); azalt.transfo4d(Mat4d::zrotation(angleRotateZOffset));
// in case we also have a horizon polygon defined, this is trivial a nd fast. // in case we also have a horizon polygon defined, this is trivial a nd fast.
if (horizonPolygon) if (horizonPolygon)
{ {
skipping to change at line 896 skipping to change at line 1023
if (M_PI/2-alt_rad > texFov/2.0 ) return 1.0; // outside fov, in the clamped texture zone: always opaque. if (M_PI/2-alt_rad > texFov/2.0 ) return 1.0; // outside fov, in the clamped texture zone: always opaque.
float radius=(M_PI/2-alt_rad)*2.0f/texFov; // radius in units of map Image.height/2 float radius=(M_PI/2-alt_rad)*2.0f/texFov; // radius in units of map Image.height/2
float az=atan2(azalt[0], azalt[1]) + M_PI/2 - angleRotateZ; // -pi/2 ..+3pi/2, real azimuth. NESW float az=atan2(azalt[0], azalt[1]) + M_PI/2 - angleRotateZ; // -pi/2 ..+3pi/2, real azimuth. NESW
// The texture map has south on top, east at right (if anglerotateZ =0) // The texture map has south on top, east at right (if anglerotateZ =0)
int x= mapImage->height()/2*(1 + radius*std::sin(az)); int x= mapImage->height()/2*(1 + radius*std::sin(az));
int y= mapImage->height()/2*(1 + radius*std::cos(az)); int y= mapImage->height()/2*(1 + radius*std::cos(az));
QRgb pixVal=mapImage->pixel(x, y); QRgb pixVal=mapImage->pixel(x, y);
/*
#ifndef NDEBUG #ifndef NDEBUG
// GZ: please leave the comment available for further development! // GZ: please leave the comment available for further development!
qDebug() << "Landscape sampling: az=" << (az+angleRotateZ)/M_PI*180. 0f << "° alt=" << alt_rad/M_PI*180.f qDebug() << "Landscape sampling: az=" << (az+angleRotateZ)/M_PI*180. 0f << "° alt=" << alt_rad/M_PI*180.f
<< "°, w=" << mapImage->width() << " h=" << mapImag e->height() << "°, w=" << mapImage->width() << " h=" << mapImag e->height()
<< " --> x:" << x << " y:" << y << " alpha:" << qAl pha(pixVal)/255.0f; << " --> x:" << x << " y:" << y << " alpha:" << qAl pha(pixVal)/255.0f;
#endif #endif
*/
return qAlpha(pixVal)/255.0f; return qAlpha(pixVal)/255.0f;
} }
/////////////////////////////////////////////////////////////////////////// ////////////////////// /////////////////////////////////////////////////////////////////////////// //////////////////////
// spherical panoramas // spherical panoramas
LandscapeSpherical::LandscapeSpherical(float _radius) LandscapeSpherical::LandscapeSpherical(float _radius)
: Landscape(_radius) : Landscape(_radius)
, mapTexTop(0.) , mapTexTop(0.)
, mapTexBottom(0.) , mapTexBottom(0.)
, fogTexTop(0.) , fogTexTop(0.)
, fogTexBottom(0.) , fogTexBottom(0.)
, illumTexTop(0.) , illumTexTop(0.)
, illumTexBottom(0.) , illumTexBottom(0.)
, mapImage(NULL) , mapImage(NULL)
{} {}
LandscapeSpherical::~LandscapeSpherical() LandscapeSpherical::~LandscapeSpherical()
{ {
if (mapImage) delete mapImage; if (mapImage) delete mapImage;
landscapeLabels.clear();
} }
void LandscapeSpherical::load(const QSettings& landscapeIni, const QString& landscapeId) void LandscapeSpherical::load(const QSettings& landscapeIni, const QString& landscapeId)
{ {
loadCommon(landscapeIni, landscapeId); loadCommon(landscapeIni, landscapeId);
// if (horizonPolygon) // if (horizonPolygon)
// qDebug() << "This landscape, " << landscapeId << ", has a po lygon defined!" ; // qDebug() << "This landscape, " << landscapeId << ", has a po lygon defined!" ;
// else // else
// qDebug() << "This landscape, " << landscapeId << ", has no p olygon defined!" ; // qDebug() << "This landscape, " << landscapeId << ", has no p olygon defined!" ;
skipping to change at line 1040 skipping to change at line 1170
transfo = core->getAltAzModelViewTransform(StelCore::Refract ionOff); transfo = core->getAltAzModelViewTransform(StelCore::Refract ionOff);
transfo->combine(Mat4d::zrotation(-angleRotateZOffset)); transfo->combine(Mat4d::zrotation(-angleRotateZOffset));
const StelProjectorP prj = core->getProjection(transfo); const StelProjectorP prj = core->getProjection(transfo);
sPainter.setProjector(prj); sPainter.setProjector(prj);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
sPainter.setColor(horizonPolygonLineColor[0], horizonPolygon LineColor[1], horizonPolygonLineColor[2], landFader.getInterstate()); sPainter.setColor(horizonPolygonLineColor[0], horizonPolygon LineColor[1], horizonPolygonLineColor[2], landFader.getInterstate());
sPainter.drawSphericalRegion(horizonPolygon.data(), StelPain ter::SphericalPolygonDrawModeBoundary); sPainter.drawSphericalRegion(horizonPolygon.data(), StelPain ter::SphericalPolygonDrawModeBoundary);
} }
//else qDebug() << "no polygon defined"; //else qDebug() << "no polygon defined";
glDisable(GL_CULL_FACE); glDisable(GL_CULL_FACE);
drawLabels(core, &sPainter);
} }
//! Sample landscape texture for transparency. May be used for advanced vis ibility computation like sunrise on the visible horizon etc. //! Sample landscape texture for transparency. May be used for advanced vis ibility computation like sunrise on the visible horizon etc.
//! @param azalt: normalized direction in alt-az frame //! @param azalt: normalized direction in alt-az frame
//! @retval alpha (0..1), where 0=fully transparent. //! @retval alpha (0..1), where 0=fully transparent.
float LandscapeSpherical::getOpacity(Vec3d azalt) const float LandscapeSpherical::getOpacity(Vec3d azalt) const
{ {
if (angleRotateZOffset!=0.0f) if (angleRotateZOffset!=0.0f)
azalt.transfo4d(Mat4d::zrotation(angleRotateZOffset)); azalt.transfo4d(Mat4d::zrotation(angleRotateZOffset));
skipping to change at line 1081 skipping to change at line 1211
if (az<0) az+=2.0f; // 0..2 = N.E.S. W.N if (az<0) az+=2.0f; // 0..2 = N.E.S. W.N
const float xShift=(angleRotateZ) /M_PI; // shift value in -2..2 const float xShift=(angleRotateZ) /M_PI; // shift value in -2..2
float az_phot=az - 0.5f - xShift; // The 0.5 is caused by regul ar pano left edge being East. The xShift compensates any configured angleRo tateZ float az_phot=az - 0.5f - xShift; // The 0.5 is caused by regul ar pano left edge being East. The xShift compensates any configured angleRo tateZ
az_phot=fmodf(az_phot, 2.0f); az_phot=fmodf(az_phot, 2.0f);
if (az_phot<0) az_phot+=2.0f; // 0.. 2 = image-X if (az_phot<0) az_phot+=2.0f; // 0.. 2 = image-X
int x=(az_phot/2.0f) * mapImage->width(); // pixel X from left. int x=(az_phot/2.0f) * mapImage->width(); // pixel X from left.
QRgb pixVal=mapImage->pixel(x, y); QRgb pixVal=mapImage->pixel(x, y);
/*
#ifndef NDEBUG #ifndef NDEBUG
// GZ: please leave the comment available for further development! // GZ: please leave the comment available for further development!
qDebug() << "Landscape sampling: az=" << az*180.0 << "° alt=" << alt _pm1*90.0f qDebug() << "Landscape sampling: az=" << az*180.0 << "° alt=" << alt _pm1*90.0f
<< "°, xShift[-2..+2]=" << xShift << " az_phot[0..2 ]=" << az_phot << "°, xShift[-2..+2]=" << xShift << " az_phot[0..2 ]=" << az_phot
<< ", w=" << mapImage->width() << " h=" << mapImage ->height() << ", w=" << mapImage->width() << " h=" << mapImage ->height()
<< " --> x:" << x << " y:" << y << " alpha:" << qAl pha(pixVal)/255.0f; << " --> x:" << x << " y:" << y << " alpha:" << qAl pha(pixVal)/255.0f;
#endif #endif
*/
return qAlpha(pixVal)/255.0f; return qAlpha(pixVal)/255.0f;
} }
 End of changes. 22 change blocks. 
4 lines changed or deleted 160 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/