From e0486b26549062d0311b706cc0d58465d43883e7 Mon Sep 17 00:00:00 2001 From: Andrzej Kapolka Date: Mon, 12 May 2014 15:25:25 -0700 Subject: [PATCH] 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