mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-01-05 19:19:39 -06:00
Feature/navigation state (#930)
* Replace setCameraState with setNavigationState + equivalents * Add documentation and verification of NavigationState-related interfaces * Documentation and verification fixes * Change reference frame behavior * Scene fixes * Replace earthrise recording with navigation state and time
This commit is contained in:
committed by
Alexander Bock
parent
b25b205e99
commit
f43bcadee3
@@ -51,7 +51,7 @@ public:
|
||||
|
||||
private:
|
||||
std::function<T(float)> _transferFunction;
|
||||
float _t = 0.f;
|
||||
float _t = 1.f;
|
||||
float _interpolationTime = 1.f;
|
||||
float _scaledDeltaTime = 0.f;
|
||||
};
|
||||
|
||||
@@ -25,13 +25,17 @@
|
||||
#ifndef __OPENSPACE_CORE___NAVIGATIONHANDLER___H__
|
||||
#define __OPENSPACE_CORE___NAVIGATIONHANDLER___H__
|
||||
|
||||
#include <openspace/properties/propertyowner.h>
|
||||
|
||||
#include <openspace/documentation/documentation.h>
|
||||
#include <openspace/interaction/inputstate.h>
|
||||
#include <openspace/interaction/joystickcamerastates.h>
|
||||
#include <openspace/interaction/orbitalnavigator.h>
|
||||
#include <openspace/interaction/keyframenavigator.h>
|
||||
#include <openspace/properties/propertyowner.h>
|
||||
#include <openspace/properties/stringproperty.h>
|
||||
#include <openspace/properties/scalar/boolproperty.h>
|
||||
#include <openspace/util/mouse.h>
|
||||
#include <openspace/util/keys.h>
|
||||
#include <optional>
|
||||
|
||||
namespace openspace {
|
||||
class Camera;
|
||||
@@ -48,6 +52,25 @@ class OrbitalNavigator;
|
||||
|
||||
class NavigationHandler : public properties::PropertyOwner {
|
||||
public:
|
||||
struct NavigationState {
|
||||
NavigationState() = default;
|
||||
NavigationState(const ghoul::Dictionary& dictionary);
|
||||
NavigationState(std::string anchor, std::string aim, std::string referenceFrame,
|
||||
glm::dvec3 position, std::optional<glm::dvec3> up = std::nullopt,
|
||||
double yaw = 0.0, double pitch = 0.0);
|
||||
|
||||
ghoul::Dictionary dictionary() const;
|
||||
static documentation::Documentation Documentation();
|
||||
|
||||
std::string anchor;
|
||||
std::string aim;
|
||||
std::string referenceFrame;
|
||||
glm::dvec3 position;
|
||||
std::optional<glm::dvec3> up;
|
||||
double yaw = 0.0;
|
||||
double pitch = 0.0;
|
||||
};
|
||||
|
||||
NavigationHandler();
|
||||
~NavigationHandler();
|
||||
|
||||
@@ -55,10 +78,10 @@ public:
|
||||
void deinitialize();
|
||||
|
||||
// Mutators
|
||||
void setNavigationStateNextFame(NavigationState state);
|
||||
void setCamera(Camera* camera);
|
||||
void setInterpolationTime(float durationInSeconds);
|
||||
|
||||
void setCameraStateFromDictionary(const ghoul::Dictionary& cameraDict);
|
||||
void updateCamera(double deltaTime);
|
||||
void setEnableKeyFrameInteraction();
|
||||
void setDisableKeyFrameInteraction();
|
||||
@@ -66,12 +89,11 @@ public:
|
||||
void stopPlayback();
|
||||
|
||||
// Accessors
|
||||
ghoul::Dictionary cameraStateDictionary();
|
||||
Camera* camera() const;
|
||||
const InputState& inputState() const;
|
||||
const OrbitalNavigator& orbitalNavigator() const;
|
||||
OrbitalNavigator& orbitalNavigator();
|
||||
KeyframeNavigator& keyframeNavigator() const;
|
||||
KeyframeNavigator& keyframeNavigator();
|
||||
bool isKeyFrameInteractionEnabled() const;
|
||||
float interpolationTime() const;
|
||||
|
||||
@@ -100,10 +122,14 @@ public:
|
||||
void clearJoystickButtonCommand(int button);
|
||||
std::vector<std::string> joystickButtonCommand(int button) const;
|
||||
|
||||
NavigationState navigationState(const SceneGraphNode& referenceFrame) const;
|
||||
|
||||
void saveNavigationState(const std::string& filepath,
|
||||
const std::string& referenceFrameIdentifier);
|
||||
|
||||
void saveCameraStateToFile(const std::string& filepath);
|
||||
void restoreCameraStateFromFile(const std::string& filepath);
|
||||
void loadNavigationState(const std::string& filepath);
|
||||
|
||||
void setNavigationStateNextFrame(NavigationState state);
|
||||
|
||||
/**
|
||||
* \return The Lua library that contains all Lua functions available to affect the
|
||||
@@ -112,15 +138,18 @@ public:
|
||||
static scripting::LuaLibrary luaLibrary();
|
||||
|
||||
private:
|
||||
bool _cameraUpdatedFromScript = false;
|
||||
void applyNavigationState(const NavigationHandler::NavigationState& ns);
|
||||
|
||||
bool _playbackModeEnabled = false;
|
||||
|
||||
std::unique_ptr<InputState> _inputState;
|
||||
InputState _inputState;
|
||||
Camera* _camera = nullptr;
|
||||
std::function<void()> _playbackEndCallback;
|
||||
|
||||
std::unique_ptr<OrbitalNavigator> _orbitalNavigator;
|
||||
std::unique_ptr<KeyframeNavigator> _keyframeNavigator;
|
||||
OrbitalNavigator _orbitalNavigator;
|
||||
KeyframeNavigator _keyframeNavigator;
|
||||
|
||||
std::optional<NavigationState> _pendingNavigationState;
|
||||
|
||||
properties::BoolProperty _useKeyFrameInteraction;
|
||||
};
|
||||
|
||||
@@ -38,6 +38,8 @@
|
||||
#include <ghoul/glm.h>
|
||||
#include <glm/gtx/quaternion.hpp>
|
||||
|
||||
#include <optional>
|
||||
|
||||
namespace openspace {
|
||||
class SceneGraphNode;
|
||||
class Camera;
|
||||
@@ -58,6 +60,7 @@ public:
|
||||
|
||||
Camera* camera() const;
|
||||
void setCamera(Camera* camera);
|
||||
void clearPreviousState();
|
||||
|
||||
void setFocusNode(const std::string& focusNode);
|
||||
void setAnchorNode(const std::string& anchorNode);
|
||||
@@ -70,6 +73,7 @@ public:
|
||||
void resetNodeMovements();
|
||||
|
||||
JoystickCameraStates& joystickStates();
|
||||
const JoystickCameraStates& joystickStates() const;
|
||||
|
||||
bool followingNodeRotation() const;
|
||||
const SceneGraphNode* anchorNode() const;
|
||||
@@ -146,10 +150,9 @@ private:
|
||||
const SceneGraphNode* _anchorNode = nullptr;
|
||||
const SceneGraphNode* _aimNode = nullptr;
|
||||
|
||||
glm::dvec3 _previousAnchorNodePosition;
|
||||
glm::dquat _previousAnchorNodeRotation;
|
||||
|
||||
glm::dvec3 _previousAimNodePosition;
|
||||
std::optional<glm::dvec3>_previousAnchorNodePosition;
|
||||
std::optional<glm::dquat> _previousAnchorNodeRotation;
|
||||
std::optional<glm::dvec3> _previousAimNodePosition;
|
||||
|
||||
double _currentCameraToSurfaceDistance = 0.0;
|
||||
bool _directlySetStereoDistance = false;
|
||||
|
||||
Reference in New Issue
Block a user