mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-01-07 04:00:37 -06:00
Merge branch 'master' into feature/hdrOS
This commit is contained in:
1
Jenkinsfile
vendored
1
Jenkinsfile
vendored
@@ -11,6 +11,7 @@ def modules = [
|
||||
"multiresvolume",
|
||||
"spacecraftinstruments",
|
||||
"space",
|
||||
"touch",
|
||||
"toyvolume",
|
||||
"volume"
|
||||
];
|
||||
|
||||
@@ -6,6 +6,8 @@ The project stems from the same academic collaboration between Sweden’s [Link
|
||||
- Utilization of NASA’s SPICE observational geometry system with its Planetary Data Service (PDS) to enable space mission visualization that reveal how missions are designed to gather science.
|
||||
- Globe browsing techniques across spatial and temporal scales to examine scientific campaigns on multiple planets, including close up surface exploration.
|
||||
|
||||
This repository contains the source code and example scenes for OpenSpace, but does not contain any data. To build and install the client, we refer to the [Wiki](https://github.com/OpenSpace/OpenSpace/wiki) pages here on GitHub, specifically [building](https://github.com/OpenSpace/OpenSpace/wiki/General-Getting-Started-Guide%3A-Compiling-OpenSpace) for [Windows](https://github.com/OpenSpace/OpenSpace/wiki/Guides-Compile-OpenSpace-on-Windows), [Linux](https://github.com/OpenSpace/OpenSpace/wiki/Guides-Compile-OpenSpace-on-Linux), and [MacOS](https://github.com/OpenSpace/OpenSpace/wiki/Guides-Compile-OpenSpace-on-macOS). Required preexisting dependencies are: [Boost](http://www.boost.org/) and [Qt](http://www.qt.io/download). Feel free to create issues for missing features, bug reports, or compile problems or contact us via [email](mailto:alexander.bock@me.com?subject=OpenSpace:).
|
||||
OpenSpace requires graphics support for [OpenGL](https://www.opengl.org/) version 3.3.
|
||||
|
||||
This repository contains the source code and example scenes for OpenSpace, but does not contain any data. To build and install the client, we refer to the [OpenSpace Wiki](http://wiki.openspaceproject.com/), specifically [building](http://wiki.openspaceproject.com/developer/compiling/general) for [Windows](http://wiki.openspaceproject.com/developer/compiling/windows), [Linux (Ubuntu)](http://wiki.openspaceproject.com/developer/compiling/ubuntu), and [MacOS](http://wiki.openspaceproject.com/developer/compiling/macos). Required preexisting dependencies are: [Boost](http://www.boost.org/) and [Qt](http://www.qt.io/download). Feel free to create issues for missing features, bug reports, or compile problems or contact us via [email](mailto:alexander.bock@me.com?subject=OpenSpace:).
|
||||
|
||||
Regarding any issues, you are very welcome on our [Slack support channel](https://openspacesupport.slack.com) to which you can freely [sign-up](https://join.slack.com/t/openspacesupport/shared_invite/enQtMjUxNzUyMTQ1ODQxLTI4YjNmMTY3ZDI1N2Q1NWM1ZjQ1NTQyNzAxM2YyMGQ5Y2NmYWJiNjI1NjU4YTkyNTc5ZDE5NzdhNGM2YmUzYTk).
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
#include <string>
|
||||
#include <ghoul/glm.h>
|
||||
|
||||
#include <ghoul/ghoul.h>
|
||||
#include <ghoul/opengl/ghoul_gl.h>
|
||||
#include <ghoul/io/texture/texturereader.h>
|
||||
#include <ghoul/io/texture/texturereaderdevil.h>
|
||||
@@ -34,7 +35,8 @@
|
||||
#include <ghoul/filesystem/directory.h>
|
||||
#include <ghoul/logging/logmanager.h>
|
||||
#include <ghoul/logging/consolelog.h>
|
||||
#include <ghoul/ghoul.h>
|
||||
#include <ghoul/filesystem/file.h>
|
||||
#include <ghoul/filesystem/filesystem.h>
|
||||
#include <ghoul/cmdparser/commandlineparser.h>
|
||||
#include <ghoul/cmdparser/singlecommand.h>
|
||||
|
||||
@@ -106,6 +108,14 @@ int main(int argc, char** argv) {
|
||||
|
||||
ghoul::initialize();
|
||||
|
||||
// Register the path of the executable,
|
||||
// to make it possible to find other files in the same directory.
|
||||
FileSys.registerPathToken(
|
||||
"${BIN}",
|
||||
ghoul::filesystem::File(absPath(argv[0])).directoryName(),
|
||||
ghoul::filesystem::FileSystem::Override::Yes
|
||||
);
|
||||
|
||||
std::string configFile = configuration::findConfiguration();
|
||||
global::configuration = configuration::loadConfigurationFromFile(configFile);
|
||||
openspace::global::openSpaceEngine.registerPathTokens();
|
||||
|
||||
@@ -39,7 +39,7 @@ asset.onInitialize(function ()
|
||||
)
|
||||
|
||||
openspace.navigation.setCameraState({
|
||||
Focus = DawnAsset.Dawn.Identifier,
|
||||
Anchor = DawnAsset.Dawn.Identifier,
|
||||
Position = { 526781518487.171326, 257168309890.072144, -1381125204152.817383 },
|
||||
Rotation = { -0.106166, 0.981574, -0.084545, 0.134513 },
|
||||
})
|
||||
|
||||
@@ -96,7 +96,7 @@ asset.onInitialize(function ()
|
||||
)
|
||||
|
||||
openspace.navigation.setCameraState({
|
||||
Focus = earthAsset.Earth.Identifier,
|
||||
Anchor = earthAsset.Earth.Identifier,
|
||||
Position = { 0, 0, 0 },
|
||||
Rotation = { 0.758797, 0.221490, -0.605693, -0.091135 },
|
||||
})
|
||||
|
||||
@@ -33,7 +33,7 @@ asset.onInitialize(function ()
|
||||
openspace.setPropertyValueSingle('Scene.Stars.Renderable.Enabled', false);
|
||||
|
||||
openspace.navigation.setCameraState({
|
||||
Focus = "Gaia",
|
||||
Anchor = "Gaia",
|
||||
Position = { 1000000000000.0, 1000000000000.0, 1000000000000.0 },
|
||||
Rotation = { 0.683224, -0.765934, -0.601234, -0.418073 },
|
||||
})
|
||||
|
||||
@@ -43,7 +43,7 @@ asset.onInitialize(function ()
|
||||
)
|
||||
|
||||
openspace.navigation.setCameraState({
|
||||
Focus = junoAsset.Juno.Identifier,
|
||||
Anchor = junoAsset.Juno.Identifier,
|
||||
Position = { 1837386367.601345, -389860693812.834839, 714830404470.398926 },
|
||||
Rotation = { -0.336540, 0.711402, -0.099212, 0.608937 },
|
||||
})
|
||||
|
||||
@@ -63,7 +63,7 @@ asset.onInitialize(function ()
|
||||
)
|
||||
|
||||
openspace.navigation.setCameraState({
|
||||
Focus = "Mercury",
|
||||
Anchor = "Mercury",
|
||||
Position = { 526781518487.171326, 257168309890.072144, -1381125204152.817383 },
|
||||
Rotation = {0.180662, 0.021334, 0.979084, 0.091111},
|
||||
})
|
||||
|
||||
@@ -212,7 +212,7 @@ asset.onInitialize(function ()
|
||||
2160, 4320, 8640
|
||||
})
|
||||
|
||||
openspace.setPropertyValueSingle('NavigationHandler.OrbitalNavigator.FollowFocusNodeRotationDistance', 20.000000);
|
||||
openspace.setPropertyValueSingle('NavigationHandler.OrbitalNavigator.FollowAnchorNodeRotationDistance', 20.000000);
|
||||
|
||||
openspace.addVirtualProperty(
|
||||
"BoolProperty",
|
||||
@@ -225,7 +225,7 @@ asset.onInitialize(function ()
|
||||
)
|
||||
|
||||
openspace.navigation.setCameraState({
|
||||
Focus = NewHorizonsAsset.NewHorizons.Identifier,
|
||||
Anchor = NewHorizonsAsset.NewHorizons.Identifier,
|
||||
Position = { 4662120063743.592773, 1263245003503.724854, -955413856565.788086 },
|
||||
Rotation = { 0.683224, -0.165934, 0.701234, 0.118073 },
|
||||
})
|
||||
|
||||
@@ -133,7 +133,7 @@ asset.onInitialize(function ()
|
||||
)
|
||||
|
||||
openspace.navigation.setCameraState({
|
||||
Focus = OsirisRexAsset.OsirisRex.Identifier,
|
||||
Anchor = OsirisRexAsset.OsirisRex.Identifier,
|
||||
Position = { 26974590199.661884, 76314608558.908020, -127086452897.101791 },
|
||||
Rotation = { 0.729548, -0.126024, 0.416827, 0.527382 },
|
||||
})
|
||||
|
||||
@@ -137,7 +137,7 @@ asset.onInitialize(function ()
|
||||
)
|
||||
|
||||
openspace.navigation.setCameraState({
|
||||
Focus = Comet67PAsset.Comet67P.Identifier,
|
||||
Anchor = Comet67PAsset.Comet67P.Identifier,
|
||||
Position = { 526781518487.171326, 257168309890.072144, -1381125204152.817383 },
|
||||
Rotation = { -0.106166, 0.981574, -0.084545, 0.134513 },
|
||||
})
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
local guiCustomization = asset.require('customization/gui')
|
||||
|
||||
-- Select which commit hashes to use for the frontend and backend
|
||||
local frontendHash = "abf5fe23ef29af408d6c071057f1cc706c9b09a3"
|
||||
local frontendHash = "6a34f2b0c6cfde64b890f12aa5bfaa42ac61a40f"
|
||||
local backendHash = "6e773425b3e90ba93f0090e44427e474fe5c633f"
|
||||
|
||||
local dataProvider = "data.openspaceproject.com/files/webgui"
|
||||
|
||||
@@ -71,7 +71,7 @@ asset.onInitialize(function ()
|
||||
)
|
||||
|
||||
openspace.navigation.setCameraState({
|
||||
Focus = VoyagerAsset.Voyager_1.Identifier,
|
||||
Anchor = VoyagerAsset.Voyager_1.Identifier,
|
||||
Position = { 526781518487.171326, 257168309890.072144, -1381125204152.817383 },
|
||||
Rotation = { -0.106166, 0.981574, -0.084545, 0.134513 },
|
||||
})
|
||||
|
||||
@@ -55,9 +55,7 @@ public:
|
||||
void deinitialize();
|
||||
|
||||
// Mutators
|
||||
void setFocusNode(SceneGraphNode* node);
|
||||
void setCamera(Camera* camera);
|
||||
void resetCameraDirection();
|
||||
void setInterpolationTime(float durationInSeconds);
|
||||
|
||||
void setCameraStateFromDictionary(const ghoul::Dictionary& cameraDict);
|
||||
@@ -69,12 +67,10 @@ public:
|
||||
|
||||
// Accessors
|
||||
ghoul::Dictionary cameraStateDictionary();
|
||||
SceneGraphNode* focusNode() const;
|
||||
glm::dvec3 focusNodeToCameraVector() const;
|
||||
glm::quat focusNodeToCameraRotation() const;
|
||||
Camera* camera() const;
|
||||
const InputState& inputState() const;
|
||||
const OrbitalNavigator& orbitalNavigator() const;
|
||||
OrbitalNavigator& orbitalNavigator();
|
||||
KeyframeNavigator& keyframeNavigator() const;
|
||||
bool isKeyFrameInteractionEnabled() const;
|
||||
float interpolationTime() const;
|
||||
@@ -126,7 +122,6 @@ private:
|
||||
std::unique_ptr<OrbitalNavigator> _orbitalNavigator;
|
||||
std::unique_ptr<KeyframeNavigator> _keyframeNavigator;
|
||||
|
||||
properties::StringProperty _origin;
|
||||
properties::BoolProperty _useKeyFrameInteraction;
|
||||
};
|
||||
|
||||
|
||||
@@ -31,8 +31,10 @@
|
||||
#include <openspace/interaction/interpolator.h>
|
||||
#include <openspace/interaction/joystickcamerastates.h>
|
||||
#include <openspace/interaction/mousecamerastates.h>
|
||||
#include <openspace/properties/stringproperty.h>
|
||||
#include <openspace/properties/scalar/boolproperty.h>
|
||||
#include <openspace/properties/scalar/floatproperty.h>
|
||||
#include <openspace/properties/triggerproperty.h>
|
||||
#include <ghoul/glm.h>
|
||||
#include <glm/gtx/quaternion.hpp>
|
||||
|
||||
@@ -51,28 +53,46 @@ public:
|
||||
OrbitalNavigator();
|
||||
|
||||
void updateStatesFromInput(const InputState& inputState, double deltaTime);
|
||||
void updateCameraStateFromStates(Camera& camera, double deltaTime);
|
||||
void updateCameraStateFromStates(double deltaTime);
|
||||
|
||||
void setFocusNode(SceneGraphNode* focusNode);
|
||||
void startInterpolateCameraDirection(const Camera& camera);
|
||||
float rotateToFocusInterpolationTime() const;
|
||||
void setRotateToFocusInterpolationTime(float durationInSeconds);
|
||||
Camera* camera() const;
|
||||
void setCamera(Camera* camera);
|
||||
|
||||
void setFocusNode(const std::string& focusNode);
|
||||
void setAnchorNode(const std::string& anchorNode);
|
||||
void setAimNode(const std::string& aimNode);
|
||||
|
||||
void startRetargetAnchor();
|
||||
void startRetargetAim();
|
||||
float retargetInterpolationTime() const;
|
||||
void setRetargetInterpolationTime(float durationInSeconds);
|
||||
|
||||
JoystickCameraStates& joystickStates();
|
||||
|
||||
bool followingNodeRotation() const;
|
||||
SceneGraphNode* focusNode() const;
|
||||
const SceneGraphNode* anchorNode() const;
|
||||
const SceneGraphNode* aimNode() const;
|
||||
|
||||
bool hasRotationalFriction() const;
|
||||
bool hasZoomFriction() const;
|
||||
bool hasRollFriction() const;
|
||||
|
||||
glm::dvec3 anchorNodeToCameraVector() const;
|
||||
glm::quat anchorNodeToCameraRotation() const;
|
||||
|
||||
private:
|
||||
struct CameraRotationDecomposition {
|
||||
glm::dquat localRotation;
|
||||
glm::dquat globalRotation;
|
||||
};
|
||||
|
||||
struct CameraPose {
|
||||
glm::dvec3 position;
|
||||
glm::dquat rotation;
|
||||
};
|
||||
|
||||
using Displacement = std::pair<glm::dvec3, glm::dvec3>;
|
||||
|
||||
struct Friction : public properties::PropertyOwner {
|
||||
Friction();
|
||||
|
||||
@@ -83,9 +103,28 @@ private:
|
||||
properties::FloatProperty friction;
|
||||
};
|
||||
|
||||
void setFocusNode(const SceneGraphNode* focusNode);
|
||||
void setAnchorNode(const SceneGraphNode* anchorNode);
|
||||
void setAimNode(const SceneGraphNode* aimNode);
|
||||
|
||||
Camera* _camera;
|
||||
|
||||
Friction _friction;
|
||||
|
||||
properties::FloatProperty _followFocusNodeRotationDistance;
|
||||
// Anchor: Node to follow and orbit.
|
||||
properties::StringProperty _anchor;
|
||||
|
||||
// Aim: Node to look at (when camera direction is reset),
|
||||
// Empty string means same as anchor.
|
||||
// If these are the same node we call it the `focus` node.
|
||||
properties::StringProperty _aim;
|
||||
|
||||
// Reset camera direction to the anchor node.
|
||||
properties::TriggerProperty _retargetAnchor;
|
||||
// Reset camera direction to the aim node.
|
||||
properties::TriggerProperty _retargetAim;
|
||||
|
||||
properties::FloatProperty _followAnchorNodeRotationDistance;
|
||||
properties::FloatProperty _minimumAllowedDistance;
|
||||
|
||||
properties::FloatProperty _mouseSensitivity;
|
||||
@@ -95,33 +134,64 @@ private:
|
||||
properties::FloatProperty _stereoscopicDepthOfFocusSurface;
|
||||
properties::FloatProperty _staticViewScaleExponent;
|
||||
|
||||
properties::FloatProperty _rotateToFocusInterpolationTime;
|
||||
properties::FloatProperty _retargetInterpolationTime;
|
||||
properties::FloatProperty _stereoInterpolationTime;
|
||||
properties::FloatProperty _followRotationInterpolationTime;
|
||||
|
||||
MouseCameraStates _mouseStates;
|
||||
JoystickCameraStates _joystickStates;
|
||||
|
||||
SceneGraphNode* _focusNode = nullptr;
|
||||
glm::dvec3 _previousFocusNodePosition;
|
||||
glm::dquat _previousFocusNodeRotation;
|
||||
const SceneGraphNode* _anchorNode = nullptr;
|
||||
const SceneGraphNode* _aimNode = nullptr;
|
||||
|
||||
glm::dvec3 _previousAnchorNodePosition;
|
||||
glm::dquat _previousAnchorNodeRotation;
|
||||
|
||||
glm::dvec3 _previousAimNodePosition;
|
||||
glm::dquat _previousAimNodeRotation;
|
||||
|
||||
double _currentCameraToSurfaceDistance = 0.0;
|
||||
bool _directlySetStereoDistance = false;
|
||||
|
||||
Interpolator<double> _rotateToFocusNodeInterpolator;
|
||||
Interpolator<double> _retargetAimInterpolator;
|
||||
Interpolator<double> _retargetAnchorInterpolator;
|
||||
Interpolator<double> _cameraToSurfaceDistanceInterpolator;
|
||||
Interpolator<double> _followRotationInterpolator;
|
||||
|
||||
/**
|
||||
* Decomposes the cameras rotation in to a global and a local rotation defined by
|
||||
* Decomposes the camera's 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
|
||||
* camera points towards the reference 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);
|
||||
CameraRotationDecomposition decomposeCameraRotationSurface(const CameraPose pose,
|
||||
const SceneGraphNode& reference);
|
||||
|
||||
/**
|
||||
* Decomposes the camera's 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 reference node's origin.
|
||||
* The local rotation defines the differential from the global to the current total
|
||||
* rotation so that <code>cameraRotation = globalRotation * localRotation</code>.
|
||||
*/
|
||||
CameraRotationDecomposition decomposeCameraRotation(const CameraPose pose,
|
||||
glm::dvec3 reference);
|
||||
|
||||
/**
|
||||
* Composes a pair of global and local rotations into a quaternion that can be used
|
||||
* as the world rotation for a camera.
|
||||
*/
|
||||
glm::dquat composeCameraRotation(const CameraRotationDecomposition& composition);
|
||||
|
||||
/*
|
||||
* Moves and rotates the camera around the anchor node in order to maintain the
|
||||
* screen space position of the aim node. Also interpolates to the aim node, when
|
||||
* retargeting the aim.
|
||||
*/
|
||||
CameraPose followAim(CameraPose pose, glm::dvec3 cameraToAnchor,
|
||||
Displacement anchorToAim);
|
||||
|
||||
/*
|
||||
* Perform a camera roll on the local camera rotation
|
||||
@@ -137,47 +207,47 @@ private:
|
||||
const glm::dquat& localCameraRotation) const;
|
||||
|
||||
/**
|
||||
* Interpolates the local rotation towards a 0 rotation.
|
||||
* \returns a modified local rotation interpolated towards 0.
|
||||
* Interpolates the camera rotation based on active interpolators.
|
||||
* \returns a new rotation quaternion
|
||||
*/
|
||||
glm::dquat interpolateLocalRotation(double deltaTime,
|
||||
const glm::dquat& localCameraRotation);
|
||||
|
||||
|
||||
double interpolateCameraToSurfaceDistance(double deltaTime,
|
||||
double currentDistance,
|
||||
double targetDistance);
|
||||
Displacement interpolateRetargetAim(double deltaTime, CameraPose pose,
|
||||
glm::dvec3 cameraToAnchor, Displacement anchorToAim);
|
||||
|
||||
double interpolateCameraToSurfaceDistance(double deltaTime, double currentDistance,
|
||||
double targetDistance);
|
||||
|
||||
/**
|
||||
* Translates the horizontal direction. If far from the focus object, this will
|
||||
* 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
|
||||
* 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 glm::dvec3& objectPosition, 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
|
||||
* Adds rotation to the camera position so that it follows the rotation of the anchor
|
||||
* node defined by the differential anchorNodeRotationDiff.
|
||||
* \returns a position updated with the rotation defined by anchorNodeRotationDiff
|
||||
*/
|
||||
glm::dvec3 followFocusNodeRotation(const glm::dvec3& cameraPosition,
|
||||
const glm::dvec3& objectPosition, const glm::dquat& focusNodeRotationDiff) const;
|
||||
glm::dvec3 followAnchorNodeRotation(const glm::dvec3& cameraPosition,
|
||||
const glm::dvec3& objectPosition, const glm::dquat& anchorNodeRotationDiff) 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.
|
||||
* Updates the global rotation so that it points towards the anchor node.
|
||||
* \returns a global rotation quaternion defining a rotation towards the anchor node.
|
||||
*/
|
||||
glm::dquat rotateGlobally(const glm::dquat& globalCameraRotation,
|
||||
const glm::dvec3& objectPosition, const glm::dquat& focusNodeRotationDiff,
|
||||
const glm::dvec3& cameraPosition,
|
||||
const glm::dquat& aimNodeRotationDiff,
|
||||
const SurfacePositionHandle& positionHandle) const;
|
||||
|
||||
/**
|
||||
* Translates the camera position towards or away from the focus node.
|
||||
* Translates the camera position towards or away from the anchor node.
|
||||
* \returns a position vector adjusted in the vertical direction.
|
||||
*/
|
||||
glm::dvec3 translateVertically(double deltaTime, const glm::dvec3& cameraPosition,
|
||||
@@ -189,7 +259,7 @@ private:
|
||||
* \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 glm::dquat& globalCameraRotation,
|
||||
const SurfacePositionHandle& positionHandle) const;
|
||||
|
||||
/**
|
||||
@@ -210,17 +280,15 @@ private:
|
||||
const SurfacePositionHandle& positionHandle);
|
||||
|
||||
/**
|
||||
* Get the vector from the camera to the surface of the focus object in world space.
|
||||
* Get the vector from the camera to the surface of the anchor object in world space.
|
||||
*/
|
||||
glm::dvec3 cameraToSurfaceVector(
|
||||
const glm::dvec3& cameraPos,
|
||||
const glm::dvec3& centerPos,
|
||||
const SurfacePositionHandle& posHandle);
|
||||
glm::dvec3 cameraToSurfaceVector(const glm::dvec3& cameraPos,
|
||||
const glm::dvec3& centerPos, const SurfacePositionHandle& posHandle);
|
||||
|
||||
/**
|
||||
* Calculates a SurfacePositionHandle given a camera position in world space.
|
||||
*/
|
||||
SurfacePositionHandle calculateSurfacePositionHandle(
|
||||
SurfacePositionHandle calculateSurfacePositionHandle(const SceneGraphNode& node,
|
||||
const glm::dvec3 cameraPositionWorldSpace);
|
||||
};
|
||||
|
||||
|
||||
@@ -96,7 +96,6 @@ public:
|
||||
void traversePostOrder(const std::function<void(SceneGraphNode*)>& fn);
|
||||
void update(const UpdateData& data);
|
||||
void render(const RenderData& data, RendererTasks& tasks);
|
||||
void updateCamera(Camera* camera) const;
|
||||
|
||||
void attachChild(std::unique_ptr<SceneGraphNode> child);
|
||||
std::unique_ptr<SceneGraphNode> detachChild(SceneGraphNode& child);
|
||||
@@ -109,7 +108,7 @@ public:
|
||||
void setDependencies(const std::vector<SceneGraphNode*>& dependencies);
|
||||
|
||||
SurfacePositionHandle calculateSurfacePositionHandle(
|
||||
const glm::dvec3& targetModelSpace);
|
||||
const glm::dvec3& targetModelSpace) const;
|
||||
|
||||
const std::vector<SceneGraphNode*>& dependencies() const;
|
||||
const std::vector<SceneGraphNode*>& dependentNodes() const;
|
||||
@@ -183,6 +182,8 @@ private:
|
||||
glm::dmat3 _worldRotationCached;
|
||||
double _worldScaleCached = 1.0;
|
||||
|
||||
float _fixedBoundingSphere = 0.f;
|
||||
|
||||
glm::dmat4 _modelTransformCached;
|
||||
glm::dmat4 _inverseModelTransformCached;
|
||||
|
||||
|
||||
@@ -72,7 +72,6 @@ public:
|
||||
|
||||
// Mutators
|
||||
void setPositionVec3(glm::dvec3 pos);
|
||||
void setFocusPositionVec3(glm::dvec3 pos);
|
||||
void setRotation(glm::dquat rotation);
|
||||
void setScaling(float scaling);
|
||||
void setMaxFov(float fov);
|
||||
@@ -86,7 +85,6 @@ public:
|
||||
const glm::dvec3& positionVec3() const;
|
||||
glm::dvec3 eyePositionVec3() const;
|
||||
const glm::dvec3& unsynchedPositionVec3() const;
|
||||
const glm::dvec3& focusPositionVec3() const;
|
||||
const glm::dvec3& viewDirectionWorldSpace() const;
|
||||
const glm::dvec3& lookUpVectorCameraSpace() const;
|
||||
const glm::dvec3& lookUpVectorWorldSpace() const;
|
||||
@@ -138,18 +136,6 @@ public:
|
||||
mutable std::mutex _mutex;
|
||||
} sgctInternal;
|
||||
|
||||
// Deprecated
|
||||
// [[deprecated("Replaced by Camera::setPositionVec3()")]]
|
||||
void setPosition(psc pos);
|
||||
// [[deprecated("Replaced by Camera::setFocusPositionVec3()")]]
|
||||
void setFocusPosition(psc pos);
|
||||
// [[deprecated("Replaced by Camera::positionVec3()")]]
|
||||
psc position() const;
|
||||
// [[deprecated("Replaced by Camera::unsynchedPositionVec3()")]]
|
||||
psc unsynchedPosition() const;
|
||||
// [[deprecated("Replaced by Camera::focusPositionVec3()")]]
|
||||
psc focusPosition() const;
|
||||
const glm::mat4& sceneMatrix() const;
|
||||
// @TODO use Camera::SgctInternal interface instead
|
||||
// [[deprecated("Replaced by Camera::SgctInternal::viewMatrix()")]]
|
||||
const glm::mat4& viewMatrix() const;
|
||||
@@ -160,10 +146,11 @@ public:
|
||||
|
||||
std::vector<Syncable*> getSyncables();
|
||||
|
||||
private:
|
||||
// Static constants
|
||||
static const glm::dvec3 ViewDirectionCameraSpace;
|
||||
static const glm::dvec3 LookupVectorCameraSpace;
|
||||
static const glm::dvec3 UpDirectionCameraSpace;
|
||||
|
||||
private:
|
||||
|
||||
SyncData<glm::dvec3> _position = glm::dvec3(1.0, 1.0, 1.0);
|
||||
SyncData<glm::dquat> _rotation = glm::dquat(glm::dvec3(1.0, 1.0, 1.0));
|
||||
|
||||
@@ -28,6 +28,7 @@
|
||||
#include <openspace/documentation/verifier.h>
|
||||
#include <openspace/engine/globals.h>
|
||||
#include <openspace/interaction/navigationhandler.h>
|
||||
#include <openspace/interaction/orbitalnavigator.h>
|
||||
#include <openspace/rendering/renderengine.h>
|
||||
#include <openspace/scene/scene.h>
|
||||
#include <openspace/scene/scenegraphnode.h>
|
||||
@@ -380,7 +381,14 @@ std::pair<glm::dvec3, std::string> DashboardItemAngle::positionAndLabel(
|
||||
case Type::Node:
|
||||
return { comp.node->worldPosition(), comp.node->guiName() };
|
||||
case Type::Focus:
|
||||
return { global::navigationHandler.focusNode()->worldPosition(), "focus" };
|
||||
{
|
||||
const SceneGraphNode* node =
|
||||
global::navigationHandler.orbitalNavigator().anchorNode();
|
||||
return {
|
||||
node->worldPosition(),
|
||||
"focus"
|
||||
};
|
||||
}
|
||||
case Type::Camera:
|
||||
return { global::renderEngine.scene()->camera()->positionVec3(), "camera" };
|
||||
default:
|
||||
|
||||
@@ -28,6 +28,7 @@
|
||||
#include <openspace/documentation/verifier.h>
|
||||
#include <openspace/engine/globals.h>
|
||||
#include <openspace/interaction/navigationhandler.h>
|
||||
#include <openspace/interaction/orbitalnavigator.h>
|
||||
#include <openspace/rendering/renderengine.h>
|
||||
#include <openspace/scene/scene.h>
|
||||
#include <openspace/scene/scenegraphnode.h>
|
||||
@@ -402,7 +403,7 @@ std::pair<glm::dvec3, std::string> DashboardItemDistance::positionAndLabel(
|
||||
}
|
||||
case Type::Focus:
|
||||
return {
|
||||
global::navigationHandler.focusNode()->worldPosition(),
|
||||
global::navigationHandler.orbitalNavigator().anchorNode()->worldPosition(),
|
||||
"focus"
|
||||
};
|
||||
case Type::Camera:
|
||||
|
||||
@@ -29,6 +29,7 @@
|
||||
#include <openspace/engine/globals.h>
|
||||
#include <openspace/engine/windowdelegate.h>
|
||||
#include <openspace/interaction/navigationhandler.h>
|
||||
#include <openspace/interaction/orbitalnavigator.h>
|
||||
#include <openspace/rendering/renderengine.h>
|
||||
#include <openspace/scene/scene.h>
|
||||
#include <openspace/util/timemanager.h>
|
||||
@@ -763,8 +764,10 @@ void RenderableFieldlinesSequence::definePropertyCallbackFunctions() {
|
||||
));
|
||||
return;
|
||||
}
|
||||
global::navigationHandler.setFocusNode(node->parent());
|
||||
global::navigationHandler.resetCameraDirection();
|
||||
global::navigationHandler.orbitalNavigator().setFocusNode(
|
||||
node->parent()->identifier()
|
||||
);
|
||||
global::navigationHandler.orbitalNavigator().startRetargetAnchor();
|
||||
});
|
||||
|
||||
_pJumpToStartBtn.onChange([this] {
|
||||
|
||||
@@ -116,7 +116,7 @@ void GalaxyRaycaster::postRaycast(const RaycastData&, ghoul::opengl::ProgramObje
|
||||
|
||||
bool GalaxyRaycaster::isCameraInside(const RenderData& data, glm::vec3& localPosition) {
|
||||
// Camera rig position in world coordinates.
|
||||
const glm::vec4 rigWorldPos = glm::vec4(data.camera.position().vec3(), 1.0);
|
||||
const glm::vec4 rigWorldPos = glm::vec4(data.camera.positionVec3(), 1.0);
|
||||
//rigWorldPos /= data.camera.scaling().x * pow(10.0, data.camera.scaling().y);
|
||||
//glm::mat4 invSgctMatrix = glm::inverse(data.camera.viewMatrix());
|
||||
|
||||
|
||||
@@ -309,7 +309,7 @@ void RenderableGalaxy::update(const UpdateData& data) {
|
||||
void RenderableGalaxy::render(const RenderData& data, RendererTasks& tasks) {
|
||||
RaycasterTask task { _raycaster.get(), data };
|
||||
|
||||
const glm::vec3 position = data.camera.position().vec3();
|
||||
const glm::vec3 position = data.camera.positionVec3();
|
||||
const float length = safeLength(position);
|
||||
const glm::vec3 galaxySize = _volumeSize;
|
||||
|
||||
|
||||
@@ -31,6 +31,8 @@
|
||||
#include <modules/globebrowsing/src/globetranslation.h>
|
||||
#include <modules/globebrowsing/src/memoryawaretilecache.h>
|
||||
#include <modules/globebrowsing/src/tileprovider.h>
|
||||
#include <openspace/interaction/navigationhandler.h>
|
||||
#include <openspace/interaction/orbitalnavigator.h>
|
||||
#include <openspace/engine/globalscallbacks.h>
|
||||
#include <openspace/scripting/lualibrary.h>
|
||||
#include <openspace/util/factorymanager.h>
|
||||
@@ -474,7 +476,7 @@ void GlobeBrowsingModule::goToGeodetic2(Camera& camera, globebrowsing::Geodetic2
|
||||
|
||||
const glm::dvec3 cameraPosition = global::navigationHandler.camera()->positionVec3();
|
||||
const glm::dmat4 inverseModelTransform =
|
||||
global::navigationHandler.focusNode()->inverseModelTransform();
|
||||
global::navigationHandler.orbitalNavigator().anchorNode()->inverseModelTransform();
|
||||
const glm::dvec3 cameraPositionModelSpace =
|
||||
glm::dvec3(inverseModelTransform * glm::dvec4(cameraPosition, 1.0));
|
||||
const SurfacePositionHandle posHandle = globe->calculateSurfacePositionHandle(
|
||||
@@ -557,7 +559,9 @@ GlobeBrowsingModule::castFocusNodeRenderableToGlobe()
|
||||
{
|
||||
using namespace globebrowsing;
|
||||
|
||||
const Renderable* renderable = global::navigationHandler.focusNode()->renderable();
|
||||
const Renderable* renderable =
|
||||
global::navigationHandler.orbitalNavigator().anchorNode()->renderable();
|
||||
|
||||
if (!renderable) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -208,7 +208,7 @@ int getGeoPositionForCamera(lua_State* L) {
|
||||
|
||||
const glm::dvec3 cameraPosition = global::navigationHandler.camera()->positionVec3();
|
||||
const glm::dmat4 inverseModelTransform =
|
||||
global::navigationHandler.focusNode()->inverseModelTransform();
|
||||
global::navigationHandler.orbitalNavigator().anchorNode()->inverseModelTransform();
|
||||
const glm::dvec3 cameraPositionModelSpace =
|
||||
glm::dvec3(inverseModelTransform * glm::dvec4(cameraPosition, 1.0));
|
||||
const SurfacePositionHandle posHandle = globe->calculateSurfacePositionHandle(
|
||||
|
||||
@@ -82,10 +82,11 @@ openspace.globebrowsing.documentation = {
|
||||
},
|
||||
{
|
||||
Name = "addFocusNodeFromLatLong",
|
||||
Arguments = "string, number, number, string",
|
||||
Arguments = "string, string, number, number, number",
|
||||
Documentation =
|
||||
"Creates a new SceneGraphNode that can be used as focus node. " ..
|
||||
"Usage: openspace.globebrowsing.addFocusNodeFromLatLong(\"Olympus Mons\", -18.65, 226.2, \"Mars\")"
|
||||
"Usage: openspace.globebrowsing.addFocusNodeFromLatLong(" ..
|
||||
"\"Olympus Mons\", \"Mars\", -18.65, 226.2, optionalAltitude)"
|
||||
},
|
||||
{
|
||||
Name = "loadWMSServersFromFile",
|
||||
@@ -289,10 +290,10 @@ openspace.globebrowsing.addFocusNodesFromDirectory = function (dir, node_name)
|
||||
end
|
||||
end
|
||||
|
||||
openspace.globebrowsing.addFocusNodeFromLatLong = function (name, lat, long, globe_identifier)
|
||||
openspace.printInfo("Creating focus node for '" .. name .. "'")
|
||||
openspace.globebrowsing.addFocusNodeFromLatLong = function (name, globe_identifier, lat, long, altitude)
|
||||
altitude = altitude or 0;
|
||||
|
||||
local a, b, c = openspace.globebrowsing.getGeoPosition(globe_identifier, lat, long, 0.0)
|
||||
local a, b, c = openspace.globebrowsing.getGeoPosition(globe_identifier, lat, long, altitude)
|
||||
local p = { a, b, c }
|
||||
local identifier = globe_identifier .. "-" .. name
|
||||
|
||||
@@ -301,8 +302,11 @@ openspace.globebrowsing.addFocusNodeFromLatLong = function (name, lat, long, glo
|
||||
Parent = globe_identifier,
|
||||
Transform = {
|
||||
Translation = {
|
||||
Type = "StaticTranslation",
|
||||
Position = { p[1], p[2], p[3] }
|
||||
Type = "GlobeTranslation",
|
||||
Globe = globe_identifier,
|
||||
Latitude = lat,
|
||||
Longitude = long,
|
||||
FixedAltitude = altitude
|
||||
}
|
||||
},
|
||||
GUI = {
|
||||
|
||||
@@ -30,6 +30,7 @@
|
||||
#include <openspace/documentation/verifier.h>
|
||||
#include <openspace/engine/globals.h>
|
||||
#include <openspace/interaction/navigationhandler.h>
|
||||
#include <openspace/interaction/orbitalnavigator.h>
|
||||
#include <openspace/scene/scenegraphnode.h>
|
||||
#include <openspace/util/distanceconversion.h>
|
||||
#include <openspace/util/updatestructures.h>
|
||||
@@ -142,7 +143,7 @@ DashboardItemGlobeLocation::DashboardItemGlobeLocation(
|
||||
void DashboardItemGlobeLocation::render(glm::vec2& penPosition) {
|
||||
using namespace globebrowsing;
|
||||
|
||||
SceneGraphNode* n = global::navigationHandler.focusNode();
|
||||
const SceneGraphNode* n = global::navigationHandler.orbitalNavigator().anchorNode();
|
||||
const RenderableGlobe* globe = dynamic_cast<const RenderableGlobe*>(n->renderable());
|
||||
if (!globe) {
|
||||
return;
|
||||
|
||||
@@ -29,6 +29,7 @@
|
||||
#include <openspace/engine/globals.h>
|
||||
#include <openspace/engine/moduleengine.h>
|
||||
#include <openspace/interaction/navigationhandler.h>
|
||||
#include <openspace/interaction/orbitalnavigator.h>
|
||||
#include <openspace/rendering/renderable.h>
|
||||
#include <openspace/rendering/renderengine.h>
|
||||
#include <openspace/scene/scene.h>
|
||||
@@ -122,7 +123,9 @@ void GuiGlobeBrowsingComponent::render() {
|
||||
// node
|
||||
|
||||
// Check if the focus node is a RenderableGlobe
|
||||
const SceneGraphNode* const focus = global::navigationHandler.focusNode();
|
||||
const SceneGraphNode* const focus =
|
||||
global::navigationHandler.orbitalNavigator().anchorNode();
|
||||
|
||||
const auto it = std::find(nodes.cbegin(), nodes.cend(), focus);
|
||||
if (it != nodes.end()) {
|
||||
_currentNode = focus->identifier();
|
||||
@@ -145,7 +148,9 @@ void GuiGlobeBrowsingComponent::render() {
|
||||
ImGui::SameLine();
|
||||
bool selectFocusNode = ImGui::Button("From Focus");
|
||||
if (selectFocusNode) {
|
||||
const SceneGraphNode* const focus = global::navigationHandler.focusNode();
|
||||
const SceneGraphNode* const focus =
|
||||
global::navigationHandler.orbitalNavigator().anchorNode();
|
||||
|
||||
const auto it = std::find(nodes.cbegin(), nodes.cend(), focus);
|
||||
if (it != nodes.end()) {
|
||||
_currentNode = focus->identifier();
|
||||
|
||||
@@ -29,6 +29,7 @@
|
||||
#include <openspace/engine/globals.h>
|
||||
#include <openspace/engine/windowdelegate.h>
|
||||
#include <openspace/interaction/navigationhandler.h>
|
||||
#include <openspace/interaction/orbitalnavigator.h>
|
||||
#include <openspace/rendering/renderengine.h>
|
||||
#include <openspace/scene/scenegraphnode.h>
|
||||
#include <openspace/scene/scene.h>
|
||||
@@ -63,6 +64,11 @@ namespace {
|
||||
}
|
||||
}
|
||||
|
||||
constexpr const char* AnchorProperty = "NavigationHandler.OrbitalNavigator.Anchor";
|
||||
|
||||
constexpr const char* RetargetAnchorProperty =
|
||||
"NavigationHandler.OrbitalNavigator.RetargetAnchor";
|
||||
|
||||
} // namespace
|
||||
|
||||
namespace openspace::gui {
|
||||
@@ -102,10 +108,16 @@ void GuiSpaceTimeComponent::render() {
|
||||
ImGui::SameLine();
|
||||
if (pressed) {
|
||||
global::scriptEngine.queueScript(
|
||||
"openspace.setPropertyValue('NavigationHandler.Origin', '" +
|
||||
"openspace.setPropertyValue('" +
|
||||
std::string(AnchorProperty) + "', '" +
|
||||
n->identifier() + "');",
|
||||
scripting::ScriptEngine::RemoteScripting::Yes
|
||||
);
|
||||
global::scriptEngine.queueScript(
|
||||
"openspace.setPropertyValue('" +
|
||||
std::string(RetargetAnchorProperty) + "', nil);",
|
||||
scripting::ScriptEngine::RemoteScripting::Yes
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -113,7 +125,8 @@ void GuiSpaceTimeComponent::render() {
|
||||
ImGui::NewLine();
|
||||
ImGui::SetCursorPosY(ImGui::GetCursorPosY() + 10.f);
|
||||
|
||||
SceneGraphNode* currentFocus = global::navigationHandler.focusNode();
|
||||
const SceneGraphNode* currentFocus =
|
||||
global::navigationHandler.orbitalNavigator().anchorNode();
|
||||
|
||||
std::string nodeNames;
|
||||
for (SceneGraphNode* n : nodes) {
|
||||
@@ -131,24 +144,23 @@ void GuiSpaceTimeComponent::render() {
|
||||
const bool hasChanged = ImGui::Combo("", ¤tPosition, nodeNames.c_str());
|
||||
if (hasChanged) {
|
||||
global::scriptEngine.queueScript(
|
||||
"openspace.setPropertyValue('NavigationHandler.Origin', '" +
|
||||
"openspace.setPropertyValue('" + std::string(AnchorProperty) + "', '" +
|
||||
nodes[currentPosition]->identifier() + "');",
|
||||
scripting::ScriptEngine::RemoteScripting::Yes
|
||||
);
|
||||
global::scriptEngine.queueScript(
|
||||
"openspace.setPropertyValue('" +
|
||||
std::string(RetargetAnchorProperty) + "', nil);",
|
||||
scripting::ScriptEngine::RemoteScripting::Yes
|
||||
);
|
||||
}
|
||||
|
||||
ImGui::SameLine();
|
||||
const bool pressed = ImGui::Button("Refocus");
|
||||
if (pressed) {
|
||||
// To refocus, we are first clearing the origin property before setting it back
|
||||
// to its old value. The property mechanism's onChange does not fire if the same
|
||||
// value is set again, hence the need for the clearing
|
||||
global::scriptEngine.queueScript(
|
||||
R"(
|
||||
local o = openspace.getPropertyValue('NavigationHandler.Origin');
|
||||
openspace.setPropertyValue('NavigationHandler.Origin', '');
|
||||
openspace.setPropertyValue('NavigationHandler.Origin', o);
|
||||
)",
|
||||
"openspace.setPropertyValue('" +
|
||||
std::string(RetargetAnchorProperty) + "', nil);",
|
||||
scripting::ScriptEngine::RemoteScripting::Yes
|
||||
);
|
||||
}
|
||||
|
||||
@@ -133,7 +133,7 @@ bool MultiresVolumeRaycaster::isCameraInside(const RenderData& data,
|
||||
glm::vec3& localPosition)
|
||||
{
|
||||
// Camera rig position in world coordinates.
|
||||
glm::vec4 rigWorldPos = glm::vec4(data.camera.position().vec3(), 1.0);
|
||||
glm::vec4 rigWorldPos = glm::vec4(data.camera.positionVec3(), 1.0);
|
||||
//rigWorldPos /= data.camera.scaling().x * pow(10.0, data.camera.scaling().y);
|
||||
//glm::mat4 invSgctMatrix = glm::inverse(data.camera.viewMatrix());
|
||||
|
||||
|
||||
@@ -28,6 +28,8 @@
|
||||
#include <openspace/properties/property.h>
|
||||
#include <openspace/query/query.h>
|
||||
#include <ghoul/logging/logmanager.h>
|
||||
#include <openspace/engine/globals.h>
|
||||
#include <openspace/scripting/scriptengine.h>
|
||||
|
||||
namespace {
|
||||
constexpr const char* PropertyKey = "property";
|
||||
@@ -40,22 +42,19 @@ namespace openspace {
|
||||
void TriggerPropertyTopic::handleJson(const nlohmann::json& json) {
|
||||
try {
|
||||
const std::string& propertyKey = json.at(PropertyKey).get<std::string>();
|
||||
|
||||
properties::Property* prop = property(propertyKey);
|
||||
if (prop) {
|
||||
LDEBUG("Triggering " + propertyKey);
|
||||
prop->set("poke");
|
||||
}
|
||||
else {
|
||||
LWARNING("Could not find property " + propertyKey);
|
||||
}
|
||||
global::scriptEngine.queueScript(
|
||||
fmt::format(
|
||||
"openspace.setPropertyValueSingle(\"{}\", nil)", propertyKey
|
||||
),
|
||||
scripting::ScriptEngine::RemoteScripting::Yes
|
||||
);
|
||||
}
|
||||
catch (const std::out_of_range& e) {
|
||||
LERROR("Could not poke property -- key or value is missing in payload");
|
||||
LERROR("Could not trigger property -- key or value is missing in payload");
|
||||
LERROR(e.what());
|
||||
}
|
||||
catch (const ghoul::RuntimeError& e) {
|
||||
LERROR("Could not poke property -- runtime error:");
|
||||
LERROR("Could not trigger property -- runtime error:");
|
||||
LERROR(e.what());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -75,4 +75,9 @@ add_library(libTUIO11
|
||||
target_include_directories(libTUIO11 PUBLIC
|
||||
${PROJECT_SOURCE_DIR}/libTUIO11/
|
||||
${PROJECT_SOURCE_DIR}/libTUIO11/oscpack
|
||||
${PROJECT_SOURCE_DIR}/libTUIO11/TUIO)
|
||||
${PROJECT_SOURCE_DIR}/libTUIO11/TUIO)
|
||||
|
||||
if (WIN32)
|
||||
# Tuio dependencies
|
||||
target_link_libraries(libTUIO11 PRIVATE winmm.lib wininet.lib ws2_32.lib)
|
||||
endif()
|
||||
|
||||
@@ -133,11 +133,16 @@ public:
|
||||
|
||||
// Get & Setters
|
||||
Camera* getCamera();
|
||||
SceneGraphNode* getFocusNode();
|
||||
void setFocusNode(SceneGraphNode* focusNode);
|
||||
const SceneGraphNode* getFocusNode();
|
||||
void setFocusNode(const SceneGraphNode* focusNode);
|
||||
void setCamera(Camera* camera);
|
||||
|
||||
private:
|
||||
/* Returns true if the clicked position contains WebGui content and the event will
|
||||
* be parsed to the webbrowser
|
||||
*/
|
||||
bool webContent(const std::vector<TUIO::TuioCursor>& list);
|
||||
|
||||
/* Returns true if we have the GUI window open. If so, emulates the incoming touch
|
||||
* input to a mouse such that we can interact with the GUI
|
||||
*/
|
||||
@@ -185,7 +190,6 @@ private:
|
||||
void resetToDefault();
|
||||
|
||||
Camera* _camera = nullptr;
|
||||
SceneGraphNode* _focusNode = nullptr;
|
||||
|
||||
// Property variables
|
||||
properties::StringProperty _origin;
|
||||
|
||||
@@ -22,8 +22,11 @@
|
||||
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
|
||||
****************************************************************************************/
|
||||
|
||||
#include <openspace/engine/globals.h>
|
||||
#include <modules/touch/include/touchinteraction.h>
|
||||
#include <modules/imgui/imguimodule.h>
|
||||
#include <modules/webbrowser/webbrowsermodule.h>
|
||||
#include <modules/webgui/webguimodule.h>
|
||||
|
||||
#include <openspace/interaction/orbitalnavigator.h>
|
||||
#include <openspace/engine/globals.h>
|
||||
@@ -363,6 +366,8 @@ void TouchInteraction::updateStateFromInput(const std::vector<TuioCursor>& list,
|
||||
_time.initSession();
|
||||
}
|
||||
|
||||
bool hasWebContent = webContent(list);
|
||||
|
||||
//Code for lower-right corner double-tap to zoom-out
|
||||
glm::ivec2 res = global::windowDelegate.currentWindowSize();
|
||||
glm::dvec2 pos = glm::vec2(
|
||||
@@ -377,16 +382,16 @@ void TouchInteraction::updateStateFromInput(const std::vector<TuioCursor>& list,
|
||||
res.y * (1.0f - bottomCornerSizeForZoomTap_fraction)
|
||||
);
|
||||
|
||||
bool isTapInLowerCorner = std::abs(pos.x) > zoomTapThresholdX &&
|
||||
std::abs(pos.y) > zoomTapThresholdY;
|
||||
bool isTapInLowerRightCorner =
|
||||
(std::abs(pos.x) > zoomTapThresholdX && std::abs(pos.y) > zoomTapThresholdY);
|
||||
|
||||
if (_doubleTap && isTapInLowerCorner) {
|
||||
if (_doubleTap && isTapInLowerRightCorner) {
|
||||
_zoomOutTap = true;
|
||||
_tap = false;
|
||||
_doubleTap = false;
|
||||
}
|
||||
|
||||
if (!guiMode(list)) {
|
||||
if (!guiMode(list) && !hasWebContent) {
|
||||
bool isThisFrameTransitionBetweenTouchModes
|
||||
= (_wasPrevModeDirectTouch != _directTouchMode);
|
||||
if (isThisFrameTransitionBetweenTouchModes) {
|
||||
@@ -425,6 +430,17 @@ void TouchInteraction::updateStateFromInput(const std::vector<TuioCursor>& list,
|
||||
}
|
||||
}
|
||||
|
||||
bool TouchInteraction::webContent(const std::vector<TuioCursor>& list) {
|
||||
glm::ivec2 res = global::windowDelegate.currentWindowSize();
|
||||
glm::dvec2 pos = glm::vec2(
|
||||
list.at(0).getScreenX(res.x),
|
||||
list.at(0).getScreenY(res.y)
|
||||
);
|
||||
|
||||
WebBrowserModule& module = *(global::moduleEngine.module<WebBrowserModule>());
|
||||
return module.eventHandler().hasContentCallback(pos.x, pos.y);
|
||||
}
|
||||
|
||||
// Activates/Deactivates gui input mode (if active it voids all other interactions)
|
||||
bool TouchInteraction::guiMode(const std::vector<TuioCursor>& list) {
|
||||
if (_ignoreGui) {
|
||||
@@ -1021,6 +1037,8 @@ void TouchInteraction::computeVelocities(const std::vector<TuioCursor>& list,
|
||||
{
|
||||
const TuioCursor& cursor = list.at(0);
|
||||
const int action = interpretInteraction(list, lastProcessed);
|
||||
const SceneGraphNode* anchor =
|
||||
global::navigationHandler.orbitalNavigator().anchorNode();
|
||||
|
||||
#ifdef TOUCH_DEBUG_PROPERTIES
|
||||
const std::map<int, std::string> interactionNames = {
|
||||
@@ -1082,11 +1100,11 @@ void TouchInteraction::computeVelocities(const std::vector<TuioCursor>& list,
|
||||
) / lastProcessed.size();
|
||||
|
||||
glm::dvec3 camPos = _camera->positionVec3();
|
||||
glm::dvec3 centerPos = _focusNode->worldPosition();
|
||||
glm::dvec3 centerPos = anchor->worldPosition();
|
||||
glm::dvec3 currDistanceToFocusNode = camPos - centerPos;
|
||||
|
||||
double distanceFromFocusSurface =
|
||||
length(currDistanceToFocusNode) - _focusNode->boundingSphere();
|
||||
length(currDistanceToFocusNode) - anchor->boundingSphere();
|
||||
double zoomFactor = (distance - lastDistance);
|
||||
#ifdef TOUCH_DEBUG_PROPERTIES
|
||||
pinchConsecCt++;
|
||||
@@ -1161,12 +1179,9 @@ void TouchInteraction::computeVelocities(const std::vector<TuioCursor>& list,
|
||||
// pick something in the scene as focus node
|
||||
if (_pickingSelected) {
|
||||
setFocusNode(_pickingSelected);
|
||||
// cant do setFocusNode() since TouchInteraction is not subclass of
|
||||
// InteractionMode
|
||||
global::navigationHandler.setFocusNode(_focusNode);
|
||||
|
||||
// rotate camera to look at new focus, using slerp quat
|
||||
glm::dvec3 camToFocus = _focusNode->worldPosition() -
|
||||
glm::dvec3 camToFocus = _pickingSelected->worldPosition() -
|
||||
_camera->positionVec3();
|
||||
glm::dvec3 forward = glm::normalize(_camera->viewDirectionWorldSpace());
|
||||
double angle = glm::angle(forward, camToFocus);
|
||||
@@ -1206,8 +1221,15 @@ double TouchInteraction::computeConstTimeDecayCoefficient(double velocity) {
|
||||
}
|
||||
|
||||
double TouchInteraction::computeTapZoomDistance(double zoomGain) {
|
||||
double dist = glm::distance(_camera->positionVec3(), _camera->focusPositionVec3());
|
||||
dist -= _focusNode->boundingSphere();
|
||||
const SceneGraphNode* anchor =
|
||||
global::navigationHandler.orbitalNavigator().anchorNode();
|
||||
|
||||
double dist = glm::distance(
|
||||
_camera->positionVec3(),
|
||||
global::navigationHandler.orbitalNavigator().anchorNode()->worldPosition()
|
||||
);
|
||||
|
||||
dist -= anchor->boundingSphere();
|
||||
|
||||
double newVelocity = dist * _tapZoomFactor;
|
||||
newVelocity *= std::max(_touchScreenSize.value() * 0.1, 1.0);
|
||||
@@ -1221,13 +1243,16 @@ double TouchInteraction::computeTapZoomDistance(double zoomGain) {
|
||||
void TouchInteraction::step(double dt) {
|
||||
using namespace glm;
|
||||
|
||||
const SceneGraphNode* anchor =
|
||||
global::navigationHandler.orbitalNavigator().anchorNode();
|
||||
|
||||
// since functions cant be called directly (TouchInteraction not a subclass of
|
||||
// InteractionMode)
|
||||
setFocusNode(global::navigationHandler.focusNode());
|
||||
if (_focusNode && _camera) {
|
||||
setFocusNode(global::navigationHandler.orbitalNavigator().anchorNode());
|
||||
if (anchor && _camera) {
|
||||
// Create variables from current state
|
||||
dvec3 camPos = _camera->positionVec3();
|
||||
dvec3 centerPos = _focusNode->worldPosition();
|
||||
dvec3 centerPos = anchor->worldPosition();
|
||||
|
||||
dvec3 directionToCenter = normalize(centerPos - camPos);
|
||||
dvec3 centerToCamera = camPos - centerPos;
|
||||
@@ -1245,7 +1270,7 @@ void TouchInteraction::step(double dt) {
|
||||
dquat globalCamRot = normalize(quat_cast(inverse(lookAtMat)));
|
||||
dquat localCamRot = inverse(globalCamRot) * _camera->rotationQuaternion();
|
||||
|
||||
double boundingSphere = _focusNode->boundingSphere();
|
||||
double boundingSphere = anchor->boundingSphere();
|
||||
dvec3 centerToBoundingSphere;
|
||||
double distance = std::max(length(centerToCamera) - boundingSphere, 0.0);
|
||||
_currentRadius = boundingSphere /
|
||||
@@ -1296,12 +1321,15 @@ void TouchInteraction::step(double dt) {
|
||||
planetBoundaryRadius *= _zoomBoundarySphereMultiplier;
|
||||
double distToSurface = length(centerToCamera - planetBoundaryRadius);
|
||||
|
||||
WebGuiModule& module = *(global::moduleEngine.module<WebGuiModule>());
|
||||
|
||||
//Apply the velocity to update camera position
|
||||
if (length(_vel.zoom*dt) < distToSurface &&
|
||||
length(centerToCamera + directionToCenter*_vel.zoom*dt)
|
||||
> planetBoundaryRadius)
|
||||
{
|
||||
camPos += directionToCenter * _vel.zoom * dt;
|
||||
glm::dvec3 velocityIncr = directionToCenter * _vel.zoom * dt;
|
||||
bool isDeltaLessThanDistToSurface = (length(_vel.zoom * dt) < distToSurface);
|
||||
bool isNewPosOutsidePlanetRadius =
|
||||
(length(centerToCamera + velocityIncr) > planetBoundaryRadius);
|
||||
if (isDeltaLessThanDistToSurface && isNewPosOutsidePlanetRadius) {
|
||||
camPos += velocityIncr;
|
||||
}
|
||||
else {
|
||||
#ifdef TOUCH_DEBUG_PROPERTIES
|
||||
@@ -1399,10 +1427,6 @@ void TouchInteraction::decelerate(double dt) {
|
||||
_vel.roll *= computeDecayCoeffFromFrametime(_constTimeDecayCoeff.roll, times);
|
||||
_vel.pan *= computeDecayCoeffFromFrametime(_constTimeDecayCoeff.pan, times);
|
||||
_vel.zoom *= computeDecayCoeffFromFrametime(_constTimeDecayCoeff.zoom, times);
|
||||
|
||||
glm::dvec3 camPos = _camera->positionVec3();
|
||||
glm::dvec3 centerPos = _focusNode->worldPosition();
|
||||
glm::dvec3 centerToCamera = camPos - centerPos;
|
||||
}
|
||||
|
||||
double TouchInteraction::computeDecayCoeffFromFrametime(double coeff, int times) {
|
||||
@@ -1489,14 +1513,14 @@ Camera* TouchInteraction::getCamera() {
|
||||
return _camera;
|
||||
}
|
||||
|
||||
SceneGraphNode* TouchInteraction::getFocusNode() {
|
||||
return _focusNode;
|
||||
const SceneGraphNode* TouchInteraction::getFocusNode() {
|
||||
return global::navigationHandler.orbitalNavigator().anchorNode();
|
||||
}
|
||||
void TouchInteraction::setCamera(Camera* camera) {
|
||||
_camera = camera;
|
||||
}
|
||||
void TouchInteraction::setFocusNode(SceneGraphNode* focusNode) {
|
||||
_focusNode = focusNode;
|
||||
void TouchInteraction::setFocusNode(const SceneGraphNode* focusNode) {
|
||||
global::navigationHandler.orbitalNavigator().setAnchorNode(focusNode->identifier());
|
||||
}
|
||||
|
||||
void FrameTimeAverage::updateWithNewFrame(double sample) {
|
||||
|
||||
@@ -23,11 +23,15 @@
|
||||
****************************************************************************************/
|
||||
|
||||
#include <modules/touch/touchmodule.h>
|
||||
#include <modules/webbrowser/webbrowsermodule.h>
|
||||
#include <modules/webgui/webguimodule.h>
|
||||
|
||||
#include <openspace/engine/globals.h>
|
||||
#include <openspace/engine/globalscallbacks.h>
|
||||
#include <openspace/engine/moduleengine.h>
|
||||
#include <openspace/engine/windowdelegate.h>
|
||||
#include <openspace/interaction/navigationhandler.h>
|
||||
#include <openspace/interaction/orbitalnavigator.h>
|
||||
#include <openspace/rendering/renderengine.h>
|
||||
#include <openspace/rendering/screenspacerenderable.h>
|
||||
#include <ghoul/logging/logmanager.h>
|
||||
@@ -70,6 +74,9 @@ bool TouchModule::hasNewInput() {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Check if we need to parse touchevent to the webgui
|
||||
hasNewWebInput(listOfContactPoints);
|
||||
|
||||
// Return true if we got new input
|
||||
if (listOfContactPoints.size() == lastProcessed.size() &&
|
||||
!listOfContactPoints.empty())
|
||||
@@ -103,7 +110,36 @@ bool TouchModule::hasNewInput() {
|
||||
}
|
||||
}
|
||||
|
||||
TouchModule::TouchModule() : OpenSpaceModule("Touch") {
|
||||
void TouchModule::hasNewWebInput(const std::vector<TuioCursor>& listOfContactPoints) {
|
||||
// If one point input and no data in webPosition callback send mouse click to webgui
|
||||
bool isWebPositionCallbackZero =
|
||||
(webPositionCallback.x == 0 && webPositionCallback.y == 0);
|
||||
bool isSingleContactPoint = (listOfContactPoints.size() == 1);
|
||||
if (isSingleContactPoint && isWebPositionCallbackZero) {
|
||||
glm::ivec2 res = global::windowDelegate.currentWindowSize();
|
||||
glm::dvec2 pos = glm::vec2(
|
||||
listOfContactPoints.at(0).getScreenX(res.x),
|
||||
listOfContactPoints.at(0).getScreenY(res.y)
|
||||
);
|
||||
|
||||
WebBrowserModule& module = *(global::moduleEngine.module<WebBrowserModule>());
|
||||
if (module.eventHandler().hasContentCallback(pos.x, pos.y)) {
|
||||
webPositionCallback = glm::vec2(pos.x, pos.y);
|
||||
module.eventHandler().touchPressCallback(pos.x, pos.y);
|
||||
}
|
||||
}
|
||||
// Send mouse release if not same point input
|
||||
else if (!isSingleContactPoint && !isWebPositionCallbackZero) {
|
||||
WebBrowserModule& module = *(global::moduleEngine.module<WebBrowserModule>());
|
||||
module.eventHandler().touchReleaseCallback(webPositionCallback.x,
|
||||
webPositionCallback.y);
|
||||
webPositionCallback = glm::vec2(0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
TouchModule::TouchModule()
|
||||
: OpenSpaceModule("Touch")
|
||||
{
|
||||
addPropertySubOwner(touch);
|
||||
addPropertySubOwner(markers);
|
||||
|
||||
@@ -119,7 +155,7 @@ TouchModule::TouchModule() : OpenSpaceModule("Touch") {
|
||||
|
||||
global::callback::preSync.push_back([&]() {
|
||||
touch.setCamera(global::navigationHandler.camera());
|
||||
touch.setFocusNode(global::navigationHandler.focusNode());
|
||||
touch.setFocusNode(global::navigationHandler.orbitalNavigator().anchorNode());
|
||||
|
||||
if (hasNewInput() && global::windowDelegate.isMaster()) {
|
||||
touch.updateStateFromInput(listOfContactPoints, lastProcessed);
|
||||
|
||||
@@ -42,6 +42,10 @@ namespace openspace {
|
||||
* Returns true if new touch input occured since the last frame
|
||||
*/
|
||||
bool hasNewInput();
|
||||
/**
|
||||
* Checks if touchevent should be parsed to the webgui
|
||||
*/
|
||||
void hasNewWebInput(const std::vector<TUIO::TuioCursor>& listOfContactPoints);
|
||||
|
||||
TuioEar ear;
|
||||
TouchInteraction touch;
|
||||
@@ -49,6 +53,7 @@ namespace openspace {
|
||||
std::vector<TUIO::TuioCursor> listOfContactPoints;
|
||||
// contains an id and the TuioPoint that was processed last frame
|
||||
std::vector<Point> lastProcessed;
|
||||
glm::ivec2 webPositionCallback = glm::ivec2(0,0);
|
||||
};
|
||||
|
||||
} // namespace openspace
|
||||
|
||||
@@ -84,6 +84,12 @@ public:
|
||||
void draw();
|
||||
void close(bool force = false);
|
||||
|
||||
void sendTouchPressEvent(const CefMouseEvent & event,
|
||||
CefBrowserHost::MouseButtonType button, const int clickCount);
|
||||
|
||||
void sendResleasePressEvent(const CefMouseEvent & event,
|
||||
CefBrowserHost::MouseButtonType button, const int clickCount);
|
||||
|
||||
bool sendKeyEvent(const CefKeyEvent& event);
|
||||
bool sendMouseClickEvent(const CefMouseEvent& event,
|
||||
CefBrowserHost::MouseButtonType button, bool mouseUp,
|
||||
|
||||
@@ -60,6 +60,9 @@ public:
|
||||
void setBrowser(const CefRefPtr<CefBrowser>& browser);
|
||||
void setBrowserInstance(BrowserInstance* browserInstance);
|
||||
void detachBrowser();
|
||||
void touchPressCallback(const double x, const double y);
|
||||
void touchReleaseCallback(const double x, const double y);
|
||||
bool hasContentCallback(const double, const double);
|
||||
|
||||
private:
|
||||
bool mouseButtonCallback(MouseButton button, MouseAction action, KeyModifier mods);
|
||||
|
||||
@@ -131,6 +131,18 @@ bool BrowserInstance::sendMouseClickEvent(const CefMouseEvent& event,
|
||||
return hasContent(event.x, event.y);
|
||||
}
|
||||
|
||||
void BrowserInstance::sendTouchPressEvent(const CefMouseEvent &event, CefBrowserHost::MouseButtonType button,
|
||||
const int clickCount)
|
||||
{
|
||||
_browser->GetHost()->SendMouseClickEvent(event, button, false, clickCount);
|
||||
}
|
||||
|
||||
void BrowserInstance::sendResleasePressEvent(const CefMouseEvent &event, CefBrowserHost::MouseButtonType button,
|
||||
const int clickCount)
|
||||
{
|
||||
_browser->GetHost()->SendMouseClickEvent(event, button, true, clickCount);
|
||||
}
|
||||
|
||||
bool BrowserInstance::sendMouseMoveEvent(const CefMouseEvent& event) {
|
||||
constexpr const bool DidNotLeaveWindow = false;
|
||||
|
||||
|
||||
@@ -143,6 +143,30 @@ void EventHandler::initialize() {
|
||||
);
|
||||
}
|
||||
|
||||
void EventHandler::touchPressCallback(const double x, const double y) {
|
||||
if (_browserInstance) {
|
||||
_mousePosition.x = static_cast<float>(x);
|
||||
_mousePosition.y = static_cast<float>(y);
|
||||
|
||||
int clickCount = BrowserInstance::SingleClick;
|
||||
_browserInstance->sendMouseClickEvent(mouseEvent(), MBT_LEFT, false, clickCount);
|
||||
}
|
||||
}
|
||||
|
||||
void EventHandler::touchReleaseCallback(const double x, const double y) {
|
||||
if (_browserInstance) {
|
||||
_mousePosition.x = static_cast<float>(x);
|
||||
_mousePosition.y = static_cast<float>(y);
|
||||
|
||||
int clickCount = BrowserInstance::SingleClick;
|
||||
_browserInstance->sendMouseClickEvent(mouseEvent(), MBT_LEFT, true, clickCount);
|
||||
}
|
||||
}
|
||||
|
||||
bool EventHandler::hasContentCallback(const double x, const double y) {
|
||||
return _browserInstance->hasContent(static_cast<int>(x), static_cast<int>(y));
|
||||
}
|
||||
|
||||
bool EventHandler::mouseButtonCallback(MouseButton button,
|
||||
MouseAction action,
|
||||
KeyModifier mods)
|
||||
@@ -215,6 +239,7 @@ bool EventHandler::mouseWheelCallback(glm::ivec2 delta) {
|
||||
bool EventHandler::charCallback(unsigned int charCode, KeyModifier modifier) {
|
||||
CefKeyEvent keyEvent;
|
||||
keyEvent.windows_key_code = charCode;
|
||||
keyEvent.character = charCode;
|
||||
keyEvent.modifiers = static_cast<uint32>(modifier);
|
||||
keyEvent.type = KEYEVENT_CHAR;
|
||||
// TODO(klas): figure out when to block
|
||||
|
||||
@@ -140,6 +140,10 @@ void WebBrowserModule::attachEventHandler(BrowserInstance* browserInstance) {
|
||||
}
|
||||
}
|
||||
|
||||
EventHandler WebBrowserModule::eventHandler() {
|
||||
return _eventHandler;
|
||||
}
|
||||
|
||||
void WebBrowserModule::detachEventHandler() {
|
||||
if (_enabled) {
|
||||
_eventHandler.setBrowserInstance(nullptr);
|
||||
|
||||
@@ -42,6 +42,7 @@ public:
|
||||
void addBrowser(BrowserInstance*);
|
||||
void removeBrowser(BrowserInstance*);
|
||||
|
||||
EventHandler eventHandler();
|
||||
void attachEventHandler(BrowserInstance* browserInstance);
|
||||
void detachEventHandler();
|
||||
bool isEnabled() const;
|
||||
|
||||
@@ -39,6 +39,7 @@
|
||||
#include <openspace/interaction/keybindingmanager.h>
|
||||
#include <openspace/interaction/sessionrecording.h>
|
||||
#include <openspace/interaction/navigationhandler.h>
|
||||
#include <openspace/interaction/orbitalnavigator.h>
|
||||
#include <openspace/network/networkengine.h>
|
||||
#include <openspace/network/parallelpeer.h>
|
||||
#include <openspace/performance/performancemeasurement.h>
|
||||
@@ -651,7 +652,14 @@ void OpenSpaceEngine::loadSingleAsset(const std::string& assetPath) {
|
||||
|
||||
global::renderEngine.setCamera(camera);
|
||||
global::navigationHandler.setCamera(camera);
|
||||
global::navigationHandler.setFocusNode(camera->parent());
|
||||
const SceneGraphNode* parent = camera->parent();
|
||||
if (parent) {
|
||||
global::navigationHandler.orbitalNavigator().setFocusNode(parent->identifier());
|
||||
} else {
|
||||
global::navigationHandler.orbitalNavigator().setFocusNode(
|
||||
_scene->root()->identifier()
|
||||
);
|
||||
}
|
||||
|
||||
global::renderEngine.setScene(_scene.get());
|
||||
|
||||
|
||||
@@ -106,19 +106,22 @@ void ExternInteraction::scriptInteraction(datamessagestructures::ScriptMessage s
|
||||
|
||||
datamessagestructures::CameraKeyframe ExternInteraction::generateCameraKeyframe() {
|
||||
datamessagestructures::CameraKeyframe kf;
|
||||
SceneGraphNode* focusNode = global::navigationHandler.focusNode();
|
||||
const SceneGraphNode* focusNode =
|
||||
global::navigationHandler.orbitalNavigator().anchorNode();
|
||||
|
||||
if (!focusNode) {
|
||||
return kf;
|
||||
}
|
||||
|
||||
//kf._position = global::navigationHandler.camera()->positionVec3();
|
||||
kf._position = global::navigationHandler.focusNodeToCameraVector();
|
||||
kf._position = global::navigationHandler.orbitalNavigator().anchorNodeToCameraVector();
|
||||
|
||||
kf._followNodeRotation =
|
||||
global::navigationHandler.orbitalNavigator().followingNodeRotation();
|
||||
if (kf._followNodeRotation) {
|
||||
kf._position = glm::inverse(focusNode->worldRotationMatrix()) * kf._position;
|
||||
kf._rotation = global::navigationHandler.focusNodeToCameraRotation();
|
||||
kf._rotation =
|
||||
global::navigationHandler.orbitalNavigator().anchorNodeToCameraVector();
|
||||
}
|
||||
else {
|
||||
kf._rotation = global::navigationHandler.camera()->rotationQuaternion();
|
||||
|
||||
@@ -26,6 +26,11 @@
|
||||
|
||||
#include <openspace/interaction/inputstate.h>
|
||||
|
||||
namespace {
|
||||
const double SENSITIVITY_ADJUSTMENT_INCREASE = 8.0;
|
||||
const double SENSITIVITY_ADJUSTMENT_DECREASE = 0.5;
|
||||
}
|
||||
|
||||
namespace openspace::interaction {
|
||||
|
||||
MouseCameraStates::MouseCameraStates(double sensitivity, double velocityScaleFactor)
|
||||
@@ -82,8 +87,17 @@ void MouseCameraStates::updateStateFromInput(const InputState& inputState,
|
||||
if (button2Pressed || (keyAltPressed && button1Pressed)) {
|
||||
glm::dvec2 mousePositionDelta = _truckMovementState.previousPosition -
|
||||
mousePosition;
|
||||
|
||||
double sensitivity = _sensitivity;
|
||||
if (inputState.isKeyPressed(Key::Z)) {
|
||||
sensitivity *= SENSITIVITY_ADJUSTMENT_INCREASE;
|
||||
}
|
||||
else if (inputState.isKeyPressed(Key::X)) {
|
||||
sensitivity *= SENSITIVITY_ADJUSTMENT_DECREASE;
|
||||
}
|
||||
|
||||
_truckMovementState.velocity.set(
|
||||
mousePositionDelta * _sensitivity,
|
||||
mousePositionDelta * sensitivity,
|
||||
deltaTime
|
||||
);
|
||||
}
|
||||
|
||||
@@ -25,7 +25,6 @@
|
||||
#include <openspace/interaction/navigationhandler.h>
|
||||
|
||||
#include <openspace/engine/globals.h>
|
||||
#include <openspace/query/query.h>
|
||||
#include <openspace/scene/scenegraphnode.h>
|
||||
#include <openspace/scripting/lualibrary.h>
|
||||
#include <openspace/interaction/orbitalnavigator.h>
|
||||
@@ -41,18 +40,11 @@
|
||||
namespace {
|
||||
constexpr const char* _loggerCat = "NavigationHandler";
|
||||
|
||||
constexpr const char* KeyFocus = "Focus";
|
||||
constexpr const char* KeyAnchor = "Anchor";
|
||||
constexpr const char* KeyAim = "Aim";
|
||||
constexpr const char* KeyPosition = "Position";
|
||||
constexpr const char* KeyRotation = "Rotation";
|
||||
|
||||
constexpr const openspace::properties::Property::PropertyInfo OriginInfo = {
|
||||
"Origin",
|
||||
"Origin",
|
||||
"The name of the scene graph node that is the origin of the camera interaction. "
|
||||
"The camera is always focussed on this object and every interaction is relative "
|
||||
"towards this object. Any scene graph node can be the origin node."
|
||||
};
|
||||
|
||||
constexpr const openspace::properties::Property::PropertyInfo KeyFrameInfo = {
|
||||
"UseKeyFrameInteraction",
|
||||
"Use keyframe interaction",
|
||||
@@ -67,31 +59,14 @@ namespace openspace::interaction {
|
||||
|
||||
NavigationHandler::NavigationHandler()
|
||||
: properties::PropertyOwner({ "NavigationHandler" })
|
||||
, _origin(OriginInfo)
|
||||
, _useKeyFrameInteraction(KeyFrameInfo, false)
|
||||
{
|
||||
_origin.onChange([this]() {
|
||||
if (_origin.value().empty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
SceneGraphNode* node = sceneGraphNode(_origin.value());
|
||||
if (!node) {
|
||||
LWARNING(fmt::format(
|
||||
"Could not find a node in scenegraph called '{}'", _origin.value()
|
||||
));
|
||||
return;
|
||||
}
|
||||
setFocusNode(node);
|
||||
resetCameraDirection();
|
||||
});
|
||||
|
||||
_inputState = std::make_unique<InputState>();
|
||||
_orbitalNavigator = std::make_unique<OrbitalNavigator>();
|
||||
_keyframeNavigator = std::make_unique<KeyframeNavigator>();
|
||||
|
||||
// Add the properties
|
||||
addProperty(_origin);
|
||||
addProperty(_useKeyFrameInteraction);
|
||||
addPropertySubOwner(*_orbitalNavigator);
|
||||
}
|
||||
@@ -113,23 +88,19 @@ void NavigationHandler::deinitialize() {
|
||||
global::parallelPeer.connectionEvent().unsubscribe("NavigationHandler");
|
||||
}
|
||||
|
||||
void NavigationHandler::setFocusNode(SceneGraphNode* node) {
|
||||
_orbitalNavigator->setFocusNode(node);
|
||||
_camera->setFocusPositionVec3(focusNode()->worldPosition());
|
||||
}
|
||||
|
||||
void NavigationHandler::setCamera(Camera* camera) {
|
||||
_camera = camera;
|
||||
}
|
||||
|
||||
void NavigationHandler::resetCameraDirection() {
|
||||
_orbitalNavigator->startInterpolateCameraDirection(*_camera);
|
||||
_orbitalNavigator->setCamera(camera);
|
||||
}
|
||||
|
||||
const OrbitalNavigator& NavigationHandler::orbitalNavigator() const {
|
||||
return *_orbitalNavigator;
|
||||
}
|
||||
|
||||
OrbitalNavigator& NavigationHandler::orbitalNavigator() {
|
||||
return *_orbitalNavigator;
|
||||
}
|
||||
|
||||
KeyframeNavigator& NavigationHandler::keyframeNavigator() const {
|
||||
return *_keyframeNavigator;
|
||||
}
|
||||
@@ -139,11 +110,11 @@ bool NavigationHandler::isKeyFrameInteractionEnabled() const {
|
||||
}
|
||||
|
||||
float NavigationHandler::interpolationTime() const {
|
||||
return _orbitalNavigator->rotateToFocusInterpolationTime();
|
||||
return _orbitalNavigator->retargetInterpolationTime();
|
||||
}
|
||||
|
||||
void NavigationHandler::setInterpolationTime(float durationInSeconds) {
|
||||
_orbitalNavigator->setRotateToFocusInterpolationTime(durationInSeconds);
|
||||
_orbitalNavigator->setRetargetInterpolationTime(durationInSeconds);
|
||||
}
|
||||
|
||||
void NavigationHandler::updateCamera(double deltaTime) {
|
||||
@@ -154,14 +125,13 @@ void NavigationHandler::updateCamera(double deltaTime) {
|
||||
_cameraUpdatedFromScript = false;
|
||||
}
|
||||
else if ( ! _playbackModeEnabled ) {
|
||||
if (_camera && focusNode()) {
|
||||
if (_camera) {
|
||||
if (_useKeyFrameInteraction) {
|
||||
_keyframeNavigator->updateCamera(*_camera, _playbackModeEnabled);
|
||||
}
|
||||
else {
|
||||
_orbitalNavigator->updateStatesFromInput(*_inputState, deltaTime);
|
||||
_orbitalNavigator->updateCameraStateFromStates(*_camera, deltaTime);
|
||||
_camera->setFocusPositionVec3(focusNode()->worldPosition());
|
||||
_orbitalNavigator->updateCameraStateFromStates(deltaTime);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -183,21 +153,6 @@ void NavigationHandler::stopPlayback() {
|
||||
_playbackModeEnabled = false;
|
||||
}
|
||||
|
||||
SceneGraphNode* NavigationHandler::focusNode() const {
|
||||
return _orbitalNavigator->focusNode();
|
||||
}
|
||||
|
||||
glm::dvec3 NavigationHandler::focusNodeToCameraVector() const {
|
||||
return _camera->positionVec3() - focusNode()->worldPosition();
|
||||
}
|
||||
|
||||
glm::quat NavigationHandler::focusNodeToCameraRotation() const {
|
||||
glm::dmat4 invWorldRotation = glm::dmat4(
|
||||
glm::inverse(focusNode()->worldRotationMatrix())
|
||||
);
|
||||
return glm::quat(invWorldRotation) * glm::quat(_camera->rotationQuaternion());
|
||||
}
|
||||
|
||||
Camera* NavigationHandler::camera() const {
|
||||
return _camera;
|
||||
}
|
||||
@@ -227,13 +182,15 @@ void NavigationHandler::setCameraStateFromDictionary(const ghoul::Dictionary& ca
|
||||
{
|
||||
bool readSuccessful = true;
|
||||
|
||||
std::string focus;
|
||||
std::string anchor;
|
||||
std::string aim;
|
||||
glm::dvec3 cameraPosition;
|
||||
glm::dvec4 cameraRotation; // Need to read the quaternion as a vector first.
|
||||
|
||||
readSuccessful &= cameraDict.getValue(KeyFocus, focus);
|
||||
readSuccessful &= cameraDict.getValue(KeyAnchor, anchor);
|
||||
readSuccessful &= cameraDict.getValue(KeyPosition, cameraPosition);
|
||||
readSuccessful &= cameraDict.getValue(KeyRotation, cameraRotation);
|
||||
cameraDict.getValue(KeyAim, aim); // Aim is not required
|
||||
|
||||
if (!readSuccessful) {
|
||||
throw ghoul::RuntimeError(
|
||||
@@ -242,7 +199,9 @@ void NavigationHandler::setCameraStateFromDictionary(const ghoul::Dictionary& ca
|
||||
}
|
||||
|
||||
// Set state
|
||||
_origin = focus;
|
||||
_orbitalNavigator->setAnchorNode(anchor);
|
||||
_orbitalNavigator->setAimNode(aim);
|
||||
|
||||
_camera->setPositionVec3(cameraPosition);
|
||||
_camera->setRotation(glm::dquat(
|
||||
cameraRotation.x, cameraRotation.y, cameraRotation.z, cameraRotation.w));
|
||||
@@ -260,7 +219,10 @@ ghoul::Dictionary NavigationHandler::cameraStateDictionary() {
|
||||
ghoul::Dictionary cameraDict;
|
||||
cameraDict.setValue(KeyPosition, cameraPosition);
|
||||
cameraDict.setValue(KeyRotation, cameraRotation);
|
||||
cameraDict.setValue(KeyFocus, focusNode()->identifier());
|
||||
cameraDict.setValue(KeyAnchor, _orbitalNavigator->anchorNode()->identifier());
|
||||
if (_orbitalNavigator->aimNode()) {
|
||||
cameraDict.setValue(KeyAim, _orbitalNavigator->aimNode()->identifier());
|
||||
}
|
||||
|
||||
return cameraDict;
|
||||
}
|
||||
@@ -281,8 +243,16 @@ void NavigationHandler::saveCameraStateToFile(const std::string& filepath) {
|
||||
glm::dquat q = _camera->rotationQuaternion();
|
||||
|
||||
ofs << "return {" << std::endl;
|
||||
ofs << " " << KeyFocus << " = " << "\"" << focusNode()->identifier() << "\""
|
||||
ofs << " " << KeyAnchor << " = " << "\"" <<
|
||||
_orbitalNavigator->anchorNode()->identifier() << "\""
|
||||
<< "," << std::endl;
|
||||
|
||||
if (_orbitalNavigator->aimNode()) {
|
||||
ofs << " " << KeyAim << " = " << "\"" <<
|
||||
_orbitalNavigator->aimNode()->identifier() << "\""
|
||||
<< "," << std::endl;
|
||||
}
|
||||
|
||||
ofs << " " << KeyPosition << " = {"
|
||||
<< std::to_string(p.x) << ", "
|
||||
<< std::to_string(p.y) << ", "
|
||||
@@ -391,11 +361,18 @@ scripting::LuaLibrary NavigationHandler::luaLibrary() {
|
||||
"Restore the camera state from file"
|
||||
},
|
||||
{
|
||||
"resetCameraDirection",
|
||||
&luascriptfunctions::resetCameraDirection,
|
||||
"retargetAnchor",
|
||||
&luascriptfunctions::retargetAnchor,
|
||||
{},
|
||||
"void",
|
||||
"Reset the camera direction to point at the focus node"
|
||||
"Reset the camera direction to point at the anchor node"
|
||||
},
|
||||
{
|
||||
"retargetAim",
|
||||
&luascriptfunctions::retargetAim,
|
||||
{},
|
||||
"void",
|
||||
"Reset the camera direction to point at the aim node"
|
||||
},
|
||||
{
|
||||
"bindJoystickAxis",
|
||||
|
||||
@@ -86,10 +86,19 @@ int saveCameraStateToFile(lua_State* L) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int resetCameraDirection(lua_State* L) {
|
||||
ghoul::lua::checkArgumentsAndThrow(L, 0, "lua::resetCameraDirection");
|
||||
int retargetAnchor(lua_State* L) {
|
||||
ghoul::lua::checkArgumentsAndThrow(L, 0, "lua::retargetAnchor");
|
||||
|
||||
global::navigationHandler.resetCameraDirection();
|
||||
global::navigationHandler.orbitalNavigator().startRetargetAnchor();
|
||||
|
||||
ghoul_assert(lua_gettop(L) == 0, "Incorrect number of items left on stack");
|
||||
return 0;
|
||||
}
|
||||
|
||||
int retargetAim(lua_State* L) {
|
||||
ghoul::lua::checkArgumentsAndThrow(L, 0, "lua::retargetAim");
|
||||
|
||||
global::navigationHandler.orbitalNavigator().startRetargetAim();
|
||||
|
||||
ghoul_assert(lua_gettop(L) == 0, "Incorrect number of items left on stack");
|
||||
return 0;
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -291,9 +291,11 @@ void SessionRecording::cleanUpPlayback() {
|
||||
Scene* scene = camera->parent()->scene();
|
||||
if (!_timeline.empty()) {
|
||||
unsigned int p = _timeline[_idxTimeline_cameraPtrPrev].idxIntoKeyframeTypeArray;
|
||||
global::navigationHandler.setFocusNode(
|
||||
scene->sceneGraphNode(_keyframesCamera[p].focusNode)
|
||||
);
|
||||
const SceneGraphNode* node = scene->sceneGraphNode(_keyframesCamera[p].focusNode);
|
||||
if (node) {
|
||||
global::navigationHandler.orbitalNavigator().setFocusNode(node->identifier());
|
||||
}
|
||||
|
||||
}
|
||||
global::scriptScheduler.stopPlayback();
|
||||
|
||||
@@ -428,8 +430,9 @@ void SessionRecording::saveCameraKeyframe() {
|
||||
return;
|
||||
}
|
||||
|
||||
SceneGraphNode* focusNode = global::navigationHandler.focusNode();
|
||||
if (!focusNode) {
|
||||
const SceneGraphNode* anchorNode =
|
||||
global::navigationHandler.orbitalNavigator().anchorNode();
|
||||
if (!anchorNode) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1150,9 +1153,13 @@ bool SessionRecording::processCameraKeyframe(double now) {
|
||||
// the rendered objects will be unstable and actually incorrect
|
||||
Camera* camera = global::navigationHandler.camera();
|
||||
Scene* scene = camera->parent()->scene();
|
||||
global::navigationHandler.setFocusNode(scene->sceneGraphNode(
|
||||
_keyframesCamera[prevIdx].focusNode
|
||||
));
|
||||
|
||||
const SceneGraphNode* node =
|
||||
scene->sceneGraphNode(_keyframesCamera[prevIdx].focusNode);
|
||||
|
||||
if (node) {
|
||||
global::navigationHandler.orbitalNavigator().setFocusNode(node->identifier());
|
||||
}
|
||||
|
||||
return interaction::KeyframeNavigator::updateCamera(
|
||||
global::navigationHandler.camera(),
|
||||
|
||||
@@ -585,20 +585,22 @@ const std::string& ParallelPeer::hostName() {
|
||||
}
|
||||
|
||||
void ParallelPeer::sendCameraKeyframe() {
|
||||
SceneGraphNode* focusNode = global::navigationHandler.focusNode();
|
||||
const SceneGraphNode* focusNode =
|
||||
global::navigationHandler.orbitalNavigator().anchorNode();
|
||||
if (!focusNode) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Create a keyframe with current position and orientation of camera
|
||||
datamessagestructures::CameraKeyframe kf;
|
||||
kf._position = global::navigationHandler.focusNodeToCameraVector();
|
||||
kf._position = global::navigationHandler.orbitalNavigator().anchorNodeToCameraVector();
|
||||
|
||||
kf._followNodeRotation =
|
||||
global::navigationHandler.orbitalNavigator().followingNodeRotation();
|
||||
if (kf._followNodeRotation) {
|
||||
kf._position = glm::inverse(focusNode->worldRotationMatrix()) * kf._position;
|
||||
kf._rotation = global::navigationHandler.focusNodeToCameraRotation();
|
||||
kf._rotation =
|
||||
global::navigationHandler.orbitalNavigator().anchorNodeToCameraRotation();
|
||||
}
|
||||
else {
|
||||
kf._rotation = global::navigationHandler.camera()->rotationQuaternion();
|
||||
|
||||
@@ -364,22 +364,22 @@ std::string PropertyOwner::generateJson() const {
|
||||
std::function<std::string(properties::PropertyOwner*)> createJson =
|
||||
[&createJson](properties::PropertyOwner* owner) -> std::string
|
||||
{
|
||||
constexpr const char* replStr = R"("{}": "{}",)";
|
||||
constexpr const char* replStr = R"("{}": "{}")";
|
||||
|
||||
std::stringstream json;
|
||||
json << "{";
|
||||
json << fmt::format(replStr, "name", owner->identifier());
|
||||
json << fmt::format(replStr, "name", owner->identifier()) << ",";
|
||||
|
||||
json << "\"properties\": [";
|
||||
const std::vector<properties::Property*>& properties = owner->properties();
|
||||
for (properties::Property* p : properties) {
|
||||
json << "{";
|
||||
json << fmt::format(replStr, "id", p->identifier());
|
||||
json << fmt::format(replStr, "type", p->className());
|
||||
json << fmt::format(replStr, "id", p->identifier()) << ",";
|
||||
json << fmt::format(replStr, "type", p->className()) << ",";
|
||||
json << fmt::format(
|
||||
replStr, "fullyQualifiedId", p->fullyQualifiedIdentifier()
|
||||
);
|
||||
json << fmt::format(replStr, "guiName", p->guiName());
|
||||
) << ",";
|
||||
json << fmt::format(replStr, "guiName", p->guiName()) << ",";
|
||||
json << fmt::format(replStr, "description", escapedJson(p->description()));
|
||||
json << "}";
|
||||
if (p != properties.back()) {
|
||||
|
||||
@@ -37,6 +37,9 @@ Scene* sceneGraph() {
|
||||
|
||||
SceneGraphNode* sceneGraphNode(const std::string& name) {
|
||||
const Scene* graph = sceneGraph();
|
||||
if (!graph) {
|
||||
return nullptr;
|
||||
}
|
||||
return graph->sceneGraphNode(name);
|
||||
}
|
||||
|
||||
|
||||
@@ -165,7 +165,7 @@ void Renderable::setPscUniforms(ghoul::opengl::ProgramObject& program,
|
||||
const Camera& camera,
|
||||
const PowerScaledCoordinate& position)
|
||||
{
|
||||
program.setUniform("campos", camera.position().vec4());
|
||||
program.setUniform("campos", glm::vec4(camera.positionVec3(), 1.f));
|
||||
program.setUniform("objpos", position.vec4());
|
||||
program.setUniform("camrot", glm::mat4(camera.viewRotationMatrix()));
|
||||
program.setUniform("scaling", glm::vec2(1.f, 0.f));
|
||||
|
||||
@@ -49,6 +49,8 @@ namespace {
|
||||
|
||||
constexpr const char* KeyTimeFrame = "TimeFrame";
|
||||
|
||||
constexpr const char* KeyFixedBoundingSphere = "FixedBoundingSphere";
|
||||
|
||||
constexpr openspace::properties::Property::PropertyInfo GuiPathInfo = {
|
||||
"GuiPath",
|
||||
"Gui Path",
|
||||
@@ -220,6 +222,12 @@ std::unique_ptr<SceneGraphNode> SceneGraphNode::createFromDictionary(
|
||||
result->addProperty(result->_guiPath);
|
||||
}
|
||||
|
||||
if (dictionary.hasKey(KeyFixedBoundingSphere)) {
|
||||
result->_fixedBoundingSphere = static_cast<float>(
|
||||
dictionary.value<double>(KeyFixedBoundingSphere)
|
||||
);
|
||||
}
|
||||
|
||||
LDEBUG(fmt::format("Successfully created SceneGraphNode '{}'", result->identifier()));
|
||||
return result;
|
||||
}
|
||||
@@ -588,7 +596,7 @@ void SceneGraphNode::setDependencies(const std::vector<SceneGraphNode*>& depende
|
||||
}
|
||||
|
||||
SurfacePositionHandle SceneGraphNode::calculateSurfacePositionHandle(
|
||||
const glm::dvec3& targetModelSpace)
|
||||
const glm::dvec3& targetModelSpace) const
|
||||
{
|
||||
if (_renderable) {
|
||||
return _renderable->calculateSurfacePositionHandle(targetModelSpace);
|
||||
@@ -737,11 +745,11 @@ std::vector<SceneGraphNode*> SceneGraphNode::children() const {
|
||||
return nodes;
|
||||
}
|
||||
|
||||
float SceneGraphNode::boundingSphere() const{
|
||||
float SceneGraphNode::boundingSphere() const {
|
||||
if (_renderable) {
|
||||
return _renderable->boundingSphere();
|
||||
}
|
||||
return 0.0;
|
||||
return _fixedBoundingSphere;
|
||||
}
|
||||
|
||||
// renderable
|
||||
@@ -809,19 +817,4 @@ const SceneGraphNode::PerformanceRecord& SceneGraphNode::performanceRecord() con
|
||||
return _performanceRecord;
|
||||
}
|
||||
|
||||
void SceneGraphNode::updateCamera(Camera* camera) const {
|
||||
psc origin(worldPosition());
|
||||
//int i = 0;
|
||||
// the camera position
|
||||
|
||||
psc relative = camera->position();
|
||||
psc focus = camera->focusPosition();
|
||||
psc relative_focus = relative - focus;
|
||||
|
||||
psc target = origin + relative_focus;
|
||||
|
||||
camera->setPosition(target);
|
||||
camera->setFocusPosition(origin);
|
||||
}
|
||||
|
||||
} // namespace openspace
|
||||
|
||||
@@ -28,15 +28,14 @@
|
||||
|
||||
namespace openspace {
|
||||
|
||||
const glm::dvec3 Camera::ViewDirectionCameraSpace = glm::dvec3(0, 0, -1);
|
||||
const glm::dvec3 Camera::LookupVectorCameraSpace = glm::dvec3(0, 1, 0);
|
||||
const glm::dvec3 Camera::ViewDirectionCameraSpace = glm::dvec3(0.0, 0.0, -1.0);
|
||||
const glm::dvec3 Camera::UpDirectionCameraSpace = glm::dvec3(0.0, 1.0, 0.0);
|
||||
|
||||
Camera::Camera(const Camera& o)
|
||||
: sgctInternal(o.sgctInternal)
|
||||
, _position(o._position)
|
||||
, _rotation(o._rotation)
|
||||
, _scaling(o._scaling)
|
||||
, _focusPosition(o._focusPosition)
|
||||
, _maxFov(o._maxFov)
|
||||
, _cachedViewDirection(o._cachedViewDirection)
|
||||
, _cachedLookupVector(o._cachedLookupVector)
|
||||
@@ -49,11 +48,6 @@ void Camera::setPositionVec3(glm::dvec3 pos) {
|
||||
_cachedCombinedViewMatrix.isDirty = true;
|
||||
}
|
||||
|
||||
void Camera::setFocusPositionVec3(glm::dvec3 pos) {
|
||||
std::lock_guard<std::mutex> _lock(_mutex);
|
||||
_focusPosition = std::move(pos);
|
||||
}
|
||||
|
||||
void Camera::setRotation(glm::dquat rotation) {
|
||||
std::lock_guard<std::mutex> _lock(_mutex);
|
||||
_rotation = std::move(rotation);
|
||||
@@ -116,30 +110,26 @@ const glm::dvec3& Camera::unsynchedPositionVec3() const {
|
||||
return _position;
|
||||
}
|
||||
|
||||
const glm::dvec3& Camera::focusPositionVec3() const {
|
||||
return _focusPosition;
|
||||
}
|
||||
|
||||
const glm::dvec3& Camera::viewDirectionWorldSpace() const {
|
||||
if (_cachedViewDirection.isDirty) {
|
||||
_cachedViewDirection.datum = glm::normalize(
|
||||
static_cast<glm::dquat>(_rotation) * ViewDirectionCameraSpace
|
||||
);
|
||||
_cachedViewDirection.isDirty = true;
|
||||
_cachedViewDirection.isDirty = false;
|
||||
}
|
||||
return _cachedViewDirection.datum;
|
||||
}
|
||||
|
||||
const glm::dvec3& Camera::lookUpVectorCameraSpace() const {
|
||||
return LookupVectorCameraSpace;
|
||||
return UpDirectionCameraSpace;
|
||||
}
|
||||
|
||||
const glm::dvec3& Camera::lookUpVectorWorldSpace() const {
|
||||
if (_cachedLookupVector.isDirty) {
|
||||
_cachedLookupVector.datum = glm::normalize(
|
||||
static_cast<glm::dquat>(_rotation) * LookupVectorCameraSpace
|
||||
static_cast<glm::dquat>(_rotation) * UpDirectionCameraSpace
|
||||
);
|
||||
_cachedLookupVector.isDirty = true;
|
||||
_cachedLookupVector.isDirty = false;
|
||||
}
|
||||
|
||||
return _cachedLookupVector.datum;
|
||||
@@ -170,6 +160,7 @@ const glm::dmat4& Camera::viewRotationMatrix() const {
|
||||
_cachedViewRotationMatrix.datum = glm::mat4_cast(
|
||||
glm::inverse(static_cast<glm::dquat>(_rotation))
|
||||
);
|
||||
_cachedViewRotationMatrix.isDirty = false;
|
||||
}
|
||||
return _cachedViewRotationMatrix.datum;
|
||||
}
|
||||
@@ -177,6 +168,7 @@ const glm::dmat4& Camera::viewRotationMatrix() const {
|
||||
const glm::dmat4& Camera::viewScaleMatrix() const {
|
||||
if (_cachedViewScaleMatrix.isDirty) {
|
||||
_cachedViewScaleMatrix.datum = glm::scale(glm::mat4(1.f), glm::vec3(_scaling));
|
||||
_cachedViewScaleMatrix.isDirty = false;
|
||||
}
|
||||
return _cachedViewScaleMatrix.datum;
|
||||
}
|
||||
@@ -195,7 +187,7 @@ const glm::dmat4& Camera::combinedViewMatrix() const {
|
||||
glm::dmat4(viewScaleMatrix()) *
|
||||
glm::dmat4(viewRotationMatrix()) *
|
||||
cameraTranslation;
|
||||
_cachedCombinedViewMatrix.isDirty = true;
|
||||
_cachedCombinedViewMatrix.isDirty = false;
|
||||
}
|
||||
return _cachedCombinedViewMatrix.datum;
|
||||
}
|
||||
@@ -205,6 +197,8 @@ void Camera::invalidateCache() {
|
||||
_cachedLookupVector.isDirty = true;
|
||||
_cachedViewRotationMatrix.isDirty = true;
|
||||
_cachedCombinedViewMatrix.isDirty = true;
|
||||
_cachedViewScaleMatrix.isDirty = true;
|
||||
_cachedSinMaxFov.isDirty = true;
|
||||
}
|
||||
|
||||
void Camera::serialize(std::ostream& os) const {
|
||||
@@ -270,29 +264,6 @@ const glm::mat4& Camera::SgctInternal::viewProjectionMatrix() const {
|
||||
return _cachedViewProjectionMatrix.datum;
|
||||
}
|
||||
|
||||
// Deprecated
|
||||
void Camera::setPosition(psc pos) {
|
||||
std::lock_guard<std::mutex> _lock(_mutex);
|
||||
_position = pos.dvec3();
|
||||
}
|
||||
|
||||
void Camera::setFocusPosition(psc pos) {
|
||||
std::lock_guard<std::mutex> _lock(_mutex);
|
||||
_focusPosition = pos.dvec3();
|
||||
}
|
||||
|
||||
psc Camera::position() const {
|
||||
return psc(static_cast<glm::dvec3>(_position));
|
||||
}
|
||||
|
||||
psc Camera::unsynchedPosition() const {
|
||||
return psc(static_cast<glm::dvec3>(_position));
|
||||
}
|
||||
|
||||
psc Camera::focusPosition() const {
|
||||
return psc(_focusPosition);
|
||||
}
|
||||
|
||||
const glm::mat4& Camera::viewMatrix() const {
|
||||
return sgctInternal.viewMatrix();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user