diff --git a/data/assets/scene/solarsystem/dsn/communicationlines/communicationlines.asset b/data/assets/scene/solarsystem/dsn/communicationlines/communicationlines.asset index dfdec3d829..59441be63c 100644 --- a/data/assets/scene/solarsystem/dsn/communicationlines/communicationlines.asset +++ b/data/assets/scene/solarsystem/dsn/communicationlines/communicationlines.asset @@ -1,6 +1,6 @@ local assetHelper = asset.require('util/asset_helper') -local kernels = asset.require('scene/solarsystem/missions/voyager1/kernels') -local earthAsset = asset.require('scene/solarsystem/planets/earth/earth') +local stationsAsset = asset.require('scene/solarsystem/dsn/stations') + --Communicationline data local dataFolder = openspace.absPath("../../../sync/http/dsn_data/1/json") @@ -14,9 +14,8 @@ local Signals = { Type = "RenderableSignals", DataFolder = dataFolder, DataFileType = "json", - MadridColor = {1.0, 0.0, 0.0}, - GoldstoneColor = {0.0, 0.0, 1.0}, - CanberraColor = {0.0, 1.0, 0.0} + SiteColors = stationsAsset.siteColorMap, + StationSites = stationsAsset.stationSiteMap }, GUI = { Name = "Signals", diff --git a/data/assets/scene/solarsystem/dsn/stations.asset b/data/assets/scene/solarsystem/dsn/stations.asset index fd85db670b..4804cc6c8a 100644 --- a/data/assets/scene/solarsystem/dsn/stations.asset +++ b/data/assets/scene/solarsystem/dsn/stations.asset @@ -27,6 +27,31 @@ local LightSources = { } } +-- Colormap for the different sites +local siteColorMap = { + Goldstone = {0.0, 0.0, 1.0}, + Canberra = {0.0, 1.0, 0.0}, + Madrid = {1.0, 0.0, 0.0} + } + +-- Map to the site locations above, this will determine the signal colors +local stationSiteMap = { + DSS14 = "Goldstone", + DSS15 = "Goldstone", + DSS24 = "Goldstone", + DSS25 = "Goldstone", + DSS26 = "Goldstone", + DSS43 = "Canberra", + DSS34 = "Canberra", + DSS35 = "Canberra", + DSS36 = "Canberra", + DSS45 = "Canberra", + DSS63 = "Madrid", + DSS65 = "Madrid", + DSS54 = "Madrid", + DSS55 = "Madrid" + } + --------------------- Goldstone ------------------------ local DSS14 = { Identifier = "DSS14", @@ -375,6 +400,10 @@ local DSS55 = { + assetHelper.registerSceneGraphNodesAndExport(asset, { DSS14, DSS15, DSS24, DSS25, DSS26, DSS43, DSS34, DSS35, DSS36, DSS45, DSS63, DSS65, DSS54, DSS55 }) + +asset.export("siteColorMap", siteColorMap) +asset.export("stationSiteMap", stationSiteMap) \ No newline at end of file diff --git a/modules/dsn/rendering/renderablesignals.cpp b/modules/dsn/rendering/renderablesignals.cpp index b8493b862a..bc766d45a4 100644 --- a/modules/dsn/rendering/renderablesignals.cpp +++ b/modules/dsn/rendering/renderablesignals.cpp @@ -41,35 +41,24 @@ namespace { constexpr const char* ProgramName = "SignalsProgram"; constexpr const char* KeyTranslation = "Translation"; constexpr const char* _loggerCat = "RenderableSignals"; + constexpr const char* KeyStationSites = "StationSites"; + constexpr const std::array UniformNames = { "modelViewStation","modelViewSpacecraft", "projectionTransform" }; - constexpr openspace::properties::Property::PropertyInfo MadridColorInfo = { - "MadridColor", - "MadridColor", + constexpr openspace::properties::Property::PropertyInfo SiteColorsInfo = { + "SiteColors", + "SiteColors", "This value determines the RGB main color for the lines " - "of communication to and from Madrid." - }; - - constexpr openspace::properties::Property::PropertyInfo GoldstoneColorInfo = { - "GoldstoneColor", - "GoldstoneColor", - "This value determines the RGB main color for the lines " - "of communication to and from Goldstone." - }; - constexpr openspace::properties::Property::PropertyInfo CanberraColorInfo = { - "CanberraColor", - "CanberraColor", - "This value determines the RGB main color for the lines " - "of communication to and from Canberra." + "of communication to and from different sites on Earth." }; constexpr openspace::properties::Property::PropertyInfo LineWidthInfo = { "LineWidth", "Line Width", - "This value specifies the line width of the communication package. " + "This value specifies the line width of the signals. " }; } // namespace @@ -90,22 +79,17 @@ documentation::Documentation RenderableSignals::Documentation() { "Translation object can be used here." }, { - MadridColorInfo.identifier, - new DoubleVector3Verifier, - Optional::Yes, - MadridColorInfo.description + SiteColorsInfo.identifier, + new TableVerifier, + Optional::No, + SiteColorsInfo.description }, { - GoldstoneColorInfo.identifier, - new DoubleVector3Verifier, - Optional::Yes, - GoldstoneColorInfo.description - }, - { - CanberraColorInfo.identifier, - new DoubleVector3Verifier, - Optional::Yes, - GoldstoneColorInfo.description + KeyStationSites, + new TableVerifier, + Optional::No, + "This is a map of the individual stations to their " + "respective site location on Earth." }, { LineWidthInfo.identifier, @@ -119,9 +103,6 @@ documentation::Documentation RenderableSignals::Documentation() { RenderableSignals::RenderableSignals(const ghoul::Dictionary& dictionary) : Renderable(dictionary) - , _madridLineColor(MadridColorInfo, glm::vec3(1.f), glm::vec3(0.f), glm::vec3(1.f)) - , _goldstoneLineColor(GoldstoneColorInfo, glm::vec3(1.f), glm::vec3(0.f), glm::vec3(1.f)) - , _canberraLineColor(CanberraColorInfo, glm::vec3(1.f), glm::vec3(0.f), glm::vec3(1.f)) , _lineWidth(LineWidthInfo, 2.f, 1.f, 20.f) { _translation = Translation::createFromDictionary( @@ -129,30 +110,40 @@ RenderableSignals::RenderableSignals(const ghoul::Dictionary& dictionary) ); addPropertySubOwner(_translation.get()); - if (dictionary.hasKeyAndValue(MadridColorInfo.identifier)) { - _madridLineColor = dictionary.value(MadridColorInfo.identifier); - } - else { - _madridLineColor = glm::vec3(1.f, 0.f, 0.f); - } - addProperty(_madridLineColor); + if (dictionary.hasKeyAndValue(SiteColorsInfo.identifier)) { + ghoul::Dictionary colorDictionary = dictionary.value(SiteColorsInfo.identifier); + std::vector siteNames = colorDictionary.keys(); - if (dictionary.hasKeyAndValue(CanberraColorInfo.identifier)) { - _canberraLineColor = dictionary.value(CanberraColorInfo.identifier); + // Create + for (int siteIndex = 0; siteIndex < siteNames.size(); siteIndex++) + { + const char* str = siteNames.at(siteIndex).c_str(); + openspace::properties::Property::PropertyInfo SiteColorsInfo = { + str, + str, + "This value determines the RGB main color for signals " + "of communication to and from different sites on Earth." + }; + std::string site = siteNames[siteIndex]; + glm::vec3 siteColor = colorDictionary.value(siteNames.at(siteIndex)); + _siteColors.push_back(std::make_unique(SiteColorsInfo, siteColor, glm::vec3(0.f), glm::vec3(1.f))); + _siteToIndex[siteNames.at(siteIndex)] = siteIndex; + addProperty(_siteColors.back().get()); + } } - else { - _canberraLineColor = glm::vec3(0.f, 1.f, 0.f); - } - addProperty(_canberraLineColor); - if (dictionary.hasKeyAndValue(GoldstoneColorInfo.identifier)) { - _goldstoneLineColor = dictionary.value(GoldstoneColorInfo.identifier); - } - else { - _goldstoneLineColor = glm::vec3(0.f, 0.f, 1.f); - } - addProperty(_goldstoneLineColor); + if (dictionary.hasKeyAndValue(KeyStationSites)) { + ghoul::Dictionary stationDictionary = dictionary.value(KeyStationSites); + std::vector keys = stationDictionary.keys(); + for (int i = 0; i < keys.size(); i++) + { + std::string station = keys.at(i); + std::string site = stationDictionary.value(keys.at(i)); + _stationToSite[station] = site; + } + } + if (dictionary.hasKeyAndValue(LineWidthInfo.identifier)) { _lineWidth = static_cast(dictionary.value( LineWidthInfo.identifier @@ -367,7 +358,8 @@ void RenderableSignals::extractData(std::unique_ptr &dictiona void RenderableSignals::pushSignalDataToVertexArray(SignalManager::Signal signal) { - ColorVBOLayout color = getSiteColor(signal.dishName); + glm::dvec4 color = { getStationColor(signal.dishName), 1.0 }; + //glm::vec4 color = { signal.color, 1.0 }; glm::vec3 posStation = getPositionForGeocentricSceneGraphNode(signal.dishName.c_str()); glm::vec3 posSpacecraft = getSuitablePrecisionPositionForSceneGraphNode(signal.spacecraft.c_str()); @@ -477,46 +469,23 @@ glm::dvec3 RenderableSignals::convertRaDecRangeToCartesian() { return raDecPos; } +glm::vec3 RenderableSignals::getStationColor(std::string dishidentifier) { -RenderableSignals::ColorVBOLayout RenderableSignals::getSiteColor(std::string dishidentifier) { - - glm::vec3 color(0.0f,0.0f,0.0f); - RenderableSignals::ColorVBOLayout colorVbo; - SiteEnum site; + glm::dvec3 color(0.0f, 0.0f, 1.0f); + std::string site; try { - site = StationToSiteConversion.at(dishidentifier); + site = _stationToSite.at(dishidentifier); } catch (const std::exception& e) { LERROR(fmt::format("Station {} has no site location.", dishidentifier)); } - switch (site) { - case 0: - color = _goldstoneLineColor; - break; - case 1: - color = _madridLineColor; - break; - case 2: - color = _canberraLineColor; - break; - } + int siteIndex = _siteToIndex.at(site); + color = _siteColors[siteIndex]->value(); - colorVbo.r = color.r; - colorVbo.g = color.g; - colorVbo.b = color.b; - - //have different alpha for the 70m antennas - if (dishidentifier == "DSS14" || dishidentifier == "DSS63" || dishidentifier == "DSS43") - { - colorVbo.a = 1.0; - } - else { - colorVbo.a = 0.6f; - } - - return colorVbo; + return color; } + } // namespace openspace diff --git a/modules/dsn/rendering/renderablesignals.h b/modules/dsn/rendering/renderablesignals.h index c8bc6c23df..f6e46bcf8b 100644 --- a/modules/dsn/rendering/renderablesignals.h +++ b/modules/dsn/rendering/renderablesignals.h @@ -90,10 +90,12 @@ namespace openspace { glm::dvec3 getEstimatedCoordinatePosFromFocusNode(glm::vec3 pos); /* Converts the Ra Dec range coordinates into cartesian coordinates*/ glm::dvec3 convertRaDecRangeToCartesian(); - /*Returns a position for a spacecraft*/ + /* Returns a position for a spacecraft*/ glm::vec3 getSuitablePrecisionPositionForSceneGraphNode(std::string id); - /*Returns a position for a station that has Earth as parent*/ + /* Returns a position for a station that has Earth as parent*/ glm::vec3 getPositionForGeocentricSceneGraphNode(const char* id); + /* Returns a color based on what site the station is located to */ + glm::vec3 getStationColor(std::string dishidentifier); /* The VBO layout of the vertex position */ struct PositionVBOLayout { @@ -104,9 +106,6 @@ namespace openspace { float r, g, b, a; }; - /* The function deciding what color to use for a signal */ - // Todo: move to asset file - ColorVBOLayout getSiteColor(std::string dishIdentifier); const char* _identifier = "Signals"; protected: @@ -142,10 +141,14 @@ namespace openspace { /// Set of information about the main rendering parts RenderInformation _lineRenderInformation; - /// Specifies the base color of the site lines - properties::Vec3Property _madridLineColor; - properties::Vec3Property _goldstoneLineColor; - properties::Vec3Property _canberraLineColor; + /// Specifies the base color for the different sites + std::vector> _siteColors; + + /// Maps a station identifier to a site location + std::map _stationToSite; + + /// Maps a site location to an index in the _siteColors property vector + std::map _siteToIndex; /// The attribute location for vertex position const GLuint _locVer = 0; @@ -166,30 +169,6 @@ namespace openspace { UniformCache(modelViewStation, modelViewSpacecraft, projection) _uniformCache; - enum SiteEnum { - GoldStone = 0, - Madrid, - Canberra - }; - - // Todo: move to asset file - // Key Value map of stations and their sites - const std::map StationToSiteConversion = { - { "DSS14", GoldStone }, - { "DSS15", GoldStone }, - { "DSS24", GoldStone }, - { "DSS25", GoldStone }, - { "DSS26", GoldStone }, - { "DSS43", Canberra }, - { "DSS34", Canberra }, - { "DSS35", Canberra }, - { "DSS36", Canberra }, - { "DSS45", Canberra }, - { "DSS63", Madrid }, - { "DSS65", Madrid }, - { "DSS54", Madrid }, - { "DSS55", Madrid } - }; /*Checks if the current time is within a signal's start and endtime*/ bool isSignalActive(double currentTime, std::string signalStartTime, std::string signalEndTime);