mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-01-06 19:50:03 -06:00
Make fovs doubles instead of floats and use the target as for the roll calculation instead of the camera. This is however still not correct (need the up vector for the target)
This commit is contained in:
@@ -51,7 +51,7 @@ public:
|
||||
|
||||
// Animation
|
||||
bool isAnimated() const;
|
||||
void startFovAnimation(float fov);
|
||||
void startFovAnimation(double fov);
|
||||
void incrementallyAnimateToFov(float deltaTime);
|
||||
|
||||
float opacity() const;
|
||||
@@ -86,7 +86,7 @@ private:
|
||||
bool _sizeIsDirty = false;
|
||||
|
||||
// Animation of fieldOfView
|
||||
float _endVfov = 0.f;
|
||||
double _endVfov = 0.0;
|
||||
glm::vec2 _size = glm::vec2(0.5f);
|
||||
};
|
||||
} // namespace openspace
|
||||
|
||||
@@ -50,7 +50,7 @@ public:
|
||||
void removeHighlight(const glm::ivec3& color);
|
||||
void highlight(const glm::ivec3& color);
|
||||
// Animation
|
||||
void startAnimation(glm::dvec3 coordsEnd, float fovEnd, bool shouldLockAfter = true);
|
||||
void startAnimation(glm::dvec3 coordsEnd, double fovEnd, bool shouldLockAfter = true);
|
||||
void incrementallyAnimateToCoordinate(double deltaTime);
|
||||
void incrementallyFade(float goalState, float fadeTime, float deltaTime);
|
||||
// Mouse interaction
|
||||
@@ -76,13 +76,13 @@ public:
|
||||
|
||||
void setEnabled(bool enable);
|
||||
void setIsSyncedWithWwt(bool isSynced);
|
||||
void setVerticalFov(float vfov);
|
||||
void setVerticalFov(double vfov);
|
||||
void setEquatorialAim(const glm::dvec2& aim);
|
||||
void setBorderColor(const glm::ivec3& color);
|
||||
void setScreenSpaceSize(const glm::vec2& dimensions);
|
||||
void setVerticalFovWithScroll(float scroll);
|
||||
|
||||
float verticalFov() const;
|
||||
double verticalFov() const;
|
||||
glm::ivec3 borderColor() const;
|
||||
glm::dvec2 targetDirectionEquatorial() const;
|
||||
glm::dvec3 targetDirectionGalactic() const;
|
||||
|
||||
@@ -124,7 +124,7 @@ glm::dvec3 localCameraToEquatorial(const glm::dvec3& coords);
|
||||
* \return Angle in degrees between the OpenSpace camera's up direction vector and the
|
||||
* equatorial North Pole direction.
|
||||
*/
|
||||
double cameraRoll();
|
||||
double targetRoll(const glm::dvec3& up, const glm::dvec3& forward);
|
||||
/**
|
||||
* Returns the view direction of the OpenSpace camera in galactic coordinates.
|
||||
* \return View direction of the OpenSpace camera in Cartesian galactic coordinates.
|
||||
|
||||
@@ -55,17 +55,18 @@ public:
|
||||
void hideChromeInterface(bool shouldHide);
|
||||
|
||||
bool hasLoadedImages() const;
|
||||
float verticalFov() const;
|
||||
double verticalFov() const;
|
||||
glm::ivec3 borderColor() const;
|
||||
glm::dvec2 equatorialAim() const;
|
||||
glm::dvec2 fieldsOfView() const;
|
||||
const std::deque<int>& getSelectedImages() const;
|
||||
|
||||
void setHasLoadedImages(bool isLoaded);
|
||||
void setVerticalFov(float vfov);
|
||||
void setVerticalFov(double vfov);
|
||||
void setIsSyncedWithWwt(bool isSynced);
|
||||
void setEquatorialAim(glm::dvec2 equatorial);
|
||||
void setBorderColor(glm::ivec3 color);
|
||||
void setTargetRoll(double roll);
|
||||
|
||||
void highlight(const glm::ivec3& addition);
|
||||
// The removal parameter decides what will be removed from the border color
|
||||
@@ -76,9 +77,10 @@ public:
|
||||
protected:
|
||||
void setIdInBrowser(const std::string& id);
|
||||
|
||||
float _verticalFov = 10.f;
|
||||
double _verticalFov = 10.0f;
|
||||
glm::ivec3 _borderColor = glm::ivec3(70);
|
||||
glm::dvec2 _equatorialAim = glm::dvec2(0.0);
|
||||
double _targetRoll = 0.0;
|
||||
bool _hasLoadedImages = false;
|
||||
std::deque<int> _selectedImages;
|
||||
|
||||
|
||||
@@ -219,19 +219,19 @@ bool ScreenSpaceSkyBrowser::isAnimated() const{
|
||||
return _isFovAnimated;
|
||||
}
|
||||
|
||||
void ScreenSpaceSkyBrowser::startFovAnimation(float fov) {
|
||||
void ScreenSpaceSkyBrowser::startFovAnimation(double fov) {
|
||||
_isFovAnimated = true;
|
||||
_endVfov = fov;
|
||||
}
|
||||
|
||||
void ScreenSpaceSkyBrowser::incrementallyAnimateToFov(float deltaTime) {
|
||||
// If distance too large, keep animating. Else, stop animation
|
||||
float diff = _endVfov - verticalFov();
|
||||
double diff = _endVfov - verticalFov();
|
||||
bool shouldAnimate = abs(diff) > FovThreshold;
|
||||
|
||||
if (shouldAnimate) {
|
||||
float delta = _animationSpeed * (diff * deltaTime);
|
||||
_verticalFov = std::clamp(_verticalFov + delta, 0.0001f, 70.0f);
|
||||
double delta = _animationSpeed * (diff * static_cast<double>(deltaTime));
|
||||
_verticalFov = std::clamp(_verticalFov + delta, 0.0, 70.0);
|
||||
}
|
||||
else {
|
||||
_isFovAnimated = false;
|
||||
@@ -295,10 +295,10 @@ void ScreenSpaceSkyBrowser::update() {
|
||||
|
||||
void ScreenSpaceSkyBrowser::setVerticalFovWithScroll(float scroll) {
|
||||
// Make scroll more sensitive the smaller the FOV
|
||||
float x = _verticalFov;
|
||||
float zoomFactor = atan(x / 50.f) + exp(x / 40.f) - 0.999999f;
|
||||
float zoom = scroll > 0.f ? -zoomFactor : zoomFactor;
|
||||
_verticalFov = std::clamp(_verticalFov + zoom, 0.000001f, 70.0f);
|
||||
double x = _verticalFov;
|
||||
double zoomFactor = atan(x / 50.0) + exp(x / 40.0) - 0.99999999999999999999999999999;
|
||||
double zoom = scroll > 0.0 ? -zoomFactor : zoomFactor;
|
||||
_verticalFov = std::clamp(_verticalFov + zoom, 0.0, 70.0);
|
||||
}
|
||||
|
||||
void ScreenSpaceSkyBrowser::bindTexture() {
|
||||
|
||||
@@ -29,6 +29,8 @@
|
||||
#include <modules/skybrowser/include/utility.h>
|
||||
#include <modules/skybrowser/include/wwtdatahandler.h>
|
||||
#include <openspace/engine/globals.h>
|
||||
#include <openspace/navigation/navigationhandler.h>
|
||||
#include <openspace/camera/camera.h>
|
||||
#include <openspace/rendering/screenspacerenderable.h>
|
||||
#include <openspace/scripting/scriptengine.h>
|
||||
#include <ghoul/misc/assert.h>
|
||||
@@ -144,6 +146,11 @@ void TargetBrowserPair::synchronizeAim() {
|
||||
// target, send the locked coordinates to wwt
|
||||
glm::dvec2 aim = targetDirectionEquatorial();
|
||||
_browser->setEquatorialAim(aim);
|
||||
glm::dvec3 direction = _targetNode->worldPosition() -
|
||||
global::navigationHandler->camera()->positionVec3();
|
||||
glm::dvec3 normalized = glm::normalize(direction);
|
||||
glm::dvec3 up = global::navigationHandler->camera()->lookUpVectorWorldSpace();
|
||||
_browser->setTargetRoll(skybrowser::targetRoll(up, normalized));
|
||||
_targetRenderable->setVerticalFov(_browser->verticalFov());
|
||||
}
|
||||
}
|
||||
@@ -201,7 +208,7 @@ glm::vec2 TargetBrowserPair::size() const {
|
||||
return _browser->size();
|
||||
}
|
||||
|
||||
float TargetBrowserPair::verticalFov() const {
|
||||
double TargetBrowserPair::verticalFov() const {
|
||||
return _browser->verticalFov();
|
||||
}
|
||||
|
||||
@@ -251,7 +258,7 @@ void TargetBrowserPair::setIsSyncedWithWwt(bool isSynced) {
|
||||
_browser->setIsSyncedWithWwt(isSynced);
|
||||
}
|
||||
|
||||
void TargetBrowserPair::setVerticalFov(float vfov) {
|
||||
void TargetBrowserPair::setVerticalFov(double vfov) {
|
||||
_browser->setVerticalFov(vfov);
|
||||
_targetRenderable->setVerticalFov(vfov);
|
||||
}
|
||||
@@ -290,7 +297,7 @@ void TargetBrowserPair::incrementallyAnimateToCoordinate(double deltaTime) {
|
||||
}
|
||||
}
|
||||
|
||||
void TargetBrowserPair::startAnimation(glm::dvec3 galacticCoords, float fovEnd,
|
||||
void TargetBrowserPair::startAnimation(glm::dvec3 galacticCoords, double fovEnd,
|
||||
bool shouldLockAfter)
|
||||
{
|
||||
_browser->startFovAnimation(fovEnd);
|
||||
|
||||
@@ -118,17 +118,13 @@ glm::dvec3 galacticToLocalCamera(const glm::dvec3& coords) {
|
||||
return glm::normalize(viewDirectionLocal);
|
||||
}
|
||||
|
||||
double cameraRoll() {
|
||||
openspace::Camera* camera = global::navigationHandler->camera();
|
||||
glm::dvec3 upWorld = camera->lookUpVectorWorldSpace();
|
||||
glm::dvec3 forwardWorld = camera->viewDirectionWorldSpace();
|
||||
double targetRoll(const glm::dvec3& up, const glm::dvec3& forward) {
|
||||
glm::dvec3 upJ2000 = skybrowser::galacticToEquatorial(up);
|
||||
glm::dvec3 forwardJ2000 = skybrowser::galacticToEquatorial(forward);
|
||||
|
||||
glm::dvec3 camUpJ2000 = skybrowser::galacticToEquatorial(upWorld);
|
||||
glm::dvec3 camForwardJ2000 = skybrowser::galacticToEquatorial(forwardWorld);
|
||||
|
||||
glm::dvec3 crossUpNorth = glm::cross(camUpJ2000, skybrowser::NorthPole);
|
||||
double dotNorthUp = glm::dot(skybrowser::NorthPole, camUpJ2000);
|
||||
double dotCrossUpNorthForward = glm::dot(crossUpNorth, camForwardJ2000);
|
||||
glm::dvec3 crossUpNorth = glm::cross(upJ2000, NorthPole);
|
||||
double dotNorthUp = glm::dot(NorthPole, upJ2000);
|
||||
double dotCrossUpNorthForward = glm::dot(upJ2000, forwardJ2000);
|
||||
|
||||
return glm::degrees(atan2(dotCrossUpNorthForward, dotNorthUp));
|
||||
}
|
||||
|
||||
@@ -72,7 +72,12 @@ const std::deque<int>& WwtCommunicator::getSelectedImages() const {
|
||||
return _selectedImages;
|
||||
}
|
||||
|
||||
void WwtCommunicator::setVerticalFov(float vfov) {
|
||||
void WwtCommunicator::setTargetRoll(double roll)
|
||||
{
|
||||
_targetRoll = roll;
|
||||
}
|
||||
|
||||
void WwtCommunicator::setVerticalFov(double vfov) {
|
||||
_verticalFov = vfov;
|
||||
_equatorialAimIsDirty = true;
|
||||
}
|
||||
@@ -112,12 +117,11 @@ void WwtCommunicator::updateBorderColor() {
|
||||
}
|
||||
|
||||
void WwtCommunicator::updateAim() {
|
||||
double roll = _isSyncedWithWwt ? skybrowser::cameraRoll() : 0.0;
|
||||
// Message WorldWide Telescope current view
|
||||
ghoul::Dictionary message = moveCameraMessage(
|
||||
_equatorialAim,
|
||||
_verticalFov,
|
||||
roll
|
||||
_targetRoll
|
||||
);
|
||||
sendMessageToWwt(message);
|
||||
}
|
||||
@@ -215,7 +219,7 @@ glm::ivec3 WwtCommunicator::borderColor() const {
|
||||
return _borderColor;
|
||||
}
|
||||
|
||||
float WwtCommunicator::verticalFov() const {
|
||||
double WwtCommunicator::verticalFov() const {
|
||||
return _verticalFov;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user