diff --git a/modules/exoplanets/discoverymethods/discoverymethods.cpp b/modules/exoplanets/discoverymethods/discoverymethods.cpp index 5be5117a91..ec671b2273 100644 --- a/modules/exoplanets/discoverymethods/discoverymethods.cpp +++ b/modules/exoplanets/discoverymethods/discoverymethods.cpp @@ -32,6 +32,9 @@ #include #include #include +#include +#include +#include namespace { constexpr const char* _loggerCat = "DiscoveryMethods"; @@ -51,65 +54,115 @@ namespace { namespace openspace::exoplanets{ - void DiscoveryMethods::addTransitMethodVisualization() { - - std::string starName = OsEng.moduleEngine().module()->getStarName(); - std::vector planets = OsEng.moduleEngine().module()->getPlsy(); - float planetSemiMajorAxis = planets[0].A; // AU - float eccentricity = planets[0].ECC; - float starRadius = planets[0].RSTAR; // Solar Radii + void DiscoveryMethods::addDirectionsMarkers(glm::dvec3 viewDirecionPos, glm::dvec3 northDirectionPos, float starRadius) { - // periapsis radius - float periapsisRadius = planetSemiMajorAxis * (1.0 - eccentricity); - // to km - periapsisRadius *= 149597871; - starRadius *= 695700; - - // increase star radius to two thirds of periapsis radius - float scaleFactor = (0.666 * periapsisRadius) / starRadius; - std::string planetName = starName + " b"; - scaleStar(starName +"Globe", scaleFactor); - scaleStar(planetName, scaleFactor); - moveCameraTransitView(); + const std::string markerView = "{" + "Identifier = 'markerView'," + "Parent = 'SolarSystemBarycenter'," + "Enabled = true," + "Renderable = {" + "Type = 'RenderableGlobe'," + "Radii = " + std::to_string(starRadius) + "* 0.5," + "SegmentsPerPatch = 64," + "PerformShading = false," + "Layers = {" + "ColorLayers = {" + "{" + "Identifier = 'dir'," + "Type = 'SolidColor'," + "BlendMode = 'Normal'," + "Color = {1.0,0.0,0.0}," + "Enabled = true" + "}," + "}" + "}" + "}," + "Transform = {" + "Translation = {" + "Type = 'StaticTranslation'," + "Position = " + std::to_string(viewDirecionPos) + "," + "}," + "}," + "}"; + std::string script = "openspace.addSceneGraphNode(" + markerView + ");"; + OsEng.scriptEngine().queueScript( + script, + openspace::scripting::ScriptEngine::RemoteScripting::Yes + ); + const std::string markerNorth = "{" + "Identifier = 'markerNorth'," + "Parent = 'SolarSystemBarycenter'," + "Enabled = true," + "Renderable = {" + "Type = 'RenderableGlobe'," + "Radii = " + std::to_string(starRadius) + "* 0.5," + "SegmentsPerPatch = 64," + "PerformShading = false," + "Layers = {" + "ColorLayers = {" + "{" + "Identifier = 'dir'," + "Type = 'SolidColor'," + "BlendMode = 'Normal'," + "Color = {0.0,0.0,1.0}," + "Enabled = true" + "}," + "}" + "}" + "}," + "Transform = {" + "Translation = {" + "Type = 'StaticTranslation'," + "Position = " + std::to_string(northDirectionPos) + "," + "}," + "}," + "}"; + script = ""; + script = "openspace.addSceneGraphNode(" + markerNorth + ");"; + OsEng.scriptEngine().queueScript( + script, + openspace::scripting::ScriptEngine::RemoteScripting::Yes + ); } - void DiscoveryMethods::removeTransitMethodVisualization() { - - std::string starName = OsEng.moduleEngine().module()->getStarName(); - std::string planetName = starName + " b"; - scaleStar(starName + "Globe", 1); - scaleStar(planetName, 1); + void DiscoveryMethods::removeDirectionsMarkers() { + std::string script = "openspace.removeSceneGraphNode('markerView'); openspace.removeSceneGraphNode('markerNorth');"; + OsEng.scriptEngine().queueScript( + script, + openspace::scripting::ScriptEngine::RemoteScripting::Yes + ); } - void DiscoveryMethods::addDopplerMethodVisualization() { - - std::string starName = OsEng.moduleEngine().module()->getStarName(); - std::vector planets = OsEng.moduleEngine().module()->getPlsy(); - //float planetSemiMajorAxis = (OsEng.moduleEngine().module()->getClosestExoplanet()).A; - float planetSemiMajorAxis = planets[0].A; - float starSemiMajorAxis = 0.1 * planetSemiMajorAxis * 149597871; // 10% of exoplanets semiMajorAxis (get value from em) - float eccentricity = planets[0].ECC; - float starRadius = planets[0].RSTAR; // Solar Radii - - float periapsisRadius = planetSemiMajorAxis * (1.0 - eccentricity); - // to km - periapsisRadius *= 149597871; - starRadius *= 695700; - float scaleFactor = (0.1 * periapsisRadius) / starRadius; - - moveCameraDopplerView(); - scaleStar(starName + "Globe", scaleFactor); - moveStar(starName, starSemiMajorAxis); - toggleVisabilityOuterPlanets("false"); + float DiscoveryMethods::getTransitScaleFactor() { + return _transitScaleFactor; } - void DiscoveryMethods::removeDopplerMethodVisualization() { - std::string starName = OsEng.moduleEngine().module()->getStarName(); - scaleStar(starName + "Globe", 1.0); - moveStar(starName, 0.0); - toggleVisabilityOuterPlanets("true"); + void addDopplerGraphs() { + std::string script = "openspace.addScreenSpaceRenderable(" + "{" + "Identifier = 'DopplerShift2'," + "Type = 'ScreenSpaceImageLocal'," + "TexturePath = openspace.absPath('${BASE}/modules/exoplanets/stripes2.png')," + "EuclideanPosition = {0.0, -0.7}" + "}" + ");" + "openspace.addScreenSpaceRenderable(" + "{" + "Identifier = 'DopplerShift1'," + "Type = 'ScreenSpaceImageLocal'," + "TexturePath = openspace.absPath('${BASE}/modules/exoplanets/spectrum.jpg')," + "EuclideanPosition = {0.0, -0.7}" + "}" + ");"; + + OsEng.scriptEngine().queueScript( + script, + openspace::scripting::ScriptEngine::RemoteScripting::Yes + ); } - void DiscoveryMethods::scaleStar(std::string nodeName, float scalefactor) { + + + void DiscoveryMethods::scaleNode(std::string nodeName, float scalefactor) { std::string script = "openspace.setPropertyValueSingle( 'Scene."+ nodeName +".Scale.Scale', " + std::to_string(scalefactor) + ", 1);"; //get name of current star from em OsEng.scriptEngine().queueScript( script, @@ -118,85 +171,228 @@ namespace openspace::exoplanets{ } void DiscoveryMethods::moveStar(std::string starName, float semiMajorAxis) { - std::string script = "openspace.setPropertyValueSingle( 'Scene."+starName+"Globe.Translation.SemiMajorAxis', " + std::to_string(semiMajorAxis) + ", 1); "; //get name of current star from em + std::string script = "openspace.setPropertyValueSingle( 'Scene."+starName+"Globe.Translation.SemiMajorAxis', " + std::to_string(semiMajorAxis) + ", 1); "; OsEng.scriptEngine().queueScript( script, openspace::scripting::ScriptEngine::RemoteScripting::Yes ); } - void DiscoveryMethods::moveCameraTransitView() { - - Camera* cam = OsEng.navigationHandler().camera(); - - SceneGraphNode* focusNode = OsEng.navigationHandler().focusNode(); - glm::dvec3 starPosition = focusNode->worldPosition(); - // get the vector between star and the sun - glm::dvec3 starToSunVec = normalize(glm::dvec3(0.0, 0.0, 0.0) - starPosition); - - // a position along that vector (twice the semimajor axis away from the sun) - float semiMajorAxis = (OsEng.moduleEngine().module()->getClosestExoplanet()).A; - glm::dvec3 newCameraPosition = starPosition + ((3.0 * semiMajorAxis * 149597870700) * starToSunVec); - - //move camera to that pos - cam->setPositionVec3(newCameraPosition); - OsEng.navigationHandler().resetCameraDirection(); - - } - - void DiscoveryMethods::toggleVisabilityOuterPlanets(std::string visability) { - //std::vector planets = OsEng.moduleEngine().module()->getPlsy(); - std::vector planetNames = OsEng.moduleEngine().module()->getPlna(); + void DiscoveryMethods::toggleVisabilityOuterPlanets(std::vector planetNames, std::string visability) { + std::vector planets = OsEng.moduleEngine().module()->getPlsy(); + //std::vector planetNames = OsEng.moduleEngine().module()->getPlna(); if (planetNames.size()>1) { //keeping first planet in the list, wich dosn't neccesarily mean the closest one... for (size_t i = 1; i < planetNames.size(); i++) { + std::string script = ""; //remove planetglobe - script += "openspace.setPropertyValueSingle( 'Scene." + planetNames[i] + ".renderable.Enabled', "+visability+"); "; + if (!isnan(planets[i].R)) { + script += "openspace.setPropertyValueSingle( 'Scene." + planetNames[i] + ".renderable.Enabled', " + visability + "); "; + } //remove trail script += "openspace.setPropertyValueSingle( 'Scene." + planetNames[i] + "Trail.renderable.Enabled', " + visability + "); "; //remove disc - script += "openspace.setPropertyValueSingle( 'Scene."+planetNames[i]+"Disc.renderable.Enabled', " + visability + "); "; - + if (!isnan(planets[i].AUPPER) && !isnan(planets[i].ALOWER)) { + script += "openspace.setPropertyValueSingle( 'Scene." + planetNames[i] + "Disc.renderable.Enabled', " + visability + "); "; + } + OsEng.scriptEngine().queueScript( script, openspace::scripting::ScriptEngine::RemoteScripting::Yes ); } - } + } + } + + void DiscoveryMethods::toggleVisabilityPlanet(std::string nodeName, std::string visability) { + std::string script = "openspace.setPropertyValueSingle( 'Scene." +nodeName + ".RenderableGlobe.Enabled', " + visability + "); "; + OsEng.scriptEngine().queueScript( + script, + openspace::scripting::ScriptEngine::RemoteScripting::Yes + ); } - void DiscoveryMethods::moveCameraDopplerView() { + void DiscoveryMethods::moveCameraDopplerView(glm::dvec3 pos) { Camera* cam = OsEng.navigationHandler().camera(); - - SceneGraphNode* focusNode = OsEng.navigationHandler().focusNode(); - glm::dvec3 starPosition = focusNode->worldPosition(); - glm::dvec3 starToSunVec = normalize(glm::dvec3(0.0, 0.0, 0.0) - starPosition); - glm::dvec3 north = glm::dvec3(0.0, 0.0, 1.0); - glm::dvec3 northProjected = glm::normalize(glm::length(north)*glm::sin(glm::dot(north, starToSunVec)) * glm::cross(starToSunVec, glm::cross(north, starToSunVec))); - glm::dvec3 faceOnVector = glm::normalize(glm::cross(starToSunVec, northProjected)); - // a position along that vector (3x the semimajor axis away from the star) - //float semiMajorAxis = (OsEng.moduleEngine().module()->getClosestExoplanet()).A; - std::vector planets = OsEng.moduleEngine().module()->getPlsy(); - float semiMajorAxis = planets[0].A; - glm::dvec3 newCameraPosition = starPosition + ((3.0 * semiMajorAxis * 149597870700) * faceOnVector); - - //move camera to that pos - cam->setPositionVec3(newCameraPosition); + cam->setPositionVec3(pos); OsEng.navigationHandler().resetCameraDirection(); } + void DiscoveryMethods::moveCameraTransitView(glm::dvec3 pos) { + + Camera* cam = OsEng.navigationHandler().camera(); + cam->setPositionVec3(pos); + OsEng.navigationHandler().resetCameraDirection(); + + } + + bool DiscoveryMethods::isDoppler() { + return _showDoppler; + } + bool DiscoveryMethods::isTransit() { + return _showTransit; + } + void DiscoveryMethods::setDopplerImagePos(float value) { + std::string script = "openspace.setPropertyValueSingle( 'ScreenSpace.DopplerShift2.EuclideanPosition', {"+std::to_string(value)+", -0.7}); "; //get name of current star from em + OsEng.scriptEngine().queueScript( + script, + openspace::scripting::ScriptEngine::RemoteScripting::Yes + ); + } + + void DiscoveryMethods::addDopplerMethodVisualization() { + SceneGraphNode* focusNode = OsEng.navigationHandler().focusNode(); + std::string starName = OsEng.moduleEngine().module()->getStarName(); // getStarName + glm::dvec3 starPosition = focusNode->worldPosition(); // can get from Exoplanet.POSITIONX/.POSITIONY/.POSITIONZ (in parsecs) + glm::dvec3 starToSunVec = normalize(glm::dvec3(0.0, 0.0, 0.0) - starPosition); + std::vector planets = OsEng.moduleEngine().module()->getPlsy(); + std::vector planetNames = OsEng.moduleEngine().module()->getPlna(); + + float semiMajorAxis = planets[0].A; // in AU + float starSemiMajorAxis = 0.1 * semiMajorAxis; // 10% of exoplanets semiMajorAxis + float eccentricity = planets[0].ECC; + float starRadius = planets[0].RSTAR; // in Solar Radii + + glm::dvec3 north = glm::dvec3(0.0, 0.0, 1.0); + //glm::dvec3 northProjected = glm::normalize(glm::length(north)*glm::sin(glm::dot(north, starToSunVec)) * glm::cross(starToSunVec, glm::cross(north, starToSunVec))); + glm::dvec3 northProjected = normalize(north - (((dot(north, starToSunVec)) / (glm::length(starToSunVec)))*starToSunVec)); + + // MOVE CAMERA + glm::dvec3 faceOnVector = glm::normalize(glm::cross(starToSunVec, northProjected)); + glm::dvec3 cameraPosition = starPosition + ((4.0 * semiMajorAxis * 149597870700.0) * faceOnVector); + moveCameraDopplerView(cameraPosition); + // END CAMERA + + // SCALE STAR AND PLANET + float periapsisDistance = semiMajorAxis * (1.0 - eccentricity); // in AU + periapsisDistance *= 149597870700.0; // in m + starRadius *= 6.957E8; // in m + float scale = (0.1 * periapsisDistance) / starRadius; + scaleNode(starName + "Globe", scale); + scaleNode(planetNames[0], scale); // using planetNames[0] because i know that will be the one visible after removing outer planets + // END SCALE + + // MOVE STAR + starSemiMajorAxis *= 149597871.0; // in km + moveStar(starName, starSemiMajorAxis); + + // SHOW ONE PLANET + // for planets found with doppler method, the radius is not always known. + //so this "fake" planet is shown for the sake of the vizualisation + toggleVisabilityPlanet(planetNames[0], "true"); + + // HIDE THE REST OF THE PLANETS + // in some cases there are multiple planets in the system, but for the viz only one can be shown + toggleVisabilityOuterPlanets(planetNames, "false"); + + // SHOW GRAPHS + addDopplerGraphs(); + + + // HELPER MARKERS + glm::dvec3 northDirectionPos = starPosition + (double(starRadius * scale) * northProjected); + glm::dvec3 viewDirectionPos = starPosition + (double(starRadius * scale) * starToSunVec); + addDirectionsMarkers(viewDirectionPos, northDirectionPos, starRadius); + // END MARKERS + + } + + void DiscoveryMethods::removeDopplerMethodVisualization() { + std::string starName = OsEng.moduleEngine().module()->getStarName(); + std::vector planetNames = OsEng.moduleEngine().module()->getPlna(); + std::vector planets = OsEng.moduleEngine().module()->getPlsy(); + + //SCALE STAR AND PLANET + scaleNode(starName + "Globe", 1.0); + scaleNode(planetNames[0], 1.0); + + // MOVE STAR + moveStar(starName, 0.0); + + //HIDE THE PLANET (if it was hidden from the start) + if (isnan(planets[0].R)) { + toggleVisabilityPlanet(planetNames[0], "false"); + } + + // SHOW THE REST OF THE PLANETS + toggleVisabilityOuterPlanets(planetNames, "true"); + + // HIDE GRAPHS + std::string script = "openspace.removeScreenSpaceRenderable('DopplerShift1'); openspace.removeScreenSpaceRenderable('DopplerShift2');"; + OsEng.scriptEngine().queueScript( + script, + openspace::scripting::ScriptEngine::RemoteScripting::Yes + ); + + //REMOVE HELP MARKERS + removeDirectionsMarkers(); + } + + void DiscoveryMethods::addTransitMethodVisualization() { + + SceneGraphNode* focusNode = OsEng.navigationHandler().focusNode(); + std::string starName = OsEng.moduleEngine().module()->getStarName(); // getStarName + glm::dvec3 starPosition = focusNode->worldPosition(); // can get from Exoplanet.POSITIONX/.POSITIONY/.POSITIONZ (in parsecs) + glm::dvec3 starToSunVec = normalize(glm::dvec3(0.0, 0.0, 0.0) - starPosition); + std::vector planets = OsEng.moduleEngine().module()->getPlsy(); + std::vector planetNames = OsEng.moduleEngine().module()->getPlna(); + + float semiMajorAxis = planets[0].A; // in AU (1AU = 149 597 870 700m) + float eccentricity = planets[0].ECC; + float starRadius = planets[0].RSTAR; // in Solar Radii + + // MOVE CAMERA + //borde kanske va periapsis distance, men det går bra ändå + glm::dvec3 cameraPosition = starPosition + ((3.0 * semiMajorAxis * 149597870700.0) * starToSunVec);; + moveCameraTransitView(cameraPosition); + // END CAMERA + toggleVisabilityPlanet(planetNames[0], "true"); + + // SCALE BOTH STAR AND PLANET + // want star to take up 2/3 of the radius, the radius is as smallest at the periapsis + float periapsisDistance = semiMajorAxis * (1.0 - eccentricity); // in AU + periapsisDistance *= 149597870700.0; // in m + starRadius *= 6.957E8; // in m + + float scale = (0.666 * periapsisDistance) / starRadius; // actual radius * scale = wanted radius + scaleNode(starName + "Globe", scale); + scaleNode(planetNames[0], scale); //eller använda getPlna()? + _transitScaleFactor = scale; + // END SCALE + + // HELPER MARKERS + glm::dvec3 north = glm::dvec3(0.0, 0.0, 1.0); + //glm::dvec3 northProjected = glm::normalize(glm::length(north)*glm::sin(glm::dot(north, starToSunVec)) * glm::cross(starToSunVec, glm::cross(north, starToSunVec))); + glm::dvec3 northProjected = normalize(north - (((dot(north, starToSunVec)) / (glm::length(starToSunVec)))*starToSunVec)); + glm::dvec3 northDirectionPos = starPosition + (double(starRadius * scale) * northProjected); + glm::dvec3 viewDirectionPos = starPosition + (double(starRadius * scale) * starToSunVec); + addDirectionsMarkers(viewDirectionPos, northDirectionPos, starRadius); + // END MARKERS + } + void DiscoveryMethods::removeTransitMethodVisualization() { + + //SCALE STAR AND PLANET + std::string starName = OsEng.moduleEngine().module()->getStarName(); + scaleNode(starName + "Globe", 1); + scaleNode(starName + " b", 1); + + + + //REMOVE HELP MARKERS + removeDirectionsMarkers(); + } + + DiscoveryMethods::DiscoveryMethods() : PropertyOwner({ "DiscoveryMethods" }) , _showTransit(TransitMethodInfo, false) , _showDoppler(DopplerMethodInfo, false) { - addProperty(_showTransit); - addProperty(_showDoppler); _showTransit.onChange([&]() { if (_showTransit) //just changed to true { @@ -214,11 +410,13 @@ namespace openspace::exoplanets{ } }); + addProperty(_showTransit); _showDoppler.onChange([&]() { if (_showDoppler) //just changed to true { if (_showTransit) { + _showTransit = false; removeTransitMethodVisualization(); } @@ -230,7 +428,8 @@ namespace openspace::exoplanets{ } }); - + addProperty(_showDoppler); + printf("slut pa constructor"); } } // namespce diff --git a/modules/exoplanets/discoverymethods/discoverymethods.h b/modules/exoplanets/discoverymethods/discoverymethods.h index c340c62e3a..c5e5afdfaa 100644 --- a/modules/exoplanets/discoverymethods/discoverymethods.h +++ b/modules/exoplanets/discoverymethods/discoverymethods.h @@ -34,6 +34,11 @@ namespace openspace::exoplanets { class DiscoveryMethods : public properties::PropertyOwner { public: DiscoveryMethods(); + bool isDoppler(); + bool isTransit(); + void setDopplerImagePos(float); + void setTransitImagePos(float, float); + float getTransitScaleFactor(); private: properties::BoolProperty _showTransit; @@ -44,11 +49,16 @@ private: void addDopplerMethodVisualization(); void removeDopplerMethodVisualization(); - void scaleStar(std::string, float); + void addDirectionsMarkers(glm::dvec3, glm::dvec3, float); + void removeDirectionsMarkers(); + void scaleNode(std::string, float); void moveStar(std::string, float); - void moveCameraTransitView(); - void moveCameraDopplerView(); - void toggleVisabilityOuterPlanets(std::string); + void moveCameraTransitView(glm::dvec3); + void moveCameraDopplerView(glm::dvec3); + void toggleVisabilityOuterPlanets(std::vector, std::string); + void toggleVisabilityPlanet(std::string, std::string); + + float _transitScaleFactor; }; diff --git a/modules/exoplanets/exoplanetsmodule.cpp b/modules/exoplanets/exoplanetsmodule.cpp index 0f60d9a86a..9cbbeecd0d 100644 --- a/modules/exoplanets/exoplanetsmodule.cpp +++ b/modules/exoplanets/exoplanetsmodule.cpp @@ -26,8 +26,15 @@ #include #include +#include +#include +#include +#include #include +#include +#include + #include "exoplanetsmodule_lua.inl" namespace openspace { @@ -103,6 +110,49 @@ void ExoplanetsModule::internalInitialize(const ghoul::Dictionary&) { _discoveryMethods = std::make_unique(); addPropertySubOwner(*_discoveryMethods); }); + + // Render + OsEng.registerModuleCallback(OpenSpaceEngine::CallbackOption::Render, [&] { + + if (_discoveryMethods->isDoppler()) + { + std::string starName = OsEng.moduleEngine().module()->getStarName(); + std::vector planetNames = OsEng.moduleEngine().module()->getPlna(); + SceneGraphNode* planetNode = OsEng.renderEngine().scene()->sceneGraphNode(planetNames[0]); + SceneGraphNode* starNode = OsEng.renderEngine().scene()->sceneGraphNode(starName); + glm::dvec3 planetPos = planetNode->worldPosition(); + glm::dvec3 starPos = starNode->worldPosition(); + glm::dvec3 starToPosVec = normalize(planetPos - starPos); + glm::dvec3 starToSunVec = normalize(glm::dvec3(0.0, 0.0, 0.0) - starPos); + glm::dvec3 north = glm::dvec3(0.0, 0.0, 1.0); + glm::dvec3 northProjected = glm::normalize(glm::length(north)*glm::sin(glm::dot(north, starToSunVec)) * glm::cross(starToSunVec, glm::cross(north, starToSunVec))); + float northAngle = glm::acos(glm::dot(starToPosVec, northProjected)) * 57.2957795; + float viewAngle = glm::acos(glm::dot(starToPosVec, starToSunVec)) * 57.2957795; + + float imagePos = 0; + if ( viewAngle <= 90.0 && northAngle <= 90.0) + { + imagePos = viewAngle / -90.0; + } + else if (viewAngle > 90.0 && northAngle <= 90.0) + { + imagePos = (180.0 - viewAngle) / -90.0; + } + else if (viewAngle > 90.0 && northAngle > 90.0) + { + imagePos = (180.0 - viewAngle) / 90.0; + } + else if (viewAngle <= 90.0 && northAngle > 90.0) + { + imagePos = viewAngle / 90.0; + } + + imagePos *= 0.01; + _discoveryMethods->setDopplerImagePos(imagePos); + + } + + }); } std::vector ExoplanetsModule::documentations() const { diff --git a/modules/exoplanets/exoplanetsmodule_lua.inl b/modules/exoplanets/exoplanetsmodule_lua.inl index 2f5532f5ef..b0d8f20a66 100644 --- a/modules/exoplanets/exoplanetsmodule_lua.inl +++ b/modules/exoplanets/exoplanetsmodule_lua.inl @@ -285,14 +285,12 @@ int addExoplanetSystem(lua_State* L) { std::string script = ""; glm::dvec3 position = glm::dvec3(p.POSITIONX * parsec , p.POSITIONY * parsec, p.POSITIONZ * parsec); - glm::dvec3 starToSunVec = normalize(glm::dvec3(0.0, 0.0, 0.0) - position); glm::dvec3 northEclipticPole = glm::dvec3(0.0, 0.0, 1.0); // , 1.0); //glm::dvec3 northCelectialPole = northEclipticPole * glm::rotate(glm::radians(336.6), glm::dvec3(1.f, 0.f, 0.f)); - printf(std::to_string(northEclipticPole).c_str()); + // Earths north vector (0,0,1) projected onto the skyplane, the plane perpendicular to the viewing vector (starTosunVec) glm::dvec3 northProjected = normalize(glm::length(northEclipticPole)*glm::sin(dot(northEclipticPole, starToSunVec)) * glm::cross(starToSunVec, glm::cross(northEclipticPole, starToSunVec))); - printf(std::to_string(northProjected).c_str()); glm::dmat3 firstRotation = getExoplanetSystemRotation(glm::dvec3(0.0,0.0,1.0), starToSunVec); glm::dvec3 newX = firstRotation * glm::dvec3(1.0, 0.0, 0.0); glm::dmat3 secondRotation = getExoplanetSystemRotation(newX, northProjected); @@ -448,16 +446,27 @@ int addExoplanetSystem(lua_State* L) { else sepoch = "2009-05-19T07:11:34.080"; - - if (!isnan(plsy[i].R)) - { + float planetradius; + std::string enabled = ""; + if (isnan(plsy[i].R)) + { + planetradius = plsy[i].RSTAR; + enabled = "false"; + + } + else { + planetradius = plsy[i].R; + enabled = "true"; + } + const std::string planet = "{" "Identifier = '" + plna[i] + "'," "Parent = '" + starname + "'," "Enabled = true," "Renderable = {" "Type = 'RenderableGlobe'," - "Radii = " + std::to_string(plsy[i].R) + " *7.1492E7," //R. in meters. 1 jupiter radii = 7.1492×10e7 m + "Enabled = "+ enabled +"," + "Radii = " + std::to_string(planetradius) + " *7.1492E7," //R. in meters. 1 jupiter radii = 7.1492×10e7 m "SegmentsPerPatch = 64," "PerformShading = false," "Layers = {" @@ -496,7 +505,7 @@ int addExoplanetSystem(lua_State* L) { ); script = ""; - } + const std::string planetTrail = "{"