Landscape.cpp   Landscape.cpp 
skipping to change at line 48 skipping to change at line 48
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)
{ {
name = landscapeIni.value("landscape/name").toString(); name = landscapeIni.value("landscape/name").toString();
author = landscapeIni.value("landscape/author").toString(); author = landscapeIni.value("landscape/author").toString();
description = landscapeIni.value("landscape/description").toString() ; description = landscapeIni.value("landscape/description").toString() ;
description = description.replace(QRegExp("\\\\n\\s*\\\\n"), "<br />
");
description = description.replace("\\n", " ");
if (name.isEmpty()) if (name.isEmpty())
{ {
qWarning() << "No valid landscape definition found for lands cape ID " qWarning() << "No valid landscape definition found for lands cape ID "
<< landscapeId << ". No landscape in use." << endl; << landscapeId << ". No landscape in use." << endl;
validLandscape = 0; validLandscape = 0;
return; return;
} }
else else
{ {
validLandscape = 1; validLandscape = 1;
skipping to change at line 90 skipping to change at line 92
location.country = landscapeIni.value("location/country").to String(); location.country = landscapeIni.value("location/country").to String();
if (landscapeIni.contains("location/state")) if (landscapeIni.contains("location/state"))
location.state = landscapeIni.value("location/state").toStri ng(); location.state = landscapeIni.value("location/state").toStri ng();
if (landscapeIni.contains("location/name")) if (landscapeIni.contains("location/name"))
location.name = landscapeIni.value("location/name").toString (); location.name = landscapeIni.value("location/name").toString ();
else else
location.name = name; location.name = name;
location.landscapeKey = name; location.landscapeKey = name;
} }
#include <iostream>
const QString Landscape::getTexturePath(const QString& basename, const QStr ing& landscapeId) const QString Landscape::getTexturePath(const QString& basename, const QStr ing& landscapeId)
{ {
// 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; QString path;
try try
{ {
path = StelFileMgr::findFile("landscapes/" + landscapeId + " /" + basename); path = StelFileMgr::findFile("landscapes/" + landscapeId + " /" + basename);
return path; return path;
} }
catch (std::runtime_error& e) catch (std::runtime_error& e)
{ {
#ifdef BUILD_FOR_MAEMO
if (!basename.endsWith(".pvr"))
{
QString tmp = basename;
tmp.replace(".png", ".pvr");
try
{
tmp = getTexturePath(tmp, landscapeId);
tmp.replace(".pvr", ".png");
return tmp;
}
catch (std::runtime_error& e)
{;}
}
#endif
path = StelFileMgr::findFile("textures/" + basename); path = StelFileMgr::findFile("textures/" + basename);
return path; return path;
} }
} }
LandscapeOldStyle::LandscapeOldStyle(float _radius) : Landscape(_radius), s ideTexs(NULL), sides(NULL), tanMode(false), calibrated(false) LandscapeOldStyle::LandscapeOldStyle(float _radius) : Landscape(_radius), s ideTexs(NULL), sides(NULL), tanMode(false), calibrated(false)
{} {}
LandscapeOldStyle::~LandscapeOldStyle() LandscapeOldStyle::~LandscapeOldStyle()
{ {
skipping to change at line 150 skipping to change at line 168
// Load sides textures // Load sides textures
nbSideTexs = landscapeIni.value("landscape/nbsidetex", 0).toInt(); nbSideTexs = landscapeIni.value("landscape/nbsidetex", 0).toInt();
sideTexs = new StelTextureSP[nbSideTexs]; sideTexs = new StelTextureSP[nbSideTexs];
for (int i=0;i<nbSideTexs;++i) for (int i=0;i<nbSideTexs;++i)
{ {
QString tmp = QString("tex%1").arg(i); QString tmp = QString("tex%1").arg(i);
sideTexs[i] = StelApp::getInstance().getTextureManager().cre ateTexture(getTexturePath(landscapeIni.value(QString("landscape/")+tmp).toS tring(), landscapeId)); sideTexs[i] = StelApp::getInstance().getTextureManager().cre ateTexture(getTexturePath(landscapeIni.value(QString("landscape/")+tmp).toS tring(), landscapeId));
} }
QMap<int, int> texToSide;
// Init sides parameters // Init sides parameters
nbSide = landscapeIni.value("landscape/nbside", 0).toInt(); nbSide = landscapeIni.value("landscape/nbside", 0).toInt();
sides = new landscapeTexCoord[nbSide]; sides = new landscapeTexCoord[nbSide];
QString s; QString s;
int texnum; int texnum;
float a,b,c,d; float a,b,c,d;
for (int i=0;i<nbSide;++i) for (int i=0;i<nbSide;++i)
{ {
QString tmp = QString("side%1").arg(i); QString tmp = QString("side%1").arg(i);
s = landscapeIni.value(QString("landscape/")+tmp).toString() ; s = landscapeIni.value(QString("landscape/")+tmp).toString() ;
sscanf(s.toLocal8Bit(),"tex%d:%f:%f:%f:%f",&texnum,&a,&b,&c, &d); sscanf(s.toLocal8Bit(),"tex%d:%f:%f:%f:%f",&texnum,&a,&b,&c, &d);
sides[i].tex = sideTexs[texnum]; sides[i].tex = sideTexs[texnum];
sides[i].texCoords[0] = a; sides[i].texCoords[0] = a;
sides[i].texCoords[1] = b; sides[i].texCoords[1] = b;
sides[i].texCoords[2] = c; sides[i].texCoords[2] = c;
sides[i].texCoords[3] = d; sides[i].texCoords[3] = d;
// qDebug("%f %f %f %f\n",a,b,c,d);
// Prior to precomputing the sides, we used to match E to si
de0
// in r4598 the precomputing was put in place and caused a p
roblem for
// old_style landscapes which had a z rotation on the side t
extures
// and where side0 did not map to tex0
// texToSide is a nasty hack to replace the old behaviour
texToSide[i] = texnum;
} }
nbDecorRepeat = landscapeIni.value("landscape/nb_decor_repeat", 1).t oInt(); nbDecorRepeat = landscapeIni.value("landscape/nb_decor_repeat", 1).t oInt();
groundTex = StelApp::getInstance().getTextureManager().createTexture (getTexturePath(landscapeIni.value("landscape/groundtex").toString(), lands capeId), StelTexture::StelTextureParams(true)); groundTex = StelApp::getInstance().getTextureManager().createTexture (getTexturePath(landscapeIni.value("landscape/groundtex").toString(), lands capeId), StelTexture::StelTextureParams(true));
s = landscapeIni.value("landscape/ground").toString(); s = landscapeIni.value("landscape/ground").toString();
sscanf(s.toLocal8Bit(),"groundtex:%f:%f:%f:%f",&a,&b,&c,&d); sscanf(s.toLocal8Bit(),"groundtex:%f:%f:%f:%f",&a,&b,&c,&d);
groundTexCoord.tex = groundTex; groundTexCoord.tex = groundTex;
groundTexCoord.texCoords[0] = a; groundTexCoord.texCoords[0] = a;
groundTexCoord.texCoords[1] = b; groundTexCoord.texCoords[1] = b;
skipping to change at line 205 skipping to change at line 230
groundAngleRotateZ = landscapeIni.value("landscape/ground_angle_rota tez", 0.).toFloat(); groundAngleRotateZ = landscapeIni.value("landscape/ground_angle_rota tez", 0.).toFloat();
drawGroundFirst = landscapeIni.value("landscape/draw_ground_first ", 0).toInt(); drawGroundFirst = landscapeIni.value("landscape/draw_ground_first ", 0).toInt();
tanMode = landscapeIni.value("landscape/tan_mode", false) .toBool(); tanMode = landscapeIni.value("landscape/tan_mode", false) .toBool();
calibrated = landscapeIni.value("landscape/calibrated", fals e).toBool(); calibrated = landscapeIni.value("landscape/calibrated", fals e).toBool();
// Precompute the vertex arrays for ground display // Precompute the vertex arrays for ground display
// Make slices_per_side=(3<<K) so that the innermost polygon of the fandisk becomes a triangle: // Make slices_per_side=(3<<K) so that the innermost polygon of the fandisk becomes a triangle:
int slices_per_side = 3*64/(nbDecorRepeat*nbSide); int slices_per_side = 3*64/(nbDecorRepeat*nbSide);
if (slices_per_side<=0) if (slices_per_side<=0)
slices_per_side = 1; slices_per_side = 1;
// draw a fan disk instead of a ordinary disk to that the inner slic es // draw a fan disk instead of a ordinary disk to that the inner slic es
// are not so slender. When they are too slender, culling errors occ ur // are not so slender. When they are too slender, culling errors occ ur
// in cylinder projection mode. // in cylinder projection mode.
int slices_inside = nbSide*slices_per_side*nbDecorRepeat; int slices_inside = nbSide*slices_per_side*nbDecorRepeat;
int level = 0; int level = 0;
while ((slices_inside&1)==0 && slices_inside > 4) while ((slices_inside&1)==0 && slices_inside > 4)
{ {
++level; ++level;
slices_inside>>=1; slices_inside>>=1;
} }
StelPainter::computeFanDisk(radius, slices_inside, level, groundVert exArr, groundTexCoordArr); StelPainter::computeFanDisk(radius, slices_inside, level, groundVert exArr, groundTexCoordArr);
// Precompute the vertex arrays for side display // Precompute the vertex arrays for side display
static const int stacks = (calibrated ? 16 : 8); // GZ: 8->16, I nee d better precision. static const int stacks = (calibrated ? 16 : 8); // GZ: 8->16, I nee d better precision.
// make slices_per_side=(3<<K) so that the innermost polygon of the
// fandisk becomes a triangle:
const double z0 = calibrated ? const double z0 = calibrated ?
// GZ: For calibrated, we use z=decorAngleShift...(decorAltAngle-dec orAngleShift), but we must compute the tan in the loop. // GZ: For calibrated, we use z=decorAngleShift...(decorAltAngle-dec orAngleShift), but we must compute the tan in the loop.
decorAngleShift : (tanMode ? radius * std::tan(decorAngleShift*M_PI/ 180.f) : radius * std::sin(decorAngleShift*M_PI/180.f)); decorAngleShift : (tanMode ? radius * std::tan(decorAngleShift*M_PI/ 180.f) : radius * std::sin(decorAngleShift*M_PI/180.f));
// GZ: The old formula is completely meaningless for photos with ope ning angle >90, // GZ: The old formula is completely meaningless for photos with ope ning angle >90,
// and most likely also not what was intended for other images. // and most likely also not what was intended for other images.
// Note that GZ fills this value with a different meaning! // Note that GZ fills this value with a different meaning!
const double d_z = calibrated ? decorAltAngle/stacks : (tanMode ? ra dius*std::tan(decorAltAngle*M_PI/180.f)/stacks : radius*std::sin(decorAltAn gle*M_PI/180.0)/stacks); const double d_z = calibrated ? decorAltAngle/stacks : (tanMode ? ra dius*std::tan(decorAltAngle*M_PI/180.f)/stacks : radius*std::sin(decorAltAn gle*M_PI/180.0)/stacks);
const float alpha = 2.f*M_PI/(nbDecorRepeat*nbSide*slices_per_side); const float alpha = 2.f*M_PI/(nbDecorRepeat*nbSide*slices_per_side);
const float ca = std::cos(alpha); const float ca = std::cos(alpha);
const float sa = std::sin(alpha); const float sa = std::sin(alpha);
float y0 = radius*std::cos((angleRotateZ+angleRotateZOffset)*M_PI/18 float y0 = radius*std::cos(angleRotateZ*M_PI/180.f);
0.f); float x0 = radius*std::sin(angleRotateZ*M_PI/180.f);
float x0 = radius*std::sin((angleRotateZ+angleRotateZOffset)*M_PI/18
0.f);
LOSSide precompSide; LOSSide precompSide;
precompSide.arr.primitiveType=StelVertexArray::Triangles; precompSide.arr.primitiveType=StelVertexArray::Triangles;
for (int n=0;n<nbDecorRepeat;n++) for (int n=0;n<nbDecorRepeat;n++)
{ {
for (int i=0;i<nbSide;i++) for (int i=0;i<nbSide;i++)
{ {
int ti;
if (texToSide.contains(i))
ti = texToSide[i];
else
{
qDebug() << QString("LandscapeOldStyle::load
ERROR: found no corresponding tex value for side%1").arg(i);
break;
}
precompSide.arr.vertex.resize(0); precompSide.arr.vertex.resize(0);
precompSide.arr.texCoords.resize(0); precompSide.arr.texCoords.resize(0);
precompSide.arr.indices.resize(0); precompSide.arr.indices.resize(0);
precompSide.tex=sideTexs[i]; precompSide.tex=sideTexs[ti];
float tx0 = sides[i].texCoords[0]; float tx0 = sides[ti].texCoords[0];
const float d_tx0 = (sides[i].texCoords[2]-sides[i]. const float d_tx0 = (sides[ti].texCoords[2]-sides[ti
texCoords[0]) / slices_per_side; ].texCoords[0]) / slices_per_side;
const float d_ty = (sides[i].texCoords[3]-sides[i].t const float d_ty = (sides[ti].texCoords[3]-sides[ti]
exCoords[1]) / stacks; .texCoords[1]) / stacks;
for (int j=0;j<slices_per_side;j++) for (int j=0;j<slices_per_side;j++)
{ {
const float y1 = y0*ca - x0*sa; const float y1 = y0*ca - x0*sa;
const float x1 = y0*sa + x0*ca; const float x1 = y0*sa + x0*ca;
const float tx1 = tx0 + d_tx0; const float tx1 = tx0 + d_tx0;
float z = z0; float z = z0;
float ty0 = sides[i].texCoords[1]; float ty0 = sides[ti].texCoords[1];
for (int k=0;k<=stacks*2;k+=2) for (int k=0;k<=stacks*2;k+=2)
{ {
precompSide.arr.texCoords << Vec2f(t x0, ty0) << Vec2f(tx1, ty0); precompSide.arr.texCoords << Vec2f(t x0, ty0) << Vec2f(tx1, ty0);
if (calibrated) if (calibrated)
{ {
float tanZ=radius * std::tan (z*M_PI/180.f); float tanZ=radius * std::tan (z*M_PI/180.f);
precompSide.arr.vertex << Ve c3d(x0, y0, tanZ) << Vec3d(x1, y1, tanZ); precompSide.arr.vertex << Ve c3d(x0, y0, tanZ) << Vec3d(x1, y1, tanZ);
} else } else
{ {
precompSide.arr.vertex << Ve c3d(x0, y0, z) << Vec3d(x1, y1, z); precompSide.arr.vertex << Ve c3d(x0, y0, z) << Vec3d(x1, y1, z);
skipping to change at line 333 skipping to change at line 365
void LandscapeOldStyle::drawDecor(StelCore* core, StelPainter& sPainter) co nst void LandscapeOldStyle::drawDecor(StelCore* core, StelPainter& sPainter) co nst
{ {
// Patched by Georg Zotti: I located an undocumented switch tan_mode , maybe tan_mode=true means cylindrical panorama projection. // Patched by Georg Zotti: I located an undocumented switch tan_mode , maybe tan_mode=true means cylindrical panorama projection.
// anyway, the old code makes unfortunately no sense. // anyway, the old code makes unfortunately no sense.
// I added a switch "calibrated" for the ini file. If true, it works as this landscape apparently was originally intended. // I added a switch "calibrated" for the ini file. If true, it works as this landscape apparently was originally intended.
// So I corrected the texture coordinates so that decorAltAngle is t he total angle, decorAngleShift the lower angle, // So I corrected the texture coordinates so that decorAltAngle is t he total angle, decorAngleShift the lower angle,
// and the texture in between is correctly stretched. // and the texture in between is correctly stretched.
// TODO: (1) Replace fog cylinder by similar texture, which could be painted as image layer in Photoshop/Gimp. // TODO: (1) Replace fog cylinder by similar texture, which could be painted as image layer in Photoshop/Gimp.
// (2) Implement calibrated && tan_mode // (2) Implement calibrated && tan_mode
sPainter.setProjector(core->getProjection(StelCore::FrameAltAz)); Mat4d mat = core->getNavigator()->getAltAzModelViewMat() * Mat4d::zr
otation(-angleRotateZOffset*M_PI/180.f);
sPainter.setProjector(core->getProjection(mat));
if (!landFader.getInterstate()) if (!landFader.getInterstate())
return; return;
const float nightModeFilter = StelApp::getInstance().getVisionModeNi ght() ? 0.f : 1.f; const float nightModeFilter = StelApp::getInstance().getVisionModeNi ght() ? 0.f : 1.f;
sPainter.setColor(skyBrightness, skyBrightness*nightModeFilter, skyB rightness*nightModeFilter, landFader.getInterstate()); sPainter.setColor(skyBrightness, skyBrightness*nightModeFilter, skyB rightness*nightModeFilter, landFader.getInterstate());
foreach (const LOSSide& side, precomputedSides) foreach (const LOSSide& side, precomputedSides)
{ {
side.tex->bind(); side.tex->bind();
sPainter.drawSphericalTriangles(side.arr, true, NULL, false) ; sPainter.drawSphericalTriangles(side.arr, true, NULL, false) ;
skipping to change at line 405 skipping to change at line 438
texFov = atexturefov*M_PI/180.f; texFov = atexturefov*M_PI/180.f;
angleRotateZ = aangleRotateZ*M_PI/180.f; angleRotateZ = aangleRotateZ*M_PI/180.f;
} }
void LandscapeFisheye::draw(StelCore* core) void LandscapeFisheye::draw(StelCore* core)
{ {
if(!validLandscape) return; if(!validLandscape) return;
if(!landFader.getInterstate()) return; if(!landFader.getInterstate()) return;
StelNavigator* nav = core->getNavigator(); StelNavigator* nav = core->getNavigator();
const StelProjectorP prj = core->getProjection(nav->getAltAzModelVie wMat() * Mat4d::zrotation(-(angleRotateZ+(angleRotateZOffset*2*M_PI/360.))) ); const StelProjectorP prj = core->getProjection(nav->getAltAzModelVie wMat() * Mat4d::zrotation(-(angleRotateZ+(angleRotateZOffset*M_PI/180.))));
StelPainter sPainter(prj); StelPainter sPainter(prj);
// Normal transparency mode // Normal transparency mode
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
float nightModeFilter = StelApp::getInstance().getVisionModeNight() ? 0.f : 1.f; float nightModeFilter = StelApp::getInstance().getVisionModeNight() ? 0.f : 1.f;
sPainter.setColor(skyBrightness, skyBrightness*nightModeFilter, skyB rightness*nightModeFilter, landFader.getInterstate()); sPainter.setColor(skyBrightness, skyBrightness*nightModeFilter, skyB rightness*nightModeFilter, landFader.getInterstate());
glEnable(GL_CULL_FACE); glEnable(GL_CULL_FACE);
sPainter.enableTexture2d(true); sPainter.enableTexture2d(true);
glEnable(GL_BLEND); glEnable(GL_BLEND);
skipping to change at line 466 skipping to change at line 499
mapTex = StelApp::getInstance().getTextureManager().createTexture(_m aptex, StelTexture::StelTextureParams(true)); mapTex = StelApp::getInstance().getTextureManager().createTexture(_m aptex, StelTexture::StelTextureParams(true));
angleRotateZ = _angleRotateZ*M_PI/180.f; angleRotateZ = _angleRotateZ*M_PI/180.f;
} }
void LandscapeSpherical::draw(StelCore* core) void LandscapeSpherical::draw(StelCore* core)
{ {
if(!validLandscape) return; if(!validLandscape) return;
if(!landFader.getInterstate()) return; if(!landFader.getInterstate()) return;
StelNavigator* nav = core->getNavigator(); StelNavigator* nav = core->getNavigator();
const StelProjectorP prj = core->getProjection(nav->getAltAzModelVie wMat() * Mat4d::zrotation(-(angleRotateZ+(angleRotateZOffset*2*M_PI/360.))) ); const StelProjectorP prj = core->getProjection(nav->getAltAzModelVie wMat() * Mat4d::zrotation(-(angleRotateZ+(angleRotateZOffset*M_PI/180.))));
StelPainter sPainter(prj); StelPainter sPainter(prj);
// Normal transparency mode // Normal transparency mode
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
float nightModeFilter = StelApp::getInstance().getVisionModeNight() ? 0. : 1.; float nightModeFilter = StelApp::getInstance().getVisionModeNight() ? 0. : 1.;
sPainter.setColor(skyBrightness, skyBrightness*nightModeFilter, skyB rightness*nightModeFilter, landFader.getInterstate()); sPainter.setColor(skyBrightness, skyBrightness*nightModeFilter, skyB rightness*nightModeFilter, landFader.getInterstate());
glEnable(GL_CULL_FACE); glEnable(GL_CULL_FACE);
sPainter.enableTexture2d(true); sPainter.enableTexture2d(true);
glEnable(GL_BLEND); glEnable(GL_BLEND);
 End of changes. 15 change blocks. 
17 lines changed or deleted 54 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/