mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-01-06 03:29:44 -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:
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);
|
||||
|
||||
Reference in New Issue
Block a user