Planet.cpp   Planet.cpp 
skipping to change at line 26 skipping to change at line 26
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA. * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA.
*/ */
#include "StelApp.hpp" #include "StelApp.hpp"
#include "StelCore.hpp" #include "StelCore.hpp"
#include "StelFileMgr.hpp" #include "StelFileMgr.hpp"
#include "StelTexture.hpp" #include "StelTexture.hpp"
#include "StelSkyDrawer.hpp" #include "StelSkyDrawer.hpp"
#include "SolarSystem.hpp" #include "SolarSystem.hpp"
#include "LandscapeMgr.hpp"
#include "Planet.hpp" #include "Planet.hpp"
#include "planetsephems/precession.h" #include "planetsephems/precession.h"
#include "StelObserver.hpp" #include "StelObserver.hpp"
#include "StelProjector.hpp" #include "StelProjector.hpp"
#include "sidereal_time.h" #include "sidereal_time.h"
#include "StelTextureMgr.hpp" #include "StelTextureMgr.hpp"
#include "StelModuleMgr.hpp" #include "StelModuleMgr.hpp"
#include "StarMgr.hpp" #include "StarMgr.hpp"
#include "StelMovementMgr.hpp" #include "StelMovementMgr.hpp"
#include "StelPainter.hpp" #include "StelPainter.hpp"
skipping to change at line 314 skipping to change at line 315
} }
else if (re.period==0.) else if (re.period==0.)
{ {
oss << q_("The period of rotation is chaotic ") << "<br>"; oss << q_("The period of rotation is chaotic ") << "<br>";
} }
} }
if (englishName != "Sun") if (englishName != "Sun")
{ {
const Vec3d& observerHelioPos = core->getObserverHel iocentricEclipticPos(); const Vec3d& observerHelioPos = core->getObserverHel iocentricEclipticPos();
const double elongation = getElongation(observerHeli oPos); const double elongation = getElongation(observerHeli oPos);
QString phase = "";
double deg;
bool sign;
StelUtils::radToDecDeg(elongation, sign, deg);
if (deg>=357.5 && deg<=2.5)
phase = q_("New Moon");
if (deg>=87.5 && deg<=92.5)
phase = q_("Last Quarter");
if (deg>=177.5 && deg<=182.5)
phase = q_("Full Moon");
if (deg>=267.5 && deg<=272.5)
phase = q_("First Quarter");
if (withDecimalDegree) if (withDecimalDegree)
{ {
oss << QString(q_("Phase Angle: %1")).arg(St elUtils::radToDecDegStr(getPhaseAngle(observerHelioPos),4,false,true)) << " <br>"; oss << QString(q_("Phase Angle: %1")).arg(St elUtils::radToDecDegStr(getPhaseAngle(observerHelioPos),4,false,true)) << " <br>";
oss << QString(q_("Elongation: %1")).arg(Ste lUtils::radToDecDegStr(elongation,4,false,true)) << "<br>"; oss << QString(q_("Elongation: %1")).arg(Ste lUtils::radToDecDegStr(elongation,4,false,true)) << "<br>";
} }
else else
{ {
oss << QString(q_("Phase Angle: %1")).arg(St elUtils::radToDmsStr(getPhaseAngle(observerHelioPos))) << "<br>"; oss << QString(q_("Phase Angle: %1")).arg(St elUtils::radToDmsStr(getPhaseAngle(observerHelioPos))) << "<br>";
oss << QString(q_("Elongation: %1")).arg(Ste lUtils::radToDmsStr(elongation)) << "<br>"; oss << QString(q_("Elongation: %1")).arg(Ste lUtils::radToDmsStr(elongation)) << "<br>";
} }
if (englishName=="Moon" && !phase.isEmpty()) oss << QString(q_("Phase: %1")).arg(getPhase(observe
{ rHelioPos), 0, 'f', 2) << "<br>";
if (qRound(deg)==180.f || qRound(deg)==90.f
|| qRound(deg)==270.f || qRound(deg)==0.f)
phase = QString("%1 (<b>%2</b>)").ar
g(getPhase(observerHelioPos), 0, 'f', 2).arg(phase);
else
phase = QString("%1 (%2)").arg(getPh
ase(observerHelioPos), 0, 'f', 2).arg(phase);
}
else
phase = QString("%1").arg(getPhase(observerH
elioPos), 0, 'f', 2);
oss << QString(q_("Phase: %1")).arg(phase) << "<br>"
;
oss << QString(q_("Illuminated: %1%")).arg(getPhase( observerHelioPos) * 100, 0, 'f', 1) << "<br>"; oss << QString(q_("Illuminated: %1%")).arg(getPhase( observerHelioPos) * 100, 0, 'f', 1) << "<br>";
} }
if (englishName=="Sun") if (englishName=="Sun")
{ {
// Only show during eclipse, show percent? // Only show during eclipse, show percent?
static SolarSystem *ssystem=GETSTELMODULE(SolarSyste m); static SolarSystem *ssystem=GETSTELMODULE(SolarSyste m);
// Debug solution: // Debug solution:
// float eclipseFactor = ssystem->getEclipseFactor(core ); // float eclipseFactor = ssystem->getEclipseFactor(core );
// oss << QString(q_("Eclipse Factor: %1 alpha: %2")).a rg(eclipseFactor).arg(-0.1f*qMax(-10.0f, (float) std::log10(eclipseFactor)) ) << "<br>"; // oss << QString(q_("Eclipse Factor: %1 alpha: %2")).a rg(eclipseFactor).arg(-0.1f*qMax(-10.0f, (float) std::log10(eclipseFactor)) ) << "<br>";
// Release version: // Release version:
float eclipseFactor = 100.f*(1.f-ssystem->getEclipse Factor(core)); float eclipseFactor = 100.f*(1.f-ssystem->getEclipse Factor(core));
if (eclipseFactor>0.f) if (eclipseFactor>1.e-7) // needed to avoid false di splay of 1e-14 or so.
oss << QString(q_("Eclipse Factor: %1%")).ar g(eclipseFactor) << "<br>"; oss << QString(q_("Eclipse Factor: %1%")).ar g(eclipseFactor) << "<br>";
} }
} }
postProcessInfoString(str, flags); postProcessInfoString(str, flags);
return str; return str;
} }
skipping to change at line 1220 skipping to change at line 1199
GL(unprojectedVertex = p->attributeLocation("unprojectedVertex")); GL(unprojectedVertex = p->attributeLocation("unprojectedVertex"));
GL(vertex = p->attributeLocation("vertex")); GL(vertex = p->attributeLocation("vertex"));
GL(texture = p->uniformLocation("tex")); GL(texture = p->uniformLocation("tex"));
GL(lightDirection = p->uniformLocation("lightDirection")); GL(lightDirection = p->uniformLocation("lightDirection"));
GL(eyeDirection = p->uniformLocation("eyeDirection")); GL(eyeDirection = p->uniformLocation("eyeDirection"));
GL(diffuseLight = p->uniformLocation("diffuseLight")); GL(diffuseLight = p->uniformLocation("diffuseLight"));
GL(ambientLight = p->uniformLocation("ambientLight")); GL(ambientLight = p->uniformLocation("ambientLight"));
GL(shadowCount = p->uniformLocation("shadowCount")); GL(shadowCount = p->uniformLocation("shadowCount"));
GL(shadowData = p->uniformLocation("shadowData")); GL(shadowData = p->uniformLocation("shadowData"));
GL(sunInfo = p->uniformLocation("sunInfo")); GL(sunInfo = p->uniformLocation("sunInfo"));
GL(skyBrightness = p->uniformLocation("skyBrightness"));
} }
void Planet::initShader() void Planet::initShader()
{ {
qWarning() << "Intializing planets GL shaders... "; qDebug() << "Initializing planets GL shaders... ";
const char *vsrc = const char *vsrc =
"attribute highp vec3 vertex;\n" "attribute highp vec3 vertex;\n"
"attribute highp vec3 unprojectedVertex;\n" "attribute highp vec3 unprojectedVertex;\n"
"attribute mediump vec2 texCoord;\n" "attribute mediump vec2 texCoord;\n"
"uniform highp mat4 projectionMatrix;\n" "uniform highp mat4 projectionMatrix;\n"
"uniform highp vec3 lightDirection;\n" "uniform highp vec3 lightDirection;\n"
"uniform highp vec3 eyeDirection;\n" "uniform highp vec3 eyeDirection;\n"
"varying mediump vec2 texc;\n" "varying mediump vec2 texc;\n"
"varying highp vec3 P;\n" "varying highp vec3 P;\n"
skipping to change at line 1267 skipping to change at line 1247
" P = unprojectedVertex;\n" " P = unprojectedVertex;\n"
"}\n" "}\n"
"\n"; "\n";
const char *fsrc = const char *fsrc =
"varying mediump vec2 texc;\n" "varying mediump vec2 texc;\n"
"uniform sampler2D tex;\n" "uniform sampler2D tex;\n"
"uniform mediump vec3 ambientLight;\n" "uniform mediump vec3 ambientLight;\n"
"uniform mediump vec3 diffuseLight;\n" "uniform mediump vec3 diffuseLight;\n"
"uniform highp vec4 sunInfo;\n" "uniform highp vec4 sunInfo;\n"
"uniform mediump float skyBrightness;\n"
"varying highp vec3 P;\n" "varying highp vec3 P;\n"
"\n" "\n"
"uniform int shadowCount;\n" "uniform int shadowCount;\n"
"uniform highp mat4 shadowData;\n" "uniform highp mat4 shadowData;\n"
"\n" "\n"
"#ifdef RINGS_SUPPORT\n" "#ifdef RINGS_SUPPORT\n"
"uniform bool ring;\n" "uniform bool ring;\n"
"uniform highp float outerRadius;\n" "uniform highp float outerRadius;\n"
"uniform highp float innerRadius;\n" "uniform highp float innerRadius;\n"
"uniform sampler2D ringS;\n" "uniform sampler2D ringS;\n"
skipping to change at line 1392 skipping to change at line 1373
" // Use an Oren-Nayar model for rough surfaces\n" " // Use an Oren-Nayar model for rough surfaces\n"
" // Ref: http://content.gpwiki.org/index.php/D3DBook:(Li ghting)_Oren-Nayar\n" " // Ref: http://content.gpwiki.org/index.php/D3DBook:(Li ghting)_Oren-Nayar\n"
// GZ next 2 don't require highp IMHO // GZ next 2 don't require highp IMHO
" mediump float cosAngleLightNormal = dot(normal, lightDi rection);\n" " mediump float cosAngleLightNormal = dot(normal, lightDi rection);\n"
" mediump float cosAngleEyeNormal = dot(normal, eyeDirect ion);\n" " mediump float cosAngleEyeNormal = dot(normal, eyeDirect ion);\n"
" mediump float angleLightNormal = acos(cosAngleLightNorm al);\n" " mediump float angleLightNormal = acos(cosAngleLightNorm al);\n"
" mediump float angleEyeNormal = acos(cosAngleEyeNormal); \n" " mediump float angleEyeNormal = acos(cosAngleEyeNormal); \n"
" mediump float alpha = max(angleEyeNormal, angleLightNor mal);\n" " mediump float alpha = max(angleEyeNormal, angleLightNor mal);\n"
" mediump float beta = min(angleEyeNormal, angleLightNorm al);\n" " mediump float beta = min(angleEyeNormal, angleLightNorm al);\n"
" mediump float gamma = dot(eyeDirection - normal * cosAn gleEyeNormal, lightDirection - normal * cosAngleLightNormal);\n" " mediump float gamma = dot(eyeDirection - normal * cosAn gleEyeNormal, lightDirection - normal * cosAngleLightNormal);\n"
// GZ next 5 can be lowp instead of mediump. Roughness origi // GZ next 5 can be lowp instead of mediump. Roughness origi
nal 1.0 nal 1.0, then 0.8 in 0.14.0.
" lowp float roughness = 0.8;\n" " lowp float roughness = 0.9;\n"
" lowp float roughnessSquared = roughness * roughness;\n" " lowp float roughnessSquared = roughness * roughness;\n"
" lowp float A = 1.0 - 0.5 * (roughnessSquared / (roughne ssSquared + 0.57));\n" " lowp float A = 1.0 - 0.5 * (roughnessSquared / (roughne ssSquared + 0.57));\n"
" lowp float B = 0.45 * (roughnessSquared / (roughnessSqu ared + 0.09));\n" " lowp float B = 0.45 * (roughnessSquared / (roughnessSqu ared + 0.09));\n"
" lowp float C = sin(alpha) * tan(beta);\n" " lowp float C = sin(alpha) * tan(beta);\n"
// GZ final number was 2, but this causes overly bright moon // GZ final number was 2, but this causes overly bright moon
. . was 1.5 in 0.14.0.
" lum = max(0.0, cosAngleLightNormal) * (A + B * max(0.0, " lum = max(0.0, cosAngleLightNormal) * (A + B * max(0.0,
gamma) * C) * 1.5;\n" gamma) * C) * 1.85;\n"
"#endif\n" "#endif\n"
//Reduce lum if sky is bright, to avoid burnt-out look in da
ylight sky.
" lum *= (1.0-0.4*skyBrightness);\n"
" mediump vec4 litColor = vec4(lum * final_illumination * diffuseLight + ambientLight, 1.0);\n" " mediump vec4 litColor = vec4(lum * final_illumination * diffuseLight + ambientLight, 1.0);\n"
"#ifdef IS_MOON\n" "#ifdef IS_MOON\n"
" if(final_illumination < 0.99)\n" " if(final_illumination < 0.99)\n"
" {\n" " {\n"
" lowp vec4 shadowColor = texture2D(earthShadow, vec2 (final_illumination, 0.5));\n" " lowp vec4 shadowColor = texture2D(earthShadow, vec2 (final_illumination, 0.5));\n"
" gl_FragColor = mix(texture2D(tex, texc) * litColor, shadowColor, shadowColor.a);\n" " gl_FragColor = mix(texture2D(tex, texc) * litColor, shadowColor, shadowColor.a);\n"
" }\n" " }\n"
" else\n" " else\n"
"#endif\n" "#endif\n"
" {\n" " {\n"
skipping to change at line 1513 skipping to change at line 1496
if (flagLighting) if (flagLighting)
{ {
// Set the main source of light to be the sun // Set the main source of light to be the sun
Vec3d sunPos(0); Vec3d sunPos(0);
core->getHeliocentricEclipticModelViewTransform()->f orward(sunPos); core->getHeliocentricEclipticModelViewTransform()->f orward(sunPos);
light.position=Vec4f(sunPos[0],sunPos[1],sunPos[2],1 .f); light.position=Vec4f(sunPos[0],sunPos[1],sunPos[2],1 .f);
// Set the light parameters taking sun as the light source // Set the light parameters taking sun as the light source
light.diffuse = Vec4f(1.f,magFactorGreen*1.f,magFact orBlue*1.f); light.diffuse = Vec4f(1.f,magFactorGreen*1.f,magFact orBlue*1.f);
light.ambient = Vec4f(0.02f,magFactorGreen*0.02f,mag FactorBlue*0.02f); light.ambient = Vec4f(0.02f,magFactorGreen*0.02f,mag FactorBlue*0.02f);
// TODO: ambient for the moon should provide the Ash en light!
if (this==ssm->getMoon()) if (this==ssm->getMoon())
{ {
// Special case for the Moon (maybe better u float fov=core->getProjection(transfo)->getF
se 1.5,1.5,1.5,1.0 ?) Was 1.6, but this often is too bright. ov();
light.diffuse = Vec4f(1.5f,magFactorGreen*1. float fovFactor=1.6f;
5f,magFactorBlue*1.5f,1.f); // scale brightness to reduce if fov smaller
than 5 degrees. Min brightness (to avoid glare) if fov=2deg.
if (fov<5.0f)
{
fovFactor -= 0.1f*(5.0f-qMax(2.0f, f
ov));
}
// Special case for the Moon. Was 1.6, but t
his often is too bright.
light.diffuse = Vec4f(fovFactor,magFactorGre
en*fovFactor,magFactorBlue*fovFactor,1.f);
} }
} }
else else
{ {
sPainter->setColor(albedo,magFactorGreen*albedo,magF actorBlue*albedo); sPainter->setColor(albedo,magFactorGreen*albedo,magF actorBlue*albedo);
} }
// possibly tint sun's color from extinction. This should de liberately cause stronger reddening than for the other objects. // possibly tint sun's color from extinction. This should de liberately cause stronger reddening than for the other objects.
if (this==ssm->getSun()) if (this==ssm->getSun())
sPainter->setColor(2.f, pow(0.75f, extinctedMag)*2.f , pow(0.42f, 0.9f*extinctedMag)*2.f); sPainter->setColor(2.f, pow(0.75f, extinctedMag)*2.f , pow(0.42f, 0.9f*extinctedMag)*2.f);
skipping to change at line 1796 skipping to change at line 1788
lightPos3.normalize(); lightPos3.normalize();
Vec3d eyePos = StelApp::getInstance().getCore()->getObserverHeliocen tricEclipticPos(); Vec3d eyePos = StelApp::getInstance().getCore()->getObserverHeliocen tricEclipticPos();
//qDebug() << eyePos[0] << " " << eyePos[1] << " " << eyePos[2] << " --> "; //qDebug() << eyePos[0] << " " << eyePos[1] << " " << eyePos[2] << " --> ";
// Use refractionOff for avoiding flickering Moon. (Bug #1411958) // Use refractionOff for avoiding flickering Moon. (Bug #1411958)
StelApp::getInstance().getCore()->getHeliocentricEclipticModelViewTr ansform(StelCore::RefractionOff)->forward(eyePos); StelApp::getInstance().getCore()->getHeliocentricEclipticModelViewTr ansform(StelCore::RefractionOff)->forward(eyePos);
//qDebug() << "-->" << eyePos[0] << " " << eyePos[1] << " " << eyePo s[2]; //qDebug() << "-->" << eyePos[0] << " " << eyePos[1] << " " << eyePo s[2];
projector->getModelViewTransform()->backward(eyePos); projector->getModelViewTransform()->backward(eyePos);
eyePos.normalize(); eyePos.normalize();
//qDebug() << " -->" << eyePos[0] << " " << eyePos[1] << " " << eyeP os[2]; //qDebug() << " -->" << eyePos[0] << " " << eyePos[1] << " " << eyeP os[2];
LandscapeMgr* lmgr=GETSTELMODULE(LandscapeMgr);
Q_ASSERT(lmgr);
GL(shader->setUniformValue(shaderVars->projectionMatrix, qMat)); GL(shader->setUniformValue(shaderVars->projectionMatrix, qMat));
GL(shader->setUniformValue(shaderVars->lightDirection, lightPos3[0], lightPos3[1], lightPos3[2])); GL(shader->setUniformValue(shaderVars->lightDirection, lightPos3[0], lightPos3[1], lightPos3[2]));
GL(shader->setUniformValue(shaderVars->eyeDirection, eyePos[0], eyeP os[1], eyePos[2])); GL(shader->setUniformValue(shaderVars->eyeDirection, eyePos[0], eyeP os[1], eyePos[2]));
GL(shader->setUniformValue(shaderVars->diffuseLight, light.diffuse[0 ], light.diffuse[1], light.diffuse[2])); GL(shader->setUniformValue(shaderVars->diffuseLight, light.diffuse[0 ], light.diffuse[1], light.diffuse[2]));
GL(shader->setUniformValue(shaderVars->ambientLight, light.ambient[0 ], light.ambient[1], light.ambient[2])); GL(shader->setUniformValue(shaderVars->ambientLight, light.ambient[0 ], light.ambient[1], light.ambient[2]));
GL(shader->setUniformValue(shaderVars->texture, 0)); GL(shader->setUniformValue(shaderVars->texture, 0));
GL(shader->setUniformValue(shaderVars->shadowCount, shadowCandidates .size())); GL(shader->setUniformValue(shaderVars->shadowCount, shadowCandidates .size()));
GL(shader->setUniformValue(shaderVars->shadowData, shadowCandidatesD ata)); GL(shader->setUniformValue(shaderVars->shadowData, shadowCandidatesD ata));
GL(shader->setUniformValue(shaderVars->sunInfo, mTarget[12], mTarget [13], mTarget[14], ssm->getSun()->getRadius())); GL(shader->setUniformValue(shaderVars->sunInfo, mTarget[12], mTarget [13], mTarget[14], ssm->getSun()->getRadius()));
GL(texMap->bind(1)); GL(texMap->bind(1));
GL(shader->setUniformValue(shaderVars->skyBrightness, lmgr->getLumin ance()));
if (rings!=NULL) if (rings!=NULL)
{ {
GL(ringPlanetShaderProgram->setUniformValue(ringPlanetShader Vars.isRing, false)); GL(ringPlanetShaderProgram->setUniformValue(ringPlanetShader Vars.isRing, false));
GL(ringPlanetShaderProgram->setUniformValue(ringPlanetShader Vars.ring, true)); GL(ringPlanetShaderProgram->setUniformValue(ringPlanetShader Vars.ring, true));
GL(ringPlanetShaderProgram->setUniformValue(ringPlanetShader Vars.outerRadius, rings->radiusMax)); GL(ringPlanetShaderProgram->setUniformValue(ringPlanetShader Vars.outerRadius, rings->radiusMax));
GL(ringPlanetShaderProgram->setUniformValue(ringPlanetShader Vars.innerRadius, rings->radiusMin)); GL(ringPlanetShaderProgram->setUniformValue(ringPlanetShader Vars.innerRadius, rings->radiusMin));
GL(ringPlanetShaderProgram->setUniformValue(ringPlanetShader Vars.ringS, 2)); GL(ringPlanetShaderProgram->setUniformValue(ringPlanetShader Vars.ringS, 2));
rings->tex->bind(2); rings->tex->bind(2);
} }
 End of changes. 14 change blocks. 
41 lines changed or deleted 36 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/