From 2bc0dd8efd2aae75c418f379b526c54fa140fc22 Mon Sep 17 00:00:00 2001 From: Emma Broman Date: Thu, 3 Sep 2020 11:29:12 +0200 Subject: [PATCH] Add a glare to the host star, similar to the sun --- modules/exoplanets/exoplanetsmodule_lua.inl | 35 +++++++++++++++++++-- 1 file changed, 32 insertions(+), 3 deletions(-) diff --git a/modules/exoplanets/exoplanetsmodule_lua.inl b/modules/exoplanets/exoplanetsmodule_lua.inl index ffe1a821b1..74f755ca41 100644 --- a/modules/exoplanets/exoplanetsmodule_lua.inl +++ b/modules/exoplanets/exoplanetsmodule_lua.inl @@ -221,9 +221,15 @@ int addExoplanetSystem(lua_State* L) { starToSunVec.z ); + const std::string starIdentifier = createIdentifier(starNameSpeck); + // Star renderable globe, if we have a radius std::string starGlobeRenderableString = ""; const float starRadius = p.RSTAR; + + const float validRadius = isnan(starRadius) ? 1.f : starRadius; + const float starRadiusInMeter = validRadius * distanceconstants::SolarRadius; + if (!isnan(starRadius)) { std::ifstream colorMap( absPath("${SYNC}/http/stars_colormap/2/colorbv.cmap"), @@ -235,11 +241,10 @@ int addExoplanetSystem(lua_State* L) { } const std::string color = getStarColor(p.BMV, colorMap); - const float radiusInMeter = starRadius * distanceconstants::SolarRadius; starGlobeRenderableString = "Renderable = {" "Type = 'RenderableGlobe'," - "Radii = " + std::to_string(radiusInMeter) + "," + "Radii = " + std::to_string(starRadiusInMeter) + "," "SegmentsPerPatch = 64," "PerformShading = false," "Layers = {" @@ -262,7 +267,6 @@ int addExoplanetSystem(lua_State* L) { "},"; } - const std::string starIdentifier = createIdentifier(starNameSpeck); const std::string starParent = "{" "Identifier = '" + starIdentifier + "'," @@ -284,11 +288,36 @@ int addExoplanetSystem(lua_State* L) { "}" "}"; + openspace::global::scriptEngine.queueScript( "openspace.addSceneGraphNode(" + starParent + ");", openspace::scripting::ScriptEngine::RemoteScripting::Yes ); + const std::string starGlare = "{" + "Identifier = '" + starIdentifier + "_glare'," + "Parent = '" + starIdentifier + "'," + "Renderable = {" + "Type = 'RenderablePlaneImageLocal'," + "Size = " + std::to_string(10.f * starRadiusInMeter) + "," + "Origin = 'Center'," + "Billboard = true," + "Texture = openspace.absPath('${SYNC}/http/sun_textures/4/halo.png')," + "BlendMode = 'Additive'," + "Opacity = 0.65," + "RenderableType = 'PreDeferredTransparency'" + "}," + "GUI = {" + "Name = '" + starNameSpeck + " (Star Glare)'," + "Path = '" + ExoplanetsGuiPath + starNameSpeck + "'," + "}" + "}"; + + openspace::global::scriptEngine.queueScript( + "openspace.addSceneGraphNode(" + starGlare + ");", + openspace::scripting::ScriptEngine::RemoteScripting::Yes + ); + for (size_t i = 0; i < planetSystem.size(); i++) { Exoplanet planet = planetSystem[i]; const std::string planetName = planetNames[i];