mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-01-16 08:51:26 -06:00
* Removal of dead code and compiler warnings
* Added basic internal touch
This commit only adds the description-shell of the touch implementation
* Added callbacks and first WIP of internal touch
Makes use of the TouchInput/TouchInputs class in the TouchModule.
Internally we cache the TouchInputs as an input deque and utilizes it
for motion-vectors.
This commit has bugs and issues, which will be worked upon.
* Happy new year!
Bumped year on branch-local files
* Improvements to internal touch
Almost reached feature-parity with tuio-handled touch events
- Added most of the touch-logic to touchinteraction
- Added helper functions to new TouchInput/TouchInputs classes
* Naming changes to touch interface
* Translate TUIO to TouchInput
This commit translates TUIO messages to an internal TouchInput structure
while still trying to keep feature parity.
Removed TUIO-dependencies from many files.
Changed behavior on tuioear to lock-swap its content.
* Minor cleanup and fixes
- Should fix touch roll
- Simplified some functions
* Build fix
* Use internal touch in webgui
- Added consume-logic to touch callbacks
- Constrained touch-input to either webgui or 3D application as mouse is
- This fixes some flaws with previous implementation,
such as ghost inputs
- Initialize touchmodule through init-functions rather than constructor
* Cleanup of comments
* Simplified touch classes
Added timestamp through constructor meaning no more sprinkled timestamps
Renamed TouchInputs to TouchInputHolder for clarity
Added helper functions to the Holder to see if it holds an input
Remade addInput as tryAddInput which return true on successful insertion
+ other cleanup
* Code style cleanup and tweaks
Removed avoidable zero-comparison for code clarity
Cleanup of code style
* Added comments to DirectInputSolver
Clarifying the use of the DirectInputSolver.
* Changes for coding style
Change SGCT version to make it checkout-able
* Clarify magic bitmask
* const -> constexpr const for magic bitmasks
Co-authored-by: Alexander Bock <mail@alexanderbock.eu>
175 lines
7.2 KiB
C++
175 lines
7.2 KiB
C++
/*****************************************************************************************
|
|
* *
|
|
* OpenSpace *
|
|
* *
|
|
* Copyright (c) 2014-2019 *
|
|
* *
|
|
* 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___CAMERA___H__
|
|
#define __OPENSPACE_CORE___CAMERA___H__
|
|
|
|
#include <openspace/util/syncdata.h>
|
|
#include <ghoul/glm.h>
|
|
#include <mutex>
|
|
|
|
namespace openspace {
|
|
|
|
class SceneGraphNode;
|
|
|
|
/**
|
|
* This class still needs some more love. Suggested improvements:
|
|
* - Accessors should return constant references to double precision class members.
|
|
* - Remove the scaling variable (What is it used for?)
|
|
* - Remove the maxFov and sinMaxfov variables. Redundant since the fov is embedded
|
|
* within the perspective projection matrix.
|
|
* - Remove focusposition, part of the integration with the scale graph. The
|
|
* "focus position" should not be needed since we assume the camera is always
|
|
* positioned relative to its origin. When orbiting another object (not in origin),
|
|
* the focus position should probably be handled outside the camera class
|
|
* (interaction handler) since it does not affect the state of the camera
|
|
* (only how it interacts).
|
|
* - The class might need some more reasonable accessors depending on use cases.
|
|
* (up vector world space?)
|
|
* - Make clear which function returns a combined view matrix (things that are
|
|
* dependent on the separate sgct nodes).
|
|
*/
|
|
class Camera {
|
|
public:
|
|
/**
|
|
* Used to explicitly show which variables within the Camera class that are used
|
|
* for caching.
|
|
*/
|
|
template<typename T>
|
|
struct Cached {
|
|
Cached() { isDirty = true; }
|
|
T datum;
|
|
bool isDirty;
|
|
};
|
|
|
|
Camera() = default;
|
|
Camera(const Camera& o);
|
|
~Camera() = default;
|
|
|
|
// Mutators
|
|
void setPositionVec3(glm::dvec3 pos);
|
|
void setRotation(glm::dquat rotation);
|
|
void setScaling(float scaling);
|
|
void setMaxFov(float fov);
|
|
void setParent(SceneGraphNode* parent);
|
|
|
|
// Relative mutators
|
|
void rotate(glm::dquat rotation);
|
|
|
|
// Accessors
|
|
// Remove Vec3 from the name when psc is gone
|
|
const glm::dvec3& positionVec3() const;
|
|
glm::dvec3 eyePositionVec3() const;
|
|
const glm::dvec3& unsynchedPositionVec3() const;
|
|
const glm::dvec3& viewDirectionWorldSpace() const;
|
|
const glm::dvec3& lookUpVectorCameraSpace() const;
|
|
const glm::dvec3& lookUpVectorWorldSpace() const;
|
|
const glm::dmat4& viewRotationMatrix() const;
|
|
const glm::dmat4& viewScaleMatrix() const;
|
|
const glm::dquat& rotationQuaternion() const;
|
|
float maxFov() const;
|
|
float sinMaxFov() const;
|
|
SceneGraphNode* parent() const;
|
|
float scaling() const;
|
|
|
|
// @TODO this should simply be called viewMatrix!
|
|
// Or it needs to be changed so that it actually is combined. Right now it is
|
|
// only the view matrix that is the same for all SGCT cameras.
|
|
// Right now this function returns the actual combined matrix which makes some
|
|
// of the old calls to the function wrong..
|
|
const glm::dmat4& combinedViewMatrix() const;
|
|
|
|
void invalidateCache();
|
|
|
|
void serialize(std::ostream& os) const;
|
|
void deserialize(std::istream& is);
|
|
|
|
/**
|
|
* Handles SGCT's internal matrices. Also caches a calculated viewProjection
|
|
* matrix. This is the data that is different for different cameras within SGCT.
|
|
*/
|
|
class SgctInternal {
|
|
friend class Camera;
|
|
public:
|
|
void setSceneMatrix(glm::mat4 sceneMatrix);
|
|
void setViewMatrix(glm::mat4 viewMatrix);
|
|
void setProjectionMatrix(glm::mat4 projectionMatrix);
|
|
|
|
const glm::mat4& sceneMatrix() const;
|
|
const glm::mat4& viewMatrix() const;
|
|
const glm::mat4& projectionMatrix() const;
|
|
const glm::mat4& viewProjectionMatrix() const;
|
|
|
|
private:
|
|
SgctInternal() = default;
|
|
SgctInternal(const SgctInternal& o);
|
|
|
|
glm::mat4 _sceneMatrix;
|
|
glm::mat4 _viewMatrix;
|
|
glm::mat4 _projectionMatrix;
|
|
|
|
mutable Cached<glm::mat4> _cachedViewProjectionMatrix;
|
|
mutable std::mutex _mutex;
|
|
} sgctInternal;
|
|
|
|
// @TODO use Camera::SgctInternal interface instead
|
|
// [[deprecated("Replaced by Camera::SgctInternal::viewMatrix()")]]
|
|
const glm::mat4& viewMatrix() const;
|
|
// [[deprecated("Replaced by Camera::SgctInternal::projectionMatrix()")]]
|
|
const glm::mat4& projectionMatrix() const;
|
|
// [[deprecated("Replaced by Camera::SgctInternal::viewProjectionMatrix()")]]
|
|
const glm::mat4& viewProjectionMatrix() const;
|
|
|
|
std::vector<Syncable*> getSyncables();
|
|
|
|
// Static constants
|
|
static const glm::dvec3 ViewDirectionCameraSpace;
|
|
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));
|
|
SyncData<float> _scaling = 1.f;
|
|
SceneGraphNode* _parent = nullptr;
|
|
|
|
// _focusPosition to be removed
|
|
glm::dvec3 _focusPosition;
|
|
float _maxFov = 0.f;
|
|
|
|
// Cached data
|
|
mutable Cached<glm::dvec3> _cachedViewDirection;
|
|
mutable Cached<glm::dvec3> _cachedLookupVector;
|
|
mutable Cached<glm::dmat4> _cachedViewRotationMatrix;
|
|
mutable Cached<glm::dmat4> _cachedViewScaleMatrix;
|
|
mutable Cached<glm::dmat4> _cachedCombinedViewMatrix;
|
|
mutable Cached<float> _cachedSinMaxFov;
|
|
|
|
mutable std::mutex _mutex;
|
|
};
|
|
|
|
} // namespace openspace
|
|
|
|
#endif // __OPENSPACE_CORE___CAMERA___H__
|