diff --git a/modules/base/rendering/renderablemodel.cpp b/modules/base/rendering/renderablemodel.cpp index 5c6596c93e..374ae7587b 100644 --- a/modules/base/rendering/renderablemodel.cpp +++ b/modules/base/rendering/renderablemodel.cpp @@ -46,11 +46,20 @@ namespace { const char* KeyGeometry = "Geometry"; const char* KeyTexture = "Textures.Color"; const char* KeyModelTransform = "Rotation.ModelTransform"; - const char* KeyFading = "Shading.Fadeable"; - const char* keyBody = "Body"; - const char* keyStart = "StartTime"; - const char* keyEnd = "EndTime"; + static const openspace::properties::Property::PropertyInfo TextureInfo = { + "ColorTexture", // @TODO replace with only "Texture" + "Color Texture", + "This value points to a color texture file that is applied to the geometry " + "rendered in this object." + }; + + static const openspace::properties::Property::PropertyInfo ShadingInfo = { + "PerformShading", + "Perform Shading", + "This value determines whether this model should be shaded by using the position " + "of the Sun." + }; } // namespace namespace openspace { @@ -68,10 +77,15 @@ documentation::Documentation RenderableModel::Documentation() { Optional::No }, { - KeyTexture, + KeyTexture, // @TODO replace with TextureInfo.identifier new StringVerifier, - "A color texture that can be applied to the model specified by the " - "Geometry.", + TextureInfo.description, + Optional::Yes + }, + { + ShadingInfo.identifier, + new BoolVerifier, + ShadingInfo.description, Optional::Yes }, { @@ -80,13 +94,6 @@ documentation::Documentation RenderableModel::Documentation() { "Specifies a distinct transformation matrix that is applied to the " "model. If it is not specified, it is equal to the Identity matrix.", Optional::Yes - }, - { - KeyFading, - new BoolVerifier, - "Specifies whether the model should be periodically fading in and out. " - "If this value is not specified, it will not fade.", - Optional::Yes } } }; @@ -95,10 +102,8 @@ documentation::Documentation RenderableModel::Documentation() { RenderableModel::RenderableModel(const ghoul::Dictionary& dictionary) : Renderable(dictionary) , _geometry(nullptr) - , _colorTexturePath({ "ColorTexture", "Color Texture", "" }) // @TODO Missing documentation - , _performFade({ "PerformFading", "Perform Fading", "" }, false) // @TODO Missing documentation - , _performShading({ "PerformShading", "Perform Shading", "" }, true) // @TODO Missing documentation - , _fading({ "Fading", "Fade", "" }, 0) // @TODO Missing documentation + , _colorTexturePath(TextureInfo) + , _performShading(ShadingInfo, true) , _programObject(nullptr) , _texture(nullptr) , _modelTransform(1.0) @@ -129,8 +134,8 @@ RenderableModel::RenderableModel(const ghoul::Dictionary& dictionary) _modelTransform = dictionary.value(KeyModelTransform); } - if (dictionary.hasKey(KeyFading)) { - _performFade = dictionary.value(KeyFading); + if (dictionary.hasKey(ShadingInfo.identifier)) { + _performShading = dictionary.value(ShadingInfo.identifier); } addPropertySubOwner(_geometry.get()); @@ -139,7 +144,6 @@ RenderableModel::RenderableModel(const ghoul::Dictionary& dictionary) _colorTexturePath.onChange(std::bind(&RenderableModel::loadTexture, this)); addProperty(_performShading); - addProperty(_performFade); } bool RenderableModel::isReady() const { @@ -179,14 +183,6 @@ bool RenderableModel::deinitialize() { void RenderableModel::render(const RenderData& data, RendererTasks&) { _programObject->activate(); - // Fading - if (_performFade && _fading > 0.f) { - _fading = _fading - 0.01f; - } - else if (!_performFade && _fading < 1.f) { - _fading = _fading + 0.01f; - } - // Model transform and view transform needs to be in double precision glm::dmat4 modelTransform = glm::translate(glm::dmat4(1.0), data.modelTransform.translation) * // Translation @@ -201,7 +197,7 @@ void RenderableModel::render(const RenderData& data, RendererTasks&) { _programObject->setUniform("modelViewTransform", glm::mat4(modelViewTransform)); _programObject->setUniform("projectionTransform", data.camera.projectionMatrix()); _programObject->setUniform("performShading", _performShading); - _programObject->setUniform("fading", _fading); + _programObject->setUniform("fading", 1.f); // @TODO remove this _geometry->setUniforms(*_programObject); diff --git a/modules/base/rendering/renderablemodel.h b/modules/base/rendering/renderablemodel.h index fadd85bde6..1fc9ec5c51 100644 --- a/modules/base/rendering/renderablemodel.h +++ b/modules/base/rendering/renderablemodel.h @@ -68,9 +68,7 @@ private: std::unique_ptr _geometry; properties::StringProperty _colorTexturePath; - properties::BoolProperty _performFade; properties::BoolProperty _performShading; - properties::FloatProperty _fading; std::unique_ptr _programObject; std::unique_ptr _texture; diff --git a/modules/base/rendering/renderableplane.cpp b/modules/base/rendering/renderableplane.cpp index 75fb5cc5af..efb44c9743 100644 --- a/modules/base/rendering/renderableplane.cpp +++ b/modules/base/rendering/renderableplane.cpp @@ -38,10 +38,39 @@ #include namespace { - const char* KeySize = "Size"; - const char* KeyBillboard = "Billboard"; const char* KeyBlendMode = "BlendMode"; - const char* KeyTexture = "Texture"; + + enum BlendMode { + BlendModeNormal = 0, + BlendModeAdditive + }; + + static const openspace::properties::Property::PropertyInfo TextureInfo = { + "Texture", + "Texture", + "This value specifies an image that is loaded from disk and is used as a texture " + "that is applied to this plane. This image has to be square." + }; + + static const openspace::properties::Property::PropertyInfo BillboardInfo = { + "Billboard", + "Billboard mode", + "This value specifies whether the plane is a billboard, which means that it is " + "always facing the camera. If this is false, it can be oriented using other " + "transformations." + }; + + static const openspace::properties::Property::PropertyInfo SizeInfo = { + "Size", + "Size (in meters)", + "This value specifies the size of the plane in meters." + }; + + static const openspace::properties::Property::PropertyInfo BlendModeInfo = { + "BlendMode", + "Blending Mode", + "This determines the blending mode that is applied to this plane." + }; } // namespace namespace openspace { @@ -53,31 +82,27 @@ documentation::Documentation RenderablePlane::Documentation() { "base_renderable_plane", { { - KeySize, + SizeInfo.identifier, new DoubleVerifier, - "Specifies the size of the square plane in meters.", + SizeInfo.description, Optional::No }, { - KeyBillboard, + BillboardInfo.identifier, new BoolVerifier, - "Specifies whether the plane is a billboard, which means that it is " - "always facing the camera. If this is false, it can be oriented using " - "other transformations. The default is 'false'.", + BillboardInfo.description, Optional::Yes }, { - KeyBlendMode, + BlendModeInfo.identifier, new StringInListVerifier({ "Normal", "Additive" }), - "Specifies the blend mode that is applied to this plane. The default " - "value is 'Normal'.", + BlendModeInfo.description, // + " The default value is 'Normal'.", Optional::Yes }, { - KeyTexture, + TextureInfo.identifier, new StringVerifier, - "Specifies the texture that is applied to this plane. This image has to " - "be a square image.", + TextureInfo.description, Optional::No } } @@ -87,12 +112,13 @@ documentation::Documentation RenderablePlane::Documentation() { RenderablePlane::RenderablePlane(const ghoul::Dictionary& dictionary) : Renderable(dictionary) - , _texturePath({ "Texture", "Texture", "" }) // @TODO Missing documentation - , _billboard({ "Billboard", "Billboard", "" }, false) // @TODO Missing documentation - , _size({ "Size", "Size", "" }, 10, 0, std::pow(10, 25)) // @TODO Missing documentation + , _texturePath(TextureInfo) + , _billboard(BillboardInfo, false) + , _size(SizeInfo, 10.f, 0.f, 1e25) + , _blendMode(BlendModeInfo, properties::OptionProperty::DisplayType::Dropdown) , _shader(nullptr) , _texture(nullptr) - , _blendMode(BlendMode::Normal) + //, _blendMode(BlendMode::Normal) , _quad(0) , _vertexPositionBuffer(0) , _planeIsDirty(false) @@ -104,23 +130,39 @@ RenderablePlane::RenderablePlane(const ghoul::Dictionary& dictionary) "RenderablePlane" ); - _size = static_cast(dictionary.value(KeySize)); + _size = static_cast(dictionary.value(SizeInfo.identifier)); - if (dictionary.hasKey(KeyBillboard)) { - _billboard = dictionary.value(KeyBillboard); + if (dictionary.hasKey(BillboardInfo.identifier)) { + _billboard = dictionary.value(BillboardInfo.identifier); } + _blendMode.addOptions({ + { BlendModeNormal, "Normal" }, + { BlendModeAdditive, "Additive"} + }); + _blendMode.onChange([&]() { + switch (_blendMode) { + case BlendModeNormal: + setRenderBin(Renderable::RenderBin::Opaque); + break; + case BlendModeAdditive: + setRenderBin(Renderable::RenderBin::Transparent); + break; + default: + throw ghoul::MissingCaseException(); + } + }); + if (dictionary.hasKey(KeyBlendMode)) { const std::string v = dictionary.value(KeyBlendMode); if (v == "Normal") { - _blendMode = BlendMode::Normal; + _blendMode = BlendModeNormal; } else if (v == "Additive") { - _blendMode = BlendMode::Additive; - setRenderBin(Renderable::RenderBin::Transparent); + _blendMode = BlendModeAdditive; } } - _texturePath = absPath(dictionary.value(KeyTexture)); + _texturePath = absPath(dictionary.value(TextureInfo.identifier)); _textureFile = std::make_unique(_texturePath); addProperty(_billboard); diff --git a/modules/base/rendering/renderableplane.h b/modules/base/rendering/renderableplane.h index 4b49246dbe..143a004cae 100644 --- a/modules/base/rendering/renderableplane.h +++ b/modules/base/rendering/renderableplane.h @@ -27,6 +27,7 @@ #include +#include #include #include #include @@ -64,24 +65,18 @@ public: static documentation::Documentation Documentation(); private: - enum class BlendMode : int { - Normal = 0, - Additive - }; - void loadTexture(); void createPlane(); properties::StringProperty _texturePath; properties::BoolProperty _billboard; properties::FloatProperty _size; + properties::OptionProperty _blendMode; std::unique_ptr _shader; std::unique_ptr _texture; std::unique_ptr _textureFile; - BlendMode _blendMode; - GLuint _quad; GLuint _vertexPositionBuffer; diff --git a/modules/base/rendering/renderablesphere.cpp b/modules/base/rendering/renderablesphere.cpp index 03e8715aec..30d2b03de5 100644 --- a/modules/base/rendering/renderablesphere.cpp +++ b/modules/base/rendering/renderablesphere.cpp @@ -41,15 +41,44 @@ #include namespace { - const char* KeySize = "Size"; - const char* KeySegments = "Segments"; - const char* KeyTexture = "Texture"; - const char* KeyOrientation = "Orientation"; - enum Orientation { Outside = 1, Inside = 2 }; + + static const openspace::properties::Property::PropertyInfo TextureInfo = { + "Texture", + "Texture", + "This value specifies an image that is loaded from disk and is used as a texture " + "that is applied to this sphere. This image is expected to be an equirectangular " + "projection." + }; + + static const openspace::properties::Property::PropertyInfo OrientationInfo = { + "Orientation", + "Orientation", + "Specifies whether the texture is applied to the inside of the sphere, the " + "outside of the sphere, or both." + }; + + static const openspace::properties::Property::PropertyInfo SegmentsInfo = { + "Segments", + "Number of Segments", + "This value specifies the number of segments that the sphere is separated in." + }; + + static const openspace::properties::Property::PropertyInfo SizeInfo = { + "Size", + "Size (in meters)", + "This value specifies the radius of the sphere in meters." + }; + + static const openspace::properties::Property::PropertyInfo TransparencyInfo = { + "Alpha", + "Transparency", + "This value determines the transparency of the sphere. If this value is set to " + "1, the sphere is completely opaque. At 0, the sphere is completely transparent." + }; } // namespace namespace openspace { @@ -61,28 +90,33 @@ documentation::Documentation RenderableSphere::Documentation() { "base_renderable_sphere", { { - KeySize, + SizeInfo.identifier, new DoubleVerifier, - "Specifies the radius of the sphere in meters.", + SizeInfo.description, Optional::No }, { - KeySegments, + SegmentsInfo.identifier, new IntVerifier, - "Specifies the number of segments the sphere is separated in.", + SegmentsInfo.description, Optional::No }, { - KeyTexture, + TextureInfo.identifier, new StringVerifier, - "Specifies the texture that is applied to the sphere.", + TextureInfo.description, Optional::No }, { - KeyOrientation, + OrientationInfo.identifier, new StringInListVerifier({ "Inside", "Outside", "Inside/Outside" }), - "Specifies whether the texture is applied to the inside of the sphere, " - "the outside of the sphere, or both. The default value is 'Outside'.", + OrientationInfo.description, + Optional::Yes + }, + { + TransparencyInfo.identifier, + new DoubleInRangeVerifier(0.0, 1.0), + TransparencyInfo.description, Optional::Yes } } @@ -92,11 +126,11 @@ documentation::Documentation RenderableSphere::Documentation() { RenderableSphere::RenderableSphere(const ghoul::Dictionary& dictionary) : Renderable(dictionary) - , _texturePath({ "Texture", "Texture", "" }) // @TODO Missing documentation - , _orientation({ "Orientation", "Orientation", "" }) // @TODO Missing documentation - , _size({ "Size", "Size", "" }, 1.f, 0.f, std::pow(10.f, 45)) // @TODO Missing documentation - , _segments({ "Segments", "Segments", "" }, 8, 4, 100) // @TODO Missing documentation - , _transparency({ "Transparency", "Transparency", "" }, 1.f, 0.f, 1.f) // @TODO Missing documentation + , _texturePath(TextureInfo) + , _orientation(OrientationInfo, properties::OptionProperty::DisplayType::Dropdown) + , _size(SizeInfo, 1.f, 0.f, 1e35) + , _segments(SegmentsInfo, 8, 4, 1000) + , _transparency(TransparencyInfo, 1.f, 0.f, 1.f) , _shader(nullptr) , _texture(nullptr) , _sphere(nullptr) @@ -108,16 +142,18 @@ RenderableSphere::RenderableSphere(const ghoul::Dictionary& dictionary) "RenderableSphere" ); - _size = static_cast(dictionary.value(KeySize)); - _segments = static_cast(dictionary.value(KeySegments)); - _texturePath = absPath(dictionary.value(KeyTexture)); + _size = static_cast(dictionary.value(SizeInfo.identifier)); + _segments = static_cast(dictionary.value(SegmentsInfo.identifier)); + _texturePath = absPath(dictionary.value(TextureInfo.identifier)); - _orientation.addOption(Outside, "Outside"); - _orientation.addOption(Inside, "Inside"); - _orientation.addOption(Outside | Inside, "Inside/Outside"); + _orientation.addOptions({ + { Outside, "Outside" }, + { Inside, "Inside" }, + { Outside | Inside, "Inside/Outside" } + }); - if (dictionary.hasKey(KeyOrientation)) { - const std::string v = dictionary.value(KeyOrientation); + if (dictionary.hasKey(OrientationInfo.identifier)) { + const std::string v = dictionary.value(OrientationInfo.identifier); if (v == "Inside") { _orientation = Inside; } @@ -128,7 +164,7 @@ RenderableSphere::RenderableSphere(const ghoul::Dictionary& dictionary) _orientation = Outside | Inside; } else { - ghoul_assert(false, "Missing 'case' label"); + throw ghoul::MissingCaseException(); } } else { @@ -142,12 +178,22 @@ RenderableSphere::RenderableSphere(const ghoul::Dictionary& dictionary) addProperty(_segments); _segments.onChange([this](){ _sphereIsDirty = true; }); + _transparency.onChange([this](){ + if (_transparency > 0.f && _transparency < 1.f) { + setRenderBin(Renderable::RenderBin::Transparent); + } + else { + setRenderBin(Renderable::RenderBin::Opaque); + } + }); + if (dictionary.hasKey(TransparencyInfo.identifier)) { + _transparency = dictionary.value(TransparencyInfo.identifier); + } addProperty(_transparency); + addProperty(_texturePath); - _texturePath.onChange([this]() {loadTexture(); }); + _texturePath.onChange([this]() { loadTexture(); }); - - setRenderBin(Renderable::RenderBin::Transparent); } bool RenderableSphere::isReady() const { diff --git a/modules/base/rendering/renderabletrail.cpp b/modules/base/rendering/renderabletrail.cpp index e92b515d5a..898346c226 100644 --- a/modules/base/rendering/renderabletrail.cpp +++ b/modules/base/rendering/renderabletrail.cpp @@ -35,12 +35,6 @@ namespace { const char* KeyTranslation = "Translation"; - const char* KeyColor = "Color"; - const char* KeyEnableFade = "EnableFade"; - const char* KeyFade = "Fade"; - const char* KeyLineWidth = "LineWidth"; - const char* KeyPointSize = "PointSize"; - const char* KeyRendering = "Rendering"; // The possible values for the _renderingModes property enum RenderingMode { @@ -56,6 +50,54 @@ namespace { { "Lines+Points", RenderingModeLinesPoints }, { "Points+Lines", RenderingModeLinesPoints } }; + + static const openspace::properties::Property::PropertyInfo LineColorInfo = { + "Color", + "Color", + "This value determines the RGB main color for the lines and points of the trail." + }; + + static const openspace::properties::Property::PropertyInfo EnableFadeInfo = { + "EnableFade", + "Enable line fading of old points", + "Toggles whether the trail should fade older points out. If this value is " + "'true', the 'Fade' parameter determines the speed of fading. If this value is " + "'false', the entire trail is rendered at full opacity and color." + }; + + static const openspace::properties::Property::PropertyInfo FadeInfo = { + "Fade", + "Line fade", + "The fading factor that is applied to the trail if the 'EnableFade' value is " + "'true'. If it is 'false', this setting has no effect. The higher the number, " + "the less fading is applied." + }; + + static const openspace::properties::Property::PropertyInfo LineWidthInfo = { + "LineWidth", + "Line Width", + "This value specifies the line width of the trail if the selected rendering " + "method includes lines. If the rendering mode is set to Points, this value is " + "ignored." + }; + + static const openspace::properties::Property::PropertyInfo PointSizeInfo = { + "PointSize", + "Point Size", + "This value specifies the base size of the points along the line if the selected " + "rendering method includes points. If the rendering mode is set the Lines, this " + "value is ignored. If a subsampling of the values is performed, the subsampled " + "values are half this size." + }; + + static const openspace::properties::Property::PropertyInfo RenderingModeInfo = { + "Rendering", + "Rendering Mode", + "Determines how the trail should be rendered to the screen.If 'Lines' is " + "selected, only the line part is visible, if 'Points' is selected, only the " + "corresponding points (and subpoints) are shown. 'Lines+Points' shows both parts." + }; + } // namespace namespace openspace { @@ -74,56 +116,42 @@ documentation::Documentation RenderableTrail::Documentation() { Optional::No }, { - KeyColor, + LineColorInfo.identifier, new DoubleVector3Verifier, - "The main color the for lines and points on this trail. The value is " - "interpreted as an RGB value.", + LineColorInfo.description, Optional::No }, { - KeyEnableFade, + EnableFadeInfo.identifier, new BoolVerifier, - "Toggles whether the trail should fade older points out. If this value " - "is 'true', the 'Fade' parameter determines the speed of fading. If this " - "value is 'false', the entire trail is rendered at full opacity and " - "color. The default value is 'true'.", + EnableFadeInfo.description, Optional::Yes }, { - KeyFade, + FadeInfo.identifier, new DoubleVerifier, - "The fading factor that is applied to the trail if the 'EnableFade' " - "value is 'true'. If it is 'false', this setting has no effect. The " - "higher the number, the less fading is applied. This value defaults to " - "1.0.", + FadeInfo.description, Optional::Yes }, { - KeyLineWidth, + LineWidthInfo.identifier, new DoubleVerifier, - "This value specifies the line width of the trail if this rendering " - "method is selected. It defaults to 2.0.", + LineWidthInfo.description, Optional::Yes }, { - KeyPointSize, + PointSizeInfo.identifier, new DoubleVerifier, - "This value specifies the base size of the points along the line if this " - "rendering method is selected. If a subsampling of the values is " - "performed, the subsampled values are half this size. The default value " - "is 1.0.", + PointSizeInfo.description, Optional::Yes }, { - KeyRendering, + RenderingModeInfo.identifier, new StringInListVerifier( // Taken from the RenderingModeConversion map above - { "Lines", "Points", "Lines+Points", "Points + Lines" } + { "Lines", "Points", "Lines+Points", "Points+Lines" } ), - "Determines how the trail should be rendered to the screen. If 'Lines' " - "is selected, only the line part is visible, if 'Points' is selected, " - "only the corresponding points (and subpoints) are shown. " - "Lines+Points' shows both parts. On default, only the lines are rendered", + RenderingModeInfo.description, Optional::Yes } }, @@ -133,14 +161,12 @@ documentation::Documentation RenderableTrail::Documentation() { RenderableTrail::RenderableTrail(const ghoul::Dictionary& dictionary) : Renderable(dictionary) - , _lineColor({ "LineColor", "Color", "" }, glm::vec3(1.f), glm::vec3(0.f), glm::vec3(1.f)) // @TODO Missing documentation - , _useLineFade({ "UseLineFade", "Use Line Fade", "" }, true) // @TODO Missing documentation - , _lineFade({ "LineFade", "Line Fade", "" }, 1.f, 0.f, 20.f) // @TODO Missing documentation - , _lineWidth({ "LineWidth", "Line Width", "" }, 2.f, 1.f, 20.f) // @TODO Missing documentation - , _pointSize({ "PointSize", "Point Size", "" }, 1, 1, 64) // @TODO Missing documentation - , _renderingModes( - { "RenderingMode", "Rendering Mode", "" }, // @TODO Missing documentation - properties::OptionProperty::DisplayType::Dropdown + , _lineColor(LineColorInfo, glm::vec3(1.f), glm::vec3(0.f), glm::vec3(1.f)) + , _useLineFade(EnableFadeInfo, true) + , _lineFade(FadeInfo, 1.f, 0.f, 30.f) + , _lineWidth(LineWidthInfo, 2.f, 1.f, 20.f) + , _pointSize(PointSizeInfo, 1, 1, 64) + , _renderingModes(RenderingModeInfo, properties::OptionProperty::DisplayType::Dropdown ) { _translation = std::unique_ptr(Translation::createFromDictionary( @@ -148,26 +174,28 @@ RenderableTrail::RenderableTrail(const ghoul::Dictionary& dictionary) )); addPropertySubOwner(_translation.get()); - _lineColor = dictionary.value(KeyColor); + _lineColor = dictionary.value(LineColorInfo.identifier); addProperty(_lineColor); - if (dictionary.hasKeyAndValue(KeyEnableFade)) { - _useLineFade = dictionary.value(KeyEnableFade); + if (dictionary.hasKeyAndValue(EnableFadeInfo.identifier)) { + _useLineFade = dictionary.value(EnableFadeInfo.identifier); } addProperty(_useLineFade); - if (dictionary.hasKeyAndValue(KeyFade)) { - _lineFade = static_cast(dictionary.value(KeyFade)); + if (dictionary.hasKeyAndValue(FadeInfo.identifier)) { + _lineFade = static_cast(dictionary.value(FadeInfo.identifier)); } addProperty(_lineFade); - if (dictionary.hasKeyAndValue(KeyLineWidth)) { - _lineWidth = static_cast(dictionary.value(KeyLineWidth)); + if (dictionary.hasKeyAndValue(LineWidthInfo.identifier)) { + _lineWidth = static_cast(dictionary.value( + LineWidthInfo.identifier + )); } addProperty(_lineWidth); - if (dictionary.hasKeyAndValue(KeyPointSize)) { - _pointSize = static_cast(dictionary.value(KeyPointSize)); + if (dictionary.hasKeyAndValue(PointSizeInfo.identifier)) { + _pointSize = static_cast(dictionary.value(PointSizeInfo.identifier)); } addProperty(_pointSize); @@ -179,9 +207,9 @@ RenderableTrail::RenderableTrail(const ghoul::Dictionary& dictionary) // This map is not accessed out of order as long as the Documentation is adapted // whenever the map changes. The documentation will check for valid values - if (dictionary.hasKeyAndValue(KeyRendering)) { + if (dictionary.hasKeyAndValue(RenderingModeInfo.identifier)) { _renderingModes = RenderingModeConversion.at( - dictionary.value(KeyRendering) + dictionary.value(RenderingModeInfo.identifier) ); } else { diff --git a/modules/base/rendering/renderabletrailorbit.cpp b/modules/base/rendering/renderabletrailorbit.cpp index 35ee4bdb32..106e0ec8b2 100644 --- a/modules/base/rendering/renderabletrailorbit.cpp +++ b/modules/base/rendering/renderabletrailorbit.cpp @@ -81,8 +81,24 @@ // items in memory as was shown to be much slower than the current system. ---abock namespace { - const char* KeyPeriod = "Period"; - const char* KeyResolution = "Resolution"; + static const openspace::properties::Property::PropertyInfo PeriodInfo = { + "Period", + "Period (in days)", + "The objects period, i.e. the length of its orbit around the parent object given " + "in (Earth) days. In the case of Earth, this would be a sidereal year " + "(=365.242 days). If this values is specified as multiples of the period, it is " + "possible to show the effects of precession." + }; + + static const openspace::properties::Property::PropertyInfo ResolutionInfo = { + "Resolution", + "Number of samples along the orbit", + "The number of samples along the orbit. This determines the resolution of the " + "trail; the tradeoff being that a higher resolution is able to resolve more " + "detail, but will take more resources while rendering, too. The higher, the " + "smoother the trail, but also more memory will be used." + }; + } // namespace namespace openspace { @@ -94,27 +110,15 @@ documentation::Documentation RenderableTrailOrbit::Documentation() { "base_renderable_renderabletrailorbit", { { - "Type", - new StringEqualVerifier("RenderableTrailOrbit"), - "", - Optional::No - }, - { - KeyPeriod, + PeriodInfo.identifier, new DoubleVerifier, - "The objects period, i.e. the length of its orbit around the parent " - "object given in (Earth) days. In the case of Earth, this would be a " - "sidereal year (=365.242 days). If this values is specified as multiples " - "of the period, it is possible to show the effects of precession.", + PeriodInfo.description, Optional::No }, { - KeyResolution, + ResolutionInfo.identifier, new IntVerifier, - "The number of samples along the orbit. This determines the resolution " - "of the trail; the tradeoff being that a higher resolution is able to " - "resolve more detail, but will take more resources while rendering, too. " - "The higher, the smoother the trail, but also more memory will be used.", + ResolutionInfo.description, Optional::No } } @@ -134,8 +138,8 @@ documentation::Documentation RenderableTrailOrbit::Documentation() { RenderableTrailOrbit::RenderableTrailOrbit(const ghoul::Dictionary& dictionary) : RenderableTrail(dictionary) - , _period({ "Period", "Period in days", "" }, 0.0, 0.0, 1e9) // @TODO Missing documentation - , _resolution({ "Resolution", "Number of Samples along Orbit", "" }, 10000, 1, 1000000) // @TODO Missing documentation + , _period(PeriodInfo, 0.0, 0.0, 1e9) + , _resolution(ResolutionInfo, 1e4, 1, 1e6) , _needsFullSweep(true) , _indexBufferDirty(true) , _previousTime(0) @@ -152,12 +156,12 @@ RenderableTrailOrbit::RenderableTrailOrbit(const ghoul::Dictionary& dictionary) // Period is in days using namespace std::chrono; - long long factor = duration_cast(hours(24)).count(); - _period = dictionary.value(KeyPeriod) * factor; + const long long sph = duration_cast(hours(24)).count(); + _period = dictionary.value(PeriodInfo.identifier) * sph; _period.onChange([&] { _needsFullSweep = true; _indexBufferDirty = true; }); addProperty(_period); - _resolution = static_cast(dictionary.value(KeyResolution)); + _resolution = static_cast(dictionary.value(ResolutionInfo.identifier)); _resolution.onChange([&] { _needsFullSweep = true; _indexBufferDirty = true; }); addProperty(_resolution); diff --git a/modules/base/rendering/renderabletrailtrajectory.cpp b/modules/base/rendering/renderabletrailtrajectory.cpp index 5c18e1ed01..f82af3ab75 100644 --- a/modules/base/rendering/renderabletrailtrajectory.cpp +++ b/modules/base/rendering/renderabletrailtrajectory.cpp @@ -44,11 +44,45 @@ namespace { const char* KeyTranslation = "Translation"; - const char* KeyStartTime = "StartTime"; - const char* KeyEndTime = "EndTime"; - const char* KeySampleInterval = "SampleInterval"; - const char* KeyTimeStampSubsample = "TimeStampSubsampleFactor"; - const char* KeyShowFullTrail = "ShowFullTrail"; + + static const openspace::properties::Property::PropertyInfo StartTimeInfo = { + "StartTime", + "Start Time", + "The start time for the range of this trajectory. The date must be in ISO 8601 " + "format: YYYY MM DD HH:mm:ss.xxx." + }; + + static const openspace::properties::Property::PropertyInfo EndTimeInfo = { + "EndTime", + "End Time", + "The end time for the range of this trajectory. The date must be in ISO 8601 " + "format: YYYY MM DD HH:mm:ss.xxx." + }; + + static const openspace::properties::Property::PropertyInfo SampleIntervalInfo = { + "SampleInterval", + "Sample Interval", + "The interval between samples of the trajectory. This value (together with " + "'TimeStampSubsampleFactor') determines how far apart (in time) the samples are " + "spaced along the trajectory. The time interval between 'StartTime' and " + "'EndTime' is split into 'SampleInterval' * 'TimeStampSubsampleFactor' segments." + }; + + static const openspace::properties::Property::PropertyInfo TimeSubSampleInfo = { + "TimeStampSubsampleFactor", + "Time Stamp Subsampling Factor", + "The factor that is used to create subsamples along the trajectory. This value " + "(together with 'SampleInterval') determines how far apart (in time) the samples " + "are spaced along the trajectory. The time interval between 'StartTime' and " + "'EndTime' is split into 'SampleInterval' * 'TimeStampSubsampleFactor' segments." + }; + + static const openspace::properties::Property::PropertyInfo RenderFullPathInfo = { + "ShowFullTrail", + "Render Full Trail", + "If this value is set to 'true', the entire trail will be rendered; if it is " + "'false', only the trail until the current time in the application will be shown." + }; } // namespace namespace openspace { @@ -61,56 +95,39 @@ documentation::Documentation RenderableTrailTrajectory::Documentation() { "base_renderable_renderabletrailtrajectory", { { - "Type", - new StringEqualVerifier("RenderableTrailTrajectory"), - "", + StartTimeInfo.identifier, + new StringAnnotationVerifier("A valid date in ISO 8601 format"), + StartTimeInfo.description, Optional::No }, { - KeyStartTime, - new StringAnnotationVerifier("A valid date"), - "The start time for the range of this trajectory. The date must be in " - "ISO 8601 format: YYYY MM DD HH:mm:ss.xxx", + EndTimeInfo.identifier, + new StringAnnotationVerifier("A valid date in ISO 8601 format"), + EndTimeInfo.description, Optional::No }, { - KeyEndTime, - new StringAnnotationVerifier("A valid date"), - "The end time for the range of this trajectory. The date must be in " - "ISO 8601 format: YYYY MM DD HH:mm:ss.xxx", - Optional::No - }, - { - KeySampleInterval, + SampleIntervalInfo.identifier, new DoubleVerifier, - "The interval between samples of the trajectory. This value (together " - "with 'TimeStampSubsampleFactor') determines how far apart (in time) the " - "samples are spaced along the trajectory. The time interval between " - "'StartTime' and 'EndTime' is split into 'SampleInterval' * " - "'TimeStampSubsampleFactor' segments.", + SampleIntervalInfo.description, Optional::No }, { - KeyTimeStampSubsample, + TimeSubSampleInfo.identifier, new IntVerifier, - "The factor that is used to create subsamples along the trajectory. This " - "value (together with 'SampleInterval') determines how far apart (in " - "time) the samples are spaced along the trajectory. The time interval " - "between 'StartTime' and 'EndTime' is split into 'SampleInterval' * " - "'TimeStampSubsampleFactor' segments. The default value for this is 1", + TimeSubSampleInfo.description, Optional::Yes }, { - KeyShowFullTrail, + RenderFullPathInfo.identifier, new BoolVerifier, - "If this value is set to 'true', the entire trail will be rendered; if " - "it is 'false', only the trail until the current time in the application " - "will be shown. The default value for this setting is 'false'.", + RenderFullPathInfo.description, Optional::Yes } } }; + // @TODO cleanup // Insert the parents documentation entries until we have a verifier that can deal // with class hierarchy documentation::Documentation parentDoc = RenderableTrail::Documentation(); @@ -125,14 +142,11 @@ documentation::Documentation RenderableTrailTrajectory::Documentation() { RenderableTrailTrajectory::RenderableTrailTrajectory(const ghoul::Dictionary& dictionary) : RenderableTrail(dictionary) - , _startTime({ "StartTime", "Start Time", "" }) // @TODO Missing documentation - , _endTime({ "EndTime", "End Time", "" }) // @TODO Missing documentation - , _sampleInterval({ "SampleInterval", "Sample Interval", "" }, 2.0, 2.0, 1e6) // @TODO Missing documentation - , _timeStampSubsamplingFactor( - { "SubSample", "Time Stamp Subsampling Factor", "" }, // @TODO Missing documentation - 1, 1, 1000000000 - ) - , _renderFullTrail({ "RenderFullTrail", "Render Full Trail", "" }, false) // @TODO Missing documentation + , _startTime(StartTimeInfo) + , _endTime(EndTimeInfo) + , _sampleInterval(SampleIntervalInfo, 2.0, 2.0, 1e6) + , _timeStampSubsamplingFactor(TimeSubSampleInfo, 1, 1, 1e9) + , _renderFullTrail(RenderFullPathInfo, false) , _needsFullSweep(true) , _subsamplingIsDirty(true) { @@ -146,28 +160,28 @@ RenderableTrailTrajectory::RenderableTrailTrajectory(const ghoul::Dictionary& di _needsFullSweep = true; }); - _startTime = dictionary.value(KeyStartTime); + _startTime = dictionary.value(StartTimeInfo.identifier); _startTime.onChange([this] { _needsFullSweep = true; }); addProperty(_startTime); - _endTime = dictionary.value(KeyEndTime); + _endTime = dictionary.value(EndTimeInfo.identifier); _endTime.onChange([this] { _needsFullSweep = true; }); addProperty(_endTime); - _sampleInterval = dictionary.value(KeySampleInterval); + _sampleInterval = dictionary.value(SampleIntervalInfo.identifier); _sampleInterval.onChange([this] { _needsFullSweep = true; }); addProperty(_sampleInterval); - if (dictionary.hasKeyAndValue(KeyTimeStampSubsample)) { + if (dictionary.hasKeyAndValue(TimeSubSampleInfo.identifier)) { _timeStampSubsamplingFactor = static_cast( - dictionary.value(KeyTimeStampSubsample) + dictionary.value(TimeSubSampleInfo.identifier) ); } _timeStampSubsamplingFactor.onChange([this] { _subsamplingIsDirty = true; }); addProperty(_timeStampSubsamplingFactor); - if (dictionary.hasKeyAndValue(KeyShowFullTrail)) { - _renderFullTrail = dictionary.value(KeyShowFullTrail); + if (dictionary.hasKeyAndValue(RenderFullPathInfo.identifier)) { + _renderFullTrail = dictionary.value(RenderFullPathInfo.identifier); } addProperty(_renderFullTrail); diff --git a/modules/base/rendering/screenspaceframebuffer.cpp b/modules/base/rendering/screenspaceframebuffer.cpp index 87417acba9..8bc62a2c51 100644 --- a/modules/base/rendering/screenspaceframebuffer.cpp +++ b/modules/base/rendering/screenspaceframebuffer.cpp @@ -34,6 +34,15 @@ #include #include + +namespace { + static const openspace::properties::Property::PropertyInfo SizeInfo = { + "Size", + "Size", + "This value explicitly specifies the size of the screen space plane." + }; +} // namespace + namespace openspace { documentation::Documentation ScreenSpaceFramebuffer::Documentation() { @@ -48,7 +57,7 @@ documentation::Documentation ScreenSpaceFramebuffer::Documentation() { ScreenSpaceFramebuffer::ScreenSpaceFramebuffer(const ghoul::Dictionary& dictionary) : ScreenSpaceRenderable(dictionary) - , _size({ "Size", "Size", "" }, glm::vec4(0), glm::vec4(0), glm::vec4(2000)) // @TODO Missing documentation + , _size(SizeInfo, glm::vec4(0), glm::vec4(0), glm::vec4(16384)) , _framebuffer(nullptr) { documentation::testSpecificationAndThrow( @@ -63,13 +72,11 @@ ScreenSpaceFramebuffer::ScreenSpaceFramebuffer(const ghoul::Dictionary& dictiona glm::vec2 resolution = OsEng.windowWrapper().currentWindowResolution(); addProperty(_size); _size.set(glm::vec4(0, 0, resolution.x,resolution.y)); - - _scale.setValue(1.0f); } -ScreenSpaceFramebuffer::~ScreenSpaceFramebuffer(){} +ScreenSpaceFramebuffer::~ScreenSpaceFramebuffer() {} -bool ScreenSpaceFramebuffer::initialize(){ +bool ScreenSpaceFramebuffer::initialize() { _originalViewportSize = OsEng.windowWrapper().currentWindowResolution(); createPlane(); @@ -79,7 +86,7 @@ bool ScreenSpaceFramebuffer::initialize(){ return isReady(); } -bool ScreenSpaceFramebuffer::deinitialize(){ +bool ScreenSpaceFramebuffer::deinitialize() { glDeleteVertexArrays(1, &_quad); _quad = 0; @@ -88,7 +95,7 @@ bool ScreenSpaceFramebuffer::deinitialize(){ _texture = nullptr; - RenderEngine& renderEngine = OsEng.renderEngine(); + RenderEngine& renderEngine = OsEng.renderEngine(); if (_shader) { renderEngine.removeRenderProgram(_shader); _shader = nullptr; @@ -120,7 +127,7 @@ void ScreenSpaceFramebuffer::render() { glClearColor (0.0f, 0.0f, 0.0f, 0.0f); glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glEnable(GL_ALPHA_TEST); - for(auto renderFunction : _renderFunctions){ + for (const auto& renderFunction : _renderFunctions) { (*renderFunction)(); } _framebuffer->deactivate(); @@ -142,42 +149,48 @@ void ScreenSpaceFramebuffer::render() { } } +void ScreenSpaceFramebuffer::update() {} -void ScreenSpaceFramebuffer::update(){} - -bool ScreenSpaceFramebuffer::isReady() const{ +bool ScreenSpaceFramebuffer::isReady() const { bool ready = true; - if (!_shader) + if (!_shader) { ready &= false; - if(!_texture) + } + if (!_texture) { ready &= false; + } return ready; } - -void ScreenSpaceFramebuffer::setSize(glm::vec4 size){ +void ScreenSpaceFramebuffer::setSize(glm::vec4 size) { _size.set(size); } -void ScreenSpaceFramebuffer::addRenderFunction(std::shared_ptr> renderFunction){ +void ScreenSpaceFramebuffer::addRenderFunction( + std::shared_ptr> renderFunction) +{ _renderFunctions.push_back(renderFunction); } -void ScreenSpaceFramebuffer::removeAllRenderFunctions(){ +void ScreenSpaceFramebuffer::removeAllRenderFunctions() { _renderFunctions.clear(); } -void ScreenSpaceFramebuffer::createFragmentbuffer(){ +void ScreenSpaceFramebuffer::createFragmentbuffer() { _framebuffer = std::make_unique(); _framebuffer->activate(); - _texture = std::make_unique(glm::uvec3(_originalViewportSize.x, _originalViewportSize.y, 1)); + _texture = std::make_unique(glm::uvec3( + _originalViewportSize.x, + _originalViewportSize.y, + 1 + )); _texture->uploadTexture(); _texture->setFilter(ghoul::opengl::Texture::FilterMode::Linear); _framebuffer->attachTexture(_texture.get(), GL_COLOR_ATTACHMENT0); _framebuffer->deactivate(); } -int ScreenSpaceFramebuffer::id(){ +int ScreenSpaceFramebuffer::id() { static int id = 0; return id++; } diff --git a/modules/base/rendering/screenspaceimage.cpp b/modules/base/rendering/screenspaceimage.cpp index 72d7545f34..8f8932d681 100644 --- a/modules/base/rendering/screenspaceimage.cpp +++ b/modules/base/rendering/screenspaceimage.cpp @@ -39,6 +39,15 @@ namespace { const char* KeyName = "Name"; const char* KeyTexturePath = "TexturePath"; const char* KeyUrl = "URL"; + + static const openspace::properties::Property::PropertyInfo TexturePathInfo = { + "TexturePath", + "Texture path", + "Sets the path of the texture that is displayed on this screen space plane. If " + "this value is changed, the image at the new path will automatically be loaded " + "and displayed. The size of the image will also automatically set the default " + "size of this plane." + }; } // namespace namespace openspace { @@ -70,7 +79,7 @@ ScreenSpaceImage::ScreenSpaceImage(const ghoul::Dictionary& dictionary) : ScreenSpaceRenderable(dictionary) , _downloadImage(false) , _textureIsDirty(false) - , _texturePath({ "TexturePath", "Texture path", "" }) // @TODO Missing documentation + , _texturePath(TexturePathInfo) { documentation::testSpecificationAndThrow( Documentation(), diff --git a/modules/base/rotation/staticrotation.cpp b/modules/base/rotation/staticrotation.cpp index 340a29087f..8f88d81389 100644 --- a/modules/base/rotation/staticrotation.cpp +++ b/modules/base/rotation/staticrotation.cpp @@ -28,7 +28,12 @@ #include namespace { - const char* KeyRotation = "Rotation"; + static const openspace::properties::Property::PropertyInfo RotationInfo = { + "Rotation", + "Rotation", + "This value is the used as a 3x3 rotation matrix that is applied to the scene " + "graph node that this transformation is attached to relative to its parent." + }; } // namespace namespace openspace { @@ -46,7 +51,7 @@ documentation::Documentation StaticRotation::Documentation() { Optional::No }, { - KeyRotation, + RotationInfo.identifier, new OrVerifier( new DoubleVector3Verifier(), new DoubleMatrix3Verifier() @@ -61,8 +66,11 @@ documentation::Documentation StaticRotation::Documentation() { } StaticRotation::StaticRotation() - : _rotationMatrix({ "Rotation", "Rotation", "" }, glm::dmat3(1.0)) // @TODO Missing documentation -{} + : _rotationMatrix(RotationInfo, glm::dmat3(1.0)) +{ + addProperty(_rotationMatrix); + _rotationMatrix.onChange([this]() { _matrix = _rotationMatrix; }); +} StaticRotation::StaticRotation(const ghoul::Dictionary& dictionary) : StaticRotation() @@ -74,18 +82,16 @@ StaticRotation::StaticRotation(const ghoul::Dictionary& dictionary) ); - if (dictionary.hasKeyAndValue(KeyRotation)) { + if (dictionary.hasKeyAndValue(RotationInfo.identifier)) { _rotationMatrix = glm::mat3_cast( - glm::dquat(dictionary.value(KeyRotation)) + glm::dquat(dictionary.value(RotationInfo.identifier)) ); } else { // Must be glm::dmat3 due to specification restriction - _rotationMatrix = dictionary.value(KeyRotation); + _rotationMatrix = dictionary.value(RotationInfo.identifier); } - addProperty(_rotationMatrix); - _rotationMatrix.onChange([this]() { _matrix = _rotationMatrix; }); } } // namespace openspace diff --git a/modules/base/scale/staticscale.cpp b/modules/base/scale/staticscale.cpp index 75366fa88d..69db7ea3f8 100644 --- a/modules/base/scale/staticscale.cpp +++ b/modules/base/scale/staticscale.cpp @@ -28,7 +28,12 @@ #include namespace { - const char* KeyValue = "Scale"; + static const openspace::properties::Property::PropertyInfo ScaleInfo = { + "Scale", + "Scale", + "This value is used as a scaling factor for the scene graph node that this " + "transformation is attached to relative to its parent." + }; } // namespace namespace openspace { @@ -40,27 +45,27 @@ documentation::Documentation StaticScale::Documentation() { "base_scale_static", { { - KeyValue, + ScaleInfo.identifier, new DoubleVerifier, - "The scaling factor by which the scenegraph node is scaled." + ScaleInfo.description, + Optional::No } } }; } StaticScale::StaticScale() - : _scaleValue({ "Scale", "Scale", "" }, 1.0, 1.0, 1000.0) // @TODO Missing documentation + : _scaleValue(ScaleInfo, 1.0, 1.0, 1e6) { addProperty(_scaleValue); } - StaticScale::StaticScale(const ghoul::Dictionary& dictionary) : StaticScale() { documentation::testSpecificationAndThrow(Documentation(), dictionary, "StaticScale"); - _scaleValue = static_cast(dictionary.value(KeyValue)); + _scaleValue = static_cast(dictionary.value(ScaleInfo.identifier)); } double StaticScale::scaleValue() const { diff --git a/modules/base/translation/statictranslation.cpp b/modules/base/translation/statictranslation.cpp index 22c0f366d0..72a5de4df4 100644 --- a/modules/base/translation/statictranslation.cpp +++ b/modules/base/translation/statictranslation.cpp @@ -28,7 +28,12 @@ #include namespace { - const char* KeyPosition = "Position"; + static const openspace::properties::Property::PropertyInfo PositionInfo = { + "Position", + "Position", + "This value is used as a static offset (in meters) that is applied to the scene " + "graph node that this transformation is attached to relative to its parent." + }; } // namespace namespace openspace { @@ -40,16 +45,9 @@ documentation::Documentation StaticTranslation::Documentation() { "base_transform_translation_static", { { - "Type", - new StringEqualVerifier("StaticTranslation"), - "", - Optional::No - }, - { - KeyPosition, + PositionInfo.identifier, new DoubleVector3Verifier, - "Specifies the position (in meters) that this scenegraph node is located " - "at relative to its parent", + PositionInfo.description, Optional::No } }, @@ -60,7 +58,7 @@ documentation::Documentation StaticTranslation::Documentation() { StaticTranslation::StaticTranslation() : _position( - { "Position", "Position", "" }, // @TODO Missing documentation + PositionInfo, glm::dvec3(0.0), glm::dvec3(-std::numeric_limits::max()), glm::dvec3(std::numeric_limits::max()) @@ -78,7 +76,7 @@ StaticTranslation::StaticTranslation(const ghoul::Dictionary& dictionary) "StaticEphemeris" ); - _position = dictionary.value(KeyPosition); + _position = dictionary.value(PositionInfo.identifier); } glm::dvec3 StaticTranslation::position() const { diff --git a/modules/debugging/rendering/renderabledebugplane.cpp b/modules/debugging/rendering/renderabledebugplane.cpp index 161fd2675c..3442f909d7 100644 --- a/modules/debugging/rendering/renderabledebugplane.cpp +++ b/modules/debugging/rendering/renderabledebugplane.cpp @@ -39,62 +39,138 @@ #include #include +#include +#include + namespace { - const char* _loggerCat = "RenderablePlaneTexture"; + enum Origin { + LowerLeft = 0, + LowerRight, + UpperLeft, + UpperRight, + Center + }; + + static const openspace::properties::Property::PropertyInfo TextureInfo = { + "Texture", + "Texture", + "The OpenGL name of the texture that is displayed on this plane." + }; + + static const openspace::properties::Property::PropertyInfo BillboardInfo = { + "Billboard", + "Billboard mode", + "This value specifies whether the plane is a billboard, which means that it is " + "always facing the camera. If this is false, it can be oriented using other " + "transformations." + }; + + static const openspace::properties::Property::PropertyInfo SizeInfo = { + "Size", + "Size (in meters)", + "This value specifies the size of the plane in meters." + }; + + static const openspace::properties::Property::PropertyInfo OriginInfo = { + "Origin", + "Texture Coordinate Origin", + "The origin of the texture coorinate system." + }; } // namespace namespace openspace { +documentation::Documentation RenderableDebugPlane::Documentation() { + using namespace documentation; + return { + "RenderableDebugPlane", + "debugging_renderable_debugplane", + { + { + TextureInfo.identifier, + new IntVerifier, + TextureInfo.description, + Optional::Yes + }, + { + BillboardInfo.identifier, + new BoolVerifier, + BillboardInfo.description, + Optional::Yes + }, + { + SizeInfo.identifier, + new DoubleVerifier, + SizeInfo.description, + Optional::Yes + }, + { + OriginInfo.identifier, + new StringInListVerifier( + { "LowerLeft", "LowerRight", "UpperLeft", "UpperRight", "Center" } + ), + OriginInfo.description, + Optional::Yes + } + }, + Exhaustive::Yes + }; +} + + RenderableDebugPlane::RenderableDebugPlane(const ghoul::Dictionary& dictionary) : Renderable(dictionary) - , _texture({ "Texture", "Texture", "" }, -1, -1, 255) // @TODO Missing documentation - , _billboard({ "Billboard", "Billboard", "" }, false) // @TODO Missing documentation - , _size({ "Size", "Size", "" }, 10.f, 0.f, std::pow(10.f, 25.f)) // @TODO Missing documentation - , _origin(Origin::Center) + , _texture(TextureInfo, -1, -1, 512) + , _billboard(BillboardInfo, false) + , _size(SizeInfo, 10.f, 0.f, 1e25f) + , _origin(OriginInfo, properties::OptionProperty::DisplayType::Dropdown) , _shader(nullptr) , _quad(0) , _vertexPositionBuffer(0) { - dictionary.getValue("Size", _size); - - if (dictionary.hasKey("Name")){ - dictionary.getValue("Name", _nodeName); + if (dictionary.hasKey(TextureInfo.identifier)) { + _texture = static_cast(dictionary.value(TextureInfo.identifier)); } - if (dictionary.hasKey("Texture")) { - int t; - dictionary.getValue("Texture", t); - _texture = t; + if (dictionary.hasKey(SizeInfo.identifier)) { + _size = static_cast(dictionary.value(SizeInfo.identifier)); } - std::string origin; - if (dictionary.getValue("Origin", origin)) { + if (dictionary.hasKey(BillboardInfo.identifier)) { + _billboard = dictionary.value(BillboardInfo.identifier); + } + + _origin.addOptions({ + { LowerLeft, "LowerLeft" }, + { LowerRight, "LowerRight" }, + { UpperLeft, "UpperLeft" }, + { UpperRight, "UpperRight" }, + { Center, "Center" } + }); + _origin.setValue(Center); + + if (dictionary.hasKey(OriginInfo.identifier)) { + const std::string origin = dictionary.value(OriginInfo.identifier); if (origin == "LowerLeft") { - _origin = Origin::LowerLeft; + _origin = LowerLeft; } else if (origin == "LowerRight") { - _origin = Origin::LowerRight; + _origin = LowerRight; } else if (origin == "UpperLeft") { - _origin = Origin::UpperLeft; + _origin = UpperLeft; } else if (origin == "UpperRight") { - _origin = Origin::UpperRight; + _origin = UpperRight; } else if (origin == "Center") { - _origin = Origin::Center; + _origin = Center; } } - - // Attempt to get the billboard value - bool billboard = false; - if (dictionary.getValue("Billboard", billboard)) { - _billboard = billboard; + else { + _origin = Center; } - int texture; - if (dictionary.getValue("Texture", texture)) - _texture = texture; addProperty(_texture); addProperty(_billboard); @@ -105,13 +181,13 @@ RenderableDebugPlane::RenderableDebugPlane(const ghoul::Dictionary& dictionary) setBoundingSphere(_size); } -RenderableDebugPlane::~RenderableDebugPlane() { -} +RenderableDebugPlane::~RenderableDebugPlane() {} bool RenderableDebugPlane::isReady() const { bool ready = true; - if (!_shader) + if (!_shader) { ready &= false; + } return ready; } @@ -120,19 +196,14 @@ bool RenderableDebugPlane::initialize() { glGenBuffers(1, &_vertexPositionBuffer); // generate buffer createPlane(); - if (_shader == nullptr) { - // Plane Program - + if (!_shader) { RenderEngine& renderEngine = OsEng.renderEngine(); _shader = renderEngine.buildRenderProgram("PlaneProgram", "${MODULE_BASE}/shaders/plane_vs.glsl", "${MODULE_BASE}/shaders/plane_fs.glsl" ); - if (!_shader) - return false; } - return isReady(); } @@ -154,8 +225,9 @@ bool RenderableDebugPlane::deinitialize() { void RenderableDebugPlane::render(const RenderData& data, RendererTasks&) { glm::mat4 transform = glm::mat4(1.0); - if (_billboard) + if (_billboard) { transform = glm::inverse(glm::mat4(data.camera.viewRotationMatrix())); + } // Activate shader _shader->activate(); @@ -176,11 +248,13 @@ void RenderableDebugPlane::render(const RenderData& data, RendererTasks&) { } void RenderableDebugPlane::update(const UpdateData&) { - if (_shader->isDirty()) + if (_shader->isDirty()) { _shader->rebuildFromFile(); + } - if (_planeIsDirty) + if (_planeIsDirty) { createPlane(); + } } void RenderableDebugPlane::createPlane() { diff --git a/modules/debugging/rendering/renderabledebugplane.h b/modules/debugging/rendering/renderabledebugplane.h index aa3dbd8fed..6ea0db8819 100644 --- a/modules/debugging/rendering/renderabledebugplane.h +++ b/modules/debugging/rendering/renderabledebugplane.h @@ -27,6 +27,7 @@ #include +#include #include #include #include @@ -37,6 +38,8 @@ namespace ghoul::opengl { class Texture; } // namespace ghoul::opengl +namespace documentation { struct Documentation; } + namespace openspace { struct LinePoint; @@ -54,19 +57,15 @@ public: void render(const RenderData& data, RendererTasks& rendererTask) override; void update(const UpdateData& data) override; -private: - enum class Origin { - LowerLeft, LowerRight, UpperLeft, UpperRight, Center - }; + static documentation::Documentation Documentation(); +private: void createPlane(); properties::IntProperty _texture; properties::BoolProperty _billboard; properties::FloatProperty _size; - - Origin _origin; - std::string _nodeName; + properties::OptionProperty _origin; bool _planeIsDirty; diff --git a/src/rendering/renderengine.cpp b/src/rendering/renderengine.cpp index 12643c9281..15e772a277 100644 --- a/src/rendering/renderengine.cpp +++ b/src/rendering/renderengine.cpp @@ -90,6 +90,98 @@ namespace { const char* KeyFontMono = "Mono"; const char* KeyFontLight = "Light"; + + static const openspace::properties::Property::PropertyInfo PerformanceInfo = { + "PerformanceMeasurements", + "Performance Measurements", + "If this value is enabled, detailed performance measurements about the updates " + "and rendering of the scene graph nodes are collected each frame. These values " + "provide some information about the impact of individual nodes on the overall " + "performance." + }; + + static const openspace::properties::Property::PropertyInfo FrametimeInfo = { + "FrametimeType", + "Type of the frame time display", + "This value determines the units in which the frame time is displayed." + }; + + static const openspace::properties::Property::PropertyInfo ShowDateInfo = { + "ShowDate", + "Show Date Information", + "This values determines whether the date will be printed in the top left corner " + "of the rendering window if a regular rendering window is used (as opposed to a " + "fisheye rendering, for example)." + }; + + static const openspace::properties::Property::PropertyInfo ShowInfoInfo = { + "ShowInfo", + "Show Rendering Information", + "This value determines whether the rendering info, which is the delta time and " + "the frame time, is shown in the top left corner of the rendering window if a " + "regular rendering window is used (as opposed to a fisheye rendering, for " + "example)." + }; + + static const openspace::properties::Property::PropertyInfo ShowLogInfo = { + "ShowLog", + "Show the on-screen log", + "This value determines whether the on-screen log will be shown or hidden. Even " + "if it is shown, all 'Debug' and 'Trace' level messages are omitted from this " + "log." + }; + + static const openspace::properties::Property::PropertyInfo TakeScreenshotInfo = { + "TakeScreenshot", + "Take Screenshot", + "If this property is triggered, a screenshot is taken and stored in the current " + "working directory (which is the same directory where the OpenSpace.exe) is " + "located in most cases. The images are prefixed with 'SGCT' and postfixed with " + "the number of frames. This function will silently overwrite images that are " + "already present in the folder." + }; + + static const openspace::properties::Property::PropertyInfo ApplyWarpingInfo = { + "ApplyWarpingScreenshot", + "Apply Warping to Screenshots", + "This value determines whether a warping should be applied before taking a " + "screenshot. If it is enabled, all post processing is applied as well, which " + "includes everything rendered on top of the rendering, such as the user " + "interface." + }; + + static const openspace::properties::Property::PropertyInfo ShowFrameNumberInfo = { + "ShowFrameNumber", + "Show Frame Number", + "If this value is enabled, the current frame number is rendered into the window." + }; + + static const openspace::properties::Property::PropertyInfo DisableMasterInfo = { + "DisableMasterRendering", + "Disable Master Rendering", + "If this value is enabled, the rendering on the master node will be disabled. " + "Every other aspect of the application will be unaffected by this and it will " + "still respond to user input. This setting is reasonably only useful in the case " + "of multi-pipeline environments, such as planetariums, where the output of the " + "master node is not required and performance can be gained by disabling it." + }; + + static const openspace::properties::Property::PropertyInfo DisableTranslationInfo = { + "DisableSceneTranslationOnMaster", + "Disable Scene Translation on Master", + "If this value is enabled, any scene translations such as specified in, for " + "example an SGCT configuration, is disabled for the master node. This setting " + "can be useful if a planetarium environment requires a scene translation to be " + "applied, which would otherwise make interacting through the master node " + "difficult." + }; + + static const openspace::properties::Property::PropertyInfo AaSamplesInfo = { + "AaSamples", + "Number of Anti-aliasing samples", + "This value determines the number of anti-aliasing samples to be used in the " + "rendering for the MSAA method." + }; } // namespace @@ -100,32 +192,26 @@ RenderEngine::RenderEngine() , _camera(nullptr) , _scene(nullptr) , _raycasterManager(nullptr) - , _performanceMeasurements({ "PerformanceMeasurements", "Performance Measurements", "" }) // @TODO Missing documentation + , _performanceMeasurements(PerformanceInfo) , _performanceManager(nullptr) , _renderer(nullptr) , _rendererImplementation(RendererImplementation::Invalid) , _log(nullptr) - , _frametimeType( - { "FrametimeType", "Type of the frametime display", "" }, // @TODO Missing documentation - properties::OptionProperty::DisplayType::Dropdown - ) - , _showDate({ "ShowDate", "Show Date Information", "" }, true) // @TODO Missing documentation - , _showInfo({ "ShowInfo", "Show Render Information", "" }, true) // @TODO Missing documentation - , _showLog({ "ShowLog", "Show the OnScreen log", "" }, true) // @TODO Missing documentation - , _takeScreenshot({ "TakeScreenshot", "Take Screenshot", "" }) // @TODO Missing documentation + , _frametimeType(FrametimeInfo, properties::OptionProperty::DisplayType::Dropdown) + , _showDate(ShowDateInfo, true) + , _showInfo(ShowInfoInfo, true) + , _showLog(ShowLogInfo, true) + , _takeScreenshot(TakeScreenshotInfo) , _shouldTakeScreenshot(false) - , _applyWarping({ "ApplyWarpingScreenshot", "Apply Warping to Screenshots", "" }, false) // @TODO Missing documentation - , _showFrameNumber({ "ShowFrameNumber", "Show Frame Number", "" }, false) // @TODO Missing documentation - , _disableMasterRendering({ "DisableMasterRendering", "Disable Master Rendering", "" }, false) // @TODO Missing documentation - , _disableSceneTranslationOnMaster( - { "DisableSceneTranslationOnMaster", "Disable Scene Translation on Master", "" }, // @TODO Missing documentation - false - ) + , _applyWarping(ApplyWarpingInfo, false) + , _showFrameNumber(ShowFrameNumberInfo, false) + , _disableMasterRendering(DisableMasterInfo, false) + , _disableSceneTranslationOnMaster(DisableTranslationInfo, false) , _globalBlackOutFactor(1.f) , _fadeDuration(2.f) , _currentFadeTime(0.f) , _fadeDirection(0) - , _nAaSamples({ "NAaSamples", "Number of Antialiasing samples", "" }, 8, 1, 16) // @TODO Missing documentation + , _nAaSamples(AaSamplesInfo, 8, 1, 16) , _frameNumber(0) { _performanceMeasurements.onChange([this](){ diff --git a/src/rendering/screenspacerenderable.cpp b/src/rendering/screenspacerenderable.cpp index fccf1bae30..a9af742723 100644 --- a/src/rendering/screenspacerenderable.cpp +++ b/src/rendering/screenspacerenderable.cpp @@ -33,11 +33,6 @@ #include #include -#ifdef WIN32 -#define _USE_MATH_DEFINES -#include -#endif - namespace { const char* _loggerCat = "ScreenSpaceRenderable"; @@ -49,6 +44,69 @@ namespace { const char* KeyAlpha = "Alpha"; const char* KeyTag = "Tag"; const float PlaneDepth = -2.f; + + static const openspace::properties::Property::PropertyInfo EnabledInfo = { + "Enabled", + "Is Enabled", + "This setting determines whether this sceen space plane will be visible or not." + }; + + static const openspace::properties::Property::PropertyInfo FlatScreenInfo = { + "FlatScreen", + "Flat Screen specification", + "This value determines whether the location of this screen space plane will be " + "specified in a two-dimensional Euclidean plane (if this is set to 'true') or " + "specified in spherical coordinates. By switching this value, the correct " + "property will be shown or hidden. The Euclidean coordinate system is useful if " + "a regular rendering is applied, whereas the spherical coordinates are most " + "useful in a planetarium environment." + }; + + static const openspace::properties::Property::PropertyInfo EuclideanPositionInfo = { + "EuclideanPosition", + "Euclidean coordinates", + "This value determines the position of this screen space plane in Euclidean " + "two-dimensional coordinates." + }; + + static const openspace::properties::Property::PropertyInfo SphericalPositionInfo = { + "SphericalPosition", + "Spherical coordinates", + "This value determines the position of this screen space plane in a spherical " + "coordinate system." + }; + + static const openspace::properties::Property::PropertyInfo DepthInfo = { + "Depth", + "Depth value", + "This value determines the depth of the plane. This value does not change the " + "apparent size of the plane, but is only used to sort the planes correctly. The " + "plane with a lower value will be shown in front of a plane with a higher depth " + "value." + }; + + static const openspace::properties::Property::PropertyInfo ScaleInfo = { + "Scale", + "Scale value", + "This value determines a scale factor for the plane. The default size of a plane " + "is determined by the concrete instance and reflects, for example, the size of " + "the image being displayed." + }; + + static const openspace::properties::Property::PropertyInfo AlphaInfo = { + "Alpha", + "Transparency", + "This value determines the transparency of the screen space plane. If this value " + "is 1, the plane is completely opaque, if this value is 0, the plane is " + "completely transparent." + }; + + static const openspace::properties::Property::PropertyInfo DeleteInfo = { + "Delete", + "Delete", + "If this property is triggered, this screen space plane is removed from the " + "scene." + }; } // namespace namespace openspace { @@ -98,24 +156,24 @@ std::unique_ptr ScreenSpaceRenderable::createFromDictiona ScreenSpaceRenderable::ScreenSpaceRenderable(const ghoul::Dictionary& dictionary) : properties::PropertyOwner("") - , _enabled({ "Enabled", "Is Enabled", "" }, true) // @TODO Missing documentation - , _useFlatScreen({ "FlatScreen", "Flat Screen", "" }, true) // @TODO Missing documentation + , _enabled(EnabledInfo, true) + , _useFlatScreen(FlatScreenInfo, true) , _euclideanPosition( - { "EuclideanPosition", "Euclidean coordinates", "" }, // @TODO Missing documentation + EuclideanPositionInfo, glm::vec2(0.f), glm::vec2(-4.f), glm::vec2(4.f) ) , _sphericalPosition( - { "SphericalPosition", "Spherical coordinates", "" }, // @TODO Missing documentation - glm::vec2(0.f, static_cast(M_PI_2)), - glm::vec2(-static_cast(M_PI)), - glm::vec2(static_cast(M_PI)) + SphericalPositionInfo, + glm::vec2(0.f, glm::half_pi()), + glm::vec2(-glm::pi()), + glm::vec2(glm::pi()) ) - , _depth({ "Depth", "Depth", "" }, 0.f, 0.f, 1.f) // @TODO Missing documentation - , _scale({ "Scale", "Scale", "" }, 0.25f, 0.f, 2.f) // @TODO Missing documentation - , _alpha({ "Alpha", "Alpha", "" }, 1.f, 0.f, 1.f) // @TODO Missing documentation - , _delete({ "Delete", "Delete", "" }) // @TODO Missing documentation + , _depth(DepthInfo, 0.f, 0.f, 1.f) + , _scale(ScaleInfo, 0.25f, 0.f, 2.f) + , _alpha(AlphaInfo, 1.f, 0.f, 1.f) + , _delete(DeleteInfo) , _quad(0) , _vertexPositionBuffer(0) , _texture(nullptr) @@ -258,8 +316,8 @@ glm::vec2 ScreenSpaceRenderable::toEuclidean(const glm::vec2& spherical, float r } glm::vec2 ScreenSpaceRenderable::toSpherical(const glm::vec2& euclidean) { - _radius = -sqrt(pow(euclidean[0],2)+pow(euclidean[1],2)+pow(PlaneDepth,2)); - float theta = atan2(-PlaneDepth, euclidean[0]) - static_cast(M_PI_2); + _radius = -sqrt(pow(euclidean[0],2) + pow(euclidean[1],2) + pow(PlaneDepth,2)); + float theta = atan2(-PlaneDepth, euclidean[0]) - glm::half_pi(); float phi = acos(euclidean[1]/_radius); return glm::vec2(theta, phi); @@ -315,7 +373,7 @@ glm::mat4 ScreenSpaceRenderable::rotationMatrix() { rotation = glm::rotate(rotation, position.x, glm::vec3(0.f, 1.f, 0.f)); rotation = glm::rotate( rotation, - static_cast(position.y - M_PI_2), + position.y - glm::half_pi(), glm::vec3(1.f, 0.f, 0.f) ); }