mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-03-01 09:08:49 -06:00
Merge branch 'feature/interactionhandler' into develop
Conflicts: include/openspace/engine/openspaceengine.h include/openspace/interaction/interactionhandler.h src/engine/openspaceengine.cpp src/interaction/interactionhandler.cpp src/rendering/renderengine.cpp
This commit is contained in:
@@ -22,65 +22,109 @@
|
||||
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
|
||||
****************************************************************************************/
|
||||
|
||||
#ifndef INTERACTIONHANDLER_H
|
||||
#define INTERACTIONHANDLER_H
|
||||
//<<<<<<< HEAD
|
||||
//#ifndef INTERACTIONHANDLER_H
|
||||
//#define INTERACTIONHANDLER_H
|
||||
//
|
||||
//#include <openspace/scripting/scriptengine.h>
|
||||
//#include <openspace/util/powerscaledcoordinate.h>
|
||||
//#include <openspace/util/powerscaledscalar.h>
|
||||
//
|
||||
//// std includes
|
||||
//#include <vector>
|
||||
//#include <mutex>
|
||||
//#include <map>
|
||||
//#include <functional>
|
||||
//
|
||||
//namespace openspace {
|
||||
//
|
||||
//// Forward declare to minimize dependencies
|
||||
//class Camera;
|
||||
//class SceneGraphNode;
|
||||
//class ExternalControl;
|
||||
//
|
||||
//class InteractionHandler {
|
||||
//public:
|
||||
// InteractionHandler(void);
|
||||
// InteractionHandler(const InteractionHandler& src);
|
||||
// InteractionHandler& operator=(const InteractionHandler& rhs);
|
||||
// virtual ~InteractionHandler();
|
||||
//
|
||||
// void enable();
|
||||
// void disable();
|
||||
// const bool isEnabled() const;
|
||||
//
|
||||
// void connectDevices();
|
||||
// void addExternalControl(ExternalControl* controller);
|
||||
//
|
||||
// void setCamera(Camera *camera = nullptr);
|
||||
// void setOrigin(SceneGraphNode* node);
|
||||
//
|
||||
// Camera* getCamera() const;
|
||||
// const psc getOrigin() const;
|
||||
// void lockControls();
|
||||
// void unlockControls();
|
||||
//
|
||||
// void setFocusNode(SceneGraphNode *node);
|
||||
//
|
||||
// void orbit(const glm::quat &rotation);
|
||||
// void rotate(const glm::quat &rotation);
|
||||
// void distance(const PowerScaledScalar &distance, size_t iterations = 0);
|
||||
//=======
|
||||
#ifndef __INTERACTIONHANDLER_H__
|
||||
#define __INTERACTIONHANDLER_H__
|
||||
|
||||
#include <openspace/scripting/scriptengine.h>
|
||||
#include <openspace/util/powerscaledcoordinate.h>
|
||||
#include <openspace/util/powerscaledscalar.h>
|
||||
#include <openspace/interaction/keyboardcontroller.h>
|
||||
#include <openspace/interaction/mousecontroller.h>
|
||||
|
||||
// std includes
|
||||
#include <vector>
|
||||
#include <mutex>
|
||||
#include <map>
|
||||
#include <functional>
|
||||
|
||||
namespace openspace {
|
||||
|
||||
// Forward declare to minimize dependencies
|
||||
class Camera;
|
||||
class SceneGraphNode;
|
||||
class ExternalControl;
|
||||
|
||||
namespace interaction {
|
||||
|
||||
class InteractionHandler {
|
||||
public:
|
||||
InteractionHandler(void);
|
||||
InteractionHandler(const InteractionHandler& src);
|
||||
InteractionHandler& operator=(const InteractionHandler& rhs);
|
||||
virtual ~InteractionHandler();
|
||||
InteractionHandler();
|
||||
|
||||
void enable();
|
||||
void disable();
|
||||
const bool isEnabled() const;
|
||||
~InteractionHandler();
|
||||
|
||||
void connectDevices();
|
||||
void addExternalControl(ExternalControl* controller);
|
||||
void setKeyboardController(KeyboardController* controller);
|
||||
void setMouseController(MouseController* controller);
|
||||
void addController(Controller* controller);
|
||||
|
||||
void setCamera(Camera *camera = nullptr);
|
||||
void setOrigin(SceneGraphNode* node);
|
||||
|
||||
Camera* getCamera() const;
|
||||
const psc getOrigin() const;
|
||||
void lockControls();
|
||||
void unlockControls();
|
||||
|
||||
void setFocusNode(SceneGraphNode *node);
|
||||
|
||||
void orbit(const glm::quat &rotation);
|
||||
void rotate(const glm::quat &rotation);
|
||||
void distance(const PowerScaledScalar &distance, size_t iterations = 0);
|
||||
void update(double deltaTime);
|
||||
|
||||
void lookAt(const glm::quat &rotation);
|
||||
void setRotation(const glm::quat &rotation);
|
||||
|
||||
void update(const double dt);
|
||||
|
||||
double dt();
|
||||
void setFocusNode(SceneGraphNode* node);
|
||||
const SceneGraphNode* const focusNode() const;
|
||||
void setCamera(Camera* camera);
|
||||
const Camera* const camera() const;
|
||||
|
||||
void keyboardCallback(int key, int action);
|
||||
void mouseButtonCallback(int key, int action);
|
||||
void mousePositionCallback(int x, int y);
|
||||
void mouseScrollWheelCallback(int pos);
|
||||
void mouseButtonCallback(int button, int action);
|
||||
void mousePositionCallback(int x, int y);
|
||||
void mouseScrollWheelCallback(int pos);
|
||||
|
||||
//<<<<<<< HEAD
|
||||
//double dt();
|
||||
//=======
|
||||
double deltaTime() const;
|
||||
|
||||
void orbitDelta(const glm::quat& rotation);
|
||||
|
||||
void rotateDelta(const glm::quat& rotation);
|
||||
|
||||
void distanceDelta(const PowerScaledScalar& distance);
|
||||
|
||||
void lookAt(const glm::quat& rotation);
|
||||
|
||||
void setRotation(const glm::quat& rotation);
|
||||
|
||||
void resetKeyBindings();
|
||||
void bindKey(int key, const std::string& lua);
|
||||
@@ -95,30 +139,47 @@ public:
|
||||
static scripting::ScriptEngine::LuaLibrary luaLibrary();
|
||||
|
||||
private:
|
||||
glm::vec3 mapToTrackball(glm::vec2 mousePos);
|
||||
glm::vec3 mapToCamera(glm::vec3 trackballPos);
|
||||
void trackballRotate(int x, int y);
|
||||
friend class Controller;
|
||||
|
||||
//<<<<<<< HEAD
|
||||
// Camera* _camera;
|
||||
// bool _enabled;
|
||||
// SceneGraphNode* _node;
|
||||
//
|
||||
// double _dt;
|
||||
//=======
|
||||
InteractionHandler(const InteractionHandler&) = delete;
|
||||
InteractionHandler& operator=(const InteractionHandler&) = delete;
|
||||
InteractionHandler(InteractionHandler&&) = delete;
|
||||
InteractionHandler& operator=(InteractionHandler&&) = delete;
|
||||
|
||||
Camera* _camera;
|
||||
bool _enabled;
|
||||
SceneGraphNode* _node;
|
||||
|
||||
double _dt;
|
||||
SceneGraphNode* _focusNode;
|
||||
|
||||
glm::vec3 _lastTrackballPos;
|
||||
bool _leftMouseButtonDown, _isMouseBeingPressedAndHeld;
|
||||
double _deltaTime;
|
||||
std::mutex _mutex;
|
||||
|
||||
// used for calling when updating and deallocation
|
||||
std::vector<ExternalControl*> _controllers;
|
||||
|
||||
// for locking and unlocking
|
||||
std::mutex _cameraGuard;
|
||||
//<<<<<<< HEAD
|
||||
// // used for calling when updating and deallocation
|
||||
// std::vector<ExternalControl*> _controllers;
|
||||
//
|
||||
// // for locking and unlocking
|
||||
// std::mutex _cameraGuard;
|
||||
|
||||
bool _validKeyLua;
|
||||
std::multimap<int, std::string > _keyLua;
|
||||
|
||||
KeyboardController* _keyboardController;
|
||||
MouseController* _mouseController;
|
||||
std::vector<Controller*> _controllers;
|
||||
|
||||
|
||||
// glm::vec3 mapToTrackball(glm::vec2 mousePos);
|
||||
// glm::vec3 mapToCamera(glm::vec3 trackballPos);
|
||||
// void trackballRotate(int x, int y);
|
||||
};
|
||||
|
||||
} // namespace interaction
|
||||
} // namespace openspace
|
||||
|
||||
#endif
|
||||
#endif // __INTERACTIONHANDLER_H__
|
||||
|
||||
Reference in New Issue
Block a user