mirror of
https://github.com/overte-org/overte.git
synced 2025-06-22 22:40:32 +02:00
Generalize "faceshift" data handling to "facetracker"
DDE face tracking data is now broadcast to other avatars.
This commit is contained in:
parent
a66af77b23
commit
d704af21ac
7 changed files with 21 additions and 26 deletions
|
@ -193,7 +193,7 @@ void Agent::run() {
|
||||||
|
|
||||||
// setup an Avatar for the script to use
|
// setup an Avatar for the script to use
|
||||||
ScriptableAvatar scriptedAvatar(&_scriptEngine);
|
ScriptableAvatar scriptedAvatar(&_scriptEngine);
|
||||||
scriptedAvatar.setForceFaceshiftConnected(true);
|
scriptedAvatar.setForceFaceTrackerConnected(true);
|
||||||
|
|
||||||
// call model URL setters with empty URLs so our avatar, if user, will have the default models
|
// call model URL setters with empty URLs so our avatar, if user, will have the default models
|
||||||
scriptedAvatar.setFaceModelURL(QUrl());
|
scriptedAvatar.setFaceModelURL(QUrl());
|
||||||
|
|
|
@ -80,13 +80,8 @@ void Head::simulate(float deltaTime, bool isMine, bool billboard) {
|
||||||
// Only use face trackers when not playing back a recording.
|
// Only use face trackers when not playing back a recording.
|
||||||
if (!myAvatar->isPlaying()) {
|
if (!myAvatar->isPlaying()) {
|
||||||
FaceTracker* faceTracker = Application::getInstance()->getActiveFaceTracker();
|
FaceTracker* faceTracker = Application::getInstance()->getActiveFaceTracker();
|
||||||
auto dde = DependencyManager::get<DdeFaceTracker>();
|
_isFaceTrackerConnected = faceTracker != NULL;
|
||||||
auto faceshift = DependencyManager::get<Faceshift>();
|
if (_isFaceTrackerConnected) {
|
||||||
|
|
||||||
if ((_isFaceshiftConnected = (faceshift == faceTracker))) {
|
|
||||||
_blendshapeCoefficients = faceTracker->getBlendshapeCoefficients();
|
|
||||||
} else if (dde->isActive()) {
|
|
||||||
faceTracker = dde.data();
|
|
||||||
_blendshapeCoefficients = faceTracker->getBlendshapeCoefficients();
|
_blendshapeCoefficients = faceTracker->getBlendshapeCoefficients();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -109,7 +104,7 @@ void Head::simulate(float deltaTime, bool isMine, bool billboard) {
|
||||||
_longTermAverageLoudness = glm::mix(_longTermAverageLoudness, _averageLoudness, glm::min(deltaTime / AUDIO_LONG_TERM_AVERAGING_SECS, 1.0f));
|
_longTermAverageLoudness = glm::mix(_longTermAverageLoudness, _averageLoudness, glm::min(deltaTime / AUDIO_LONG_TERM_AVERAGING_SECS, 1.0f));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(_isFaceshiftConnected || billboard)) {
|
if (!(_isFaceTrackerConnected || billboard)) {
|
||||||
// Update eye saccades
|
// Update eye saccades
|
||||||
const float AVERAGE_MICROSACCADE_INTERVAL = 0.50f;
|
const float AVERAGE_MICROSACCADE_INTERVAL = 0.50f;
|
||||||
const float AVERAGE_SACCADE_INTERVAL = 4.0f;
|
const float AVERAGE_SACCADE_INTERVAL = 4.0f;
|
||||||
|
|
|
@ -44,7 +44,7 @@ AvatarData::AvatarData() :
|
||||||
_handState(0),
|
_handState(0),
|
||||||
_keyState(NO_KEY_DOWN),
|
_keyState(NO_KEY_DOWN),
|
||||||
_isChatCirclingEnabled(false),
|
_isChatCirclingEnabled(false),
|
||||||
_forceFaceshiftConnected(false),
|
_forceFaceTrackerConnected(false),
|
||||||
_hasNewJointRotations(true),
|
_hasNewJointRotations(true),
|
||||||
_headData(NULL),
|
_headData(NULL),
|
||||||
_handData(NULL),
|
_handData(NULL),
|
||||||
|
@ -136,8 +136,8 @@ QByteArray AvatarData::toByteArray() {
|
||||||
if (!_headData) {
|
if (!_headData) {
|
||||||
_headData = new HeadData(this);
|
_headData = new HeadData(this);
|
||||||
}
|
}
|
||||||
if (_forceFaceshiftConnected) {
|
if (_forceFaceTrackerConnected) {
|
||||||
_headData->_isFaceshiftConnected = true;
|
_headData->_isFaceTrackerConnected = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
QByteArray avatarDataByteArray;
|
QByteArray avatarDataByteArray;
|
||||||
|
@ -191,7 +191,7 @@ QByteArray AvatarData::toByteArray() {
|
||||||
setAtBit(bitItems, HAND_STATE_FINGER_POINTING_BIT);
|
setAtBit(bitItems, HAND_STATE_FINGER_POINTING_BIT);
|
||||||
}
|
}
|
||||||
// faceshift state
|
// faceshift state
|
||||||
if (_headData->_isFaceshiftConnected) {
|
if (_headData->_isFaceTrackerConnected) {
|
||||||
setAtBit(bitItems, IS_FACESHIFT_CONNECTED);
|
setAtBit(bitItems, IS_FACESHIFT_CONNECTED);
|
||||||
}
|
}
|
||||||
if (_isChatCirclingEnabled) {
|
if (_isChatCirclingEnabled) {
|
||||||
|
@ -208,7 +208,7 @@ QByteArray AvatarData::toByteArray() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// If it is connected, pack up the data
|
// If it is connected, pack up the data
|
||||||
if (_headData->_isFaceshiftConnected) {
|
if (_headData->_isFaceTrackerConnected) {
|
||||||
memcpy(destinationBuffer, &_headData->_leftEyeBlink, sizeof(float));
|
memcpy(destinationBuffer, &_headData->_leftEyeBlink, sizeof(float));
|
||||||
destinationBuffer += sizeof(float);
|
destinationBuffer += sizeof(float);
|
||||||
|
|
||||||
|
@ -417,7 +417,7 @@ int AvatarData::parseDataAtOffset(const QByteArray& packet, int offset) {
|
||||||
_handState = getSemiNibbleAt(bitItems, HAND_STATE_START_BIT)
|
_handState = getSemiNibbleAt(bitItems, HAND_STATE_START_BIT)
|
||||||
+ (oneAtBit(bitItems, HAND_STATE_FINGER_POINTING_BIT) ? IS_FINGER_POINTING_FLAG : 0);
|
+ (oneAtBit(bitItems, HAND_STATE_FINGER_POINTING_BIT) ? IS_FINGER_POINTING_FLAG : 0);
|
||||||
|
|
||||||
_headData->_isFaceshiftConnected = oneAtBit(bitItems, IS_FACESHIFT_CONNECTED);
|
_headData->_isFaceTrackerConnected = oneAtBit(bitItems, IS_FACESHIFT_CONNECTED);
|
||||||
_isChatCirclingEnabled = oneAtBit(bitItems, IS_CHAT_CIRCLING_ENABLED);
|
_isChatCirclingEnabled = oneAtBit(bitItems, IS_CHAT_CIRCLING_ENABLED);
|
||||||
bool hasReferential = oneAtBit(bitItems, HAS_REFERENTIAL);
|
bool hasReferential = oneAtBit(bitItems, HAS_REFERENTIAL);
|
||||||
|
|
||||||
|
@ -436,7 +436,7 @@ int AvatarData::parseDataAtOffset(const QByteArray& packet, int offset) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (_headData->_isFaceshiftConnected) {
|
if (_headData->_isFaceTrackerConnected) {
|
||||||
float leftEyeBlink, rightEyeBlink, averageLoudness, browAudioLift;
|
float leftEyeBlink, rightEyeBlink, averageLoudness, browAudioLift;
|
||||||
minPossibleSize += sizeof(leftEyeBlink) + sizeof(rightEyeBlink) + sizeof(averageLoudness) + sizeof(browAudioLift);
|
minPossibleSize += sizeof(leftEyeBlink) + sizeof(rightEyeBlink) + sizeof(averageLoudness) + sizeof(browAudioLift);
|
||||||
minPossibleSize++; // one byte for blendDataSize
|
minPossibleSize++; // one byte for blendDataSize
|
||||||
|
|
|
@ -241,7 +241,7 @@ public:
|
||||||
|
|
||||||
Q_INVOKABLE void setBlendshape(QString name, float val) { _headData->setBlendshape(name, val); }
|
Q_INVOKABLE void setBlendshape(QString name, float val) { _headData->setBlendshape(name, val); }
|
||||||
|
|
||||||
void setForceFaceshiftConnected(bool connected) { _forceFaceshiftConnected = connected; }
|
void setForceFaceTrackerConnected(bool connected) { _forceFaceTrackerConnected = connected; }
|
||||||
|
|
||||||
// key state
|
// key state
|
||||||
void setKeyState(KeyState s) { _keyState = s; }
|
void setKeyState(KeyState s) { _keyState = s; }
|
||||||
|
@ -357,7 +357,7 @@ protected:
|
||||||
KeyState _keyState;
|
KeyState _keyState;
|
||||||
|
|
||||||
bool _isChatCirclingEnabled;
|
bool _isChatCirclingEnabled;
|
||||||
bool _forceFaceshiftConnected;
|
bool _forceFaceTrackerConnected;
|
||||||
bool _hasNewJointRotations; // set in AvatarData, cleared in Avatar
|
bool _hasNewJointRotations; // set in AvatarData, cleared in Avatar
|
||||||
|
|
||||||
HeadData* _headData;
|
HeadData* _headData;
|
||||||
|
|
|
@ -31,7 +31,7 @@ HeadData::HeadData(AvatarData* owningAvatar) :
|
||||||
_torsoTwist(0.0f),
|
_torsoTwist(0.0f),
|
||||||
_lookAtPosition(0.0f, 0.0f, 0.0f),
|
_lookAtPosition(0.0f, 0.0f, 0.0f),
|
||||||
_audioLoudness(0.0f),
|
_audioLoudness(0.0f),
|
||||||
_isFaceshiftConnected(false),
|
_isFaceTrackerConnected(false),
|
||||||
_leftEyeBlink(0.0f),
|
_leftEyeBlink(0.0f),
|
||||||
_rightEyeBlink(0.0f),
|
_rightEyeBlink(0.0f),
|
||||||
_averageLoudness(0.0f),
|
_averageLoudness(0.0f),
|
||||||
|
|
|
@ -92,7 +92,7 @@ protected:
|
||||||
|
|
||||||
glm::vec3 _lookAtPosition;
|
glm::vec3 _lookAtPosition;
|
||||||
float _audioLoudness;
|
float _audioLoudness;
|
||||||
bool _isFaceshiftConnected;
|
bool _isFaceTrackerConnected;
|
||||||
float _leftEyeBlink;
|
float _leftEyeBlink;
|
||||||
float _rightEyeBlink;
|
float _rightEyeBlink;
|
||||||
float _averageLoudness;
|
float _averageLoudness;
|
||||||
|
|
|
@ -110,7 +110,7 @@ void Player::startPlaying() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Fake faceshift connection
|
// Fake faceshift connection
|
||||||
_avatar->setForceFaceshiftConnected(true);
|
_avatar->setForceFaceTrackerConnected(true);
|
||||||
|
|
||||||
qDebug() << "Recorder::startPlaying()";
|
qDebug() << "Recorder::startPlaying()";
|
||||||
setupAudioThread();
|
setupAudioThread();
|
||||||
|
@ -136,8 +136,8 @@ void Player::stopPlaying() {
|
||||||
cleanupAudioThread();
|
cleanupAudioThread();
|
||||||
_avatar->clearJointsData();
|
_avatar->clearJointsData();
|
||||||
|
|
||||||
// Turn off fake faceshift connection
|
// Turn off fake face tracker connection
|
||||||
_avatar->setForceFaceshiftConnected(false);
|
_avatar->setForceFaceTrackerConnected(false);
|
||||||
|
|
||||||
if (_useAttachments) {
|
if (_useAttachments) {
|
||||||
_avatar->setAttachmentData(_currentContext.attachments);
|
_avatar->setAttachmentData(_currentContext.attachments);
|
||||||
|
@ -255,8 +255,8 @@ void Player::play() {
|
||||||
|
|
||||||
HeadData* head = const_cast<HeadData*>(_avatar->getHeadData());
|
HeadData* head = const_cast<HeadData*>(_avatar->getHeadData());
|
||||||
if (head) {
|
if (head) {
|
||||||
// Make sure fake faceshift connection doesn't get turned off
|
// Make sure fake face tracker connection doesn't get turned off
|
||||||
_avatar->setForceFaceshiftConnected(true);
|
_avatar->setForceFaceTrackerConnected(true);
|
||||||
|
|
||||||
QVector<float> blendCoef(currentFrame.getBlendshapeCoefficients().size());
|
QVector<float> blendCoef(currentFrame.getBlendshapeCoefficients().size());
|
||||||
for (int i = 0; i < currentFrame.getBlendshapeCoefficients().size(); ++i) {
|
for (int i = 0; i < currentFrame.getBlendshapeCoefficients().size(); ++i) {
|
||||||
|
|
Loading…
Reference in a new issue