mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-01-24 13:09:22 -06:00
Merge branch 'master' of github.com:OpenSpace/OpenSpace into feature/data-management
Conflicts: include/openspace/scene/scenegraphnode.h src/engine/openspaceengine.cpp src/interaction/interactionhandler.cpp src/interaction/interactionmode.cpp
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
/*****************************************************************************************
|
||||
/*****************************************************************************************
|
||||
* *
|
||||
* OpenSpace *
|
||||
* *
|
||||
@@ -78,12 +78,16 @@ public:
|
||||
static const std::string KeySettingsScript;
|
||||
/// The key that stores the settings for determining log-related settings
|
||||
static const std::string KeyLogging;
|
||||
/// The key that stores the directory for Logging
|
||||
static const std::string PartLogDir;
|
||||
/// The key that stores the desired LogLevel for the whole application
|
||||
/// \sa ghoul::logging::LogManager
|
||||
static const std::string PartLogLevel;
|
||||
/// The key that stores whether the log should be immediately flushed after a n
|
||||
/// \sa ghoul::logging::LogManager
|
||||
static const std::string PartImmediateFlush;
|
||||
/// The key for prefixing PerformanceMeasurement logfiles
|
||||
static const std::string PartLogPerformancePrefix;
|
||||
/// The key that stores a subdirectory with a description for additional
|
||||
/// ghoul::logging::Log%s to be created
|
||||
/// \sa LogFactory
|
||||
@@ -144,6 +148,11 @@ public:
|
||||
static const std::string PartFilterIdentifierIdentifier;
|
||||
/// The part of the key storing a list of severities that should be filtered out
|
||||
static const std::string PartFilterSeverity;
|
||||
/// The part of the key storing whether the OpenGL state should be checked each call
|
||||
static const std::string KeyCheckOpenGLState;
|
||||
/// The part of the key storing whether each OpenGL call should be logged
|
||||
static const std::string KeyLogEachOpenGLCall;
|
||||
|
||||
|
||||
/**
|
||||
* Iteratively walks the directory structure starting with \p filename to find the
|
||||
|
||||
@@ -97,7 +97,7 @@ public:
|
||||
ModuleSubClass* module() const {
|
||||
auto it = std::find_if(_modules.begin(), _modules.end(),
|
||||
[](const std::unique_ptr<OpenSpaceModule>& module) {
|
||||
return module->name() == ModuleSubClass::name;
|
||||
return module->name() == ModuleSubClass::Name;
|
||||
});
|
||||
if (it != _modules.end()) {
|
||||
return dynamic_cast<ModuleSubClass*>(it->get());
|
||||
|
||||
@@ -64,7 +64,10 @@ class SyncEngine;
|
||||
class TimeManager;
|
||||
class WindowWrapper;
|
||||
|
||||
namespace interaction { class InteractionHandler; }
|
||||
namespace interaction {
|
||||
class NavigationHandler;
|
||||
class KeyBindingManager;
|
||||
}
|
||||
namespace gui { class GUI; }
|
||||
namespace properties { class PropertyOwner; }
|
||||
namespace scripting {
|
||||
@@ -98,7 +101,7 @@ public:
|
||||
void charCallback(unsigned int codepoint, KeyModifier mod);
|
||||
void mouseButtonCallback(MouseButton button, MouseAction action);
|
||||
void mousePositionCallback(double x, double y);
|
||||
void mouseScrollWheelCallback(double pos);
|
||||
void mouseScrollWheelCallback(double posX, double posY);
|
||||
void externalControlCallback(const char* receivedChars, int size, int clientId);
|
||||
void encode();
|
||||
void decode();
|
||||
@@ -124,7 +127,8 @@ public:
|
||||
WindowWrapper& windowWrapper();
|
||||
AssetLoader& assetLoader();
|
||||
ghoul::fontrendering::FontManager& fontManager();
|
||||
interaction::InteractionHandler& interactionHandler();
|
||||
interaction::NavigationHandler& navigationHandler();
|
||||
interaction::KeyBindingManager& keyBindingManager();
|
||||
properties::PropertyOwner& globalPropertyOwner();
|
||||
scripting::ScriptEngine& scriptEngine();
|
||||
scripting::ScriptScheduler& scriptScheduler();
|
||||
@@ -163,7 +167,9 @@ public:
|
||||
std::function<void (double, double)> function);
|
||||
|
||||
// Registers a callback that is called when a scroll wheel change is received
|
||||
void registerModuleMouseScrollWheelCallback(std::function<bool (double)> function);
|
||||
void registerModuleMouseScrollWheelCallback(
|
||||
std::function<bool (double, double)> function
|
||||
);
|
||||
|
||||
/**
|
||||
* Returns the Lua library that contains all Lua functions available to affect the
|
||||
@@ -197,7 +203,8 @@ private:
|
||||
std::unique_ptr<WindowWrapper> _windowWrapper;
|
||||
std::unique_ptr<ghoul::cmdparser::CommandlineParser> _commandlineParser;
|
||||
std::unique_ptr<ghoul::fontrendering::FontManager> _fontManager;
|
||||
std::unique_ptr<interaction::InteractionHandler> _interactionHandler;
|
||||
std::unique_ptr<interaction::NavigationHandler> _navigationHandler;
|
||||
std::unique_ptr<interaction::KeyBindingManager> _keyBindingManager;
|
||||
std::unique_ptr<scripting::ScriptEngine> _scriptEngine;
|
||||
std::unique_ptr<scripting::ScriptScheduler> _scriptScheduler;
|
||||
std::unique_ptr<VirtualPropertyManager> _virtualPropertyManager;
|
||||
@@ -225,7 +232,7 @@ private:
|
||||
|
||||
std::vector<std::function<bool (MouseButton, MouseAction)>> mouseButton;
|
||||
std::vector<std::function<void (double, double)>> mousePosition;
|
||||
std::vector<std::function<bool (double)>> mouseScrollWheel;
|
||||
std::vector<std::function<bool (double, double)>> mouseScrollWheel;
|
||||
} _moduleCallbacks;
|
||||
|
||||
double _runTime;
|
||||
|
||||
@@ -33,7 +33,7 @@
|
||||
namespace openspace {
|
||||
namespace interaction {
|
||||
|
||||
class InteractionHandler;
|
||||
class NavigationHandler;
|
||||
|
||||
class Controller {
|
||||
public:
|
||||
@@ -41,10 +41,10 @@ public:
|
||||
_handler(nullptr)
|
||||
{}
|
||||
|
||||
void setHandler(InteractionHandler* handler);
|
||||
void setHandler(NavigationHandler* handler);
|
||||
|
||||
protected:
|
||||
InteractionHandler* _handler;
|
||||
NavigationHandler* _handler;
|
||||
};
|
||||
|
||||
} // namespace interaction
|
||||
|
||||
59
include/openspace/interaction/delayedvariable.h
Normal file
59
include/openspace/interaction/delayedvariable.h
Normal file
@@ -0,0 +1,59 @@
|
||||
/*****************************************************************************************
|
||||
* *
|
||||
* OpenSpace *
|
||||
* *
|
||||
* Copyright (c) 2014-2017 *
|
||||
* *
|
||||
* 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___DELAYEDVARIABLE___H__
|
||||
#define __OPENSPACE_CORE___DELAYEDVARIABLE___H__
|
||||
|
||||
namespace openspace {
|
||||
namespace interaction {
|
||||
|
||||
/**
|
||||
* Class that acts as a smoothing filter to a variable. The filter has a step
|
||||
* response on a form that resembles the function y = 1-e^(-t/scale). The variable
|
||||
* will be updated as soon as it is set to a value (calling the set() function).
|
||||
*/
|
||||
template <typename T, typename ScaleType>
|
||||
class DelayedVariable {
|
||||
public:
|
||||
DelayedVariable(ScaleType scaleFactor, ScaleType friction);
|
||||
void set(T value, double dt);
|
||||
void decelerate(double dt);
|
||||
void setHard(T value);
|
||||
void setFriction(ScaleType friction);
|
||||
void setScaleFactor(ScaleType scaleFactor);
|
||||
T get() const;
|
||||
|
||||
private:
|
||||
ScaleType _scaleFactor;
|
||||
ScaleType _friction;
|
||||
T _targetValue;
|
||||
T _currentValue;
|
||||
};
|
||||
|
||||
} // namespace interaction
|
||||
} // namespace openspace
|
||||
|
||||
#include "delayedvariable.inl"
|
||||
|
||||
#endif // __OPENSPACE_CORE___DELAYEDVARIABLE___H__
|
||||
76
include/openspace/interaction/delayedvariable.inl
Normal file
76
include/openspace/interaction/delayedvariable.inl
Normal file
@@ -0,0 +1,76 @@
|
||||
/*****************************************************************************************
|
||||
* *
|
||||
* OpenSpace *
|
||||
* *
|
||||
* Copyright (c) 2014-2017 *
|
||||
* *
|
||||
* 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 <ghoul/misc/assert.h>
|
||||
#include <ghoul/glm.h>
|
||||
|
||||
namespace openspace {
|
||||
namespace interaction {
|
||||
|
||||
template <typename T, typename ScaleType>
|
||||
DelayedVariable<T, ScaleType>::DelayedVariable(ScaleType scaleFactor, ScaleType friction)
|
||||
: _scaleFactor(std::move(scaleFactor))
|
||||
, _friction(friction)
|
||||
{
|
||||
ghoul_assert(_friction >= ScaleType(0.0), "Friction must be positive");
|
||||
}
|
||||
|
||||
template <typename T, typename ScaleType>
|
||||
void DelayedVariable<T, ScaleType>::set(T value, double dt) {
|
||||
_targetValue = value;
|
||||
_currentValue = _currentValue + (_targetValue - _currentValue) *
|
||||
glm::min(_scaleFactor * dt, 1.0); // less or equal to 1.0 keeps it stable
|
||||
}
|
||||
|
||||
template <typename T, typename ScaleType>
|
||||
void DelayedVariable<T, ScaleType>::decelerate(double dt) {
|
||||
_currentValue = _currentValue + (- _currentValue) *
|
||||
glm::min(_scaleFactor * _friction * dt, 1.0);
|
||||
// less or equal to 1.0 keeps it stable
|
||||
}
|
||||
|
||||
template <typename T, typename ScaleType>
|
||||
void DelayedVariable<T, ScaleType>::setHard(T value) {
|
||||
_targetValue = value;
|
||||
_currentValue = value;
|
||||
}
|
||||
|
||||
template <typename T, typename ScaleType>
|
||||
void DelayedVariable<T, ScaleType>::setFriction(ScaleType friction) {
|
||||
_friction = friction;
|
||||
ghoul_assert(_friction >= ScaleType(0.0), "Friction must be positive");
|
||||
}
|
||||
|
||||
template <typename T, typename ScaleType>
|
||||
void DelayedVariable<T, ScaleType>::setScaleFactor(ScaleType scaleFactor) {
|
||||
_scaleFactor = scaleFactor;
|
||||
}
|
||||
|
||||
template <typename T, typename ScaleType>
|
||||
T DelayedVariable<T, ScaleType>::get() const {
|
||||
return _currentValue;
|
||||
}
|
||||
|
||||
} // namespace interaction
|
||||
} // namespace openspace
|
||||
70
include/openspace/interaction/inputstate.h
Normal file
70
include/openspace/interaction/inputstate.h
Normal file
@@ -0,0 +1,70 @@
|
||||
/*****************************************************************************************
|
||||
* *
|
||||
* OpenSpace *
|
||||
* *
|
||||
* Copyright (c) 2014-2017 *
|
||||
* *
|
||||
* 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___INPUTSTATE___H__
|
||||
#define __OPENSPACE_CORE___INPUTSTATE___H__
|
||||
|
||||
#include <openspace/util/keys.h>
|
||||
#include <openspace/util/mouse.h>
|
||||
|
||||
#include <glm/glm.hpp>
|
||||
|
||||
#include <list>
|
||||
|
||||
namespace openspace {
|
||||
namespace interaction {
|
||||
|
||||
class InputState {
|
||||
public:
|
||||
InputState() = default;
|
||||
~InputState() = default;
|
||||
|
||||
// Callback functions
|
||||
void keyboardCallback(Key key, KeyModifier modifier, KeyAction action);
|
||||
void mouseButtonCallback(MouseButton button, MouseAction action);
|
||||
void mousePositionCallback(double mouseX, double mouseY);
|
||||
void mouseScrollWheelCallback(double mouseScrollDelta);
|
||||
|
||||
// Accessors
|
||||
const std::list<std::pair<Key, KeyModifier>>& getPressedKeys() const;
|
||||
const std::list<MouseButton>& getPressedMouseButtons() const;
|
||||
glm::dvec2 getMousePosition() const;
|
||||
double getMouseScrollDelta() const;
|
||||
|
||||
bool isKeyPressed(std::pair<Key, KeyModifier> keyModPair) const;
|
||||
bool isKeyPressed(Key key) const;
|
||||
bool isMouseButtonPressed(MouseButton mouseButton) const;
|
||||
|
||||
private:
|
||||
// Input from keyboard and mouse
|
||||
std::list<std::pair<Key, KeyModifier>> _keysDown;
|
||||
std::list<MouseButton> _mouseButtonsDown;
|
||||
glm::dvec2 _mousePosition;
|
||||
double _mouseScrollDelta;
|
||||
};
|
||||
|
||||
} // namespace interaction
|
||||
} // namespace openspace
|
||||
|
||||
#endif // __OPENSPACE_CORE___INPUTSTATE___H__
|
||||
@@ -1,286 +0,0 @@
|
||||
/*****************************************************************************************
|
||||
* *
|
||||
* OpenSpace *
|
||||
* *
|
||||
* Copyright (c) 2014-2017 *
|
||||
* *
|
||||
* 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___INTERACTIONMODE___H__
|
||||
#define __OPENSPACE_CORE___INTERACTIONMODE___H__
|
||||
|
||||
#include <openspace/network/parallelconnection.h>
|
||||
#include <openspace/util/mouse.h>
|
||||
#include <openspace/util/keys.h>
|
||||
#include <openspace/util/timeline.h>
|
||||
|
||||
#ifdef OPENSPACE_MODULE_GLOBEBROWSING_ENABLED
|
||||
#include <modules/globebrowsing/tile/tileindex.h>
|
||||
#include <modules/globebrowsing/geometry/geodetic2.h>
|
||||
#include <modules/globebrowsing/geometry/geodetic3.h>
|
||||
#endif
|
||||
|
||||
#include <list>
|
||||
|
||||
namespace openspace {
|
||||
|
||||
class Camera;
|
||||
class SceneGraphNode;
|
||||
|
||||
namespace globebrowsing {
|
||||
class RenderableGlobe;
|
||||
}
|
||||
|
||||
namespace interaction {
|
||||
|
||||
template <typename T>
|
||||
class Interpolator
|
||||
{
|
||||
public:
|
||||
Interpolator(std::function<T(double)> transferFunction)
|
||||
: _t(0.0)
|
||||
, _transferFunction(transferFunction) {};
|
||||
~Interpolator() {};
|
||||
|
||||
void start() { _t = 0.0; };
|
||||
void end() { _t = 1.0; };
|
||||
void step(double delta) { _t += delta; };
|
||||
|
||||
T value() { return _transferFunction(_t); };
|
||||
bool isInterpolating() { return _t < 1.0; };
|
||||
private:
|
||||
std::function<T(double)> _transferFunction;
|
||||
double _t;
|
||||
};
|
||||
|
||||
class InputState
|
||||
{
|
||||
public:
|
||||
InputState();
|
||||
~InputState();
|
||||
|
||||
// Callback functions
|
||||
void keyboardCallback(Key key, KeyModifier modifier, KeyAction action);
|
||||
void mouseButtonCallback(MouseButton button, MouseAction action);
|
||||
void mousePositionCallback(double mouseX, double mouseY);
|
||||
void mouseScrollWheelCallback(double mouseScrollDelta);
|
||||
|
||||
// Accessors
|
||||
const std::list<std::pair<Key, KeyModifier> >& getPressedKeys() const;
|
||||
const std::list<MouseButton>& getPressedMouseButtons() const;
|
||||
glm::dvec2 getMousePosition() const;
|
||||
double getMouseScrollDelta() const;
|
||||
const std::vector<datamessagestructures::CameraKeyframe>& keyframes() const;
|
||||
|
||||
bool isKeyPressed(std::pair<Key, KeyModifier> keyModPair) const;
|
||||
bool isKeyPressed(Key key) const;
|
||||
bool isMouseButtonPressed(MouseButton mouseButton) const;
|
||||
private:
|
||||
// Input from keyboard and mouse
|
||||
std::list<std::pair<Key, KeyModifier> > _keysDown;
|
||||
std::list<MouseButton> _mouseButtonsDown;
|
||||
glm::dvec2 _mousePosition;
|
||||
double _mouseScrollDelta;
|
||||
};
|
||||
|
||||
|
||||
|
||||
class InteractionMode {
|
||||
public:
|
||||
InteractionMode();
|
||||
virtual ~InteractionMode();
|
||||
|
||||
// Mutators
|
||||
virtual void setFocusNode(SceneGraphNode* focusNode);
|
||||
|
||||
// Accessors
|
||||
SceneGraphNode* focusNode();
|
||||
Interpolator<double>& rotateToFocusNodeInterpolator();
|
||||
virtual bool followingNodeRotation() const = 0;
|
||||
|
||||
virtual void updateMouseStatesFromInput(const InputState& inputState, double deltaTime) = 0;
|
||||
virtual void updateCameraStateFromMouseStates(Camera& camera, double deltaTime) = 0;
|
||||
|
||||
protected:
|
||||
/**
|
||||
Inner class that acts as a smoothing filter to a variable. The filter has a step
|
||||
response on a form that resembles the function y = 1-e^(-t/scale). The variable
|
||||
will be updates as soon as it is set to a value (calling the set() function).
|
||||
*/
|
||||
template <typename T, typename ScaleType>
|
||||
class DelayedVariable {
|
||||
public:
|
||||
DelayedVariable(ScaleType scaleFactor, ScaleType friction) {
|
||||
_scaleFactor = scaleFactor;
|
||||
_friction = glm::max(friction, ScaleType(0.0));
|
||||
}
|
||||
void set(T value, double dt) {
|
||||
_targetValue = value;
|
||||
_currentValue = _currentValue + (_targetValue - _currentValue) *
|
||||
std::min(_scaleFactor * dt, 1.0); // less or equal to 1.0 keeps it stable
|
||||
}
|
||||
void decelerate(double dt) {
|
||||
_currentValue = _currentValue + (- _currentValue) *
|
||||
std::min(_scaleFactor * _friction * dt, 1.0); // less or equal to 1.0 keeps it stable
|
||||
}
|
||||
void setHard(T value) {
|
||||
_targetValue = value;
|
||||
_currentValue = value;
|
||||
}
|
||||
void setFriction(ScaleType friction) {
|
||||
_friction = glm::max(friction, ScaleType(0.0));
|
||||
}
|
||||
void setScaleFactor(ScaleType scaleFactor) {
|
||||
_scaleFactor = scaleFactor;
|
||||
}
|
||||
T get() {
|
||||
return _currentValue;
|
||||
}
|
||||
private:
|
||||
ScaleType _scaleFactor;
|
||||
ScaleType _friction;
|
||||
T _targetValue;
|
||||
T _currentValue;
|
||||
};
|
||||
|
||||
struct MouseState {
|
||||
MouseState(double scaleFactor)
|
||||
: velocity(scaleFactor, 1)
|
||||
, previousPosition(0.0, 0.0) {}
|
||||
void setFriction(double friction) {
|
||||
velocity.setFriction(friction);
|
||||
}
|
||||
void setVelocityScaleFactor(double scaleFactor) {
|
||||
velocity.setScaleFactor(scaleFactor);
|
||||
}
|
||||
glm::dvec2 previousPosition;
|
||||
DelayedVariable<glm::dvec2, double> velocity;
|
||||
};
|
||||
|
||||
SceneGraphNode* _focusNode = nullptr;
|
||||
glm::dvec3 _previousFocusNodePosition;
|
||||
glm::dquat _previousFocusNodeRotation;
|
||||
|
||||
|
||||
Interpolator<double> _rotateToFocusNodeInterpolator;
|
||||
};
|
||||
|
||||
class KeyframeInteractionMode : public InteractionMode
|
||||
{
|
||||
public:
|
||||
struct CameraPose {
|
||||
glm::dvec3 position;
|
||||
glm::quat rotation;
|
||||
std::string focusNode;
|
||||
bool followFocusNodeRotation;
|
||||
};
|
||||
|
||||
KeyframeInteractionMode();
|
||||
~KeyframeInteractionMode();
|
||||
|
||||
virtual void updateMouseStatesFromInput(const InputState& inputState, double deltaTime);
|
||||
virtual void updateCameraStateFromMouseStates(Camera& camera, double deltaTime);
|
||||
bool followingNodeRotation() const override;
|
||||
Timeline<CameraPose>& timeline();
|
||||
|
||||
private:
|
||||
Timeline<CameraPose> _cameraPoseTimeline;
|
||||
};
|
||||
|
||||
class GlobeBrowsingInteractionMode;
|
||||
|
||||
class OrbitalInteractionMode : public InteractionMode
|
||||
{
|
||||
public:
|
||||
class MouseStates
|
||||
{
|
||||
public:
|
||||
/**
|
||||
\param sensitivity
|
||||
\param velocityScaleFactor can be set to 60 to remove the inertia of the
|
||||
interaction. Lower value will make it harder to move the camera.
|
||||
*/
|
||||
MouseStates(double sensitivity, double velocityScaleFactor);
|
||||
void updateMouseStatesFromInput(const InputState& inputState, double deltaTime);
|
||||
void setRotationalFriction(double friction);
|
||||
void setHorizontalFriction(double friction);
|
||||
void setVerticalFriction(double friction);
|
||||
void setSensitivity(double sensitivity);
|
||||
void setVelocityScaleFactor(double scaleFactor);
|
||||
|
||||
glm::dvec2 synchedGlobalRotationMouseVelocity();
|
||||
glm::dvec2 synchedLocalRotationMouseVelocity();
|
||||
glm::dvec2 synchedTruckMovementMouseVelocity();
|
||||
glm::dvec2 synchedLocalRollMouseVelocity();
|
||||
glm::dvec2 synchedGlobalRollMouseVelocity();
|
||||
|
||||
private:
|
||||
double _sensitivity;
|
||||
|
||||
MouseState _globalRotationMouseState;
|
||||
MouseState _localRotationMouseState;
|
||||
MouseState _truckMovementMouseState;
|
||||
MouseState _localRollMouseState;
|
||||
MouseState _globalRollMouseState;
|
||||
};
|
||||
|
||||
OrbitalInteractionMode(std::shared_ptr<MouseStates> mouseStates);
|
||||
~OrbitalInteractionMode();
|
||||
|
||||
//virtual void update(Camera& camera, const InputState& inputState, double deltaTime);
|
||||
|
||||
virtual void updateMouseStatesFromInput(const InputState& inputState, double deltaTime);
|
||||
virtual void updateCameraStateFromMouseStates(Camera& camera, double deltaTime);
|
||||
bool followingNodeRotation() const override;
|
||||
|
||||
protected:
|
||||
//void updateCameraStateFromMouseStates(Camera& camera, double deltaTime);
|
||||
std::shared_ptr<MouseStates> _mouseStates;
|
||||
};
|
||||
|
||||
class GlobeBrowsingInteractionMode : public OrbitalInteractionMode
|
||||
{
|
||||
public:
|
||||
GlobeBrowsingInteractionMode(std::shared_ptr<MouseStates> mouseStates);
|
||||
~GlobeBrowsingInteractionMode();
|
||||
|
||||
virtual void setFocusNode(SceneGraphNode* focusNode);
|
||||
//virtual void update(Camera& camera, const InputState& inputState, double deltaTime);
|
||||
virtual void updateCameraStateFromMouseStates(Camera& camera, double deltaTime);
|
||||
bool followingNodeRotation() const override;
|
||||
#ifdef OPENSPACE_MODULE_GLOBEBROWSING_ENABLED
|
||||
void goToChunk(Camera& camera, globebrowsing::TileIndex ti, glm::vec2 uv,
|
||||
bool resetCameraDirection);
|
||||
void goToGeodetic2(Camera& camera, globebrowsing::Geodetic2 geo2,
|
||||
bool resetCameraDirection);
|
||||
|
||||
void goToGeodetic3(Camera& camera, globebrowsing::Geodetic3 geo3);
|
||||
void resetCameraDirection(Camera& camera, globebrowsing::Geodetic2 geo2);
|
||||
#endif
|
||||
private:
|
||||
//void updateCameraStateFromMouseStates(Camera& camera, double deltaTime);
|
||||
#ifdef OPENSPACE_MODULE_GLOBEBROWSING_ENABLED
|
||||
globebrowsing::RenderableGlobe* _globe;
|
||||
#endif
|
||||
};
|
||||
|
||||
} // namespace interaction
|
||||
} // namespace openspace
|
||||
|
||||
#endif // __OPENSPACE_CORE___INTERACTIONMODE___H__
|
||||
65
include/openspace/interaction/interpolator.h
Normal file
65
include/openspace/interaction/interpolator.h
Normal file
@@ -0,0 +1,65 @@
|
||||
/*****************************************************************************************
|
||||
* *
|
||||
* OpenSpace *
|
||||
* *
|
||||
* Copyright (c) 2014-2017 *
|
||||
* *
|
||||
* 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___INTERPOLATOR___H__
|
||||
#define __OPENSPACE_CORE___INTERPOLATOR___H__
|
||||
|
||||
#include <functional>
|
||||
|
||||
namespace openspace {
|
||||
namespace interaction {
|
||||
|
||||
/*
|
||||
* Interpolates a typename T using a transfer function.
|
||||
*/
|
||||
template <typename T>
|
||||
class Interpolator {
|
||||
public:
|
||||
Interpolator();
|
||||
~Interpolator() = default;
|
||||
|
||||
void start();
|
||||
void end();
|
||||
void setDeltaTime(float deltaTime);
|
||||
void setTransferFunction(std::function<T(float)> transferFunction);
|
||||
void setInterpolationTime(float interpolationTime);
|
||||
void step();
|
||||
|
||||
float deltaTimeScaled() const;
|
||||
T value() const;
|
||||
bool isInterpolating() const;
|
||||
|
||||
private:
|
||||
std::function<T(float)> _transferFunction;
|
||||
float _t;
|
||||
float _interpolationTime;
|
||||
float _scaledDeltaTime;
|
||||
};
|
||||
|
||||
} // namespace interaction
|
||||
} // namespace openspace
|
||||
|
||||
#include "interpolator.inl"
|
||||
|
||||
#endif // __OPENSPACE_CORE___INTERPOLATOR___H__
|
||||
85
include/openspace/interaction/interpolator.inl
Normal file
85
include/openspace/interaction/interpolator.inl
Normal file
@@ -0,0 +1,85 @@
|
||||
/*****************************************************************************************
|
||||
* *
|
||||
* OpenSpace *
|
||||
* *
|
||||
* Copyright (c) 2014-2017 *
|
||||
* *
|
||||
* 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 <ghoul/misc/assert.h>
|
||||
|
||||
#include <functional>
|
||||
|
||||
namespace openspace {
|
||||
namespace interaction {
|
||||
|
||||
template <typename T>
|
||||
Interpolator<T>::Interpolator()
|
||||
: _transferFunction([](float t){ return t; })
|
||||
, _t(0.0)
|
||||
, _interpolationTime(1.0) {};
|
||||
|
||||
template <typename T>
|
||||
void Interpolator<T>::start() {
|
||||
_t = 0.0;
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
void Interpolator<T>::end() {
|
||||
_t = 1.0;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void Interpolator<T>::setDeltaTime(float deltaTime) {
|
||||
_scaledDeltaTime = deltaTime / _interpolationTime;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void Interpolator<T>::setTransferFunction(std::function<T(float)> transferFunction) {
|
||||
_transferFunction = transferFunction;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void Interpolator<T>::setInterpolationTime(float interpolationTime) {
|
||||
_interpolationTime = interpolationTime;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void Interpolator<T>::step() {
|
||||
_t += _scaledDeltaTime;
|
||||
_t = glm::clamp(_t, 0.0f, 1.0f);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
float Interpolator<T>::deltaTimeScaled() const {
|
||||
return _scaledDeltaTime;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
T Interpolator<T>::value() const {
|
||||
return _transferFunction(_t);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
bool Interpolator<T>::isInterpolating() const {
|
||||
return _t < 1.0 && _t >= 0.0;
|
||||
}
|
||||
|
||||
} // namespace interaction
|
||||
} // namespace openspace
|
||||
87
include/openspace/interaction/keybindingmanager.h
Normal file
87
include/openspace/interaction/keybindingmanager.h
Normal file
@@ -0,0 +1,87 @@
|
||||
/*****************************************************************************************
|
||||
* *
|
||||
* OpenSpace *
|
||||
* *
|
||||
* Copyright (c) 2014-2017 *
|
||||
* *
|
||||
* 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___KEYBINDINGMANAGER___H__
|
||||
#define __OPENSPACE_CORE___KEYBINDINGMANAGER___H__
|
||||
|
||||
#include <openspace/documentation/documentationgenerator.h>
|
||||
#include <openspace/scripting/lualibrary.h>
|
||||
#include <openspace/util/keys.h>
|
||||
|
||||
#include <ghoul/misc/boolean.h>
|
||||
|
||||
namespace openspace {
|
||||
|
||||
class Camera;
|
||||
class SceneGraphNode;
|
||||
|
||||
namespace interaction {
|
||||
|
||||
class KeyBindingManager : public DocumentationGenerator
|
||||
{
|
||||
public:
|
||||
KeyBindingManager();
|
||||
~KeyBindingManager() = default;
|
||||
|
||||
void resetKeyBindings();
|
||||
|
||||
void bindKeyLocal(
|
||||
Key key,
|
||||
KeyModifier modifier,
|
||||
std::string luaCommand,
|
||||
std::string documentation = ""
|
||||
);
|
||||
|
||||
void bindKey(
|
||||
Key key,
|
||||
KeyModifier modifier,
|
||||
std::string luaCommand,
|
||||
std::string documentation = ""
|
||||
);
|
||||
|
||||
static scripting::LuaLibrary luaLibrary();
|
||||
|
||||
// Callback functions
|
||||
void keyboardCallback(Key key, KeyModifier modifier, KeyAction action);
|
||||
|
||||
private:
|
||||
using Synchronized = ghoul::Boolean;
|
||||
|
||||
struct KeyInformation {
|
||||
std::string command;
|
||||
Synchronized synchronization;
|
||||
std::string documentation;
|
||||
};
|
||||
|
||||
std::string generateJson() const override;
|
||||
|
||||
bool _cameraUpdatedFromScript = false;
|
||||
|
||||
std::multimap<KeyWithModifier, KeyInformation> _keyLua;
|
||||
};
|
||||
|
||||
} // namespace interaction
|
||||
} // namespace openspace
|
||||
|
||||
#endif // __OPENSPACE_CORE___KEYBINDINGMANAGER___H__
|
||||
69
include/openspace/interaction/keyframenavigator.h
Normal file
69
include/openspace/interaction/keyframenavigator.h
Normal file
@@ -0,0 +1,69 @@
|
||||
/*****************************************************************************************
|
||||
* *
|
||||
* OpenSpace *
|
||||
* *
|
||||
* Copyright (c) 2014-2017 *
|
||||
* *
|
||||
* 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___KEYFRAMENAVIGATOR___H__
|
||||
#define __OPENSPACE_CORE___KEYFRAMENAVIGATOR___H__
|
||||
|
||||
#include <openspace/util/timeline.h>
|
||||
#include <openspace/network/parallelconnection.h>
|
||||
|
||||
#include <glm/glm.hpp>
|
||||
#include <glm/gtx/quaternion.hpp>
|
||||
|
||||
namespace openspace {
|
||||
|
||||
class Camera;
|
||||
|
||||
namespace interaction {
|
||||
|
||||
class KeyframeNavigator
|
||||
{
|
||||
public:
|
||||
struct CameraPose {
|
||||
glm::dvec3 position;
|
||||
glm::quat rotation;
|
||||
std::string focusNode;
|
||||
bool followFocusNodeRotation;
|
||||
};
|
||||
|
||||
KeyframeNavigator() = default;
|
||||
~KeyframeNavigator() = default;
|
||||
|
||||
void updateCamera(Camera& camera);
|
||||
Timeline<CameraPose>& timeline();
|
||||
|
||||
void addKeyframe(double timestamp, KeyframeNavigator::CameraPose pose);
|
||||
void removeKeyframesAfter(double timestamp);
|
||||
void clearKeyframes();
|
||||
size_t nKeyframes() const;
|
||||
const std::vector<datamessagestructures::CameraKeyframe>& keyframes() const;
|
||||
|
||||
private:
|
||||
Timeline<CameraPose> _cameraPoseTimeline;
|
||||
};
|
||||
|
||||
} // namespace interaction
|
||||
} // namespace openspace
|
||||
|
||||
#endif // __OPENSPACE_CORE___KEYFRAMENAVIGATOR___H__
|
||||
80
include/openspace/interaction/mousestate.h
Normal file
80
include/openspace/interaction/mousestate.h
Normal file
@@ -0,0 +1,80 @@
|
||||
/*****************************************************************************************
|
||||
* *
|
||||
* OpenSpace *
|
||||
* *
|
||||
* Copyright (c) 2014-2017 *
|
||||
* *
|
||||
* 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___MOUSESTATE___H__
|
||||
#define __OPENSPACE_CORE___MOUSESTATE___H__
|
||||
|
||||
#include <openspace/interaction/delayedvariable.h>
|
||||
#include <openspace/interaction/inputstate.h>
|
||||
|
||||
#include <glm/glm.hpp>
|
||||
|
||||
namespace openspace {
|
||||
namespace interaction {
|
||||
|
||||
struct MouseState {
|
||||
MouseState(double scaleFactor);
|
||||
void setFriction(double friction);
|
||||
void setVelocityScaleFactor(double scaleFactor);
|
||||
|
||||
glm::dvec2 previousPosition;
|
||||
DelayedVariable<glm::dvec2, double> velocity;
|
||||
};
|
||||
|
||||
class MouseStates
|
||||
{
|
||||
public:
|
||||
/**
|
||||
\param sensitivity
|
||||
\param velocityScaleFactor can be set to 60 to remove the inertia of the
|
||||
interaction. Lower value will make it harder to move the camera.
|
||||
*/
|
||||
MouseStates(double sensitivity, double velocityScaleFactor);
|
||||
void updateMouseStatesFromInput(const InputState& inputState, double deltaTime);
|
||||
void setRotationalFriction(double friction);
|
||||
void setHorizontalFriction(double friction);
|
||||
void setVerticalFriction(double friction);
|
||||
void setSensitivity(double sensitivity);
|
||||
void setVelocityScaleFactor(double scaleFactor);
|
||||
|
||||
glm::dvec2 globalRotationMouseVelocity() const;
|
||||
glm::dvec2 localRotationMouseVelocity() const;
|
||||
glm::dvec2 truckMovementMouseVelocity() const;
|
||||
glm::dvec2 localRollMouseVelocity() const;
|
||||
glm::dvec2 globalRollMouseVelocity() const;
|
||||
|
||||
private:
|
||||
double _sensitivity;
|
||||
|
||||
MouseState _globalRotationMouseState;
|
||||
MouseState _localRotationMouseState;
|
||||
MouseState _truckMovementMouseState;
|
||||
MouseState _localRollMouseState;
|
||||
MouseState _globalRollMouseState;
|
||||
};
|
||||
|
||||
} // namespace interaction
|
||||
} // namespace openspace
|
||||
|
||||
#endif // __OPENSPACE_CORE___MOUSESTATE___H__
|
||||
@@ -22,14 +22,13 @@
|
||||
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
|
||||
****************************************************************************************/
|
||||
|
||||
#ifndef __OPENSPACE_CORE___INTERACTIONHANDLER___H__
|
||||
#define __OPENSPACE_CORE___INTERACTIONHANDLER___H__
|
||||
#ifndef __OPENSPACE_CORE___NAVIGATIONHANDLER___H__
|
||||
#define __OPENSPACE_CORE___NAVIGATIONHANDLER___H__
|
||||
|
||||
#include <openspace/documentation/documentationgenerator.h>
|
||||
#include <openspace/properties/propertyowner.h>
|
||||
|
||||
#include <openspace/interaction/interactionmode.h>
|
||||
#include <openspace/network/parallelconnection.h>
|
||||
#include <openspace/interaction/orbitalnavigator.h>
|
||||
#include <openspace/interaction/keyframenavigator.h>
|
||||
#include <openspace/properties/stringproperty.h>
|
||||
#include <openspace/properties/scalar/boolproperty.h>
|
||||
#include <openspace/properties/scalar/floatproperty.h>
|
||||
@@ -38,10 +37,6 @@
|
||||
|
||||
#include <ghoul/misc/boolean.h>
|
||||
|
||||
#include <list>
|
||||
|
||||
#include <mutex>
|
||||
|
||||
namespace openspace {
|
||||
|
||||
class Camera;
|
||||
@@ -49,11 +44,10 @@ class SceneGraphNode;
|
||||
|
||||
namespace interaction {
|
||||
|
||||
class InteractionHandler : public properties::PropertyOwner, public DocumentationGenerator
|
||||
{
|
||||
class NavigationHandler : public properties::PropertyOwner {
|
||||
public:
|
||||
InteractionHandler();
|
||||
~InteractionHandler();
|
||||
NavigationHandler();
|
||||
~NavigationHandler();
|
||||
|
||||
void initialize();
|
||||
void deinitialize();
|
||||
@@ -63,39 +57,9 @@ public:
|
||||
void setCamera(Camera* camera);
|
||||
void resetCameraDirection();
|
||||
|
||||
// Interaction mode setters
|
||||
void setCameraStateFromDictionary(const ghoul::Dictionary& cameraDict);
|
||||
InteractionMode* interactionMode();
|
||||
void setCameraStateFromDictionary(const ghoul::Dictionary& cameraDict);
|
||||
|
||||
void goToChunk(int x, int y, int level);
|
||||
void goToGeo(double latitude, double longitude);
|
||||
|
||||
void resetKeyBindings();
|
||||
|
||||
void addKeyframe(double timestamp, KeyframeInteractionMode::CameraPose pose);
|
||||
void removeKeyframesAfter(double timestamp);
|
||||
void clearKeyframes();
|
||||
size_t nKeyframes() const;
|
||||
const std::vector<datamessagestructures::CameraKeyframe>& keyframes() const;
|
||||
|
||||
void bindKeyLocal(
|
||||
Key key,
|
||||
KeyModifier modifier,
|
||||
std::string luaCommand,
|
||||
std::string documentation = ""
|
||||
);
|
||||
void bindKey(
|
||||
Key key,
|
||||
KeyModifier modifier,
|
||||
std::string luaCommand,
|
||||
std::string documentation = ""
|
||||
);
|
||||
void lockControls();
|
||||
void unlockControls();
|
||||
|
||||
//void update(double deltaTime);
|
||||
void updateCamera(double deltaTime);
|
||||
void updateInputStates(double timeSinceLastUpdate);
|
||||
|
||||
// Accessors
|
||||
ghoul::Dictionary getCameraStateDictionary();
|
||||
@@ -104,15 +68,8 @@ public:
|
||||
glm::quat focusNodeToCameraRotation() const;
|
||||
Camera* camera() const;
|
||||
const InputState& inputState() const;
|
||||
|
||||
/**
|
||||
* Returns the Lua library that contains all Lua functions available to affect the
|
||||
* interaction. The functions contained are
|
||||
* - openspace::luascriptfunctions::setOrigin
|
||||
* \return The Lua library that contains all Lua functions available to affect the
|
||||
* interaction
|
||||
*/
|
||||
static scripting::LuaLibrary luaLibrary();
|
||||
const OrbitalNavigator& orbitalNavigator() const;
|
||||
KeyframeNavigator& keyframeNavigator() const;
|
||||
|
||||
// Callback functions
|
||||
void keyboardCallback(Key key, KeyModifier modifier, KeyAction action);
|
||||
@@ -123,47 +80,26 @@ public:
|
||||
void saveCameraStateToFile(const std::string& filepath);
|
||||
void restoreCameraStateFromFile(const std::string& filepath);
|
||||
|
||||
/**
|
||||
* \return The Lua library that contains all Lua functions available to affect the
|
||||
* interaction
|
||||
*/
|
||||
static scripting::LuaLibrary luaLibrary();
|
||||
private:
|
||||
using Synchronized = ghoul::Boolean;
|
||||
|
||||
struct KeyInformation {
|
||||
std::string command;
|
||||
Synchronized synchronization;
|
||||
std::string documentation;
|
||||
};
|
||||
|
||||
std::string generateJson() const override;
|
||||
|
||||
void setInteractionMode(InteractionMode* interactionMode);
|
||||
|
||||
bool _cameraUpdatedFromScript = false;
|
||||
|
||||
std::multimap<KeyWithModifier, KeyInformation> _keyLua;
|
||||
|
||||
std::unique_ptr<InputState> _inputState;
|
||||
Camera* _camera;
|
||||
|
||||
InteractionMode* _currentInteractionMode;
|
||||
|
||||
std::shared_ptr<OrbitalInteractionMode::MouseStates> _mouseStates;
|
||||
|
||||
std::unique_ptr<OrbitalInteractionMode> _orbitalInteractionMode;
|
||||
std::unique_ptr<GlobeBrowsingInteractionMode> _globeBrowsingInteractionMode;
|
||||
std::unique_ptr<KeyframeInteractionMode> _keyframeInteractionMode;
|
||||
std::unique_ptr<OrbitalNavigator> _orbitalNavigator;
|
||||
std::unique_ptr<KeyframeNavigator> _keyframeNavigator;
|
||||
|
||||
// Properties
|
||||
properties::StringProperty _origin;
|
||||
properties::OptionProperty _interactionModeOption;
|
||||
|
||||
properties::BoolProperty _rotationalFriction;
|
||||
properties::BoolProperty _horizontalFriction;
|
||||
properties::BoolProperty _verticalFriction;
|
||||
|
||||
properties::FloatProperty _sensitivity;
|
||||
properties::FloatProperty _rapidness;
|
||||
properties::BoolProperty _useKeyFrameInteraction;
|
||||
};
|
||||
|
||||
} // namespace interaction
|
||||
} // namespace openspace
|
||||
|
||||
#endif // __OPENSPACE_CORE___INTERACTIONHANDLER___H__
|
||||
#endif // __OPENSPACE_CORE___NAVIGATIONHANDLER___H__
|
||||
197
include/openspace/interaction/orbitalnavigator.h
Normal file
197
include/openspace/interaction/orbitalnavigator.h
Normal file
@@ -0,0 +1,197 @@
|
||||
/*****************************************************************************************
|
||||
* *
|
||||
* OpenSpace *
|
||||
* *
|
||||
* Copyright (c) 2014-2017 *
|
||||
* *
|
||||
* 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___ORBITALNAVIGATOR___H__
|
||||
#define __OPENSPACE_CORE___ORBITALNAVIGATOR___H__
|
||||
|
||||
#include <openspace/interaction/delayedvariable.h>
|
||||
#include <openspace/interaction/inputstate.h>
|
||||
#include <openspace/interaction/interpolator.h>
|
||||
#include <openspace/interaction/mousestate.h>
|
||||
|
||||
#include <openspace/properties/propertyowner.h>
|
||||
#include <openspace/properties/scalar/boolproperty.h>
|
||||
#include <openspace/properties/scalar/floatproperty.h>
|
||||
|
||||
#include <glm/glm.hpp>
|
||||
#include <glm/gtx/quaternion.hpp>
|
||||
|
||||
namespace openspace {
|
||||
|
||||
class SceneGraphNode;
|
||||
class Camera;
|
||||
class SurfacePositionHandle;
|
||||
|
||||
namespace interaction {
|
||||
|
||||
class OrbitalNavigator : public properties::PropertyOwner {
|
||||
public:
|
||||
OrbitalNavigator();
|
||||
~OrbitalNavigator();
|
||||
|
||||
void updateMouseStatesFromInput(const InputState& inputState, double deltaTime);
|
||||
void updateCameraStateFromMouseStates(Camera& camera, double deltaTime);
|
||||
void setFocusNode(SceneGraphNode* focusNode);
|
||||
void startInterpolateCameraDirection(const Camera& camera);
|
||||
|
||||
bool followingNodeRotation() const;
|
||||
SceneGraphNode* focusNode() const;
|
||||
|
||||
private:
|
||||
struct CameraRotationDecomposition {
|
||||
glm::dquat localRotation;
|
||||
glm::dquat globalRotation;
|
||||
};
|
||||
|
||||
// Properties
|
||||
properties::BoolProperty _rotationalFriction;
|
||||
properties::BoolProperty _horizontalFriction;
|
||||
properties::BoolProperty _verticalFriction;
|
||||
properties::FloatProperty _followFocusNodeRotationDistance;
|
||||
properties::FloatProperty _minimumAllowedDistance;
|
||||
properties::FloatProperty _sensitivity;
|
||||
properties::FloatProperty _motionLag;
|
||||
|
||||
MouseStates _mouseStates;
|
||||
|
||||
SceneGraphNode* _focusNode = nullptr;
|
||||
glm::dvec3 _previousFocusNodePosition;
|
||||
glm::dquat _previousFocusNodeRotation;
|
||||
|
||||
Interpolator<double> _rotateToFocusNodeInterpolator;
|
||||
Interpolator<double> _followRotationInterpolator;
|
||||
|
||||
/**
|
||||
* Decomposes the cameras rotation in to a global and a local rotation defined by
|
||||
* CameraRotationDecomposition. The global rotation defines the rotation so that the
|
||||
* camera points towards the focus node in the direction opposite to the direction
|
||||
* out from the surface of the object. The local rotation defines the differential
|
||||
* from the global to the current total rotation so that
|
||||
* <code>cameraRotation = globalRotation * localRotation</code>.
|
||||
*/
|
||||
CameraRotationDecomposition decomposeCameraRotation(
|
||||
const glm::dvec3& cameraPosition,
|
||||
const glm::dquat& cameraRotation,
|
||||
const glm::dvec3& cameraLookUp,
|
||||
const glm::dvec3& cameraViewDirection);
|
||||
|
||||
/*
|
||||
* Perform a camera roll on the local camera rotation
|
||||
* \returns a local camera rotation modified with a roll.
|
||||
*/
|
||||
glm::dquat roll(double deltaTime, const glm::dquat& localCameraRotation) const;
|
||||
|
||||
/**
|
||||
* Performs rotation around the cameras x and y axes.
|
||||
* \returns a local camera rotation modified with two degrees of freedom.
|
||||
*/
|
||||
glm::dquat rotateLocally(double deltaTime,
|
||||
const glm::dquat& localCameraRotation) const;
|
||||
|
||||
/**
|
||||
* Interpolates the local rotation towards a 0 rotation.
|
||||
* \returns a modified local rotation interpolated towards 0.
|
||||
*/
|
||||
glm::dquat interpolateLocalRotation(double deltaTime,
|
||||
const glm::dquat& localCameraRotation);
|
||||
|
||||
/**
|
||||
* Translates the horizontal direction. If far from the focus object, this will
|
||||
* result in an orbital rotation around the object. This function does not affect the
|
||||
* rotation but only the position.
|
||||
* \returns a position vector adjusted in the horizontal direction.
|
||||
*/
|
||||
glm::dvec3 translateHorizontally(double deltaTime, const glm::dvec3& cameraPosition,
|
||||
const glm::dvec3& objectPosition,
|
||||
const glm::dquat& focusNodeRotationDiff,
|
||||
const glm::dquat& globalCameraRotation,
|
||||
const SurfacePositionHandle& positionHandle) const;
|
||||
|
||||
/*
|
||||
* Adds rotation to the camera position so that it follows the rotation of the focus
|
||||
* node defined by the differential focusNodeRotationDiff.
|
||||
* \returns a position updated with the rotation defined by focusNodeRotationDiff
|
||||
*/
|
||||
glm::dvec3 followFocusNodeRotation(const glm::dvec3& cameraPosition,
|
||||
const glm::dvec3& objectPosition,
|
||||
const glm::dquat& focusNodeRotationDiff) const;
|
||||
|
||||
/**
|
||||
* Updates the global rotation so that it points towards the focus node.
|
||||
* \returns a global rotation quaternion defining a rotation towards the focus node.
|
||||
*/
|
||||
glm::dquat rotateGlobally(const glm::dquat& globalCameraRotation,
|
||||
const glm::dvec3& objectPosition,
|
||||
const glm::dquat& focusNodeRotationDiff,
|
||||
const glm::dvec3& cameraPosition,
|
||||
const SurfacePositionHandle& positionHandle) const;
|
||||
|
||||
/**
|
||||
* Translates the camera position towards or away from the focus node.
|
||||
* \returns a position vector adjusted in the vertical direction.
|
||||
*/
|
||||
glm::dvec3 translateVertically(double deltaTime, const glm::dvec3& cameraPosition,
|
||||
const glm::dvec3& objectPosition,
|
||||
const SurfacePositionHandle& positionHandle) const;
|
||||
|
||||
/**
|
||||
* Rotates the camera around the out vector of the surface.
|
||||
* \returns a quaternion adjusted to rotate around the out vector of the surface.
|
||||
*/
|
||||
glm::dquat rotateHorizontally(double deltaTime,
|
||||
const glm::dquat& globalCameraRotation,
|
||||
const glm::dvec3& cameraPosition,
|
||||
const SurfacePositionHandle& positionHandle) const;
|
||||
|
||||
/**
|
||||
* Push the camera out to the surface of the object.
|
||||
* \returns a position vector adjusted to be at least minHeightAboveGround meters
|
||||
* above the actual surface of the object
|
||||
*/
|
||||
glm::dvec3 pushToSurface(double minHeightAboveGround,
|
||||
const glm::dvec3& cameraPosition,
|
||||
const glm::dvec3& objectPosition,
|
||||
const SurfacePositionHandle& positionHandle) const;
|
||||
|
||||
/**
|
||||
* Interpolates between rotationDiff and a 0 rotation.
|
||||
*/
|
||||
glm::dquat interpolateRotationDifferential(
|
||||
double deltaTime, double interpolationTime,
|
||||
const glm::dquat& rotationDiff,
|
||||
const glm::dvec3& objectPosition,
|
||||
const glm::dvec3& cameraPosition,
|
||||
const SurfacePositionHandle& positionHandle);
|
||||
|
||||
/**
|
||||
* Calculates a SurfacePositionHandle given a camera position in world space.
|
||||
*/
|
||||
SurfacePositionHandle calculateSurfacePositionHandle(
|
||||
const glm::dvec3 cameraPositionWorldSpace);
|
||||
};
|
||||
|
||||
} // namespace interaction
|
||||
} // namespace openspace
|
||||
|
||||
#endif // __OPENSPACE_CORE___ORBITALNAVIGATOR___H__
|
||||
@@ -58,14 +58,41 @@ public:
|
||||
void storeIndividualPerformanceMeasurement(std::string identifier, long long nanoseconds);
|
||||
void storeScenePerformanceMeasurements(const std::vector<SceneGraphNode*>& sceneNodes);
|
||||
|
||||
PerformanceLayout* performanceData();
|
||||
void outputLogs();
|
||||
|
||||
void writeData(std::ofstream& out, const std::vector<float>& data);
|
||||
|
||||
std::string formatLogName(std::string nodeName);
|
||||
|
||||
void logDir(std::string dir);
|
||||
std::string logDir() const;
|
||||
void prefix(std::string prefix);
|
||||
std::string prefix() const;
|
||||
|
||||
void enableLogging();
|
||||
void disableLogging();
|
||||
void toggleLogging();
|
||||
void setLogging(bool enabled);
|
||||
bool loggingEnabled() const;
|
||||
|
||||
PerformanceLayout* performanceData();
|
||||
private:
|
||||
bool _doPerformanceMeasurements;
|
||||
bool _loggingEnabled;
|
||||
|
||||
std::string _logDir;
|
||||
std::string _prefix;
|
||||
std::string _suffix;
|
||||
std::string _ext;
|
||||
|
||||
std::map<std::string, size_t> individualPerformanceLocations;
|
||||
|
||||
std::unique_ptr<ghoul::SharedMemory> _performanceMemory;
|
||||
|
||||
size_t _tick;
|
||||
|
||||
void tick();
|
||||
bool createLogDir();
|
||||
};
|
||||
|
||||
} // namespace performance
|
||||
|
||||
@@ -73,6 +73,14 @@ public:
|
||||
User = 0 ///< Visible in User mode
|
||||
};
|
||||
|
||||
/// An OnChangeHandle is returned by the onChange method to uniquely identify an
|
||||
/// onChange callback
|
||||
using OnChangeHandle = uint32_t;
|
||||
|
||||
/// This OnChangeHandle can be used to remove all onChange callbacks from this
|
||||
/// Property
|
||||
static OnChangeHandle OnChangeHandleAll;
|
||||
|
||||
/**
|
||||
* The constructor for the property. The <code>identifier</code> needs to be unique
|
||||
* for each PropertyOwner. The <code>guiName</code> will be stored in the metaData
|
||||
@@ -92,7 +100,7 @@ public:
|
||||
* The destructor taking care of deallocating all unused memory. This method will not
|
||||
* remove the Property from the PropertyOwner.
|
||||
*/
|
||||
virtual ~Property();
|
||||
virtual ~Property() = default;
|
||||
|
||||
/**
|
||||
* This method returns the class name of the Property. The method is used by the
|
||||
@@ -191,12 +199,25 @@ public:
|
||||
* This method registers a <code>callback</code> function that will be called every
|
||||
* time if either Property:set or Property::setLuaValue was called with a value that
|
||||
* is different from the previously stored value. The callback can be removed by
|
||||
* passing an empty <code>std::function<void()></code> object.
|
||||
* calling the removeOnChange method with the OnChangeHandle that was returned here.
|
||||
* \param callback The callback function that is called when the encapsulated type has
|
||||
* been successfully changed by either the Property::set or Property::setLuaValue
|
||||
* methods.
|
||||
* \pre The callback must not be empty
|
||||
* \return An OnChangeHandle that can be used in subsequent calls to remove a callback
|
||||
*/
|
||||
virtual void onChange(std::function<void()> callback);
|
||||
OnChangeHandle onChange(std::function<void()> callback);
|
||||
|
||||
/**
|
||||
* This method deregisters a callback that was previously registered with the onChange
|
||||
* method. If OnChangeHandleAll is passed to this function, all registered callbacks
|
||||
* are removed.
|
||||
* \param handle An OnChangeHandle that was returned from a previous call to onChange
|
||||
* by this property or OnChangeHandleAll if all callbacks should be removed.
|
||||
* \pre handle must refer to a callback that has been previously registred
|
||||
* \pre handle must refer to a callback that has not been removed previously
|
||||
*/
|
||||
void removeOnChange(OnChangeHandle handle);
|
||||
|
||||
/**
|
||||
* This method returns the unique identifier of this Property.
|
||||
@@ -389,8 +410,11 @@ protected:
|
||||
/// The Dictionary containing all meta data necessary for external applications
|
||||
ghoul::Dictionary _metaData;
|
||||
|
||||
/// The callback function that will be invoked whenever the encapsulated value changes
|
||||
std::function<void()> _onChangeCallback;
|
||||
/// The callback function sthat will be invoked whenever the value changes
|
||||
std::vector<std::pair<OnChangeHandle, std::function<void()>>> _onChangeCallbacks;
|
||||
|
||||
private:
|
||||
OnChangeHandle _currentHandleValue;
|
||||
};
|
||||
|
||||
} // namespace properties
|
||||
|
||||
@@ -42,6 +42,7 @@ namespace openspace {
|
||||
struct RenderData;
|
||||
struct UpdateData;
|
||||
struct RendererTasks;
|
||||
struct SurfacePositionHandle;
|
||||
|
||||
namespace documentation { struct Documentation; }
|
||||
|
||||
@@ -78,6 +79,8 @@ public:
|
||||
virtual void render(const RenderData& data);
|
||||
virtual void render(const RenderData& data, RendererTasks& rendererTask);
|
||||
virtual void update(const UpdateData& data);
|
||||
virtual SurfacePositionHandle calculateSurfacePositionHandle(
|
||||
const glm::dvec3& targetModelSpace);
|
||||
|
||||
RenderBin renderBin() const;
|
||||
void setRenderBin(RenderBin bin);
|
||||
|
||||
@@ -48,6 +48,7 @@ class Translation;
|
||||
class Scale;
|
||||
class Scene;
|
||||
struct UpdateData;
|
||||
struct SurfacePositionHandle;
|
||||
|
||||
namespace documentation { struct Documentation; }
|
||||
|
||||
@@ -93,6 +94,9 @@ public:
|
||||
void clearDependencies();
|
||||
void setDependencies(const std::vector<SceneGraphNode*>& dependencies);
|
||||
|
||||
SurfacePositionHandle calculateSurfacePositionHandle(
|
||||
const glm::dvec3& targetModelSpace);
|
||||
|
||||
const std::vector<SceneGraphNode*>& dependencies() const;
|
||||
const std::vector<SceneGraphNode*>& dependentNodes() const;
|
||||
|
||||
|
||||
@@ -75,6 +75,21 @@ struct RaycastData {
|
||||
std::string namespaceName;
|
||||
};
|
||||
|
||||
/**
|
||||
* Defines the position of an object relative to a surface. The surface is defined as
|
||||
* a reference surface together with a height offset from that reference surface.
|
||||
*/
|
||||
struct SurfacePositionHandle {
|
||||
/// Vector from the center of the object to the reference surface of the object
|
||||
glm::dvec3 centerToReferenceSurface;
|
||||
/// Direction out from the reference. Can conincide with the surface normal but does
|
||||
/// not have to.
|
||||
glm::dvec3 referenceSurfaceOutDirection;
|
||||
/// Height from the reference surface out to the actual surface in the direction of
|
||||
/// the surface normal. Can be positive or negative.
|
||||
double heightToSurface;
|
||||
};
|
||||
|
||||
} // namespace openspace
|
||||
|
||||
#endif // __OPENSPACE_CORE___UPDATESTRUCTURES___H__
|
||||
|
||||
Reference in New Issue
Block a user