From ada2594ad17462ef92c625877a544be0594fe517 Mon Sep 17 00:00:00 2001 From: Andrzej Kapolka Date: Tue, 18 Feb 2014 16:36:54 -0800 Subject: [PATCH] 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__) */