mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-02-22 12:59:07 -06:00
Fading of propertyowners through GUI, and more owners with fade property (#2557)
* Add property in OpenSpaceEngine for fading duration when enabling / disabling * Add interface for fadeable components and apply to renderable * Make layers a fadeable component * Make globelabels a fadeable component * Make labelscomponent a fadeable, and give it an enabled property * Make screenspace renderables fadeable components * Introduce concept of parent fadeables, to fade out subowners with parent * Make rings fadeable as well --------- Co-authored-by: Alexander Bock <alexander.bock@liu.se>
This commit is contained in:
@@ -11,6 +11,7 @@ local object = {
|
||||
Type = "RenderableBillboardsCloud",
|
||||
Enabled = false,
|
||||
Labels = {
|
||||
Enabled = true,
|
||||
File = speck .. "stars-altlbl.label",
|
||||
Color = { 0.4, 0.4, 0.4 },
|
||||
Size = 14.7,
|
||||
@@ -19,8 +20,7 @@ local object = {
|
||||
},
|
||||
Color = { 1.0, 1.0, 1.0 },
|
||||
Opacity = 0.65,
|
||||
Unit = "pc",
|
||||
DrawLabels = true
|
||||
Unit = "pc"
|
||||
},
|
||||
GUI = {
|
||||
Name = "Stars Labels - Alternate",
|
||||
|
||||
@@ -11,6 +11,7 @@ local object = {
|
||||
Type = "RenderableBillboardsCloud",
|
||||
Enabled = false,
|
||||
Labels = {
|
||||
Enabled = true,
|
||||
File = speck .. "galclust.label",
|
||||
Color = { 1.0, 0.44, 0.0 },
|
||||
Size = 22,
|
||||
@@ -20,13 +21,12 @@ local object = {
|
||||
Color = { 1.0, 1.0, 1.0 },
|
||||
Opacity = 0.65,
|
||||
Unit = "Mpc",
|
||||
DrawLabels = true,
|
||||
TransformationMatrix = {
|
||||
-0.7357425748, 0.67726129641, 0.0, 0.0,
|
||||
-0.074553778365, -0.080991471307, 0.9939225904, 0.0,
|
||||
0.67314530211, 0.73127116582, 0.11008126223, 0.0,
|
||||
0.0, 0.0, 0.0, 1.0
|
||||
},
|
||||
}
|
||||
},
|
||||
GUI = {
|
||||
Name = "Galaxy Cluster Labels",
|
||||
|
||||
@@ -126,6 +126,7 @@ local eclipticLabels = {
|
||||
Type = "RenderableBillboardsCloud",
|
||||
Enabled = false,
|
||||
Labels = {
|
||||
Enabled = true,
|
||||
File = speck .. "eclip.label",
|
||||
Color = { 0.5, 0.5, 0.5 },
|
||||
Size = 14.75,
|
||||
@@ -136,7 +137,6 @@ local eclipticLabels = {
|
||||
Color = { 1.0, 1.0, 1.0 },
|
||||
Opacity = 0.65,
|
||||
Unit = "pc",
|
||||
DrawLabels = true,
|
||||
TransformationMatrix = eclipticTransformationMatrix
|
||||
},
|
||||
GUI = {
|
||||
@@ -178,6 +178,7 @@ local equatorialLabels = {
|
||||
Type = "RenderableBillboardsCloud",
|
||||
Enabled = false,
|
||||
Labels = {
|
||||
Enabled = true,
|
||||
File = speck .. "radec.label",
|
||||
Color = { 0.5, 0.5, 0.5 },
|
||||
Size = 14.5,
|
||||
@@ -188,7 +189,6 @@ local equatorialLabels = {
|
||||
Color = { 1.0, 1.0, 1.0 },
|
||||
Opacity = 0.65,
|
||||
Unit = "pc",
|
||||
DrawLabels = true,
|
||||
TransformationMatrix = equatorialTransformationMatrix
|
||||
},
|
||||
GUI = {
|
||||
@@ -226,6 +226,7 @@ local galacticLabels = {
|
||||
Type = "RenderableBillboardsCloud",
|
||||
Enabled = false,
|
||||
Labels = {
|
||||
Enabled = true,
|
||||
File = speck .. "galac.label",
|
||||
Color = { 0.5, 0.5, 0.5 },
|
||||
Size = 15.8,
|
||||
@@ -234,8 +235,7 @@ local galacticLabels = {
|
||||
},
|
||||
Color = { 1.0, 1.0, 1.0 },
|
||||
Opacity = 0.65,
|
||||
Unit = "pc",
|
||||
DrawLabels = true
|
||||
Unit = "pc"
|
||||
},
|
||||
GUI = {
|
||||
Name = "Galactic Sphere Labels",
|
||||
|
||||
@@ -11,6 +11,7 @@ local object = {
|
||||
Type = "RenderableBillboardsCloud",
|
||||
Enabled = false,
|
||||
Labels = {
|
||||
Enabled = true,
|
||||
File = speck .. "groups.label",
|
||||
Color = { 0.1, 0.6, 0.2 },
|
||||
Size = 21.5,
|
||||
@@ -21,7 +22,6 @@ local object = {
|
||||
Opacity = 0.65,
|
||||
--ScaleFactor = 10.0,
|
||||
Unit = "Mpc",
|
||||
DrawLabels = true,
|
||||
TransformationMatrix = {
|
||||
-0.7357425748, 0.67726129641, 0.0, 0.0,
|
||||
-0.074553778365, -0.080991471307, 0.9939225904, 0.0,
|
||||
|
||||
@@ -11,6 +11,7 @@ local homeLabel = {
|
||||
Type = "RenderableBillboardsCloud",
|
||||
Enabled = false,
|
||||
Labels = {
|
||||
Enabled = true,
|
||||
File = homespeck .. "home.label",
|
||||
Color = { 0.8, 0.8, 0.8 },
|
||||
Size = 20.50,
|
||||
@@ -20,7 +21,6 @@ local homeLabel = {
|
||||
Color = { 1.0, 0.4, 0.2 },
|
||||
Opacity = 0.99,
|
||||
ScaleFactor = 500.0,
|
||||
DrawLabels = true,
|
||||
Unit = "Mpc",
|
||||
TransformationMatrix = {
|
||||
-0.7357425748, 0.67726129641, 0.0, 0.0,
|
||||
|
||||
@@ -11,6 +11,7 @@ local object = {
|
||||
Type = "RenderableBillboardsCloud",
|
||||
Enabled = false,
|
||||
Labels = {
|
||||
Enabled = true,
|
||||
File = speck .. "stars.label",
|
||||
Color = { 0.4, 0.4, 0.4 },
|
||||
Size = 14.7,
|
||||
@@ -19,8 +20,7 @@ local object = {
|
||||
},
|
||||
Color = { 1.0, 1.0, 1.0 },
|
||||
Opacity = 0.65,
|
||||
Unit = "pc",
|
||||
DrawLabels = true
|
||||
Unit = "pc"
|
||||
},
|
||||
GUI = {
|
||||
Name = "Stars Labels",
|
||||
|
||||
@@ -18,6 +18,7 @@ local object = {
|
||||
Type = "RenderableBillboardsCloud",
|
||||
Enabled = false,
|
||||
Labels = {
|
||||
Enabled = true,
|
||||
File = speck .. "superclust.label",
|
||||
Color = { 0.9, 0.9, 0.9 },
|
||||
Size = 22.44,
|
||||
@@ -31,7 +32,6 @@ local object = {
|
||||
Texture = textures .. "point3A.png",
|
||||
Unit = "Mpc",
|
||||
ScaleFactor = 531.0,
|
||||
DrawLabels = true,
|
||||
-- BillboardMinMaxSize = { 0.0, 7.2 },
|
||||
EnablePixelSizeControl = true
|
||||
},
|
||||
|
||||
@@ -34,7 +34,6 @@ local tullyPoints = {
|
||||
--ColorOption = { "proximity" },
|
||||
ColorOption = { "prox5Mpc" },
|
||||
ColorRange = { { 1.0, 30.0 } },
|
||||
DrawLabels = false,
|
||||
Unit = "Mpc",
|
||||
TransformationMatrix = {
|
||||
-0.7357425748, 0.67726129641, 0.0, 0.0,
|
||||
|
||||
@@ -11,6 +11,7 @@ local object = {
|
||||
Type = "RenderableBillboardsCloud",
|
||||
Enabled = false,
|
||||
Labels = {
|
||||
Enabled = true,
|
||||
File = speck .. "voids.label",
|
||||
Color = { 0.296, 0.629, 1.0 },
|
||||
Size = 20.9,
|
||||
@@ -18,7 +19,6 @@ local object = {
|
||||
Unit = "Mpc"
|
||||
},
|
||||
DrawElements = false,
|
||||
DrawLabels = true,
|
||||
Color = { 1.0, 1.0, 1.0 },
|
||||
Opacity = 0.65,
|
||||
Unit = "Mpc"
|
||||
|
||||
@@ -29,8 +29,9 @@
|
||||
#include <openspace/properties/optionproperty.h>
|
||||
#include <openspace/properties/propertyowner.h>
|
||||
#include <openspace/properties/property.h>
|
||||
#include <openspace/properties/stringproperty.h>
|
||||
#include <openspace/properties/scalar/boolproperty.h>
|
||||
#include <openspace/properties/scalar/floatproperty.h>
|
||||
#include <openspace/properties/stringproperty.h>
|
||||
#include <openspace/scene/profile.h>
|
||||
#include <openspace/util/keys.h>
|
||||
#include <openspace/util/mouse.h>
|
||||
@@ -145,6 +146,7 @@ private:
|
||||
properties::BoolProperty _printEvents;
|
||||
properties::OptionProperty _visibility;
|
||||
properties::BoolProperty _showHiddenSceneGraphNodes;
|
||||
properties::FloatProperty _fadeOnEnableDuration;
|
||||
properties::BoolProperty _disableAllMouseInputs;
|
||||
|
||||
std::unique_ptr<Scene> _scene;
|
||||
|
||||
62
include/openspace/rendering/fadeable.h
Normal file
62
include/openspace/rendering/fadeable.h
Normal file
@@ -0,0 +1,62 @@
|
||||
/*****************************************************************************************
|
||||
* *
|
||||
* OpenSpace *
|
||||
* *
|
||||
* Copyright (c) 2014-2023 *
|
||||
* *
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this *
|
||||
* software and associated documentation files (the "Software"), to deal in the Software *
|
||||
* without restriction, including without limitation the rights to use, copy, modify, *
|
||||
* merge, publish, distribute, sublicense, and/or sell copies of the Software, and to *
|
||||
* permit persons to whom the Software is furnished to do so, subject to the following *
|
||||
* conditions: *
|
||||
* *
|
||||
* The above copyright notice and this permission notice shall be included in all copies *
|
||||
* or substantial portions of the Software. *
|
||||
* *
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, *
|
||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A *
|
||||
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT *
|
||||
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF *
|
||||
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE *
|
||||
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
|
||||
****************************************************************************************/
|
||||
|
||||
#ifndef __OPENSPACE_CORE___FADEABLE___H__
|
||||
#define __OPENSPACE_CORE___FADEABLE___H__
|
||||
|
||||
#include <openspace/properties/scalar/floatproperty.h>
|
||||
|
||||
namespace openspace {
|
||||
|
||||
/**
|
||||
* This class is an interface for all things fadeable in the software; things that need
|
||||
* a fade and opacity property, which will be combined into a final opacity value
|
||||
*
|
||||
* A Fadeable can also be dependent on the fade value from a specified parent fadeable,
|
||||
* so that it fades out together with the parent
|
||||
*/
|
||||
class Fadeable {
|
||||
public:
|
||||
Fadeable();
|
||||
virtual ~Fadeable() = default;
|
||||
|
||||
void setFade(float fade);
|
||||
void setParentFadeable(Fadeable* parent);
|
||||
|
||||
float fade() const;
|
||||
virtual bool isVisible() const;
|
||||
|
||||
/// Returns the full opacity constructed from the _opacity and _fade property values
|
||||
virtual float opacity() const;
|
||||
|
||||
protected:
|
||||
properties::FloatProperty _opacity;
|
||||
properties::FloatProperty _fade;
|
||||
|
||||
Fadeable* _parentFadeable = nullptr;
|
||||
};
|
||||
|
||||
} // namespace openspace
|
||||
|
||||
#endif // __OPENSPACE_CORE___FADEABLE___H__
|
||||
@@ -26,6 +26,7 @@
|
||||
#define __OPENSPACE_CORE___RENDERABLE___H__
|
||||
|
||||
#include <openspace/properties/propertyowner.h>
|
||||
#include <openspace/rendering/fadeable.h>
|
||||
|
||||
#include <openspace/properties/scalar/boolproperty.h>
|
||||
#include <openspace/properties/scalar/doubleproperty.h>
|
||||
@@ -52,7 +53,7 @@ namespace documentation { struct Documentation; }
|
||||
|
||||
class Camera;
|
||||
|
||||
class Renderable : public properties::PropertyOwner {
|
||||
class Renderable : public properties::PropertyOwner, public Fadeable {
|
||||
public:
|
||||
enum class RenderBin : int {
|
||||
Background = 1,
|
||||
@@ -102,9 +103,7 @@ public:
|
||||
|
||||
bool matchesSecondaryRenderBin(int binMask) const noexcept;
|
||||
|
||||
void setFade(float fade);
|
||||
|
||||
bool isVisible() const;
|
||||
bool isVisible() const override;
|
||||
|
||||
void onEnabledChange(std::function<void(bool)> callback);
|
||||
|
||||
@@ -112,8 +111,6 @@ public:
|
||||
|
||||
protected:
|
||||
properties::BoolProperty _enabled;
|
||||
properties::FloatProperty _opacity;
|
||||
properties::FloatProperty _fade;
|
||||
properties::StringProperty _renderableType;
|
||||
properties::BoolProperty _dimInAtmosphere;
|
||||
|
||||
@@ -124,7 +121,7 @@ protected:
|
||||
void registerUpdateRenderBinFromOpacity();
|
||||
|
||||
/// Returns the full opacity constructed from the _opacity and _fade property values
|
||||
float opacity() const;
|
||||
float opacity() const override;
|
||||
|
||||
double _boundingSphere = 0.0;
|
||||
double _interactionSphere = 0.0;
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
#define __OPENSPACE_CORE___SCREENSPACERENDERABLE___H__
|
||||
|
||||
#include <openspace/properties/propertyowner.h>
|
||||
#include <openspace/rendering/fadeable.h>
|
||||
|
||||
#include <openspace/properties/triggerproperty.h>
|
||||
#include <openspace/properties/scalar/boolproperty.h>
|
||||
@@ -49,7 +50,7 @@ namespace documentation { struct Documentation; }
|
||||
* the planes from Spherical to Cartesian coordinates and back. It also specifies the
|
||||
* interface that its children need to implement.
|
||||
*/
|
||||
class ScreenSpaceRenderable : public properties::PropertyOwner {
|
||||
class ScreenSpaceRenderable : public properties::PropertyOwner, public Fadeable {
|
||||
public:
|
||||
static std::unique_ptr<ScreenSpaceRenderable> createFromDictionary(
|
||||
const ghoul::Dictionary& dictionary);
|
||||
@@ -111,7 +112,6 @@ protected:
|
||||
glm::vec3 cartesianToSpherical(const glm::vec3& cartesian) const;
|
||||
glm::vec3 sphericalToCartesian(glm::vec3 spherical) const;
|
||||
glm::vec3 sanitizeSphericalCoordinates(glm::vec3 spherical) const;
|
||||
float opacity() const;
|
||||
|
||||
properties::BoolProperty _enabled;
|
||||
properties::BoolProperty _usePerspectiveProjection;
|
||||
@@ -133,8 +133,6 @@ protected:
|
||||
properties::FloatProperty _gamma;
|
||||
properties::Vec3Property _multiplyColor;
|
||||
properties::Vec4Property _backgroundColor;
|
||||
properties::FloatProperty _opacity;
|
||||
properties::FloatProperty _fade;
|
||||
properties::TriggerProperty _delete;
|
||||
|
||||
glm::ivec2 _objectSize = glm::ivec2(0);
|
||||
|
||||
@@ -54,14 +54,7 @@ namespace {
|
||||
"This value species the size of each dimensions of the box"
|
||||
};
|
||||
|
||||
constexpr openspace::properties::Property::PropertyInfo DrawLabelInfo = {
|
||||
"DrawLabels",
|
||||
"Draw Labels",
|
||||
"Determines whether labels should be drawn or hidden"
|
||||
};
|
||||
|
||||
static const openspace::properties::PropertyOwner::PropertyOwnerInfo LabelsInfo =
|
||||
{
|
||||
static const openspace::properties::PropertyOwner::PropertyOwnerInfo LabelsInfo = {
|
||||
"Labels",
|
||||
"Labels",
|
||||
"The labels for the grid"
|
||||
@@ -77,9 +70,6 @@ namespace {
|
||||
// [[codegen::verbatim(SizeInfo.description)]]
|
||||
std::optional<glm::vec3> size;
|
||||
|
||||
// [[codegen::verbatim(DrawLabelInfo.description)]]
|
||||
std::optional<bool> drawLabels;
|
||||
|
||||
// [[codegen::verbatim(LabelsInfo.description)]]
|
||||
std::optional<ghoul::Dictionary> labels
|
||||
[[codegen::reference("space_labelscomponent")]];
|
||||
@@ -98,7 +88,6 @@ RenderableBoxGrid::RenderableBoxGrid(const ghoul::Dictionary& dictionary)
|
||||
, _color(ColorInfo, glm::vec3(0.5f), glm::vec3(0.f), glm::vec3(1.f))
|
||||
, _lineWidth(LineWidthInfo, 0.5f, 1.f, 20.f)
|
||||
, _size(SizeInfo, glm::vec3(1.f), glm::vec3(1.f), glm::vec3(100.f))
|
||||
, _drawLabels(DrawLabelInfo, false)
|
||||
{
|
||||
const Parameters p = codegen::bake<Parameters>(dictionary);
|
||||
|
||||
@@ -117,12 +106,11 @@ RenderableBoxGrid::RenderableBoxGrid(const ghoul::Dictionary& dictionary)
|
||||
addProperty(_size);
|
||||
|
||||
if (p.labels.has_value()) {
|
||||
_drawLabels = p.drawLabels.value_or(_drawLabels);
|
||||
addProperty(_drawLabels);
|
||||
|
||||
_labels = std::make_unique<LabelsComponent>(*p.labels);
|
||||
_hasLabels = true;
|
||||
addPropertySubOwner(_labels.get());
|
||||
// Fading of the labels should also depend on the fading of the renderable
|
||||
_labels->setParentFadeable(this);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -215,7 +203,7 @@ void RenderableBoxGrid::render(const RenderData& data, RendererTasks&){
|
||||
global::renderEngine->openglStateCache().resetDepthState();
|
||||
|
||||
// Draw labels
|
||||
if (_drawLabels && _hasLabels) {
|
||||
if (_hasLabels && _labels->enabled()) {
|
||||
const glm::vec3 lookup = data.camera.lookUpVectorWorldSpace();
|
||||
const glm::vec3 viewDirection = data.camera.viewDirectionWorldSpace();
|
||||
glm::vec3 right = glm::cross(viewDirection, lookup);
|
||||
|
||||
@@ -76,7 +76,6 @@ protected:
|
||||
|
||||
// Labels
|
||||
bool _hasLabels = false;
|
||||
properties::BoolProperty _drawLabels;
|
||||
std::unique_ptr<LabelsComponent> _labels;
|
||||
};
|
||||
|
||||
|
||||
@@ -81,14 +81,7 @@ namespace {
|
||||
"This value species the size of each dimensions of the grid"
|
||||
};
|
||||
|
||||
constexpr openspace::properties::Property::PropertyInfo DrawLabelInfo = {
|
||||
"DrawLabels",
|
||||
"Draw Labels",
|
||||
"Determines whether labels should be drawn or hidden"
|
||||
};
|
||||
|
||||
static const openspace::properties::PropertyOwner::PropertyOwnerInfo LabelsInfo =
|
||||
{
|
||||
static const openspace::properties::PropertyOwner::PropertyOwnerInfo LabelsInfo = {
|
||||
"Labels",
|
||||
"Labels",
|
||||
"The labels for the grid"
|
||||
@@ -116,9 +109,6 @@ namespace {
|
||||
// [[codegen::verbatim(SizeInfo.description)]]
|
||||
std::optional<glm::vec2> size;
|
||||
|
||||
// [[codegen::verbatim(DrawLabelInfo.description)]]
|
||||
std::optional<bool> drawLabels;
|
||||
|
||||
// [[codegen::verbatim(LabelsInfo.description)]]
|
||||
std::optional<ghoul::Dictionary> labels
|
||||
[[codegen::reference("space_labelscomponent")]];
|
||||
@@ -141,7 +131,6 @@ RenderableGrid::RenderableGrid(const ghoul::Dictionary& dictionary)
|
||||
, _lineWidth(LineWidthInfo, 0.5f, 1.f, 20.f)
|
||||
, _highlightLineWidth(HighlightLineWidthInfo, 0.5f, 1.f, 20.f)
|
||||
, _size(SizeInfo, glm::vec2(1.f), glm::vec2(1.f), glm::vec2(1e11f))
|
||||
, _drawLabels(DrawLabelInfo, false)
|
||||
{
|
||||
const Parameters p = codegen::bake<Parameters>(dictionary);
|
||||
|
||||
@@ -178,12 +167,11 @@ RenderableGrid::RenderableGrid(const ghoul::Dictionary& dictionary)
|
||||
addProperty(_size);
|
||||
|
||||
if (p.labels.has_value()) {
|
||||
_drawLabels = p.drawLabels.value_or(_drawLabels);
|
||||
addProperty(_drawLabels);
|
||||
|
||||
_labels = std::make_unique<LabelsComponent>(*p.labels);
|
||||
_hasLabels = true;
|
||||
addPropertySubOwner(_labels.get());
|
||||
// Fading of the labels should also depend on the fading of the renderable
|
||||
_labels->setParentFadeable(this);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -314,11 +302,11 @@ void RenderableGrid::render(const RenderData& data, RendererTasks&){
|
||||
global::renderEngine->openglStateCache().resetDepthState();
|
||||
|
||||
// Draw labels
|
||||
if (_drawLabels && _hasLabels) {
|
||||
if (_hasLabels && _labels->enabled()) {
|
||||
const glm::vec3 orthoUp = glm::normalize(
|
||||
glm::vec3(worldToModelTransform * glm::dvec4(up, 0.0))
|
||||
);
|
||||
_labels->render(data, modelViewProjectionMatrix, orthoRight, orthoUp);
|
||||
_labels->render(data, modelViewProjectionMatrix, orthoRight, orthoUp);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -85,7 +85,6 @@ protected:
|
||||
|
||||
// Labels
|
||||
bool _hasLabels = false;
|
||||
properties::BoolProperty _drawLabels;
|
||||
std::unique_ptr<LabelsComponent> _labels;
|
||||
};
|
||||
|
||||
|
||||
@@ -71,14 +71,7 @@ namespace {
|
||||
"ring"
|
||||
};
|
||||
|
||||
constexpr openspace::properties::Property::PropertyInfo DrawLabelInfo = {
|
||||
"DrawLabels",
|
||||
"Draw Labels",
|
||||
"Determines whether labels should be drawn or hidden"
|
||||
};
|
||||
|
||||
static const openspace::properties::PropertyOwner::PropertyOwnerInfo LabelsInfo =
|
||||
{
|
||||
static const openspace::properties::PropertyOwner::PropertyOwnerInfo LabelsInfo = {
|
||||
"Labels",
|
||||
"Labels",
|
||||
"The labels for the grid"
|
||||
@@ -100,9 +93,6 @@ namespace {
|
||||
// [[codegen::verbatim(RadiiInfo.description)]]
|
||||
std::optional<glm::vec2> radii;
|
||||
|
||||
// [[codegen::verbatim(DrawLabelInfo.description)]]
|
||||
std::optional<bool> drawLabels;
|
||||
|
||||
// [[codegen::verbatim(LabelsInfo.description)]]
|
||||
std::optional<ghoul::Dictionary> labels
|
||||
[[codegen::reference("space_labelscomponent")]];
|
||||
@@ -123,7 +113,6 @@ RenderableRadialGrid::RenderableRadialGrid(const ghoul::Dictionary& dictionary)
|
||||
, _circleSegments(CircleSegmentsInfo, 36, 4, 200)
|
||||
, _lineWidth(LineWidthInfo, 0.5f, 1.f, 20.f)
|
||||
, _radii(RadiiInfo, glm::vec2(0.f, 1.f), glm::vec2(0.f), glm::vec2(20.f))
|
||||
, _drawLabels(DrawLabelInfo, false)
|
||||
{
|
||||
const Parameters p = codegen::bake<Parameters>(dictionary);
|
||||
|
||||
@@ -157,12 +146,11 @@ RenderableRadialGrid::RenderableRadialGrid(const ghoul::Dictionary& dictionary)
|
||||
addProperty(_radii);
|
||||
|
||||
if (p.labels.has_value()) {
|
||||
_drawLabels = p.drawLabels.value_or(_drawLabels);
|
||||
addProperty(_drawLabels);
|
||||
|
||||
_labels = std::make_unique<LabelsComponent>(*p.labels);
|
||||
_hasLabels = true;
|
||||
addPropertySubOwner(_labels.get());
|
||||
// Fading of the labels should also depend on the fading of the renderable
|
||||
_labels->setParentFadeable(this);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -244,7 +232,7 @@ void RenderableRadialGrid::render(const RenderData& data, RendererTasks&) {
|
||||
global::renderEngine->openglStateCache().resetDepthState();
|
||||
|
||||
// Draw labels
|
||||
if (_drawLabels && _hasLabels) {
|
||||
if (_hasLabels && _labels->enabled()) {
|
||||
const glm::vec3 lookup = data.camera.lookUpVectorWorldSpace();
|
||||
const glm::vec3 viewDirection = data.camera.viewDirectionWorldSpace();
|
||||
glm::vec3 right = glm::cross(viewDirection, lookup);
|
||||
|
||||
@@ -90,7 +90,6 @@ protected:
|
||||
|
||||
// Labels
|
||||
bool _hasLabels = false;
|
||||
properties::BoolProperty _drawLabels;
|
||||
std::unique_ptr<LabelsComponent> _labels;
|
||||
};
|
||||
|
||||
|
||||
@@ -55,14 +55,7 @@ namespace {
|
||||
"This value specifies the line width of the spherical grid"
|
||||
};
|
||||
|
||||
constexpr openspace::properties::Property::PropertyInfo DrawLabelInfo = {
|
||||
"DrawLabels",
|
||||
"Draw Labels",
|
||||
"Determines whether labels should be drawn or hidden"
|
||||
};
|
||||
|
||||
static const openspace::properties::PropertyOwner::PropertyOwnerInfo LabelsInfo =
|
||||
{
|
||||
static const openspace::properties::PropertyOwner::PropertyOwnerInfo LabelsInfo = {
|
||||
"Labels",
|
||||
"Labels",
|
||||
"The labels for the grid"
|
||||
@@ -78,9 +71,6 @@ namespace {
|
||||
// [[codegen::verbatim(LineWidthInfo.description)]]
|
||||
std::optional<float> lineWidth;
|
||||
|
||||
// [[codegen::verbatim(DrawLabelInfo.description)]]
|
||||
std::optional<bool> drawLabels;
|
||||
|
||||
// [[codegen::verbatim(LabelsInfo.description)]]
|
||||
std::optional<ghoul::Dictionary> labels
|
||||
[[codegen::reference("space_labelscomponent")]];
|
||||
@@ -100,7 +90,6 @@ RenderableSphericalGrid::RenderableSphericalGrid(const ghoul::Dictionary& dictio
|
||||
, _color(ColorInfo, glm::vec3(0.5f), glm::vec3(0.f), glm::vec3(1.f))
|
||||
, _segments(SegmentsInfo, 36, 4, 200)
|
||||
, _lineWidth(LineWidthInfo, 0.5f, 1.f, 20.f)
|
||||
, _drawLabels(DrawLabelInfo, false)
|
||||
{
|
||||
const Parameters p = codegen::bake<Parameters>(dictionary);
|
||||
|
||||
@@ -127,12 +116,11 @@ RenderableSphericalGrid::RenderableSphericalGrid(const ghoul::Dictionary& dictio
|
||||
setBoundingSphere(1.0);
|
||||
|
||||
if (p.labels.has_value()) {
|
||||
_drawLabels = p.drawLabels.value_or(_drawLabels);
|
||||
addProperty(_drawLabels);
|
||||
|
||||
_labels = std::make_unique<LabelsComponent>(*p.labels);
|
||||
_hasLabels = true;
|
||||
addPropertySubOwner(_labels.get());
|
||||
// Fading of the labels should also depend on the fading of the renderable
|
||||
_labels->setParentFadeable(this);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -232,7 +220,7 @@ void RenderableSphericalGrid::render(const RenderData& data, RendererTasks&){
|
||||
global::renderEngine->openglStateCache().resetDepthState();
|
||||
|
||||
// Draw labels
|
||||
if (_drawLabels && _hasLabels) {
|
||||
if (_hasLabels && _labels->enabled()) {
|
||||
const glm::vec3 lookup = data.camera.lookUpVectorWorldSpace();
|
||||
const glm::vec3 viewDirection = data.camera.viewDirectionWorldSpace();
|
||||
glm::vec3 right = glm::cross(viewDirection, lookup);
|
||||
|
||||
@@ -80,7 +80,6 @@ protected:
|
||||
|
||||
// Labels
|
||||
bool _hasLabels = false;
|
||||
properties::BoolProperty _drawLabels;
|
||||
std::unique_ptr<LabelsComponent> _labels;
|
||||
};
|
||||
|
||||
|
||||
@@ -106,14 +106,7 @@ namespace {
|
||||
"Enables/Disables the drawing of the astronomical objects"
|
||||
};
|
||||
|
||||
constexpr openspace::properties::Property::PropertyInfo DrawLabelInfo = {
|
||||
"DrawLabels",
|
||||
"Draw Labels",
|
||||
"Determines whether labels should be drawn or hidden"
|
||||
};
|
||||
|
||||
static const openspace::properties::PropertyOwner::PropertyOwnerInfo LabelsInfo =
|
||||
{
|
||||
static const openspace::properties::PropertyOwner::PropertyOwnerInfo LabelsInfo = {
|
||||
"Labels",
|
||||
"Labels",
|
||||
"The labels for the astronomical objects"
|
||||
@@ -251,9 +244,6 @@ namespace {
|
||||
// The number of sides for the polygon used to represent the astronomical object
|
||||
std::optional<int> polygonSides;
|
||||
|
||||
// [[codegen::verbatim(DrawLabelInfo.description)]]
|
||||
std::optional<bool> drawLabels;
|
||||
|
||||
// [[codegen::verbatim(LabelsInfo.description)]]
|
||||
std::optional<ghoul::Dictionary> labels
|
||||
[[codegen::reference("space_labelscomponent")]];
|
||||
@@ -308,7 +298,6 @@ RenderableBillboardsCloud::RenderableBillboardsCloud(const ghoul::Dictionary& di
|
||||
, _pointColor(ColorInfo, glm::vec3(1.f), glm::vec3(0.f), glm::vec3(1.f))
|
||||
, _spriteTexturePath(SpriteTextureInfo)
|
||||
, _drawElements(DrawElementsInfo, true)
|
||||
, _drawLabels(DrawLabelInfo, false)
|
||||
, _pixelSizeControl(PixelSizeControlInfo, false)
|
||||
, _colorOption(ColorOptionInfo, properties::OptionProperty::DisplayType::Dropdown)
|
||||
, _optionColorRangeData(OptionColorRangeInfo, glm::vec2(0.f))
|
||||
@@ -441,12 +430,11 @@ RenderableBillboardsCloud::RenderableBillboardsCloud(const ghoul::Dictionary& di
|
||||
_hasPolygon = p.polygonSides.has_value();
|
||||
|
||||
if (p.labels.has_value()) {
|
||||
_drawLabels = p.drawLabels.value_or(_drawLabels);
|
||||
addProperty(_drawLabels);
|
||||
|
||||
_labels = std::make_unique<LabelsComponent>(*p.labels);
|
||||
_hasLabels = true;
|
||||
addPropertySubOwner(_labels.get());
|
||||
// Fading of the labels should also depend on the fading of the renderable
|
||||
_labels->setParentFadeable(this);
|
||||
}
|
||||
|
||||
_transformationMatrix = p.transformationMatrix.value_or(_transformationMatrix);
|
||||
@@ -719,7 +707,7 @@ void RenderableBillboardsCloud::render(const RenderData& data, RendererTasks&) {
|
||||
renderBillboards(data, modelMatrix, orthoRight, orthoUp, fadeInVar);
|
||||
}
|
||||
|
||||
if (_drawLabels && _hasLabels) {
|
||||
if (_hasLabels) {
|
||||
_labels->render(data, modelViewProjectionMatrix, orthoRight, orthoUp, fadeInVar);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -98,7 +98,6 @@ private:
|
||||
properties::Vec3Property _pointColor;
|
||||
properties::StringProperty _spriteTexturePath;
|
||||
properties::BoolProperty _drawElements;
|
||||
properties::BoolProperty _drawLabels;
|
||||
properties::BoolProperty _pixelSizeControl;
|
||||
properties::OptionProperty _colorOption;
|
||||
properties::Vec2Property _optionColorRangeData;
|
||||
|
||||
@@ -242,6 +242,8 @@ RenderablePlanesCloud::RenderablePlanesCloud(const ghoul::Dictionary& dictionary
|
||||
_labels = std::make_unique<LabelsComponent>(*p.labels);
|
||||
_hasLabels = true;
|
||||
addPropertySubOwner(_labels.get());
|
||||
// Fading of the labels should also depend on the fading of the renderable
|
||||
_labels->setParentFadeable(this);
|
||||
}
|
||||
|
||||
_transformationMatrix = p.transformationMatrix.value_or(_transformationMatrix);
|
||||
|
||||
@@ -45,6 +45,7 @@ uniform vec3 sunPositionObj;
|
||||
uniform vec3 camPositionObj;
|
||||
uniform float nightFactor;
|
||||
uniform float zFightingPercentage;
|
||||
uniform float opacity;
|
||||
|
||||
|
||||
Fragment getFragment() {
|
||||
@@ -123,6 +124,7 @@ Fragment getFragment() {
|
||||
Fragment frag;
|
||||
|
||||
frag.color = diffuse * shadow;
|
||||
frag.color.a *= opacity;
|
||||
frag.depth = vs_screenSpaceDepth;
|
||||
frag.gPosition = vec4(1e30, 1e30, 1e30, 1.0);
|
||||
frag.gNormal = vec4(normal, 1.0);
|
||||
|
||||
@@ -39,6 +39,7 @@ uniform float colorFilterValue;
|
||||
uniform vec3 sunPosition;
|
||||
uniform float nightFactor;
|
||||
uniform float zFightingPercentage;
|
||||
uniform float opacity;
|
||||
|
||||
|
||||
Fragment getFragment() {
|
||||
@@ -111,6 +112,7 @@ Fragment getFragment() {
|
||||
Fragment frag;
|
||||
|
||||
frag.color = diffuse * shadow;
|
||||
frag.color.a *= opacity;
|
||||
frag.depth = vs_screenSpaceDepth;
|
||||
frag.gPosition = vec4(1e30, 1e30, 1e30, 1.0);
|
||||
frag.gNormal = vec4(normal, 1.0);
|
||||
|
||||
@@ -97,12 +97,6 @@ namespace {
|
||||
"The text color of the labels"
|
||||
};
|
||||
|
||||
constexpr openspace::properties::Property::PropertyInfo OpacityInfo = {
|
||||
"Opacity",
|
||||
"Opacity",
|
||||
"The opacity of the labels"
|
||||
};
|
||||
|
||||
constexpr openspace::properties::Property::PropertyInfo FadeDistancesInfo = {
|
||||
"FadeDistances",
|
||||
"Fade-In Distances",
|
||||
@@ -165,7 +159,7 @@ namespace {
|
||||
// [[codegen::verbatim(ColorInfo.description)]]
|
||||
std::optional<glm::vec3> color [[codegen::color()]];
|
||||
|
||||
// [[codegen::verbatim(OpacityInfo.description)]]
|
||||
// The opacity of the labels
|
||||
std::optional<float> opacity [[codegen::inrange(0.f, 1.f)]];
|
||||
|
||||
// [[codegen::verbatim(FadeDistancesInfo.description)]]
|
||||
@@ -207,7 +201,6 @@ GlobeLabelsComponent::GlobeLabelsComponent()
|
||||
, _minMaxSize(MinMaxSizeInfo, glm::ivec2(1, 1000), glm::ivec2(1), glm::ivec2(1000))
|
||||
, _heightOffset(HeightOffsetInfo, 100.f, 0.f, 10000.f)
|
||||
, _color(ColorInfo, glm::vec3(1.f, 1.f, 0.f), glm::vec3(0.f), glm::vec3(1.f))
|
||||
, _opacity(OpacityInfo, 1.f, 0.f, 1.f)
|
||||
, _fadeDistances(
|
||||
FadeDistancesInfo,
|
||||
glm::vec2(1e4f, 1e6f),
|
||||
@@ -224,19 +217,21 @@ GlobeLabelsComponent::GlobeLabelsComponent()
|
||||
)
|
||||
{
|
||||
addProperty(_enabled);
|
||||
addProperty(_color);
|
||||
_color.setViewOption(properties::Property::ViewOptions::Color);
|
||||
addProperty(_opacity);
|
||||
addProperty(_fade);
|
||||
|
||||
addProperty(_fontSize);
|
||||
addProperty(_size);
|
||||
_minMaxSize.setViewOption(properties::Property::ViewOptions::MinMaxRange);
|
||||
addProperty(_minMaxSize);
|
||||
addProperty(_color);
|
||||
addProperty(_opacity);
|
||||
_fadeDistances.setViewOption(properties::Property::ViewOptions::MinMaxRange);
|
||||
_fadeDistances.setExponent(3.f);
|
||||
addProperty(_fadeDistances);
|
||||
addProperty(_fadeInEnabled);
|
||||
addProperty(_fadeOutEnabled);
|
||||
addProperty(_heightOffset);
|
||||
_color.setViewOption(properties::Property::ViewOptions::Color);
|
||||
addProperty(_disableCulling);
|
||||
addProperty(_distanceEPS);
|
||||
|
||||
@@ -533,7 +528,7 @@ void GlobeLabelsComponent::renderLabels(const RenderData& data,
|
||||
) {
|
||||
glm::vec4 textColor = glm::vec4(
|
||||
glm::vec3(_color),
|
||||
_opacity * fadeInVariable
|
||||
opacity() * fadeInVariable
|
||||
);
|
||||
|
||||
glm::dmat4 VP = glm::dmat4(data.camera.sgctInternal.projectionMatrix()) *
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
#define __OPENSPACE_MODULE_GLOBEBROWSING___GLOBELABELSCOMPONENT___H__
|
||||
|
||||
#include <openspace/properties/propertyowner.h>
|
||||
#include <openspace/rendering/fadeable.h>
|
||||
|
||||
#include <openspace/properties/optionproperty.h>
|
||||
#include <openspace/properties/scalar/boolproperty.h>
|
||||
@@ -47,7 +48,7 @@ struct RenderData;
|
||||
namespace documentation { struct Documentation; }
|
||||
namespace globebrowsing { class RenderableGlobe; }
|
||||
|
||||
class GlobeLabelsComponent : public properties::PropertyOwner {
|
||||
class GlobeLabelsComponent : public properties::PropertyOwner, public Fadeable {
|
||||
public:
|
||||
GlobeLabelsComponent();
|
||||
~GlobeLabelsComponent() override = default;
|
||||
@@ -85,14 +86,11 @@ private:
|
||||
};
|
||||
|
||||
properties::BoolProperty _enabled;
|
||||
properties::Vec3Property _color;
|
||||
properties::FloatProperty _fontSize;
|
||||
properties::FloatProperty _size;
|
||||
properties::IVec2Property _minMaxSize;
|
||||
properties::FloatProperty _heightOffset;
|
||||
|
||||
properties::Vec3Property _color;
|
||||
properties::FloatProperty _opacity;
|
||||
|
||||
properties::Vec2Property _fadeDistances;
|
||||
properties::BoolProperty _fadeInEnabled;
|
||||
properties::BoolProperty _fadeOutEnabled;
|
||||
|
||||
@@ -48,7 +48,7 @@ void GPULayerGroup::setValue(ghoul::opengl::ProgramObject& program,
|
||||
auto& galuc = gal.uniformCache;
|
||||
const Layer& al = *activeLayers[i];
|
||||
|
||||
program.setUniform(galuc.opacity, al.renderSettings().opacity);
|
||||
program.setUniform(galuc.opacity, al.opacity());
|
||||
program.setUniform(galuc.gamma, al.renderSettings().gamma);
|
||||
program.setUniform(galuc.multiplier, al.renderSettings().multiplier);
|
||||
program.setUniform(galuc.offset, al.renderSettings().offset);
|
||||
|
||||
@@ -125,10 +125,10 @@ namespace {
|
||||
// borders
|
||||
std::optional<bool> padTiles;
|
||||
|
||||
struct Settings {
|
||||
// The opacity value of the layer
|
||||
std::optional<float> opacity [[codegen::inrange(0.0, 1.0)]];
|
||||
// The opacity value of the layer
|
||||
std::optional<float> opacity [[codegen::inrange(0.0, 1.0)]];
|
||||
|
||||
struct Settings {
|
||||
// The gamma value that is applied to each pixel of the layer
|
||||
std::optional<float> gamma;
|
||||
|
||||
@@ -228,8 +228,11 @@ Layer::Layer(layers::Group::ID id, const ghoul::Dictionary& layerDict, LayerGrou
|
||||
_padTilePixelStartOffset = initData.tilePixelStartOffset;
|
||||
_padTilePixelSizeDifference = initData.tilePixelSizeDifference;
|
||||
|
||||
_opacity = p.opacity.value_or(_opacity);
|
||||
addProperty(_opacity);
|
||||
addProperty(_fade);
|
||||
|
||||
if (p.settings.has_value()) {
|
||||
_renderSettings.opacity = p.settings->opacity.value_or(_renderSettings.opacity);
|
||||
_renderSettings.gamma = p.settings->gamma.value_or(_renderSettings.gamma);
|
||||
_renderSettings.multiplier =
|
||||
p.settings->multiplier.value_or(_renderSettings.multiplier);
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
#define __OPENSPACE_MODULE_GLOBEBROWSING___LAYER___H__
|
||||
|
||||
#include <openspace/properties/propertyowner.h>
|
||||
#include <openspace/rendering/fadeable.h>
|
||||
|
||||
#include <modules/globebrowsing/src/basictypes.h>
|
||||
#include <modules/globebrowsing/src/layeradjustment.h>
|
||||
@@ -42,7 +43,7 @@ struct LayerGroup;
|
||||
struct TileIndex;
|
||||
struct TileProvider;
|
||||
|
||||
class Layer : public properties::PropertyOwner {
|
||||
class Layer : public properties::PropertyOwner, public Fadeable {
|
||||
public:
|
||||
Layer(layers::Group::ID id, const ghoul::Dictionary& layerDict, LayerGroup& parent);
|
||||
|
||||
|
||||
@@ -32,14 +32,6 @@ namespace {
|
||||
"values"
|
||||
};
|
||||
|
||||
constexpr openspace::properties::Property::PropertyInfo OpacityInfo = {
|
||||
"Opacity",
|
||||
"Opacity",
|
||||
"This value sets the transparency of this layer. If this value is equal to '1', "
|
||||
"the layer is completely opaque. If this value is equal to '0', the layer is "
|
||||
"completely transparent"
|
||||
};
|
||||
|
||||
constexpr openspace::properties::Property::PropertyInfo GammaInfo = {
|
||||
"Gamma",
|
||||
"Gamma",
|
||||
@@ -65,20 +57,17 @@ namespace openspace::globebrowsing {
|
||||
|
||||
LayerRenderSettings::LayerRenderSettings()
|
||||
: properties::PropertyOwner({ "Settings" })
|
||||
, opacity(OpacityInfo, 1.f, 0.f, 1.f)
|
||||
, gamma(GammaInfo, 1.f, 0.f, 5.f)
|
||||
, multiplier(MultiplierInfo, 1.f, 0.f, 20.f)
|
||||
, offset(OffsetInfo, 0.f, -10000.f, 10000.f)
|
||||
, setDefault(SetDefaultInfo)
|
||||
{
|
||||
addProperty(opacity);
|
||||
addProperty(gamma);
|
||||
addProperty(multiplier);
|
||||
addProperty(offset);
|
||||
addProperty(setDefault);
|
||||
|
||||
setDefault.onChange([this](){
|
||||
opacity = 1.f;
|
||||
gamma = 1.f;
|
||||
multiplier = 1.f;
|
||||
offset = 0.f;
|
||||
@@ -86,7 +75,6 @@ LayerRenderSettings::LayerRenderSettings()
|
||||
}
|
||||
|
||||
void LayerRenderSettings::onChange(std::function<void()> callback) {
|
||||
opacity.onChange(callback);
|
||||
gamma.onChange(callback);
|
||||
multiplier.onChange(callback);
|
||||
multiplier.onChange(callback);
|
||||
@@ -95,7 +83,7 @@ void LayerRenderSettings::onChange(std::function<void()> callback) {
|
||||
|
||||
float LayerRenderSettings::performLayerSettings(float v) const {
|
||||
return
|
||||
((glm::sign(v) * glm::pow(glm::abs(v), gamma) * multiplier) + offset) * opacity;
|
||||
((glm::sign(v) * glm::pow(glm::abs(v), gamma) * multiplier) + offset);
|
||||
}
|
||||
|
||||
glm::vec4 LayerRenderSettings::performLayerSettings(const glm::vec4& currentValue) const {
|
||||
|
||||
@@ -35,7 +35,6 @@ namespace openspace::globebrowsing {
|
||||
struct LayerRenderSettings : public properties::PropertyOwner {
|
||||
LayerRenderSettings();
|
||||
|
||||
properties::FloatProperty opacity;
|
||||
properties::FloatProperty gamma;
|
||||
properties::FloatProperty multiplier;
|
||||
properties::FloatProperty offset;
|
||||
|
||||
@@ -655,6 +655,7 @@ RenderableGlobe::RenderableGlobe(const ghoul::Dictionary& dictionary)
|
||||
// Components
|
||||
_hasRings = p.rings.has_value();
|
||||
if (_hasRings) {
|
||||
_ringsComponent.setParentFadeable(this);
|
||||
_ringsComponent.initialize();
|
||||
addPropertySubOwner(_ringsComponent);
|
||||
}
|
||||
@@ -676,6 +677,9 @@ void RenderableGlobe::initializeGL() {
|
||||
if (!_labelsDictionary.isEmpty()) {
|
||||
_globeLabelsComponent.initialize(_labelsDictionary, this);
|
||||
addPropertySubOwner(_globeLabelsComponent);
|
||||
|
||||
// Fading of the labels should also depend on the fading of the globe
|
||||
_globeLabelsComponent.setParentFadeable(this);
|
||||
}
|
||||
|
||||
_layerManager.update();
|
||||
@@ -749,7 +753,9 @@ void RenderableGlobe::render(const RenderData& data, RendererTasks& rendererTask
|
||||
|
||||
// Render from light source point of view
|
||||
renderChunks(lightRenderData, rendererTask, {}, true);
|
||||
if (_hasRings && _ringsComponent.isEnabled()) {
|
||||
if (_hasRings && _ringsComponent.isEnabled() &&
|
||||
_ringsComponent.isVisible())
|
||||
{
|
||||
_ringsComponent.draw(
|
||||
lightRenderData,
|
||||
RingsComponent::RenderPass::GeometryOnly
|
||||
@@ -762,7 +768,9 @@ void RenderableGlobe::render(const RenderData& data, RendererTasks& rendererTask
|
||||
|
||||
// Render again from original point of view
|
||||
renderChunks(data, rendererTask, _shadowComponent.shadowMapData());
|
||||
if (_hasRings && _ringsComponent.isEnabled()) {
|
||||
if (_hasRings && _ringsComponent.isEnabled() &&
|
||||
_ringsComponent.isVisible())
|
||||
{
|
||||
_ringsComponent.draw(
|
||||
data,
|
||||
RingsComponent::RenderPass::GeometryAndShading,
|
||||
@@ -772,7 +780,9 @@ void RenderableGlobe::render(const RenderData& data, RendererTasks& rendererTask
|
||||
}
|
||||
else {
|
||||
renderChunks(data, rendererTask);
|
||||
if (_hasRings && _ringsComponent.isEnabled()) {
|
||||
if (_hasRings && _ringsComponent.isEnabled() &&
|
||||
_ringsComponent.isVisible())
|
||||
{
|
||||
_ringsComponent.draw(
|
||||
data,
|
||||
RingsComponent::RenderPass::GeometryAndShading
|
||||
|
||||
@@ -53,18 +53,18 @@
|
||||
namespace {
|
||||
constexpr std::string_view _loggerCat = "RingsComponent";
|
||||
|
||||
constexpr std::array<const char*, 9> UniformNames = {
|
||||
constexpr std::array<const char*, 10> UniformNames = {
|
||||
"modelViewProjectionMatrix", "textureOffset", "colorFilterValue", "nightFactor",
|
||||
"sunPosition", "ringTexture", "shadowMatrix", "shadowMapTexture",
|
||||
"zFightingPercentage"
|
||||
"zFightingPercentage", "opacity"
|
||||
};
|
||||
|
||||
constexpr std::array<const char*, 15> UniformNamesAdvancedRings = {
|
||||
constexpr std::array<const char*, 16> UniformNamesAdvancedRings = {
|
||||
"modelViewProjectionMatrix", "textureOffset", "colorFilterValue", "nightFactor",
|
||||
"sunPosition", "sunPositionObj", "camPositionObj", "ringTextureFwrd",
|
||||
"ringTextureBckwrd", "ringTextureUnlit", "ringTextureColor",
|
||||
"ringTextureTransparency", "shadowMatrix", "shadowMapTexture",
|
||||
"zFightingPercentage"
|
||||
"zFightingPercentage", "opacity"
|
||||
};
|
||||
|
||||
constexpr std::array<const char*, 3> GeomUniformNames = {
|
||||
@@ -248,6 +248,8 @@ void RingsComponent::initialize() {
|
||||
const Parameters p = codegen::bake<Parameters>(_ringsDictionary);
|
||||
|
||||
addProperty(_enabled);
|
||||
addProperty(_opacity);
|
||||
addProperty(_fade);
|
||||
|
||||
_size.setExponent(15.f);
|
||||
_size = p.size.value_or(_size);
|
||||
@@ -473,6 +475,7 @@ void RingsComponent::draw(const RenderData& data, RenderPass renderPass,
|
||||
_uniformCacheAdvancedRings.ringTextureTransparency,
|
||||
ringTextureTransparencyUnit
|
||||
);
|
||||
_shader->setUniform(_uniformCacheAdvancedRings.opacityValue, opacity());
|
||||
|
||||
// Adding the model transformation to the final shadow matrix so we have a
|
||||
// complete transformation from the model coordinates to the clip space of
|
||||
@@ -507,7 +510,6 @@ void RingsComponent::draw(const RenderData& data, RenderPass renderPass,
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
glEnablei(GL_BLEND, 0);
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
|
||||
}
|
||||
else {
|
||||
_shader->setUniform(
|
||||
@@ -523,6 +525,7 @@ void RingsComponent::draw(const RenderData& data, RenderPass renderPass,
|
||||
_uniformCache.modelViewProjectionMatrix,
|
||||
modelViewProjectionTransform
|
||||
);
|
||||
_shader->setUniform(_uniformCache.opacityValue, opacity());
|
||||
|
||||
ringTextureUnit.activate();
|
||||
_texture->bind();
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
#define __OPENSPACE_MODULE_GLOBEBROWSING___RINGSCOMPONENT___H__
|
||||
|
||||
#include <openspace/properties/propertyowner.h>
|
||||
#include <openspace/rendering/fadeable.h>
|
||||
|
||||
#include <modules/globebrowsing/src/shadowcomponent.h>
|
||||
#include <openspace/properties/stringproperty.h>
|
||||
@@ -48,7 +49,7 @@ namespace openspace {
|
||||
|
||||
namespace documentation { struct Documentation; }
|
||||
|
||||
class RingsComponent : public properties::PropertyOwner {
|
||||
class RingsComponent : public properties::PropertyOwner, public Fadeable {
|
||||
public:
|
||||
enum class RenderPass {
|
||||
GeometryOnly,
|
||||
@@ -95,12 +96,13 @@ private:
|
||||
std::unique_ptr<ghoul::opengl::ProgramObject> _shader;
|
||||
std::unique_ptr<ghoul::opengl::ProgramObject> _geometryOnlyShader;
|
||||
UniformCache(modelViewProjectionMatrix, textureOffset, colorFilterValue, nightFactor,
|
||||
sunPosition, ringTexture, shadowMatrix, shadowMapTexture, zFightingPercentage
|
||||
sunPosition, ringTexture, shadowMatrix, shadowMapTexture, zFightingPercentage,
|
||||
opacityValue
|
||||
) _uniformCache;
|
||||
UniformCache(modelViewProjectionMatrix, textureOffset, colorFilterValue, nightFactor,
|
||||
sunPosition, sunPositionObj, camPositionObj, ringTextureFwrd, ringTextureBckwrd,
|
||||
ringTextureUnlit, ringTextureColor, ringTextureTransparency, shadowMatrix,
|
||||
shadowMapTexture, zFightingPercentage
|
||||
shadowMapTexture, zFightingPercentage, opacityValue
|
||||
) _uniformCacheAdvancedRings;
|
||||
UniformCache(modelViewProjectionMatrix, textureOffset, ringTexture
|
||||
) _geomUniformCache;
|
||||
|
||||
@@ -39,19 +39,19 @@ namespace {
|
||||
constexpr int RenderOptionFaceCamera = 0;
|
||||
constexpr int RenderOptionPositionNormal = 1;
|
||||
|
||||
constexpr openspace::properties::Property::PropertyInfo EnabledInfo = {
|
||||
"Enabled",
|
||||
"Is Enabled",
|
||||
"This setting determines whether the labels will be visible or not. They are "
|
||||
"disabled per default"
|
||||
};
|
||||
|
||||
constexpr openspace::properties::Property::PropertyInfo FileInfo = {
|
||||
"File",
|
||||
"File",
|
||||
"The speck label file with the data for the labels"
|
||||
};
|
||||
|
||||
constexpr openspace::properties::Property::PropertyInfo OpacityInfo = {
|
||||
"Opacity",
|
||||
"Opacity",
|
||||
"Determines the transparency of the labels, where 1 is completely opaque "
|
||||
"and 0 fully transparent"
|
||||
};
|
||||
|
||||
constexpr openspace::properties::Property::PropertyInfo ColorInfo = {
|
||||
"Color",
|
||||
"Color",
|
||||
@@ -90,10 +90,13 @@ namespace {
|
||||
};
|
||||
|
||||
struct [[codegen::Dictionary(LabelsComponent)]] Parameters {
|
||||
// [[codegen::verbatim(EnabledInfo.description)]]
|
||||
std::optional<bool> enabled;
|
||||
|
||||
// [[codegen::verbatim(FileInfo.description)]]
|
||||
std::filesystem::path file;
|
||||
|
||||
// [[codegen::verbatim(OpacityInfo.description)]]
|
||||
// The opacity of the labels
|
||||
std::optional<float> opacity [[codegen::inrange(0.0, 1.0)]];
|
||||
|
||||
// [[codegen::verbatim(ColorInfo.description)]]
|
||||
@@ -136,7 +139,7 @@ documentation::Documentation LabelsComponent::Documentation() {
|
||||
|
||||
LabelsComponent::LabelsComponent(const ghoul::Dictionary& dictionary)
|
||||
: properties::PropertyOwner({ "Labels" })
|
||||
, _opacity(OpacityInfo, 1.f, 0.f, 1.f)
|
||||
, _enabled(EnabledInfo, false)
|
||||
, _color(ColorInfo, glm::vec3(1.f), glm::vec3(0.f), glm::vec3(1.f))
|
||||
, _size(SizeInfo, 8.f, 0.5f, 24.f)
|
||||
, _fontSize(FontSizeInfo, 50.f, 1.f, 300.f)
|
||||
@@ -159,9 +162,14 @@ LabelsComponent::LabelsComponent(const ghoul::Dictionary& dictionary)
|
||||
_unit = DistanceUnit::Meter;
|
||||
}
|
||||
|
||||
_enabled = p.enabled.value_or(_enabled);
|
||||
addProperty(_enabled);
|
||||
|
||||
_opacity = p.opacity.value_or(_opacity);
|
||||
addProperty(_opacity);
|
||||
|
||||
addProperty(_fade);
|
||||
|
||||
_color = p.color.value_or(_color);
|
||||
_color.setViewOption(properties::Property::ViewOptions::Color);
|
||||
addProperty(_color);
|
||||
@@ -223,11 +231,18 @@ bool LabelsComponent::isReady() const {
|
||||
return !(_labelset.entries.empty());
|
||||
}
|
||||
|
||||
bool LabelsComponent::enabled() const {
|
||||
return _enabled;
|
||||
}
|
||||
|
||||
void LabelsComponent::render(const RenderData& data,
|
||||
const glm::dmat4& modelViewProjectionMatrix,
|
||||
const glm::vec3& orthoRight, const glm::vec3& orthoUp,
|
||||
float fadeInVariable)
|
||||
{
|
||||
if (!_enabled) {
|
||||
return;
|
||||
}
|
||||
float scale = static_cast<float>(toMeter(_unit));
|
||||
|
||||
int renderOption = _faceCamera ? RenderOptionFaceCamera : RenderOptionPositionNormal;
|
||||
@@ -245,7 +260,7 @@ void LabelsComponent::render(const RenderData& data,
|
||||
labelInfo.enableDepth = true;
|
||||
labelInfo.enableFalseDepth = false;
|
||||
|
||||
glm::vec4 textColor = glm::vec4(glm::vec3(_color), _opacity * fadeInVariable);
|
||||
glm::vec4 textColor = glm::vec4(glm::vec3(_color), opacity() * fadeInVariable);
|
||||
|
||||
for (const speck::Labelset::Entry& e : _labelset.entries) {
|
||||
if (!e.isEnabled) {
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
#define __OPENSPACE_MODULE_SPACE___LABELSCOMPONENT___H__
|
||||
|
||||
#include <openspace/properties/propertyowner.h>
|
||||
#include <openspace/rendering/fadeable.h>
|
||||
|
||||
#include <modules/space/speckloader.h>
|
||||
#include <openspace/properties/scalar/boolproperty.h>
|
||||
@@ -43,7 +44,7 @@ struct RenderData;
|
||||
|
||||
namespace documentation { struct Documentation; }
|
||||
|
||||
class LabelsComponent : public properties::PropertyOwner {
|
||||
class LabelsComponent : public properties::PropertyOwner, public Fadeable {
|
||||
public:
|
||||
explicit LabelsComponent(const ghoul::Dictionary& dictionary);
|
||||
~LabelsComponent() override = default;
|
||||
@@ -56,6 +57,7 @@ public:
|
||||
void loadLabels();
|
||||
|
||||
bool isReady() const;
|
||||
bool enabled() const;
|
||||
|
||||
void render(const RenderData& data, const glm::dmat4& modelViewProjectionMatrix,
|
||||
const glm::vec3& orthoRight, const glm::vec3& orthoUp,
|
||||
@@ -73,7 +75,7 @@ private:
|
||||
glm::dmat4 _transformationMatrix = glm::dmat4(1.0);
|
||||
|
||||
// Properties
|
||||
properties::FloatProperty _opacity;
|
||||
properties::BoolProperty _enabled;
|
||||
properties::Vec3Property _color;
|
||||
properties::FloatProperty _size;
|
||||
properties::FloatProperty _fontSize;
|
||||
|
||||
@@ -51,12 +51,6 @@ namespace {
|
||||
"The line width of the constellation"
|
||||
};
|
||||
|
||||
constexpr openspace::properties::Property::PropertyInfo DrawLabelInfo = {
|
||||
"DrawLabels",
|
||||
"Draw Labels",
|
||||
"Determines whether labels should be drawn or hidden"
|
||||
};
|
||||
|
||||
constexpr openspace::properties::Property::PropertyInfo SelectionInfo = {
|
||||
"ConstellationSelection",
|
||||
"Constellation Selection",
|
||||
@@ -70,9 +64,6 @@ namespace {
|
||||
};
|
||||
|
||||
struct [[codegen::Dictionary(RenderableConstellationsBase)]] Parameters {
|
||||
// [[codegen::verbatim(DrawLabelInfo.description)]]
|
||||
std::optional<bool> drawLabels;
|
||||
|
||||
// [[codegen::verbatim(NamesFileInfo.description)]]
|
||||
std::optional<std::filesystem::path> namesFile;
|
||||
|
||||
@@ -100,7 +91,6 @@ RenderableConstellationsBase::RenderableConstellationsBase(
|
||||
: Renderable(dictionary)
|
||||
, _lineWidth(LineWidthInfo, 2.f, 1.f, 16.f)
|
||||
, _selection(SelectionInfo)
|
||||
, _drawLabels(DrawLabelInfo, false)
|
||||
, _namesFilename(NamesFileInfo)
|
||||
{
|
||||
const Parameters p = codegen::bake<Parameters>(dictionary);
|
||||
@@ -119,12 +109,11 @@ RenderableConstellationsBase::RenderableConstellationsBase(
|
||||
addProperty(_lineWidth);
|
||||
|
||||
if (p.labels.has_value()) {
|
||||
_drawLabels = p.drawLabels.value_or(_drawLabels);
|
||||
addProperty(_drawLabels);
|
||||
|
||||
_labels = std::make_unique<LabelsComponent>(*p.labels);
|
||||
_hasLabels = true;
|
||||
addPropertySubOwner(_labels.get());
|
||||
// Fading of the labels should also depend on the fading of the renderable
|
||||
_labels->setParentFadeable(this);
|
||||
}
|
||||
|
||||
_selection.onChange([this]() { selectionPropertyHasChanged(); });
|
||||
@@ -218,7 +207,7 @@ bool RenderableConstellationsBase::isReady() const {
|
||||
}
|
||||
|
||||
void RenderableConstellationsBase::render(const RenderData& data, RendererTasks&) {
|
||||
if (!_hasLabels || !_drawLabels) {
|
||||
if (!_hasLabels || !_labels->enabled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -85,7 +85,6 @@ protected:
|
||||
|
||||
// Labels
|
||||
bool _hasLabels = false;
|
||||
properties::BoolProperty _drawLabels;
|
||||
// Everything related to the labels is handled by LabelsComponent
|
||||
std::unique_ptr<LabelsComponent> _labels;
|
||||
|
||||
|
||||
@@ -125,6 +125,7 @@ set(OPENSPACE_SOURCE
|
||||
rendering/dashboardtextitem.cpp
|
||||
rendering/framebufferrenderer.cpp
|
||||
rendering/deferredcastermanager.cpp
|
||||
rendering/fadeable.cpp
|
||||
rendering/helper.cpp
|
||||
rendering/loadingscreen.cpp
|
||||
rendering/luaconsole.cpp
|
||||
@@ -313,6 +314,7 @@ set(OPENSPACE_HEADER
|
||||
${PROJECT_SOURCE_DIR}/include/openspace/rendering/deferredcaster.h
|
||||
${PROJECT_SOURCE_DIR}/include/openspace/rendering/deferredcasterlistener.h
|
||||
${PROJECT_SOURCE_DIR}/include/openspace/rendering/deferredcastermanager.h
|
||||
${PROJECT_SOURCE_DIR}/include/openspace/rendering/fadeable.h
|
||||
${PROJECT_SOURCE_DIR}/include/openspace/rendering/loadingscreen.h
|
||||
${PROJECT_SOURCE_DIR}/include/openspace/rendering/luaconsole.h
|
||||
${PROJECT_SOURCE_DIR}/include/openspace/rendering/helper.h
|
||||
|
||||
@@ -134,6 +134,15 @@ namespace {
|
||||
"If checked, hidden scene graph nodes are visible in the UI"
|
||||
};
|
||||
|
||||
constexpr openspace::properties::Property::PropertyInfo FadeDurationInfo = {
|
||||
"FadeDuration",
|
||||
"Fade Duration (seconds)",
|
||||
"Controls how long time the fading in/out takes when enabling/disabling an "
|
||||
"object through a checkbox in the UI. Holding SHIFT while clicking the "
|
||||
"checkbox will enable/disable the renderable without fading, as will setting "
|
||||
"this value to zero."
|
||||
};
|
||||
|
||||
constexpr openspace::properties::Property::PropertyInfo DisableMouseInputInfo = {
|
||||
"DisableMouseInputs",
|
||||
"Disable All Mouse Inputs",
|
||||
@@ -151,6 +160,7 @@ OpenSpaceEngine::OpenSpaceEngine()
|
||||
, _printEvents(PrintEventsInfo, false)
|
||||
, _visibility(VisibilityInfo)
|
||||
, _showHiddenSceneGraphNodes(ShowHiddenSceneInfo, false)
|
||||
, _fadeOnEnableDuration(FadeDurationInfo, 1.f, 0.f, 5.f)
|
||||
, _disableAllMouseInputs(DisableMouseInputInfo, false)
|
||||
{
|
||||
FactoryManager::initialize();
|
||||
@@ -160,6 +170,7 @@ OpenSpaceEngine::OpenSpaceEngine()
|
||||
addProperty(_printEvents);
|
||||
addProperty(_visibility);
|
||||
addProperty(_showHiddenSceneGraphNodes);
|
||||
addProperty(_fadeOnEnableDuration);
|
||||
addProperty(_disableAllMouseInputs);
|
||||
|
||||
using Visibility = openspace::properties::Property::Visibility;
|
||||
|
||||
89
src/rendering/fadeable.cpp
Normal file
89
src/rendering/fadeable.cpp
Normal file
@@ -0,0 +1,89 @@
|
||||
/*****************************************************************************************
|
||||
* *
|
||||
* OpenSpace *
|
||||
* *
|
||||
* Copyright (c) 2014-2023 *
|
||||
* *
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this *
|
||||
* software and associated documentation files (the "Software"), to deal in the Software *
|
||||
* without restriction, including without limitation the rights to use, copy, modify, *
|
||||
* merge, publish, distribute, sublicense, and/or sell copies of the Software, and to *
|
||||
* permit persons to whom the Software is furnished to do so, subject to the following *
|
||||
* conditions: *
|
||||
* *
|
||||
* The above copyright notice and this permission notice shall be included in all copies *
|
||||
* or substantial portions of the Software. *
|
||||
* *
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, *
|
||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A *
|
||||
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT *
|
||||
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF *
|
||||
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE *
|
||||
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
|
||||
****************************************************************************************/
|
||||
|
||||
#include <openspace/rendering/fadeable.h>
|
||||
|
||||
#include <openspace/documentation/documentation.h>
|
||||
#include <openspace/documentation/verifier.h>
|
||||
#include <optional>
|
||||
|
||||
namespace {
|
||||
constexpr openspace::properties::Property::PropertyInfo OpacityInfo = {
|
||||
"Opacity",
|
||||
"Opacity",
|
||||
"This value determines the opacity of this object. A value of 0 means "
|
||||
"completely transparent"
|
||||
};
|
||||
|
||||
constexpr openspace::properties::Property::PropertyInfo FadeInfo = {
|
||||
"Fade",
|
||||
"Fade",
|
||||
"This value is used by the system to be able to fade out objects "
|
||||
"independently from the Opacity value selected by the user. This value should "
|
||||
"not be directly manipulated through a user interface, but instead used by other "
|
||||
"components of the system programmatically",
|
||||
// The Developer mode should be used once the properties in the UI listen to this
|
||||
// openspace::properties::Property::Visibility::Developer
|
||||
openspace::properties::Property::Visibility::Hidden
|
||||
};
|
||||
} // namespace
|
||||
|
||||
namespace openspace {
|
||||
|
||||
Fadeable::Fadeable()
|
||||
: _opacity(OpacityInfo, 1.f, 0.f, 1.f)
|
||||
, _fade(FadeInfo, 1.f, 0.f, 1.f)
|
||||
{
|
||||
// Note that this is not a property owner. It's still up to the subclasses to
|
||||
// add the properties, assign values, etc.
|
||||
}
|
||||
|
||||
void Fadeable::setFade(float fade) {
|
||||
_fade = fade;
|
||||
}
|
||||
|
||||
void Fadeable::setParentFadeable(Fadeable* parent) {
|
||||
_parentFadeable = parent;
|
||||
}
|
||||
|
||||
float Fadeable::fade() const {
|
||||
return _fade;
|
||||
}
|
||||
|
||||
bool Fadeable::isVisible() const {
|
||||
return opacity() > 0.f;
|
||||
}
|
||||
|
||||
float Fadeable::opacity() const {
|
||||
float fadeFromParent = 1.f;
|
||||
if (_parentFadeable) {
|
||||
// Note that we only care about the fade here, not the full opacity of the
|
||||
// parent. A subowner might still be visible even if the opacity of the
|
||||
// parent is set to zero
|
||||
fadeFromParent = _parentFadeable->fade();
|
||||
}
|
||||
return _opacity * _fade * fadeFromParent;
|
||||
}
|
||||
|
||||
} // namespace openspace
|
||||
@@ -48,25 +48,6 @@ namespace {
|
||||
"This setting determines whether this object will be visible or not"
|
||||
};
|
||||
|
||||
constexpr openspace::properties::Property::PropertyInfo OpacityInfo = {
|
||||
"Opacity",
|
||||
"Opacity",
|
||||
"This value determines the opacity of this renderable. A value of 0 means "
|
||||
"completely transparent"
|
||||
};
|
||||
|
||||
constexpr openspace::properties::Property::PropertyInfo FadeInfo = {
|
||||
"Fade",
|
||||
"Fade",
|
||||
"This value is used by the system to be able to fade out renderables "
|
||||
"independently from the Opacity value selected by the user. This value should "
|
||||
"not be directly manipulated through a user interface, but instead used by other "
|
||||
"components of the system programmatically",
|
||||
// The Developer mode should be used once the properties in the UI listen to this
|
||||
// openspace::properties::Property::Visibility::Developer
|
||||
openspace::properties::Property::Visibility::Hidden
|
||||
};
|
||||
|
||||
constexpr openspace::properties::Property::PropertyInfo RenderableTypeInfo = {
|
||||
"Type",
|
||||
"Renderable Type",
|
||||
@@ -95,7 +76,8 @@ namespace {
|
||||
// [[codegen::verbatim(EnabledInfo.description)]]
|
||||
std::optional<bool> enabled;
|
||||
|
||||
// [[codegen::verbatim(OpacityInfo.description)]]
|
||||
// This value determines the opacity of this renderable. A value of 0 means
|
||||
// completely transparent
|
||||
std::optional<float> opacity [[codegen::inrange(0.0, 1.0)]];
|
||||
|
||||
// A single tag or a list of tags that this renderable will respond to when
|
||||
@@ -155,9 +137,8 @@ ghoul::mm_unique_ptr<Renderable> Renderable::createFromDictionary(
|
||||
|
||||
Renderable::Renderable(const ghoul::Dictionary& dictionary)
|
||||
: properties::PropertyOwner({ "Renderable" })
|
||||
, Fadeable()
|
||||
, _enabled(EnabledInfo, true)
|
||||
, _opacity(OpacityInfo, 1.f, 0.f, 1.f)
|
||||
, _fade(FadeInfo, 1.f, 0.f, 1.f)
|
||||
, _renderableType(RenderableTypeInfo, "Renderable")
|
||||
, _dimInAtmosphere(DimInAtmosphereInfo, false)
|
||||
{
|
||||
@@ -280,12 +261,8 @@ bool Renderable::matchesSecondaryRenderBin(int binMask) const noexcept {
|
||||
return binMask & static_cast<int>(*_secondaryRenderBin);
|
||||
}
|
||||
|
||||
void Renderable::setFade(float fade) {
|
||||
_fade = fade;
|
||||
}
|
||||
|
||||
bool Renderable::isVisible() const {
|
||||
return _enabled && _opacity > 0.f && _fade > 0.f;
|
||||
return _enabled && Fadeable::isVisible();
|
||||
}
|
||||
|
||||
bool Renderable::isReady() const {
|
||||
@@ -331,7 +308,8 @@ float Renderable::opacity() const {
|
||||
const float dimming = _dimInAtmosphere ?
|
||||
global::navigationHandler->camera()->atmosphereDimmingFactor() :
|
||||
1.f;
|
||||
return _opacity * _fade * dimming;
|
||||
// @TODO (2023-03-20, emmbr) Should the dimming set the fade value instead?
|
||||
return dimming * Fadeable::opacity();
|
||||
}
|
||||
|
||||
} // namespace openspace
|
||||
|
||||
@@ -117,26 +117,6 @@ namespace {
|
||||
"with the background color to produce the final result"
|
||||
};
|
||||
|
||||
constexpr openspace::properties::Property::PropertyInfo OpacityInfo = {
|
||||
"Opacity",
|
||||
"Opacity",
|
||||
"This value determines the opacity 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"
|
||||
};
|
||||
|
||||
constexpr openspace::properties::Property::PropertyInfo FadeInfo = {
|
||||
"Fade",
|
||||
"Fade",
|
||||
"This value is used by the system to be able to fade out renderables "
|
||||
"independently from the Opacity value selected by the user. This value should "
|
||||
"not be directly manipulated through a user interface, but instead used by other "
|
||||
"components of the system programmatically",
|
||||
// The Developer mode should be used once the properties in the UI listen to this
|
||||
// openspace::properties::Property::Visibility::Developer
|
||||
openspace::properties::Property::Visibility::Hidden
|
||||
};
|
||||
|
||||
constexpr openspace::properties::Property::PropertyInfo DeleteInfo = {
|
||||
"Delete",
|
||||
"Delete",
|
||||
@@ -208,7 +188,9 @@ namespace {
|
||||
// [[codegen::verbatim(BackgroundColorInfo.description)]]
|
||||
std::optional<glm::vec4> backgroundColor [[codegen::color()]];
|
||||
|
||||
// [codegen::verbatim(OpacityInfo.description)]]
|
||||
// This value determines the opacity 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
|
||||
std::optional<float> opacity [[codegen::inrange(0.f, 1.f)]];
|
||||
|
||||
// Defines either a single or multiple tags that apply to this
|
||||
@@ -293,8 +275,6 @@ ScreenSpaceRenderable::ScreenSpaceRenderable(const ghoul::Dictionary& dictionary
|
||||
glm::vec4(0.f),
|
||||
glm::vec4(1.f)
|
||||
)
|
||||
, _opacity(OpacityInfo, 1.f, 0.f, 1.f)
|
||||
, _fade(FadeInfo, 1.f, 0.f, 1.f)
|
||||
, _delete(DeleteInfo)
|
||||
{
|
||||
const Parameters p = codegen::bake<Parameters>(dictionary);
|
||||
@@ -705,8 +685,4 @@ glm::vec3 ScreenSpaceRenderable::sphericalToRae(glm::vec3 spherical) const {
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
float ScreenSpaceRenderable::opacity() const {
|
||||
return _opacity * _fade;
|
||||
}
|
||||
} // namespace openspace
|
||||
|
||||
Reference in New Issue
Block a user