mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-04-28 14:59:31 -05:00
Change screenspaceskybrowser to renderableskybrowser
This commit is contained in:
@@ -1,116 +0,0 @@
|
||||
/*****************************************************************************************
|
||||
* *
|
||||
* OpenSpace *
|
||||
* *
|
||||
* Copyright (c) 2014-2022 *
|
||||
* *
|
||||
* 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_MODULE_SKYBROWSER___SCREENSPACESKYTARGET___H__
|
||||
#define __OPENSPACE_MODULE_SKYBROWSER___SCREENSPACESKYTARGET___H__
|
||||
|
||||
#include <openspace/rendering/screenspacerenderable.h>
|
||||
|
||||
#include <openspace/documentation/documentation.h>
|
||||
#include <openspace/properties/scalar/floatproperty.h>
|
||||
#include <openspace/properties/scalar/doubleproperty.h>
|
||||
|
||||
namespace openspace::documentation { struct Documentation; }
|
||||
|
||||
namespace openspace {
|
||||
|
||||
class ScreenSpaceSkyBrowser;
|
||||
|
||||
class ScreenSpaceSkyTarget : public ScreenSpaceRenderable {
|
||||
public:
|
||||
constexpr static const float DeltaTimeThreshold = 0.03f;
|
||||
|
||||
explicit ScreenSpaceSkyTarget(const ghoul::Dictionary& dictionary);
|
||||
virtual ~ScreenSpaceSkyTarget();
|
||||
|
||||
bool initializeGL() override;
|
||||
bool deinitializeGL() override;
|
||||
bool isReady() const override;
|
||||
void render() override;
|
||||
void update() override;
|
||||
glm::mat4 scaleMatrix() override;
|
||||
void bindTexture() override; // Empty function but has to be defined
|
||||
void createShaders();
|
||||
|
||||
glm::ivec3 borderColor() const;
|
||||
float opacity() const;
|
||||
glm::dvec2 lockedCoordinates() const;
|
||||
|
||||
void setScaleFromVfov(float verticalFov);
|
||||
void setFovFromScale();
|
||||
void setDimensions(glm::vec2 dimensions);
|
||||
void setColor(glm::ivec3 color);
|
||||
void setOpacity(float opacity);
|
||||
void setLock(bool isLocked);
|
||||
void setEquatorialAim(const glm::dvec2& aim);
|
||||
|
||||
// Target directions
|
||||
glm::dvec3 directionGalactic() const;
|
||||
glm::dvec2 equatorialAim() const;
|
||||
|
||||
// Locking functionality
|
||||
bool isLocked() const;
|
||||
|
||||
// Animation
|
||||
bool isAnimated() const;
|
||||
void startAnimation(glm::dvec3 end, bool shouldLockAfter = true);
|
||||
void incrementallyAnimateToCoordinate(float deltaTime);
|
||||
// Display
|
||||
void highlight(const glm::ivec3& addition);
|
||||
void removeHighlight(const glm::ivec3& removal);
|
||||
|
||||
private:
|
||||
// Properties
|
||||
properties::FloatProperty _crossHairSize;
|
||||
properties::FloatProperty _showRectangleThreshold;
|
||||
properties::FloatProperty _lineWidth;
|
||||
properties::DoubleProperty _stopAnimationThreshold;
|
||||
properties::DoubleProperty _animationSpeed;
|
||||
|
||||
// Flags
|
||||
bool _isLocked = false;
|
||||
bool _isAnimated = false;
|
||||
bool _shouldLockAfterAnimation = false;
|
||||
|
||||
// Shader
|
||||
UniformCache(modelTransform, viewProj, crossHairSize, showRectangle, lineWidth,
|
||||
dimensions, lineColor) _uniformCache;
|
||||
GLuint _vertexArray = 0;
|
||||
GLuint _vertexBuffer = 0;
|
||||
|
||||
// Sky browser
|
||||
float _verticalFov = 70.0f;
|
||||
glm::dvec2 _equatorialAim = glm::dvec2(0.0);
|
||||
glm::ivec3 _borderColor = glm::ivec3(255);
|
||||
|
||||
// Lock target to a coordinate on the sky
|
||||
glm::dvec3 _lockedCoordinates; // Cartesian equatorial coordinates
|
||||
|
||||
// Animation
|
||||
glm::dvec3 _animationEnd; // Cartesian equatorial coordinates
|
||||
glm::dvec3 _animationStart; // Cartesian equatorial coordinates
|
||||
};
|
||||
} // namespace openspace
|
||||
|
||||
#endif // __OPENSPACE_MODULE_SKYBROWSER___SCREENSPACESKYTARGET___H__
|
||||
@@ -31,15 +31,17 @@
|
||||
namespace openspace {
|
||||
|
||||
class ScreenSpaceSkyBrowser;
|
||||
class ScreenSpaceSkyTarget;
|
||||
class RenderableSkyTarget;
|
||||
class ScreenSpaceRenderable;
|
||||
class ImageData;
|
||||
class SceneGraphNode;
|
||||
|
||||
class TargetBrowserPair {
|
||||
public:
|
||||
constexpr static const float FadeThreshold = 0.01f;
|
||||
constexpr static const float DeltaTimeThreshold = 0.03f;
|
||||
|
||||
TargetBrowserPair(ScreenSpaceSkyBrowser* browser, ScreenSpaceSkyTarget* target);
|
||||
TargetBrowserPair(SceneGraphNode* target, ScreenSpaceSkyBrowser* browser);
|
||||
TargetBrowserPair& operator=(TargetBrowserPair other);
|
||||
|
||||
// Target & Browser
|
||||
@@ -54,8 +56,6 @@ public:
|
||||
// Mouse interaction
|
||||
bool checkMouseIntersection(const glm::vec2& mousePosition);
|
||||
glm::vec2 selectedScreenSpacePosition() const;
|
||||
bool isBrowserSelected() const;
|
||||
bool isTargetSelected() const;
|
||||
void fineTuneTarget(const glm::vec2& start, const glm::vec2& translation);
|
||||
void translateSelected(const glm::vec2& start, const glm::vec2& translation);
|
||||
void synchronizeAim();
|
||||
@@ -68,12 +68,12 @@ public:
|
||||
void centerTargetOnScreen();
|
||||
void lock();
|
||||
void unlock();
|
||||
void incrementallyAnimateTarget(float deltaTime);
|
||||
|
||||
bool hasFinishedFading(float goalState) const;
|
||||
bool isFacingCamera() const;
|
||||
bool isUsingRadiusAzimuthElevation() const;
|
||||
bool isEnabled() const;
|
||||
bool isLocked() const;
|
||||
|
||||
void setEnabled(bool enable);
|
||||
void setIsSyncedWithWwt(bool isSynced);
|
||||
@@ -82,7 +82,6 @@ public:
|
||||
void setBorderColor(const glm::ivec3& color);
|
||||
void setScreenSpaceSize(const glm::vec2& dimensions);
|
||||
void setVerticalFovWithScroll(float scroll);
|
||||
void setSelectedWithId(const std::string& id);
|
||||
|
||||
float verticalFov() const;
|
||||
glm::ivec3 borderColor() const;
|
||||
@@ -90,11 +89,12 @@ public:
|
||||
glm::dvec3 targetDirectionGalactic() const;
|
||||
std::string browserGuiName() const;
|
||||
std::string browserId() const;
|
||||
std::string targetId() const;
|
||||
std::string targetRenderableId() const;
|
||||
std::string targetNodeId() const;
|
||||
std::string selectedId();
|
||||
glm::vec2 size() const;
|
||||
|
||||
ScreenSpaceSkyTarget* target() const;
|
||||
RenderableSkyTarget* target() const;
|
||||
ScreenSpaceSkyBrowser* browser() const;
|
||||
const std::deque<int>& selectedImages() const;
|
||||
|
||||
@@ -115,16 +115,22 @@ private:
|
||||
bool isTargetFadeFinished(float goalState) const;
|
||||
bool isBrowserFadeFinished(float goalState) const;
|
||||
|
||||
void aimTargetGalactic(glm::dvec3 position);
|
||||
|
||||
void setFovTarget(double fov);
|
||||
|
||||
// Selection
|
||||
ScreenSpaceRenderable* _selected = nullptr;
|
||||
bool _isSelectedBrowser = false;
|
||||
ScreenSpaceSkyBrowser* _selected = nullptr;
|
||||
|
||||
// Target and browser
|
||||
ScreenSpaceSkyTarget* _target = nullptr;
|
||||
RenderableSkyTarget* _targetRenderable = nullptr;
|
||||
ScreenSpaceSkyBrowser* _browser = nullptr;
|
||||
|
||||
// Shared properties between the target and the browser
|
||||
float _verticalFov = 70.f;
|
||||
SceneGraphNode* _targetNode = nullptr;
|
||||
glm::dvec3 _animationStart = glm::dvec3(0);
|
||||
glm::dvec3 _animationEnd = glm::dvec3(0);
|
||||
bool _shouldLockAfterAnimation = false;
|
||||
bool _targetIsAnimated = false;
|
||||
|
||||
glm::dvec2 _equatorialAim = glm::dvec2(0.0);
|
||||
glm::ivec3 _borderColor = glm::ivec3(255);
|
||||
glm::vec2 _dimensions = glm::vec2(0.5f);
|
||||
|
||||
@@ -26,12 +26,13 @@
|
||||
#define __OPENSPACE_MODULE_SKYBROWSER___UTILITY___H__
|
||||
|
||||
#include <openspace/documentation/documentation.h>
|
||||
#include <openspace/util/distanceconstants.h>
|
||||
|
||||
namespace openspace::skybrowser {
|
||||
// Constants
|
||||
constexpr const double ScreenSpaceZ = -2.1;
|
||||
constexpr const glm::dvec3 NorthPole = { 0.0, 0.0, 1.0 };
|
||||
constexpr const double CelestialSphereRadius = std::numeric_limits<float>::max();
|
||||
constexpr const double CelestialSphereRadius = 4 * distanceconstants::Parsec;
|
||||
|
||||
// Conversion matrix - J2000 equatorial <-> galactic
|
||||
// https://arxiv.org/abs/1010.3773v1
|
||||
@@ -174,7 +175,15 @@ double angleBetweenVectors(const glm::dvec3& start, const glm::dvec3& end);
|
||||
* \return 4x4 matrix for incremental rotation animation of a vector
|
||||
*/
|
||||
glm::dmat4 incrementalAnimationMatrix(const glm::dvec3& start, const glm::dvec3& end,
|
||||
double deltaTime, double speedFactor = 1.0);
|
||||
double deltaTime, double speedFactor = 1.0);
|
||||
/**
|
||||
* Returns the size in meters that for example a plane would need to have in order to
|
||||
* display a specified field of view.
|
||||
* \param fov The set field of view
|
||||
* \param worldPosition The galactic position of the plane
|
||||
* \return Field of view
|
||||
*/
|
||||
double sizeFromFov(double fov, glm::dvec3 worldPosition);
|
||||
|
||||
} // namespace openspace::skybrowser
|
||||
|
||||
|
||||
Reference in New Issue
Block a user