moved the color mapping to the asset files

This commit is contained in:
Lovisa Hassler
2018-11-12 18:26:12 -05:00
parent 89e0b20cc4
commit 5a49c66204
4 changed files with 101 additions and 125 deletions

View File

@@ -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",

View File

@@ -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)

View File

@@ -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<const char*, 3> 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<glm::vec3>(MadridColorInfo.identifier)) {
_madridLineColor = dictionary.value<glm::vec3>(MadridColorInfo.identifier);
}
else {
_madridLineColor = glm::vec3(1.f, 0.f, 0.f);
}
addProperty(_madridLineColor);
if (dictionary.hasKeyAndValue<ghoul::Dictionary>(SiteColorsInfo.identifier)) {
ghoul::Dictionary colorDictionary = dictionary.value<ghoul::Dictionary>(SiteColorsInfo.identifier);
std::vector<std::string> siteNames = colorDictionary.keys();
if (dictionary.hasKeyAndValue<glm::vec3>(CanberraColorInfo.identifier)) {
_canberraLineColor = dictionary.value<glm::vec3>(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<glm::vec3>(siteNames.at(siteIndex));
_siteColors.push_back(std::make_unique<properties::Vec3Property>(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<glm::vec3>(GoldstoneColorInfo.identifier)) {
_goldstoneLineColor = dictionary.value<glm::vec3>(GoldstoneColorInfo.identifier);
}
else {
_goldstoneLineColor = glm::vec3(0.f, 0.f, 1.f);
}
addProperty(_goldstoneLineColor);
if (dictionary.hasKeyAndValue<ghoul::Dictionary>(KeyStationSites)) {
ghoul::Dictionary stationDictionary = dictionary.value<ghoul::Dictionary>(KeyStationSites);
std::vector<std::string> keys = stationDictionary.keys();
for (int i = 0; i < keys.size(); i++)
{
std::string station = keys.at(i);
std::string site = stationDictionary.value<std::string>(keys.at(i));
_stationToSite[station] = site;
}
}
if (dictionary.hasKeyAndValue<double>(LineWidthInfo.identifier)) {
_lineWidth = static_cast<float>(dictionary.value<double>(
LineWidthInfo.identifier
@@ -367,7 +358,8 @@ void RenderableSignals::extractData(std::unique_ptr<ghoul::Dictionary> &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

View File

@@ -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<std::unique_ptr<properties::Vec3Property>> _siteColors;
/// Maps a station identifier to a site location
std::map<std::string, std::string> _stationToSite;
/// Maps a site location to an index in the _siteColors property vector
std::map<std::string, int> _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<std::string, SiteEnum> 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);