diff --git a/interface/CMakeLists.txt b/interface/CMakeLists.txt index 00bbd50d8a..c447bfa1a5 100644 --- a/interface/CMakeLists.txt +++ b/interface/CMakeLists.txt @@ -17,6 +17,14 @@ 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 () + +set(CMAKE_PREFIX_PATH ${CMAKE_PREFIX_PATH} $ENV{QT_CMAKE_PREFIX_PATH}) + if (APPLE) set(GL_HEADERS "#include \n#include ") else (APPLE) @@ -35,6 +43,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..26b2260965 --- /dev/null +++ b/interface/InterfaceVersion.h.in @@ -0,0 +1,9 @@ +// +// InterfaceVersion.h +// Declaration of version and build data +// +// 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 eff2af5c1c..92ea597234 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 @@ -215,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); @@ -241,10 +246,8 @@ Application::Application(int& argc, char** argv, timeval &startup_time) : // allow you to move a particle around in your hand _particleEditSender.setPacketsPerSecond(3000); // super high!! - - printf("Application::Application() _voxelEditSender=%p\n", &_voxelEditSender); - printf("Application::Application() _particleEditSender=%p\n", &_particleEditSender); - + // Set the sixense filtering + _sixenseManager.setFilter(Menu::getInstance()->isOptionChecked(MenuOption::FilterSixense)); } Application::~Application() { @@ -4106,12 +4109,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 += " @ "; } title += _profile.getLastDomain(); + title += buildVersion; qDebug("Application title set to: %s.\n", title.toStdString().c_str()); _window->setWindowTitle(title); diff --git a/interface/src/Application.h b/interface/src/Application.h index df1e4bdeae..d54f9e74d8 100644 --- a/interface/src/Application.h +++ b/interface/src/Application.h @@ -152,6 +152,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 15b5b0d365..d79c2938f1 100644 --- a/interface/src/Menu.cpp +++ b/interface/src/Menu.cpp @@ -363,6 +363,12 @@ Menu::Menu() : QMenu* handOptionsMenu = developerMenu->addMenu("Hand Options"); + 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); diff --git a/interface/src/Menu.h b/interface/src/Menu.h index 80775738bb..117a24831e 100644 --- a/interface/src/Menu.h +++ b/interface/src/Menu.h @@ -176,6 +176,7 @@ namespace MenuOption { const QString DisplayFrustum = "Display Frustum"; const QString DisplayLeapHands = "Display Leap Hands"; const QString DisplayHandTargets = "Display Hand Targets"; + 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/avatar/Hand.cpp b/interface/src/avatar/Hand.cpp index 0f503f6ad1..115fd1985d 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; @@ -74,7 +76,6 @@ void Hand::reset() { void Hand::simulateToyBall(PalmData& palm, const glm::vec3& fingerTipPosition, float deltaTime) { bool ballFromHand = Menu::getInstance()->isOptionChecked(MenuOption::BallFromHand); int handID = palm.getSixenseID(); - glm::vec3 targetPosition = palm.getPosition() / (float)TREE_SCALE; float targetRadius = (TOY_BALL_RADIUS * 4.0f) / (float)TREE_SCALE; const Particle* closestParticle = Application::getInstance()->getParticles() @@ -137,8 +138,6 @@ void Hand::simulateToyBall(PalmData& palm, const glm::vec3& fingerTipPosition, f // Is the controller button being held down.... if (palm.getControllerButtons() & BUTTON_FWD) { - // If grabbing toy ball, add forces to it. - // If we don't currently have a ball in hand, then create it... if (!_toyBallInHand[handID]) { // Test for whether close enough to catch and catch.... @@ -209,6 +208,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) { @@ -239,6 +255,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(); @@ -285,6 +308,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/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; 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__) */ + diff --git a/libraries/avatars/src/HandData.h b/libraries/avatars/src/HandData.h index 86f29cf2f1..0a72160e95 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;