From 305a75c2b74a4b43831164e87272699d8f531af8 Mon Sep 17 00:00:00 2001 From: Philip Rosedale Date: Thu, 12 Dec 2013 12:33:04 -0800 Subject: [PATCH 1/9] =?UTF-8?q?don=E2=80=99t=20render=20toy=20ball=20if=20?= =?UTF-8?q?hand=20controller=20trigger=20not=20pressed=20at=20all?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- interface/src/avatar/Hand.cpp | 6 +++++- interface/src/avatar/Hand.h | 2 ++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/interface/src/avatar/Hand.cpp b/interface/src/avatar/Hand.cpp index a085a42953..cc4c64d1e5 100755 --- a/interface/src/avatar/Hand.cpp +++ b/interface/src/avatar/Hand.cpp @@ -42,6 +42,7 @@ Hand::Hand(Avatar* owningAvatar) : _toyBallVelocity(0), _toyBallInHand(false), _hasToyBall(false), + _toyBallShouldRender(false), _ballParticleEditHandle(NULL), _pitchUpdate(0) { @@ -61,9 +62,11 @@ void Hand::reset() { } void Hand::simulateToyBall(PalmData& palm, const glm::vec3& fingerTipPosition, float deltaTime) { + // Is the controller button being held down.... if (palm.getControllerButtons() & BUTTON_FWD) { // If grabbing toy ball, add forces to it. + _toyBallShouldRender = true; // If we don't currently have a ball in hand, then create it... if (!_toyBallInHand) { @@ -357,7 +360,8 @@ void Hand::render( bool isMine) { } // Render toy ball - if (isMine) { + + if (isMine && _toyBallShouldRender) { glPushMatrix(); glColor3f(1, 0, 0); glTranslatef(_toyBallPosition.x, _toyBallPosition.y, _toyBallPosition.z); diff --git a/interface/src/avatar/Hand.h b/interface/src/avatar/Hand.h index 1d3dc7b724..771b0d5e26 100755 --- a/interface/src/avatar/Hand.h +++ b/interface/src/avatar/Hand.h @@ -100,6 +100,8 @@ private: glm::vec3 _toyBallVelocity; bool _toyBallInHand; bool _hasToyBall; + bool _toyBallShouldRender; + ParticleEditHandle* _ballParticleEditHandle; float _pitchUpdate; From 1b1fdd3dc4a901454598e5d85224c8d6a4499637 Mon Sep 17 00:00:00 2001 From: Philip Rosedale Date: Fri, 13 Dec 2013 15:21:32 -0800 Subject: [PATCH 2/9] add menu option for sixense filter --- interface/src/Application.cpp | 3 +++ interface/src/Application.h | 1 + interface/src/Menu.cpp | 14 ++++++++++---- interface/src/Menu.h | 1 + interface/src/devices/SixenseManager.cpp | 13 ++++++++++++- interface/src/devices/SixenseManager.h | 8 +++++++- 6 files changed, 34 insertions(+), 6 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index f12cd94578..90d7fdb22a 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -240,6 +240,9 @@ Application::Application(int& argc, char** argv, timeval &startup_time) : // probably not the right long term solution. But for now, we're going to do this to // allow you to move a particle around in your hand _particleEditSender.setPacketsPerSecond(3000); // super high!! + + // Set the sixense filtering + _sixenseManager.setFilter(Menu::getInstance()->isOptionChecked(MenuOption::FilterSixense)); } Application::~Application() { diff --git a/interface/src/Application.h b/interface/src/Application.h index a37e13147a..b3b8ebf8f5 100644 --- a/interface/src/Application.h +++ b/interface/src/Application.h @@ -151,6 +151,7 @@ public: SerialInterface* getSerialHeadSensor() { return &_serialHeadSensor; } Webcam* getWebcam() { return &_webcam; } Faceshift* getFaceshift() { return &_faceshift; } + SixenseManager* getSixenseManager() { return &_sixenseManager; } BandwidthMeter* getBandwidthMeter() { return &_bandwidthMeter; } QSettings* getSettings() { return _settings; } Swatch* getSwatch() { return &_swatch; } diff --git a/interface/src/Menu.cpp b/interface/src/Menu.cpp index 13510067cd..646fcadc40 100644 --- a/interface/src/Menu.cpp +++ b/interface/src/Menu.cpp @@ -357,11 +357,17 @@ Menu::Menu() : appInstance->getWebcam()->getGrabber(), SLOT(setDepthOnly(bool))); - QMenu* raveGloveOptionsMenu = developerMenu->addMenu("Hand Options"); + QMenu* handOptionsMenu = developerMenu->addMenu("Hand Options"); - addCheckableActionToQMenuAndActionHash(raveGloveOptionsMenu, MenuOption::SimulateLeapHand); - addCheckableActionToQMenuAndActionHash(raveGloveOptionsMenu, MenuOption::DisplayLeapHands, 0, true); - addCheckableActionToQMenuAndActionHash(raveGloveOptionsMenu, MenuOption::LeapDrive, 0, false); + addCheckableActionToQMenuAndActionHash(handOptionsMenu, + MenuOption::FilterSixense, + 0, + true, + appInstance->getSixenseManager(), + SLOT(setFilter(bool))); + addCheckableActionToQMenuAndActionHash(handOptionsMenu, MenuOption::SimulateLeapHand); + addCheckableActionToQMenuAndActionHash(handOptionsMenu, MenuOption::DisplayLeapHands, 0, true); + addCheckableActionToQMenuAndActionHash(handOptionsMenu, MenuOption::LeapDrive, 0, false); QMenu* trackingOptionsMenu = developerMenu->addMenu("Tracking Options"); diff --git a/interface/src/Menu.h b/interface/src/Menu.h index aa3b925517..aac503af6f 100644 --- a/interface/src/Menu.h +++ b/interface/src/Menu.h @@ -167,6 +167,7 @@ namespace MenuOption { const QString DisableLowRes = "Disable Lower Resolution While Moving"; const QString DisplayFrustum = "Display Frustum"; const QString DisplayLeapHands = "Display Leap Hands"; + const QString FilterSixense = "Smooth Sixense Movement"; const QString DontRenderVoxels = "Don't call _voxels.render()"; const QString DontCallOpenGLForVoxels = "Don't call glDrawRangeElementsEXT() for Voxels"; const QString EnableOcclusionCulling = "Enable Occlusion Culling"; diff --git a/interface/src/devices/SixenseManager.cpp b/interface/src/devices/SixenseManager.cpp index a76bed3ac9..3a5c2bf95c 100644 --- a/interface/src/devices/SixenseManager.cpp +++ b/interface/src/devices/SixenseManager.cpp @@ -16,7 +16,6 @@ SixenseManager::SixenseManager() { #ifdef HAVE_SIXENSE sixenseInit(); - sixenseSetFilterEnabled(1); #endif } @@ -26,6 +25,18 @@ SixenseManager::~SixenseManager() { #endif } +void SixenseManager::setFilter(bool filter) { +#ifdef HAVE_SIXENSE + if (filter) { + qDebug("Sixense Filter ON\n"); + sixenseSetFilterEnabled(1); + } else { + qDebug("Sixense Filter OFF\n"); + sixenseSetFilterEnabled(0); + } +#endif +} + void SixenseManager::update(float deltaTime) { #ifdef HAVE_SIXENSE if (sixenseGetNumActiveControllers() == 0) { diff --git a/interface/src/devices/SixenseManager.h b/interface/src/devices/SixenseManager.h index 43e11b682f..874f29fc34 100644 --- a/interface/src/devices/SixenseManager.h +++ b/interface/src/devices/SixenseManager.h @@ -10,13 +10,19 @@ #define __interface__SixenseManager__ /// Handles interaction with the Sixense SDK (e.g., Razer Hydra). -class SixenseManager { +class SixenseManager : public QObject { + Q_OBJECT public: SixenseManager(); ~SixenseManager(); void update(float deltaTime); + +public slots: + + void setFilter(bool filter); }; #endif /* defined(__interface__SixenseManager__) */ + From 41fdbcb30f9ce19a52b80f26a3d4f8e73e472af2 Mon Sep 17 00:00:00 2001 From: Andrzej Kapolka Date: Fri, 13 Dec 2013 15:25:03 -0800 Subject: [PATCH 3/9] Fix for crash that Philip was seeing. --- interface/src/avatar/SkeletonModel.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/interface/src/avatar/SkeletonModel.cpp b/interface/src/avatar/SkeletonModel.cpp index b8c500d3bd..b7af35c632 100644 --- a/interface/src/avatar/SkeletonModel.cpp +++ b/interface/src/avatar/SkeletonModel.cpp @@ -127,6 +127,9 @@ bool operator<(const IndexValue& firstIndex, const IndexValue& secondIndex) { void SkeletonModel::applyPalmData(int jointIndex, const QVector& fingerJointIndices, const QVector& fingertipJointIndices, PalmData& palm) { + if (jointIndex == -1) { + return; + } const FBXGeometry& geometry = _geometry->getFBXGeometry(); setJointPosition(jointIndex, palm.getPosition()); float sign = (jointIndex == geometry.rightHandJointIndex) ? 1.0f : -1.0f; From 21d7fe1277ddc9e447776bc3aac1d117912bbc4b Mon Sep 17 00:00:00 2001 From: Philip Rosedale Date: Fri, 13 Dec 2013 21:59:19 -0800 Subject: [PATCH 4/9] Grab and move with button 4 --- interface/src/avatar/Hand.cpp | 29 ++++++++++++++++++++++++++++- interface/src/avatar/Hand.h | 8 ++++++++ interface/src/avatar/MyAvatar.cpp | 8 ++++++++ libraries/avatars/src/HandData.h | 6 +++++- 4 files changed, 49 insertions(+), 2 deletions(-) diff --git a/interface/src/avatar/Hand.cpp b/interface/src/avatar/Hand.cpp index 50cf1ebde6..f59929b35a 100755 --- a/interface/src/avatar/Hand.cpp +++ b/interface/src/avatar/Hand.cpp @@ -48,7 +48,9 @@ Hand::Hand(Avatar* owningAvatar) : _collisionCenter(0,0,0), _collisionAge(0), _collisionDuration(0), - _pitchUpdate(0) + _pitchUpdate(0), + _grabDelta(0, 0, 0), + _grabDeltaVelocity(0, 0, 0) { for (int i = 0; i < MAX_HANDS; i++) { _toyBallInHand[i] = false; @@ -167,6 +169,23 @@ void Hand::simulateToyBall(PalmData& palm, const glm::vec3& fingerTipPosition, f } } +glm::vec3 Hand::getAndResetGrabDelta() { + const float HAND_GRAB_SCALE_DISTANCE = 5.f; + glm::vec3 delta = _grabDelta * _owningAvatar->getScale() * HAND_GRAB_SCALE_DISTANCE; + _grabDelta = glm::vec3(0,0,0); + glm::quat avatarRotation = _owningAvatar->getOrientation(); + return avatarRotation * -delta; +} + +glm::vec3 Hand::getAndResetGrabDeltaVelocity() { + const float HAND_GRAB_SCALE_VELOCITY = 5.f; + glm::vec3 delta = _grabDeltaVelocity * _owningAvatar->getScale() * HAND_GRAB_SCALE_VELOCITY; + _grabDeltaVelocity = glm::vec3(0,0,0); + glm::quat avatarRotation = _owningAvatar->getOrientation(); + return avatarRotation * -delta; + +} + void Hand::simulate(float deltaTime, bool isMine) { if (_collisionAge > 0.f) { @@ -197,6 +216,13 @@ void Hand::simulate(float deltaTime, bool isMine) { simulateToyBall(palm, fingerTipPosition, deltaTime); + if (palm.getControllerButtons() & BUTTON_4) { + _grabDelta += palm.getRawVelocity() * deltaTime; + } + if ((palm.getLastControllerButtons() & BUTTON_4) && !(palm.getControllerButtons() & BUTTON_4)) { + _grabDeltaVelocity = palm.getRawVelocity(); + } + if (palm.getControllerButtons() & BUTTON_1) { if (glm::length(fingerTipPosition - _lastFingerAddVoxel) > (FINGERTIP_VOXEL_SIZE / 2.f)) { QColor paintColor = Menu::getInstance()->getActionForOption(MenuOption::VoxelPaintColor)->data().value(); @@ -243,6 +269,7 @@ void Hand::simulate(float deltaTime, bool isMine) { } } } + palm.setLastControllerButtons(palm.getControllerButtons()); } } } diff --git a/interface/src/avatar/Hand.h b/interface/src/avatar/Hand.h index a6f3014797..451da1b878 100755 --- a/interface/src/avatar/Hand.h +++ b/interface/src/avatar/Hand.h @@ -61,6 +61,10 @@ public: const float getPitchUpdate() const { return _pitchUpdate; } void setPitchUpdate(float pitchUpdate) { _pitchUpdate = pitchUpdate; } + // Get the drag distance to move + glm::vec3 getAndResetGrabDelta(); + glm::vec3 getAndResetGrabDeltaVelocity(); + private: // disallow copies of the Hand, copy of owning Avatar is disallowed too Hand(const Hand&); @@ -95,6 +99,7 @@ private: void handleVoxelCollision(PalmData* palm, const glm::vec3& fingerTipPosition, VoxelTreeElement* voxel, float deltaTime); void simulateToyBall(PalmData& palm, const glm::vec3& fingerTipPosition, float deltaTime); + #define MAX_HANDS 2 bool _toyBallInHand[MAX_HANDS]; @@ -103,6 +108,9 @@ private: int _lastControllerButtons; float _pitchUpdate; + + glm::vec3 _grabDelta; + glm::vec3 _grabDeltaVelocity; }; diff --git a/interface/src/avatar/MyAvatar.cpp b/interface/src/avatar/MyAvatar.cpp index 7518d639c3..e462426f2e 100644 --- a/interface/src/avatar/MyAvatar.cpp +++ b/interface/src/avatar/MyAvatar.cpp @@ -271,6 +271,14 @@ void MyAvatar::simulate(float deltaTime, Transmitter* transmitter) { updateChatCircle(deltaTime); + // Get any position or velocity update from Grab controller + glm::vec3 moveFromGrab = _hand.getAndResetGrabDelta(); + if (glm::length(moveFromGrab) > EPSILON) { + _position += moveFromGrab; + _velocity = glm::vec3(0, 0, 0); + } + _velocity += _hand.getAndResetGrabDeltaVelocity(); + _position += _velocity * deltaTime; // update avatar skeleton and simulate hand and head diff --git a/libraries/avatars/src/HandData.h b/libraries/avatars/src/HandData.h index 6fba4d5e2c..e299382c66 100755 --- a/libraries/avatars/src/HandData.h +++ b/libraries/avatars/src/HandData.h @@ -158,8 +158,11 @@ public: // Controller buttons void setControllerButtons(int controllerButtons) { _controllerButtons = controllerButtons; } - int getControllerButtons() { return _controllerButtons; } + void setLastControllerButtons(int controllerButtons) { _lastControllerButtons = controllerButtons; } + int getControllerButtons() { return _controllerButtons; } + int getLastControllerButtons() { return _lastControllerButtons; } + void setTrigger(float trigger) { _trigger = trigger; } float getTrigger() { return _trigger; } void setJoystick(float joystickX, float joystickY) { _joystickX = joystickX; _joystickY = joystickY; } @@ -181,6 +184,7 @@ private: glm::vec3 _tipPosition; glm::vec3 _tipVelocity; int _controllerButtons; + int _lastControllerButtons; float _trigger; float _joystickX, _joystickY; From 3ca9cde500396d6710045245a030e5e64cae659d Mon Sep 17 00:00:00 2001 From: Leonardo Murillo Date: Mon, 16 Dec 2013 11:03:49 -0600 Subject: [PATCH 5/9] Adding build sequence to Interface build --- interface/CMakeLists.txt | 11 +++++++++++ interface/InterfaceConfig.h.in | 1 - interface/InterfaceVersion.h.in | 9 +++++++++ interface/src/Application.cpp | 3 +++ 4 files changed, 23 insertions(+), 1 deletion(-) create mode 100644 interface/InterfaceVersion.h.in diff --git a/interface/CMakeLists.txt b/interface/CMakeLists.txt index 31f6e74e5a..6d0817b0a3 100644 --- a/interface/CMakeLists.txt +++ b/interface/CMakeLists.txt @@ -17,6 +17,16 @@ set(OPENCV_ROOT_DIR ${CMAKE_CURRENT_SOURCE_DIR}/external/OpenCV) set(SIXENSE_ROOT_DIR ${CMAKE_CURRENT_SOURCE_DIR}/external/Sixense) set(UVCCAMERACONTROL_ROOT_DIR ${CMAKE_CURRENT_SOURCE_DIR}/external/UVCCameraControl) +if (DEFINED ENV{JOB_ID}) + set(BUILD_SEQ $ENV{JOB_ID}) +else () + set(BUILD_SEQ "0") +endif () + +message("BUILD_SEQ = ${BUILD_SEQ}") + +set(CMAKE_PREFIX_PATH ${CMAKE_PREFIX_PATH} $ENV{QT_CMAKE_PREFIX_PATH}) + if (APPLE) set(GL_HEADERS "#include \n#include ") else (APPLE) @@ -35,6 +45,7 @@ include_glm(${TARGET_NAME} ${ROOT_DIR}) # create the InterfaceConfig.h file based on GL_HEADERS above configure_file(InterfaceConfig.h.in ${PROJECT_BINARY_DIR}/includes/InterfaceConfig.h) +configure_file(InterfaceVersion.h.in ${PROJECT_BINARY_DIR}/includes/InterfaceVersion.h) # grab the implementation and header files from src dirs file(GLOB INTERFACE_SRCS src/*.cpp src/*.h) diff --git a/interface/InterfaceConfig.h.in b/interface/InterfaceConfig.h.in index 802574434c..0b570f622f 100644 --- a/interface/InterfaceConfig.h.in +++ b/interface/InterfaceConfig.h.in @@ -12,5 +12,4 @@ #define GL_GLEXT_PROTOTYPES 1 @GL_HEADERS@ - #endif diff --git a/interface/InterfaceVersion.h.in b/interface/InterfaceVersion.h.in new file mode 100644 index 0000000000..b13c14bda6 --- /dev/null +++ b/interface/InterfaceVersion.h.in @@ -0,0 +1,9 @@ +// +// InterfaceVersion.h +// Declaration of version and buidl variables +// +// Created by Leonardo Murillo on 12/16/13. +// Copyright (c) 2013 High Fidelity, Inc.. All rights reserved. +// + +const int BUILD_VERSION = @BUILD_SEQ@; diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 90d7fdb22a..bf7fef57a5 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -49,6 +49,7 @@ #include "Application.h" #include "DataServerClient.h" +#include "InterfaceVersion.h" #include "LogDisplay.h" #include "Menu.h" #include "Swatch.h" @@ -144,6 +145,8 @@ Application::Application(int& argc, char** argv, timeval &startup_time) : _applicationStartupTime = startup_time; _window->setWindowTitle("Interface"); + qDebug( "[VERSION] Build sequence: %i", BUILD_VERSION); + qInstallMessageHandler(messageHandler); unsigned int listenPort = 0; // bind to an ephemeral port by default From 7b9147fb6c4f984e335accff0a0136a855decb0e Mon Sep 17 00:00:00 2001 From: Leonardo Murillo Date: Mon, 16 Dec 2013 11:05:08 -0600 Subject: [PATCH 6/9] Tidy up --- interface/CMakeLists.txt | 2 -- interface/InterfaceVersion.h.in | 2 +- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/interface/CMakeLists.txt b/interface/CMakeLists.txt index 6d0817b0a3..52e91a1489 100644 --- a/interface/CMakeLists.txt +++ b/interface/CMakeLists.txt @@ -23,8 +23,6 @@ else () set(BUILD_SEQ "0") endif () -message("BUILD_SEQ = ${BUILD_SEQ}") - set(CMAKE_PREFIX_PATH ${CMAKE_PREFIX_PATH} $ENV{QT_CMAKE_PREFIX_PATH}) if (APPLE) diff --git a/interface/InterfaceVersion.h.in b/interface/InterfaceVersion.h.in index b13c14bda6..26b2260965 100644 --- a/interface/InterfaceVersion.h.in +++ b/interface/InterfaceVersion.h.in @@ -1,6 +1,6 @@ // // InterfaceVersion.h -// Declaration of version and buidl variables +// Declaration of version and build data // // Created by Leonardo Murillo on 12/16/13. // Copyright (c) 2013 High Fidelity, Inc.. All rights reserved. From 06d14436bd986b77a04594f2cb6f56fa81690885 Mon Sep 17 00:00:00 2001 From: Leonardo Murillo Date: Mon, 16 Dec 2013 13:29:17 -0600 Subject: [PATCH 7/9] Printing build version on title --- interface/src/Application.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index bf7fef57a5..291086a478 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -4106,12 +4106,14 @@ void Application::attachNewHeadToNode(Node* newNode) { void Application::updateWindowTitle(){ QString title = ""; + QString buildVersion = " (build " + QString::number(BUILD_VERSION) + ")"; QString username = _profile.getUsername(); if(!username.isEmpty()){ - title += _profile.getUsername(); + title += _profile.getUsername();s title += " @ "; } title += _profile.getLastDomain(); + title += buildVersion; qDebug("Application title set to: %s.\n", title.toStdString().c_str()); _window->setWindowTitle(title); From 5ac125fdd88f64dab4c848602d6c221c0ca2375b Mon Sep 17 00:00:00 2001 From: Leonardo Murillo Date: Mon, 16 Dec 2013 13:32:12 -0600 Subject: [PATCH 8/9] Typo fix --- interface/src/Application.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 291086a478..942cf998d9 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -4109,7 +4109,7 @@ void Application::updateWindowTitle(){ QString buildVersion = " (build " + QString::number(BUILD_VERSION) + ")"; QString username = _profile.getUsername(); if(!username.isEmpty()){ - title += _profile.getUsername();s + title += _profile.getUsername(); title += " @ "; } title += _profile.getLastDomain(); From 4f1ff5b56683a7da6da97446eb73ebbc78ab0217 Mon Sep 17 00:00:00 2001 From: Leonardo Murillo Date: Mon, 16 Dec 2013 13:55:04 -0600 Subject: [PATCH 9/9] Using QStandardPaths for cache directory --- interface/src/Application.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 942cf998d9..267786edb9 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -218,9 +218,11 @@ Application::Application(int& argc, char** argv, timeval &startup_time) : connect(silentNodeTimer, SIGNAL(timeout()), nodeList, SLOT(removeSilentNodes())); silentNodeTimer->start(NODE_SILENCE_THRESHOLD_USECS / 1000); + QString cachePath = QStandardPaths::writableLocation(QStandardPaths::DataLocation); + _networkAccessManager = new QNetworkAccessManager(this); QNetworkDiskCache* cache = new QNetworkDiskCache(_networkAccessManager); - cache->setCacheDirectory("interfaceCache"); + cache->setCacheDirectory(!cachePath.isEmpty() ? cachePath : "interfaceCache"); _networkAccessManager->setCache(cache); _window->setCentralWidget(_glWidget);