diff --git a/data/assets/scene/solarsystem/dsn/stationsfov.asset b/data/assets/scene/solarsystem/dsn/stationsfov.asset index f3ad391c4e..7b6f3165d7 100644 --- a/data/assets/scene/solarsystem/dsn/stationsfov.asset +++ b/data/assets/scene/solarsystem/dsn/stationsfov.asset @@ -1,11 +1,9 @@ local assetHelper = asset.require('util/asset_helper') local earthAsset = asset.require('scene/solarsystem/planets/earth/earth') -local stationsAsset = asset.require('scene/solarsystem/dsn/stations') ---------------------------------------------------------------------- ---- The Fields Of View of the DSN Ground Station Location Sites ---- ---------------------------------------------------------------------- -colors = stationsAsset.siteColorMap local GoldstoneFOV = { Identifier = "GoldstoneFOV", @@ -16,7 +14,7 @@ local GoldstoneFOV = { BaseCenterDirection = earthAsset.Earth.Identifier, ReverseDirection = true, Resolution = 50, - Color = colors.GoldstoneColor, + ColorPropertyURI = "Scene.Signals.Renderable.GoldstoneColor", -- keep in sync with stationsAsset siteColorMap ViewAngle = 160.0 }, GUI = { @@ -33,7 +31,7 @@ local MadridFOV = { BaseCenterDirection = earthAsset.Earth.Identifier, ReverseDirection = true, Resolution = 50, - Color = colors.MadridColor, + ColorPropertyURI = "Scene.Signals.Renderable.MadridColor", -- keep in sync with stationsAsset siteColorMap ViewAngle = 160.0 }, GUI = { @@ -50,7 +48,7 @@ local CanberraFOV = { BaseCenterDirection = earthAsset.Earth.Identifier, ReverseDirection = true, Resolution = 50, - Color = colors.CanberraColor, + ColorPropertyURI = "Scene.Signals.Renderable.CanberraColor", -- keep in sync with stationsAsset siteColorMap ViewAngle = 160.0 }, GUI = { @@ -59,4 +57,4 @@ local CanberraFOV = { } } -assetHelper.registerSceneGraphNodesAndExport(asset, {GoldstoneFOV, MadridFOV,CanberraFOV}) \ No newline at end of file +assetHelper.registerSceneGraphNodesAndExport(asset, {GoldstoneFOV, MadridFOV, CanberraFOV}) \ No newline at end of file diff --git a/modules/dsn/rendering/renderablestationfov.cpp b/modules/dsn/rendering/renderablestationfov.cpp index 3ac912d02a..1bd8d35665 100644 --- a/modules/dsn/rendering/renderablestationfov.cpp +++ b/modules/dsn/rendering/renderablestationfov.cpp @@ -29,6 +29,8 @@ #include #include #include +#include + namespace { constexpr const char* ProgramName = "StationFovProgram"; @@ -48,6 +50,12 @@ namespace { "Distance Fade", "Fade applied linearly from viewpoint" }; + + constexpr openspace::properties::Property::PropertyInfo ColorPropertyUriInfo = { + "ColorPropertyURI", + "Color Property URI", + "Color property URI that makes the station field of view update with the station site colors." + }; } // namespace namespace openspace { @@ -68,7 +76,7 @@ documentation::Documentation RenderableStationFov::Documentation() { { ViewAngleInfo.identifier, new DoubleVerifier, - Optional::Yes, + Optional::No, ViewAngleInfo.description }, { @@ -76,6 +84,12 @@ documentation::Documentation RenderableStationFov::Documentation() { new BoolVerifier, Optional::Yes, ViewAngleInfo.description + }, + { + ColorPropertyUriInfo.identifier, + new StringVerifier, + Optional::Yes, + ColorPropertyUriInfo.description } } }; @@ -97,6 +111,7 @@ RenderableStationFov::RenderableStationFov(const ghoul::Dictionary& dictionary) : RenderableCone(dictionary) , _angle(ViewAngleInfo, 160.0, 0.0, 180.0) , _distanceFade(DistanceFadeInfo, true) + , _colorPropertyUri(ColorPropertyUriInfo) { _showbase = false; _directionIsReversed = true; @@ -105,6 +120,15 @@ RenderableStationFov::RenderableStationFov(const ghoul::Dictionary& dictionary) if (dictionary.hasKeyAndValue(ViewAngleInfo.identifier)) { _angle = dictionary.value(ViewAngleInfo.identifier); } + + if (dictionary.hasKeyAndValue(ColorPropertyUriInfo.identifier)) { + _colorPropertyUri = dictionary.value(ColorPropertyUriInfo.identifier); + _colorPropertyPointer = openspace::property(_colorPropertyUri); + addProperty(_colorPropertyUri); + _hasUriColor = true; + removeProperty(_color); + } + addProperty(_distanceFade); addProperty(_angle); removeProperty(_radius); @@ -149,6 +173,11 @@ void RenderableStationFov::updateVertexAttributes() void RenderableStationFov::fillVertexArrays() { + if (_hasUriColor) { + properties::Vec4Property* colorProperty = static_cast(_colorPropertyPointer); + glm::vec4 color = colorProperty->value(); + _color.setValue(glm::vec3(color.x, color.y, color.z)); + } glm::vec4 colorAndOpacity = { glm::vec3(_color), _opacity }; float apexFade = 1.0; diff --git a/modules/dsn/rendering/renderablestationfov.h b/modules/dsn/rendering/renderablestationfov.h index c6fffa1de9..0b9ac94588 100644 --- a/modules/dsn/rendering/renderablestationfov.h +++ b/modules/dsn/rendering/renderablestationfov.h @@ -52,6 +52,10 @@ namespace openspace { properties::FloatProperty _angle; properties::BoolProperty _distanceFade; + properties::StringProperty _colorPropertyUri; + properties::Property* _colorPropertyPointer = nullptr; + + bool _hasUriColor = false; private: /// The vertex attribute location for position