From 78e15e021268d5bc3ed3a3f9b9dc1f3779e51d08 Mon Sep 17 00:00:00 2001 From: Andrzej Kapolka Date: Tue, 11 Feb 2014 16:03:23 -0800 Subject: [PATCH 01/39] Starting on Visage support. --- cmake/modules/FindVisage.cmake | 0 interface/external/visage/readme.txt | 8 ++++++++ 2 files changed, 8 insertions(+) create mode 100644 cmake/modules/FindVisage.cmake create mode 100644 interface/external/visage/readme.txt diff --git a/cmake/modules/FindVisage.cmake b/cmake/modules/FindVisage.cmake new file mode 100644 index 0000000000..e69de29bb2 diff --git a/interface/external/visage/readme.txt b/interface/external/visage/readme.txt new file mode 100644 index 0000000000..fe2e81f87b --- /dev/null +++ b/interface/external/visage/readme.txt @@ -0,0 +1,8 @@ + +Instructions for adding the Visage driver to Interface +Andrzej Kapolka, February 11, 2014 + +1. Copy the Visage sdk folders (lib, include) into the interface/external/visage folder. This readme.txt should be there as well. + +2. Delete your build directory, run cmake and build, and you should be all set. + From 25066f8b4f81f2d11427d996896c76452a343a00 Mon Sep 17 00:00:00 2001 From: Andrzej Kapolka Date: Tue, 11 Feb 2014 16:44:25 -0800 Subject: [PATCH 02/39] Starting on Visage integration. --- cmake/modules/FindVisage.cmake | 44 ++++++++++++++++++++++++++++ interface/CMakeLists.txt | 14 ++++++++- interface/external/visage/readme.txt | 10 +++++-- interface/src/Application.h | 2 ++ interface/src/devices/Visage.cpp | 36 +++++++++++++++++++++++ interface/src/devices/Visage.h | 28 ++++++++++++++++++ 6 files changed, 131 insertions(+), 3 deletions(-) create mode 100644 interface/src/devices/Visage.cpp create mode 100644 interface/src/devices/Visage.h diff --git a/cmake/modules/FindVisage.cmake b/cmake/modules/FindVisage.cmake index e69de29bb2..a8d1acc30b 100644 --- a/cmake/modules/FindVisage.cmake +++ b/cmake/modules/FindVisage.cmake @@ -0,0 +1,44 @@ +# Try to find the Visage controller library +# +# You must provide a VISAGE_ROOT_DIR which contains lib and include directories +# +# Once done this will define +# +# VISAGE_FOUND - system found Visage +# VISAGE_INCLUDE_DIRS - the Visage include directory +# VISAGE_LIBRARIES - Link this to use Visage +# +# Created on 2/11/2014 by Andrzej Kapolka +# Copyright (c) 2014 High Fidelity +# + +if (VISAGE_LIBRARIES AND VISAGE_INCLUDE_DIRS) + # in cache already + set(VISAGE_FOUND TRUE) +else (VISAGE_LIBRARIES AND VISAGE_INCLUDE_DIRS) + find_path(VISAGE_INCLUDE_DIRS VisageTracker2.h ${VISAGE_ROOT_DIR}/include) + + if (APPLE) + find_library(VISAGE_LIBRARIES libvscore.a ${VISAGE_ROOT_DIR}/lib) + elseif (WIN32) + find_library(VISAGE_LIBRARIES vscore.dll ${VISAGE_ROOT_DIR}/lib) + endif () + + if (VISAGE_INCLUDE_DIRS AND VISAGE_LIBRARIES) + set(VISAGE_FOUND TRUE) + endif (VISAGE_INCLUDE_DIRS AND VISAGE_LIBRARIES) + + if (VISAGE_FOUND) + if (NOT VISAGE_FIND_QUIETLY) + message(STATUS "Found Visage: ${VISAGE_LIBRARIES}") + endif (NOT VISAGE_FIND_QUIETLY) + else (VISAGE_FOUND) + if (VISAGE_FIND_REQUIRED) + message(FATAL_ERROR "Could not find Visage") + endif (VISAGE_FIND_REQUIRED) + endif (VISAGE_FOUND) + + # show the VISAGE_INCLUDE_DIRS and VISAGE_LIBRARIES variables only in the advanced view + mark_as_advanced(VISAGE_INCLUDE_DIRS VISAGE_LIBRARIES) + +endif (VISAGE_LIBRARIES AND VISAGE_INCLUDE_DIRS) diff --git a/interface/CMakeLists.txt b/interface/CMakeLists.txt index 6af6ed478d..188e7a6995 100644 --- a/interface/CMakeLists.txt +++ b/interface/CMakeLists.txt @@ -11,6 +11,7 @@ set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/../cmake set(FACESHIFT_ROOT_DIR ${CMAKE_CURRENT_SOURCE_DIR}/external/faceshift) set(LIBOVR_ROOT_DIR ${CMAKE_CURRENT_SOURCE_DIR}/external/LibOVR) set(SIXENSE_ROOT_DIR ${CMAKE_CURRENT_SOURCE_DIR}/external/Sixense) +set(VISAGE_ROOT_DIR ${CMAKE_CURRENT_SOURCE_DIR}/external/visage) if (DEFINED ENV{JOB_ID}) set(BUILD_SEQ $ENV{JOB_ID}) @@ -132,9 +133,10 @@ find_package(Faceshift) find_package(GLM REQUIRED) find_package(LibOVR) find_package(Sixense) +find_package(Visage) find_package(ZLIB) -# likewise with Sixense library for Razer Hydra +# include the Sixense library for Razer Hydra if available if (SIXENSE_FOUND AND NOT DISABLE_SIXENSE) add_definitions(-DHAVE_SIXENSE) include_directories(SYSTEM ${SIXENSE_INCLUDE_DIRS}) @@ -144,6 +146,16 @@ if (SIXENSE_FOUND AND NOT DISABLE_SIXENSE) target_link_libraries(${TARGET_NAME} ${SIXENSE_LIBRARIES}) endif (SIXENSE_FOUND AND NOT DISABLE_SIXENSE) +# likewise with Visage library for webcam feature tracking +if (VISAGE_FOUND AND NOT DISABLE_VISAGE) + add_definitions(-DHAVE_VISAGE) + include_directories(SYSTEM ${VISAGE_INCLUDE_DIRS}) + if (APPLE OR UNIX) + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -isystem ${VISAGE_INCLUDE_DIRS}") + endif (APPLE OR UNIX) + target_link_libraries(${TARGET_NAME} ${VISAGE_LIBRARIES}) +endif (VISAGE_FOUND AND NOT DISABLE_VISAGE) + # and with LibOVR for Oculus Rift if (LIBOVR_FOUND AND NOT DISABLE_LIBOVR) add_definitions(-DHAVE_LIBOVR) diff --git a/interface/external/visage/readme.txt b/interface/external/visage/readme.txt index fe2e81f87b..dfb3da3969 100644 --- a/interface/external/visage/readme.txt +++ b/interface/external/visage/readme.txt @@ -2,7 +2,13 @@ Instructions for adding the Visage driver to Interface Andrzej Kapolka, February 11, 2014 -1. Copy the Visage sdk folders (lib, include) into the interface/external/visage folder. This readme.txt should be there as well. +1. Copy the Visage sdk folders (lib, include) into the interface/external/visage folder. + This readme.txt should be there as well. -2. Delete your build directory, run cmake and build, and you should be all set. +2. Copy the Visage configuration data folder (visageSDK-MacOS/Samples/MacOSX/data/) to interface/resources/visage + (i.e., so that interface/resources/visage/candide3.wfm is accessible) + +3. Copy the Visage license file to interface/resources/visage/license.vlc. + +4. Delete your build directory, run cmake and build, and you should be all set. diff --git a/interface/src/Application.h b/interface/src/Application.h index ff6e08758b..b2af223edc 100644 --- a/interface/src/Application.h +++ b/interface/src/Application.h @@ -55,6 +55,7 @@ #include "avatar/Profile.h" #include "devices/Faceshift.h" #include "devices/SixenseManager.h" +#include "devices/Visage.h" #include "renderer/AmbientOcclusionEffect.h" #include "renderer/GeometryCache.h" #include "renderer/GlowEffect.h" @@ -378,6 +379,7 @@ private: Profile _profile; // The data-server linked profile for this user Faceshift _faceshift; + Visage _visage; SixenseManager _sixenseManager; QStringList _activeScripts; diff --git a/interface/src/devices/Visage.cpp b/interface/src/devices/Visage.cpp new file mode 100644 index 0000000000..4b986d7db4 --- /dev/null +++ b/interface/src/devices/Visage.cpp @@ -0,0 +1,36 @@ +// +// Visage.cpp +// interface +// +// Created by Andrzej Kapolka on 2/11/14. +// Copyright (c) 2014 High Fidelity, Inc. All rights reserved. +// + +#ifdef HAVE_VISAGE +#include +#endif + +#include + +#include "Visage.h" + +namespace VisageSDK { + void initializeLicenseManager(char* licenseKeyFileName); +} + +using namespace VisageSDK; + +Visage::Visage() { +#ifdef HAVE_VISAGE + switchToResourcesParentIfRequired(); + initializeLicenseManager("resources/visage/license.vlc"); + _tracker = new VisageTracker2("resources/visage/Facial Features Tracker - Asymmetric.cfg"); + _tracker->trackFromCam(); +#endif +} + +Visage::~Visage() { +#ifdef HAVE_VISAGE + delete _tracker; +#endif +} diff --git a/interface/src/devices/Visage.h b/interface/src/devices/Visage.h new file mode 100644 index 0000000000..1b9d283bb3 --- /dev/null +++ b/interface/src/devices/Visage.h @@ -0,0 +1,28 @@ +// +// Visage.h +// interface +// +// Created by Andrzej Kapolka on 2/11/14. +// Copyright (c) 2014 High Fidelity, Inc. All rights reserved. +// + +#ifndef __interface__Visage__ +#define __interface__Visage__ + +namespace VisageSDK { + class VisageTracker2; +} + +/// Handles input from the Visage webcam feature tracking software. +class Visage { +public: + + Visage(); + ~Visage(); + +private: + + VisageSDK::VisageTracker2* _tracker; +}; + +#endif /* defined(__interface__Visage__) */ From b3fba320fcd3dced1f9252637eff016a89b23482 Mon Sep 17 00:00:00 2001 From: Andrzej Kapolka Date: Tue, 11 Feb 2014 17:03:24 -0800 Subject: [PATCH 03/39] We need the dependencies, too. --- cmake/modules/FindVisage.cmake | 32 ++++++++++++++++++++++++---- interface/external/visage/readme.txt | 2 +- 2 files changed, 29 insertions(+), 5 deletions(-) diff --git a/cmake/modules/FindVisage.cmake b/cmake/modules/FindVisage.cmake index a8d1acc30b..600164908c 100644 --- a/cmake/modules/FindVisage.cmake +++ b/cmake/modules/FindVisage.cmake @@ -16,12 +16,36 @@ if (VISAGE_LIBRARIES AND VISAGE_INCLUDE_DIRS) # in cache already set(VISAGE_FOUND TRUE) else (VISAGE_LIBRARIES AND VISAGE_INCLUDE_DIRS) - find_path(VISAGE_INCLUDE_DIRS VisageTracker2.h ${VISAGE_ROOT_DIR}/include) - + find_path(VISAGE_INCLUDE_DIR VisageTracker2.h ${VISAGE_ROOT_DIR}/include) + if (APPLE) - find_library(VISAGE_LIBRARIES libvscore.a ${VISAGE_ROOT_DIR}/lib) + find_path(VISAGE_OPENCV_INCLUDE_DIR cv.h ${VISAGE_ROOT_DIR}/dependencies/OpenCV_MacOSX/include) + if (VISAGE_INCLUDE_DIR AND VISAGE_OPENCV_INCLUDE_DIR) + set(VISAGE_INCLUDE_DIRS "${VISAGE_INCLUDE_DIR};${VISAGE_OPENCV_INCLUDE_DIR}" CACHE INTERNAL "Visage include dirs") + endif (VISAGE_INCLUDE_DIR AND VISAGE_OPENCV_INCLUDE_DIR) + + find_library(VISAGE_CORE_LIBRARY libvscore.a ${VISAGE_ROOT_DIR}/lib) + find_library(VISAGE_VISION_LIBRARY libvsvision.a ${VISAGE_ROOT_DIR}/lib) + find_library(VISAGE_OPENCV_LIBRARY libOpenCV.a ${VISAGE_ROOT_DIR}/dependencies/OpenCV_MacOSX/lib) + if (VISAGE_CORE_LIBRARY AND VISAGE_VISION_LIBRARY AND VISAGE_OPENCV_LIBRARY) + set(VISAGE_LIBRARIES "${VISAGE_CORE_LIBRARY};${VISAGE_VISION_LIBRARY};${VISAGE_OPENCV_LIBRARY}" + CACHE INTERNAL "Visage libraries") + endif (VISAGE_CORE_LIBRARY AND VISAGE_VISION_LIBRARY AND VISAGE_OPENCV_LIBRARY) + elseif (WIN32) - find_library(VISAGE_LIBRARIES vscore.dll ${VISAGE_ROOT_DIR}/lib) + find_path(VISAGE_OPENCV_INCLUDE_DIR cv.h ${VISAGE_ROOT_DIR}/dependencies/OpenCV_Win32/include) + if (VISAGE_INCLUDE_DIR AND VISAGE_OPENCV_INCLUDE_DIR) + set(VISAGE_INCLUDE_DIRS "${VISAGE_INCLUDE_DIR};${VISAGE_OPENCV_INCLUDE_DIR}" CACHE INTERNAL "Visage include dirs") + endif (VISAGE_INCLUDE_DIR AND VISAGE_OPENCV_INCLUDE_DIR) + + find_library(VISAGE_CORE_LIBRARY vscore.lib ${VISAGE_ROOT_DIR}/lib) + find_library(VISAGE_VISION_LIBRARY vsvision.lib ${VISAGE_ROOT_DIR}/lib) + find_library(VISAGE_OPENCV_LIBRARY OpenCV.lib ${VISAGE_ROOT_DIR}/dependencies/OpenCV_Win32/lib) + if (VISAGE_CORE_LIBRARY AND VISAGE_VISION_LIBRARY AND VISAGE_OPENCV_LIBRARY) + set(VISAGE_LIBRARIES "${VISAGE_CORE_LIBRARY};${VISAGE_VISION_LIBRARY};${VISAGE_OPENCV_LIBRARY}" + CACHE INTERNAL "Visage libraries") + endif (VISAGE_CORE_LIBRARY AND VISAGE_VISION_LIBRARY AND VISAGE_OPENCV_LIBRARY) + endif () if (VISAGE_INCLUDE_DIRS AND VISAGE_LIBRARIES) diff --git a/interface/external/visage/readme.txt b/interface/external/visage/readme.txt index dfb3da3969..8aa28f81c4 100644 --- a/interface/external/visage/readme.txt +++ b/interface/external/visage/readme.txt @@ -2,7 +2,7 @@ Instructions for adding the Visage driver to Interface Andrzej Kapolka, February 11, 2014 -1. Copy the Visage sdk folders (lib, include) into the interface/external/visage folder. +1. Copy the Visage sdk folders (lib, include, dependencies) into the interface/external/visage folder. This readme.txt should be there as well. 2. Copy the Visage configuration data folder (visageSDK-MacOS/Samples/MacOSX/data/) to interface/resources/visage From 68584c654b0612f1c7ff47c6326c61b973bfb2ce Mon Sep 17 00:00:00 2001 From: stojce Date: Wed, 12 Feb 2014 02:12:52 +0100 Subject: [PATCH 04/39] Allow drag-and-drop of snapshots into Interface --- interface/src/Application.cpp | 34 +++++++++- interface/src/Application.h | 3 +- interface/src/GLCanvas.cpp | 19 +++++- interface/src/GLCanvas.h | 3 + interface/src/Menu.cpp | 107 ++++++++++++++---------------- interface/src/Menu.h | 4 +- interface/src/ui/Snapshot.cpp | 63 ++++++++++++++++-- interface/src/ui/Snapshot.h | 27 ++++++-- libraries/shared/src/NodeList.cpp | 3 +- 9 files changed, 190 insertions(+), 73 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 160d6b7c2c..0bb5d03eaa 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -48,6 +48,8 @@ #include #include #include +#include +#include #include #include @@ -197,7 +199,7 @@ Application::Application(int& argc, char** argv, timeval &startup_time) : connect(audioThread, SIGNAL(started()), &_audio, SLOT(start())); audioThread->start(); - + connect(nodeList, SIGNAL(domainChanged(const QString&)), SLOT(domainChanged(const QString&))); connect(nodeList, &NodeList::nodeAdded, this, &Application::nodeAdded); connect(nodeList, &NodeList::nodeKilled, this, &Application::nodeKilled); @@ -1378,6 +1380,32 @@ void Application::wheelEvent(QWheelEvent* event) { } } +void Application::dropEvent(QDropEvent *event) { + QString snapshotPath; + const QMimeData *mimeData = event->mimeData(); + foreach (QUrl url, mimeData->urls()) { + if (url.url().toLower().endsWith("jpg")) { + snapshotPath = url.url().remove("file://"); + break; + } + } + + SnapshotMetaData* snapshotData = Snapshot::parseSnapshotData(snapshotPath); + if (snapshotData != NULL) { + if (!snapshotData->getDomain().isEmpty()) { + Menu::getInstance()->goToDomain(snapshotData->getDomain()); + } + + _myAvatar->setPosition(snapshotData->getLocation()); + _myAvatar->setOrientation(snapshotData->getOrientation()); + } else { + QMessageBox msgBox; + msgBox.setText("No location details were found in this JPG, try dragging in an authentic Hifi snapshot."); + msgBox.setStandardButtons(QMessageBox::Ok); + msgBox.exec(); + } +} + void Application::sendPingPackets() { QByteArray pingPacket = NodeList::getInstance()->constructPingPacket(); controlledBroadcastToNodes(pingPacket, NodeSet() << NodeType::VoxelServer @@ -3794,7 +3822,7 @@ void Application::updateWindowTitle(){ QString title = QString() + _profile.getUsername() + " " + nodeList->getSessionUUID().toString() + " @ " + nodeList->getDomainHostname() + buildVersion; - + qDebug("Application title set to: %s", title.toStdString().c_str()); _window->setWindowTitle(title); } @@ -4170,6 +4198,6 @@ void Application::takeSnapshot() { player->setMedia(QUrl::fromLocalFile(inf.absoluteFilePath())); player->play(); - Snapshot::saveSnapshot(_glWidget, _profile.getUsername(), _myAvatar->getPosition()); + Snapshot::saveSnapshot(_glWidget, &_profile, _myAvatar); } diff --git a/interface/src/Application.h b/interface/src/Application.h index ff6e08758b..9508c0c9a5 100644 --- a/interface/src/Application.h +++ b/interface/src/Application.h @@ -127,7 +127,8 @@ public: void touchUpdateEvent(QTouchEvent* event); void wheelEvent(QWheelEvent* event); - + void dropEvent(QDropEvent *event); + void makeVoxel(glm::vec3 position, float scale, unsigned char red, diff --git a/interface/src/GLCanvas.cpp b/interface/src/GLCanvas.cpp index cd6f49383e..cfff3b8696 100644 --- a/interface/src/GLCanvas.cpp +++ b/interface/src/GLCanvas.cpp @@ -9,6 +9,8 @@ #include "Application.h" #include "GLCanvas.h" +#include +#include GLCanvas::GLCanvas() : QGLWidget(QGLFormat(QGL::NoDepthBuffer, QGL::NoStencilBuffer)) { } @@ -16,6 +18,7 @@ GLCanvas::GLCanvas() : QGLWidget(QGLFormat(QGL::NoDepthBuffer, QGL::NoStencilBuf void GLCanvas::initializeGL() { Application::getInstance()->initializeGL(); setAttribute(Qt::WA_AcceptTouchEvents); + setAcceptDrops(true); } void GLCanvas::paintGL() { @@ -67,4 +70,18 @@ bool GLCanvas::event(QEvent* event) { void GLCanvas::wheelEvent(QWheelEvent* event) { Application::getInstance()->wheelEvent(event); -} \ No newline at end of file +} + +void GLCanvas::dragEnterEvent(QDragEnterEvent* event) { + const QMimeData *mimeData = event->mimeData(); + foreach (QUrl url, mimeData->urls()) { + if (url.url().toLower().endsWith("jpg")) { + event->acceptProposedAction(); + break; + } + } +} + +void GLCanvas::dropEvent(QDropEvent* event) { + Application::getInstance()->dropEvent(event); +} diff --git a/interface/src/GLCanvas.h b/interface/src/GLCanvas.h index ad181f4456..0f0cb5c7d0 100644 --- a/interface/src/GLCanvas.h +++ b/interface/src/GLCanvas.h @@ -31,6 +31,9 @@ protected: virtual bool event(QEvent* event); virtual void wheelEvent(QWheelEvent* event); + + virtual void dragEnterEvent(QDragEnterEvent *event); + virtual void dropEvent(QDropEvent* event); }; #endif /* defined(__hifi__GLCanvas__) */ diff --git a/interface/src/Menu.cpp b/interface/src/Menu.cpp index 7eb5807c6f..a73506243d 100644 --- a/interface/src/Menu.cpp +++ b/interface/src/Menu.cpp @@ -109,7 +109,7 @@ Menu::Menu() : MenuOption::GoToDomain, Qt::CTRL | Qt::Key_D, this, - SLOT(goToDomain())); + SLOT(goToDomainDialog())); addActionToQMenuAndActionHash(fileMenu, MenuOption::GoToLocation, Qt::CTRL | Qt::SHIFT | Qt::Key_L, @@ -889,7 +889,18 @@ void Menu::editPreferences() { sendFakeEnterEvent(); } -void Menu::goToDomain() { +void Menu::goToDomain(const QString newDomain) { + if (NodeList::getInstance()->getDomainHostname() != newDomain) { + + // send a node kill request, indicating to other clients that they should play the "disappeared" effect + Application::getInstance()->getAvatar()->sendKillAvatar(); + + // give our nodeList the new domain-server hostname + NodeList::getInstance()->setDomainHostname(newDomain); + } +} + +void Menu::goToDomainDialog() { QString currentDomainHostname = NodeList::getInstance()->getDomainHostname(); @@ -913,17 +924,46 @@ void Menu::goToDomain() { // the user input a new hostname, use that newHostname = domainDialog.textValue(); } - - // send a node kill request, indicating to other clients that they should play the "disappeared" effect - Application::getInstance()->getAvatar()->sendKillAvatar(); - - // give our nodeList the new domain-server hostname - NodeList::getInstance()->setDomainHostname(domainDialog.textValue()); + + goToDomain(newHostname); } sendFakeEnterEvent(); } +bool Menu::goToDestination(QString destination) { + + QStringList coordinateItems = destination.split(QRegExp("_|,"), QString::SkipEmptyParts); + + const int NUMBER_OF_COORDINATE_ITEMS = 3; + const int X_ITEM = 0; + const int Y_ITEM = 1; + const int Z_ITEM = 2; + if (coordinateItems.size() == NUMBER_OF_COORDINATE_ITEMS) { + + double x = replaceLastOccurrence('-', '.', coordinateItems[X_ITEM].trimmed()).toDouble(); + double y = replaceLastOccurrence('-', '.', coordinateItems[Y_ITEM].trimmed()).toDouble(); + double z = replaceLastOccurrence('-', '.', coordinateItems[Z_ITEM].trimmed()).toDouble(); + + glm::vec3 newAvatarPos(x, y, z); + + MyAvatar* myAvatar = Application::getInstance()->getAvatar(); + glm::vec3 avatarPos = myAvatar->getPosition(); + if (newAvatarPos != avatarPos) { + // send a node kill request, indicating to other clients that they should play the "disappeared" effect + MyAvatar::sendKillAvatar(); + + qDebug("Going To Location: %f, %f, %f...", x, y, z); + myAvatar->setPosition(newAvatarPos); + } + + return true; + } + + // no coordinates were parsed + return false; +} + void Menu::goTo() { QInputDialog gotoDialog(Application::getInstance()->getWindow()); @@ -939,31 +979,8 @@ void Menu::goTo() { destination = gotoDialog.textValue(); - QStringList coordinateItems = destination.split(QRegExp("_|,"), QString::SkipEmptyParts); - - const int NUMBER_OF_COORDINATE_ITEMS = 3; - const int X_ITEM = 0; - const int Y_ITEM = 1; - const int Z_ITEM = 2; - if (coordinateItems.size() == NUMBER_OF_COORDINATE_ITEMS) { - - double x = replaceLastOccurrence('-', '.', coordinateItems[X_ITEM].trimmed()).toDouble(); - double y = replaceLastOccurrence('-', '.', coordinateItems[Y_ITEM].trimmed()).toDouble(); - double z = replaceLastOccurrence('-', '.', coordinateItems[Z_ITEM].trimmed()).toDouble(); - - glm::vec3 newAvatarPos(x, y, z); - - MyAvatar* myAvatar = Application::getInstance()->getAvatar(); - glm::vec3 avatarPos = myAvatar->getPosition(); - if (newAvatarPos != avatarPos) { - // send a node kill request, indicating to other clients that they should play the "disappeared" effect - MyAvatar::sendKillAvatar(); - - qDebug("Going To Location: %f, %f, %f...", x, y, z); - myAvatar->setPosition(newAvatarPos); - } - - } else { + // go to coordinate destination or to Username + if (!goToDestination(destination)) { // there's a username entered by the user, make a request to the data-server DataServerClient::getValuesForKeysAndUserString( QStringList() @@ -994,29 +1011,7 @@ void Menu::goToLocation() { int dialogReturn = coordinateDialog.exec(); if (dialogReturn == QDialog::Accepted && !coordinateDialog.textValue().isEmpty()) { - QByteArray newCoordinates; - - QString delimiterPattern(","); - QStringList coordinateItems = coordinateDialog.textValue().split(delimiterPattern); - - const int NUMBER_OF_COORDINATE_ITEMS = 3; - const int X_ITEM = 0; - const int Y_ITEM = 1; - const int Z_ITEM = 2; - if (coordinateItems.size() == NUMBER_OF_COORDINATE_ITEMS) { - double x = coordinateItems[X_ITEM].toDouble(); - double y = coordinateItems[Y_ITEM].toDouble(); - double z = coordinateItems[Z_ITEM].toDouble(); - glm::vec3 newAvatarPos(x, y, z); - - if (newAvatarPos != avatarPos) { - // send a node kill request, indicating to other clients that they should play the "disappeared" effect - MyAvatar::sendKillAvatar(); - - qDebug("Going To Location: %f, %f, %f...", x, y, z); - myAvatar->setPosition(newAvatarPos); - } - } + goToDestination(coordinateDialog.textValue()); } sendFakeEnterEvent(); diff --git a/interface/src/Menu.h b/interface/src/Menu.h index 742b9fc66f..780face29a 100644 --- a/interface/src/Menu.h +++ b/interface/src/Menu.h @@ -84,6 +84,8 @@ public: const char* member = NULL, QAction::MenuRole role = QAction::NoRole); virtual void removeAction(QMenu* menu, const QString& actionName); + bool goToDestination(QString destination); + void goToDomain(const QString newDomain); public slots: void bandwidthDetails(); @@ -100,7 +102,7 @@ private slots: void aboutApp(); void login(); void editPreferences(); - void goToDomain(); + void goToDomainDialog(); void goToLocation(); void bandwidthDetailsClosed(); void voxelStatsDetailsClosed(); diff --git a/interface/src/ui/Snapshot.cpp b/interface/src/ui/Snapshot.cpp index f0fef33cee..33d2087594 100644 --- a/interface/src/ui/Snapshot.cpp +++ b/interface/src/ui/Snapshot.cpp @@ -14,6 +14,8 @@ #include #include +#include + // filename format: hifi-snap-by-%username%-on-%date%_%time%_@-%location%.jpg // %1 <= username, %2 <= date and time, %3 <= current location const QString FILENAME_PATH_FORMAT = "hifi-snap-by-%1-on-%2@%3.jpg"; @@ -21,18 +23,69 @@ const QString FILENAME_PATH_FORMAT = "hifi-snap-by-%1-on-%2@%3.jpg"; const QString DATETIME_FORMAT = "yyyy-MM-dd_hh-mm-ss"; const QString SNAPSHOTS_DIRECTORY = "Snapshots"; -void Snapshot::saveSnapshot(QGLWidget* widget, QString username, glm::vec3 location) { - QImage shot = widget->grabFrameBuffer(); +const QString LOCATION_X = "location-x"; +const QString LOCATION_Y = "location-y"; +const QString LOCATION_Z = "location-z"; +const QString ORIENTATION_X = "orientation-x"; +const QString ORIENTATION_Y = "orientation-y"; +const QString ORIENTATION_Z = "orientation-z"; +const QString ORIENTATION_W = "orientation-w"; + +const QString DOMAIN_KEY = "domain"; + + +SnapshotMetaData* Snapshot::parseSnapshotData(QString snapshotPath) { + + if (!QFile(snapshotPath).exists()) { + return NULL; + } + + QImage shot(snapshotPath); + + // no location data stored + if (shot.text(LOCATION_X).isEmpty() || shot.text(LOCATION_Y).isEmpty() || shot.text(LOCATION_Z).isEmpty()) { + return NULL; + } + + SnapshotMetaData* data = new SnapshotMetaData(); + data->setLocation(glm::vec3(shot.text(LOCATION_X).toFloat(), + shot.text(LOCATION_Y).toFloat(), + shot.text(LOCATION_Z).toFloat())); + + data->setOrientation(glm::quat(shot.text(ORIENTATION_X).toFloat(), + shot.text(ORIENTATION_Y).toFloat(), + shot.text(ORIENTATION_Z).toFloat(), + shot.text(ORIENTATION_W).toFloat())); + + data->setDomain(shot.text(DOMAIN_KEY)); + + return data; +} + +void Snapshot::saveSnapshot(QGLWidget* widget, Profile* profile, MyAvatar* avatar) { + QImage shot = widget->grabFrameBuffer(); + + glm::vec3 location = avatar->getPosition(); + glm::quat orientation = avatar->getHead().getOrientation(); + // add metadata - shot.setText("location-x", QString::number(location.x)); - shot.setText("location-y", QString::number(location.y)); - shot.setText("location-z", QString::number(location.z)); + shot.setText(LOCATION_X, QString::number(location.x)); + shot.setText(LOCATION_Y, QString::number(location.y)); + shot.setText(LOCATION_Z, QString::number(location.z)); + + shot.setText(ORIENTATION_X, QString::number(orientation.x)); + shot.setText(ORIENTATION_Y, QString::number(orientation.y)); + shot.setText(ORIENTATION_Z, QString::number(orientation.z)); + shot.setText(ORIENTATION_W, QString::number(orientation.w)); + + shot.setText(DOMAIN_KEY, profile->getLastDomain()); QString formattedLocation = QString("%1_%2_%3").arg(location.x).arg(location.y).arg(location.z); // replace decimal . with '-' formattedLocation.replace('.', '-'); + QString username = profile->getUsername(); // normalize username, replace all non alphanumeric with '-' username.replace(QRegExp("[^A-Za-z0-9_]"), "-"); diff --git a/interface/src/ui/Snapshot.h b/interface/src/ui/Snapshot.h index 26315678f9..05a2fc3147 100644 --- a/interface/src/ui/Snapshot.h +++ b/interface/src/ui/Snapshot.h @@ -13,15 +13,32 @@ #include #include -#include +#include "avatar/MyAvatar.h" +#include "avatar/Profile.h" + +class SnapshotMetaData { +public: + + QString getDomain() { return _domain; } + void setDomain(QString domain) { _domain = domain; } + + glm::vec3 getLocation() { return _location; } + void setLocation(glm::vec3 location) { _location = location; } + + glm::quat getOrientation() { return _orientation; } + void setOrientation(glm::quat orientation) { _orientation = orientation; } + +private: + QString _domain; + glm::vec3 _location; + glm::quat _orientation;; +}; class Snapshot { public: - static void saveSnapshot(QGLWidget* widget, QString username, glm::vec3 location); - -private: - QString _username; + static void saveSnapshot(QGLWidget* widget, Profile* profile, MyAvatar* avatar); + static SnapshotMetaData* parseSnapshotData(QString snapshotPath); }; #endif /* defined(__hifi__Snapshot__) */ diff --git a/libraries/shared/src/NodeList.cpp b/libraries/shared/src/NodeList.cpp index c0bc7f0010..8dd3857198 100644 --- a/libraries/shared/src/NodeList.cpp +++ b/libraries/shared/src/NodeList.cpp @@ -807,7 +807,8 @@ void NodeList::loadData(QSettings *settings) { } else { _domainHostname = DEFAULT_DOMAIN_HOSTNAME; } - + + emit domainChanged(_domainHostname); settings->endGroup(); } From a9b415b0f9dc309677109cf792ede2e6a81d1a01 Mon Sep 17 00:00:00 2001 From: Andrzej Kapolka Date: Tue, 11 Feb 2014 17:22:40 -0800 Subject: [PATCH 05/39] More build settings. --- cmake/modules/FindVisage.cmake | 10 +++++++--- interface/CMakeLists.txt | 5 +++-- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/cmake/modules/FindVisage.cmake b/cmake/modules/FindVisage.cmake index 600164908c..0b5ac5f563 100644 --- a/cmake/modules/FindVisage.cmake +++ b/cmake/modules/FindVisage.cmake @@ -19,10 +19,14 @@ else (VISAGE_LIBRARIES AND VISAGE_INCLUDE_DIRS) find_path(VISAGE_INCLUDE_DIR VisageTracker2.h ${VISAGE_ROOT_DIR}/include) if (APPLE) + find_path(VISAGE_XML_INCLUDE_DIR libxml/xmlreader.h /usr/include/libxml2) find_path(VISAGE_OPENCV_INCLUDE_DIR cv.h ${VISAGE_ROOT_DIR}/dependencies/OpenCV_MacOSX/include) - if (VISAGE_INCLUDE_DIR AND VISAGE_OPENCV_INCLUDE_DIR) - set(VISAGE_INCLUDE_DIRS "${VISAGE_INCLUDE_DIR};${VISAGE_OPENCV_INCLUDE_DIR}" CACHE INTERNAL "Visage include dirs") - endif (VISAGE_INCLUDE_DIR AND VISAGE_OPENCV_INCLUDE_DIR) + find_path(VISAGE_OPENCV2_INCLUDE_DIR cv.h ${VISAGE_ROOT_DIR}/dependencies/OpenCV_MacOSX/include/opencv2) + if (VISAGE_INCLUDE_DIR AND VISAGE_XML_INCLUDE_DIR AND VISAGE_OPENCV_INCLUDE_DIR AND VISAGE_OPENCV2_INCLUDE_DIR) + set(VISAGE_INCLUDE_DIRS + "${VISAGE_INCLUDE_DIR};${VISAGE_XML_INCLUDE_DIR};${VISAGE_OPENCV_INCLUDE_DIR};${VISAGE_OPENCV2_INCLUDE_DIR}" + CACHE INTERNAL "Visage include dirs") + endif (VISAGE_INCLUDE_DIR AND VISAGE_XML_INCLUDE_DIR AND VISAGE_OPENCV_INCLUDE_DIR AND VISAGE_OPENCV2_INCLUDE_DIR) find_library(VISAGE_CORE_LIBRARY libvscore.a ${VISAGE_ROOT_DIR}/lib) find_library(VISAGE_VISION_LIBRARY libvsvision.a ${VISAGE_ROOT_DIR}/lib) diff --git a/interface/CMakeLists.txt b/interface/CMakeLists.txt index 188e7a6995..81170b0a57 100644 --- a/interface/CMakeLists.txt +++ b/interface/CMakeLists.txt @@ -148,10 +148,11 @@ endif (SIXENSE_FOUND AND NOT DISABLE_SIXENSE) # likewise with Visage library for webcam feature tracking if (VISAGE_FOUND AND NOT DISABLE_VISAGE) - add_definitions(-DHAVE_VISAGE) + add_definitions(-DHAVE_VISAGE -DVISAGE_STATIC) include_directories(SYSTEM ${VISAGE_INCLUDE_DIRS}) if (APPLE OR UNIX) - SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -isystem ${VISAGE_INCLUDE_DIRS}") + add_definitions(_DMAC_OS_X) + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-comment -isystem ${VISAGE_INCLUDE_DIRS}") endif (APPLE OR UNIX) target_link_libraries(${TARGET_NAME} ${VISAGE_LIBRARIES}) endif (VISAGE_FOUND AND NOT DISABLE_VISAGE) From 87f7e2465fd5bbbdd9fa399627c5d171e547607f Mon Sep 17 00:00:00 2001 From: Andrzej Kapolka Date: Tue, 11 Feb 2014 17:25:25 -0800 Subject: [PATCH 06/39] Missed a spot. --- cmake/modules/FindVisage.cmake | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/cmake/modules/FindVisage.cmake b/cmake/modules/FindVisage.cmake index 0b5ac5f563..4c600755cd 100644 --- a/cmake/modules/FindVisage.cmake +++ b/cmake/modules/FindVisage.cmake @@ -21,7 +21,7 @@ else (VISAGE_LIBRARIES AND VISAGE_INCLUDE_DIRS) if (APPLE) find_path(VISAGE_XML_INCLUDE_DIR libxml/xmlreader.h /usr/include/libxml2) find_path(VISAGE_OPENCV_INCLUDE_DIR cv.h ${VISAGE_ROOT_DIR}/dependencies/OpenCV_MacOSX/include) - find_path(VISAGE_OPENCV2_INCLUDE_DIR cv.h ${VISAGE_ROOT_DIR}/dependencies/OpenCV_MacOSX/include/opencv2) + find_path(VISAGE_OPENCV2_INCLUDE_DIR opencv.hpp ${VISAGE_ROOT_DIR}/dependencies/OpenCV_MacOSX/include/opencv2) if (VISAGE_INCLUDE_DIR AND VISAGE_XML_INCLUDE_DIR AND VISAGE_OPENCV_INCLUDE_DIR AND VISAGE_OPENCV2_INCLUDE_DIR) set(VISAGE_INCLUDE_DIRS "${VISAGE_INCLUDE_DIR};${VISAGE_XML_INCLUDE_DIR};${VISAGE_OPENCV_INCLUDE_DIR};${VISAGE_OPENCV2_INCLUDE_DIR}" @@ -37,10 +37,14 @@ else (VISAGE_LIBRARIES AND VISAGE_INCLUDE_DIRS) endif (VISAGE_CORE_LIBRARY AND VISAGE_VISION_LIBRARY AND VISAGE_OPENCV_LIBRARY) elseif (WIN32) + find_path(VISAGE_XML_INCLUDE_DIR libxml/xmlreader.h /usr/include/libxml2) find_path(VISAGE_OPENCV_INCLUDE_DIR cv.h ${VISAGE_ROOT_DIR}/dependencies/OpenCV_Win32/include) - if (VISAGE_INCLUDE_DIR AND VISAGE_OPENCV_INCLUDE_DIR) - set(VISAGE_INCLUDE_DIRS "${VISAGE_INCLUDE_DIR};${VISAGE_OPENCV_INCLUDE_DIR}" CACHE INTERNAL "Visage include dirs") - endif (VISAGE_INCLUDE_DIR AND VISAGE_OPENCV_INCLUDE_DIR) + find_path(VISAGE_OPENCV2_INCLUDE_DIR opencv.hpp ${VISAGE_ROOT_DIR}/dependencies/OpenCV_Win32/include/opencv2) + if (VISAGE_INCLUDE_DIR AND VISAGE_XML_INCLUDE_DIR AND VISAGE_OPENCV_INCLUDE_DIR AND VISAGE_OPENCV2_INCLUDE_DIR) + set(VISAGE_INCLUDE_DIRS + "${VISAGE_INCLUDE_DIR};${VISAGE_XML_INCLUDE_DIR};${VISAGE_OPENCV_INCLUDE_DIR};${VISAGE_OPENCV2_INCLUDE_DIR}" + CACHE INTERNAL "Visage include dirs") + endif (VISAGE_INCLUDE_DIR AND VISAGE_XML_INCLUDE_DIR AND VISAGE_OPENCV_INCLUDE_DIR AND VISAGE_OPENCV2_INCLUDE_DIR) find_library(VISAGE_CORE_LIBRARY vscore.lib ${VISAGE_ROOT_DIR}/lib) find_library(VISAGE_VISION_LIBRARY vsvision.lib ${VISAGE_ROOT_DIR}/lib) From c07801261415bee79711ddb97ba4ef69b2fb245b Mon Sep 17 00:00:00 2001 From: Andrzej Kapolka Date: Tue, 11 Feb 2014 17:26:31 -0800 Subject: [PATCH 07/39] Sniffing glue, wrong day, etc. --- interface/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/interface/CMakeLists.txt b/interface/CMakeLists.txt index 81170b0a57..e000efa695 100644 --- a/interface/CMakeLists.txt +++ b/interface/CMakeLists.txt @@ -151,7 +151,7 @@ if (VISAGE_FOUND AND NOT DISABLE_VISAGE) add_definitions(-DHAVE_VISAGE -DVISAGE_STATIC) include_directories(SYSTEM ${VISAGE_INCLUDE_DIRS}) if (APPLE OR UNIX) - add_definitions(_DMAC_OS_X) + add_definitions(-DMAC_OS_X) SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-comment -isystem ${VISAGE_INCLUDE_DIRS}") endif (APPLE OR UNIX) target_link_libraries(${TARGET_NAME} ${VISAGE_LIBRARIES}) From 8206f8d2b3ef4f972aaa8abc8732dda697678ea2 Mon Sep 17 00:00:00 2001 From: Andrzej Kapolka Date: Tue, 11 Feb 2014 19:00:41 -0800 Subject: [PATCH 08/39] Fixes for Windows. Compiles, but the license doesn't work yet. --- cmake/modules/FindVisage.cmake | 8 ++++---- interface/src/devices/Visage.cpp | 12 ++++++++---- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/cmake/modules/FindVisage.cmake b/cmake/modules/FindVisage.cmake index 4c600755cd..84f672525d 100644 --- a/cmake/modules/FindVisage.cmake +++ b/cmake/modules/FindVisage.cmake @@ -37,9 +37,9 @@ else (VISAGE_LIBRARIES AND VISAGE_INCLUDE_DIRS) endif (VISAGE_CORE_LIBRARY AND VISAGE_VISION_LIBRARY AND VISAGE_OPENCV_LIBRARY) elseif (WIN32) - find_path(VISAGE_XML_INCLUDE_DIR libxml/xmlreader.h /usr/include/libxml2) - find_path(VISAGE_OPENCV_INCLUDE_DIR cv.h ${VISAGE_ROOT_DIR}/dependencies/OpenCV_Win32/include) - find_path(VISAGE_OPENCV2_INCLUDE_DIR opencv.hpp ${VISAGE_ROOT_DIR}/dependencies/OpenCV_Win32/include/opencv2) + find_path(VISAGE_XML_INCLUDE_DIR libxml/xmlreader.h ${VISAGE_ROOT_DIR}/dependencies/libxml2/include) + find_path(VISAGE_OPENCV_INCLUDE_DIR opencv/cv.h ${VISAGE_ROOT_DIR}/dependencies/OpenCV/include) + find_path(VISAGE_OPENCV2_INCLUDE_DIR cv.h ${VISAGE_ROOT_DIR}/dependencies/OpenCV/include/opencv) if (VISAGE_INCLUDE_DIR AND VISAGE_XML_INCLUDE_DIR AND VISAGE_OPENCV_INCLUDE_DIR AND VISAGE_OPENCV2_INCLUDE_DIR) set(VISAGE_INCLUDE_DIRS "${VISAGE_INCLUDE_DIR};${VISAGE_XML_INCLUDE_DIR};${VISAGE_OPENCV_INCLUDE_DIR};${VISAGE_OPENCV2_INCLUDE_DIR}" @@ -48,7 +48,7 @@ else (VISAGE_LIBRARIES AND VISAGE_INCLUDE_DIRS) find_library(VISAGE_CORE_LIBRARY vscore.lib ${VISAGE_ROOT_DIR}/lib) find_library(VISAGE_VISION_LIBRARY vsvision.lib ${VISAGE_ROOT_DIR}/lib) - find_library(VISAGE_OPENCV_LIBRARY OpenCV.lib ${VISAGE_ROOT_DIR}/dependencies/OpenCV_Win32/lib) + find_library(VISAGE_OPENCV_LIBRARY opencv_core243.lib ${VISAGE_ROOT_DIR}/dependencies/OpenCV/lib) if (VISAGE_CORE_LIBRARY AND VISAGE_VISION_LIBRARY AND VISAGE_OPENCV_LIBRARY) set(VISAGE_LIBRARIES "${VISAGE_CORE_LIBRARY};${VISAGE_VISION_LIBRARY};${VISAGE_OPENCV_LIBRARY}" CACHE INTERNAL "Visage libraries") diff --git a/interface/src/devices/Visage.cpp b/interface/src/devices/Visage.cpp index 4b986d7db4..f69121bf7f 100644 --- a/interface/src/devices/Visage.cpp +++ b/interface/src/devices/Visage.cpp @@ -6,16 +6,20 @@ // Copyright (c) 2014 High Fidelity, Inc. All rights reserved. // +#include + #ifdef HAVE_VISAGE #include #endif -#include - #include "Visage.h" namespace VisageSDK { - void initializeLicenseManager(char* licenseKeyFileName); +#ifdef WIN32 + void __declspec(dllimport) initializeLicenseManager(char* licenseKeyFileName); +#else + void initializeLicenseManager(char* licenseKeyFileName); +#endif } using namespace VisageSDK; @@ -23,7 +27,7 @@ using namespace VisageSDK; Visage::Visage() { #ifdef HAVE_VISAGE switchToResourcesParentIfRequired(); - initializeLicenseManager("resources/visage/license.vlc"); + initializeLicenseManager("resources/visage"); _tracker = new VisageTracker2("resources/visage/Facial Features Tracker - Asymmetric.cfg"); _tracker->trackFromCam(); #endif From 0244ead5dfc09b9ab7e5bdc11bc91fa0d55379c3 Mon Sep 17 00:00:00 2001 From: stojce Date: Wed, 12 Feb 2014 21:06:30 +0100 Subject: [PATCH 09/39] fixed glm::quat initialization --- interface/src/ui/Snapshot.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/interface/src/ui/Snapshot.cpp b/interface/src/ui/Snapshot.cpp index 33d2087594..bd4de19c86 100644 --- a/interface/src/ui/Snapshot.cpp +++ b/interface/src/ui/Snapshot.cpp @@ -53,10 +53,10 @@ SnapshotMetaData* Snapshot::parseSnapshotData(QString snapshotPath) { shot.text(LOCATION_Y).toFloat(), shot.text(LOCATION_Z).toFloat())); - data->setOrientation(glm::quat(shot.text(ORIENTATION_X).toFloat(), + data->setOrientation(glm::quat(shot.text(ORIENTATION_W).toFloat(), + shot.text(ORIENTATION_X).toFloat(), shot.text(ORIENTATION_Y).toFloat(), - shot.text(ORIENTATION_Z).toFloat(), - shot.text(ORIENTATION_W).toFloat())); + shot.text(ORIENTATION_Z).toFloat())); data->setDomain(shot.text(DOMAIN_KEY)); From 08c8f47cd4cb2b2b9fa7cf2776ea64cd126c133a Mon Sep 17 00:00:00 2001 From: stojce Date: Thu, 13 Feb 2014 20:05:59 +0100 Subject: [PATCH 10/39] added SNAPSHOT_EXTENSION constant --- interface/src/Application.cpp | 2 +- interface/src/Application.h | 2 ++ interface/src/GLCanvas.cpp | 2 +- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index eaaea9c5be..4ede4a9405 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -1384,7 +1384,7 @@ void Application::dropEvent(QDropEvent *event) { QString snapshotPath; const QMimeData *mimeData = event->mimeData(); foreach (QUrl url, mimeData->urls()) { - if (url.url().toLower().endsWith("jpg")) { + if (url.url().toLower().endsWith(SNAPSHOT_EXTENSION)) { snapshotPath = url.url().remove("file://"); break; } diff --git a/interface/src/Application.h b/interface/src/Application.h index 9508c0c9a5..54a804ab72 100644 --- a/interface/src/Application.h +++ b/interface/src/Application.h @@ -93,6 +93,8 @@ static const float NODE_KILLED_RED = 1.0f; static const float NODE_KILLED_GREEN = 0.0f; static const float NODE_KILLED_BLUE = 0.0f; +static const QString SNAPSHOT_EXTENSION = ".jpg"; + class Application : public QApplication { Q_OBJECT diff --git a/interface/src/GLCanvas.cpp b/interface/src/GLCanvas.cpp index cfff3b8696..7bc79e56d8 100644 --- a/interface/src/GLCanvas.cpp +++ b/interface/src/GLCanvas.cpp @@ -75,7 +75,7 @@ void GLCanvas::wheelEvent(QWheelEvent* event) { void GLCanvas::dragEnterEvent(QDragEnterEvent* event) { const QMimeData *mimeData = event->mimeData(); foreach (QUrl url, mimeData->urls()) { - if (url.url().toLower().endsWith("jpg")) { + if (url.url().toLower().endsWith(SNAPSHOT_EXTENSION)) { event->acceptProposedAction(); break; } From 861ae12151c93f69293a49e50d5eea098b378154 Mon Sep 17 00:00:00 2001 From: Andrzej Kapolka Date: Thu, 13 Feb 2014 16:53:17 -0800 Subject: [PATCH 11/39] Added Visage stuff to .gitignore. --- .gitignore | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.gitignore b/.gitignore index 62686287bc..087e24208d 100644 --- a/.gitignore +++ b/.gitignore @@ -39,5 +39,11 @@ interface/external/Leap/util/ interface/external/Sixense/include/ interface/external/Sixense/lib/ +# Ignore Visage +interface/external/visage/dependencies/ +interface/external/visage/include/ +interface/external/visage/lib/ +interface/resources/visage/ + # Ignore interfaceCache for Linux users interface/interfaceCache/ From 58e773340abc7645105fa368ffc9d1df9193ff0d Mon Sep 17 00:00:00 2001 From: gaitat Date: Fri, 14 Feb 2014 09:40:59 -0500 Subject: [PATCH 12/39] Worklist Job #19503 Exposing the average audio intensity to javascript through the MyAvatar object. --- examples/audioBall.js | 78 ++++++++++++++++++++++++++++++ examples/audioBallLifetime.js | 62 ++++++++++++++++++++++++ interface/src/Audio.h | 2 + interface/src/avatar/MyAvatar.cpp | 6 ++- libraries/avatars/src/AvatarData.h | 8 ++- libraries/avatars/src/HeadData.h | 11 +++-- 6 files changed, 161 insertions(+), 6 deletions(-) create mode 100644 examples/audioBall.js create mode 100644 examples/audioBallLifetime.js diff --git a/examples/audioBall.js b/examples/audioBall.js new file mode 100644 index 0000000000..b2761a3dd3 --- /dev/null +++ b/examples/audioBall.js @@ -0,0 +1,78 @@ +// +// audioBall.js +// hifi +// +// Created by Athanasios Gaitatzes on 2/10/14. +// Copyright (c) 2014 HighFidelity, Inc. All rights reserved. +// +// This script creates a particle in front of the user that stays in front of +// the user's avatar as they move, and animates it's radius and color +// in response to the audio intensity. +// + +// add two vectors +function vPlus(a, b) { + var rval = { x: a.x + b.x, y: a.y + b.y, z: a.z + b.z }; + return rval; +} + +// multiply scalar with vector +function vsMult(s, v) { + var rval = { x: s * v.x, y: s * v.y, z: s * v.z }; + return rval; +} + +var sound = new Sound("https://s3-us-west-1.amazonaws.com/highfidelity-public/sounds/Animals/mexicanWhipoorwill.raw"); +var FACTOR = 0.20; + +var countParticles = 0; // the first time around we want to create the particle and thereafter to modify it. +var particleID; + +function updateParticle() +{ + // the particle should be placed in front of the user's avatar + var avatarFront = Quat.getFront(MyAvatar.orientation); + + // move particle three units in front of the avatar + var particlePosition = vPlus(MyAvatar.position, vsMult (3, avatarFront)); + + // play a sound at the location of the particle + var options = new AudioInjectionOptions(); + options.position = particlePosition; + options.volume = 0.75; + Audio.playSound(sound, options); + + var audioCardAverageLoudness = MyAvatar.audioCardAverageLoudness * FACTOR; + + if (countParticles < 1) + { + var particleProperies = { + position: particlePosition // the particle should stay in front of the user's avatar as he moves + , color: { red: 0, green: 255, blue: 0 } + , radius: audioCardAverageLoudness + , velocity: { x: 0.0, y: 0.0, z: 0.0 } + , gravity: { x: 0.0, y: 0.0, z: 0.0 } + , damping: 0.0 + } + + particleID = Particles.addParticle (particleProperies); + countParticles++; + } + else + { + // animates the particles radius and color in response to the changing audio intensity + var newProperties = { + position: particlePosition // the particle should stay in front of the user's avatar as he moves + , color: { red: 0, green: 255 * audioCardAverageLoudness, blue: 0 } + , radius: audioCardAverageLoudness + }; + + Particles.editParticle (particleID, newProperties); + } +} + +// register the call back so it fires before each data send +Script.willSendVisualDataCallback.connect(updateParticle); + +// register our scriptEnding callback +Script.scriptEnding.connect(function scriptEnding() {}); diff --git a/examples/audioBallLifetime.js b/examples/audioBallLifetime.js new file mode 100644 index 0000000000..7df4a0cdad --- /dev/null +++ b/examples/audioBallLifetime.js @@ -0,0 +1,62 @@ +// +// audioBall.js +// hifi +// +// Created by Athanasios Gaitatzes on 2/10/14. +// Copyright (c) 2014 HighFidelity, Inc. All rights reserved. +// +// This script creates a particle in front of the user that stays in front of +// the user's avatar as they move, and animates it's radius and color +// in response to the audio intensity. +// + +// add two vectors +function vPlus(a, b) { + var rval = { x: a.x + b.x, y: a.y + b.y, z: a.z + b.z }; + return rval; +} + +// multiply scalar with vector +function vsMult(s, v) { + var rval = { x: s * v.x, y: s * v.y, z: s * v.z }; + return rval; +} + +var sound = new Sound("https://s3-us-west-1.amazonaws.com/highfidelity-public/sounds/Animals/mexicanWhipoorwill.raw"); +var FACTOR = 0.20; + +function addParticle() +{ + // the particle should be placed in front of the user's avatar + var avatarFront = Quat.getFront(MyAvatar.orientation); + + // move particle three units in front of the avatar + var particlePosition = vPlus(MyAvatar.position, vsMult (3, avatarFront)); + + // play a sound at the location of the particle + var options = new AudioInjectionOptions(); + options.position = particlePosition; + options.volume = 0.25; + Audio.playSound(sound, options); + + var audioCardAverageLoudness = MyAvatar.audioCardAverageLoudness * FACTOR; + + // animates the particles radius and color in response to the changing audio intensity + var particleProperies = { + position: particlePosition // the particle should stay in front of the user's avatar as he moves + , color: { red: 0, green: 255 * audioCardAverageLoudness, blue: 0 } + , radius: audioCardAverageLoudness + , velocity: { x: 0.0, y: 0.0, z: 0.0 } + , gravity: { x: 0.0, y: 0.0, z: 0.0 } + , damping: 0.0 + , lifetime: 0.05 + } + + Particles.addParticle (particleProperies); +} + +// register the call back so it fires before each data send +Script.willSendVisualDataCallback.connect(addParticle); + +// register our scriptEnding callback +Script.scriptEnding.connect(function scriptEnding() {}); diff --git a/interface/src/Audio.h b/interface/src/Audio.h index 88e2731006..a356d93425 100644 --- a/interface/src/Audio.h +++ b/interface/src/Audio.h @@ -47,6 +47,8 @@ public: float getLastInputLoudness() const { return glm::max(_lastInputLoudness - _averageInputLoudness, 0.f); } + float getAudioCardAverageInputLoudness() const { return _averageInputLoudness; } // saki + void setNoiseGateEnabled(bool noiseGateEnabled) { _noiseGateEnabled = noiseGateEnabled; } void setLastAcceleration(const glm::vec3 lastAcceleration) { _lastAcceleration = lastAcceleration; } diff --git a/interface/src/avatar/MyAvatar.cpp b/interface/src/avatar/MyAvatar.cpp index 5628740770..f4570dca45 100644 --- a/interface/src/avatar/MyAvatar.cpp +++ b/interface/src/avatar/MyAvatar.cpp @@ -157,7 +157,9 @@ void MyAvatar::update(float deltaTime) { } // Get audio loudness data from audio input device - _head.setAudioLoudness(Application::getInstance()->getAudio()->getLastInputLoudness()); + Audio *audio = Application::getInstance()->getAudio(); + _head.setAudioLoudness(audio->getLastInputLoudness()); + _head.setAudioCardAverageLoudness(audio->getAudioCardAverageInputLoudness()); // saki if (Menu::getInstance()->isOptionChecked(MenuOption::Gravity)) { setGravity(Application::getInstance()->getEnvironment()->getGravity(getPosition())); @@ -639,7 +641,7 @@ void MyAvatar::loadData(QSettings* settings) { _position.y = loadSetting(settings, "position_y", 0.0f); _position.z = loadSetting(settings, "position_z", 0.0f); - _head.setPupilDilation(settings->value("pupilDilation", 0.0f).toFloat()); + _head.setPupilDilation(loadSetting(settings, "pupilDilation", 0.0f)); _leanScale = loadSetting(settings, "leanScale", 0.05f); _targetScale = loadSetting(settings, "scale", 1.0f); diff --git a/libraries/avatars/src/AvatarData.h b/libraries/avatars/src/AvatarData.h index 46d92c0f2e..65f2a318e7 100755 --- a/libraries/avatars/src/AvatarData.h +++ b/libraries/avatars/src/AvatarData.h @@ -75,7 +75,9 @@ class AvatarData : public NodeData { Q_PROPERTY(glm::quat orientation READ getOrientation WRITE setOrientation) Q_PROPERTY(float headPitch READ getHeadPitch WRITE setHeadPitch) - + + Q_PROPERTY(float audioCardAverageLoudness READ getAudioCardAverageLoudness WRITE setAudioCardAverageLoudness) // saki + Q_PROPERTY(QUrl faceModelURL READ getFaceModelURL WRITE setFaceModelURL) Q_PROPERTY(QUrl skeletonModelURL READ getSkeletonModelURL WRITE setSkeletonModelURL) public: @@ -106,6 +108,10 @@ public: float getHeadPitch() const { return _headData->getPitch(); } void setHeadPitch(float value) { _headData->setPitch(value); }; + // access to Head().set/getAverageLoudness + float getAudioCardAverageLoudness() const { return _headData->getAudioCardAverageLoudness(); } // saki + void setAudioCardAverageLoudness(float value) { _headData->setAudioCardAverageLoudness(value); }; // saki + // Scale float getTargetScale() const { return _targetScale; } void setTargetScale(float targetScale) { _targetScale = targetScale; } diff --git a/libraries/avatars/src/HeadData.h b/libraries/avatars/src/HeadData.h index fde684bbf1..477a790f93 100644 --- a/libraries/avatars/src/HeadData.h +++ b/libraries/avatars/src/HeadData.h @@ -41,9 +41,13 @@ public: float getRoll() const { return _roll; } void setRoll(float roll) { _roll = glm::clamp(roll, MIN_HEAD_ROLL, MAX_HEAD_ROLL); } - - void setAudioLoudness(float audioLoudness) { _audioLoudness = audioLoudness; } - + + float getAudioLoudness() const { return _audioLoudness; } + void setAudioLoudness(float audioLoudness) { _audioLoudness = audioLoudness; } + + float getAudioCardAverageLoudness() const { return _audioCardAverageLoudness; } // saki + void setAudioCardAverageLoudness(float audioCardAverageLoudness) { _audioCardAverageLoudness = audioCardAverageLoudness; } // saki + const std::vector& getBlendshapeCoefficients() const { return _blendshapeCoefficients; } float getPupilDilation() const { return _pupilDilation; } @@ -79,6 +83,7 @@ protected: float _rightEyeBlink; float _averageLoudness; float _browAudioLift; + float _audioCardAverageLoudness; // saki std::vector _blendshapeCoefficients; float _pupilDilation; AvatarData* _owningAvatar; From fcd44f58176580db7506f5229ee3c40b819ac0e9 Mon Sep 17 00:00:00 2001 From: gaitat Date: Sat, 15 Feb 2014 08:16:05 -0500 Subject: [PATCH 13/39] Fix for Worklist Job #19503 --- examples/audioBall.js | 11 ++++++----- examples/audioBallLifetime.js | 9 +++++---- interface/src/Audio.h | 3 +-- interface/src/avatar/MyAvatar.cpp | 2 +- libraries/avatars/src/AvatarData.h | 9 ++++++--- libraries/avatars/src/HeadData.h | 6 +++--- 6 files changed, 22 insertions(+), 18 deletions(-) diff --git a/examples/audioBall.js b/examples/audioBall.js index b2761a3dd3..cfa08ef3a2 100644 --- a/examples/audioBall.js +++ b/examples/audioBall.js @@ -23,7 +23,7 @@ function vsMult(s, v) { } var sound = new Sound("https://s3-us-west-1.amazonaws.com/highfidelity-public/sounds/Animals/mexicanWhipoorwill.raw"); -var FACTOR = 0.20; +var FACTOR = 0.75; var countParticles = 0; // the first time around we want to create the particle and thereafter to modify it. var particleID; @@ -42,14 +42,15 @@ function updateParticle() options.volume = 0.75; Audio.playSound(sound, options); - var audioCardAverageLoudness = MyAvatar.audioCardAverageLoudness * FACTOR; + var audioAverageLoudness = MyAvatar.audioAverageLoudness * FACTOR; + //print ("Audio Loudness = " + MyAvatar.audioLoudness + " -- Audio Average Loudness = " + MyAvatar.audioAverageLoudness); if (countParticles < 1) { var particleProperies = { position: particlePosition // the particle should stay in front of the user's avatar as he moves , color: { red: 0, green: 255, blue: 0 } - , radius: audioCardAverageLoudness + , radius: audioAverageLoudness , velocity: { x: 0.0, y: 0.0, z: 0.0 } , gravity: { x: 0.0, y: 0.0, z: 0.0 } , damping: 0.0 @@ -63,8 +64,8 @@ function updateParticle() // animates the particles radius and color in response to the changing audio intensity var newProperties = { position: particlePosition // the particle should stay in front of the user's avatar as he moves - , color: { red: 0, green: 255 * audioCardAverageLoudness, blue: 0 } - , radius: audioCardAverageLoudness + , color: { red: 0, green: 255 * audioAverageLoudness, blue: 0 } + , radius: audioAverageLoudness }; Particles.editParticle (particleID, newProperties); diff --git a/examples/audioBallLifetime.js b/examples/audioBallLifetime.js index 7df4a0cdad..da15ec7421 100644 --- a/examples/audioBallLifetime.js +++ b/examples/audioBallLifetime.js @@ -23,7 +23,7 @@ function vsMult(s, v) { } var sound = new Sound("https://s3-us-west-1.amazonaws.com/highfidelity-public/sounds/Animals/mexicanWhipoorwill.raw"); -var FACTOR = 0.20; +var FACTOR = 0.75; function addParticle() { @@ -39,13 +39,14 @@ function addParticle() options.volume = 0.25; Audio.playSound(sound, options); - var audioCardAverageLoudness = MyAvatar.audioCardAverageLoudness * FACTOR; + var audioAverageLoudness = MyAvatar.audioAverageLoudness * FACTOR; + //print ("Audio Loudness = " + MyAvatar.audioLoudness + " -- Audio Average Loudness = " + MyAvatar.audioAverageLoudness); // animates the particles radius and color in response to the changing audio intensity var particleProperies = { position: particlePosition // the particle should stay in front of the user's avatar as he moves - , color: { red: 0, green: 255 * audioCardAverageLoudness, blue: 0 } - , radius: audioCardAverageLoudness + , color: { red: 0, green: 255 * audioAverageLoudness, blue: 0 } + , radius: audioAverageLoudness , velocity: { x: 0.0, y: 0.0, z: 0.0 } , gravity: { x: 0.0, y: 0.0, z: 0.0 } , damping: 0.0 diff --git a/interface/src/Audio.h b/interface/src/Audio.h index 3b54a02f4e..fd77cfb3b8 100644 --- a/interface/src/Audio.h +++ b/interface/src/Audio.h @@ -46,8 +46,7 @@ public: void render(int screenWidth, int screenHeight); float getLastInputLoudness() const { return glm::max(_lastInputLoudness - _noiseGateMeasuredFloor, 0.f); } - - float getAudioCardAverageInputLoudness() const { return _averageInputLoudness; } // saki + float getAudioAverageInputLoudness() const { return _lastInputLoudness; } void setNoiseGateEnabled(bool noiseGateEnabled) { _noiseGateEnabled = noiseGateEnabled; } diff --git a/interface/src/avatar/MyAvatar.cpp b/interface/src/avatar/MyAvatar.cpp index 971d93ced8..b38d970011 100644 --- a/interface/src/avatar/MyAvatar.cpp +++ b/interface/src/avatar/MyAvatar.cpp @@ -143,7 +143,7 @@ void MyAvatar::update(float deltaTime) { // Get audio loudness data from audio input device Audio *audio = Application::getInstance()->getAudio(); _head.setAudioLoudness(audio->getLastInputLoudness()); - _head.setAudioCardAverageLoudness(audio->getAudioCardAverageInputLoudness()); // saki + _head.setAudioAverageLoudness(audio->getAudioAverageInputLoudness()); if (Menu::getInstance()->isOptionChecked(MenuOption::Gravity)) { setGravity(Application::getInstance()->getEnvironment()->getGravity(getPosition())); diff --git a/libraries/avatars/src/AvatarData.h b/libraries/avatars/src/AvatarData.h index a141929d44..796d60abd9 100755 --- a/libraries/avatars/src/AvatarData.h +++ b/libraries/avatars/src/AvatarData.h @@ -77,7 +77,8 @@ class AvatarData : public NodeData { Q_PROPERTY(glm::quat orientation READ getOrientation WRITE setOrientation) Q_PROPERTY(float headPitch READ getHeadPitch WRITE setHeadPitch) - Q_PROPERTY(float audioCardAverageLoudness READ getAudioCardAverageLoudness WRITE setAudioCardAverageLoudness) // saki + Q_PROPERTY(float audioLoudness READ getAudioLoudness WRITE setAudioLoudness) + Q_PROPERTY(float audioAverageLoudness READ getAudioAverageLoudness WRITE setAudioAverageLoudness) Q_PROPERTY(QUrl faceModelURL READ getFaceModelURL WRITE setFaceModelURL) Q_PROPERTY(QUrl skeletonModelURL READ getSkeletonModelURL WRITE setSkeletonModelURL) @@ -110,8 +111,10 @@ public: void setHeadPitch(float value) { _headData->setPitch(value); }; // access to Head().set/getAverageLoudness - float getAudioCardAverageLoudness() const { return _headData->getAudioCardAverageLoudness(); } // saki - void setAudioCardAverageLoudness(float value) { _headData->setAudioCardAverageLoudness(value); }; // saki + float getAudioLoudness() const { return _headData->getAudioLoudness(); } + void setAudioLoudness(float value) { _headData->setAudioLoudness(value); } + float getAudioAverageLoudness() const { return _headData->getAudioAverageLoudness(); } + void setAudioAverageLoudness(float value) { _headData->setAudioAverageLoudness(value); } // Scale float getTargetScale() const { return _targetScale; } diff --git a/libraries/avatars/src/HeadData.h b/libraries/avatars/src/HeadData.h index 5c4ac4c067..5b95d84d7b 100644 --- a/libraries/avatars/src/HeadData.h +++ b/libraries/avatars/src/HeadData.h @@ -45,8 +45,8 @@ public: float getAudioLoudness() const { return _audioLoudness; } void setAudioLoudness(float audioLoudness) { _audioLoudness = audioLoudness; } - float getAudioCardAverageLoudness() const { return _audioCardAverageLoudness; } // saki - void setAudioCardAverageLoudness(float audioCardAverageLoudness) { _audioCardAverageLoudness = audioCardAverageLoudness; } // saki + float getAudioAverageLoudness() const { return _audioAverageLoudness; } + void setAudioAverageLoudness(float audioAverageLoudness) { _audioAverageLoudness = audioAverageLoudness; } const std::vector& getBlendshapeCoefficients() const { return _blendshapeCoefficients; } @@ -76,7 +76,7 @@ protected: float _rightEyeBlink; float _averageLoudness; float _browAudioLift; - float _audioCardAverageLoudness; // saki + float _audioAverageLoudness; std::vector _blendshapeCoefficients; float _pupilDilation; AvatarData* _owningAvatar; From e30cf33a03885e902fc7d3dfd52a7cda5baa101e Mon Sep 17 00:00:00 2001 From: gaitat Date: Sat, 15 Feb 2014 23:04:58 -0500 Subject: [PATCH 14/39] Fix for Worklist Job #19503 Formatting errors --- examples/audioBall.js | 27 ++++++--------------------- examples/audioBallLifetime.js | 17 ++--------------- interface/src/avatar/MyAvatar.cpp | 2 +- libraries/avatars/src/HeadData.h | 2 +- 4 files changed, 10 insertions(+), 38 deletions(-) diff --git a/examples/audioBall.js b/examples/audioBall.js index cfa08ef3a2..a0d9423526 100644 --- a/examples/audioBall.js +++ b/examples/audioBall.js @@ -10,31 +10,18 @@ // in response to the audio intensity. // -// add two vectors -function vPlus(a, b) { - var rval = { x: a.x + b.x, y: a.y + b.y, z: a.z + b.z }; - return rval; -} - -// multiply scalar with vector -function vsMult(s, v) { - var rval = { x: s * v.x, y: s * v.y, z: s * v.z }; - return rval; -} - var sound = new Sound("https://s3-us-west-1.amazonaws.com/highfidelity-public/sounds/Animals/mexicanWhipoorwill.raw"); var FACTOR = 0.75; var countParticles = 0; // the first time around we want to create the particle and thereafter to modify it. var particleID; -function updateParticle() -{ +function updateParticle() { // the particle should be placed in front of the user's avatar - var avatarFront = Quat.getFront(MyAvatar.orientation); + var avatarFront = Quat.getFront(MyAvatar.orientation); // move particle three units in front of the avatar - var particlePosition = vPlus(MyAvatar.position, vsMult (3, avatarFront)); + var particlePosition = Vec3.sum(MyAvatar.position, Vec3.multiply(avatarFront, 3)); // play a sound at the location of the particle var options = new AudioInjectionOptions(); @@ -42,11 +29,10 @@ function updateParticle() options.volume = 0.75; Audio.playSound(sound, options); - var audioAverageLoudness = MyAvatar.audioAverageLoudness * FACTOR; + var audioAverageLoudness = MyAvatar.audioAverageLoudness * FACTOR; //print ("Audio Loudness = " + MyAvatar.audioLoudness + " -- Audio Average Loudness = " + MyAvatar.audioAverageLoudness); - if (countParticles < 1) - { + if (countParticles < 1) { var particleProperies = { position: particlePosition // the particle should stay in front of the user's avatar as he moves , color: { red: 0, green: 255, blue: 0 } @@ -59,8 +45,7 @@ function updateParticle() particleID = Particles.addParticle (particleProperies); countParticles++; } - else - { + else { // animates the particles radius and color in response to the changing audio intensity var newProperties = { position: particlePosition // the particle should stay in front of the user's avatar as he moves diff --git a/examples/audioBallLifetime.js b/examples/audioBallLifetime.js index da15ec7421..a7b8a0a749 100644 --- a/examples/audioBallLifetime.js +++ b/examples/audioBallLifetime.js @@ -10,28 +10,15 @@ // in response to the audio intensity. // -// add two vectors -function vPlus(a, b) { - var rval = { x: a.x + b.x, y: a.y + b.y, z: a.z + b.z }; - return rval; -} - -// multiply scalar with vector -function vsMult(s, v) { - var rval = { x: s * v.x, y: s * v.y, z: s * v.z }; - return rval; -} - var sound = new Sound("https://s3-us-west-1.amazonaws.com/highfidelity-public/sounds/Animals/mexicanWhipoorwill.raw"); var FACTOR = 0.75; -function addParticle() -{ +function addParticle() { // the particle should be placed in front of the user's avatar var avatarFront = Quat.getFront(MyAvatar.orientation); // move particle three units in front of the avatar - var particlePosition = vPlus(MyAvatar.position, vsMult (3, avatarFront)); + var particlePosition = Vec3.sum(MyAvatar.position, Vec3.multiply (avatarFront, 3)); // play a sound at the location of the particle var options = new AudioInjectionOptions(); diff --git a/interface/src/avatar/MyAvatar.cpp b/interface/src/avatar/MyAvatar.cpp index b38d970011..a16162112e 100644 --- a/interface/src/avatar/MyAvatar.cpp +++ b/interface/src/avatar/MyAvatar.cpp @@ -141,7 +141,7 @@ void MyAvatar::update(float deltaTime) { } // Get audio loudness data from audio input device - Audio *audio = Application::getInstance()->getAudio(); + Audio* audio = Application::getInstance()->getAudio(); _head.setAudioLoudness(audio->getLastInputLoudness()); _head.setAudioAverageLoudness(audio->getAudioAverageInputLoudness()); diff --git a/libraries/avatars/src/HeadData.h b/libraries/avatars/src/HeadData.h index 5b95d84d7b..04d5fe5b46 100644 --- a/libraries/avatars/src/HeadData.h +++ b/libraries/avatars/src/HeadData.h @@ -76,7 +76,7 @@ protected: float _rightEyeBlink; float _averageLoudness; float _browAudioLift; - float _audioAverageLoudness; + float _audioAverageLoudness; std::vector _blendshapeCoefficients; float _pupilDilation; AvatarData* _owningAvatar; From 03d3a535f827a31e4080a8b4fe85ffefe902401b Mon Sep 17 00:00:00 2001 From: gaitat Date: Sun, 16 Feb 2014 14:50:50 -0500 Subject: [PATCH 15/39] Fix for Worklist Job #19503 Added random sound trigger to the examples --- examples/audioBall.js | 14 +++++++++----- examples/audioBallLifetime.js | 14 +++++++++----- 2 files changed, 18 insertions(+), 10 deletions(-) diff --git a/examples/audioBall.js b/examples/audioBall.js index a0d9423526..676b9118b3 100644 --- a/examples/audioBall.js +++ b/examples/audioBall.js @@ -11,6 +11,8 @@ // var sound = new Sound("https://s3-us-west-1.amazonaws.com/highfidelity-public/sounds/Animals/mexicanWhipoorwill.raw"); +var CHANCE_OF_PLAYING_SOUND = 0.01; + var FACTOR = 0.75; var countParticles = 0; // the first time around we want to create the particle and thereafter to modify it. @@ -23,11 +25,13 @@ function updateParticle() { // move particle three units in front of the avatar var particlePosition = Vec3.sum(MyAvatar.position, Vec3.multiply(avatarFront, 3)); - // play a sound at the location of the particle - var options = new AudioInjectionOptions(); - options.position = particlePosition; - options.volume = 0.75; - Audio.playSound(sound, options); + if (Math.random() < CHANCE_OF_PLAYING_SOUND) { + // play a sound at the location of the particle + var options = new AudioInjectionOptions(); + options.position = particlePosition; + options.volume = 0.75; + Audio.playSound(sound, options); + } var audioAverageLoudness = MyAvatar.audioAverageLoudness * FACTOR; //print ("Audio Loudness = " + MyAvatar.audioLoudness + " -- Audio Average Loudness = " + MyAvatar.audioAverageLoudness); diff --git a/examples/audioBallLifetime.js b/examples/audioBallLifetime.js index a7b8a0a749..affb75f04d 100644 --- a/examples/audioBallLifetime.js +++ b/examples/audioBallLifetime.js @@ -11,6 +11,8 @@ // var sound = new Sound("https://s3-us-west-1.amazonaws.com/highfidelity-public/sounds/Animals/mexicanWhipoorwill.raw"); +var CHANCE_OF_PLAYING_SOUND = 0.01; + var FACTOR = 0.75; function addParticle() { @@ -20,11 +22,13 @@ function addParticle() { // move particle three units in front of the avatar var particlePosition = Vec3.sum(MyAvatar.position, Vec3.multiply (avatarFront, 3)); - // play a sound at the location of the particle - var options = new AudioInjectionOptions(); - options.position = particlePosition; - options.volume = 0.25; - Audio.playSound(sound, options); + if (Math.random() < CHANCE_OF_PLAYING_SOUND) { + // play a sound at the location of the particle + var options = new AudioInjectionOptions(); + options.position = particlePosition; + options.volume = 0.25; + Audio.playSound(sound, options); + } var audioAverageLoudness = MyAvatar.audioAverageLoudness * FACTOR; //print ("Audio Loudness = " + MyAvatar.audioLoudness + " -- Audio Average Loudness = " + MyAvatar.audioAverageLoudness); From 9e7597a6ada5fc945d06d02d4f1cc8f9b51ccce0 Mon Sep 17 00:00:00 2001 From: stojce Date: Mon, 17 Feb 2014 19:06:55 +0100 Subject: [PATCH 16/39] bad merge fix --- interface/src/Menu.h | 1 - 1 file changed, 1 deletion(-) diff --git a/interface/src/Menu.h b/interface/src/Menu.h index 81cb5fd8d9..7ee13e0cb1 100644 --- a/interface/src/Menu.h +++ b/interface/src/Menu.h @@ -117,7 +117,6 @@ private slots: void login(); void editPreferences(); void goToDomainDialog(); - void goToDomain(); void goToLocation(); void bandwidthDetailsClosed(); void voxelStatsDetailsClosed(); From 2ba742675755394df0c350a224a26b33da2ecc97 Mon Sep 17 00:00:00 2001 From: stojce Date: Mon, 17 Feb 2014 19:25:53 +0100 Subject: [PATCH 17/39] windows build fix --- interface/src/ui/Snapshot.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/interface/src/ui/Snapshot.cpp b/interface/src/ui/Snapshot.cpp index bd4de19c86..d0a38eec4e 100644 --- a/interface/src/ui/Snapshot.cpp +++ b/interface/src/ui/Snapshot.cpp @@ -14,8 +14,6 @@ #include #include -#include - // filename format: hifi-snap-by-%username%-on-%date%_%time%_@-%location%.jpg // %1 <= username, %2 <= date and time, %3 <= current location const QString FILENAME_PATH_FORMAT = "hifi-snap-by-%1-on-%2@%3.jpg"; From 677e6f5ce9372e1c2f88daa9d48e1dda6c0f0126 Mon Sep 17 00:00:00 2001 From: stojce Date: Mon, 17 Feb 2014 20:19:35 +0100 Subject: [PATCH 18/39] windows build fix (2) --- interface/src/ui/Snapshot.h | 1 + 1 file changed, 1 insertion(+) diff --git a/interface/src/ui/Snapshot.h b/interface/src/ui/Snapshot.h index 05a2fc3147..5ee8fb4f8d 100644 --- a/interface/src/ui/Snapshot.h +++ b/interface/src/ui/Snapshot.h @@ -13,6 +13,7 @@ #include #include +#include #include "avatar/MyAvatar.h" #include "avatar/Profile.h" From ab3e1af64d82f708364f2620625482b55046bb6d Mon Sep 17 00:00:00 2001 From: ZappoMan Date: Mon, 17 Feb 2014 12:02:11 -0800 Subject: [PATCH 19/39] fix the sometime voxels don't show when you move bug --- interface/src/VoxelSystem.cpp | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/interface/src/VoxelSystem.cpp b/interface/src/VoxelSystem.cpp index a3352f36e7..693a010182 100644 --- a/interface/src/VoxelSystem.cpp +++ b/interface/src/VoxelSystem.cpp @@ -2105,7 +2105,7 @@ void VoxelSystem::hideOutOfView(bool forceFullFrustum) { bool VoxelSystem::hideAllSubTreeOperation(OctreeElement* element, void* extraData) { VoxelTreeElement* voxel = (VoxelTreeElement*)element; hideOutOfViewArgs* args = (hideOutOfViewArgs*)extraData; - + // If we've culled at least once, then we will use the status of this voxel in the last culled frustum to determine // how to proceed. If we've never culled, then we just consider all these voxels to be UNKNOWN so that we will not // consider that case. @@ -2141,7 +2141,7 @@ bool VoxelSystem::hideAllSubTreeOperation(OctreeElement* element, void* extraDat bool VoxelSystem::showAllSubTreeOperation(OctreeElement* element, void* extraData) { VoxelTreeElement* voxel = (VoxelTreeElement*)element; hideOutOfViewArgs* args = (hideOutOfViewArgs*)extraData; - + // If we've culled at least once, then we will use the status of this voxel in the last culled frustum to determine // how to proceed. If we've never culled, then we just consider all these voxels to be UNKNOWN so that we will not // consider that case. @@ -2184,7 +2184,7 @@ bool VoxelSystem::showAllSubTreeOperation(OctreeElement* element, void* extraDat bool VoxelSystem::hideOutOfViewOperation(OctreeElement* element, void* extraData) { VoxelTreeElement* voxel = (VoxelTreeElement*)element; hideOutOfViewArgs* args = (hideOutOfViewArgs*)extraData; - + // If we're still recursing the tree using this operator, then we don't know if we're inside or outside... // so before we move forward we need to determine our frustum location ViewFrustum::location inFrustum = voxel->inFrustum(args->thisViewFrustum); @@ -2201,7 +2201,6 @@ bool VoxelSystem::hideOutOfViewOperation(OctreeElement* element, void* extraData // ok, now do some processing for this node... switch (inFrustum) { case ViewFrustum::OUTSIDE: { - // If this node is outside the current view, then we might want to hide it... unless it was previously OUTSIDE, // if it was previously outside, then we can safely assume it's already hidden, and we can also safely assume // that all of it's children are outside both of our views, in which case we can just stop recursing... @@ -2215,12 +2214,10 @@ bool VoxelSystem::hideOutOfViewOperation(OctreeElement* element, void* extraData // we need to hide it. Additionally we know that ALL of it's children are also fully OUTSIDE so we can recurse // the children and simply mark them as hidden args->tree->recurseNodeWithOperation(voxel, hideAllSubTreeOperation, args ); - return false; } break; case ViewFrustum::INSIDE: { - // If this node is INSIDE the current view, then we might want to show it... unless it was previously INSIDE, // if it was previously INSIDE, then we can safely assume it's already shown, and we can also safely assume // that all of it's children are INSIDE both of our views, in which case we can just stop recursing... @@ -2234,12 +2231,10 @@ bool VoxelSystem::hideOutOfViewOperation(OctreeElement* element, void* extraData // we need to show it. Additionally we know that ALL of it's children are also fully INSIDE so we can recurse // the children and simply mark them as visible (as appropriate based on LOD) args->tree->recurseNodeWithOperation(voxel, showAllSubTreeOperation, args); - return false; } break; case ViewFrustum::INTERSECT: { args->nodesScanned++; - // If this node INTERSECTS the current view, then we might want to show it... unless it was previously INSIDE // the last known view, in which case it will already be visible, and we know that all it's children are also // previously INSIDE and visible. So in this case stop recursing @@ -2253,8 +2248,15 @@ bool VoxelSystem::hideOutOfViewOperation(OctreeElement* element, void* extraData // if the child node INTERSECTs the view, then we want to check to see if it thinks it should render // if it should render but is missing it's VBO index, then we want to flip it on, and we can stop recursing from // here because we know will block any children anyway + + float voxelSizeScale = Menu::getInstance()->getVoxelSizeScale(); + int boundaryLevelAdjust = Menu::getInstance()->getBoundaryLevelAdjust(); + bool shouldRender = voxel->calculateShouldRender(&args->thisViewFrustum, voxelSizeScale, boundaryLevelAdjust); + voxel->setShouldRender(shouldRender); + if (voxel->getShouldRender() && !voxel->isKnownBufferIndex()) { voxel->setDirtyBit(); // will this make it draw? + voxel->markWithChangedTime(); // both are needed to force redraw args->nodesShown++; return false; } @@ -2267,7 +2269,6 @@ bool VoxelSystem::hideOutOfViewOperation(OctreeElement* element, void* extraData } break; } // switch - return true; // keep going! } From 0df0c23c327f1a486b01a95af8974e3fe92b398a Mon Sep 17 00:00:00 2001 From: stojce Date: Mon, 17 Feb 2014 21:14:28 +0100 Subject: [PATCH 20/39] Windows build fix (3) --- interface/src/ui/Snapshot.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/interface/src/ui/Snapshot.h b/interface/src/ui/Snapshot.h index 5ee8fb4f8d..57a388020d 100644 --- a/interface/src/ui/Snapshot.h +++ b/interface/src/ui/Snapshot.h @@ -9,6 +9,8 @@ #ifndef __hifi__Snapshot__ #define __hifi__Snapshot__ +#include "InterfaceConfig.h" + #include #include #include From 6c2f3b687e7188b8ae31ff91a9a1e7410667fb89 Mon Sep 17 00:00:00 2001 From: stojce Date: Tue, 18 Feb 2014 01:50:55 +0100 Subject: [PATCH 21/39] removed unnecessary references --- interface/src/ui/Snapshot.cpp | 1 - interface/src/ui/Snapshot.h | 1 - 2 files changed, 2 deletions(-) diff --git a/interface/src/ui/Snapshot.cpp b/interface/src/ui/Snapshot.cpp index d0a38eec4e..8cfc759308 100644 --- a/interface/src/ui/Snapshot.cpp +++ b/interface/src/ui/Snapshot.cpp @@ -12,7 +12,6 @@ #include #include -#include // filename format: hifi-snap-by-%username%-on-%date%_%time%_@-%location%.jpg // %1 <= username, %2 <= date and time, %3 <= current location diff --git a/interface/src/ui/Snapshot.h b/interface/src/ui/Snapshot.h index 57a388020d..14c59552ec 100644 --- a/interface/src/ui/Snapshot.h +++ b/interface/src/ui/Snapshot.h @@ -15,7 +15,6 @@ #include #include -#include #include "avatar/MyAvatar.h" #include "avatar/Profile.h" From d36ced9b92884b7e4aa383cd36d3f6a3bcbed18e Mon Sep 17 00:00:00 2001 From: stojce Date: Tue, 18 Feb 2014 07:33:03 +0100 Subject: [PATCH 22/39] fixed misplaced #endif --- interface/src/devices/Transmitter.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/interface/src/devices/Transmitter.h b/interface/src/devices/Transmitter.h index 1fa392a280..12f2b302f7 100644 --- a/interface/src/devices/Transmitter.h +++ b/interface/src/devices/Transmitter.h @@ -45,5 +45,6 @@ private: TouchState _touchState; timeval* _lastReceivedPacket; -#endif /* defined(__hifi__Transmitter__) */ }; + +#endif /* defined(__hifi__Transmitter__) */ From 7621d70c2453a73f4f5997b602ca16aa1ee381dd Mon Sep 17 00:00:00 2001 From: stojce Date: Tue, 18 Feb 2014 08:11:59 +0100 Subject: [PATCH 23/39] use base class - replaced MyAvatar with Avatar --- interface/src/ui/Snapshot.cpp | 2 +- interface/src/ui/Snapshot.h | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/interface/src/ui/Snapshot.cpp b/interface/src/ui/Snapshot.cpp index 8cfc759308..e16b0c570d 100644 --- a/interface/src/ui/Snapshot.cpp +++ b/interface/src/ui/Snapshot.cpp @@ -60,7 +60,7 @@ SnapshotMetaData* Snapshot::parseSnapshotData(QString snapshotPath) { return data; } -void Snapshot::saveSnapshot(QGLWidget* widget, Profile* profile, MyAvatar* avatar) { +void Snapshot::saveSnapshot(QGLWidget* widget, Profile* profile, Avatar* avatar) { QImage shot = widget->grabFrameBuffer(); glm::vec3 location = avatar->getPosition(); diff --git a/interface/src/ui/Snapshot.h b/interface/src/ui/Snapshot.h index 14c59552ec..13c6945349 100644 --- a/interface/src/ui/Snapshot.h +++ b/interface/src/ui/Snapshot.h @@ -15,7 +15,7 @@ #include #include -#include "avatar/MyAvatar.h" +#include "avatar/Avatar.h" #include "avatar/Profile.h" class SnapshotMetaData { @@ -39,7 +39,7 @@ private: class Snapshot { public: - static void saveSnapshot(QGLWidget* widget, Profile* profile, MyAvatar* avatar); + static void saveSnapshot(QGLWidget* widget, Profile* profile, Avatar* avatar); static SnapshotMetaData* parseSnapshotData(QString snapshotPath); }; From b8673db9aa8557188a4b907596efa0dead4ae26c Mon Sep 17 00:00:00 2001 From: ZappoMan Date: Tue, 18 Feb 2014 09:58:14 -0800 Subject: [PATCH 24/39] remove unneeded example --- examples/audioBallLifetime.js | 54 ----------------------------------- 1 file changed, 54 deletions(-) delete mode 100644 examples/audioBallLifetime.js diff --git a/examples/audioBallLifetime.js b/examples/audioBallLifetime.js deleted file mode 100644 index affb75f04d..0000000000 --- a/examples/audioBallLifetime.js +++ /dev/null @@ -1,54 +0,0 @@ -// -// audioBall.js -// hifi -// -// Created by Athanasios Gaitatzes on 2/10/14. -// Copyright (c) 2014 HighFidelity, Inc. All rights reserved. -// -// This script creates a particle in front of the user that stays in front of -// the user's avatar as they move, and animates it's radius and color -// in response to the audio intensity. -// - -var sound = new Sound("https://s3-us-west-1.amazonaws.com/highfidelity-public/sounds/Animals/mexicanWhipoorwill.raw"); -var CHANCE_OF_PLAYING_SOUND = 0.01; - -var FACTOR = 0.75; - -function addParticle() { - // the particle should be placed in front of the user's avatar - var avatarFront = Quat.getFront(MyAvatar.orientation); - - // move particle three units in front of the avatar - var particlePosition = Vec3.sum(MyAvatar.position, Vec3.multiply (avatarFront, 3)); - - if (Math.random() < CHANCE_OF_PLAYING_SOUND) { - // play a sound at the location of the particle - var options = new AudioInjectionOptions(); - options.position = particlePosition; - options.volume = 0.25; - Audio.playSound(sound, options); - } - - var audioAverageLoudness = MyAvatar.audioAverageLoudness * FACTOR; - //print ("Audio Loudness = " + MyAvatar.audioLoudness + " -- Audio Average Loudness = " + MyAvatar.audioAverageLoudness); - - // animates the particles radius and color in response to the changing audio intensity - var particleProperies = { - position: particlePosition // the particle should stay in front of the user's avatar as he moves - , color: { red: 0, green: 255 * audioAverageLoudness, blue: 0 } - , radius: audioAverageLoudness - , velocity: { x: 0.0, y: 0.0, z: 0.0 } - , gravity: { x: 0.0, y: 0.0, z: 0.0 } - , damping: 0.0 - , lifetime: 0.05 - } - - Particles.addParticle (particleProperies); -} - -// register the call back so it fires before each data send -Script.willSendVisualDataCallback.connect(addParticle); - -// register our scriptEnding callback -Script.scriptEnding.connect(function scriptEnding() {}); From 8be17bf02aa3e76cc576baca011a2a160f240b07 Mon Sep 17 00:00:00 2001 From: Andrzej Kapolka Date: Tue, 18 Feb 2014 14:27:06 -0800 Subject: [PATCH 25/39] Attempting to get Visage building in on OS X. --- interface/CMakeLists.txt | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/interface/CMakeLists.txt b/interface/CMakeLists.txt index c3f7ebc286..13238d5c56 100644 --- a/interface/CMakeLists.txt +++ b/interface/CMakeLists.txt @@ -156,10 +156,13 @@ endif (SIXENSE_FOUND AND NOT DISABLE_SIXENSE) if (VISAGE_FOUND AND NOT DISABLE_VISAGE) add_definitions(-DHAVE_VISAGE -DVISAGE_STATIC) include_directories(SYSTEM ${VISAGE_INCLUDE_DIRS}) - if (APPLE OR UNIX) + if (APPLE) add_definitions(-DMAC_OS_X) - SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-comment -isystem ${VISAGE_INCLUDE_DIRS}") - endif (APPLE OR UNIX) + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-comment -isystem -std=c++0x ${VISAGE_INCLUDE_DIRS}") + find_library(AVFoundation AVFoundation) + find_library(CoreMedia CoreMedia) + target_link_libraries(${TARGET_NAME} ${AVFoundation} ${CoreMedia}) + endif (APPLE) target_link_libraries(${TARGET_NAME} ${VISAGE_LIBRARIES}) endif (VISAGE_FOUND AND NOT DISABLE_VISAGE) From a89959cd4768799c423e9a1b714d6d9884743c1f Mon Sep 17 00:00:00 2001 From: Andrzej Kapolka Date: Tue, 18 Feb 2014 15:09:34 -0800 Subject: [PATCH 26/39] Get rid of this line. --- interface/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/interface/CMakeLists.txt b/interface/CMakeLists.txt index 13238d5c56..0c94be59f3 100644 --- a/interface/CMakeLists.txt +++ b/interface/CMakeLists.txt @@ -158,7 +158,7 @@ if (VISAGE_FOUND AND NOT DISABLE_VISAGE) include_directories(SYSTEM ${VISAGE_INCLUDE_DIRS}) if (APPLE) add_definitions(-DMAC_OS_X) - SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-comment -isystem -std=c++0x ${VISAGE_INCLUDE_DIRS}") + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-comment -isystem ${VISAGE_INCLUDE_DIRS}") find_library(AVFoundation AVFoundation) find_library(CoreMedia CoreMedia) target_link_libraries(${TARGET_NAME} ${AVFoundation} ${CoreMedia}) From 0547fa61b4b18218400e222b5c491c893ed7d7db Mon Sep 17 00:00:00 2001 From: Andrzej Kapolka Date: Tue, 18 Feb 2014 15:17:16 -0800 Subject: [PATCH 27/39] Link in the new standard library, which Visage uses. --- interface/CMakeLists.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/interface/CMakeLists.txt b/interface/CMakeLists.txt index 0c94be59f3..a0a9033187 100644 --- a/interface/CMakeLists.txt +++ b/interface/CMakeLists.txt @@ -161,7 +161,8 @@ if (VISAGE_FOUND AND NOT DISABLE_VISAGE) SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-comment -isystem ${VISAGE_INCLUDE_DIRS}") find_library(AVFoundation AVFoundation) find_library(CoreMedia CoreMedia) - target_link_libraries(${TARGET_NAME} ${AVFoundation} ${CoreMedia}) + find_library(NEW_STD_LIBRARY libc++.dylib /usr/lib/) + target_link_libraries(${TARGET_NAME} ${AVFoundation} ${CoreMedia} ${NEW_STD_LIBRARY}) endif (APPLE) target_link_libraries(${TARGET_NAME} ${VISAGE_LIBRARIES}) endif (VISAGE_FOUND AND NOT DISABLE_VISAGE) From cc6b663ea6619f98e228272be573583f0348e12c Mon Sep 17 00:00:00 2001 From: Andrzej Kapolka Date: Tue, 18 Feb 2014 15:37:40 -0800 Subject: [PATCH 28/39] Use the ABI-compatible library (hopefully). --- interface/CMakeLists.txt | 2 +- interface/src/devices/Visage.cpp | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/interface/CMakeLists.txt b/interface/CMakeLists.txt index a0a9033187..32e75c9f34 100644 --- a/interface/CMakeLists.txt +++ b/interface/CMakeLists.txt @@ -161,7 +161,7 @@ if (VISAGE_FOUND AND NOT DISABLE_VISAGE) SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-comment -isystem ${VISAGE_INCLUDE_DIRS}") find_library(AVFoundation AVFoundation) find_library(CoreMedia CoreMedia) - find_library(NEW_STD_LIBRARY libc++.dylib /usr/lib/) + find_library(NEW_STD_LIBRARY libc++abi.dylib /usr/lib/) target_link_libraries(${TARGET_NAME} ${AVFoundation} ${CoreMedia} ${NEW_STD_LIBRARY}) endif (APPLE) target_link_libraries(${TARGET_NAME} ${VISAGE_LIBRARIES}) diff --git a/interface/src/devices/Visage.cpp b/interface/src/devices/Visage.cpp index f69121bf7f..6a612eb59d 100644 --- a/interface/src/devices/Visage.cpp +++ b/interface/src/devices/Visage.cpp @@ -27,7 +27,7 @@ using namespace VisageSDK; Visage::Visage() { #ifdef HAVE_VISAGE switchToResourcesParentIfRequired(); - initializeLicenseManager("resources/visage"); + initializeLicenseManager("resources/visage/license.vlc"); _tracker = new VisageTracker2("resources/visage/Facial Features Tracker - Asymmetric.cfg"); _tracker->trackFromCam(); #endif @@ -35,6 +35,7 @@ Visage::Visage() { Visage::~Visage() { #ifdef HAVE_VISAGE + _tracker->stop(); delete _tracker; #endif } From f83254882aff25e823a1d19c64962616736c1492 Mon Sep 17 00:00:00 2001 From: Andrzej Kapolka Date: Tue, 18 Feb 2014 16:07:08 -0800 Subject: [PATCH 29/39] Attempting to get the head rotation from Visage. --- interface/src/Application.cpp | 10 ++++++++++ interface/src/Application.h | 2 ++ interface/src/avatar/MyAvatar.cpp | 24 +++++++++++++++++------- interface/src/devices/Visage.cpp | 28 ++++++++++++++++++++++++---- interface/src/devices/Visage.h | 16 ++++++++++++++++ 5 files changed, 69 insertions(+), 11 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index b316548ad4..098b42dccf 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -2041,6 +2041,15 @@ void Application::updateFaceshift() { } } +void Application::updateVisage() { + + bool showWarnings = Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings); + PerformanceWarning warn(showWarnings, "Application::updateVisage()"); + + // Update Visage + _visage.update(); +} + void Application::updateMyAvatarLookAtPosition(glm::vec3& lookAtSpot) { bool showWarnings = Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings); @@ -2318,6 +2327,7 @@ void Application::update(float deltaTime) { glm::vec3 lookAtSpot; updateFaceshift(); + updateVisage(); _myAvatar->updateLookAtTargetAvatar(lookAtSpot); updateMyAvatarLookAtPosition(lookAtSpot); diff --git a/interface/src/Application.h b/interface/src/Application.h index f9c1005c13..06a19f13b1 100644 --- a/interface/src/Application.h +++ b/interface/src/Application.h @@ -161,6 +161,7 @@ public: const glm::vec3& getMouseRayOrigin() const { return _mouseRayOrigin; } const glm::vec3& getMouseRayDirection() const { return _mouseRayDirection; } Faceshift* getFaceshift() { return &_faceshift; } + Visage* getVisage() { return &_visage; } SixenseManager* getSixenseManager() { return &_sixenseManager; } BandwidthMeter* getBandwidthMeter() { return &_bandwidthMeter; } QSettings* getSettings() { return _settings; } @@ -284,6 +285,7 @@ private: // Various helper functions called during update() void updateMouseRay(); void updateFaceshift(); + void updateVisage(); void updateMyAvatarLookAtPosition(glm::vec3& lookAtSpot); void updateHoverVoxels(float deltaTime, float& distance, BoxFace& face); void updateMouseVoxels(float deltaTime, float& distance, BoxFace& face); diff --git a/interface/src/avatar/MyAvatar.cpp b/interface/src/avatar/MyAvatar.cpp index 17b80089a7..51de5a944c 100644 --- a/interface/src/avatar/MyAvatar.cpp +++ b/interface/src/avatar/MyAvatar.cpp @@ -337,22 +337,32 @@ const float MAX_PITCH = 90.0f; // Update avatar head rotation with sensor data void MyAvatar::updateFromGyros(float deltaTime) { Faceshift* faceshift = Application::getInstance()->getFaceshift(); + Visage* visage = Application::getInstance()->getVisage(); glm::vec3 estimatedPosition, estimatedRotation; + bool trackerActive = false; if (faceshift->isActive()) { estimatedPosition = faceshift->getHeadTranslation(); estimatedRotation = safeEulerAngles(faceshift->getHeadRotation()); + trackerActive = true; + + } else if (visage->isActive()) { + estimatedPosition = visage->getHeadTranslation(); + estimatedRotation = safeEulerAngles(visage->getHeadRotation()); + trackerActive = true; + } + if (trackerActive) { // Rotate the body if the head is turned beyond the screen if (Menu::getInstance()->isOptionChecked(MenuOption::TurnWithHead)) { - const float FACESHIFT_YAW_TURN_SENSITIVITY = 0.5f; - const float FACESHIFT_MIN_YAW_TURN = 15.f; - const float FACESHIFT_MAX_YAW_TURN = 50.f; - if ( (fabs(estimatedRotation.y) > FACESHIFT_MIN_YAW_TURN) && - (fabs(estimatedRotation.y) < FACESHIFT_MAX_YAW_TURN) ) { + const float TRACKER_YAW_TURN_SENSITIVITY = 0.5f; + const float TRACKER_MIN_YAW_TURN = 15.f; + const float TRACKER_MAX_YAW_TURN = 50.f; + if ( (fabs(estimatedRotation.y) > TRACKER_MIN_YAW_TURN) && + (fabs(estimatedRotation.y) < TRACKER_MAX_YAW_TURN) ) { if (estimatedRotation.y > 0.f) { - _bodyYawDelta += (estimatedRotation.y - FACESHIFT_MIN_YAW_TURN) * FACESHIFT_YAW_TURN_SENSITIVITY; + _bodyYawDelta += (estimatedRotation.y - TRACKER_MIN_YAW_TURN) * TRACKER_YAW_TURN_SENSITIVITY; } else { - _bodyYawDelta += (estimatedRotation.y + FACESHIFT_MIN_YAW_TURN) * FACESHIFT_YAW_TURN_SENSITIVITY; + _bodyYawDelta += (estimatedRotation.y + TRACKER_MIN_YAW_TURN) * TRACKER_YAW_TURN_SENSITIVITY; } } } diff --git a/interface/src/devices/Visage.cpp b/interface/src/devices/Visage.cpp index 6a612eb59d..59b3ac06f8 100644 --- a/interface/src/devices/Visage.cpp +++ b/interface/src/devices/Visage.cpp @@ -24,18 +24,38 @@ namespace VisageSDK { using namespace VisageSDK; -Visage::Visage() { +Visage::Visage() : + _active(false) { #ifdef HAVE_VISAGE switchToResourcesParentIfRequired(); initializeLicenseManager("resources/visage/license.vlc"); _tracker = new VisageTracker2("resources/visage/Facial Features Tracker - Asymmetric.cfg"); - _tracker->trackFromCam(); + if (_tracker->trackFromCam()) { + _data = new FaceData(); + + } else { + delete _tracker; + _tracker = NULL; + } #endif } Visage::~Visage() { #ifdef HAVE_VISAGE - _tracker->stop(); - delete _tracker; + if (_tracker) { + _tracker->stop(); + delete _tracker; + delete _data; + } +#endif +} + +void Visage::update() { +#ifdef HAVE_VISAGE + _active = (_tracker->getTrackingData(_data) == TRACK_STAT_OK); + if (!_active) { + return; + } + _headRotation = glm::quat(glm::vec3(_data->faceRotation[0], _data->faceRotation[1], _data->faceRotation[2])); #endif } diff --git a/interface/src/devices/Visage.h b/interface/src/devices/Visage.h index 1b9d283bb3..f16119cdbd 100644 --- a/interface/src/devices/Visage.h +++ b/interface/src/devices/Visage.h @@ -9,7 +9,11 @@ #ifndef __interface__Visage__ #define __interface__Visage__ +#include +#include + namespace VisageSDK { + class FaceData; class VisageTracker2; } @@ -20,9 +24,21 @@ public: Visage(); ~Visage(); + bool isActive() const { return _active; } + + const glm::quat& getHeadRotation() const { return _headRotation; } + const glm::vec3& getHeadTranslation() const { return _headTranslation; } + + void update(); + private: VisageSDK::VisageTracker2* _tracker; + VisageSDK::FaceData* _data; + + bool _active; + glm::quat _headRotation; + glm::vec3 _headTranslation; }; #endif /* defined(__interface__Visage__) */ From baa1762056264b558c1c7aa3c8c43da751c8cd1b Mon Sep 17 00:00:00 2001 From: ZappoMan Date: Tue, 18 Feb 2014 16:23:34 -0800 Subject: [PATCH 30/39] added support for overlays to editVoxels.js --- examples/editVoxels.js | 319 +++++++++++++++--- .../src/ControllerScriptingInterface.cpp | 4 + interface/src/ControllerScriptingInterface.h | 2 + 3 files changed, 285 insertions(+), 40 deletions(-) diff --git a/examples/editVoxels.js b/examples/editVoxels.js index c1f0c8dc49..c67ff0dcfa 100644 --- a/examples/editVoxels.js +++ b/examples/editVoxels.js @@ -16,14 +16,7 @@ // Click and drag to create more new voxels in the same direction // -function vLength(v) { - return Math.sqrt(v.x * v.x + v.y * v.y + v.z * v.z); -} - -function vMinus(a, b) { - var rval = { x: a.x - b.x, y: a.y - b.y, z: a.z - b.z }; - return rval; -} +var windowDimensions = Controller.getViewportDimensions(); var NEW_VOXEL_SIZE = 1.0; var NEW_VOXEL_DISTANCE_FROM_CAMERA = 3.0; @@ -76,6 +69,52 @@ var clickSound = new Sound("https://s3-us-west-1.amazonaws.com/highfidelity-publ var audioOptions = new AudioInjectionOptions();
 audioOptions.volume = 0.5; +var editToolsOn = false; // starts out off + + +var voxelPreview = Overlays.addOverlay("cube", { + position: { x: 0, y: 0, z: 0}, + size: 1, + color: { red: 255, green: 0, blue: 0}, + alpha: 1, + solid: false, + visible: false, + lineWidth: 4 + }); + + +// These will be our "overlay IDs" +var swatches = new Array(); +var swatchHeight = 54; +var swatchWidth = 31; +var swatchesWidth = swatchWidth * numColors; +var swatchesX = (windowDimensions.x - swatchesWidth) / 2; +var swatchesY = windowDimensions.y - swatchHeight; + +// create the overlays, position them in a row, set their colors, and for the selected one, use a different source image +// location so that it displays the "selected" marker +for (s = 0; s < numColors; s++) { + var imageFromX = 12 + (s * 27); + var imageFromY = 0; + if (s == whichColor) { + imageFromY = 55; + } + var swatchX = swatchesX + (30 * s); + + swatches[s] = Overlays.addOverlay("image", { + x: swatchX, + y: swatchesY, + width: swatchWidth, + height: swatchHeight, + subImage: { x: imageFromX, y: imageFromY, width: (swatchWidth - 1), height: swatchHeight }, + imageURL: "http://highfidelity-public.s3-us-west-1.amazonaws.com/images/testing-swatches.svg", + color: colors[s], + alpha: 1, + visible: editToolsOn + }); +} + + function setAudioPosition() { var camera = Camera.getPosition(); var forwardVector = Quat.getFront(MyAvatar.orientation); @@ -101,7 +140,141 @@ function fixEulerAngles(eulers) { return rVal; } +var trackLastMouseX = 0; +var trackLastMouseY = 0; +var trackAsDelete = false; +var trackAsRecolor = false; + +function showPreviewVoxel() { + if (editToolsOn) { + var voxelColor; + + var pickRay = Camera.computePickRay(trackLastMouseX, trackLastMouseY); + var intersection = Voxels.findRayIntersection(pickRay); + + if (whichColor == -1) { + // Copy mode - use clicked voxel color + voxelColor = { red: intersection.voxel.red, + green: intersection.voxel.green, + blue: intersection.voxel.blue }; + } else { + voxelColor = { red: colors[whichColor].red, + green: colors[whichColor].green, + blue: colors[whichColor].blue }; + } + + var guidePosition; + + if (trackAsDelete) { + guidePosition = { x: intersection.voxel.x, + y: intersection.voxel.y, + z: intersection.voxel.z }; + Overlays.editOverlay(voxelPreview, { + position: guidePosition, + size: intersection.voxel.s, + visible: true, + color: { red: 255, green: 0, blue: 0 }, + solid: false, + alpha: 1 + }); + } else if (trackAsRecolor) { + guidePosition = { x: intersection.voxel.x - 0.001, + y: intersection.voxel.y - 0.001, + z: intersection.voxel.z - 0.001 }; + + Overlays.editOverlay(voxelPreview, { + position: guidePosition, + size: intersection.voxel.s + 0.002, + visible: true, + color: voxelColor, + solid: true, + alpha: 0.8 + }); + + } else if (!isExtruding) { + guidePosition = { x: intersection.voxel.x, + y: intersection.voxel.y, + z: intersection.voxel.z }; + + if (intersection.face == "MIN_X_FACE") { + guidePosition.x -= intersection.voxel.s; + } else if (intersection.face == "MAX_X_FACE") { + guidePosition.x += intersection.voxel.s; + } else if (intersection.face == "MIN_Y_FACE") { + guidePosition.y -= intersection.voxel.s; + } else if (intersection.face == "MAX_Y_FACE") { + guidePosition.y += intersection.voxel.s; + } else if (intersection.face == "MIN_Z_FACE") { + guidePosition.z -= intersection.voxel.s; + } else if (intersection.face == "MAX_Z_FACE") { + guidePosition.z += intersection.voxel.s; + } + + Overlays.editOverlay(voxelPreview, { + position: guidePosition, + size: intersection.voxel.s, + visible: true, + color: voxelColor, + solid: true, + alpha: 0.7 + }); + } else if (isExtruding) { + Overlays.editOverlay(voxelPreview, { visible: false }); + } + } else { + Overlays.editOverlay(voxelPreview, { visible: false }); + } +} + +function trackMouseEvent(event) { + trackLastMouseX = event.x; + trackLastMouseY = event.y; + trackAsDelete = event.isControl; + trackAsRecolor = event.isShifted; + showPreviewVoxel(); +} + +function trackKeyPressEvent(event) { + if (event.text == "CONTROL") { + trackAsDelete = true; + showPreviewVoxel(); + } + if (event.text == "SHIFT") { + trackAsRecolor = true; + } + showPreviewVoxel(); +} + +function trackKeyReleaseEvent(event) { + if (event.text == "CONTROL") { + trackAsDelete = false; + showPreviewVoxel(); + } + if (event.text == "SHIFT") { + trackAsRecolor = false; + } + + // on TAB release, toggle our tool state + if (event.text == "TAB") { + editToolsOn = !editToolsOn; + moveTools(); + Audio.playSound(clickSound, audioOptions); + } + showPreviewVoxel(); +} + function mousePressEvent(event) { + + // if our tools are off, then don't do anything + if (!editToolsOn) { + return; + } + + if (event.isRightButton) { + // debugging of right button click on mac... + print(">>>> RIGHT BUTTON <<<<<"); + } + trackMouseEvent(event); // used by preview support mouseX = event.x; mouseY = event.y; var pickRay = Camera.computePickRay(event.x, event.y); @@ -118,16 +291,17 @@ function mousePressEvent(event) { // get position for initial azimuth, elevation orbitCenter = intersection.intersection; var orbitVector = Vec3.subtract(cameraPosition, orbitCenter); - orbitRadius = vLength(orbitVector); + orbitRadius = Vec3.length(orbitVector); orbitAzimuth = Math.atan2(orbitVector.z, orbitVector.x); orbitAltitude = Math.asin(orbitVector.y / Vec3.length(orbitVector)); - } else if (event.isRightButton || event.isControl) { + } else if (trackAsDelete || event.isRightButton) { // Delete voxel Voxels.eraseVoxel(intersection.voxel.x, intersection.voxel.y, intersection.voxel.z, intersection.voxel.s); Audio.playSound(deleteSound, audioOptions); + Overlays.editOverlay(voxelPreview, { visible: false }); - } else if (event.isShifted) { + } else if (trackAsRecolor) { // Recolor Voxel Voxels.setVoxel(intersection.voxel.x, intersection.voxel.y, @@ -135,6 +309,7 @@ function mousePressEvent(event) { intersection.voxel.s, colors[whichColor].red, colors[whichColor].green, colors[whichColor].blue); Audio.playSound(changeColorSound, audioOptions); + Overlays.editOverlay(voxelPreview, { visible: false }); } else { // Add voxel on face if (whichColor == -1) { @@ -178,6 +353,7 @@ function mousePressEvent(event) { lastVoxelScale = newVoxel.s; Audio.playSound(addSound, audioOptions); + Overlays.editOverlay(voxelPreview, { visible: false }); dragStart = { x: event.x, y: event.y }; isAdding = true; } @@ -185,42 +361,52 @@ function mousePressEvent(event) { } function keyPressEvent(event) { - key_alt = event.isAlt; - key_shift = event.isShifted; - var nVal = parseInt(event.text); - if (event.text == "0") { - print("Color = Copy"); - whichColor = -1; - Audio.playSound(clickSound, audioOptions); - } else if ((nVal > 0) && (nVal <= numColors)) { - whichColor = nVal - 1; - print("Color = " + (whichColor + 1)); - Audio.playSound(clickSound, audioOptions); - } else if (event.text == "9") { - // Create a brand new 1 meter voxel in front of your avatar - var color = whichColor; - if (color == -1) color = 0; - var newPosition = getNewVoxelPosition(); - var newVoxel = { - x: newPosition.x, - y: newPosition.y , - z: newPosition.z, - s: NEW_VOXEL_SIZE, - red: colors[color].red, - green: colors[color].green, - blue: colors[color].blue }; - Voxels.setVoxel(newVoxel.x, newVoxel.y, newVoxel.z, newVoxel.s, newVoxel.red, newVoxel.green, newVoxel.blue); - setAudioPosition(); - Audio.playSound(addSound, audioOptions); - } else if (event.text == " ") { + // if our tools are off, then don't do anything + if (editToolsOn) { + key_alt = event.isAlt; + key_shift = event.isShifted; + var nVal = parseInt(event.text); + if (event.text == "0") { + print("Color = Copy"); + whichColor = -1; + Audio.playSound(clickSound, audioOptions); + moveTools(); + } else if ((nVal > 0) && (nVal <= numColors)) { + whichColor = nVal - 1; + print("Color = " + (whichColor + 1)); + Audio.playSound(clickSound, audioOptions); + moveTools(); + } else if (event.text == "9") { + // Create a brand new 1 meter voxel in front of your avatar + var color = whichColor; + if (color == -1) color = 0; + var newPosition = getNewVoxelPosition(); + var newVoxel = { + x: newPosition.x, + y: newPosition.y , + z: newPosition.z, + s: NEW_VOXEL_SIZE, + red: colors[color].red, + green: colors[color].green, + blue: colors[color].blue }; + Voxels.setVoxel(newVoxel.x, newVoxel.y, newVoxel.z, newVoxel.s, newVoxel.red, newVoxel.green, newVoxel.blue); + setAudioPosition(); + Audio.playSound(addSound, audioOptions); + } + } + + // do this even if not in edit tools + if (event.text == " ") { // Reset my orientation! var orientation = { x:0, y:0, z:0, w:1 }; Camera.setOrientation(orientation); MyAvatar.orientation = orientation; } + trackKeyPressEvent(event); // used by preview support } function keyReleaseEvent(event) { + trackKeyReleaseEvent(event); // used by preview support key_alt = false; key_shift = false; } @@ -248,7 +434,7 @@ function mouseMoveEvent(event) { var lastVoxelDistance = { x: pickRay.origin.x - lastVoxelPosition.x, y: pickRay.origin.y - lastVoxelPosition.y, z: pickRay.origin.z - lastVoxelPosition.z }; - var distance = vLength(lastVoxelDistance); + var distance = Vec3.length(lastVoxelDistance); var mouseSpot = { x: pickRay.direction.x * distance, y: pickRay.direction.y * distance, z: pickRay.direction.z * distance }; mouseSpot.x += pickRay.origin.x; mouseSpot.y += pickRay.origin.y; @@ -279,9 +465,17 @@ function mouseMoveEvent(event) { } } } + + // update the add voxel/delete voxel overlay preview + trackMouseEvent(event); } function mouseReleaseEvent(event) { + // if our tools are off, then don't do anything + if (!editToolsOn) { + return; + } + if (isOrbiting) { var cameraOrientation = Camera.getOrientation(); var eulers = Quat.safeEulerAngles(cameraOrientation); @@ -296,6 +490,41 @@ function mouseReleaseEvent(event) { isExtruding = false; } +function moveTools() { + swatchesX = (windowDimensions.x - swatchesWidth) / 2; + swatchesY = windowDimensions.y - swatchHeight; + + // create the overlays, position them in a row, set their colors, and for the selected one, use a different source image + // location so that it displays the "selected" marker + for (s = 0; s < numColors; s++) { + var imageFromX = 12 + (s * 27); + var imageFromY = 0; + if (s == whichColor) { + imageFromY = 55; + } + var swatchX = swatchesX + ((swatchWidth - 1) * s); + + Overlays.editOverlay(swatches[s], { + x: swatchX, + y: swatchesY, + subImage: { x: imageFromX, y: imageFromY, width: (swatchWidth - 1), height: swatchHeight }, + color: colors[s], + alpha: 1, + visible: editToolsOn + }); + } +} + + +function update() { + var newWindowDimensions = Controller.getViewportDimensions(); + if (newWindowDimensions.x != windowDimensions.x || newWindowDimensions.y != windowDimensions.y) { + windowDimensions = newWindowDimensions; + print("window resized..."); + moveTools(); + } +} + Controller.mousePressEvent.connect(mousePressEvent); Controller.mouseReleaseEvent.connect(mouseReleaseEvent); Controller.mouseMoveEvent.connect(mouseMoveEvent); @@ -303,5 +532,15 @@ Controller.keyPressEvent.connect(keyPressEvent); Controller.keyReleaseEvent.connect(keyReleaseEvent); function scriptEnding() { + Overlays.deleteOverlay(voxelPreview); + for (s = 0; s < numColors; s++) { + Overlays.deleteOverlay(swatches[s]); + } } Script.scriptEnding.connect(scriptEnding); + + +Script.willSendVisualDataCallback.connect(update); + + + diff --git a/interface/src/ControllerScriptingInterface.cpp b/interface/src/ControllerScriptingInterface.cpp index b3d6170bff..b60615f124 100644 --- a/interface/src/ControllerScriptingInterface.cpp +++ b/interface/src/ControllerScriptingInterface.cpp @@ -250,3 +250,7 @@ void ControllerScriptingInterface::releaseJoystick(int joystickIndex) { } } +glm::vec2 ControllerScriptingInterface::getViewportDimensions() const { + QGLWidget* widget = Application::getInstance()->getGLWidget(); + return glm::vec2(widget->width(), widget->height()); +} diff --git a/interface/src/ControllerScriptingInterface.h b/interface/src/ControllerScriptingInterface.h index f0a50559f9..6fe5a60fa4 100644 --- a/interface/src/ControllerScriptingInterface.h +++ b/interface/src/ControllerScriptingInterface.h @@ -74,6 +74,8 @@ public slots: virtual void captureJoystick(int joystickIndex); virtual void releaseJoystick(int joystickIndex); + virtual glm::vec2 getViewportDimensions() const; + private: const PalmData* getPrimaryPalm() const; const PalmData* getPalm(int palmIndex) const; From ada2594ad17462ef92c625877a544be0594fe517 Mon Sep 17 00:00:00 2001 From: Andrzej Kapolka Date: Tue, 18 Feb 2014 16:36:54 -0800 Subject: [PATCH 31/39] Working on getting the head translation, too. --- interface/src/Application.cpp | 1 + interface/src/devices/Visage.cpp | 17 +++++++++++++---- interface/src/devices/Visage.h | 5 ++++- 3 files changed, 18 insertions(+), 5 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 098b42dccf..fc8bf8e899 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -3831,6 +3831,7 @@ void Application::resetSensors() { _mouseY = _glWidget->height() / 2; _faceshift.reset(); + _visage.reset(); if (OculusManager::isConnected()) { OculusManager::reset(); diff --git a/interface/src/devices/Visage.cpp b/interface/src/devices/Visage.cpp index 59b3ac06f8..94992417f4 100644 --- a/interface/src/devices/Visage.cpp +++ b/interface/src/devices/Visage.cpp @@ -24,11 +24,15 @@ namespace VisageSDK { using namespace VisageSDK; +const glm::vec3 DEFAULT_HEAD_ORIGIN(0.0f, 0.0f, 0.3f); + Visage::Visage() : - _active(false) { + _active(false), + _headOrigin(DEFAULT_HEAD_ORIGIN) { #ifdef HAVE_VISAGE switchToResourcesParentIfRequired(); - initializeLicenseManager("resources/visage/license.vlc"); + QByteArray licensePath = "resources/visage/license.vlc"; + initializeLicenseManager(licensePath); _tracker = new VisageTracker2("resources/visage/Facial Features Tracker - Asymmetric.cfg"); if (_tracker->trackFromCam()) { _data = new FaceData(); @@ -52,10 +56,15 @@ Visage::~Visage() { void Visage::update() { #ifdef HAVE_VISAGE - _active = (_tracker->getTrackingData(_data) == TRACK_STAT_OK); + _active = (_tracker && _tracker->getTrackingData(_data) == TRACK_STAT_OK); if (!_active) { return; } - _headRotation = glm::quat(glm::vec3(_data->faceRotation[0], _data->faceRotation[1], _data->faceRotation[2])); + _headRotation = glm::quat(glm::vec3(-_data->faceRotation[0], -_data->faceRotation[1], _data->faceRotation[2])); + _headTranslation = glm::vec3(_data->faceTranslation[0], _data->faceTranslation[1], _data->faceTranslation[2]) - _headOrigin; #endif } + +void Visage::reset() { + _headOrigin += _headTranslation; +} diff --git a/interface/src/devices/Visage.h b/interface/src/devices/Visage.h index f16119cdbd..20c361bda0 100644 --- a/interface/src/devices/Visage.h +++ b/interface/src/devices/Visage.h @@ -13,8 +13,8 @@ #include namespace VisageSDK { - class FaceData; class VisageTracker2; + struct FaceData; } /// Handles input from the Visage webcam feature tracking software. @@ -30,6 +30,7 @@ public: const glm::vec3& getHeadTranslation() const { return _headTranslation; } void update(); + void reset(); private: @@ -39,6 +40,8 @@ private: bool _active; glm::quat _headRotation; glm::vec3 _headTranslation; + + glm::vec3 _headOrigin; }; #endif /* defined(__interface__Visage__) */ From fe7970665389307d22f6c285f56de89b0e7b55d0 Mon Sep 17 00:00:00 2001 From: Andrzej Kapolka Date: Tue, 18 Feb 2014 16:42:30 -0800 Subject: [PATCH 32/39] Working on the translation scale. --- interface/src/devices/Visage.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/interface/src/devices/Visage.cpp b/interface/src/devices/Visage.cpp index 94992417f4..cce5f66340 100644 --- a/interface/src/devices/Visage.cpp +++ b/interface/src/devices/Visage.cpp @@ -32,7 +32,7 @@ Visage::Visage() : #ifdef HAVE_VISAGE switchToResourcesParentIfRequired(); QByteArray licensePath = "resources/visage/license.vlc"; - initializeLicenseManager(licensePath); + initializeLicenseManager(licensePath.data()); _tracker = new VisageTracker2("resources/visage/Facial Features Tracker - Asymmetric.cfg"); if (_tracker->trackFromCam()) { _data = new FaceData(); @@ -54,17 +54,20 @@ Visage::~Visage() { #endif } +const float TRANSLATION_SCALE = 50.0f; + void Visage::update() { #ifdef HAVE_VISAGE _active = (_tracker && _tracker->getTrackingData(_data) == TRACK_STAT_OK); if (!_active) { return; } - _headRotation = glm::quat(glm::vec3(-_data->faceRotation[0], -_data->faceRotation[1], _data->faceRotation[2])); - _headTranslation = glm::vec3(_data->faceTranslation[0], _data->faceTranslation[1], _data->faceTranslation[2]) - _headOrigin; + _headRotation = glm::quat(glm::vec3(-_data->faceRotation[0], -_data->faceRotation[1], _data->faceRotation[2])); + _headTranslation = (glm::vec3(_data->faceTranslation[0], _data->faceTranslation[1], _data->faceTranslation[2]) - + _headOrigin) * TRANSLATION_SCALE; #endif } void Visage::reset() { - _headOrigin += _headTranslation; + _headOrigin += _headTranslation / TRANSLATION_SCALE; } From 866b3dbb6315850b07647a9ef2ac1e3dc5a1ffcf Mon Sep 17 00:00:00 2001 From: ZappoMan Date: Tue, 18 Feb 2014 16:47:50 -0800 Subject: [PATCH 33/39] scripting additions --- .../script-engine/src/AbstractControllerScriptingInterface.h | 4 ++++ libraries/script-engine/src/EventTypes.cpp | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/libraries/script-engine/src/AbstractControllerScriptingInterface.h b/libraries/script-engine/src/AbstractControllerScriptingInterface.h index d9878d0b71..1878edd4d6 100644 --- a/libraries/script-engine/src/AbstractControllerScriptingInterface.h +++ b/libraries/script-engine/src/AbstractControllerScriptingInterface.h @@ -52,6 +52,10 @@ public slots: virtual void captureWheelEvents() = 0; virtual void releaseWheelEvents() = 0; + virtual void captureJoystick(int joystickIndex) = 0; + virtual void releaseJoystick(int joystickIndex) = 0; + + virtual glm::vec2 getViewportDimensions() const = 0; signals: void keyPressEvent(const KeyEvent& event); diff --git a/libraries/script-engine/src/EventTypes.cpp b/libraries/script-engine/src/EventTypes.cpp index 963912fd34..8fac2bcd2a 100644 --- a/libraries/script-engine/src/EventTypes.cpp +++ b/libraries/script-engine/src/EventTypes.cpp @@ -102,6 +102,8 @@ KeyEvent::KeyEvent(const QKeyEvent& event) { text = "END"; } else if (key == Qt::Key_Help) { text = "HELP"; + } else if (key == Qt::Key_CapsLock) { + text = "CAPS LOCK"; } } @@ -208,6 +210,8 @@ void keyEventFromScriptValue(const QScriptValue& object, KeyEvent& event) { event.key = Qt::Key_End; } else if (event.text.toUpper() == "HELP") { event.key = Qt::Key_Help; + } else if (event.text.toUpper() == "CAPS LOCK") { + event.key = Qt::Key_CapsLock; } else { event.key = event.text.at(0).unicode(); } From 9c4143e1beb7234ec03852b5001e850739f257e2 Mon Sep 17 00:00:00 2001 From: Andrzej Kapolka Date: Tue, 18 Feb 2014 17:03:43 -0800 Subject: [PATCH 34/39] Working on gaze deflection. --- interface/src/Application.cpp | 14 +++++++++++++- interface/src/devices/Visage.cpp | 10 +++++++--- interface/src/devices/Visage.h | 6 ++++++ 3 files changed, 26 insertions(+), 4 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index fc8bf8e899..88c7af102b 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -2070,13 +2070,25 @@ void Application::updateMyAvatarLookAtPosition(glm::vec3& lookAtSpot) { } lookAtSpot = _mouseRayOrigin + _mouseRayDirection * distance; } + bool trackerActive = false; + float eyePitch, eyeYaw; if (_faceshift.isActive()) { + eyePitch = _faceshift.getEstimatedEyePitch(); + eyeYaw = _faceshift.getEstimatedEyeYaw(); + trackerActive = true; + + } else if (_visage.isActive()) { + eyePitch = _visage.getEstimatedEyePitch(); + eyeYaw = _visage.getEstimatedEyeYaw(); + trackerActive = true; + } + if (trackerActive) { // deflect using Faceshift gaze data glm::vec3 origin = _myAvatar->getHead().calculateAverageEyePosition(); float pitchSign = (_myCamera.getMode() == CAMERA_MODE_MIRROR) ? -1.0f : 1.0f; float deflection = Menu::getInstance()->getFaceshiftEyeDeflection(); lookAtSpot = origin + _myCamera.getRotation() * glm::quat(glm::radians(glm::vec3( - _faceshift.getEstimatedEyePitch() * pitchSign * deflection, _faceshift.getEstimatedEyeYaw() * deflection, 0.0f))) * + eyePitch * pitchSign * deflection, eyeYaw * deflection, 0.0f))) * glm::inverse(_myCamera.getRotation()) * (lookAtSpot - origin); } _myAvatar->getHead().setLookAtPosition(lookAtSpot); diff --git a/interface/src/devices/Visage.cpp b/interface/src/devices/Visage.cpp index cce5f66340..8696db3af4 100644 --- a/interface/src/devices/Visage.cpp +++ b/interface/src/devices/Visage.cpp @@ -24,11 +24,13 @@ namespace VisageSDK { using namespace VisageSDK; -const glm::vec3 DEFAULT_HEAD_ORIGIN(0.0f, 0.0f, 0.3f); +const glm::vec3 DEFAULT_HEAD_ORIGIN(0.0f, 0.0f, 0.7f); Visage::Visage() : _active(false), - _headOrigin(DEFAULT_HEAD_ORIGIN) { + _headOrigin(DEFAULT_HEAD_ORIGIN), + _estimatedEyePitch(0.0f), + _estimatedEyeYaw(0.0f) { #ifdef HAVE_VISAGE switchToResourcesParentIfRequired(); QByteArray licensePath = "resources/visage/license.vlc"; @@ -54,7 +56,7 @@ Visage::~Visage() { #endif } -const float TRANSLATION_SCALE = 50.0f; +const float TRANSLATION_SCALE = 20.0f; void Visage::update() { #ifdef HAVE_VISAGE @@ -65,6 +67,8 @@ void Visage::update() { _headRotation = glm::quat(glm::vec3(-_data->faceRotation[0], -_data->faceRotation[1], _data->faceRotation[2])); _headTranslation = (glm::vec3(_data->faceTranslation[0], _data->faceTranslation[1], _data->faceTranslation[2]) - _headOrigin) * TRANSLATION_SCALE; + _estimatedEyePitch = glm::degrees(_data->gazeDirection[1]); + _estimatedEyeYaw = glm::degrees(_data->gazeDirection[0]); #endif } diff --git a/interface/src/devices/Visage.h b/interface/src/devices/Visage.h index 20c361bda0..966c41335e 100644 --- a/interface/src/devices/Visage.h +++ b/interface/src/devices/Visage.h @@ -29,6 +29,9 @@ public: const glm::quat& getHeadRotation() const { return _headRotation; } const glm::vec3& getHeadTranslation() const { return _headTranslation; } + float getEstimatedEyePitch() const { return _estimatedEyePitch; } + float getEstimatedEyeYaw() const { return _estimatedEyeYaw; } + void update(); void reset(); @@ -42,6 +45,9 @@ private: glm::vec3 _headTranslation; glm::vec3 _headOrigin; + + float _estimatedEyePitch; + float _estimatedEyeYaw; }; #endif /* defined(__interface__Visage__) */ From e97a912d9746600afd880cf74bab4d5b64e592ac Mon Sep 17 00:00:00 2001 From: Andrzej Kapolka Date: Tue, 18 Feb 2014 17:19:29 -0800 Subject: [PATCH 35/39] Working on blendshape coefficients. --- interface/src/avatar/Head.cpp | 26 +++++++++++--------------- interface/src/devices/Visage.cpp | 11 +++++++++-- interface/src/devices/Visage.h | 6 ++++++ 3 files changed, 26 insertions(+), 17 deletions(-) diff --git a/interface/src/avatar/Head.cpp b/interface/src/avatar/Head.cpp index ddb0660364..5c6100764a 100644 --- a/interface/src/avatar/Head.cpp +++ b/interface/src/avatar/Head.cpp @@ -62,24 +62,20 @@ void Head::simulate(float deltaTime, bool isMine) { // Update audio trailing average for rendering facial animations Faceshift* faceshift = Application::getInstance()->getFaceshift(); + Visage* visage = Application::getInstance()->getVisage(); if (isMine) { - _isFaceshiftConnected = faceshift->isActive(); + _isFaceshiftConnected = false; + if (faceshift->isActive()) { + _blendshapeCoefficients = faceshift->getBlendshapeCoefficients(); + _isFaceshiftConnected = true; + + } else if (visage->isActive()) { + _blendshapeCoefficients = visage->getBlendshapeCoefficients(); + _isFaceshiftConnected = true; + } } - if (isMine && faceshift->isActive()) { - const float EYE_OPEN_SCALE = 0.5f; - _leftEyeBlink = faceshift->getLeftBlink() - EYE_OPEN_SCALE * faceshift->getLeftEyeOpen(); - _rightEyeBlink = faceshift->getRightBlink() - EYE_OPEN_SCALE * faceshift->getRightEyeOpen(); - - // set these values based on how they'll be used. if we use faceshift in the long term, we'll want a complete - // mapping between their blendshape coefficients and our avatar features - const float MOUTH_SIZE_SCALE = 2500.0f; - _averageLoudness = faceshift->getMouthSize() * faceshift->getMouthSize() * MOUTH_SIZE_SCALE; - const float BROW_HEIGHT_SCALE = 0.005f; - _browAudioLift = faceshift->getBrowUpCenter() * BROW_HEIGHT_SCALE; - _blendshapeCoefficients = faceshift->getBlendshapeCoefficients(); - - } else if (!_isFaceshiftConnected) { + if (!_isFaceshiftConnected) { // Update eye saccades const float AVERAGE_MICROSACCADE_INTERVAL = 0.50f; const float AVERAGE_SACCADE_INTERVAL = 4.0f; diff --git a/interface/src/devices/Visage.cpp b/interface/src/devices/Visage.cpp index 8696db3af4..c6fb5b9668 100644 --- a/interface/src/devices/Visage.cpp +++ b/interface/src/devices/Visage.cpp @@ -67,8 +67,15 @@ void Visage::update() { _headRotation = glm::quat(glm::vec3(-_data->faceRotation[0], -_data->faceRotation[1], _data->faceRotation[2])); _headTranslation = (glm::vec3(_data->faceTranslation[0], _data->faceTranslation[1], _data->faceTranslation[2]) - _headOrigin) * TRANSLATION_SCALE; - _estimatedEyePitch = glm::degrees(_data->gazeDirection[1]); - _estimatedEyeYaw = glm::degrees(_data->gazeDirection[0]); + _estimatedEyePitch = glm::degrees(-_data->gazeDirection[1]); + _estimatedEyeYaw = glm::degrees(-_data->gazeDirection[0]); + + for (int i = 0; i < _data->actionUnitCount; i++) { + if (!_data->actionUnitsUsed[i]) { + continue; + } + qDebug() << _data->actionUnitsNames[i] << _data->actionUnits[i]; + } #endif } diff --git a/interface/src/devices/Visage.h b/interface/src/devices/Visage.h index 966c41335e..383c81be54 100644 --- a/interface/src/devices/Visage.h +++ b/interface/src/devices/Visage.h @@ -9,6 +9,8 @@ #ifndef __interface__Visage__ #define __interface__Visage__ +#include + #include #include @@ -32,6 +34,8 @@ public: float getEstimatedEyePitch() const { return _estimatedEyePitch; } float getEstimatedEyeYaw() const { return _estimatedEyeYaw; } + const std::vector& getBlendshapeCoefficients() const { return _blendshapeCoefficients; } + void update(); void reset(); @@ -48,6 +52,8 @@ private: float _estimatedEyePitch; float _estimatedEyeYaw; + + std::vector _blendshapeCoefficients; }; #endif /* defined(__interface__Visage__) */ From 636e3b1910952a5ce0d1ff92c89554603cc24d7a Mon Sep 17 00:00:00 2001 From: Andrzej Kapolka Date: Tue, 18 Feb 2014 18:24:25 -0800 Subject: [PATCH 36/39] Working on blendshape integration. --- interface/src/devices/Visage.cpp | 56 +++++++++++++++++++++++++++++- interface/src/devices/Visage.h | 4 +++ interface/src/renderer/FBXReader.h | 3 ++ 3 files changed, 62 insertions(+), 1 deletion(-) diff --git a/interface/src/devices/Visage.cpp b/interface/src/devices/Visage.cpp index c6fb5b9668..2ed36e9594 100644 --- a/interface/src/devices/Visage.cpp +++ b/interface/src/devices/Visage.cpp @@ -6,6 +6,8 @@ // Copyright (c) 2014 High Fidelity, Inc. All rights reserved. // +#include + #include #ifdef HAVE_VISAGE @@ -13,6 +15,7 @@ #endif #include "Visage.h" +#include "renderer/FBXReader.h" namespace VisageSDK { #ifdef WIN32 @@ -56,6 +59,43 @@ Visage::~Visage() { #endif } +static QHash createBlendshapeIndices() { + QHash blendshapeMap; + blendshapeMap.insert("Sneer", "au_nose_wrinkler"); + blendshapeMap.insert("JawFwd", "au_jaw_z_push"); + blendshapeMap.insert("JawLeft", "au_jaw_x_push"); + blendshapeMap.insert("JawOpen", "au_jaw_drop"); + blendshapeMap.insert("LipsLowerDown", "au_lower_lip_drop"); + blendshapeMap.insert("LipsUpperUp", "au_upper_lip_raiser"); + blendshapeMap.insert("LipsStretch_L", "au_lip_stretcher_left"); + blendshapeMap.insert("BrowsU_L", "au_left_outer_brow_raiser"); + blendshapeMap.insert("BrowsU_C", "au_left_inner_brow_raiser"); + blendshapeMap.insert("BrowsD_L", "au_left_brow_lowerer"); + blendshapeMap.insert("LipsStretch_R", "au_lip_stretcher_right"); + blendshapeMap.insert("BrowsU_R", "au_right_outer_brow_raiser"); + blendshapeMap.insert("BrowsU_C", "au_right_inner_brow_raiser"); + blendshapeMap.insert("BrowsD_R", "au_right_brow_lowerer"); + + QHash blendshapeIndices; + for (int i = 0;; i++) { + QByteArray blendshape = FACESHIFT_BLENDSHAPES[i]; + if (blendshape.isEmpty()) { + break; + } + QByteArray mapping = blendshapeMap.value(blendshape); + if (!mapping.isEmpty()) { + blendshapeIndices.insert(mapping, i + 1); + } + } + + return blendshapeIndices; +} + +static const QHash& getBlendshapeIndices() { + static QHash blendshapeIndices = createBlendshapeIndices(); + return blendshapeIndices; +} + const float TRANSLATION_SCALE = 20.0f; void Visage::update() { @@ -70,11 +110,25 @@ void Visage::update() { _estimatedEyePitch = glm::degrees(-_data->gazeDirection[1]); _estimatedEyeYaw = glm::degrees(-_data->gazeDirection[0]); + if (_blendshapeIndices.isEmpty()) { + _blendshapeIndices.resize(_data->actionUnitCount); + int maxIndex = -1; + for (int i = 0; i < _data->actionUnitCount; i++) { + int index = getBlendshapeIndices().value(_data->actionUnitsNames[i]) - 1; + maxIndex = qMax(maxIndex, _blendshapeIndices[i] = index); + } + _blendshapeCoefficients.resize(maxIndex + 1); + } + + qFill(_blendshapeCoefficients.begin(), _blendshapeCoefficients.end(), 0.0f); for (int i = 0; i < _data->actionUnitCount; i++) { if (!_data->actionUnitsUsed[i]) { continue; } - qDebug() << _data->actionUnitsNames[i] << _data->actionUnits[i]; + int index = _blendshapeIndices.at(i); + if (index != -1) { + _blendshapeCoefficients[index] = _data->actionUnits[i]; + } } #endif } diff --git a/interface/src/devices/Visage.h b/interface/src/devices/Visage.h index 383c81be54..0559a859de 100644 --- a/interface/src/devices/Visage.h +++ b/interface/src/devices/Visage.h @@ -11,6 +11,8 @@ #include +#include + #include #include @@ -54,6 +56,8 @@ private: float _estimatedEyeYaw; std::vector _blendshapeCoefficients; + + QVector _blendshapeIndices; }; #endif /* defined(__interface__Visage__) */ diff --git a/interface/src/renderer/FBXReader.h b/interface/src/renderer/FBXReader.h index 8efb23c98c..b89d0954b4 100644 --- a/interface/src/renderer/FBXReader.h +++ b/interface/src/renderer/FBXReader.h @@ -21,6 +21,9 @@ class FBXNode; typedef QList FBXNodeList; +/// The names of the blendshapes expected by Faceshift, terminated with an empty string. +extern const char* FACESHIFT_BLENDSHAPES[]; + /// A node within an FBX document. class FBXNode { public: From 8076f571fd5ea93aedfd91047e2e776458c5e3bc Mon Sep 17 00:00:00 2001 From: Andrzej Kapolka Date: Tue, 18 Feb 2014 18:39:38 -0800 Subject: [PATCH 37/39] Working on blinking, etc. --- interface/src/devices/Visage.cpp | 28 +++++++++++++++++++++++++++- interface/src/devices/Visage.h | 2 ++ 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/interface/src/devices/Visage.cpp b/interface/src/devices/Visage.cpp index 2ed36e9594..8a6b9d5947 100644 --- a/interface/src/devices/Visage.cpp +++ b/interface/src/devices/Visage.cpp @@ -33,7 +33,10 @@ Visage::Visage() : _active(false), _headOrigin(DEFAULT_HEAD_ORIGIN), _estimatedEyePitch(0.0f), - _estimatedEyeYaw(0.0f) { + _estimatedEyeYaw(0.0f), + _leftInnerBrowIndex(0), + _rightInnerBrowIndex(0) { + #ifdef HAVE_VISAGE switchToResourcesParentIfRequired(); QByteArray licensePath = "resources/visage/license.vlc"; @@ -59,6 +62,10 @@ Visage::~Visage() { #endif } +static int leftEyeBlinkIndex = 0; +static int rightEyeBlinkIndex = 1; +static int centerBrowIndex = 16; + static QHash createBlendshapeIndices() { QHash blendshapeMap; blendshapeMap.insert("Sneer", "au_nose_wrinkler"); @@ -82,6 +89,15 @@ static QHash createBlendshapeIndices() { if (blendshape.isEmpty()) { break; } + if (blendshape == "EyeBlink_L") { + leftEyeBlinkIndex = i; + + } else if (blendshape == "EyeBlink_R") { + rightEyeBlinkIndex = i; + + } else if (blendshape == "BrowsU_C") { + centerBrowIndex = i; + } QByteArray mapping = blendshapeMap.value(blendshape); if (!mapping.isEmpty()) { blendshapeIndices.insert(mapping, i + 1); @@ -114,6 +130,12 @@ void Visage::update() { _blendshapeIndices.resize(_data->actionUnitCount); int maxIndex = -1; for (int i = 0; i < _data->actionUnitCount; i++) { + QByteArray name = _data->actionUnitsNames[i]; + if (name == "au_left_inner_brow_raiser") { + _leftInnerBrowIndex = i; + } else if (name == "au_right_inner_brow_raiser") { + _rightInnerBrowIndex = i; + } int index = getBlendshapeIndices().value(_data->actionUnitsNames[i]) - 1; maxIndex = qMax(maxIndex, _blendshapeIndices[i] = index); } @@ -130,6 +152,10 @@ void Visage::update() { _blendshapeCoefficients[index] = _data->actionUnits[i]; } } + _blendshapeCoefficients[leftEyeBlinkIndex] = 1.0f - _data->eyeClosure[0]; + _blendshapeCoefficients[rightEyeBlinkIndex] = 1.0f - _data->eyeClosure[1]; + _blendshapeCoefficients[centerBrowIndex] = (_data->actionUnits[_leftInnerBrowIndex] + + _data->actionUnits[_rightInnerBrowIndex]) * 0.5f; #endif } diff --git a/interface/src/devices/Visage.h b/interface/src/devices/Visage.h index 0559a859de..124ef29e3b 100644 --- a/interface/src/devices/Visage.h +++ b/interface/src/devices/Visage.h @@ -58,6 +58,8 @@ private: std::vector _blendshapeCoefficients; QVector _blendshapeIndices; + int _leftInnerBrowIndex; + int _rightInnerBrowIndex; }; #endif /* defined(__interface__Visage__) */ From c4e643e3a4f6155c18eef4ee9e19c6017bfc129f Mon Sep 17 00:00:00 2001 From: Andrzej Kapolka Date: Tue, 18 Feb 2014 18:43:45 -0800 Subject: [PATCH 38/39] Eyes were reversed. --- interface/src/devices/Visage.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/interface/src/devices/Visage.cpp b/interface/src/devices/Visage.cpp index 8a6b9d5947..b1a041c0dc 100644 --- a/interface/src/devices/Visage.cpp +++ b/interface/src/devices/Visage.cpp @@ -152,8 +152,8 @@ void Visage::update() { _blendshapeCoefficients[index] = _data->actionUnits[i]; } } - _blendshapeCoefficients[leftEyeBlinkIndex] = 1.0f - _data->eyeClosure[0]; - _blendshapeCoefficients[rightEyeBlinkIndex] = 1.0f - _data->eyeClosure[1]; + _blendshapeCoefficients[leftEyeBlinkIndex] = 1.0f - _data->eyeClosure[1]; + _blendshapeCoefficients[rightEyeBlinkIndex] = 1.0f - _data->eyeClosure[0]; _blendshapeCoefficients[centerBrowIndex] = (_data->actionUnits[_leftInnerBrowIndex] + _data->actionUnits[_rightInnerBrowIndex]) * 0.5f; #endif From a89983a1c0f28f5b8d8d8cb6bb273e8273e7e459 Mon Sep 17 00:00:00 2001 From: Andrzej Kapolka Date: Tue, 18 Feb 2014 18:49:34 -0800 Subject: [PATCH 39/39] Removed tab, variable fix. --- interface/src/devices/Visage.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/interface/src/devices/Visage.cpp b/interface/src/devices/Visage.cpp index b1a041c0dc..26e7993ecb 100644 --- a/interface/src/devices/Visage.cpp +++ b/interface/src/devices/Visage.cpp @@ -21,7 +21,7 @@ namespace VisageSDK { #ifdef WIN32 void __declspec(dllimport) initializeLicenseManager(char* licenseKeyFileName); #else - void initializeLicenseManager(char* licenseKeyFileName); + void initializeLicenseManager(char* licenseKeyFileName); #endif } @@ -136,7 +136,7 @@ void Visage::update() { } else if (name == "au_right_inner_brow_raiser") { _rightInnerBrowIndex = i; } - int index = getBlendshapeIndices().value(_data->actionUnitsNames[i]) - 1; + int index = getBlendshapeIndices().value(name) - 1; maxIndex = qMax(maxIndex, _blendshapeIndices[i] = index); } _blendshapeCoefficients.resize(maxIndex + 1);