SolarSystem.cpp   SolarSystem.cpp 
skipping to change at line 22 skipping to change at line 22
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* 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 <algorithm> #include <algorithm>
#include "SolarSystem.hpp" #include "SolarSystem.hpp"
#include "STexture.hpp" #include "StelTexture.hpp"
#include "stellplanet.h" #include "stellplanet.h"
#include "Orbit.hpp" #include "Orbit.hpp"
#include "Navigator.hpp" #include "StelNavigator.hpp"
#include "Projector.hpp" #include "StelProjector.hpp"
#include "StelApp.hpp" #include "StelApp.hpp"
#include "StelCore.hpp" #include "StelCore.hpp"
#include "StelTextureMgr.hpp" #include "StelTextureMgr.hpp"
#include "StelObjectMgr.hpp" #include "StelObjectMgr.hpp"
#include "StelFontMgr.hpp" #include "StelFontMgr.hpp"
#include "StelLocaleMgr.hpp" #include "StelLocaleMgr.hpp"
#include "StelSkyCultureMgr.hpp" #include "StelSkyCultureMgr.hpp"
#include "StelFileMgr.hpp" #include "StelFileMgr.hpp"
#include "StelModuleMgr.hpp" #include "StelModuleMgr.hpp"
#include "StelIniParser.hpp" #include "StelIniParser.hpp"
#include "Planet.hpp" #include "Planet.hpp"
#include "Navigator.hpp" #include "StelNavigator.hpp"
#include "SFont.hpp" #include "StelFont.hpp"
#include "SkyDrawer.hpp" #include "StelSkyDrawer.hpp"
#include "StelStyle.hpp" #include "StelStyle.hpp"
#include "StelUtils.hpp" #include "StelUtils.hpp"
#include "StelPainter.hpp"
#include <QTextStream> #include <QTextStream>
#include <QSettings> #include <QSettings>
#include <QVariant> #include <QVariant>
#include <QString> #include <QString>
#include <QStringList> #include <QStringList>
#include <QMap> #include <QMap>
#include <QMultiMap> #include <QMultiMap>
#include <QMapIterator> #include <QMapIterator>
#include <QDebug> #include <QDebug>
skipping to change at line 86 skipping to change at line 87
} }
for(std::vector<Orbit*>::iterator iter = orbits.begin(); iter != orb its.end(); ++iter) for(std::vector<Orbit*>::iterator iter = orbits.begin(); iter != orb its.end(); ++iter)
{ {
if (*iter) delete *iter; if (*iter) delete *iter;
*iter = NULL; *iter = NULL;
} }
sun = NULL; sun = NULL;
moon = NULL; moon = NULL;
earth = NULL; earth = NULL;
Planet::hintCircleTex.reset(); Planet::hintCircleTex.reset();
Planet::texEarthShadow.reset();
} }
/************************************************************************* /*************************************************************************
Reimplementation of the getCallOrder method Reimplementation of the getCallOrder method
*************************************************************************/ *************************************************************************/
double SolarSystem::getCallOrder(StelModuleActionName actionName) const double SolarSystem::getCallOrder(StelModuleActionName actionName) const
{ {
if (actionName==StelModule::ActionDraw) if (actionName==StelModule::ActionDraw)
return StelApp::getInstance().getModuleMgr().getModule("Star Mgr")->getCallOrder(actionName)+10; return StelApp::getInstance().getModuleMgr().getModule("Star Mgr")->getCallOrder(actionName)+10;
return 0; return 0;
} }
// Init and load the solar system data // Init and load the solar system data
void SolarSystem::init() void SolarSystem::init()
{ {
QSettings* conf = StelApp::getInstance().getSettings(); QSettings* conf = StelApp::getInstance().getSettings();
assert(conf); Q_ASSERT(conf);
loadPlanets(); // Load planets data loadPlanets(); // Load planets data
// Compute position and matrix of sun and all the satellites (ie pla nets) // Compute position and matrix of sun and all the satellites (ie pla nets)
// for the first initialization assert that center is sun center (on ly impacts on light speed correction) // for the first initialization Q_ASSERT that center is sun center ( only impacts on light speed correction)
computePositions(StelUtils::getJDFromSystem()); computePositions(StelUtils::getJDFromSystem());
setSelected(""); // Fix a bug on macosX! Thanks Fumio! setSelected(""); // Fix a bug on macosX! Thanks Fumio!
setFlagMoonScale(conf->value("viewing/flag_moon_scaled", conf->value ("viewing/flag_init_moon_scaled", "false").toBool()).toBool()); // name ch ange setFlagMoonScale(conf->value("viewing/flag_moon_scaled", conf->value ("viewing/flag_init_moon_scaled", "false").toBool()).toBool()); // name ch ange
setMoonScale(conf->value("viewing/moon_scale", 5.0).toDouble()); setMoonScale(conf->value("viewing/moon_scale", 5.0).toDouble());
setFlagPlanets(conf->value("astro/flag_planets").toBool()); setFlagPlanets(conf->value("astro/flag_planets").toBool());
setFlagHints(conf->value("astro/flag_planets_hints").toBool()); setFlagHints(conf->value("astro/flag_planets_hints").toBool());
setFlagLabels(conf->value("astro/flag_planets_labels", true).toBool( )); setFlagLabels(conf->value("astro/flag_planets_labels", true).toBool( ));
setLabelsAmount(conf->value("astro/labels_amount", 3.).toDouble()); setLabelsAmount(conf->value("astro/labels_amount", 3.).toDouble());
setFlagOrbits(conf->value("astro/flag_planets_orbits").toBool()); setFlagOrbits(conf->value("astro/flag_planets_orbits").toBool());
setFlagLightTravelTime(conf->value("astro/flag_light_travel_time", f alse).toBool()); setFlagLightTravelTime(conf->value("astro/flag_light_travel_time", f alse).toBool());
skipping to change at line 130 skipping to change at line 132
StelApp::getInstance().getStelObjectMgr().registerStelObjectMgr(this ); StelApp::getInstance().getStelObjectMgr().registerStelObjectMgr(this );
StelApp::getInstance().getTextureManager().setDefaultParams(); StelApp::getInstance().getTextureManager().setDefaultParams();
StelApp::getInstance().getTextureManager().setMinFilter(GL_LINEAR); StelApp::getInstance().getTextureManager().setMinFilter(GL_LINEAR);
texPointer = StelApp::getInstance().getTextureManager().createTextur e("pointeur4.png"); texPointer = StelApp::getInstance().getTextureManager().createTextur e("pointeur4.png");
Planet::hintCircleTex = StelApp::getInstance().getTextureManager().c reateTexture("planet-indicator.png"); Planet::hintCircleTex = StelApp::getInstance().getTextureManager().c reateTexture("planet-indicator.png");
} }
void SolarSystem::drawPointer(const StelCore* core) void SolarSystem::drawPointer(const StelCore* core)
{ {
const Navigator* nav = core->getNavigation(); const StelNavigator* nav = core->getNavigator();
const Projector* prj = core->getProjection(); const StelProjectorP prj = core->getProjection(StelCore::FrameJ2000)
;
const QList<StelObjectP> newSelected = StelApp::getInstance().getSte lObjectMgr().getSelectedObject("Planet"); const QList<StelObjectP> newSelected = StelApp::getInstance().getSte lObjectMgr().getSelectedObject("Planet");
if (!newSelected.empty()) if (!newSelected.empty())
{ {
const StelObjectP obj = newSelected[0]; const StelObjectP obj = newSelected[0];
Vec3d pos=obj->getObsJ2000Pos(nav); Vec3d pos=obj->getJ2000EquatorialPos(nav);
Vec3d screenpos; Vec3d screenpos;
prj->setCurrentFrame(Projector::FrameJ2000);
// Compute 2D pos and return if outside screen // Compute 2D pos and return if outside screen
if (!prj->project(pos, screenpos)) return; if (!prj->project(pos, screenpos))
return;
StelPainter sPainter(prj);
glColor3f(1.0f,0.3f,0.3f); glColor3f(1.0f,0.3f,0.3f);
float size = obj->getOnScreenSize(core)*2; float size = obj->getAngularSize(core)*M_PI/180.*prj->getPix elPerRadAtCenter()*2.;
size+=26.f + 10.f*std::sin(2.f * StelApp::getInstance().getT otalRunTime()); size+=26.f + 10.f*std::sin(2.f * StelApp::getInstance().getT otalRunTime());
texPointer->bind(); texPointer->bind();
glEnable(GL_TEXTURE_2D); glEnable(GL_TEXTURE_2D);
glEnable(GL_BLEND); glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); // Normal transp arency mode glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); // Normal transp arency mode
glPushMatrix(); glPushMatrix();
glTranslatef(screenpos[0], screenpos[1], 0.0f); glTranslatef(screenpos[0], screenpos[1], 0.0f);
skipping to change at line 343 skipping to change at line 346
double pericenterDistance = pd.value(secname+"/orbit _PericenterDistance",-1e100).toDouble(); double pericenterDistance = pd.value(secname+"/orbit _PericenterDistance",-1e100).toDouble();
double semi_major_axis; double semi_major_axis;
if (pericenterDistance <= 0.0) { if (pericenterDistance <= 0.0) {
semi_major_axis = pd.value(secname+"/orbit_S emiMajorAxis",-1e100).toDouble(); semi_major_axis = pd.value(secname+"/orbit_S emiMajorAxis",-1e100).toDouble();
if (semi_major_axis <= -1e100) { if (semi_major_axis <= -1e100) {
qDebug() << "ERROR: " << englishName qDebug() << "ERROR: " << englishName
<< ": you must provide orbit _PericenterDistance or orbit_SemiMajorAxis"; << ": you must provide orbit _PericenterDistance or orbit_SemiMajorAxis";
abort(); abort();
} else { } else {
semi_major_axis /= AU; semi_major_axis /= AU;
assert(eccentricity != 1.0); // para bolic orbits have no semi_major_axis Q_ASSERT(eccentricity != 1.0); // pa rabolic orbits have no semi_major_axis
pericenterDistance = semi_major_axis * (1.0-eccentricity); pericenterDistance = semi_major_axis * (1.0-eccentricity);
} }
} else { } else {
pericenterDistance /= AU; pericenterDistance /= AU;
semi_major_axis = (eccentricity == 1.0) semi_major_axis = (eccentricity == 1.0)
? 0.0 // parabolic orbits ha ve no semi_major_axis ? 0.0 // parabolic orbits ha ve no semi_major_axis
: pericenterDistance / (1.0- eccentricity); : pericenterDistance / (1.0- eccentricity);
} }
double meanMotion = pd.value(secname+"/orbit_MeanMot ion",-1e100).toDouble(); double meanMotion = pd.value(secname+"/orbit_MeanMot ion",-1e100).toDouble();
double period; double period;
skipping to change at line 407 skipping to change at line 410
: 0.0; : 0.0;
double parent_rot_j2000_longitude = 0.0; double parent_rot_j2000_longitude = 0.0;
if (parent->getParent()) { if (parent->getParent()) {
const double c_obl = cos(parentRotObliquity) ; const double c_obl = cos(parentRotObliquity) ;
const double s_obl = sin(parentRotObliquity) ; const double s_obl = sin(parentRotObliquity) ;
const double c_nod = cos(parent_rot_asc_node ); const double c_nod = cos(parent_rot_asc_node );
const double s_nod = sin(parent_rot_asc_node ); const double s_nod = sin(parent_rot_asc_node );
const Vec3d OrbitAxis0( c_nod, s_nod, 0.0); const Vec3d OrbitAxis0( c_nod, s_nod, 0.0);
const Vec3d OrbitAxis1(-s_nod*c_obl, c_nod*c _obl,s_obl); const Vec3d OrbitAxis1(-s_nod*c_obl, c_nod*c _obl,s_obl);
const Vec3d OrbitPole( s_nod*s_obl,-c_nod*s _obl,c_obl); const Vec3d OrbitPole( s_nod*s_obl,-c_nod*s _obl,c_obl);
const Vec3d J2000Pole(matJ2000ToVsop87.multi plyWithoutTranslation(Vec3d(0,0,1))); const Vec3d J2000Pole(StelNavigator::matJ200 0ToVsop87.multiplyWithoutTranslation(Vec3d(0,0,1)));
Vec3d J2000NodeOrigin(J2000Pole^OrbitPole); Vec3d J2000NodeOrigin(J2000Pole^OrbitPole);
J2000NodeOrigin.normalize(); J2000NodeOrigin.normalize();
parent_rot_j2000_longitude = atan2(J2000Node Origin*OrbitAxis1,J2000NodeOrigin*OrbitAxis0); parent_rot_j2000_longitude = atan2(J2000Node Origin*OrbitAxis1,J2000NodeOrigin*OrbitAxis0);
} }
// Create an elliptical orbit // Create an elliptical orbit
EllipticalOrbit *orb = new EllipticalOrbit(pericente rDistance, EllipticalOrbit *orb = new EllipticalOrbit(pericente rDistance,
eccentric ity, eccentric ity,
inclinati on, inclinati on,
ascending _node, ascending _node,
skipping to change at line 448 skipping to change at line 451
if (eccentricity >= 1.0) closeOrbit = false; if (eccentricity >= 1.0) closeOrbit = false;
double pericenterDistance = pd.value(secname+"/orbit _PericenterDistance",-1e100).toDouble(); double pericenterDistance = pd.value(secname+"/orbit _PericenterDistance",-1e100).toDouble();
double semi_major_axis; double semi_major_axis;
if (pericenterDistance <= 0.0) { if (pericenterDistance <= 0.0) {
semi_major_axis = pd.value(secname+"/orbit_S emiMajorAxis",-1e100).toDouble(); semi_major_axis = pd.value(secname+"/orbit_S emiMajorAxis",-1e100).toDouble();
if (semi_major_axis <= -1e100) { if (semi_major_axis <= -1e100) {
qWarning() << "ERROR: " << englishNa me qWarning() << "ERROR: " << englishNa me
<< ": you must provide orbit _PericenterDistance or orbit_SemiMajorAxis"; << ": you must provide orbit _PericenterDistance or orbit_SemiMajorAxis";
abort(); abort();
} else { } else {
assert(eccentricity != 1.0); // para bolic orbits have no semi_major_axis Q_ASSERT(eccentricity != 1.0); // pa rabolic orbits have no semi_major_axis
pericenterDistance = semi_major_axis * (1.0-eccentricity); pericenterDistance = semi_major_axis * (1.0-eccentricity);
} }
} else { } else {
semi_major_axis = (eccentricity == 1.0) semi_major_axis = (eccentricity == 1.0)
? 0.0 // parabolic orbits ha ve no semi_major_axis ? 0.0 // parabolic orbits ha ve no semi_major_axis
: pericenterDistance / (1.0- eccentricity); : pericenterDistance / (1.0- eccentricity);
} }
double meanMotion = pd.value(secname+"/orbit_MeanMot ion",-1e100).toDouble(); double meanMotion = pd.value(secname+"/orbit_MeanMot ion",-1e100).toDouble();
if (meanMotion <= -1e100) { if (meanMotion <= -1e100) {
const double period = pd.value(secname+"/orb it_Period",-1e100).toDouble(); const double period = pd.value(secname+"/orb it_Period",-1e100).toDouble();
skipping to change at line 512 skipping to change at line 515
: 0.0; : 0.0;
double parent_rot_j2000_longitude = 0.0; double parent_rot_j2000_longitude = 0.0;
if (parent->getParent()) { if (parent->getParent()) {
const double c_obl = cos(parentRotObliquity); const double c_obl = cos(parentRotObliquity);
const double s_obl = sin(parentRotObliquity); const double s_obl = sin(parentRotObliquity);
const double c_nod = cos(parent_rot_asc_node); const double c_nod = cos(parent_rot_asc_node);
const double s_nod = sin(parent_rot_asc_node); const double s_nod = sin(parent_rot_asc_node);
const Vec3d OrbitAxis0( c_nod, s_nod, 0.0); const Vec3d OrbitAxis0( c_nod, s_nod, 0.0);
const Vec3d OrbitAxis1(-s_nod*c_obl, c_nod*c_obl ,s_obl); const Vec3d OrbitAxis1(-s_nod*c_obl, c_nod*c_obl ,s_obl);
const Vec3d OrbitPole( s_nod*s_obl,-c_nod*s_obl ,c_obl); const Vec3d OrbitPole( s_nod*s_obl,-c_nod*s_obl ,c_obl);
const Vec3d J2000Pole(matJ2000ToVsop87.multiplyW ithoutTranslation(Vec3d(0,0,1))); const Vec3d J2000Pole(Ste lNavigator::matJ2000ToVsop87.multiplyWithoutTranslation(Vec3d(0,0,1)));
Vec3d J2000NodeOrigin(J2000Pole^OrbitPole); Vec3d J2000NodeOrigin(J2000Pole^OrbitPole);
J2000NodeOrigin.normalize(); J2000NodeOrigin.normalize();
parent_rot_j2000_longitude = atan2(J2000NodeOrig in*OrbitAxis1,J2000NodeOrigin*OrbitAxis0); parent_rot_j2000_longitude = atan2(J2000NodeOrig in*OrbitAxis1,J2000NodeOrigin*OrbitAxis0);
} }
CometOrbit *orb = new CometOrbit(pericenterDistance, CometOrbit *orb = new CometOrbit(pericenterDistance,
eccentricity, eccentricity,
inclination, inclination,
ascending_node, ascending_node,
arg_of_pericenter, arg_of_pericenter,
time_at_pericenter, time_at_pericenter,
skipping to change at line 645 skipping to change at line 648
if (funcName=="pluto_special") if (funcName=="pluto_special")
posfunc = posFuncType(get_pluto_helio_coordsv); posfunc = posFuncType(get_pluto_helio_coordsv);
if (posfunc.empty()) if (posfunc.empty())
{ {
qWarning() << "ERROR : can't find posfunc " << funcN ame << " for " << englishName; qWarning() << "ERROR : can't find posfunc " << funcN ame << " for " << englishName;
exit(-1); exit(-1);
} }
// Create the Planet and add it to the list // Create the Planet and add it to the list
Planet* p = new Planet(parent, Planet* p = new Planet(englishName,
englishName,
pd.value(secname+"/halo").toBool(),
pd.value(secname+"/lighting").toBool (), pd.value(secname+"/lighting").toBool (),
pd.value(secname+"/radius").toDouble ()/AU, pd.value(secname+"/radius").toDouble ()/AU,
pd.value(secname+"/oblateness", 0.0) .toDouble(), pd.value(secname+"/oblateness", 0.0) .toDouble(),
StelUtils::strToVec3f(pd.value(secna me+"/color").toString()), StelUtils::strToVec3f(pd.value(secna me+"/color").toString()),
pd.value(secname+"/albedo").toDouble (), pd.value(secname+"/albedo").toDouble (),
pd.value(secname+"/tex_map").toStrin g(), pd.value(secname+"/tex_map").toStrin g(),
pd.value(secname+"/tex_halo").toStri ng(), pd.value(secname+"/tex_halo").toStri ng(),
posfunc, posfunc,
osculatingFunc, osculatingFunc,
closeOrbit, closeOrbit,
pd.value(secname+"/hidden", 0).toBoo l(), pd.value(secname+"/hidden", 0).toBoo l(),
pd.value(secname+"/atmosphere", fals e).toBool()); pd.value(secname+"/atmosphere", fals e).toBool());
if (parent!=NULL)
p->setParent(parent);
if (secname=="earth") earth = p; if (secname=="earth") earth = p;
if (secname=="sun") sun = p; if (secname=="sun") sun = p;
if (secname=="moon") moon = p; if (secname=="moon") moon = p;
double rotObliquity = pd.value(secname+"/rot_obliquity",0.). toDouble()*(M_PI/180.0); double rotObliquity = pd.value(secname+"/rot_obliquity",0.). toDouble()*(M_PI/180.0);
double rotAscNode = pd.value(secname+"/rot_equator_ascending _node",0.).toDouble()*(M_PI/180.0); double rotAscNode = pd.value(secname+"/rot_equator_ascending _node",0.).toDouble()*(M_PI/180.0);
// Use more common planet North pole data if available // Use more common planet North pole data if available
// NB: N pole as defined by IAU (NOT right hand rotation rul e) // NB: N pole as defined by IAU (NOT right hand rotation rul e)
// NB: J2000 epoch // NB: J2000 epoch
double J2000NPoleRA = pd.value(secname+"/rot_pole_ra", 0.).t oDouble()*M_PI/180.; double J2000NPoleRA = pd.value(secname+"/rot_pole_ra", 0.).t oDouble()*M_PI/180.;
double J2000NPoleDE = pd.value(secname+"/rot_pole_de", 0.).t oDouble()*M_PI/180.; double J2000NPoleDE = pd.value(secname+"/rot_pole_de", 0.).t oDouble()*M_PI/180.;
if(J2000NPoleRA || J2000NPoleDE) { if(J2000NPoleRA || J2000NPoleDE)
// qDebug() << "Using north pole data for " << engli {
shName << endl;
Vec3d J2000NPole; Vec3d J2000NPole;
StelUtils::spheToRect(J2000NPoleRA,J2000NPoleDE,J200 0NPole); StelUtils::spheToRect(J2000NPoleRA,J2000NPoleDE,J200 0NPole);
Vec3d vsop87Pole(matJ2000ToVsop87.multiplyWithoutTra nslation(J2000NPole)); Vec3d vsop87Pole(StelNavigator::matJ2000ToVsop87.mul tiplyWithoutTranslation(J2000NPole));
double ra, de; double ra, de;
StelUtils::rectToSphe(&ra, &de, vsop87Pole); StelUtils::rectToSphe(&ra, &de, vsop87Pole);
rotObliquity = (M_PI_2 - de); rotObliquity = (M_PI_2 - de);
rotAscNode = (ra + M_PI_2); rotAscNode = (ra + M_PI_2);
// qDebug() << "\tCalculated rotational obliquity: " << rotObliquity*180./M_PI << endl; // qDebug() << "\tCalculated rotational obliquity: " << rotObliquity*180./M_PI << endl;
// qDebug() << "\tCalculated rotational ascending no de: " << rotAscNode*180./M_PI << endl; // qDebug() << "\tCalculated rotational ascending no de: " << rotAscNode*180./M_PI << endl;
} }
p->setRotationElements( p->setRotationElements(
pd.value(secname+"/rot_periode", pd.value(secname+"/orbi t_Period", 24.).toDouble()).toDouble()/24., pd.value(secname+"/rot_periode", pd.value(secname+"/orbi t_Period", 24.).toDouble()).toDouble()/24.,
pd.value(secname+"/rot_rotation_offset",0.).toDouble(), pd.value(secname+"/rot_rotation_offset",0.).toDouble(),
pd.value(secname+"/rot_epoch", J2000).toDouble(), pd.value(secname+"/rot_epoch", J2000).toDouble(),
rotObliquity, rotObliquity,
rotAscNode, rotAscNode,
pd.value(secname+"/rot_precession_rate",0.).toDouble()*M _PI/(180*36525), pd.value(secname+"/rot_precession_rate",0.).toDouble()*M _PI/(180*36525),
pd.value(secname+"/orbit_visualization_period",0.).toDou ble()); pd.value(secname+"/orbit_visualization_period",0.).toDou ble());
skipping to change at line 715 skipping to change at line 715
Ring *r = new Ring(rMin,rMax,pd.value(secname+"/tex_ ring").toString()); Ring *r = new Ring(rMin,rMax,pd.value(secname+"/tex_ ring").toString());
p->setRings(r); p->setRings(r);
} }
systemPlanets.push_back(p); systemPlanets.push_back(p);
readOk++; readOk++;
} }
// special case: load earth shadow texture // special case: load earth shadow texture
StelApp::getInstance().getTextureManager().setDefaultParams(); StelApp::getInstance().getTextureManager().setDefaultParams();
texEarthShadow = StelApp::getInstance().getTextureManager().createTe xture("earth-shadow.png"); Planet::texEarthShadow = StelApp::getInstance().getTextureManager(). createTexture("earth-shadow.png");
qDebug() << "Loaded" << readOk << "/" << totalPlanets << "planet orb its"; qDebug() << "Loaded" << readOk << "/" << totalPlanets << "planet orb its";
} }
// Compute the position for every elements of the solar system. // Compute the position for every elements of the solar system.
// The order is not important since the position is computed relatively to the mother body // The order is not important since the position is computed relatively to the mother body
void SolarSystem::computePositions(double date, const Vec3d& observerPos) void SolarSystem::computePositions(double date, const Vec3d& observerPos)
{ {
if (flagLightTravelTime) if (flagLightTravelTime)
{ {
skipping to change at line 774 skipping to change at line 774
} }
} }
// Draw all the elements of the solar system // Draw all the elements of the solar system
// We are supposed to be in heliocentric coordinate // We are supposed to be in heliocentric coordinate
void SolarSystem::draw(StelCore* core) void SolarSystem::draw(StelCore* core)
{ {
if (!flagShow) if (!flagShow)
return; return;
Navigator* nav = core->getNavigation(); StelNavigator* nav = core->getNavigator();
Projector* prj = core->getProjection();
Planet::setFont(&planetNameFont); Planet::setFont(&planetNameFont);
// Set the light parameters taking sun as the light source
const float zero[4] = {0,0,0,0};
const float ambient[4] = {0.02,0.02,0.02,0.02};
const float diffuse[4] = {1,1,1,1};
glLightfv(GL_LIGHT0,GL_AMBIENT, ambient);
glLightfv(GL_LIGHT0,GL_DIFFUSE, diffuse);
glLightfv(GL_LIGHT0,GL_SPECULAR,zero);
glMaterialfv(GL_FRONT,GL_AMBIENT, ambient);
glMaterialfv(GL_FRONT,GL_DIFFUSE, diffuse);
glMaterialfv(GL_FRONT,GL_EMISSION, zero);
glMaterialfv(GL_FRONT,GL_SHININESS,zero);
glMaterialfv(GL_FRONT,GL_SPECULAR, zero);
// Light pos in zero (sun)
glLightfv(GL_LIGHT0,GL_POSITION,Vec4f(0.f,0.f,0.f,1.f));
glEnable(GL_LIGHT0);
// Compute each Planet distance to the observer // Compute each Planet distance to the observer
Vec3d obsHelioPos = nav->getObserverHelioPos(); Vec3d obsHelioPos = nav->getObserverHeliocentricEclipticPos();
vector<Planet*>::iterator iter; vector<Planet*>::iterator iter;
iter = systemPlanets.begin(); iter = systemPlanets.begin();
while (iter != systemPlanets.end()) while (iter != systemPlanets.end())
{ {
(*iter)->computeDistance(obsHelioPos); (*iter)->computeDistance(obsHelioPos);
++iter; ++iter;
} }
// And sort them from the furthest to the closest // And sort them from the furthest to the closest
skipping to change at line 820 skipping to change at line 800
// Draw the elements // Draw the elements
float maxMagLabel=core->getSkyDrawer()->getLimitMagnitude()*0.80+(la belsAmount*1.2f)-2.f; float maxMagLabel=core->getSkyDrawer()->getLimitMagnitude()*0.80+(la belsAmount*1.2f)-2.f;
iter = systemPlanets.begin(); iter = systemPlanets.begin();
while (iter != systemPlanets.end()) while (iter != systemPlanets.end())
{ {
(*iter)->draw(core, maxMagLabel); (*iter)->draw(core, maxMagLabel);
++iter; ++iter;
} }
glDisable(GL_LIGHT0);
// special case: draw earth shadow over moon if appropriate
// stencil buffer is set up in moon drawing above
// This effect curently only looks right from earth viewpoint
if (nav->getHomePlanet()->getEnglishName() == "Earth")
drawEarthShadow(nav, prj);
drawPointer(core); drawPointer(core);
} }
void SolarSystem::setStelStyle(const StelStyle& style) void SolarSystem::setStelStyle(const StelStyle& style)
{ {
// Load colors from config file // Load colors from config file
QSettings* conf = StelApp::getInstance().getSettings(); QSettings* conf = StelApp::getInstance().getSettings();
QString section = style.confSectionName; QString section = style.confSectionName;
QString defaultColor = conf->value(section+"/default_color").toStrin g(); QString defaultColor = conf->value(section+"/default_color").toStrin g();
skipping to change at line 883 skipping to change at line 855
} }
return NULL; return NULL;
} }
// Search if any Planet is close to position given in earth equatorial posi tion and return the distance // Search if any Planet is close to position given in earth equatorial posi tion and return the distance
StelObject* SolarSystem::search(Vec3d pos, const StelCore* core) const StelObject* SolarSystem::search(Vec3d pos, const StelCore* core) const
{ {
pos.normalize(); pos.normalize();
Planet * closest = NULL; Planet * closest = NULL;
double cos_angle_closest = 0.; double cos_angle_closest = 0.;
static Vec3d equPos; Vec3d equPos;
vector<Planet*>::const_iterator iter = systemPlanets.begin(); vector<Planet*>::const_iterator iter = systemPlanets.begin();
while (iter != systemPlanets.end()) while (iter != systemPlanets.end())
{ {
equPos = (*iter)->getObsEquatorialPos(core->getNavigation()) ; equPos = (*iter)->getEquinoxEquatorialPos(core->getNavigator ());
equPos.normalize(); equPos.normalize();
double cos_ang_dist = equPos[0]*pos[0] + equPos[1]*pos[1] + equPos[2]*pos[2]; double cos_ang_dist = equPos[0]*pos[0] + equPos[1]*pos[1] + equPos[2]*pos[2];
if (cos_ang_dist>cos_angle_closest) if (cos_ang_dist>cos_angle_closest)
{ {
closest = *iter; closest = *iter;
cos_angle_closest = cos_ang_dist; cos_angle_closest = cos_ang_dist;
} }
iter++; iter++;
} }
skipping to change at line 913 skipping to change at line 885
else return NULL; else return NULL;
} }
// Return a stl vector containing the planets located inside the limFov cir cle around position v // Return a stl vector containing the planets located inside the limFov cir cle around position v
QList<StelObjectP> SolarSystem::searchAround(const Vec3d& vv, double limitF ov, const StelCore* core) const QList<StelObjectP> SolarSystem::searchAround(const Vec3d& vv, double limitF ov, const StelCore* core) const
{ {
QList<StelObjectP> result; QList<StelObjectP> result;
if (!getFlagPlanets()) if (!getFlagPlanets())
return result; return result;
Vec3d v = core->getNavigation()->j2000ToEarthEqu(vv); Vec3d v = core->getNavigator()->j2000ToEquinoxEqu(vv);
v.normalize(); v.normalize();
double cosLimFov = cos(limitFov * M_PI/180.); double cosLimFov = cos(limitFov * M_PI/180.);
static Vec3d equPos; Vec3d equPos;
vector<Planet*>::const_iterator iter = systemPlanets.begin(); vector<Planet*>::const_iterator iter = systemPlanets.begin();
while (iter != systemPlanets.end()) while (iter != systemPlanets.end())
{ {
equPos = (*iter)->getObsEquatorialPos(core->getNavigation()) ; equPos = (*iter)->getEquinoxEquatorialPos(core->getNavigator ());
equPos.normalize(); equPos.normalize();
if (equPos[0]*v[0] + equPos[1]*v[1] + equPos[2]*v[2]>=cosLim Fov) if (equPos[0]*v[0] + equPos[1]*v[1] + equPos[2]*v[2]>=cosLim Fov)
{ {
result.push_back(*iter); result.push_back(*iter);
} }
iter++; iter++;
} }
return result; return result;
} }
// Update i18 names from english names according to passed translator // Update i18 names from english names according to passed translator
void SolarSystem::updateI18n() void SolarSystem::updateI18n()
{ {
Translator& trans = StelApp::getInstance().getLocaleMgr().getSkyTran slator(); StelTranslator& trans = StelApp::getInstance().getLocaleMgr().getSky Translator();
vector<Planet*>::iterator iter; vector<Planet*>::iterator iter;
for( iter = systemPlanets.begin(); iter < systemPlanets.end(); iter+ + ) for( iter = systemPlanets.begin(); iter < systemPlanets.end(); iter+ + )
{ {
(*iter)->translateName(trans); (*iter)->translateName(trans);
} }
planetNameFont = StelApp::getInstance().getFontManager().getStandard Font(trans.getTrueLocaleName(), fontSize); planetNameFont = StelApp::getInstance().getFontManager().getStandard Font(trans.getTrueLocaleName(), fontSize);
} }
QString SolarSystem::getPlanetHashString(void) QString SolarSystem::getPlanetHashString(void)
{ {
skipping to change at line 1068 skipping to change at line 1040
if (obj && obj->getType() == "Planet") if (obj && obj->getType() == "Planet")
selected = obj; selected = obj;
else else
selected = NULL; selected = NULL;
// Undraw other objects hints, orbit, trails etc.. // Undraw other objects hints, orbit, trails etc..
setFlagHints(getFlagHints()); setFlagHints(getFlagHints());
setFlagOrbits(getFlagOrbits()); setFlagOrbits(getFlagOrbits());
setFlagTrails(getFlagTrails()); setFlagTrails(getFlagTrails());
} }
// draws earth shadow overlapping the moon using stencil buffer
// umbra and penumbra are sized separately for accuracy
void SolarSystem::drawEarthShadow(const Navigator * nav, Projector * prj)
{
Vec3d e = getEarth()->getEclipticPos();
Vec3d m = getMoon()->getEclipticPos(); // relative to earth
Vec3d mh = getMoon()->getHeliocentricEclipticPos(); // relative to
sun
float mscale = getMoon()->getSphereScale();
// shadow location at earth + moon distance along earth vector from
sun
Vec3d en = e;
en.normalize();
Vec3d shadow = en * (e.length() + m.length());
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glColor3f(1,1,1);
// find shadow radii in AU
double r_penumbra = shadow.length()*702378.1/AU/e.length() - 696000/
AU;
double r_umbra = 6378.1/AU - m.length()*(689621.9/AU/e.length());
// find vector orthogonal to sun-earth vector using cross product wi
th
// a non-parallel vector
Vec3d rpt = shadow^Vec3d(0,0,1);
rpt.normalize();
Vec3d upt = rpt*r_umbra*mscale*1.02; // point on umbra edge
rpt *= r_penumbra*mscale; // point on penumbra edge
// modify shadow location for scaled moon
Vec3d mdist = shadow - mh;
if(mdist.length() > r_penumbra + 2000/AU) return; // not visible s
o don't bother drawing
shadow = mh + mdist*mscale;
r_penumbra *= mscale;
//nav->switchToHeliocentric();
glEnable(GL_STENCIL_TEST);
glStencilFunc(GL_EQUAL, 0x1, 0x1);
glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP);
prj->setCurrentFrame(Projector::FrameHelio);
// shadow radial texture
texEarthShadow->bind();
Vec3d r, s;
// umbra first
glBegin(GL_TRIANGLE_FAN);
// johannes: work-around for nasty ATI rendering bug:
// use y-texture coordinate of 0.5 instead of 0.0
glTexCoord2f(0.f,0.5f);
prj->drawVertex3v(shadow);
for (int i=0; i<=100; i++)
{
r = Mat4d::rotation(shadow, 2*M_PI*i/100.) * upt;
s = shadow + r;
glTexCoord2f(0.6f,0.5f); // position in texture of umbra ed
ge
prj->drawVertex3v(s);
}
glEnd();
// now penumbra
Vec3d u, sp;
glBegin(GL_TRIANGLE_STRIP);
for (int i=0; i<=100; i++)
{
r = Mat4d::rotation(shadow, 2*M_PI*i/100.) * rpt;
u = Mat4d::rotation(shadow, 2*M_PI*i/100.) * upt;
s = shadow + r;
sp = shadow + u;
glTexCoord2f(0.6f,0.5f);
prj->drawVertex3v(sp);
glTexCoord2f(1.f,0.5f); // position in texture of umbra edg
e
prj->drawVertex3v(s);
}
glEnd();
glDisable(GL_STENCIL_TEST);
}
void SolarSystem::update(double deltaTime) void SolarSystem::update(double deltaTime)
{ {
bool restartTrails = false; bool restartTrails = false;
Navigator* nav = StelApp::getInstance().getCore()->getNavigation(); StelNavigator* nav = StelApp::getInstance().getCore()->getNavigator( );
// Determine if home planet has changed, and restart planet trails // Determine if home planet has changed, and restart planet trails
// since the data is no longer useful // since the data is no longer useful
if (nav->getHomePlanet() != lastHomePlanet) if (nav->getHomePlanet() != lastHomePlanet)
{ {
lastHomePlanet = nav->getHomePlanet(); lastHomePlanet = nav->getHomePlanet();
restartTrails = true; restartTrails = true;
} }
vector<Planet*>::iterator iter = systemPlanets.begin(); vector<Planet*>::iterator iter = systemPlanets.begin();
 End of changes. 35 change blocks. 
160 lines changed or deleted 38 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/