Landscape.cpp   Landscape.cpp 
skipping to change at line 61 skipping to change at line 61
<< landscapeId << ". No landscape in use." << endl; << landscapeId << ". No landscape in use." << endl;
validLandscape = 0; validLandscape = 0;
return; return;
} }
else else
{ {
validLandscape = 1; validLandscape = 1;
} }
// Optional data // Optional data
// Patch GZ:
if (landscapeIni.contains("landscape/tesselate_rows"))
rows = landscapeIni.value("landscape/tesselate_rows").toInt(
);
else rows=20;
if (landscapeIni.contains("landscape/tesselate_cols"))
cols = landscapeIni.value("landscape/tesselate_cols").toInt(
);
else cols=40;
if (landscapeIni.contains("location/planet")) if (landscapeIni.contains("location/planet"))
location.planetName = landscapeIni.value("location/planet"). toString(); location.planetName = landscapeIni.value("location/planet"). toString();
else else
location.planetName = "Earth"; location.planetName = "Earth";
if (landscapeIni.contains("location/altitude")) if (landscapeIni.contains("location/altitude"))
location.altitude = landscapeIni.value("location/altitude"). toInt(); location.altitude = landscapeIni.value("location/altitude"). toInt();
if (landscapeIni.contains("location/latitude")) if (landscapeIni.contains("location/latitude"))
location.latitude = StelUtils::getDecAngle(landscapeIni.valu e("location/latitude").toString())*180./M_PI; location.latitude = StelUtils::getDecAngle(landscapeIni.valu e("location/latitude").toString())*180./M_PI;
if (landscapeIni.contains("location/longitude")) if (landscapeIni.contains("location/longitude"))
location.longitude = StelUtils::getDecAngle(landscapeIni.val ue("location/longitude").toString())*180./M_PI; location.longitude = StelUtils::getDecAngle(landscapeIni.val ue("location/longitude").toString())*180./M_PI;
skipping to change at line 98 skipping to change at line 106
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)
{ {
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) LandscapeOldStyle::LandscapeOldStyle(float _radius) : Landscape(_radius), s ideTexs(NULL), sides(NULL), tanMode(false), calibrated(false)
{} {}
LandscapeOldStyle::~LandscapeOldStyle() LandscapeOldStyle::~LandscapeOldStyle()
{ {
if (sideTexs) if (sideTexs)
{ {
delete [] sideTexs; delete [] sideTexs;
sideTexs = NULL; sideTexs = NULL;
} }
if (sides) delete [] sides; if (sides) delete [] sides;
} }
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 consolidate code // TODO: put values into hash and call create method to consolidate code
loadCommon(landscapeIni, landscapeId); loadCommon(landscapeIni, landscapeId);
// Patch GZ:
if (landscapeIni.contains("landscape/tesselate_rows"))
rows = landscapeIni.value("landscape/tesselate_rows").toInt(
);
else rows=8;
if (landscapeIni.contains("landscape/tesselate_cols"))
cols = landscapeIni.value("landscape/tesselate_cols").toInt(
);
else cols=16;
QString type = landscapeIni.value("landscape/type").toString(); QString type = landscapeIni.value("landscape/type").toString();
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[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);
skipping to change at line 174 skipping to change at line 189
fogTex = StelApp::getInstance().getTextureManager().createTexture(ge tTexturePath(landscapeIni.value("landscape/fogtex").toString(), landscapeId ), StelTexture::StelTextureParams(true, GL_LINEAR, GL_REPEAT)); fogTex = StelApp::getInstance().getTextureManager().createTexture(ge tTexturePath(landscapeIni.value("landscape/fogtex").toString(), landscapeId ), StelTexture::StelTextureParams(true, GL_LINEAR, GL_REPEAT));
s = landscapeIni.value("landscape/fog").toString(); s = landscapeIni.value("landscape/fog").toString();
sscanf(s.toLocal8Bit(),"fogtex:%f:%f:%f:%f",&a,&b,&c,&d); sscanf(s.toLocal8Bit(),"fogtex:%f:%f:%f:%f",&a,&b,&c,&d);
fogTexCoord.tex = fogTex; fogTexCoord.tex = fogTex;
fogTexCoord.texCoords[0] = a; fogTexCoord.texCoords[0] = a;
fogTexCoord.texCoords[1] = b; fogTexCoord.texCoords[1] = b;
fogTexCoord.texCoords[2] = c; fogTexCoord.texCoords[2] = c;
fogTexCoord.texCoords[3] = d; fogTexCoord.texCoords[3] = d;
fogAltAngle = landscapeIni.value("landscape/fog_alt_angle", 0 fogAltAngle = landscapeIni.value("landscape/fog_alt_angle", 0
.).toDouble(); .).toFloat();
fogAngleShift = landscapeIni.value("landscape/fog_angle_shift", fogAngleShift = landscapeIni.value("landscape/fog_angle_shift",
0.).toDouble(); 0.).toFloat();
decorAltAngle = landscapeIni.value("landscape/decor_alt_angle", decorAltAngle = landscapeIni.value("landscape/decor_alt_angle",
0.).toDouble(); 0.).toFloat();
decorAngleShift = landscapeIni.value("landscape/decor_angle_shift decorAngleShift = landscapeIni.value("landscape/decor_angle_shift
", 0.).toDouble(); ", 0.).toFloat();
angleRotateZ = landscapeIni.value("landscape/decor_angle_rotat angleRotateZ = landscapeIni.value("landscape/decor_angle_rotat
ez", 0.).toDouble(); ez", 0.).toFloat();
groundAngleShift = landscapeIni.value("landscape/ground_angle_shif groundAngleShift = landscapeIni.value("landscape/ground_angle_shif
t", 0.).toDouble(); t", 0.).toFloat();
groundAngleRotateZ = landscapeIni.value("landscape/ground_angle_rota groundAngleRotateZ = landscapeIni.value("landscape/ground_angle_rota
tez", 0.).toDouble(); 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();
// create from a hash of parameters (no ini file needed) // Precompute the vertex arrays for ground display
void LandscapeOldStyle::create(bool _fullpath, QMap<QString, QString> param // 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);
name = param["name"]; if (slices_per_side<=0)
validLandscape = 1; // assume valid if got here slices_per_side = 1;
// draw a fan disk instead of a ordinary disk to that the inner slic
// Load sides textures es
nbSideTexs = param["nbsidetex"].toInt(); // are not so slender. When they are too slender, culling errors occ
sideTexs = new StelTextureSP[nbSideTexs]; ur
// in cylinder projection mode.
char tmp[255]; int slices_inside = nbSide*slices_per_side*nbDecorRepeat;
//StelApp::getInstance().getTextureManager().setMipmapsMode(true); int level = 0;
//StelApp::getInstance().getTextureManager().setMagFilter(GL_NEAREST while ((slices_inside&1)==0 && slices_inside > 4)
);
for (int i=0;i<nbSideTexs;++i)
{ {
sprintf(tmp,"tex%d",i); ++level;
sideTexs[i] = StelApp::getInstance().getTextureManager().cre slices_inside>>=1;
ateTexture(param["path"] + param[tmp], StelTexture::StelTextureParams(true)
);
} }
StelPainter::computeFanDisk(radius, slices_inside, level, groundVert exArr, groundTexCoordArr);
// Init sides parameters // Precompute the vertex arrays for side display
nbSide = param["nbside"].toInt(); static const int stacks = (calibrated ? 16 : 8); // GZ: 8->16, I nee
sides = new landscapeTexCoord[nbSide]; d better precision.
QString s; // make slices_per_side=(3<<K) so that the innermost polygon of the
int texnum; // fandisk becomes a triangle:
float a,b,c,d; const double z0 = calibrated ?
for (int i=0;i<nbSide;++i) // GZ: For calibrated, we use z=decorAngleShift...(decorAltAngle-dec
{ orAngleShift), but we must compute the tan in the loop.
sprintf(tmp,"side%d",i); decorAngleShift : (tanMode ? radius * std::tan(decorAngleShift*M_PI/
s = param[tmp]; 180.f) : radius * std::sin(decorAngleShift*M_PI/180.f));
sscanf(s.toUtf8().constData(),"tex%d:%f:%f:%f:%f",&texnum,&a // GZ: The old formula is completely meaningless for photos with ope
,&b,&c,&d); ning angle >90,
sides[i].tex = sideTexs[texnum]; // and most likely also not what was intended for other images.
sides[i].texCoords[0] = a; // Note that GZ fills this value with a different meaning!
sides[i].texCoords[1] = b; const double d_z = calibrated ? decorAltAngle/stacks : (tanMode ? ra
sides[i].texCoords[2] = c; dius*std::tan(decorAltAngle*M_PI/180.f)/stacks : radius*std::sin(decorAltAn
sides[i].texCoords[3] = d; gle*M_PI/180.0)/stacks);
//qDebug("%f %f %f %f\n",a,b,c,d);
const float alpha = 2.f*M_PI/(nbDecorRepeat*nbSide*slices_per_side);
const float ca = std::cos(alpha);
const float sa = std::sin(alpha);
float y0 = radius*std::cos((angleRotateZ+angleRotateZOffset)*M_PI/18
0.f);
float x0 = radius*std::sin((angleRotateZ+angleRotateZOffset)*M_PI/18
0.f);
LOSSide precompSide;
precompSide.arr.primitiveType=StelVertexArray::Triangles;
for (int n=0;n<nbDecorRepeat;n++)
{
for (int i=0;i<nbSide;i++)
{
precompSide.arr.vertex.resize(0);
precompSide.arr.texCoords.resize(0);
precompSide.arr.indices.resize(0);
precompSide.tex=sideTexs[i];
float tx0 = sides[i].texCoords[0];
const float d_tx0 = (sides[i].texCoords[2]-sides[i].
texCoords[0]) / slices_per_side;
const float d_ty = (sides[i].texCoords[3]-sides[i].t
exCoords[1]) / stacks;
for (int j=0;j<slices_per_side;j++)
{
const float y1 = y0*ca - x0*sa;
const float x1 = y0*sa + x0*ca;
const float tx1 = tx0 + d_tx0;
float z = z0;
float ty0 = sides[i].texCoords[1];
for (int k=0;k<=stacks*2;k+=2)
{
precompSide.arr.texCoords << Vec2f(t
x0, ty0) << Vec2f(tx1, ty0);
if (calibrated)
{
float tanZ=radius * std::tan
(z*M_PI/180.f);
precompSide.arr.vertex << Ve
c3d(x0, y0, tanZ) << Vec3d(x1, y1, tanZ);
} else
{
precompSide.arr.vertex << Ve
c3d(x0, y0, z) << Vec3d(x1, y1, z);
}
z += d_z;
ty0 += d_ty;
}
unsigned int offset = j*(stacks+1)*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
<< offset+k-1 << offset+k+1;
}
y0 = y1;
x0 = x1;
tx0 = tx1;
}
precomputedSides.append(precompSide);
}
} }
bool ok;
nbDecorRepeat = param["nb_decor_repeat"].toInt(&ok);
if (!ok)
nbDecorRepeat = 1;
groundTex = StelApp::getInstance().getTextureManager().createTexture
(param["path"] + param["groundtex"], StelTexture::StelTextureParams(true));
s = param["ground"];
sscanf(s.toUtf8().constData(),"groundtex:%f:%f:%f:%f",&a,&b,&c,&d);
groundTexCoord.tex = groundTex;
groundTexCoord.texCoords[0] = a;
groundTexCoord.texCoords[1] = b;
groundTexCoord.texCoords[2] = c;
groundTexCoord.texCoords[3] = d;
fogTex = StelApp::getInstance().getTextureManager().createTexture(pa
ram["path"] + param["fogtex"], StelTexture::StelTextureParams(true, GL_LINE
AR, GL_REPEAT));
s = param["fog"];
sscanf(s.toUtf8().constData(),"fogtex:%f:%f:%f:%f",&a,&b,&c,&d);
fogTexCoord.tex = fogTex;
fogTexCoord.texCoords[0] = a;
fogTexCoord.texCoords[1] = b;
fogTexCoord.texCoords[2] = c;
fogTexCoord.texCoords[3] = d;
fogAltAngle = param["fog_alt_angle"].toDouble();
fogAngleShift = param["fog_angle_shift"].toDouble();
decorAltAngle = param["decor_alt_angle"].toDouble();
decorAngleShift = param["decor_angle_shift"].toDouble();
angleRotateZ = param["decor_angle_rotatez"].toDouble();
groundAngleShift = param["ground_angle_shift"].toDouble();
groundAngleRotateZ = param["ground_angle_rotatez"].toDouble();
drawGroundFirst = param["draw_ground_first"].toInt();
} }
void LandscapeOldStyle::draw(StelCore* core) void LandscapeOldStyle::draw(StelCore* core)
{ {
StelPainter painter(core->getProjection(StelCore::FrameAltAz)); StelPainter painter(core->getProjection(StelCore::FrameAltAz));
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);
skipping to change at line 281 skipping to change at line 309
drawGround(core, painter); drawGround(core, painter);
drawFog(core, painter); drawFog(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;
const double vpos = tanMode ? radius*std::tan(fogAngleShift*M_PI/180 .) : radius*std::sin(fogAngleShift*M_PI/180.); const float vpos = (tanMode||calibrated) ? radius*std::tan(fogAngleS hift*M_PI/180.) : radius*std::sin(fogAngleShift*M_PI/180.);
sPainter.setProjector(core->getProjection(core->getNavigator()->getA ltAzModelViewMat() * Mat4d::translation(Vec3d(0.,0.,vpos)))); sPainter.setProjector(core->getProjection(core->getNavigator()->getA ltAzModelViewMat() * Mat4d::translation(Vec3d(0.,0.,vpos))));
glBlendFunc(GL_ONE, GL_ONE); glBlendFunc(GL_ONE, GL_ONE);
const float nightModeFilter = StelApp::getInstance().getVisionModeNi ght() ? 0. : 1.; const float nightModeFilter = StelApp::getInstance().getVisionModeNi ght() ? 0.f : 1.f;
sPainter.setColor(fogFader.getInterstate()*(0.1f+0.1f*skyBrightness) , sPainter.setColor(fogFader.getInterstate()*(0.1f+0.1f*skyBrightness) ,
fogFader.getInterstate()*(0.1f+0.1f*skyBrightness)*nightMo deFilter, fogFader.getInterstate()*(0.1f+0.1f*skyBrightness) *nightModeFilter,
fogFader.getInterstate()*(0.1f+0.1f*skyBrightness) *nightModeFilter); fogFader.getInterstate()*(0.1f+0.1f*skyBrightness) *nightModeFilter);
fogTex->bind(); fogTex->bind();
const double height = tanMode ? radius*std::tan(fogAltAngle*M_PI/180 const float height = (tanMode||calibrated) ? radius*std::tan(fogAltA
.) : radius*std::sin(fogAltAngle*M_PI/180.); ngle*M_PI/180.) : radius*std::sin(fogAltAngle*M_PI/180.);
sPainter.sCylinder(radius, height, 128, 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 mountains with a few pieces of texture // Draw the mountains with a few pieces of texture
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.
// 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.
// 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.
// TODO: (1) Replace fog cylinder by similar texture, which could be
painted as image layer in Photoshop/Gimp.
// (2) Implement calibrated && tan_mode
sPainter.setProjector(core->getProjection(StelCore::FrameAltAz)); sPainter.setProjector(core->getProjection(StelCore::FrameAltAz));
if (!landFader.getInterstate()) if (!landFader.getInterstate())
return; return;
const float nightModeFilter = StelApp::getInstance().getVisionModeNi ght() ? 0. : 1.; 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());
static const int stacks = 8;
// make slices_per_side=(3<<K) so that the innermost polygon of th foreach (const LOSSide& side, precomputedSides)
e {
// fandisk becomes a triangle: side.tex->bind();
int slices_per_side = 3*64/(nbDecorRepeat*nbSide); sPainter.drawSphericalTriangles(side.arr, true, NULL, false)
if (slices_per_side<=0) slices_per_side = 1; ;
const double z0 = tanMode ? radius * std::tan(decorAngleShift*M_PI/1
80.0) :
radius * std::sin(decorAngleShift*M_PI/180.0);
const double d_z = tanMode ? radius * std::tan(decorAltAngle*M_PI/18
0.0) / stacks :
radius * std::sin(decorAltAngle*M_PI/180.0) / stacks;
const double alpha = 2.0*M_PI/(nbDecorRepeat*nbSide*slices_per_side)
;
const double ca = cos(alpha);
const double sa = sin(alpha);
double y0 = radius*cos((angleRotateZ+angleRotateZOffset)*M_PI/180.0)
;
double x0 = radius*sin((angleRotateZ+angleRotateZOffset)*M_PI/180.0)
;
QVector<Vec2f> texCoordsArray(stacks*2+2);
QVector<Vec3d> vertexArray(stacks*2+2);
for (int n=0;n<nbDecorRepeat;n++) for (int i=0;i<nbSide;i++) {
sides[i].tex->bind();
double tx0 = sides[i].texCoords[0];
const float d_tx0 = (sides[i].texCoords[2]-sides[i].texCoord
s[0]) / slices_per_side;
const float d_ty = (sides[i].texCoords[3]-sides[i].texCoords
[1]) / stacks;
for (int j=0;j<slices_per_side;j++) {
const double y1 = y0*ca - x0*sa;
const double x1 = y0*sa + x0*ca;
const float tx1 = tx0 + d_tx0;
double z = z0;
float ty0 = sides[i].texCoords[1];
for (int k=0;k<=stacks*2;k+=2) {
texCoordsArray[k].set(tx0, ty0);
texCoordsArray[k+1].set(tx1, ty0);
vertexArray[k].set(x0, y0, z);
vertexArray[k+1].set(x1, y1, z);
z += d_z;
ty0 += d_ty;
}
StelVertexArray array(vertexArray, StelVertexArray::
TriangleStrip, texCoordsArray);
sPainter.drawSphericalTriangles(array, true, NULL, f
alse);
y0 = y1;
x0 = x1;
tx0 = tx1;
}
} }
} }
// 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 StelNavigator* nav = core->getNavigator(); const StelNavigator* nav = core->getNavigator();
const double vshift = tanMode ? radius*std::tan(groundAngleShift*M_P const float vshift = (tanMode || calibrated) ?
I/180.) : radius*std::sin(groundAngleShift*M_PI/180.); radius*std::tan(groundAngleShift*M_PI/180.) :
radius*std::sin(groundAngleShift*M_PI/180.);
Mat4d mat = nav->getAltAzModelViewMat() * Mat4d::zrotation((groundAn gleRotateZ-angleRotateZOffset)*M_PI/180.f) * Mat4d::translation(Vec3d(0,0,v shift)); Mat4d mat = nav->getAltAzModelViewMat() * Mat4d::zrotation((groundAn gleRotateZ-angleRotateZOffset)*M_PI/180.f) * Mat4d::translation(Vec3d(0,0,v shift));
sPainter.setProjector(core->getProjection(mat)); sPainter.setProjector(core->getProjection(mat));
float nightModeFilter = StelApp::getInstance().getVisionModeNight() ? 0. : 1.; 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());
groundTex->bind(); groundTex->bind();
// make slices_per_side=(3<<K) so that the innermost polygon of th sPainter.setArrays((Vec3d*)groundVertexArr.constData(), (Vec2f*)grou
e ndTexCoordArr.constData());
// fandisk becomes a triangle: sPainter.drawFromArray(StelPainter::Triangles, groundVertexArr.size(
int slices_per_side = 3*64/(nbDecorRepeat*nbSide); )/3);
if (slices_per_side<=0) slices_per_side = 1;
// 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
// in cylinder projection mode.
int slices_inside = nbSide*slices_per_side*nbDecorRepeat;
int level = 0;
while ((slices_inside&1)==0 && slices_inside > 4)
{
++level;
slices_inside>>=1;
}
sPainter.sFanDisk(radius,slices_inside,level);
} }
LandscapeFisheye::LandscapeFisheye(float _radius) : Landscape(_radius) LandscapeFisheye::LandscapeFisheye(float _radius) : Landscape(_radius)
{} {}
LandscapeFisheye::~LandscapeFisheye() LandscapeFisheye::~LandscapeFisheye()
{ {
} }
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";
validLandscape = 0; validLandscape = 0;
return; return;
} }
create(name, 0, getTexturePath(landscapeIni.value("landscape/maptex" create(name, getTexturePath(landscapeIni.value("landscape/maptex").t
).toString(), landscapeId), oString(), landscapeId),
landscapeIni.value("landscape/texturefov", 360).toDouble(), landscapeIni.value("landscape/texturefov", 360).toFloat(),
landscapeIni.value("landscape/angle_rotatez", 0.).toDouble() landscapeIni.value("landscape/angle_rotatez", 0.).toFloat())
); ;
} }
// create a fisheye landscape from basic parameters (no ini file needed) // create a fisheye landscape from basic parameters (no ini file needed)
void LandscapeFisheye::create(const QString _name, bool _fullpath, const QS void LandscapeFisheye::create(const QString _name, const QString& _maptex,
tring& _maptex, float atexturefov, float aangleRotateZ)
double _texturefov, double _angleRotateZ)
{ {
// qDebug() << _name << " " << _fullpath << " " << _maptex << " " << _texturefov; // qDebug() << _name << " " << _fullpath << " " << _maptex << " " << _texturefov;
validLandscape = 1; // assume ok... validLandscape = 1; // assume ok...
name = _name; name = _name;
mapTex = StelApp::getInstance().getTextureManager().createTexture(_m aptex, StelTexture::StelTextureParams(true)); mapTex = StelApp::getInstance().getTextureManager().createTexture(_m aptex, StelTexture::StelTextureParams(true));
texFov = _texturefov*M_PI/180.; texFov = atexturefov*M_PI/180.f;
angleRotateZ = _angleRotateZ*M_PI/180.; 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*2*M_PI/360.))) );
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.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);
mapTex->bind(); mapTex->bind();
sPainter.sSphereMap(radius,40,20,texFov,1); // Patch GZ: (40,20)->(cols,rows)
sPainter.sSphereMap(radius,cols,rows,texFov,1);
glDisable(GL_CULL_FACE); glDisable(GL_CULL_FACE);
} }
// spherical panoramas // spherical panoramas
LandscapeSpherical::LandscapeSpherical(float _radius) : Landscape(_radius) LandscapeSpherical::LandscapeSpherical(float _radius) : Landscape(_radius)
{} {}
LandscapeSpherical::~LandscapeSpherical() LandscapeSpherical::~LandscapeSpherical()
skipping to change at line 459 skipping to change at line 446
QString type = landscapeIni.value("landscape/type").toString(); QString type = landscapeIni.value("landscape/type").toString();
if (type != "spherical") if (type != "spherical")
{ {
qWarning() << "Landscape type mismatch for landscape "<< lan dscapeId qWarning() << "Landscape type mismatch for landscape "<< lan dscapeId
<< ", expected spherical, found " << type << ", expected spherical, found " << type
<< ". No landscape in use.\n"; << ". No landscape in use.\n";
validLandscape = 0; validLandscape = 0;
return; return;
} }
create(name, 0, getTexturePath(landscapeIni.value("landscape/maptex" create(name, getTexturePath(landscapeIni.value("landscape/maptex").t
).toString(), landscapeId), oString(), landscapeId),
landscapeIni.value("landscape/angle_rotatez", 0.).toDouble() landscapeIni.value("landscape/angle_rotatez", 0.f).toFloat()
); );
} }
// create a spherical landscape from basic parameters (no ini file needed) // create a spherical landscape from basic parameters (no ini file needed)
void LandscapeSpherical::create(const QString _name, bool _fullpath, const void LandscapeSpherical::create(const QString _name, const QString& _maptex
QString& _maptex, , float _angleRotateZ)
double _angleRotateZ)
{ {
// qDebug() << _name << " " << _fullpath << " " << _maptex << " " << _texturefov; // qDebug() << _name << " " << _fullpath << " " << _maptex << " " << _texturefov;
validLandscape = 1; // assume ok... validLandscape = 1; // assume ok...
name = _name; name = _name;
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.; 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*2*M_PI/360.))) );
StelPainter sPainter(prj); StelPainter sPainter(prj);
skipping to change at line 495 skipping to change at line 481
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);
mapTex->bind(); mapTex->bind();
// TODO: verify that this works correctly for custom projections // TODO: verify that this works correctly for custom projections
// seam is at East // seam is at East
sPainter.sSphere(radius, 1.0, 40, 20, 1, true); //sPainter.sSphere(radius, 1.0, 40, 20, 1, true);
// GZ: Want better angle resolution, optional!
sPainter.sSphere(radius, 1.0, cols, rows, 1, true);
glDisable(GL_CULL_FACE); glDisable(GL_CULL_FACE);
} }
 End of changes. 30 change blocks. 
193 lines changed or deleted 189 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/