mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-05-05 10:59:47 -05:00
Add property to module for controlling the rotation speed of the camera
This commit is contained in:
@@ -54,12 +54,22 @@ namespace {
|
||||
"outside of the current field of view."
|
||||
};
|
||||
|
||||
constexpr const openspace::properties::Property::PropertyInfo CameraRotSpeedInfo = {
|
||||
"CameraRotationSpeed",
|
||||
"Camera Rotation Speed",
|
||||
"The speed of the rotation of the camera when the camera rotates to look at a "
|
||||
"coordinate which is outside of the field of view."
|
||||
};
|
||||
|
||||
struct [[codegen::Dictionary(SkyBrowserModule)]] Parameters {
|
||||
// [[codegen::verbatim(AllowInteractionInfo.description)]]
|
||||
std::optional<bool> allowMouseInteraction;
|
||||
|
||||
// [[codegen::verbatim(AllowRotationInfo.description)]]
|
||||
std::optional<bool> allowCameraRotation;
|
||||
|
||||
// [[codegen::verbatim(CameraRotSpeedInfo.description)]]
|
||||
std::optional<double> cameraRotSpeed;
|
||||
};
|
||||
|
||||
#include "skybrowsermodule_codegen.cpp"
|
||||
@@ -263,9 +273,11 @@ SkyBrowserModule::SkyBrowserModule()
|
||||
: OpenSpaceModule(SkyBrowserModule::Name)
|
||||
, _allowMouseInteraction(AllowInteractionInfo, true)
|
||||
, _allowCameraRotation(AllowRotationInfo, true)
|
||||
, _cameraRotationSpeed(CameraRotSpeedInfo, 1.f, 0.1f, 10.f)
|
||||
{
|
||||
addProperty(_allowMouseInteraction);
|
||||
addProperty(_allowCameraRotation);
|
||||
addProperty(_cameraRotationSpeed);
|
||||
|
||||
// Set callback functions
|
||||
global::callback::mouseButton->emplace_back(
|
||||
@@ -371,7 +383,7 @@ SkyBrowserModule::SkyBrowserModule()
|
||||
incrementallyAnimateTargets(deltaTime);
|
||||
}
|
||||
if (_isCameraRotating && _allowCameraRotation) {
|
||||
incrementallyRotateCamera(deltaTime);
|
||||
incrementallyRotateCamera(deltaTime, _cameraRotationSpeed);
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -576,7 +588,7 @@ void SkyBrowserModule::startRotatingCamera(glm::dvec3 endAnimation) {
|
||||
_isCameraRotating = true;
|
||||
}
|
||||
|
||||
void SkyBrowserModule::incrementallyRotateCamera(double deltaTime) {
|
||||
void SkyBrowserModule::incrementallyRotateCamera(double deltaTime, double animationSpeed) {
|
||||
|
||||
// Find smallest angle between the two vectors
|
||||
double angle = skybrowser::angleBetweenVectors(_startAnimation, _endAnimation);
|
||||
@@ -587,7 +599,7 @@ void SkyBrowserModule::incrementallyRotateCamera(double deltaTime) {
|
||||
_startAnimation,
|
||||
_endAnimation,
|
||||
deltaTime,
|
||||
AnimationSpeed
|
||||
animationSpeed
|
||||
);
|
||||
|
||||
// Rotate
|
||||
|
||||
@@ -31,6 +31,7 @@
|
||||
#include <openspace/util/distanceconstants.h>
|
||||
#include <openspace/util/mouse.h>
|
||||
#include <openspace/properties/scalar/boolproperty.h>
|
||||
#include <openspace/properties/scalar/doubleproperty.h>
|
||||
#include <fstream>
|
||||
|
||||
namespace openspace {
|
||||
@@ -57,7 +58,6 @@ public:
|
||||
constexpr static const char* Name = "SkyBrowser";
|
||||
constexpr static const double StopAnimationThreshold = 0.0005;
|
||||
constexpr static const double FadingTime = 2.0;
|
||||
constexpr static const double AnimationSpeed = 1.0;
|
||||
const double SolarSystemRadius = 30.0 * distanceconstants::AstronomicalUnit;
|
||||
|
||||
SkyBrowserModule();
|
||||
@@ -77,7 +77,7 @@ public:
|
||||
// Rotation, animation, placement
|
||||
void lookAtTarget(const std::string& id);
|
||||
void startRotatingCamera(glm::dvec3 endAnimation); // Pass in galactic coordinate
|
||||
void incrementallyRotateCamera(double deltaTime);
|
||||
void incrementallyRotateCamera(double deltaTime, double animationSpeed);
|
||||
void incrementallyFadeBrowserTargets(Transparency goal, float deltaTime);
|
||||
void incrementallyAnimateTargets(double deltaTime);
|
||||
|
||||
@@ -109,6 +109,7 @@ protected:
|
||||
private:
|
||||
properties::BoolProperty _allowMouseInteraction;
|
||||
properties::BoolProperty _allowCameraRotation;
|
||||
properties::DoubleProperty _cameraRotationSpeed;
|
||||
glm::ivec3 _highlightAddition = glm::ivec3(35); // Highlight object when mouse hovers
|
||||
|
||||
// The browsers and targets
|
||||
|
||||
Reference in New Issue
Block a user