Landscape.cpp   Landscape.cpp 
skipping to change at line 25 skipping to change at line 25
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, U SA. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, U SA.
*/ */
#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 "Location.hpp" #include "StelLocation.hpp"
#include "StelCore.hpp"
#include "StelPainter.hpp"
#include <QDebug> #include <QDebug>
#include <QSettings> #include <QSettings>
Landscape::Landscape(float _radius) : radius(_radius), skyBrightness(1.) Landscape::Landscape(float _radius) : radius(_radius), skyBrightness(1.), a ngleRotateZOffset(0.)
{ {
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 65 skipping to change at line 67
} }
// Optional data // Optional data
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()); 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()); location.longitude = StelUtils::getDecAngle(landscapeIni.val ue("location/longitude").toString())*180./M_PI;
if (landscapeIni.contains("location/country")) if (landscapeIni.contains("location/country"))
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;
} }
skipping to change at line 125 skipping to change at line 127
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 STextureSP[nbSideTexs]; sideTexs = new StelTextureSP[nbSideTexs];
StelApp::getInstance().getTextureManager().setDefaultParams(); StelApp::getInstance().getTextureManager().setDefaultParams();
StelApp::getInstance().getTextureManager().setWrapMode(GL_CLAMP_TO_E DGE); 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();
skipping to change at line 175 skipping to change at line 177
StelApp::getInstance().getTextureManager().setWrapMode(GL_REPEAT); StelApp::getInstance().getTextureManager().setWrapMode(GL_REPEAT);
fogTex = StelApp::getInstance().getTextureManager().createTexture(ge tTexturePath(landscapeIni.value("landscape/fogtex").toString(), landscapeId )); fogTex = StelApp::getInstance().getTextureManager().createTexture(ge tTexturePath(landscapeIni.value("landscape/fogtex").toString(), landscapeId ));
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();
decorAltAngle = landscapeIni.value("landscape/decor_alt_angle", 0.).toDouble(); decorAltAngle = landscapeIni.value("landscape/decor_alt_angle", 0.).toDouble();
decorAngleShift = landscapeIni.value("landscape/decor_angle_shift ", 0.).toDouble(); decorAngleShift = landscapeIni.value("landscape/decor_angle_shift ", 0.).toDouble();
decorAngleRotatez = landscapeIni.value("landscape/decor_angle_rotat ez", 0.).toDouble(); angleRotateZ = landscapeIni.value("landscape/decor_angle_rotat ez", 0.).toDouble();
groundAngleShift = landscapeIni.value("landscape/ground_angle_shif t", 0.).toDouble(); groundAngleShift = landscapeIni.value("landscape/ground_angle_shif t", 0.).toDouble();
groundAngleRotatez = landscapeIni.value("landscape/ground_angle_rota groundAngleRotateZ = landscapeIni.value("landscape/ground_angle_rota
tez", 0.).toDouble(); tez", 0.).toDouble();
drawGroundFirst = landscapeIni.value("landscape/draw_ground_fir drawGroundFirst = landscapeIni.value("landscape/draw_ground_first
st", 0).toInt(); ", 0).toInt();
tanMode = landscapeIni.value("landscape/tan_mode", fals tanMode = landscapeIni.value("landscape/tan_mode", false)
e).toBool(); .toBool();
} }
// create from a hash of parameters (no ini file needed) // create from a hash of parameters (no ini file needed)
void LandscapeOldStyle::create(bool _fullpath, QMap<QString, QString> param ) void LandscapeOldStyle::create(bool _fullpath, QMap<QString, QString> param )
{ {
name = param["name"]; name = param["name"];
validLandscape = 1; // assume valid if got here validLandscape = 1; // assume valid if got here
// Load sides textures // Load sides textures
nbSideTexs = param["nbsidetex"].toInt(); nbSideTexs = param["nbsidetex"].toInt();
sideTexs = new STextureSP[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]);
} }
skipping to change at line 249 skipping to change at line 251
StelApp::getInstance().getTextureManager().setWrapMode(GL_REPEAT); StelApp::getInstance().getTextureManager().setWrapMode(GL_REPEAT);
fogTex = StelApp::getInstance().getTextureManager().createTexture(pa ram["path"] + param["fogtex"]); fogTex = StelApp::getInstance().getTextureManager().createTexture(pa ram["path"] + param["fogtex"]);
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();
decorAngleRotatez = 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(ToneReproducer * eye, const Projector* prj, co nst Navigator* nav) void LandscapeOldStyle::draw(StelCore* core)
{ {
if(!validLandscape) return; if(!validLandscape) return;
if (drawGroundFirst) drawGround(eye, prj, nav); if (drawGroundFirst) drawGround(core);
drawDecor(eye, prj, nav); drawDecor(core);
if (!drawGroundFirst) drawGround(eye, prj, nav); if (!drawGroundFirst) drawGround(core);
drawFog(eye, prj, nav); drawFog(core);
} }
// Draw the horizon fog // Draw the horizon fog
void LandscapeOldStyle::drawFog(ToneReproducer * eye, const Projector* prj, const Navigator* nav) const void LandscapeOldStyle::drawFog(StelCore* core) const
{ {
if(!fogFader.getInterstate()) return; if (!fogFader.getInterstate())
return;
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()-
>getAltAzModelViewMat() * Mat4d::translation(Vec3d(0.,0.,vpos)));
StelPainter sPainter(prj);
glBlendFunc(GL_ONE, GL_ONE); glBlendFunc(GL_ONE, GL_ONE);
glColor3f(fogFader.getInterstate()*(0.1f+0.1f*skyBrightness), fogFad float nightModeFilter = StelApp::getInstance().getVisionModeNight()
er.getInterstate()*(0.1f+0.1f*skyBrightness), fogFader.getInterstate()*(0.1 ? 0. : 1.;
f+0.1f*skyBrightness)); glColor3f(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);
glEnable(GL_TEXTURE_2D); glEnable(GL_TEXTURE_2D);
glEnable(GL_BLEND); glEnable(GL_BLEND);
glEnable(GL_CULL_FACE); glEnable(GL_CULL_FACE);
fogTex->bind(); fogTex->bind();
const double vpos = tanMode ? radius*std::tan(fogAngleShift*M_PI/180
.) : radius*std::sin(fogAngleShift*M_PI/180.);
prj->setCustomFrame(nav->getLocalToEyeMat() * Mat4d::translation(Vec
3d(0.,0.,vpos)));
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.);
prj->sCylinder(radius, height, 128, 1, 1); sPainter.sCylinder(radius, height, 128, 1, 1);
glDisable(GL_CULL_FACE); 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(ToneReproducer * eye, const Projector* pr j, const Navigator* nav) const void LandscapeOldStyle::drawDecor(StelCore* core) const
{ {
const StelProjectorP prj = core->getProjection(StelCore::FrameAltAz)
;
StelPainter sPainter(prj);
if (!landFader.getInterstate()) return; if (!landFader.getInterstate()) return;
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glEnable(GL_TEXTURE_2D); glEnable(GL_TEXTURE_2D);
glEnable(GL_BLEND); glEnable(GL_BLEND);
glEnable(GL_CULL_FACE); glEnable(GL_CULL_FACE);
float nightModeFilter = StelApp::getInstance().getVisionModeNight()
glColor4f(skyBrightness, skyBrightness, skyBrightness, ? 0. : 1.;
landFader.getInterstate()); glColor4f(skyBrightness, skyBrightness*nightModeFilter, skyBrightnes
prj->setCurrentFrame(Projector::FrameLocal); s*nightModeFilter, landFader.getInterstate());
const int stacks = 8; 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(decorAngleRotatez*M_PI/180.0); double y0 = radius*cos((angleRotateZ+angleRotateZOffset)*M_PI/180.0)
double x0 = radius*sin(decorAngleRotatez*M_PI/180.0); ;
double x0 = radius*sin((angleRotateZ+angleRotateZOffset)*M_PI/180.0)
;
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 s[0]) const float d_tx0 = (sides[i].texCoords[2]-sides[i].texCoord s[0])
/ slices_per_side; / slices_per_side;
const float d_ty = (sides[i].texCoords[3]-sides[i].texCoords [1]) const float d_ty = (sides[i].texCoords[3]-sides[i].texCoords [1])
/ stacks; / 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); glBegin(GL_QUAD_STRIP);
for (int k=0;k<=stacks;k++) { for (int k=0;k<=stacks;k++) {
glTexCoord2f(tx0,ty0); glTexCoord2f(tx0,ty0);
prj->drawVertex3(x0, y0, z); sPainter.drawVertex3(x0, y0, z);
glTexCoord2f(tx1,ty0); glTexCoord2f(tx1,ty0);
prj->drawVertex3(x1, y1, z); sPainter.drawVertex3(x1, y1, z);
z += d_z; z += d_z;
ty0 += d_ty; ty0 += d_ty;
} }
glEnd(); glEnd();
y0 = y1; y0 = y1;
x0 = x1; x0 = x1;
tx0 = tx1; tx0 = tx1;
} }
} }
glDisable(GL_CULL_FACE); glDisable(GL_CULL_FACE);
} }
// Draw the ground // Draw the ground
void LandscapeOldStyle::drawGround(ToneReproducer * eye, const Projector* p rj, const Navigator* nav) const void LandscapeOldStyle::drawGround(StelCore* core) const
{ {
const StelNavigator* nav = core->getNavigator();
if (!landFader.getInterstate()) return; 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->getLocalToEyeMat() * Mat4d::zrotation(groundAngleRo Mat4d mat = nav->getAltAzModelViewMat() * Mat4d::zrotation((groundAn
tatez*M_PI/180.f) * Mat4d::translation(Vec3d(0,0,vshift)); gleRotateZ-angleRotateZOffset)*M_PI/180.f) * Mat4d::translation(Vec3d(0,0,v
shift));
const StelProjectorP prj = core->getProjection(mat);
StelPainter sPainter(prj);
float nightModeFilter = StelApp::getInstance().getVisionModeNight()
? 0. : 1.;
glColor4f(skyBrightness, skyBrightness*nightModeFilter, skyBrightnes
s*nightModeFilter, landFader.getInterstate());
glColor4f(skyBrightness, skyBrightness, skyBrightness, landFader.get Interstate());
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glEnable(GL_CULL_FACE); glEnable(GL_CULL_FACE);
glEnable(GL_TEXTURE_2D); glEnable(GL_TEXTURE_2D);
glEnable(GL_BLEND); 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;
prj->setCustomFrame(mat);
// 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); //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;
} }
prj->sFanDisk(radius,slices_inside,level); sPainter.sFanDisk(radius,slices_inside,level);
glDisable(GL_CULL_FACE); glDisable(GL_CULL_FACE);
} }
LandscapeFisheye::LandscapeFisheye(float _radius) : Landscape(_radius) LandscapeFisheye::LandscapeFisheye(float _radius) : Landscape(_radius)
{} {}
LandscapeFisheye::~LandscapeFisheye() LandscapeFisheye::~LandscapeFisheye()
{ {
} }
skipping to change at line 406 skipping to change at line 421
validLandscape = 0; validLandscape = 0;
return; return;
} }
create(name, 0, getTexturePath(landscapeIni.value("landscape/maptex" ).toString(), landscapeId), create(name, 0, getTexturePath(landscapeIni.value("landscape/maptex" ).toString(), landscapeId),
landscapeIni.value("landscape/texturefov", 360).toDouble(), landscapeIni.value("landscape/texturefov", 360).toDouble(),
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(); StelApp::getInstance().getTextureManager().setDefaultParams();
mapTex = StelApp::getInstance().getTextureManager().createTexture(_m aptex); mapTex = StelApp::getInstance().getTextureManager().createTexture(_m aptex);
texFov = _texturefov*M_PI/180.; texFov = _texturefov*M_PI/180.;
angleRotatez = _angleRotatez*M_PI/180.; angleRotateZ = _angleRotateZ*M_PI/180.;
} }
void LandscapeFisheye::draw(ToneReproducer * eye, const Projector* prj, con st Navigator* nav) void LandscapeFisheye::draw(StelCore* core)
{ {
if(!validLandscape) return; if(!validLandscape) return;
if(!landFader.getInterstate()) return; if(!landFader.getInterstate()) return;
StelNavigator* nav = core->getNavigator();
const StelProjectorP prj = core->getProjection(nav->getAltAzModelVie
wMat() * Mat4d::zrotation(-(angleRotateZ+(angleRotateZOffset*2*M_PI/360.)))
);
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()
glColor4f(skyBrightness, skyBrightness, skyBrightness, landFader.get ? 0. : 1.;
Interstate()); glColor4f(skyBrightness, skyBrightness*nightModeFilter, skyBrightnes
s*nightModeFilter, landFader.getInterstate());
glEnable(GL_CULL_FACE); glEnable(GL_CULL_FACE);
glEnable(GL_TEXTURE_2D); glEnable(GL_TEXTURE_2D);
glEnable(GL_BLEND); glEnable(GL_BLEND);
mapTex->bind(); mapTex->bind();
prj->setCustomFrame(nav->getLocalToEyeMat() * Mat4d::zrotation(-angl sPainter.sSphereMap(radius,40,20,texFov,1);
eRotatez));
prj->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)
{} {}
LandscapeSpherical::~LandscapeSpherical() LandscapeSpherical::~LandscapeSpherical()
skipping to change at line 466 skipping to change at line 484
validLandscape = 0; validLandscape = 0;
return; return;
} }
create(name, 0, getTexturePath(landscapeIni.value("landscape/maptex" ).toString(), landscapeId), create(name, 0, getTexturePath(landscapeIni.value("landscape/maptex" ).toString(), landscapeId),
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(); StelApp::getInstance().getTextureManager().setDefaultParams();
mapTex = StelApp::getInstance().getTextureManager().createTexture(_m aptex); mapTex = StelApp::getInstance().getTextureManager().createTexture(_m aptex);
angleRotatez = _angleRotatez*M_PI/180.; angleRotateZ = _angleRotateZ*M_PI/180.;
} }
void LandscapeSpherical::draw(ToneReproducer * eye, const Projector* prj, c onst Navigator* nav) void LandscapeSpherical::draw(StelCore* core)
{ {
if(!validLandscape) return; if(!validLandscape) return;
if(!landFader.getInterstate()) return; if(!landFader.getInterstate()) return;
StelNavigator* nav = core->getNavigator();
const StelProjectorP prj = core->getProjection(nav->getAltAzModelVie
wMat() * Mat4d::zrotation(-(angleRotateZ+(angleRotateZOffset*2*M_PI/360.)))
);
StelPainter sPainter(prj);
// Need to flip texture usage horizontally due to glusphere conventi on // Need to flip texture usage horizontally due to glusphere conventi on
// so that left-right is consistent in source texture and rendering // so that left-right is consistent in source texture and rendering
glMatrixMode(GL_TEXTURE); glMatrixMode(GL_TEXTURE);
glPushMatrix(); glPushMatrix();
glLoadIdentity(); glLoadIdentity();
glScalef(-1,1,1); glScalef(-1,1,1);
glTranslatef(-1,0,0); glTranslatef(-1,0,0);
glMatrixMode(GL_MODELVIEW); 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()
glColor4f(skyBrightness, skyBrightness, skyBrightness, landFader.get ? 0. : 1.;
Interstate()); glColor4f(skyBrightness, skyBrightness*nightModeFilter, skyBrightnes
s*nightModeFilter, landFader.getInterstate());
glEnable(GL_CULL_FACE); glEnable(GL_CULL_FACE);
glEnable(GL_TEXTURE_2D); glEnable(GL_TEXTURE_2D);
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
prj->setCustomFrame(nav->getLocalToEyeMat() * Mat4d::zrotation(-angl sPainter.sSphere(radius,1.0,40,20,1);
eRotatez));
prj->sSphere(radius,1.0,40,20,1);
glDisable(GL_CULL_FACE); glDisable(GL_CULL_FACE);
glMatrixMode(GL_TEXTURE); glMatrixMode(GL_TEXTURE);
glPopMatrix(); glPopMatrix();
glMatrixMode(GL_MODELVIEW); glMatrixMode(GL_MODELVIEW);
} }
 End of changes. 42 change blocks. 
73 lines changed or deleted 107 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/