Attempting to get the head rotation from Visage.

This commit is contained in:
Andrzej Kapolka 2014-02-18 16:07:08 -08:00
parent cc6b663ea6
commit f83254882a
5 changed files with 69 additions and 11 deletions

View file

@ -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);

View file

@ -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);

View file

@ -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;
}
}
}

View file

@ -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
}

View file

@ -9,7 +9,11 @@
#ifndef __interface__Visage__
#define __interface__Visage__
#include <glm/glm.hpp>
#include <glm/gtc/quaternion.hpp>
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__) */