Issue/451 (#595)

* Add ability for Joystick input
* Change location of LuaConsole files
This commit is contained in:
Alexander Bock
2018-04-20 16:12:18 -04:00
committed by GitHub
parent a9fa9117f6
commit 3810209365
36 changed files with 2794 additions and 391 deletions
+4 -2
View File
@@ -25,6 +25,7 @@
#ifndef __OPENSPACE_CORE___OPENSPACEENGINE___H__
#define __OPENSPACE_CORE___OPENSPACEENGINE___H__
#include <openspace/interaction/joystickinputstate.h>
#include <openspace/properties/stringproperty.h>
#include <openspace/util/keys.h>
#include <openspace/util/mouse.h>
@@ -60,9 +61,9 @@ class VirtualPropertyManager;
class WindowWrapper;
namespace interaction {
class NavigationHandler;
class KeyBindingManager;
}
class NavigationHandler;
} // namespace interaction
namespace gui { class GUI; }
namespace properties { class PropertyOwner; }
namespace scripting {
@@ -111,6 +112,7 @@ public:
void mouseButtonCallback(MouseButton button, MouseAction action);
void mousePositionCallback(double x, double y);
void mouseScrollWheelCallback(double posX, double posY);
void setJoystickInputStates(interaction::JoystickInputStates& states);
void externalControlCallback(const char* receivedChars, int size, int clientId);
void encode();
void decode();
@@ -22,56 +22,60 @@
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
****************************************************************************************/
#ifndef __OPENSPACE_CORE___MOUSESTATE___H__
#define __OPENSPACE_CORE___MOUSESTATE___H__
#ifndef __OPENSPACE_CORE___INPUTDEVICESTATES___H__
#define __OPENSPACE_CORE___INPUTDEVICESTATES___H__
#include <openspace/interaction/delayedvariable.h>
#include <openspace/interaction/inputstate.h>
#include <ghoul/glm.h>
namespace openspace::interaction {
struct MouseState {
MouseState(double scaleFactor);
void setFriction(double friction);
void setVelocityScaleFactor(double scaleFactor);
class InputState;
glm::dvec2 previousPosition;
DelayedVariable<glm::dvec2, double> velocity;
};
class MouseStates {
class CameraInteractionStates {
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);
CameraInteractionStates(double sensitivity, double velocityScaleFactor);
virtual ~CameraInteractionStates() = default;
virtual void updateStateFromInput(const InputState& inputState, double deltaTime) = 0;
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;
glm::dvec2 globalRotationVelocity() const;
glm::dvec2 localRotationVelocity() const;
glm::dvec2 truckMovementVelocity() const;
glm::dvec2 localRollVelocity() const;
glm::dvec2 globalRollVelocity() const;
protected:
struct InteractionState {
InteractionState(double scaleFactor);
void setFriction(double friction);
void setVelocityScaleFactor(double scaleFactor);
glm::dvec2 previousPosition;
DelayedVariable<glm::dvec2, double> velocity;
};
private:
double _sensitivity;
MouseState _globalRotationMouseState;
MouseState _localRotationMouseState;
MouseState _truckMovementMouseState;
MouseState _localRollMouseState;
MouseState _globalRollMouseState;
InteractionState _globalRotationState;
InteractionState _localRotationState;
InteractionState _truckMovementState;
InteractionState _localRollState;
InteractionState _globalRollState;
};
} // namespace openspace::interaction
#endif // __OPENSPACE_CORE___MOUSESTATE___H__
#endif // __OPENSPACE_CORE___INPUTDEVICESTATES___H__
@@ -0,0 +1,81 @@
/*****************************************************************************************
* *
* OpenSpace *
* *
* Copyright (c) 2014-2018 *
* *
* 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___CAMERAINTERACTIONSTATES___H__
#define __OPENSPACE_CORE___CAMERAINTERACTIONSTATES___H__
#include <openspace/interaction/delayedvariable.h>
#include <ghoul/glm.h>
namespace openspace::interaction {
class InputState;
class CameraInteractionStates {
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.
*/
CameraInteractionStates(double sensitivity, double velocityScaleFactor);
virtual ~CameraInteractionStates() = default;
virtual void updateStateFromInput(const InputState& inputState, double deltaTime) = 0;
void setRotationalFriction(double friction);
void setHorizontalFriction(double friction);
void setVerticalFriction(double friction);
void setSensitivity(double sensitivity);
void setVelocityScaleFactor(double scaleFactor);
glm::dvec2 globalRotationVelocity() const;
glm::dvec2 localRotationVelocity() const;
glm::dvec2 truckMovementVelocity() const;
glm::dvec2 localRollVelocity() const;
glm::dvec2 globalRollVelocity() const;
protected:
struct InteractionState {
InteractionState(double scaleFactor);
void setFriction(double friction);
void setVelocityScaleFactor(double scaleFactor);
glm::dvec2 previousPosition;
DelayedVariable<glm::dvec2, double> velocity;
};
double _sensitivity;
InteractionState _globalRotationState;
InteractionState _localRotationState;
InteractionState _truckMovementState;
InteractionState _localRollState;
InteractionState _globalRollState;
};
} // namespace openspace::interaction
#endif // __OPENSPACE_CORE___CAMERAINTERACTIONSTATES___H__
+20 -8
View File
@@ -25,15 +25,15 @@
#ifndef __OPENSPACE_CORE___INPUTSTATE___H__
#define __OPENSPACE_CORE___INPUTSTATE___H__
#include <openspace/interaction/joystickinputstate.h>
#include <openspace/util/keys.h>
#include <openspace/util/mouse.h>
#include <ghoul/glm.h>
#include <list>
namespace openspace::interaction {
// This class represents the global input state of interaction devices
class InputState {
public:
InputState() = default;
@@ -45,22 +45,34 @@ public:
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;
void setJoystickInputStates(JoystickInputStates& states);
// Accessors
const std::list<std::pair<Key, KeyModifier>>& pressedKeys() const;
bool isKeyPressed(std::pair<Key, KeyModifier> keyModPair) const;
bool isKeyPressed(Key key) const;
const std::list<MouseButton>& pressedMouseButtons() const;
glm::dvec2 mousePosition() const;
double mouseScrollDelta() const;
bool isMouseButtonPressed(MouseButton mouseButton) const;
const JoystickInputStates& joystickInputStates() const;
float joystickAxis(int i) const;
bool joystickButton(int i) const;
private:
// Input from keyboard and mouse
// Input from keyboard
std::list<std::pair<Key, KeyModifier>> _keysDown;
// Input from mouse
std::list<MouseButton> _mouseButtonsDown;
glm::dvec2 _mousePosition;
double _mouseScrollDelta;
// Input from joysticks
// The memory is owned by the outer most main (apps/OpenSpace/main.cpp right now)
JoystickInputStates* _joystickInputStates = nullptr;
};
} // namespace openspace::interaction
@@ -0,0 +1,122 @@
/*****************************************************************************************
* *
* OpenSpace *
* *
* Copyright (c) 2014-2018 *
* *
* 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___JOYSTICKSTATE___H__
#define __OPENSPACE_CORE___JOYSTICKSTATE___H__
#include <openspace/interaction/camerainteractionstates.h>
#include <openspace/interaction/joystickinputstate.h>
#include <ghoul/misc/boolean.h>
#include <ghoul/misc/fromstring.h>
#include <map>
#include <vector>
namespace openspace::interaction {
class JoystickCameraStates : public CameraInteractionStates {
public:
enum class AxisType {
None = 0,
OrbitX,
OrbitY,
ZoomIn,
ZoomOut,
LocalRollX,
LocalRollY,
GlobalRollX,
GlobalRollY,
PanX,
PanY
};
BooleanType(AxisInvert);
BooleanType(AxisNormalize);
BooleanType(ButtonCommandRemote);
struct AxisInformation {
AxisType type = AxisType::None;
AxisInvert invert = AxisInvert::No;
AxisNormalize normalize = AxisNormalize::No;
float deadzone = 0.f;
};
JoystickCameraStates(double sensitivity, double velocityScaleFactor);
void updateStateFromInput(const InputState& inputState, double deltaTime) override;
void setAxisMapping(
int axis,
AxisType mapping,
AxisInvert shouldInvert = AxisInvert::No,
AxisNormalize shouldNormalize = AxisNormalize::No
);
AxisInformation axisMapping(int axis) const;
void setDeadzone(int axis, float deadzone);
float deadzone(int axis) const;
void bindButtonCommand(int button, std::string command, JoystickAction action,
ButtonCommandRemote local);
void clearButtonCommand(int button);
std::vector<std::string> buttonCommand(int button) const;
private:
// We use an array for the axes and a map for the buttons since the axis are going to
// be accessed much more often and thus have to be more efficient. And storing a few
// extra AxisInformation that are not used will not matter that much; finding an axis
// location in a potential map each frame, however, would
std::array<AxisInformation, JoystickInputState::MaxAxes> _axisMapping;
struct ButtonInformation {
std::string command;
JoystickAction action;
ButtonCommandRemote synchronization;
std::string documentation;
};
std::multimap<int, ButtonInformation> _buttonMapping;
};
} // namespace openspace::interaction
namespace std {
std::string to_string(const openspace::interaction::JoystickCameraStates::AxisType& type);
} // namespace std
namespace ghoul {
template <>
openspace::interaction::JoystickCameraStates::AxisType from_string(const std::string& string);
} // namespace ghoul
#endif // __OPENSPACE_CORE___JOYSTICKSTATE___H__
@@ -0,0 +1,126 @@
/*****************************************************************************************
* *
* OpenSpace *
* *
* Copyright (c) 2014-2018 *
* *
* 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___JOYSTICKINPUTSTATE___H__
#define __OPENSPACE_CORE___JOYSTICKINPUTSTATE___H__
#include <ghoul/misc/fromstring.h>
#include <array>
#include <memory>
#include <string>
namespace openspace::interaction {
/**
* Actions that any button of a joystick can have. Each button must be in one of these
* states
*/
enum class JoystickAction : uint8_t {
/// Idle state if the button is unpressed and has been unpressed since last frame
Idle = 0,
/// If the button has been pressed since the last frame
Press,
/// If the button has been pressed since longer than last frame
Repeat,
/// If the button was released since the last frame
Release
};
/**
* The input state of a single joystick.
*/
struct JoystickInputState {
/// The maximum number of supported axes
static const int MaxAxes = 8;
/// The maximum number of supported buttons
static const int MaxButtons = 32;
/// Marks whether this joystick is connected. If this value is \c false, all other
/// members of this struct are undefined
bool isConnected = false;
/// The name of this joystick
std::string name;
/// The number of axes that this joystick supports
int nAxes = 0;
/// The values for each axis. Each value is in the range [-1, 1]. Only the first
/// \c nAxes values are defined values, the rest are undefined
std::array<float, MaxAxes> axes;
/// The number of buttons that this joystick possesses
int nButtons = 0;
/// The status of each button. Only the first \c nButtons values are defined, the rest
/// are undefined
std::array<JoystickAction, MaxButtons> buttons;
};
/// The maximum number of joysticks that are supported by this system. This number is
/// derived from the available GLFW constants
constexpr const int MaxJoysticks = 16;
struct JoystickInputStates : public std::array<JoystickInputState, MaxJoysticks> {
/**
* This function adds the contributions of all connected joysticks for the provided
* \p axis. After adding each joysticks contribution, the result is clamped to [-1,1].
* If a joystick does not possess a particular axis, it's does not contribute to the
* sum.
*
* \param axis The numerical axis for which the values are added
* \return The summed axis values of all connected joysticks
*
* \pre \p axis must be 0 or positive
*/
float axis(int axis) const;
/**
* This functions checks whether any connected joystick has its \p button in the
* passed \p action. Any joystick that does not posses the \p button, it will be
* ignored.
*
* \param button The button that is to be checked
* \param action The action which is checked for each button
* \return \c true if there is at least one joystick whose \param button is in the
* \p action state
*
* \pre \p button must be 0 or positive
*/
bool button(int button, JoystickAction action) const;
};
} // namespace openspace::interaction
namespace std {
std::string to_string(openspace::interaction::JoystickAction action);
} // namespace std
namespace ghoul {
template <>
openspace::interaction::JoystickAction from_string(const std::string& str);
} // namespace ghoul
#endif // __OPENSPACE_CORE___JOYSTICKSTATE___H__
@@ -79,7 +79,6 @@ public:
void keyboardCallback(Key key, KeyModifier modifier, KeyAction action);
private:
std::string generateJson() const override;
std::multimap<KeyWithModifier, KeyInformation> _keyLua;
@@ -22,30 +22,20 @@
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
****************************************************************************************/
#ifndef __OPENSPACE_CORE___CONTROLLER___H__
#define __OPENSPACE_CORE___CONTROLLER___H__
#ifndef __OPENSPACE_CORE___MOUSECAMERASTATES___H__
#define __OPENSPACE_CORE___MOUSECAMERASTATES___H__
#include <openspace/scene/scenegraphnode.h>
#include <ghoul/glm.h>
#include <glm/gtx/vector_angle.hpp>
#include <openspace/interaction/camerainteractionstates.h>
namespace openspace::interaction {
class NavigationHandler;
class Controller {
class MouseCameraStates : public CameraInteractionStates {
public:
Controller() :
_handler(nullptr)
{}
MouseCameraStates(double sensitivity, double velocityScaleFactor);
void setHandler(NavigationHandler* handler);
protected:
NavigationHandler* _handler;
void updateStateFromInput(const InputState& inputState, double deltaTime) override;
};
} // namespace openspace::interaction
#endif // __OPENSPACE_CORE___CONTROLLER___H__
#endif // __OPENSPACE_CORE___MOUSECAMERASTATES___H__
@@ -29,6 +29,8 @@
#include <openspace/interaction/orbitalnavigator.h>
#include <openspace/interaction/keyframenavigator.h>
#include <openspace/interaction/joystickinputstate.h>
#include <openspace/interaction/joystickcamerastates.h>
#include <openspace/properties/stringproperty.h>
#include <openspace/properties/scalar/boolproperty.h>
#include <openspace/properties/scalar/floatproperty.h>
@@ -63,7 +65,7 @@ public:
void updateCamera(double deltaTime);
// Accessors
ghoul::Dictionary getCameraStateDictionary();
ghoul::Dictionary cameraStateDictionary();
SceneGraphNode* focusNode() const;
glm::dvec3 focusNodeToCameraVector() const;
glm::quat focusNodeToCameraRotation() const;
@@ -74,10 +76,33 @@ public:
// Callback functions
void keyboardCallback(Key key, KeyModifier modifier, KeyAction action);
void mouseButtonCallback(MouseButton button, MouseAction action);
void mousePositionCallback(double x, double y);
void mouseScrollWheelCallback(double pos);
void setJoystickInputStates(JoystickInputStates& states);
void setJoystickAxisMapping(
int axis,
JoystickCameraStates::AxisType mapping,
JoystickCameraStates::AxisInvert shouldInvert = JoystickCameraStates::AxisInvert::No,
JoystickCameraStates::AxisNormalize shouldNormalize = JoystickCameraStates::AxisNormalize::No
);
JoystickCameraStates::AxisInformation joystickAxisMapping(int axis) const;
void setJoystickAxisDeadzone(int axis, float deadzone);
float joystickAxisDeadzone(int axis) const;
void bindJoystickButtonCommand(int button, std::string command, JoystickAction action,
JoystickCameraStates::ButtonCommandRemote remote);
void clearJoystickButtonCommand(int button);
std::vector<std::string> joystickButtonCommand(int button) const;
void saveCameraStateToFile(const std::string& filepath);
void restoreCameraStateFromFile(const std::string& filepath);
@@ -28,7 +28,8 @@
#include <openspace/interaction/delayedvariable.h>
#include <openspace/interaction/inputstate.h>
#include <openspace/interaction/interpolator.h>
#include <openspace/interaction/mousestate.h>
#include <openspace/interaction/joystickcamerastates.h>
#include <openspace/interaction/mousecamerastates.h>
#include <openspace/properties/propertyowner.h>
#include <openspace/properties/scalar/boolproperty.h>
@@ -50,11 +51,14 @@ public:
OrbitalNavigator();
~OrbitalNavigator();
void updateMouseStatesFromInput(const InputState& inputState, double deltaTime);
void updateCameraStateFromMouseStates(Camera& camera, double deltaTime);
void updateStatesFromInput(const InputState& inputState, double deltaTime);
void updateCameraStateFromStates(Camera& camera, double deltaTime);
void setFocusNode(SceneGraphNode* focusNode);
void startInterpolateCameraDirection(const Camera& camera);
JoystickCameraStates& joystickStates();
bool followingNodeRotation() const;
SceneGraphNode* focusNode() const;
@@ -82,9 +86,12 @@ private:
properties::FloatProperty _followFocusNodeRotationDistance;
properties::FloatProperty _minimumAllowedDistance;
properties::FloatProperty _sensitivity;
properties::FloatProperty _mouseSensitivity;
properties::FloatProperty _joystickSensitivity;
MouseStates _mouseStates;
MouseCameraStates _mouseStates;
JoystickCameraStates _joystickStates;
SceneGraphNode* _focusNode = nullptr;
glm::dvec3 _previousFocusNodePosition;
@@ -116,14 +123,14 @@ private:
* \returns a local camera rotation modified with two degrees of freedom.
*/
glm::dquat rotateLocally(double deltaTime,
const glm::dquat& localCameraRotation) const;
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);
const glm::dquat& localCameraRotation);
/**
* Translates the horizontal direction. If far from the focus object, this will
@@ -132,10 +139,9 @@ private:
* \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;
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
@@ -143,35 +149,32 @@ private:
* \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;
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;
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;
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;
const glm::dquat& globalCameraRotation, const glm::dvec3& cameraPosition,
const SurfacePositionHandle& positionHandle) const;
/**
* Push the camera out to the surface of the object.
@@ -179,19 +182,16 @@ private:
* above the actual surface of the object
*/
glm::dvec3 pushToSurface(double minHeightAboveGround,
const glm::dvec3& cameraPosition,
const glm::dvec3& objectPosition,
const SurfacePositionHandle& positionHandle) const;
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);
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.