made station fov follow the color of the site locations

This commit is contained in:
Lovisa Hassler
2019-01-23 18:01:58 -05:00
parent dcf65fe784
commit 704df2eebf
3 changed files with 38 additions and 7 deletions

View File

@@ -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})
assetHelper.registerSceneGraphNodesAndExport(asset, {GoldstoneFOV, MadridFOV, CanberraFOV})

View File

@@ -29,6 +29,8 @@
#include <ghoul/filesystem/filesystem.h>
#include <openspace/engine/globals.h>
#include <openspace/rendering/renderengine.h>
#include <openspace/query/query.h>
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<double>(ViewAngleInfo.identifier)) {
_angle = dictionary.value<double>(ViewAngleInfo.identifier);
}
if (dictionary.hasKeyAndValue<std::string>(ColorPropertyUriInfo.identifier)) {
_colorPropertyUri = dictionary.value<std::string>(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<properties::Vec4Property*>(_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;

View File

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