Landscape.cpp   Landscape.cpp 
skipping to change at line 279 skipping to change at line 279
if(type != "old_style") if(type != "old_style")
{ {
qWarning() << "Landscape type mismatch for landscape " << la ndscapeId qWarning() << "Landscape type mismatch for landscape " << la ndscapeId
<< ", expected old_style, found " << type << ". No landscape in use."; << ", expected old_style, found " << type << ". No landscape in use.";
validLandscape = 0; validLandscape = 0;
return; return;
} }
// 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[2*nbSideTexs]; // 0.14: allow upper hal f for light textures!
for (int i=0; i<nbSideTexs; ++i) for (int i=0; i<nbSideTexs; ++i)
{ {
QString textureKey = QString("landscape/tex%1").arg(i); QString textureKey = QString("landscape/tex%1").arg(i);
QString textureName = landscapeIni.value(textureKey).toStrin g(); QString textureName = landscapeIni.value(textureKey).toStrin g();
const QString texturePath = getTexturePath(textureName, land scapeId); const QString texturePath = getTexturePath(textureName, land scapeId);
sideTexs[i] = StelApp::getInstance().getTextureManager().cre ateTexture(texturePath); sideTexs[i] = StelApp::getInstance().getTextureManager().cre ateTexture(texturePath);
// GZ: To query the textures, also fill an array of QImage*, but only // GZ: To query the textures, also fill an array of QImage*, but only
// if that query is not going to be prevented by the polygon that already has been loaded at that point... // if that query is not going to be prevented by the polygon that already has been loaded at that point...
if ( (!horizonPolygon) && calibrated ) { // for uncalibrated landscapes the texture is currently never queried, so no need to store. if ( (!horizonPolygon) && calibrated ) { // for uncalibrated landscapes the texture is currently never queried, so no need to store.
QImage *image = new QImage(texturePath); QImage *image = new QImage(texturePath);
sidesImages.append(image); // indices identical to t hose in sideTexs sidesImages.append(image); // indices identical to t hose in sideTexs
} }
// Also allow light textures. The light textures must cover
the same geometry as the sides. It is allowed that not all or even any ligh
t textures are present!
textureKey = QString("landscape/light%1").arg(i);
textureName = landscapeIni.value(textureKey).toString();
if (textureName.length())
{
const QString lightTexturePath = getTexturePath(text
ureName, landscapeId);
sideTexs[nbSideTexs+i] = StelApp::getInstance().getT
extureManager().createTexture(lightTexturePath);
}
else
sideTexs[nbSideTexs+i].clear();
} }
if ( (!horizonPolygon) && calibrated ) if ( (!horizonPolygon) && calibrated )
{ {
Q_ASSERT(sidesImages.size()==nbSideTexs); Q_ASSERT(sidesImages.size()==nbSideTexs);
} }
QMap<int, int> texToSide; 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];
int texnum; int texnum;
for (int i=0;i<nbSide;++i) for (int i=0;i<nbSide;++i)
{ {
QString key = QString("landscape/side%1").arg(i); QString key = QString("landscape/side%1").arg(i);
QString description = landscapeIni.value(key).toString(); // e.g. side0
QString description = landscapeIni.value(key).toString();
// e.g. tex0:0:0:1:1
//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);
QStringList parameters = description.split(':'); QStringList parameters = description.split(':');
//TODO: How should be handled an invalid texture description ? //TODO: How should be handled an invalid texture description ?
QString textureName = parameters.value(0); QString textureName = parameters.value(0);
texnum = textureName.right(textureName.length() - 3).toInt() // tex0
; texnum = textureName.right(textureName.length() - 3).toInt()
; // 0
sides[i].tex = sideTexs[texnum]; sides[i].tex = sideTexs[texnum];
sides[i].tex_illum = sideTexs[nbSide+texnum];
sides[i].texCoords[0] = parameters.at(1).toFloat(); sides[i].texCoords[0] = parameters.at(1).toFloat();
sides[i].texCoords[1] = parameters.at(2).toFloat(); sides[i].texCoords[1] = parameters.at(2).toFloat();
sides[i].texCoords[2] = parameters.at(3).toFloat(); sides[i].texCoords[2] = parameters.at(3).toFloat();
sides[i].texCoords[3] = parameters.at(4).toFloat(); sides[i].texCoords[3] = parameters.at(4).toFloat();
//qDebug() << i << texnum << sides[i].texCoords[0] << sides[ i].texCoords[1] << sides[i].texCoords[2] << sides[i].texCoords[3]; //qDebug() << i << texnum << sides[i].texCoords[0] << sides[ i].texCoords[1] << sides[i].texCoords[2] << sides[i].texCoords[3];
// Prior to precomputing the sides, we used to match E to si de0. // 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 // 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 // old_style landscapes which had a z rotation on the side t extures
// and where side0 did not map to tex0 // and where side0 did not map to tex0
skipping to change at line 442 skipping to change at line 453
ti = texToSide[i]; ti = texToSide[i];
else else
{ {
qDebug() << QString("LandscapeOldStyle::load ERROR: found no corresponding tex value for side%1").arg(i); qDebug() << QString("LandscapeOldStyle::load ERROR: found no corresponding tex value for side%1").arg(i);
break; 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[ti]; precompSide.tex=sideTexs[ti];
precompSide.light=false;
float tx0 = sides[ti].texCoords[0]; float tx0 = sides[ti].texCoords[0];
const float d_tx = (sides[ti].texCoords[2]-sides[ti] .texCoords[0]) / slices_per_side; const float d_tx = (sides[ti].texCoords[2]-sides[ti] .texCoords[0]) / slices_per_side;
const float d_ty = (sides[ti].texCoords[3]-sides[ti] .texCoords[1]) / stacks; const float d_ty = (sides[ti].texCoords[3]-sides[ti] .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_tx; const float tx1 = tx0 + d_tx;
float z = z0; float z = z0;
skipping to change at line 478 skipping to change at line 490
for (int k = 2;k<stacks*2+2;k+=2) for (int k = 2;k<stacks*2+2;k+=2)
{ {
precompSide.arr.indices << offset+k- 2 << offset+k-1 << offset+k; precompSide.arr.indices << offset+k- 2 << offset+k-1 << offset+k;
precompSide.arr.indices << offset+k << offset+k-1 << offset+k+1; precompSide.arr.indices << offset+k << offset+k-1 << offset+k+1;
} }
y0 = y1; y0 = y1;
x0 = x1; x0 = x1;
tx0 = tx1; tx0 = tx1;
} }
precomputedSides.append(precompSide); precomputedSides.append(precompSide);
if (sideTexs[ti+nbSide])
{
precompSide.light=true;
precompSide.tex=sideTexs[ti+nbSide];
precomputedSides.append(precompSide); // T
hese sides are not called by strict index!
// M
ay be 9 for 8 sidetexs plus 1-only light panel
}
} }
} }
} }
void LandscapeOldStyle::draw(StelCore* core) void LandscapeOldStyle::draw(StelCore* core)
{ {
StelPainter painter(core->getProjection(StelCore::FrameAltAz, StelCo re::RefractionOff)); StelPainter painter(core->getProjection(StelCore::FrameAltAz, StelCo re::RefractionOff));
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glEnable(GL_BLEND); glEnable(GL_BLEND);
painter.enableTexture2d(true); painter.enableTexture2d(true);
glEnable(GL_CULL_FACE); glEnable(GL_CULL_FACE);
if (!validLandscape) if (!validLandscape)
return; return;
if (drawGroundFirst) if (drawGroundFirst)
drawGround(core, painter); drawGround(core, painter);
drawDecor(core, painter); drawDecor(core, painter, false);
if (!drawGroundFirst) if (!drawGroundFirst)
drawGround(core, painter); drawGround(core, painter);
drawFog(core, painter); drawFog(core, painter);
// GZ: ALSO HERE - Self-luminous layer (Light pollution etc). This l
ooks striking!
if (lightScapeBrightness>0.0f && core->getSkyDrawer()->getFlagHasAtm
osphere())
{
glBlendFunc(GL_SRC_ALPHA, GL_ONE);
drawDecor(core, painter, true); // GZ: NEW
}
// If a horizon line also has been defined, draw it. // If a horizon line also has been defined, draw it.
if (horizonPolygon && (horizonPolygonLineColor[0] >= 0)) if (horizonPolygon && (horizonPolygonLineColor[0] >= 0))
{ {
//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());
skipping to change at line 541 skipping to change at line 567
fogFader.getInterstate()*(0.1f+0.1f*landscapeBrigh tness)); fogFader.getInterstate()*(0.1f+0.1f*landscapeBrigh tness));
fogTex->bind(); fogTex->bind();
const float height = (calibrated? const float height = (calibrated?
radius*(std::tan((fogAltAngle+fogAngleShift) *M_PI/180.) - std::tan(fogAngleShift*M_PI/180.)) radius*(std::tan((fogAltAngle+fogAngleShift) *M_PI/180.) - std::tan(fogAngleShift*M_PI/180.))
: ((tanMode) ? radius*std::tan(fogAltAngle*M _PI/180.) : radius*std::sin(fogAltAngle*M_PI/180.))); : ((tanMode) ? radius*std::tan(fogAltAngle*M _PI/180.) : radius*std::sin(fogAltAngle*M_PI/180.)));
sPainter.sCylinder(radius, height, 64, 1); sPainter.sCylinder(radius, height, 64, 1);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
} }
// Draw the side textures // Draw the side textures
void LandscapeOldStyle::drawDecor(StelCore* core, StelPainter& sPainter) co nst void LandscapeOldStyle::drawDecor(StelCore* core, StelPainter& sPainter, co nst bool drawLight) const
{ {
StelProjector::ModelViewTranformP transfo = core->getAltAzModelViewT ransform(StelCore::RefractionOff); StelProjector::ModelViewTranformP transfo = core->getAltAzModelViewT ransform(StelCore::RefractionOff);
transfo->combine(Mat4d::zrotation(-(angleRotateZ+angleRotateZOffset) )); transfo->combine(Mat4d::zrotation(-(angleRotateZ+angleRotateZOffset) ));
sPainter.setProjector(core->getProjection(transfo)); sPainter.setProjector(core->getProjection(transfo));
if (!landFader.getInterstate()) if (!landFader.getInterstate())
return; return;
sPainter.setColor(landscapeBrightness, landscapeBrightness, landscap if (drawLight)
eBrightness, landFader.getInterstate()); sPainter.setColor(lightScapeBrightness, lightScapeBrightness
, lightScapeBrightness, landFader.getInterstate());
else
sPainter.setColor(landscapeBrightness, landscapeBrightness,
landscapeBrightness, landFader.getInterstate());
foreach (const LOSSide& side, precomputedSides) foreach (const LOSSide& side, precomputedSides)
{ {
side.tex->bind(); if (side.light==drawLight)
sPainter.drawSphericalTriangles(side.arr, true, NULL, false) {
; side.tex->bind();
sPainter.drawSphericalTriangles(side.arr, true, NULL
, false);
}
} }
} }
// Draw the ground // Draw the ground
void LandscapeOldStyle::drawGround(StelCore* core, StelPainter& sPainter) c onst void LandscapeOldStyle::drawGround(StelCore* core, StelPainter& sPainter) c onst
{ {
if (!landFader.getInterstate()) if (!landFader.getInterstate())
return; return;
const float vshift = radius * ((tanMode || calibrated) ? std::tan(gr oundAngleShift) : std::sin(groundAngleShift)); const float vshift = radius * ((tanMode || calibrated) ? std::tan(gr oundAngleShift) : std::sin(groundAngleShift));
StelProjector::ModelViewTranformP transfo = core->getAltAzModelViewT ransform(StelCore::RefractionOff); StelProjector::ModelViewTranformP transfo = core->getAltAzModelViewT ransform(StelCore::RefractionOff);
 End of changes. 12 change blocks. 
13 lines changed or deleted 57 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/