Landscape.cpp   Landscape.cpp 
skipping to change at line 31 skipping to change at line 31
#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 <QDebug> #include <QDebug>
#include <QSettings> #include <QSettings>
#include <QVarLengthArray>
Landscape::Landscape(float _radius) : radius(_radius), skyBrightness(1.), a ngleRotateZOffset(0.) Landscape::Landscape(float _radius) : radius(_radius), skyBrightness(1.), a ngleRotateZOffset(0.)
{ {
validLandscape = 0; validLandscape = 0;
} }
Landscape::~Landscape() Landscape::~Landscape()
{ {
} }
skipping to change at line 87 skipping to change at line 88
location.name = name; location.name = name;
location.landscapeKey = name; location.landscapeKey = name;
} }
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 = StelApp::getInstance().getFileMgr().findFile("landsca pes/" + landscapeId + "/" + basename); path = StelFileMgr::findFile("landscapes/" + landscapeId + " /" + basename);
return path; return path;
} }
catch (std::runtime_error& e) catch (std::runtime_error& e)
{ {
path = StelApp::getInstance().getFileMgr().findFile("texture s/" + 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)
{} {}
LandscapeOldStyle::~LandscapeOldStyle() LandscapeOldStyle::~LandscapeOldStyle()
{ {
if (sideTexs) if (sideTexs)
skipping to change at line 128 skipping to change at line 129
{ {
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];
StelApp::getInstance().getTextureManager().setDefaultParams();
StelApp::getInstance().getTextureManager().setWrapMode(GL_CLAMP_TO_E
DGE);
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));
} }
// 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;
skipping to change at line 157 skipping to change at line 156
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); // qDebug("%f %f %f %f\n",a,b,c,d);
} }
nbDecorRepeat = landscapeIni.value("landscape/nb_decor_repeat", 1).t oInt(); nbDecorRepeat = landscapeIni.value("landscape/nb_decor_repeat", 1).t oInt();
StelApp::getInstance().getTextureManager().setDefaultParams(); groundTex = StelApp::getInstance().getTextureManager().createTexture
groundTex = StelApp::getInstance().getTextureManager().createTexture (getTexturePath(landscapeIni.value("landscape/groundtex").toString(), lands
(getTexturePath(landscapeIni.value("landscape/groundtex").toString(), lands capeId), StelTexture::StelTextureParams(true));
capeId));
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;
groundTexCoord.texCoords[2] = c; groundTexCoord.texCoords[2] = c;
groundTexCoord.texCoords[3] = d; groundTexCoord.texCoords[3] = d;
StelApp::getInstance().getTextureManager().setWrapMode(GL_REPEAT); fogTex = StelApp::getInstance().getTextureManager().createTexture(ge
fogTex = StelApp::getInstance().getTextureManager().createTexture(ge tTexturePath(landscapeIni.value("landscape/fogtex").toString(), landscapeId
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 .).toDouble(); fogAltAngle = landscapeIni.value("landscape/fog_alt_angle", 0 .).toDouble();
fogAngleShift = landscapeIni.value("landscape/fog_angle_shift", 0.).toDouble(); fogAngleShift = landscapeIni.value("landscape/fog_angle_shift", 0.).toDouble();
skipping to change at line 204 skipping to change at line 201
// Load sides textures // Load sides textures
nbSideTexs = param["nbsidetex"].toInt(); nbSideTexs = param["nbsidetex"].toInt();
sideTexs = new StelTextureSP[nbSideTexs]; sideTexs = new StelTextureSP[nbSideTexs];
char tmp[255]; char tmp[255];
//StelApp::getInstance().getTextureManager().setMipmapsMode(true); //StelApp::getInstance().getTextureManager().setMipmapsMode(true);
//StelApp::getInstance().getTextureManager().setMagFilter(GL_NEAREST ); //StelApp::getInstance().getTextureManager().setMagFilter(GL_NEAREST );
for (int i=0;i<nbSideTexs;++i) for (int i=0;i<nbSideTexs;++i)
{ {
sprintf(tmp,"tex%d",i); sprintf(tmp,"tex%d",i);
sideTexs[i] = StelApp::getInstance().getTextureManager().cre ateTexture(param["path"] + param[tmp]); sideTexs[i] = StelApp::getInstance().getTextureManager().cre ateTexture(param["path"] + param[tmp], StelTexture::StelTextureParams(true) );
} }
// Init sides parameters // Init sides parameters
nbSide = param["nbside"].toInt(); nbSide = param["nbside"].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)
{ {
skipping to change at line 232 skipping to change at line 229
sides[i].texCoords[3] = d; sides[i].texCoords[3] = d;
//qDebug("%f %f %f %f\n",a,b,c,d); //qDebug("%f %f %f %f\n",a,b,c,d);
} }
bool ok; bool ok;
nbDecorRepeat = param["nb_decor_repeat"].toInt(&ok); nbDecorRepeat = param["nb_decor_repeat"].toInt(&ok);
if (!ok) if (!ok)
nbDecorRepeat = 1; nbDecorRepeat = 1;
groundTex = StelApp::getInstance().getTextureManager().createTexture (param["path"] + param["groundtex"]); groundTex = StelApp::getInstance().getTextureManager().createTexture (param["path"] + param["groundtex"], StelTexture::StelTextureParams(true));
s = param["ground"]; s = param["ground"];
sscanf(s.toUtf8().constData(),"groundtex:%f:%f:%f:%f",&a,&b,&c,&d); sscanf(s.toUtf8().constData(),"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;
groundTexCoord.texCoords[2] = c; groundTexCoord.texCoords[2] = c;
groundTexCoord.texCoords[3] = d; groundTexCoord.texCoords[3] = d;
StelApp::getInstance().getTextureManager().setWrapMode(GL_REPEAT); fogTex = StelApp::getInstance().getTextureManager().createTexture(pa
fogTex = StelApp::getInstance().getTextureManager().createTexture(pa ram["path"] + param["fogtex"], StelTexture::StelTextureParams(true, GL_LINE
ram["path"] + param["fogtex"]); AR, GL_REPEAT));
s = param["fog"]; s = param["fog"];
sscanf(s.toUtf8().constData(),"fogtex:%f:%f:%f:%f",&a,&b,&c,&d); sscanf(s.toUtf8().constData(),"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 = param["fog_alt_angle"].toDouble(); fogAltAngle = param["fog_alt_angle"].toDouble();
fogAngleShift = param["fog_angle_shift"].toDouble(); fogAngleShift = param["fog_angle_shift"].toDouble();
decorAltAngle = param["decor_alt_angle"].toDouble(); decorAltAngle = param["decor_alt_angle"].toDouble();
decorAngleShift = param["decor_angle_shift"].toDouble(); decorAngleShift = param["decor_angle_shift"].toDouble();
angleRotateZ = param["decor_angle_rotatez"].toDouble(); angleRotateZ = param["decor_angle_rotatez"].toDouble();
groundAngleShift = param["ground_angle_shift"].toDouble(); groundAngleShift = param["ground_angle_shift"].toDouble();
groundAngleRotateZ = param["ground_angle_rotatez"].toDouble(); groundAngleRotateZ = param["ground_angle_rotatez"].toDouble();
drawGroundFirst = param["draw_ground_first"].toInt(); drawGroundFirst = param["draw_ground_first"].toInt();
} }
void LandscapeOldStyle::draw(StelCore* core) void LandscapeOldStyle::draw(StelCore* core)
{ {
if(!validLandscape) return; StelPainter painter(core->getProjection(StelCore::FrameAltAz));
if (drawGroundFirst) drawGround(core); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
drawDecor(core); glEnable(GL_BLEND);
if (!drawGroundFirst) drawGround(core); painter.enableTexture2d(true);
drawFog(core); glEnable(GL_CULL_FACE);
if (!validLandscape)
return;
if (drawGroundFirst)
drawGround(core, painter);
drawDecor(core, painter);
if (!drawGroundFirst)
drawGround(core, painter);
drawFog(core, painter);
} }
// Draw the horizon fog // Draw the horizon fog
void LandscapeOldStyle::drawFog(StelCore* core) const 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 double vpos = tanMode ? radius*std::tan(fogAngleShift*M_PI/180 .) : radius*std::sin(fogAngleShift*M_PI/180.);
const StelProjectorP prj = core->getProjection(core->getNavigator()- sPainter.setProjector(core->getProjection(core->getNavigator()->getA
>getAltAzModelViewMat() * Mat4d::translation(Vec3d(0.,0.,vpos))); ltAzModelViewMat() * Mat4d::translation(Vec3d(0.,0.,vpos))));
StelPainter sPainter(prj);
glBlendFunc(GL_ONE, GL_ONE); glBlendFunc(GL_ONE, GL_ONE);
float nightModeFilter = StelApp::getInstance().getVisionModeNight() const float nightModeFilter = StelApp::getInstance().getVisionModeNi
? 0. : 1.; ght() ? 0. : 1.;
glColor3f(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)*nightMo deFilter,
fogFader.getInterstate()*(0.1f+0.1f*skyBrightness)*nightMo fogFader.getInterstate()*(0.1f+0.1f*skyBrightness)
deFilter); *nightModeFilter);
glEnable(GL_TEXTURE_2D);
glEnable(GL_BLEND);
glEnable(GL_CULL_FACE);
fogTex->bind(); fogTex->bind();
const double height = tanMode ? radius*std::tan(fogAltAngle*M_PI/180 .) : radius*std::sin(fogAltAngle*M_PI/180.); const double height = tanMode ? radius*std::tan(fogAltAngle*M_PI/180 .) : radius*std::sin(fogAltAngle*M_PI/180.);
sPainter.sCylinder(radius, height, 128, 1, 1); sPainter.sCylinder(radius, height, 128, 1);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glDisable(GL_CULL_FACE);
} }
// Draw the mountains with a few pieces of texture // Draw the mountains with a few pieces of texture
void LandscapeOldStyle::drawDecor(StelCore* core) const void LandscapeOldStyle::drawDecor(StelCore* core, StelPainter& sPainter) co nst
{ {
const StelProjectorP prj = core->getProjection(StelCore::FrameAltAz) sPainter.setProjector(core->getProjection(StelCore::FrameAltAz));
;
StelPainter sPainter(prj);
if (!landFader.getInterstate()) return; if (!landFader.getInterstate())
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); return;
glEnable(GL_TEXTURE_2D); const float nightModeFilter = StelApp::getInstance().getVisionModeNi
glEnable(GL_BLEND); ght() ? 0. : 1.;
glEnable(GL_CULL_FACE); sPainter.setColor(skyBrightness, skyBrightness*nightModeFilter, skyB
float nightModeFilter = StelApp::getInstance().getVisionModeNight() rightness*nightModeFilter, landFader.getInterstate());
? 0. : 1.; static const int stacks = 8;
glColor4f(skyBrightness, skyBrightness*nightModeFilter, skyBrightnes
s*nightModeFilter, landFader.getInterstate());
const int stacks = 8;
// make slices_per_side=(3<<K) so that the innermost polygon of th e // make slices_per_side=(3<<K) so that the innermost polygon of th e
// fandisk becomes a triangle: // 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) slices_per_side = 1; if (slices_per_side<=0) slices_per_side = 1;
const double z0 = tanMode ? radius * std::tan(decorAngleShift*M_PI/1 80.0) : const double z0 = tanMode ? radius * std::tan(decorAngleShift*M_PI/1 80.0) :
radius * std::sin(decorAngleShift*M_PI/180.0); radius * std::sin(decorAngleShift*M_PI/180.0);
const double d_z = tanMode ? radius * std::tan(decorAltAngle*M_PI/18 0.0) / stacks : const double d_z = tanMode ? radius * std::tan(decorAltAngle*M_PI/18 0.0) / stacks :
radius * std::sin(decorAltAngle*M_PI/180.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 alpha = 2.0*M_PI/(nbDecorRepeat*nbSide*slices_per_side) ;
const double ca = cos(alpha); const double ca = cos(alpha);
const double sa = sin(alpha); const double sa = sin(alpha);
double y0 = radius*cos((angleRotateZ+angleRotateZOffset)*M_PI/180.0) ; double y0 = radius*cos((angleRotateZ+angleRotateZOffset)*M_PI/180.0) ;
double x0 = radius*sin((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++) { for (int n=0;n<nbDecorRepeat;n++) for (int i=0;i<nbSide;i++) {
sides[i].tex->bind(); sides[i].tex->bind();
double tx0 = sides[i].texCoords[0]; double tx0 = sides[i].texCoords[0];
const float d_tx0 = (sides[i].texCoords[2]-sides[i].texCoord const float d_tx0 = (sides[i].texCoords[2]-sides[i].texCoord
s[0]) s[0]) / slices_per_side;
/ slices_per_side; const float d_ty = (sides[i].texCoords[3]-sides[i].texCoords
const float d_ty = (sides[i].texCoords[3]-sides[i].texCoords [1]) / stacks;
[1])
/ stacks;
for (int j=0;j<slices_per_side;j++) { for (int j=0;j<slices_per_side;j++) {
const double y1 = y0*ca - x0*sa; const double y1 = y0*ca - x0*sa;
const double x1 = y0*sa + x0*ca; const double x1 = y0*sa + x0*ca;
const float tx1 = tx0 + d_tx0; const float tx1 = tx0 + d_tx0;
double z = z0; double z = z0;
float ty0 = sides[i].texCoords[1]; float ty0 = sides[i].texCoords[1];
glBegin(GL_QUAD_STRIP); for (int k=0;k<=stacks*2;k+=2) {
for (int k=0;k<=stacks;k++) { texCoordsArray[k].set(tx0, ty0);
glTexCoord2f(tx0,ty0); texCoordsArray[k+1].set(tx1, ty0);
sPainter.drawVertex3(x0, y0, z); vertexArray[k].set(x0, y0, z);
glTexCoord2f(tx1,ty0); vertexArray[k+1].set(x1, y1, z);
sPainter.drawVertex3(x1, y1, z);
z += d_z; z += d_z;
ty0 += d_ty; ty0 += d_ty;
} }
glEnd(); StelVertexArray array(vertexArray, StelVertexArray::
TriangleStrip, texCoordsArray);
sPainter.drawSphericalTriangles(array, true, NULL, f
alse);
y0 = y1; y0 = y1;
x0 = x1; x0 = x1;
tx0 = tx1; tx0 = tx1;
} }
} }
glDisable(GL_CULL_FACE);
} }
// Draw the ground // Draw the ground
void LandscapeOldStyle::drawGround(StelCore* core) const void LandscapeOldStyle::drawGround(StelCore* core, StelPainter& sPainter) c onst
{ {
if (!landFader.getInterstate())
return;
const StelNavigator* nav = core->getNavigator(); const StelNavigator* nav = core->getNavigator();
if (!landFader.getInterstate()) return;
const double vshift = tanMode ? radius*std::tan(groundAngleShift*M_P I/180.) : radius*std::sin(groundAngleShift*M_PI/180.); const double vshift = tanMode ? radius*std::tan(groundAngleShift*M_P I/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));
const StelProjectorP prj = core->getProjection(mat); sPainter.setProjector(core->getProjection(mat));
StelPainter sPainter(prj);
float nightModeFilter = StelApp::getInstance().getVisionModeNight() ? 0. : 1.; float nightModeFilter = StelApp::getInstance().getVisionModeNight() ? 0. : 1.;
glColor4f(skyBrightness, skyBrightness*nightModeFilter, skyBrightnes sPainter.setColor(skyBrightness, skyBrightness*nightModeFilter, skyB
s*nightModeFilter, landFader.getInterstate()); rightness*nightModeFilter, landFader.getInterstate());
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glEnable(GL_CULL_FACE);
glEnable(GL_TEXTURE_2D);
glEnable(GL_BLEND);
groundTex->bind(); groundTex->bind();
// make slices_per_side=(3<<K) so that the innermost polygon of th e // make slices_per_side=(3<<K) so that the innermost polygon of th e
// fandisk becomes a triangle: // 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) slices_per_side = 1; if (slices_per_side<=0) 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.
//prj->sDisk(radius,nbSide*slices_per_side*nbDecorRepeat,5, 1);
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;
} }
sPainter.sFanDisk(radius,slices_inside,level); sPainter.sFanDisk(radius,slices_inside,level);
glDisable(GL_CULL_FACE);
} }
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)
skipping to change at line 426 skipping to change at line 408
landscapeIni.value("landscape/angle_rotatez", 0.).toDouble() ); landscapeIni.value("landscape/angle_rotatez", 0.).toDouble() );
} }
// 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 tring& _maptex, void LandscapeFisheye::create(const QString _name, bool _fullpath, const QS tring& _maptex,
double _texturefov, double _angleRotateZ) 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;
StelApp::getInstance().getTextureManager().setDefaultParams(); mapTex = StelApp::getInstance().getTextureManager().createTexture(_m
mapTex = StelApp::getInstance().getTextureManager().createTexture(_m aptex, StelTexture::StelTextureParams(true));
aptex);
texFov = _texturefov*M_PI/180.; texFov = _texturefov*M_PI/180.;
angleRotateZ = _angleRotateZ*M_PI/180.; angleRotateZ = _angleRotateZ*M_PI/180.;
} }
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. : 1.;
glColor4f(skyBrightness, skyBrightness*nightModeFilter, skyBrightnes s*nightModeFilter, landFader.getInterstate()); sPainter.setColor(skyBrightness, skyBrightness*nightModeFilter, skyB rightness*nightModeFilter, landFader.getInterstate());
glEnable(GL_CULL_FACE); glEnable(GL_CULL_FACE);
glEnable(GL_TEXTURE_2D); sPainter.enableTexture2d(true);
glEnable(GL_BLEND); glEnable(GL_BLEND);
mapTex->bind(); mapTex->bind();
sPainter.sSphereMap(radius,40,20,texFov,1); sPainter.sSphereMap(radius,40,20,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)
skipping to change at line 489 skipping to change at line 470
landscapeIni.value("landscape/angle_rotatez", 0.).toDouble() ); landscapeIni.value("landscape/angle_rotatez", 0.).toDouble() );
} }
// 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 QString& _maptex, void LandscapeSpherical::create(const QString _name, bool _fullpath, const QString& _maptex,
double _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;
StelApp::getInstance().getTextureManager().setDefaultParams(); mapTex = StelApp::getInstance().getTextureManager().createTexture(_m
mapTex = StelApp::getInstance().getTextureManager().createTexture(_m aptex, StelTexture::StelTextureParams(true));
aptex);
angleRotateZ = _angleRotateZ*M_PI/180.; angleRotateZ = _angleRotateZ*M_PI/180.;
} }
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);
// Need to flip texture usage horizontally due to glusphere conventi
on
// so that left-right is consistent in source texture and rendering
glMatrixMode(GL_TEXTURE);
glPushMatrix();
glLoadIdentity();
glScalef(-1,1,1);
glTranslatef(-1,0,0);
glMatrixMode(GL_MODELVIEW);
// 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.;
glColor4f(skyBrightness, skyBrightness*nightModeFilter, skyBrightnes s*nightModeFilter, landFader.getInterstate()); sPainter.setColor(skyBrightness, skyBrightness*nightModeFilter, skyB rightness*nightModeFilter, landFader.getInterstate());
glEnable(GL_CULL_FACE); glEnable(GL_CULL_FACE);
glEnable(GL_TEXTURE_2D); 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); sPainter.sSphere(radius, 1.0, 40, 20, 1, true);
glDisable(GL_CULL_FACE); glDisable(GL_CULL_FACE);
glMatrixMode(GL_TEXTURE);
glPopMatrix();
glMatrixMode(GL_MODELVIEW);
} }
 End of changes. 40 change blocks. 
111 lines changed or deleted 79 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/