overte/interface/src/devices/Faceshift.h
Andrzej Kapolka c56778c3bf When devices become inactive (including when Faceshift reports loss of
tracking), smoothly restore neutral head rotation/lean.
2013-09-10 11:14:36 -07:00

101 lines
2.4 KiB
C++

//
// Faceshift.h
// interface
//
// Created by Andrzej Kapolka on 9/3/13.
// Copyright (c) 2013 High Fidelity, Inc. All rights reserved.
//
#ifndef __interface__Faceshift__
#define __interface__Faceshift__
#include <QTcpSocket>
#include <glm/glm.hpp>
#include <glm/gtc/quaternion.hpp>
#include <fsbinarystream.h>
/// Handles interaction with the Faceshift software, which provides head position/orientation and facial features.
class Faceshift : public QObject {
Q_OBJECT
public:
Faceshift();
bool isActive() const { return _socket.state() == QAbstractSocket::ConnectedState && _tracking; }
const glm::quat& getHeadRotation() const { return _headRotation; }
const glm::vec3& getHeadTranslation() const { return _headTranslation; }
float getEyeGazeLeftPitch() const { return _eyeGazeLeftPitch; }
float getEyeGazeLeftYaw() const { return _eyeGazeLeftYaw; }
float getEyeGazeRightPitch() const { return _eyeGazeRightPitch; }
float getEyeGazeRightYaw() const { return _eyeGazeRightYaw; }
float getEstimatedEyePitch() const { return _estimatedEyePitch; }
float getEstimatedEyeYaw() const { return _estimatedEyeYaw; }
float getLeftBlink() const { return _leftBlink; }
float getRightBlink() const { return _rightBlink; }
float getBrowHeight() const { return _browHeight; }
float getMouthSize() const { return _mouthSize; }
void update();
void reset();
public slots:
void setEnabled(bool enabled);
private slots:
void connectSocket();
void noteConnected();
void noteError(QAbstractSocket::SocketError error);
void readFromSocket();
private:
void send(const std::string& message);
QTcpSocket _socket;
fs::fsBinaryStream _stream;
bool _enabled;
bool _tracking;
glm::quat _headRotation;
glm::vec3 _headTranslation;
float _eyeGazeLeftPitch;
float _eyeGazeLeftYaw;
float _eyeGazeRightPitch;
float _eyeGazeRightYaw;
float _leftBlink;
float _rightBlink;
int _leftBlinkIndex;
int _rightBlinkIndex;
float _browHeight;
int _browUpCenterIndex;
float _mouthSize;
int _jawOpenIndex;
float _longTermAverageEyePitch;
float _longTermAverageEyeYaw;
float _estimatedEyePitch;
float _estimatedEyeYaw;
};
#endif /* defined(__interface__Faceshift__) */