Move Faceshift related member out of Menu

Moved it to Faceshift class
This commit is contained in:
Atlante45 2015-01-17 21:35:25 -08:00
parent 8f5f634308
commit ef5cfdc3ab
6 changed files with 22 additions and 19 deletions

View file

@ -1893,7 +1893,7 @@ void Application::updateMyAvatarLookAtPosition() {
// deflect using Faceshift gaze data
glm::vec3 origin = _myAvatar->getHead()->getEyePosition();
float pitchSign = (_myCamera.getMode() == CAMERA_MODE_MIRROR) ? -1.0f : 1.0f;
float deflection = Menu::getInstance()->getFaceshiftEyeDeflection();
float deflection = DependencyManager::get<Faceshift>()->getEyeDeflection();
if (isLookingAtSomeone) {
deflection *= GAZE_DEFLECTION_REDUCTION_DURING_EYE_CONTACT;
}

View file

@ -44,6 +44,7 @@
#include "Audio.h"
#include "audio/AudioIOStatsRenderer.h"
#include "audio/AudioScope.h"
#include "devices/Faceshift.h"
#include "devices/RealSense.h"
#include "devices/Visage.h"
#include "Menu.h"
@ -591,8 +592,6 @@ void Menu::loadSettings(QSettings* settings) {
_fieldOfView = loadSetting(settings, "fieldOfView", DEFAULT_FIELD_OF_VIEW_DEGREES);
_realWorldFieldOfView = loadSetting(settings, "realWorldFieldOfView", DEFAULT_REAL_WORLD_FIELD_OF_VIEW_DEGREES);
_faceshiftEyeDeflection = loadSetting(settings, "faceshiftEyeDeflection", DEFAULT_FACESHIFT_EYE_DEFLECTION);
_faceshiftHostname = settings->value("faceshiftHostname", DEFAULT_FACESHIFT_HOSTNAME).toString();
_maxOctreePacketsPerSecond = loadSetting(settings, "maxOctreePPS", DEFAULT_MAX_OCTREE_PPS);
_snapshotsLocation = settings->value("snapshotsLocation",
QStandardPaths::writableLocation(QStandardPaths::DesktopLocation)).toString();
@ -638,8 +637,6 @@ void Menu::saveSettings(QSettings* settings) {
settings->setValue("audioOutputBufferSize", audio->getOutputBufferSize());
settings->setValue("fieldOfView", _fieldOfView);
settings->setValue("faceshiftEyeDeflection", _faceshiftEyeDeflection);
settings->setValue("faceshiftHostname", _faceshiftHostname);
settings->setValue("maxOctreePPS", _maxOctreePacketsPerSecond);
settings->setValue("snapshotsLocation", _snapshotsLocation);
settings->setValue("scriptsLocation", _scriptsLocation);

View file

@ -26,7 +26,6 @@
#include "SpeechRecognizer.h"
#endif
#include "devices/Faceshift.h"
#include "devices/SixenseManager.h"
#include "ui/ChatWindow.h"
#include "ui/JSConsole.h"
@ -141,10 +140,6 @@ public:
bool getInvertSixenseButtons() const { return _invertSixenseButtons; }
void setInvertSixenseButtons(bool invertSixenseButtons) { _invertSixenseButtons = invertSixenseButtons; bumpSettings(); }
float getFaceshiftEyeDeflection() const { return _faceshiftEyeDeflection; }
void setFaceshiftEyeDeflection(float faceshiftEyeDeflection) { _faceshiftEyeDeflection = faceshiftEyeDeflection; bumpSettings(); }
const QString& getFaceshiftHostname() const { return _faceshiftHostname; }
void setFaceshiftHostname(const QString& hostname) { _faceshiftHostname = hostname; bumpSettings(); }
QString getSnapshotsLocation() const;
void setSnapshotsLocation(QString snapshotsLocation) { _snapshotsLocation = snapshotsLocation; bumpSettings(); }
@ -215,8 +210,6 @@ private:
float _fieldOfView = DEFAULT_FIELD_OF_VIEW_DEGREES;
// The actual FOV set by the user's monitor size and view distance
float _realWorldFieldOfView = DEFAULT_REAL_WORLD_FIELD_OF_VIEW_DEGREES;
float _faceshiftEyeDeflection = DEFAULT_FACESHIFT_EYE_DEFLECTION;
QString _faceshiftHostname = DEFAULT_FACESHIFT_HOSTNAME;
QDialog* _jsConsole = nullptr;
#if defined(Q_OS_MAC) || defined(Q_OS_WIN)

View file

@ -159,7 +159,7 @@ void Faceshift::connectSocket() {
qDebug("Faceshift: Connecting...");
}
_tcpSocket.connectToHost(Menu::getInstance()->getFaceshiftHostname(), FACESHIFT_PORT);
_tcpSocket.connectToHost(_hostname, FACESHIFT_PORT);
_tracking = false;
}
}

View file

@ -61,6 +61,12 @@ public:
float getMouthSize() const { return getBlendshapeCoefficient(_jawOpenIndex); }
float getMouthSmileLeft() const { return getBlendshapeCoefficient(_mouthSmileLeftIndex); }
float getMouthSmileRight() const { return getBlendshapeCoefficient(_mouthSmileRightIndex); }
float getEyeDeflection() const { return _eyeDeflection; }
void setEyeDeflection(float faceshiftEyeDeflection) { _eyeDeflection = faceshiftEyeDeflection; }
const QString& getHostname() const { return _hostname; }
void setHostname(const QString& hostname) { _hostname = hostname; }
void update();
void reset();
@ -145,6 +151,9 @@ private:
float _longTermAverageEyeYaw;
bool _longTermAverageInitialized;
float _eyeDeflection = DEFAULT_FACESHIFT_EYE_DEFLECTION;
QString _hostname = DEFAULT_FACESHIFT_HOSTNAME;
};
#endif // hifi_Faceshift_h

View file

@ -11,6 +11,8 @@
#include <QFileDialog>
#include <devices/Faceshift.h>
#include "Application.h"
#include "Audio.h"
#include "MainWindow.h"
@ -124,10 +126,11 @@ void PreferencesDialog::loadPreferences() {
ui.pupilDilationSlider->setValue(myAvatar->getHead()->getPupilDilation() *
ui.pupilDilationSlider->maximum());
ui.faceshiftEyeDeflectionSider->setValue(menuInstance->getFaceshiftEyeDeflection() *
auto faceshift = DependencyManager::get<Faceshift>();
ui.faceshiftEyeDeflectionSider->setValue(faceshift->getEyeDeflection() *
ui.faceshiftEyeDeflectionSider->maximum());
ui.faceshiftHostnameEdit->setText(menuInstance->getFaceshiftHostname());
ui.faceshiftHostnameEdit->setText(faceshift->getHostname());
auto audio = DependencyManager::get<Audio>();
MixedProcessedAudioStream& stream = audio->getReceivedAudioStream();
@ -231,11 +234,12 @@ void PreferencesDialog::savePreferences() {
Menu::getInstance()->setRealWorldFieldOfView(ui.realWorldFieldOfViewSpin->value());
Menu::getInstance()->setFieldOfView(ui.fieldOfViewSpin->value());
Menu::getInstance()->setFaceshiftEyeDeflection(ui.faceshiftEyeDeflectionSider->value() /
(float)ui.faceshiftEyeDeflectionSider->maximum());
Menu::getInstance()->setFaceshiftHostname(ui.faceshiftHostnameEdit->text());
auto faceshift = DependencyManager::get<Faceshift>();
faceshift->setEyeDeflection(ui.faceshiftEyeDeflectionSider->value() /
(float)ui.faceshiftEyeDeflectionSider->maximum());
faceshift->setHostname(ui.faceshiftHostnameEdit->text());
Menu::getInstance()->setMaxOctreePacketsPerSecond(ui.maxOctreePPSSpin->value());