From e0486b26549062d0311b706cc0d58465d43883e7 Mon Sep 17 00:00:00 2001 From: Andrzej Kapolka Date: Mon, 12 May 2014 15:25:25 -0700 Subject: [PATCH 01/10] Starting on PrioVR integration. --- cmake/modules/FindPrioVR.cmake | 42 +++++++++++++++++++ interface/CMakeLists.txt | 9 +++++ interface/external/priovr/readme.txt | 11 +++++ interface/src/Application.cpp | 1 + interface/src/Application.h | 2 + interface/src/devices/PrioVR.cpp | 60 ++++++++++++++++++++++++++++ interface/src/devices/PrioVR.h | 41 +++++++++++++++++++ 7 files changed, 166 insertions(+) create mode 100644 cmake/modules/FindPrioVR.cmake create mode 100644 interface/external/priovr/readme.txt create mode 100644 interface/src/devices/PrioVR.cpp create mode 100644 interface/src/devices/PrioVR.h diff --git a/cmake/modules/FindPrioVR.cmake b/cmake/modules/FindPrioVR.cmake new file mode 100644 index 0000000000..96ee1a7bdc --- /dev/null +++ b/cmake/modules/FindPrioVR.cmake @@ -0,0 +1,42 @@ +# Try to find the PrioVT library +# +# You must provide a PRIOVR_ROOT_DIR which contains lib and include directories +# +# Once done this will define +# +# PRIOVR_FOUND - system found PrioVR +# PRIOVR_INCLUDE_DIRS - the PrioVR include directory +# PRIOVR_LIBRARIES - Link this to use PrioVR +# +# Created on 5/12/2014 by Andrzej Kapolka +# Copyright (c) 2014 High Fidelity +# + +if (PRIOVR_LIBRARIES AND PRIOVR_INCLUDE_DIRS) + # in cache already + set(PRIOVR_FOUND TRUE) +else (PRIOVR_LIBRARIES AND PRIOVR_INCLUDE_DIRS) + find_path(PRIOVR_INCLUDE_DIRS yei_threespace_api.h ${PRIOVR_ROOT_DIR}/include) + + if (WIN32) + find_library(PRIOVR_LIBRARIES ThreeSpace_API.lib ${PRIOVR_ROOT_DIR}) + endif (WIN32) + + if (PRIOVR_INCLUDE_DIRS AND PRIOVR_LIBRARIES) + set(PRIOVR_FOUND TRUE) + endif (PRIOVR_INCLUDE_DIRS AND PRIOVR_LIBRARIES) + + if (PRIOVR_FOUND) + if (NOT PRIOVR_FIND_QUIETLY) + message(STATUS "Found PrioVR... ${PRIOVR_LIBRARIES}") + endif (NOT PRIOVR_FIND_QUIETLY) + else () + if (PRIOVR_FIND_REQUIRED) + message(FATAL_ERROR "Could not find PrioVR") + endif (PRIOVR_FIND_REQUIRED) + endif () + + # show the PRIOVR_INCLUDE_DIRS and PRIOVR_LIBRARIES variables only in the advanced view + mark_as_advanced(PRIOVR_INCLUDE_DIRS PRIOVR_LIBRARIES) + +endif (PRIOVR_LIBRARIES AND PRIOVR_INCLUDE_DIRS) diff --git a/interface/CMakeLists.txt b/interface/CMakeLists.txt index 0a56109260..d075fbe9d0 100644 --- a/interface/CMakeLists.txt +++ b/interface/CMakeLists.txt @@ -15,6 +15,7 @@ set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/../cmake set(FACEPLUS_ROOT_DIR "${CMAKE_CURRENT_SOURCE_DIR}/external/faceplus") set(FACESHIFT_ROOT_DIR "${CMAKE_CURRENT_SOURCE_DIR}/external/faceshift") set(LIBOVR_ROOT_DIR "${CMAKE_CURRENT_SOURCE_DIR}/external/oculus") +set(PRIOVR_ROOT_DIR "${CMAKE_CURRENT_SOURCE_DIR}/external/priovr") set(SIXENSE_ROOT_DIR "${CMAKE_CURRENT_SOURCE_DIR}/external/Sixense") set(VISAGE_ROOT_DIR "${CMAKE_CURRENT_SOURCE_DIR}/external/visage") @@ -133,6 +134,7 @@ link_hifi_library(script-engine ${TARGET_NAME} "${ROOT_DIR}") find_package(Faceplus) find_package(Faceshift) find_package(LibOVR) +find_package(PrioVR) find_package(Sixense) find_package(Visage) find_package(ZLIB) @@ -183,6 +185,13 @@ if (LIBOVR_FOUND AND NOT DISABLE_LIBOVR) target_link_libraries(${TARGET_NAME} "${LIBOVR_LIBRARIES}") endif (LIBOVR_FOUND AND NOT DISABLE_LIBOVR) +# and with PrioVR library +if (PRIOVR_FOUND AND NOT DISABLE_PRIOVR) + add_definitions(-DHAVE_PRIOVR) + include_directories(SYSTEM "${PRIOVR_INCLUDE_DIRS}") + target_link_libraries(${TARGET_NAME} "${PRIOVR_LIBRARIES}") +endif (PRIOVR_FOUND AND NOT DISABLE_PRIOVR) + # and with qxmpp for chat if (QXMPP_FOUND AND NOT DISABLE_QXMPP) add_definitions(-DHAVE_QXMPP -DQXMPP_STATIC) diff --git a/interface/external/priovr/readme.txt b/interface/external/priovr/readme.txt new file mode 100644 index 0000000000..92a2aff711 --- /dev/null +++ b/interface/external/priovr/readme.txt @@ -0,0 +1,11 @@ + +Instructions for adding the PrioVR driver to Interface +Andrzej Kapolka, May 12, 2014 + +1. Copy the PrioVR sdk folders (include, *.lib) into the interface/external/priovr folder. + This readme.txt should be there as well. + +2. Copy the PrioVR DLLs from the API into your path. + +3. Delete your build directory, run cmake and build, and you should be all set. + diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 0b59fc3aa2..cc1ea14d2d 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -1987,6 +1987,7 @@ void Application::update(float deltaTime) { _myAvatar->updateLookAtTargetAvatar(); updateMyAvatarLookAtPosition(); _sixenseManager.update(deltaTime); + _prioVR.update(); updateMyAvatar(deltaTime); // Sample hardware, update view frustum if needed, and send avatar data to mixer/nodes updateThreads(deltaTime); // If running non-threaded, then give the threads some time to process... _avatarManager.updateOtherAvatars(deltaTime); //loop through all the other avatars and simulate them... diff --git a/interface/src/Application.h b/interface/src/Application.h index 67cf7dad44..77f8024b6c 100644 --- a/interface/src/Application.h +++ b/interface/src/Application.h @@ -58,6 +58,7 @@ #include "avatar/MyAvatar.h" #include "devices/Faceplus.h" #include "devices/Faceshift.h" +#include "devices/PrioVR.h" #include "devices/SixenseManager.h" #include "devices/Visage.h" #include "models/ModelTreeRenderer.h" @@ -441,6 +442,7 @@ private: Visage _visage; SixenseManager _sixenseManager; + PrioVR _prioVR; Camera _myCamera; // My view onto the world Camera _viewFrustumOffsetCamera; // The camera we use to sometimes show the view frustum from an offset mode diff --git a/interface/src/devices/PrioVR.cpp b/interface/src/devices/PrioVR.cpp new file mode 100644 index 0000000000..cd28c6ab68 --- /dev/null +++ b/interface/src/devices/PrioVR.cpp @@ -0,0 +1,60 @@ +// +// PrioVR.cpp +// interface/src/devices +// +// Created by Andrzej Kapolka on 5/12/14. +// Copyright 2014 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html +// + +#include "PrioVR.h" + +PrioVR::PrioVR() { +#ifdef HAVE_PRIOVR + TSS_ComPort comPort; + if (!tss_getComPorts(&comPort, 1, 0, PVR_FIND_BS)) { + _baseStation = TSS_NO_DEVICE_ID; + return; + } + _baseStation = tss_createTSDeviceStr(comPort.com_port, TSS_TIMESTAMP_SYSTEM); + if (_baseStation == TSS_NO_DEVICE_ID) { + return; + } + for (int i = 0; i < MAX_SENSOR_NODES; i++) { + tss_getSensorFromDongle(_baseStation, i, &_sensorNodes[i]); + if (_sensorNodes[i] == TSS_NO_DEVICE_ID) { + continue; + } + int present; + tss_isPresent(_sensorNodes[i], &present); + if (!present) { + _sensorNodes[i] = TSS_NO_DEVICE_ID; + } + } + tss_startStreaming(_baseStation, NULL); +#endif +} + +PrioVR::~PrioVR() { +#ifdef HAVE_PRIOVR + if (_baseStation != TSS_NO_DEVICE_ID) { + tss_stopStreaming(_baseStation, NULL); + } +#endif +} + +void PrioVR::update() { +#ifdef HAVE_PRIOVR + for (int i = 0; i < MAX_SENSOR_NODES; i++) { + if (_sensorNodes[i] == TSS_NO_DEVICE_ID) { + continue; + } + glm::quat rotation; + if (!tss_getLastStreamData(_sensorNodes[i], (char*)&rotation, sizeof(glm::quat), NULL)) { + qDebug() << i << rotation.x << rotation.y << rotation.z << rotation.w; + } + } +#endif +} diff --git a/interface/src/devices/PrioVR.h b/interface/src/devices/PrioVR.h new file mode 100644 index 0000000000..97fec2e1ee --- /dev/null +++ b/interface/src/devices/PrioVR.h @@ -0,0 +1,41 @@ +// +// PrioVR.h +// interface/src/devices +// +// Created by Andrzej Kapolka on 5/12/14. +// Copyright 2014 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html +// + +#ifndef hifi_PrioVR_h +#define hifi_PrioVR_h + +#include + +#ifdef HAVE_PRIOVR +#include +#endif + +/// Handles interaction with the PrioVR skeleton tracking suit. +class PrioVR : public QObject { + Q_OBJECT + +public: + + PrioVR(); + virtual ~PrioVR(); + + void update(); + +private: +#ifdef HAVE_PRIOVR + TSS_Device_Id _baseStation; + + const int MAX_SENSOR_NODES = 20; + TSS_Device_Id _sensorNodes[MAX_SENSOR_NODES]; +#endif +}; + +#endif // hifi_PrioVR_h From 52a3c70bf589fffa319a9aec039c15a708e5f990 Mon Sep 17 00:00:00 2001 From: Andrzej Kapolka Date: Mon, 12 May 2014 17:11:02 -0700 Subject: [PATCH 02/10] Updates to PrioVR interface. --- cmake/modules/FindPrioVR.cmake | 4 +-- interface/src/devices/PrioVR.cpp | 62 +++++++++++++++----------------- interface/src/devices/PrioVR.h | 15 +++++--- 3 files changed, 41 insertions(+), 40 deletions(-) diff --git a/cmake/modules/FindPrioVR.cmake b/cmake/modules/FindPrioVR.cmake index 96ee1a7bdc..6e78045321 100644 --- a/cmake/modules/FindPrioVR.cmake +++ b/cmake/modules/FindPrioVR.cmake @@ -16,10 +16,10 @@ if (PRIOVR_LIBRARIES AND PRIOVR_INCLUDE_DIRS) # in cache already set(PRIOVR_FOUND TRUE) else (PRIOVR_LIBRARIES AND PRIOVR_INCLUDE_DIRS) - find_path(PRIOVR_INCLUDE_DIRS yei_threespace_api.h ${PRIOVR_ROOT_DIR}/include) + find_path(PRIOVR_INCLUDE_DIRS yei_skeletal_api.h ${PRIOVR_ROOT_DIR}/include) if (WIN32) - find_library(PRIOVR_LIBRARIES ThreeSpace_API.lib ${PRIOVR_ROOT_DIR}) + find_library(PRIOVR_LIBRARIES Skeletal_API.lib ${PRIOVR_ROOT_DIR}/lib) endif (WIN32) if (PRIOVR_INCLUDE_DIRS AND PRIOVR_LIBRARIES) diff --git a/interface/src/devices/PrioVR.cpp b/interface/src/devices/PrioVR.cpp index cd28c6ab68..f9f807bdb7 100644 --- a/interface/src/devices/PrioVR.cpp +++ b/interface/src/devices/PrioVR.cpp @@ -9,52 +9,48 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // +#include + #include "PrioVR.h" +const unsigned int SERIAL_LIST[] = { 0x00000001, 0x00000000, 0x00000008, 0x00000009, 0x0000000A, 0x0000000C, 0x0000000D, + 0x0000000E, 0x00000004, 0x00000005, 0x00000010, 0x00000011 }; +const unsigned char AXIS_LIST[] = { 9, 43, 37, 37, 37, 13, 13, 13, 52, 52, 28, 28 }; +const int LIST_LENGTH = sizeof(SERIAL_LIST) / sizeof(SERIAL_LIST[0]); + PrioVR::PrioVR() { #ifdef HAVE_PRIOVR - TSS_ComPort comPort; - if (!tss_getComPorts(&comPort, 1, 0, PVR_FIND_BS)) { - _baseStation = TSS_NO_DEVICE_ID; - return; - } - _baseStation = tss_createTSDeviceStr(comPort.com_port, TSS_TIMESTAMP_SYSTEM); - if (_baseStation == TSS_NO_DEVICE_ID) { - return; - } - for (int i = 0; i < MAX_SENSOR_NODES; i++) { - tss_getSensorFromDongle(_baseStation, i, &_sensorNodes[i]); - if (_sensorNodes[i] == TSS_NO_DEVICE_ID) { - continue; - } - int present; - tss_isPresent(_sensorNodes[i], &present); - if (!present) { - _sensorNodes[i] = TSS_NO_DEVICE_ID; - } - } - tss_startStreaming(_baseStation, NULL); + _jointsDiscovered.resize(LIST_LENGTH); + _skeletalDevice = yei_setUpPrioVRSensors(0x00000000, const_cast(SERIAL_LIST), + const_cast(AXIS_LIST), _jointsDiscovered.data(), LIST_LENGTH, YEI_TIMESTAMP_SYSTEM); + if (!_skeletalDevice) { + return; + } + _jointRotations.resize(LIST_LENGTH); + yei_tareSensors(_skeletalDevice); #endif } PrioVR::~PrioVR() { #ifdef HAVE_PRIOVR - if (_baseStation != TSS_NO_DEVICE_ID) { - tss_stopStreaming(_baseStation, NULL); - } + if (_skeletalDevice) { + yei_stopStreaming(_skeletalDevice); + } #endif } void PrioVR::update() { #ifdef HAVE_PRIOVR - for (int i = 0; i < MAX_SENSOR_NODES; i++) { - if (_sensorNodes[i] == TSS_NO_DEVICE_ID) { - continue; - } - glm::quat rotation; - if (!tss_getLastStreamData(_sensorNodes[i], (char*)&rotation, sizeof(glm::quat), NULL)) { - qDebug() << i << rotation.x << rotation.y << rotation.z << rotation.w; - } - } + if (!_skeletalDevice) { + return; + } + unsigned int timestamp; + yei_getLastStreamDataAll(_skeletalDevice, (char*)_jointRotations.data(), + _jointRotations.size() * sizeof(glm::quat), ×tamp); + for (int i = 0; i < _jointsDiscovered.size(); i++) { + if (_jointsDiscovered.at(i)) { + qDebug() << i << _jointRotations.at(i).x << _jointRotations.at(i).y << _jointRotations.at(i).z << _jointRotations.at(i).w; + } + } #endif } diff --git a/interface/src/devices/PrioVR.h b/interface/src/devices/PrioVR.h index 97fec2e1ee..d5bac44a9a 100644 --- a/interface/src/devices/PrioVR.h +++ b/interface/src/devices/PrioVR.h @@ -13,9 +13,14 @@ #define hifi_PrioVR_h #include +#include + +#include #ifdef HAVE_PRIOVR -#include +extern "C" { +#include +} #endif /// Handles interaction with the PrioVR skeleton tracking suit. @@ -31,11 +36,11 @@ public: private: #ifdef HAVE_PRIOVR - TSS_Device_Id _baseStation; - - const int MAX_SENSOR_NODES = 20; - TSS_Device_Id _sensorNodes[MAX_SENSOR_NODES]; + YEI_Device_Id _skeletalDevice; #endif + + QVector _jointsDiscovered; + QVector _jointRotations; }; #endif // hifi_PrioVR_h From 6c58bec550a04d71d1269dfd10540a0fd3bac19e Mon Sep 17 00:00:00 2001 From: Andrzej Kapolka Date: Mon, 12 May 2014 17:32:06 -0700 Subject: [PATCH 03/10] Untabbed. --- interface/src/devices/PrioVR.cpp | 36 ++++++++++++++++---------------- interface/src/devices/PrioVR.h | 4 ++-- 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/interface/src/devices/PrioVR.cpp b/interface/src/devices/PrioVR.cpp index f9f807bdb7..9b5427be07 100644 --- a/interface/src/devices/PrioVR.cpp +++ b/interface/src/devices/PrioVR.cpp @@ -14,20 +14,20 @@ #include "PrioVR.h" const unsigned int SERIAL_LIST[] = { 0x00000001, 0x00000000, 0x00000008, 0x00000009, 0x0000000A, 0x0000000C, 0x0000000D, - 0x0000000E, 0x00000004, 0x00000005, 0x00000010, 0x00000011 }; + 0x0000000E, 0x00000004, 0x00000005, 0x00000010, 0x00000011 }; const unsigned char AXIS_LIST[] = { 9, 43, 37, 37, 37, 13, 13, 13, 52, 52, 28, 28 }; const int LIST_LENGTH = sizeof(SERIAL_LIST) / sizeof(SERIAL_LIST[0]); PrioVR::PrioVR() { #ifdef HAVE_PRIOVR - _jointsDiscovered.resize(LIST_LENGTH); + _jointsDiscovered.resize(LIST_LENGTH); _skeletalDevice = yei_setUpPrioVRSensors(0x00000000, const_cast(SERIAL_LIST), - const_cast(AXIS_LIST), _jointsDiscovered.data(), LIST_LENGTH, YEI_TIMESTAMP_SYSTEM); - if (!_skeletalDevice) { - return; - } - _jointRotations.resize(LIST_LENGTH); - yei_tareSensors(_skeletalDevice); + const_cast(AXIS_LIST), _jointsDiscovered.data(), LIST_LENGTH, YEI_TIMESTAMP_SYSTEM); + if (!_skeletalDevice) { + return; + } + _jointRotations.resize(LIST_LENGTH); + yei_tareSensors(_skeletalDevice); #endif } @@ -42,15 +42,15 @@ PrioVR::~PrioVR() { void PrioVR::update() { #ifdef HAVE_PRIOVR if (!_skeletalDevice) { - return; - } - unsigned int timestamp; - yei_getLastStreamDataAll(_skeletalDevice, (char*)_jointRotations.data(), - _jointRotations.size() * sizeof(glm::quat), ×tamp); - for (int i = 0; i < _jointsDiscovered.size(); i++) { - if (_jointsDiscovered.at(i)) { - qDebug() << i << _jointRotations.at(i).x << _jointRotations.at(i).y << _jointRotations.at(i).z << _jointRotations.at(i).w; - } - } + return; + } + unsigned int timestamp; + yei_getLastStreamDataAll(_skeletalDevice, (char*)_jointRotations.data(), + _jointRotations.size() * sizeof(glm::quat), ×tamp); + for (int i = 0; i < _jointsDiscovered.size(); i++) { + if (_jointsDiscovered.at(i)) { + qDebug() << i << _jointRotations.at(i).x << _jointRotations.at(i).y << _jointRotations.at(i).z << _jointRotations.at(i).w; + } + } #endif } diff --git a/interface/src/devices/PrioVR.h b/interface/src/devices/PrioVR.h index d5bac44a9a..1c26009b33 100644 --- a/interface/src/devices/PrioVR.h +++ b/interface/src/devices/PrioVR.h @@ -39,8 +39,8 @@ private: YEI_Device_Id _skeletalDevice; #endif - QVector _jointsDiscovered; - QVector _jointRotations; + QVector _jointsDiscovered; + QVector _jointRotations; }; #endif // hifi_PrioVR_h From 4a0b4de1787fddccc1ded9545a33bc1bf051af24 Mon Sep 17 00:00:00 2001 From: Andrzej Kapolka Date: Mon, 12 May 2014 17:55:07 -0700 Subject: [PATCH 04/10] Better instructions. --- interface/external/priovr/readme.txt | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/interface/external/priovr/readme.txt b/interface/external/priovr/readme.txt index 92a2aff711..202a90cf12 100644 --- a/interface/external/priovr/readme.txt +++ b/interface/external/priovr/readme.txt @@ -2,10 +2,15 @@ Instructions for adding the PrioVR driver to Interface Andrzej Kapolka, May 12, 2014 -1. Copy the PrioVR sdk folders (include, *.lib) into the interface/external/priovr folder. - This readme.txt should be there as well. +1. Download and install the YEI drivers from https://www.yeitechnology.com/yei-3-space-sensor-software-suite. If using + Window 8+, follow the workaround instructions at http://forum.yeitechnology.com/viewtopic.php?f=3&t=24. + +2. Get the PrioVR skeleton API, open ts_c_api2_priovr2/visual_studio/ThreeSpace_API_2/ThreeSpace_API_2.sln + in Visual Studio, and build it. -2. Copy the PrioVR DLLs from the API into your path. - -3. Delete your build directory, run cmake and build, and you should be all set. +3. Copy ts_c_api2_priovr2/visual_studio/ThreeSpace_API_2/Skeletal_API/yei_skeletal_api.h to interface/external/priovr/include, + ts_c_api2_priovr2/visual_studio/ThreeSpace_API_2/Debug/Skeletal_API.lib to interface/external/priovr/lib, and + ts_c_api2_priovr2/visual_studio/ThreeSpace_API_2/Debug/*.dll to your path. + +4. Delete your build directory, run cmake and build, and you should be all set. From 0321821b559b94125d9e2d217a478af931a79079 Mon Sep 17 00:00:00 2001 From: Andrzej Kapolka Date: Tue, 13 May 2014 11:38:24 -0700 Subject: [PATCH 05/10] More work on PrioVR integration. --- interface/src/avatar/MyAvatar.cpp | 4 +- interface/src/avatar/MyAvatar.h | 2 +- interface/src/avatar/SkeletonModel.cpp | 12 ++--- interface/src/avatar/SkeletonModel.h | 3 +- interface/src/devices/PrioVR.cpp | 35 ++++++++++---- interface/src/devices/PrioVR.h | 5 +- libraries/fbx/src/FBXReader.cpp | 65 +++++++++++++++----------- libraries/fbx/src/FBXReader.h | 9 ++-- 8 files changed, 81 insertions(+), 54 deletions(-) diff --git a/interface/src/avatar/MyAvatar.cpp b/interface/src/avatar/MyAvatar.cpp index 36c51dc9fd..e6d6634653 100644 --- a/interface/src/avatar/MyAvatar.cpp +++ b/interface/src/avatar/MyAvatar.cpp @@ -111,7 +111,7 @@ void MyAvatar::reset() { void MyAvatar::update(float deltaTime) { Head* head = getHead(); head->relaxLean(deltaTime); - updateFromFaceTracker(deltaTime); + updateFromTrackers(deltaTime); if (Menu::getInstance()->isOptionChecked(MenuOption::MoveWithLean)) { // Faceshift drive is enabled, set the avatar drive based on the head position moveWithLean(); @@ -241,7 +241,7 @@ void MyAvatar::simulate(float deltaTime) { } // Update avatar head rotation with sensor data -void MyAvatar::updateFromFaceTracker(float deltaTime) { +void MyAvatar::updateFromTrackers(float deltaTime) { glm::vec3 estimatedPosition, estimatedRotation; FaceTracker* tracker = Application::getInstance()->getActiveFaceTracker(); diff --git a/interface/src/avatar/MyAvatar.h b/interface/src/avatar/MyAvatar.h index d446c2e895..2df74f23c2 100644 --- a/interface/src/avatar/MyAvatar.h +++ b/interface/src/avatar/MyAvatar.h @@ -38,7 +38,7 @@ public: void reset(); void update(float deltaTime); void simulate(float deltaTime); - void updateFromFaceTracker(float deltaTime); + void updateFromTrackers(float deltaTime); void moveWithLean(); void render(const glm::vec3& cameraPosition, RenderMode renderMode = NORMAL_RENDER_MODE); diff --git a/interface/src/avatar/SkeletonModel.cpp b/interface/src/avatar/SkeletonModel.cpp index 8c21a3240f..96510dad25 100644 --- a/interface/src/avatar/SkeletonModel.cpp +++ b/interface/src/avatar/SkeletonModel.cpp @@ -52,15 +52,12 @@ void SkeletonModel::simulate(float deltaTime, bool fullUpdate) { } else if (leftPalmIndex == rightPalmIndex) { // right hand only - applyPalmData(geometry.rightHandJointIndex, geometry.rightFingerJointIndices, geometry.rightFingertipJointIndices, - hand->getPalms()[leftPalmIndex]); + applyPalmData(geometry.rightHandJointIndex, hand->getPalms()[leftPalmIndex]); restoreLeftHandPosition(HAND_RESTORATION_RATE); } else { - applyPalmData(geometry.leftHandJointIndex, geometry.leftFingerJointIndices, geometry.leftFingertipJointIndices, - hand->getPalms()[leftPalmIndex]); - applyPalmData(geometry.rightHandJointIndex, geometry.rightFingerJointIndices, geometry.rightFingertipJointIndices, - hand->getPalms()[rightPalmIndex]); + applyPalmData(geometry.leftHandJointIndex, hand->getPalms()[leftPalmIndex]); + applyPalmData(geometry.rightHandJointIndex, hand->getPalms()[rightPalmIndex]); } } @@ -140,8 +137,7 @@ void SkeletonModel::applyHandPosition(int jointIndex, const glm::vec3& position) applyRotationDelta(jointIndex, rotationBetween(handRotation * glm::vec3(-sign, 0.0f, 0.0f), forearmVector)); } -void SkeletonModel::applyPalmData(int jointIndex, const QVector& fingerJointIndices, - const QVector& fingertipJointIndices, PalmData& palm) { +void SkeletonModel::applyPalmData(int jointIndex, PalmData& palm) { if (jointIndex == -1) { return; } diff --git a/interface/src/avatar/SkeletonModel.h b/interface/src/avatar/SkeletonModel.h index ee6b3b9de3..20384829ea 100644 --- a/interface/src/avatar/SkeletonModel.h +++ b/interface/src/avatar/SkeletonModel.h @@ -39,8 +39,7 @@ protected: void applyHandPosition(int jointIndex, const glm::vec3& position); - void applyPalmData(int jointIndex, const QVector& fingerJointIndices, - const QVector& fingertipJointIndices, PalmData& palm); + void applyPalmData(int jointIndex, PalmData& palm); /// Updates the state of the joint at the specified index. virtual void updateJointState(int index); diff --git a/interface/src/devices/PrioVR.cpp b/interface/src/devices/PrioVR.cpp index 9b5427be07..5fe6b56b11 100644 --- a/interface/src/devices/PrioVR.cpp +++ b/interface/src/devices/PrioVR.cpp @@ -11,22 +11,44 @@ #include +#include + #include "PrioVR.h" -const unsigned int SERIAL_LIST[] = { 0x00000001, 0x00000000, 0x00000008, 0x00000009, 0x0000000A, 0x0000000C, 0x0000000D, - 0x0000000E, 0x00000004, 0x00000005, 0x00000010, 0x00000011 }; +const unsigned int SERIAL_LIST[] = { 0x00000001, 0x00000000, 0x00000008, 0x00000009, 0x0000000A, + 0x0000000C, 0x0000000D, 0x0000000E, 0x00000004, 0x00000005, 0x00000010, 0x00000011 }; const unsigned char AXIS_LIST[] = { 9, 43, 37, 37, 37, 13, 13, 13, 52, 52, 28, 28 }; const int LIST_LENGTH = sizeof(SERIAL_LIST) / sizeof(SERIAL_LIST[0]); +const char* JOINT_NAMES[] = { "Head", "Spine", "LeftArm", "LeftForeArm", "LeftHand", "RightArm", + "RightForeArm", "RightHand", "LeftUpLeg", "LeftLeg", "RightUpLeft", "RightLeg" }; + +#ifdef HAVE_PRIOVR +static int indexOfHumanIKJoint(const char* jointName) { + for (int i = 0;; i++) { + QByteArray humanIKJoint = HUMANIK_JOINTS[i]; + if (humanIKJoint.isEmpty()) { + return -1; + } + if (humanIKJoint == jointName) { + return i; + } + } +} +#endif + PrioVR::PrioVR() { #ifdef HAVE_PRIOVR - _jointsDiscovered.resize(LIST_LENGTH); + char jointsDiscovered[LIST_LENGTH]; _skeletalDevice = yei_setUpPrioVRSensors(0x00000000, const_cast(SERIAL_LIST), - const_cast(AXIS_LIST), _jointsDiscovered.data(), LIST_LENGTH, YEI_TIMESTAMP_SYSTEM); + const_cast(AXIS_LIST), jointsDiscovered, LIST_LENGTH, YEI_TIMESTAMP_SYSTEM); if (!_skeletalDevice) { return; } _jointRotations.resize(LIST_LENGTH); + for (int i = 0; i < LIST_LENGTH; i++) { + _humanIKJointIndices.append(jointsDiscovered[i] ? indexOfHumanIKJoint(JOINT_NAMES[i]) : -1); + } yei_tareSensors(_skeletalDevice); #endif } @@ -47,10 +69,5 @@ void PrioVR::update() { unsigned int timestamp; yei_getLastStreamDataAll(_skeletalDevice, (char*)_jointRotations.data(), _jointRotations.size() * sizeof(glm::quat), ×tamp); - for (int i = 0; i < _jointsDiscovered.size(); i++) { - if (_jointsDiscovered.at(i)) { - qDebug() << i << _jointRotations.at(i).x << _jointRotations.at(i).y << _jointRotations.at(i).z << _jointRotations.at(i).w; - } - } #endif } diff --git a/interface/src/devices/PrioVR.h b/interface/src/devices/PrioVR.h index 1c26009b33..8bb21f4357 100644 --- a/interface/src/devices/PrioVR.h +++ b/interface/src/devices/PrioVR.h @@ -31,6 +31,9 @@ public: PrioVR(); virtual ~PrioVR(); + + const QVector& getHumanIKJointIndices() const { return _humanIKJointIndices; } + const QVector& getJointRotations() const { return _jointRotations; } void update(); @@ -39,7 +42,7 @@ private: YEI_Device_Id _skeletalDevice; #endif - QVector _jointsDiscovered; + QVector _humanIKJointIndices; QVector _jointRotations; }; diff --git a/libraries/fbx/src/FBXReader.cpp b/libraries/fbx/src/FBXReader.cpp index 1fc03ceb66..8d2ba4001a 100644 --- a/libraries/fbx/src/FBXReader.cpp +++ b/libraries/fbx/src/FBXReader.cpp @@ -577,6 +577,25 @@ const char* FACESHIFT_BLENDSHAPES[] = { "" }; +const char* HUMANIK_JOINTS[] = { + "RightHand", + "RightForeArm", + "RightArm", + "Head", + "LeftArm", + "LeftForeArm", + "LeftHand", + "Spine", + "Hips", + "RightUpLeg", + "LeftUpLeg", + "RightLeg", + "LeftLeg", + "RightFoot", + "LeftFoot", + "" +}; + class FBXModel { public: QString name; @@ -1012,10 +1031,6 @@ FBXGeometry extractFBXGeometry(const FBXNode& node, const QVariantHash& mapping) QString jointHeadName = processID(getString(joints.value("jointHead", "jointHead"))); QString jointLeftHandName = processID(getString(joints.value("jointLeftHand", "jointLeftHand"))); QString jointRightHandName = processID(getString(joints.value("jointRightHand", "jointRightHand"))); - QVariantList jointLeftFingerNames = joints.values("jointLeftFinger"); - QVariantList jointRightFingerNames = joints.values("jointRightFinger"); - QVariantList jointLeftFingertipNames = joints.values("jointLeftFingertip"); - QVariantList jointRightFingertipNames = joints.values("jointRightFingertip"); QString jointEyeLeftID; QString jointEyeRightID; QString jointNeckID; @@ -1024,10 +1039,16 @@ FBXGeometry extractFBXGeometry(const FBXNode& node, const QVariantHash& mapping) QString jointHeadID; QString jointLeftHandID; QString jointRightHandID; - QVector jointLeftFingerIDs(jointLeftFingerNames.size()); - QVector jointRightFingerIDs(jointRightFingerNames.size()); - QVector jointLeftFingertipIDs(jointLeftFingertipNames.size()); - QVector jointRightFingertipIDs(jointRightFingertipNames.size()); + + QVector humanIKJointNames; + for (int i = 0;; i++) { + QByteArray jointName = HUMANIK_JOINTS[i]; + if (jointName.isEmpty()) { + break; + } + humanIKJointNames.append(processID(getString(joints.value(jointName, jointName)))); + } + QVector humanIKJointIDs(humanIKJointNames.size()); QVariantHash blendshapeMappings = mapping.value("bs").toHash(); QMultiHash blendshapeIndices; @@ -1091,7 +1112,6 @@ FBXGeometry extractFBXGeometry(const FBXNode& node, const QVariantHash& mapping) } else { name = getID(object.properties); } - int index; if (name == jointEyeLeftName || name == "EyeL" || name == "joint_Leye") { jointEyeLeftID = getID(object.properties); @@ -1115,19 +1135,12 @@ FBXGeometry extractFBXGeometry(const FBXNode& node, const QVariantHash& mapping) } else if (name == jointRightHandName) { jointRightHandID = getID(object.properties); - - } else if ((index = jointLeftFingerNames.indexOf(name)) != -1) { - jointLeftFingerIDs[index] = getID(object.properties); - - } else if ((index = jointRightFingerNames.indexOf(name)) != -1) { - jointRightFingerIDs[index] = getID(object.properties); - - } else if ((index = jointLeftFingertipNames.indexOf(name)) != -1) { - jointLeftFingertipIDs[index] = getID(object.properties); - - } else if ((index = jointRightFingertipNames.indexOf(name)) != -1) { - jointRightFingertipIDs[index] = getID(object.properties); } + int humanIKJointIndex = humanIKJointNames.indexOf(name); + if (humanIKJointIndex != -1) { + humanIKJointIDs[humanIKJointIndex] = getID(object.properties); + } + glm::vec3 translation; // NOTE: the euler angles as supplied by the FBX file are in degrees glm::vec3 rotationOffset; @@ -1513,11 +1526,11 @@ FBXGeometry extractFBXGeometry(const FBXNode& node, const QVariantHash& mapping) geometry.headJointIndex = modelIDs.indexOf(jointHeadID); geometry.leftHandJointIndex = modelIDs.indexOf(jointLeftHandID); geometry.rightHandJointIndex = modelIDs.indexOf(jointRightHandID); - geometry.leftFingerJointIndices = getIndices(jointLeftFingerIDs, modelIDs); - geometry.rightFingerJointIndices = getIndices(jointRightFingerIDs, modelIDs); - geometry.leftFingertipJointIndices = getIndices(jointLeftFingertipIDs, modelIDs); - geometry.rightFingertipJointIndices = getIndices(jointRightFingertipIDs, modelIDs); - + + foreach (const QString& id, humanIKJointIDs) { + geometry.humanIKJointIndices.append(modelIDs.indexOf(id)); + } + // extract the translation component of the neck transform if (geometry.neckJointIndex != -1) { const glm::mat4& transform = geometry.joints.at(geometry.neckJointIndex).transform; diff --git a/libraries/fbx/src/FBXReader.h b/libraries/fbx/src/FBXReader.h index 51e7380181..38251e4065 100644 --- a/libraries/fbx/src/FBXReader.h +++ b/libraries/fbx/src/FBXReader.h @@ -30,6 +30,9 @@ typedef QList FBXNodeList; /// The names of the blendshapes expected by Faceshift, terminated with an empty string. extern const char* FACESHIFT_BLENDSHAPES[]; +/// The names of the joints in the Maya HumanIK rig, terminated with an empty string. +extern const char* HUMANIK_JOINTS[]; + class Extents { public: /// set minimum and maximum to FLT_MAX and -FLT_MAX respectively @@ -199,11 +202,7 @@ public: int leftHandJointIndex; int rightHandJointIndex; - QVector leftFingerJointIndices; - QVector rightFingerJointIndices; - - QVector leftFingertipJointIndices; - QVector rightFingertipJointIndices; + QVector humanIKJointIndices; glm::vec3 palmDirection; From eceb600de721500952878e55abf62f0d2c393637 Mon Sep 17 00:00:00 2001 From: Andrzej Kapolka Date: Tue, 13 May 2014 14:44:24 -0700 Subject: [PATCH 06/10] More work on PrioVR integration. --- interface/src/Application.cpp | 5 +++ interface/src/Application.h | 4 +++ interface/src/avatar/MyAvatar.cpp | 47 ++++++++++++++++---------- interface/src/avatar/SkeletonModel.cpp | 20 +++++++++-- interface/src/devices/PrioVR.cpp | 40 +++++++++++++++++++++- interface/src/devices/PrioVR.h | 13 +++++++ 6 files changed, 108 insertions(+), 21 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index deefd10ab0..f9eaf89ea4 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -2752,6 +2752,9 @@ void Application::displayOverlay() { drawText(_glWidget->width() - 100, _glWidget->height() - timerBottom, 0.30f, 0.0f, 0, frameTimer, WHITE_TEXT); } + // give external parties a change to hook in + emit renderingOverlay(); + _overlays.render2D(); glPopMatrix(); @@ -3060,6 +3063,8 @@ void Application::resetSensors() { OculusManager::reset(); } + _prioVR.reset(); + QCursor::setPos(_mouseX, _mouseY); _myAvatar->reset(); diff --git a/interface/src/Application.h b/interface/src/Application.h index 77f8024b6c..985859f4d0 100644 --- a/interface/src/Application.h +++ b/interface/src/Application.h @@ -195,6 +195,7 @@ public: Visage* getVisage() { return &_visage; } FaceTracker* getActiveFaceTracker(); SixenseManager* getSixenseManager() { return &_sixenseManager; } + PrioVR* getPrioVR() { return &_prioVR; } BandwidthMeter* getBandwidthMeter() { return &_bandwidthMeter; } QUndoStack* getUndoStack() { return &_undoStack; } @@ -268,6 +269,9 @@ signals: /// Fired when we're rendering in-world interface elements; allows external parties to hook in. void renderingInWorldInterface(); + /// Fired when we're rendering the overlay. + void renderingOverlay(); + /// Fired when the import window is closed void importDone(); diff --git a/interface/src/avatar/MyAvatar.cpp b/interface/src/avatar/MyAvatar.cpp index e6d6634653..8358fecd9d 100644 --- a/interface/src/avatar/MyAvatar.cpp +++ b/interface/src/avatar/MyAvatar.cpp @@ -244,23 +244,28 @@ void MyAvatar::simulate(float deltaTime) { void MyAvatar::updateFromTrackers(float deltaTime) { glm::vec3 estimatedPosition, estimatedRotation; - FaceTracker* tracker = Application::getInstance()->getActiveFaceTracker(); - if (tracker) { - estimatedPosition = tracker->getHeadTranslation(); - estimatedRotation = glm::degrees(safeEulerAngles(tracker->getHeadRotation())); - - // Rotate the body if the head is turned beyond the screen - if (Menu::getInstance()->isOptionChecked(MenuOption::TurnWithHead)) { - const float TRACKER_YAW_TURN_SENSITIVITY = 0.5f; - const float TRACKER_MIN_YAW_TURN = 15.0f; - const float TRACKER_MAX_YAW_TURN = 50.0f; - if ( (fabs(estimatedRotation.y) > TRACKER_MIN_YAW_TURN) && - (fabs(estimatedRotation.y) < TRACKER_MAX_YAW_TURN) ) { - if (estimatedRotation.y > 0.0f) { - _bodyYawDelta += (estimatedRotation.y - TRACKER_MIN_YAW_TURN) * TRACKER_YAW_TURN_SENSITIVITY; - } else { - _bodyYawDelta += (estimatedRotation.y + TRACKER_MIN_YAW_TURN) * TRACKER_YAW_TURN_SENSITIVITY; - } + if (Application::getInstance()->getPrioVR()->isActive()) { + estimatedRotation = glm::degrees(safeEulerAngles(Application::getInstance()->getPrioVR()->getHeadRotation())); + + } else { + FaceTracker* tracker = Application::getInstance()->getActiveFaceTracker(); + if (tracker) { + estimatedPosition = tracker->getHeadTranslation(); + estimatedRotation = glm::degrees(safeEulerAngles(tracker->getHeadRotation())); + } + } + + // Rotate the body if the head is turned beyond the screen + if (Menu::getInstance()->isOptionChecked(MenuOption::TurnWithHead)) { + const float TRACKER_YAW_TURN_SENSITIVITY = 0.5f; + const float TRACKER_MIN_YAW_TURN = 15.0f; + const float TRACKER_MAX_YAW_TURN = 50.0f; + if ( (fabs(estimatedRotation.y) > TRACKER_MIN_YAW_TURN) && + (fabs(estimatedRotation.y) < TRACKER_MAX_YAW_TURN) ) { + if (estimatedRotation.y > 0.0f) { + _bodyYawDelta += (estimatedRotation.y - TRACKER_MIN_YAW_TURN) * TRACKER_YAW_TURN_SENSITIVITY; + } else { + _bodyYawDelta += (estimatedRotation.y + TRACKER_MIN_YAW_TURN) * TRACKER_YAW_TURN_SENSITIVITY; } } } @@ -278,6 +283,14 @@ void MyAvatar::updateFromTrackers(float deltaTime) { head->setDeltaYaw(estimatedRotation.y * magnifyFieldOfView); head->setDeltaRoll(estimatedRotation.z); + // the priovr can give us exact lean + if (Application::getInstance()->getPrioVR()->isActive()) { + glm::vec3 eulers = glm::degrees(safeEulerAngles(Application::getInstance()->getPrioVR()->getTorsoRotation())); + head->setLeanSideways(eulers.z); + head->setLeanForward(eulers.x); + return; + } + // Update torso lean distance based on accelerometer data const float TORSO_LENGTH = 0.5f; glm::vec3 relativePosition = estimatedPosition - glm::vec3(0.0f, -TORSO_LENGTH, 0.0f); diff --git a/interface/src/avatar/SkeletonModel.cpp b/interface/src/avatar/SkeletonModel.cpp index 96510dad25..7a515d63dc 100644 --- a/interface/src/avatar/SkeletonModel.cpp +++ b/interface/src/avatar/SkeletonModel.cpp @@ -33,14 +33,28 @@ void SkeletonModel::simulate(float deltaTime, bool fullUpdate) { return; // only simulate for own avatar } + const FBXGeometry& geometry = _geometry->getFBXGeometry(); + PrioVR* prioVR = Application::getInstance()->getPrioVR(); + if (prioVR->isActive()) { + for (int i = 0; i < prioVR->getJointRotations().size(); i++) { + int humanIKJointIndex = prioVR->getHumanIKJointIndices().at(i); + if (humanIKJointIndex == -1) { + continue; + } + int jointIndex = geometry.humanIKJointIndices.at(humanIKJointIndex); + if (jointIndex != -1) { + setJointRotation(jointIndex, _rotation * prioVR->getJointRotations().at(i), true); + } + } + return; + } + // find the left and rightmost active Leap palms int leftPalmIndex, rightPalmIndex; Hand* hand = _owningAvatar->getHand(); hand->getLeftRightPalmIndices(leftPalmIndex, rightPalmIndex); - const float HAND_RESTORATION_RATE = 0.25f; - - const FBXGeometry& geometry = _geometry->getFBXGeometry(); + const float HAND_RESTORATION_RATE = 0.25f; if (leftPalmIndex == -1) { // no Leap data; set hands from mouse if (_owningAvatar->getHandState() == HAND_STATE_NULL) { diff --git a/interface/src/devices/PrioVR.cpp b/interface/src/devices/PrioVR.cpp index 5fe6b56b11..adda3b5cb2 100644 --- a/interface/src/devices/PrioVR.cpp +++ b/interface/src/devices/PrioVR.cpp @@ -13,7 +13,9 @@ #include +#include "Application.h" #include "PrioVR.h" +#include "ui/TextRenderer.h" const unsigned int SERIAL_LIST[] = { 0x00000001, 0x00000000, 0x00000008, 0x00000009, 0x0000000A, 0x0000000C, 0x0000000D, 0x0000000E, 0x00000004, 0x00000005, 0x00000010, 0x00000011 }; @@ -49,7 +51,6 @@ PrioVR::PrioVR() { for (int i = 0; i < LIST_LENGTH; i++) { _humanIKJointIndices.append(jointsDiscovered[i] ? indexOfHumanIKJoint(JOINT_NAMES[i]) : -1); } - yei_tareSensors(_skeletalDevice); #endif } @@ -61,6 +62,16 @@ PrioVR::~PrioVR() { #endif } +glm::quat PrioVR::getHeadRotation() const { + const int HEAD_ROTATION_INDEX = 0; + return _jointRotations.size() > HEAD_ROTATION_INDEX ? _jointRotations.at(HEAD_ROTATION_INDEX) : glm::quat(); +} + +glm::quat PrioVR::getTorsoRotation() const { + const int TORSO_ROTATION_INDEX = 1; + return _jointRotations.size() > TORSO_ROTATION_INDEX ? _jointRotations.at(TORSO_ROTATION_INDEX) : glm::quat(); +} + void PrioVR::update() { #ifdef HAVE_PRIOVR if (!_skeletalDevice) { @@ -71,3 +82,30 @@ void PrioVR::update() { _jointRotations.size() * sizeof(glm::quat), ×tamp); #endif } + +void PrioVR::reset() { +#ifdef HAVE_PRIOVR + if (!_skeletalDevice) { + return; + } + connect(Application::getInstance(), SIGNAL(renderingOverlay()), SLOT(renderCalibrationCountdown())); + _calibrationCountdownStarted = QDateTime::currentDateTime(); +#endif +} + +void PrioVR::renderCalibrationCountdown() { +#ifdef HAVE_PRIOVR + const int COUNTDOWN_SECONDS = 3; + int secondsRemaining = COUNTDOWN_SECONDS - _calibrationCountdownStarted.secsTo(QDateTime::currentDateTime()); + if (secondsRemaining == 0) { + yei_tareSensors(_skeletalDevice); + Application::getInstance()->disconnect(this); + return; + } + static TextRenderer textRenderer(MONO_FONT_FAMILY, 18, QFont::Bold, false, TextRenderer::OUTLINE_EFFECT, 2); + QByteArray text = "Assume T-Pose in " + QByteArray::number(secondsRemaining) + "..."; + textRenderer.draw((Application::getInstance()->getGLWidget()->width() - textRenderer.computeWidth(text.constData())) / 2, + Application::getInstance()->getGLWidget()->height() / 2, + text); +#endif +} diff --git a/interface/src/devices/PrioVR.h b/interface/src/devices/PrioVR.h index 8bb21f4357..9cd7bda5d4 100644 --- a/interface/src/devices/PrioVR.h +++ b/interface/src/devices/PrioVR.h @@ -12,6 +12,7 @@ #ifndef hifi_PrioVR_h #define hifi_PrioVR_h +#include #include #include @@ -32,10 +33,20 @@ public: PrioVR(); virtual ~PrioVR(); + bool isActive() const { return !_jointRotations.isEmpty(); } + + glm::quat getHeadRotation() const; + glm::quat getTorsoRotation() const; + const QVector& getHumanIKJointIndices() const { return _humanIKJointIndices; } const QVector& getJointRotations() const { return _jointRotations; } void update(); + void reset(); + +private slots: + + void renderCalibrationCountdown(); private: #ifdef HAVE_PRIOVR @@ -44,6 +55,8 @@ private: QVector _humanIKJointIndices; QVector _jointRotations; + + QDateTime _calibrationCountdownStarted; }; #endif // hifi_PrioVR_h From bca5636f9b424f3024e7186218656a9e70dc7dc9 Mon Sep 17 00:00:00 2001 From: Andrzej Kapolka Date: Tue, 13 May 2014 15:05:00 -0700 Subject: [PATCH 07/10] Looks like "reflection" can be used as a synonym for "specular." --- libraries/fbx/src/FBXReader.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/fbx/src/FBXReader.cpp b/libraries/fbx/src/FBXReader.cpp index 8d2ba4001a..ce71e90114 100644 --- a/libraries/fbx/src/FBXReader.cpp +++ b/libraries/fbx/src/FBXReader.cpp @@ -1365,7 +1365,7 @@ FBXGeometry extractFBXGeometry(const FBXNode& node, const QVariantHash& mapping) } else if (type.contains("bump") || type.contains("normal")) { bumpTextures.insert(getID(connection.properties, 2), getID(connection.properties, 1)); - } else if (type.contains("specular")) { + } else if (type.contains("specular") || type.contains("reflection")) { specularTextures.insert(getID(connection.properties, 2), getID(connection.properties, 1)); } else if (type == "lcl rotation") { From cf230d1cc33ecc92153df953ac18ce789f9608ed Mon Sep 17 00:00:00 2001 From: Andrzej Kapolka Date: Wed, 14 May 2014 13:36:26 -0700 Subject: [PATCH 08/10] PrioVR tweaks. --- interface/src/avatar/MyAvatar.cpp | 4 +++- interface/src/avatar/SkeletonModel.cpp | 2 +- interface/src/devices/PrioVR.cpp | 10 ++++++++-- interface/src/devices/Visage.cpp | 3 ++- 4 files changed, 14 insertions(+), 5 deletions(-) diff --git a/interface/src/avatar/MyAvatar.cpp b/interface/src/avatar/MyAvatar.cpp index 014d53520e..5ef4b6ecc0 100644 --- a/interface/src/avatar/MyAvatar.cpp +++ b/interface/src/avatar/MyAvatar.cpp @@ -239,7 +239,9 @@ void MyAvatar::updateFromTrackers(float deltaTime) { if (Application::getInstance()->getPrioVR()->isActive()) { estimatedRotation = glm::degrees(safeEulerAngles(Application::getInstance()->getPrioVR()->getHeadRotation())); - + estimatedRotation.x *= -1.0f; + estimatedRotation.z *= -1.0f; + } else { FaceTracker* tracker = Application::getInstance()->getActiveFaceTracker(); if (tracker) { diff --git a/interface/src/avatar/SkeletonModel.cpp b/interface/src/avatar/SkeletonModel.cpp index 5c017cd094..e48ebfa63c 100644 --- a/interface/src/avatar/SkeletonModel.cpp +++ b/interface/src/avatar/SkeletonModel.cpp @@ -200,7 +200,7 @@ void SkeletonModel::updateJointState(int index) { } void SkeletonModel::maybeUpdateLeanRotation(const JointState& parentState, const FBXJoint& joint, JointState& state) { - if (!_owningAvatar->isMyAvatar()) { + if (!_owningAvatar->isMyAvatar() || Application::getInstance()->getPrioVR()->isActive()) { return; } // get the rotation axes in joint space and use them to adjust the rotation diff --git a/interface/src/devices/PrioVR.cpp b/interface/src/devices/PrioVR.cpp index adda3b5cb2..605ace5c9b 100644 --- a/interface/src/devices/PrioVR.cpp +++ b/interface/src/devices/PrioVR.cpp @@ -22,8 +22,8 @@ const unsigned int SERIAL_LIST[] = { 0x00000001, 0x00000000, 0x00000008, 0x00000 const unsigned char AXIS_LIST[] = { 9, 43, 37, 37, 37, 13, 13, 13, 52, 52, 28, 28 }; const int LIST_LENGTH = sizeof(SERIAL_LIST) / sizeof(SERIAL_LIST[0]); -const char* JOINT_NAMES[] = { "Head", "Spine", "LeftArm", "LeftForeArm", "LeftHand", "RightArm", - "RightForeArm", "RightHand", "LeftUpLeg", "LeftLeg", "RightUpLeft", "RightLeg" }; +const char* JOINT_NAMES[] = { "Neck", "Spine", "LeftArm", "LeftForeArm", "LeftHand", "RightArm", + "RightForeArm", "RightHand", "LeftUpLeg", "LeftLeg", "RightUpLeg", "RightLeg" }; #ifdef HAVE_PRIOVR static int indexOfHumanIKJoint(const char* jointName) { @@ -80,6 +80,12 @@ void PrioVR::update() { unsigned int timestamp; yei_getLastStreamDataAll(_skeletalDevice, (char*)_jointRotations.data(), _jointRotations.size() * sizeof(glm::quat), ×tamp); + + // convert to our expected coordinate system + for (int i = 0; i < _jointRotations.size(); i++) { + _jointRotations[i].y *= -1.0f; + _jointRotations[i].z *= -1.0f; + } #endif } diff --git a/interface/src/devices/Visage.cpp b/interface/src/devices/Visage.cpp index 8173519478..7c8c3ae89e 100644 --- a/interface/src/devices/Visage.cpp +++ b/interface/src/devices/Visage.cpp @@ -55,7 +55,8 @@ Visage::Visage() : Visage::~Visage() { #ifdef HAVE_VISAGE _tracker->stop(); - delete _tracker; + // deleting the tracker crashes windows; disable for now + //delete _tracker; delete _data; #endif } From 4cbe8a41dba751095b0f58e6bd643fdf29bb8950 Mon Sep 17 00:00:00 2001 From: Andrzej Kapolka Date: Wed, 14 May 2014 13:40:03 -0700 Subject: [PATCH 09/10] Add PrioVR to .gitignore. --- .gitignore | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.gitignore b/.gitignore index c296a918af..8d537b993f 100644 --- a/.gitignore +++ b/.gitignore @@ -46,5 +46,9 @@ interface/resources/visage/* interface/external/faceplus/* !interface/external/faceplus/readme.txt +# Ignore PrioVR +interface/external/priovr/* +!interface/external/priovr/readme.txt + # Ignore interfaceCache for Linux users interface/interfaceCache/ From 95c05a720dd6fd23799fe95285fdad31bb346a41 Mon Sep 17 00:00:00 2001 From: Andrzej Kapolka Date: Wed, 14 May 2014 13:48:03 -0700 Subject: [PATCH 10/10] Tabs -> spaces. --- interface/src/avatar/MyAvatar.cpp | 4 ++-- interface/src/devices/PrioVR.cpp | 12 ++++++------ interface/src/devices/Visage.cpp | 2 +- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/interface/src/avatar/MyAvatar.cpp b/interface/src/avatar/MyAvatar.cpp index 5ef4b6ecc0..1eac264ae4 100644 --- a/interface/src/avatar/MyAvatar.cpp +++ b/interface/src/avatar/MyAvatar.cpp @@ -239,8 +239,8 @@ void MyAvatar::updateFromTrackers(float deltaTime) { if (Application::getInstance()->getPrioVR()->isActive()) { estimatedRotation = glm::degrees(safeEulerAngles(Application::getInstance()->getPrioVR()->getHeadRotation())); - estimatedRotation.x *= -1.0f; - estimatedRotation.z *= -1.0f; + estimatedRotation.x *= -1.0f; + estimatedRotation.z *= -1.0f; } else { FaceTracker* tracker = Application::getInstance()->getActiveFaceTracker(); diff --git a/interface/src/devices/PrioVR.cpp b/interface/src/devices/PrioVR.cpp index 605ace5c9b..064e2be4b5 100644 --- a/interface/src/devices/PrioVR.cpp +++ b/interface/src/devices/PrioVR.cpp @@ -80,12 +80,12 @@ void PrioVR::update() { unsigned int timestamp; yei_getLastStreamDataAll(_skeletalDevice, (char*)_jointRotations.data(), _jointRotations.size() * sizeof(glm::quat), ×tamp); - - // convert to our expected coordinate system - for (int i = 0; i < _jointRotations.size(); i++) { - _jointRotations[i].y *= -1.0f; - _jointRotations[i].z *= -1.0f; - } + + // convert to our expected coordinate system + for (int i = 0; i < _jointRotations.size(); i++) { + _jointRotations[i].y *= -1.0f; + _jointRotations[i].z *= -1.0f; + } #endif } diff --git a/interface/src/devices/Visage.cpp b/interface/src/devices/Visage.cpp index 7c8c3ae89e..119d89654a 100644 --- a/interface/src/devices/Visage.cpp +++ b/interface/src/devices/Visage.cpp @@ -56,7 +56,7 @@ Visage::~Visage() { #ifdef HAVE_VISAGE _tracker->stop(); // deleting the tracker crashes windows; disable for now - //delete _tracker; + //delete _tracker; delete _data; #endif }