diff --git a/include/openspace/interaction/interactionhandler.h b/include/openspace/interaction/interactionhandler.h index 2b56ebe881..183ae0c0ca 100644 --- a/include/openspace/interaction/interactionhandler.h +++ b/include/openspace/interaction/interactionhandler.h @@ -76,6 +76,7 @@ #include #include +#include #include @@ -94,6 +95,7 @@ public: void setKeyboardController(KeyboardController* controller); void setMouseController(MouseController* controller); + void setRemoteController(RemoteController* controller); void addController(Controller* controller); void lockControls(); @@ -171,6 +173,7 @@ private: KeyboardController* _keyboardController; MouseController* _mouseController; + RemoteController* _remoteController; std::vector _controllers; }; diff --git a/include/openspace/interaction/remotecontroller.h b/include/openspace/interaction/remotecontroller.h new file mode 100644 index 0000000000..e23f020c75 --- /dev/null +++ b/include/openspace/interaction/remotecontroller.h @@ -0,0 +1,58 @@ +/***************************************************************************************** +* * +* OpenSpace * +* * +* Copyright (c) 2014-2015 * +* * +* 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 __REMOTECONTROLLER_H__ +#define __REMOTECONTROLLER_H__ + +#include +#include + +#include + +namespace openspace { + namespace interaction { + + struct ControllerKeyFrame{ + glm::mat4 _viewRotationMatrix; + psc _position; + double _timeStamp; + }; + + class RemoteController : public Controller { + public: + RemoteController(); + virtual ~RemoteController(); + virtual void update(const double& dt); + virtual void sendKeyFrame(); + virtual void keyFrameReceived(const ControllerKeyFrame& keyframe); + protected: + bool _isBroadcasting; + double _lastTimeStap; + std::ifstream ff; + }; + + } // namespace interaction +} // namespace openspace + +#endif // __REMOTECONTROLLER_H__ \ No newline at end of file diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 2c1f8518cb..0e1b46fb41 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -34,6 +34,7 @@ set(OPENSPACE_SOURCE ${OPENSPACE_BASE_DIR}/src/engine/moduleengine.cpp ${OPENSPACE_BASE_DIR}/src/engine/openspaceengine.cpp ${OPENSPACE_BASE_DIR}/src/interaction/controller.cpp + ${OPENSPACE_BASE_DIR}/src/interaction/remotecontroller.cpp ${OPENSPACE_BASE_DIR}/src/interaction/deviceidentifier.cpp ${OPENSPACE_BASE_DIR}/src/interaction/interactionhandler.cpp ${OPENSPACE_BASE_DIR}/src/interaction/interactionhandler_lua.inl @@ -99,6 +100,7 @@ set(OPENSPACE_HEADER ${OPENSPACE_BASE_DIR}/include/openspace/engine/moduleengine.h ${OPENSPACE_BASE_DIR}/include/openspace/engine/openspaceengine.h ${OPENSPACE_BASE_DIR}/include/openspace/interaction/controller.h + ${OPENSPACE_BASE_DIR}/include/openspace/interaction/remotecontroller.h ${OPENSPACE_BASE_DIR}/include/openspace/interaction/deviceidentifier.h ${OPENSPACE_BASE_DIR}/include/openspace/interaction/interactionhandler.h ${OPENSPACE_BASE_DIR}/include/openspace/interaction/keyboardcontroller.h diff --git a/src/engine/openspaceengine.cpp b/src/engine/openspaceengine.cpp index 6264d9db7c..95c69e3f34 100644 --- a/src/engine/openspaceengine.cpp +++ b/src/engine/openspaceengine.cpp @@ -350,6 +350,9 @@ bool OpenSpaceEngine::initialize() { //_interactionHandler.setMouseController(new interaction::TrackballMouseController); _interactionHandler->setMouseController(new interaction::OrbitalMouseController); + //@TODO fix this -JK + _interactionHandler->setRemoteController(new interaction::RemoteController); + // Run start up scripts runStartupScripts(); diff --git a/src/interaction/interactionhandler.cpp b/src/interaction/interactionhandler.cpp index 76668e95e0..3c4ae90b30 100644 --- a/src/interaction/interactionhandler.cpp +++ b/src/interaction/interactionhandler.cpp @@ -253,6 +253,7 @@ InteractionHandler::InteractionHandler() , _invertRotation(false) , _keyboardController(nullptr) , _mouseController(nullptr) + , _remoteController(nullptr) { } @@ -277,6 +278,13 @@ void InteractionHandler::setMouseController(MouseController* controller) { _mouseController->setHandler(this); } +void InteractionHandler::setRemoteController(RemoteController* controller) { + assert(controller); + delete _remoteController; + _remoteController = controller; + _remoteController->setHandler(this); +} + void InteractionHandler::addController(Controller* controller) { assert(controller); _controllers.push_back(controller); @@ -347,6 +355,7 @@ void InteractionHandler::unlockControls() { void InteractionHandler::update(double deltaTime) { _deltaTime = deltaTime; _mouseController->update(deltaTime); + _remoteController->update(deltaTime); } void InteractionHandler::setFocusNode(SceneGraphNode* node) { @@ -463,7 +472,7 @@ void InteractionHandler::orbit(const float &dx, const float &dy, const float &dz _camera->setFocusPosition(origin); _camera->setPosition(target); _camera->rotate(glm::quat_cast(transform)); - + unlockControls(); } diff --git a/src/interaction/remotecontroller.cpp b/src/interaction/remotecontroller.cpp new file mode 100644 index 0000000000..7d770ebb72 --- /dev/null +++ b/src/interaction/remotecontroller.cpp @@ -0,0 +1,68 @@ +/***************************************************************************************** + * * + * OpenSpace * + * * + * Copyright (c) 2014-2015 * + * * + * 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. * + ****************************************************************************************/ + +#include + +#include + +#include + +#include + +namespace openspace { +namespace interaction { + + RemoteController::RemoteController() + : _isBroadcasting(false), + _lastTimeStap(0.0) + { + //ff.open("path.txt"); + } + + RemoteController::~RemoteController(){ + + } + + void RemoteController::update(const double& dt){ + ControllerKeyFrame kf; + kf._position = _handler->camera()->position(); + kf._viewRotationMatrix = _handler->camera()->viewRotationMatrix(); + kf._timeStamp = Time::ref().currentTime(); + + std::string write = std::to_string(kf._position.vec4().x) + "\t" + std::to_string(kf._position.vec4().y) + "\t" + std::to_string(kf._position.vec4().z) + "\t" + std::to_string(kf._position.vec4().w) + "\n"; + //write += + printf("%s", write.c_str()); + } + + void RemoteController::sendKeyFrame(){ + + } + + void RemoteController::keyFrameReceived(const ControllerKeyFrame& keyframe){ + + } + + +} // namespace interaction +} // namespace openspace