Feature - OrbitalNavigator Setting - Orbit Around Up (#2874)

* Hack to try to get desired behavior (for testing)

* Add properties to control axes of rotation and whether rotation aorund up should be enabled

* Generalze orbit function to just use an angle instead of speed and deltatime

* Move speed scale computation to a separate function

* Refactor horizontal translation code a bit

* Refactor speed computation for idel behavior

* Refactor/clean up orbit code

* Add property docs

* Add some safety checks

* Apply suggestions from code review

Co-authored-by: Alexander Bock <alexander.bock@liu.se>

* More updates based on code review

---------

Co-authored-by: Alexander Bock <alexander.bock@liu.se>
This commit is contained in:
Emma Broman
2023-09-11 10:44:12 +02:00
committed by GitHub
parent aad8beb60c
commit 7bfedbdf12
2 changed files with 193 additions and 90 deletions

View File

@@ -233,6 +233,15 @@ private:
properties::BoolProperty _invertMouseButtons;
properties::BoolProperty _shouldRotateAroundUp;
enum class UpDirectionChoice {
XAxis = 0,
YAxis,
ZAxis
};
properties::OptionProperty _upToUseForRotation;
MouseCameraStates _mouseStates;
JoystickCameraStates _joystickStates;
WebsocketCameraStates _websocketStates;
@@ -322,6 +331,15 @@ private:
double interpolateCameraToSurfaceDistance(double deltaTime, double currentDistance,
double targetDistance);
/**
* Modify the camera position and global rotation to rotate around the up vector
* of the current anchor based on x-wise input
*
* The up-vector to rotate around is determined by the "_upToUseForRotation" property
*/
void rotateAroundAnchorUp(double deltaTime, double speedScale,
glm::dvec3& cameraPosition, glm::dquat& globalCameraRotation);
/**
* Translates the horizontal direction. If far from the anchor object, this will
* result in an orbital rotation around the object. This function does not affect the
@@ -329,8 +347,9 @@ private:
*
* \return a position vector adjusted in the horizontal direction.
*/
glm::dvec3 translateHorizontally(double deltaTime, const glm::dvec3& cameraPosition,
const glm::dvec3& objectPosition, const glm::dquat& globalCameraRotation,
glm::dvec3 translateHorizontally(double deltaTime, double speedScale,
const glm::dvec3& cameraPosition, const glm::dvec3& objectPosition,
const glm::dquat& globalCameraRotation,
const SurfacePositionHandle& positionHandle) const;
/*
@@ -410,13 +429,11 @@ private:
*
* Used for IdleBehavior::Behavior::Orbit
*
* \param deltaTime The time step to use for the motion. Controls the rotation angle
* \param angle The rotation angle to use for the motion
* \param position The position of the camera. Will be changed by the function
* \param globalRotation The camera's global rotation. Will be changed by the function
* \param speedScale A speed scale that controls the speed of the motion
*/
void orbitAnchor(double deltaTime, glm::dvec3& position,
glm::dquat& globalRotation, double speedScale);
void orbitAnchor(double angle, glm::dvec3& position, glm::dquat& globalRotation);
/**
* Orbit the current anchor node, by adding a rotation around the given axis. For
@@ -429,13 +446,15 @@ private:
* IdleBehavior::Behavior::OrbitAroundUp (axis = up = y-axis)
*
* \param axis The axis to arbit around, given in model coordinates of the anchor
* \param deltaTime The time step to use for the motion. Controls the rotation angle
* \param angle The rotation angle to use for the motion
* \param position The position of the camera. Will be changed by the function
* \param globalRotation The camera's global rotation. Will be changed by the function
* \param speedScale A speed scale that controls the speed of the motion
*/
void orbitAroundAxis(const glm::dvec3 axis, double deltaTime, glm::dvec3& position,
glm::dquat& globalRotation, double speedScale);
void orbitAroundAxis(const glm::dvec3 axis, double angle, glm::dvec3& position,
glm::dquat& globalRotation);
double rotationSpeedScaleFromCameraHeight(const glm::dvec3& cameraPosition,
const SurfacePositionHandle& positionHandle) const;
};
} // namespace openspace::interaction