mirror of
https://github.com/overte-org/overte.git
synced 2025-08-06 15:29:05 +02:00
Hooked up MyAvatar to playbacks
This commit is contained in:
parent
ff0a5df2d6
commit
792f779bbf
5 changed files with 97 additions and 13 deletions
|
@ -29,6 +29,7 @@
|
||||||
#include "Menu.h"
|
#include "Menu.h"
|
||||||
#include "ModelReferential.h"
|
#include "ModelReferential.h"
|
||||||
#include "Physics.h"
|
#include "Physics.h"
|
||||||
|
#include "Recorder.h"
|
||||||
#include "world.h"
|
#include "world.h"
|
||||||
#include "devices/OculusManager.h"
|
#include "devices/OculusManager.h"
|
||||||
#include "renderer/TextureCache.h"
|
#include "renderer/TextureCache.h"
|
||||||
|
@ -63,6 +64,7 @@ Avatar::Avatar() :
|
||||||
_mouseRayDirection(0.0f, 0.0f, 0.0f),
|
_mouseRayDirection(0.0f, 0.0f, 0.0f),
|
||||||
_moving(false),
|
_moving(false),
|
||||||
_collisionGroups(0),
|
_collisionGroups(0),
|
||||||
|
_player(NULL),
|
||||||
_initialized(false),
|
_initialized(false),
|
||||||
_shouldRenderBillboard(true)
|
_shouldRenderBillboard(true)
|
||||||
{
|
{
|
||||||
|
@ -725,6 +727,17 @@ bool Avatar::findCollisions(const QVector<const Shape*>& shapes, CollisionList&
|
||||||
return collided;
|
return collided;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QVector<glm::quat> Avatar::getJointRotations() const {
|
||||||
|
if (QThread::currentThread() != thread()) {
|
||||||
|
return AvatarData::getJointRotations();
|
||||||
|
}
|
||||||
|
QVector<glm::quat> jointRotations(_skeletonModel.getJointStateCount());
|
||||||
|
for (int i = 0; i < _skeletonModel.getJointStateCount(); ++i) {
|
||||||
|
_skeletonModel.getJointState(i, jointRotations[i]);
|
||||||
|
}
|
||||||
|
return jointRotations;
|
||||||
|
}
|
||||||
|
|
||||||
glm::quat Avatar::getJointRotation(int index) const {
|
glm::quat Avatar::getJointRotation(int index) const {
|
||||||
if (QThread::currentThread() != thread()) {
|
if (QThread::currentThread() != thread()) {
|
||||||
return AvatarData::getJointRotation(index);
|
return AvatarData::getJointRotation(index);
|
||||||
|
|
|
@ -23,6 +23,7 @@
|
||||||
#include "Hand.h"
|
#include "Hand.h"
|
||||||
#include "Head.h"
|
#include "Head.h"
|
||||||
#include "InterfaceConfig.h"
|
#include "InterfaceConfig.h"
|
||||||
|
#include "Recorder.h"
|
||||||
#include "SkeletonModel.h"
|
#include "SkeletonModel.h"
|
||||||
#include "world.h"
|
#include "world.h"
|
||||||
|
|
||||||
|
@ -121,6 +122,7 @@ public:
|
||||||
|
|
||||||
virtual bool isMyAvatar() { return false; }
|
virtual bool isMyAvatar() { return false; }
|
||||||
|
|
||||||
|
virtual QVector<glm::quat> getJointRotations() const;
|
||||||
virtual glm::quat getJointRotation(int index) const;
|
virtual glm::quat getJointRotation(int index) const;
|
||||||
virtual int getJointIndex(const QString& name) const;
|
virtual int getJointIndex(const QString& name) const;
|
||||||
virtual QStringList getJointNames() const;
|
virtual QStringList getJointNames() const;
|
||||||
|
@ -186,6 +188,9 @@ protected:
|
||||||
bool _moving; ///< set when position is changing
|
bool _moving; ///< set when position is changing
|
||||||
|
|
||||||
quint32 _collisionGroups;
|
quint32 _collisionGroups;
|
||||||
|
|
||||||
|
RecorderPointer _recorder;
|
||||||
|
PlayerPointer _player;
|
||||||
|
|
||||||
// protected methods...
|
// protected methods...
|
||||||
glm::vec3 getBodyRightDirection() const { return getOrientation() * IDENTITY_RIGHT; }
|
glm::vec3 getBodyRightDirection() const { return getOrientation() * IDENTITY_RIGHT; }
|
||||||
|
@ -220,8 +225,6 @@ private:
|
||||||
void renderBillboard();
|
void renderBillboard();
|
||||||
|
|
||||||
float getBillboardSize() const;
|
float getBillboardSize() const;
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // hifi_Avatar_h
|
#endif // hifi_Avatar_h
|
||||||
|
|
|
@ -64,13 +64,18 @@ void Head::reset() {
|
||||||
void Head::simulate(float deltaTime, bool isMine, bool billboard) {
|
void Head::simulate(float deltaTime, bool isMine, bool billboard) {
|
||||||
// Update audio trailing average for rendering facial animations
|
// Update audio trailing average for rendering facial animations
|
||||||
if (isMine) {
|
if (isMine) {
|
||||||
FaceTracker* faceTracker = Application::getInstance()->getActiveFaceTracker();
|
MyAvatar* myAvatar = static_cast<MyAvatar*>(_owningAvatar);
|
||||||
if ((_isFaceshiftConnected = faceTracker)) {
|
|
||||||
_blendshapeCoefficients = faceTracker->getBlendshapeCoefficients();
|
// Only use face trackers when not playing back a recording.
|
||||||
_isFaceshiftConnected = true;
|
if (!myAvatar->isPlaying()) {
|
||||||
} else if (Application::getInstance()->getDDE()->isActive()) {
|
FaceTracker* faceTracker = Application::getInstance()->getActiveFaceTracker();
|
||||||
faceTracker = Application::getInstance()->getDDE();
|
if ((_isFaceshiftConnected = faceTracker)) {
|
||||||
_blendshapeCoefficients = faceTracker->getBlendshapeCoefficients();
|
_blendshapeCoefficients = faceTracker->getBlendshapeCoefficients();
|
||||||
|
_isFaceshiftConnected = true;
|
||||||
|
} else if (Application::getInstance()->getDDE()->isActive()) {
|
||||||
|
faceTracker = Application::getInstance()->getDDE();
|
||||||
|
_blendshapeCoefficients = faceTracker->getBlendshapeCoefficients();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -35,6 +35,7 @@
|
||||||
#include "ModelReferential.h"
|
#include "ModelReferential.h"
|
||||||
#include "MyAvatar.h"
|
#include "MyAvatar.h"
|
||||||
#include "Physics.h"
|
#include "Physics.h"
|
||||||
|
#include "Recorder.h"
|
||||||
#include "devices/Faceshift.h"
|
#include "devices/Faceshift.h"
|
||||||
#include "devices/OculusManager.h"
|
#include "devices/OculusManager.h"
|
||||||
#include "ui/TextRenderer.h"
|
#include "ui/TextRenderer.h"
|
||||||
|
@ -135,6 +136,12 @@ void MyAvatar::update(float deltaTime) {
|
||||||
|
|
||||||
void MyAvatar::simulate(float deltaTime) {
|
void MyAvatar::simulate(float deltaTime) {
|
||||||
PerformanceTimer perfTimer("simulate");
|
PerformanceTimer perfTimer("simulate");
|
||||||
|
|
||||||
|
// Play back recording
|
||||||
|
if (_player && _player->isPlaying()) {
|
||||||
|
_player->play();
|
||||||
|
}
|
||||||
|
|
||||||
if (_scale != _targetScale) {
|
if (_scale != _targetScale) {
|
||||||
float scale = (1.0f - SMOOTHING_RATIO) * _scale + SMOOTHING_RATIO * _targetScale;
|
float scale = (1.0f - SMOOTHING_RATIO) * _scale + SMOOTHING_RATIO * _targetScale;
|
||||||
setScale(scale);
|
setScale(scale);
|
||||||
|
@ -147,7 +154,7 @@ void MyAvatar::simulate(float deltaTime) {
|
||||||
updateOrientation(deltaTime);
|
updateOrientation(deltaTime);
|
||||||
updatePosition(deltaTime);
|
updatePosition(deltaTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
PerformanceTimer perfTimer("hand");
|
PerformanceTimer perfTimer("hand");
|
||||||
// update avatar skeleton and simulate hand and head
|
// update avatar skeleton and simulate hand and head
|
||||||
|
@ -242,6 +249,11 @@ void MyAvatar::simulate(float deltaTime) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Record avatars movements.
|
||||||
|
if (_recorder && _recorder->isRecording()) {
|
||||||
|
_recorder->record();
|
||||||
|
}
|
||||||
|
|
||||||
// consider updating our billboard
|
// consider updating our billboard
|
||||||
maybeUpdateBillboard();
|
maybeUpdateBillboard();
|
||||||
}
|
}
|
||||||
|
@ -250,7 +262,10 @@ void MyAvatar::simulate(float deltaTime) {
|
||||||
void MyAvatar::updateFromTrackers(float deltaTime) {
|
void MyAvatar::updateFromTrackers(float deltaTime) {
|
||||||
glm::vec3 estimatedPosition, estimatedRotation;
|
glm::vec3 estimatedPosition, estimatedRotation;
|
||||||
|
|
||||||
if (Application::getInstance()->getPrioVR()->hasHeadRotation()) {
|
if (isPlaying()) {
|
||||||
|
//estimatedPosition = _player->getHeadTranslation();
|
||||||
|
estimatedRotation = glm::degrees(safeEulerAngles(_player->getHeadRotation()));
|
||||||
|
} else if (Application::getInstance()->getPrioVR()->hasHeadRotation()) {
|
||||||
estimatedRotation = glm::degrees(safeEulerAngles(Application::getInstance()->getPrioVR()->getHeadRotation()));
|
estimatedRotation = glm::degrees(safeEulerAngles(Application::getInstance()->getPrioVR()->getHeadRotation()));
|
||||||
estimatedRotation.x *= -1.0f;
|
estimatedRotation.x *= -1.0f;
|
||||||
estimatedRotation.z *= -1.0f;
|
estimatedRotation.z *= -1.0f;
|
||||||
|
@ -286,7 +301,7 @@ void MyAvatar::updateFromTrackers(float deltaTime) {
|
||||||
|
|
||||||
|
|
||||||
Head* head = getHead();
|
Head* head = getHead();
|
||||||
if (OculusManager::isConnected()) {
|
if (OculusManager::isConnected() || isPlaying()) {
|
||||||
head->setDeltaPitch(estimatedRotation.x);
|
head->setDeltaPitch(estimatedRotation.x);
|
||||||
head->setDeltaYaw(estimatedRotation.y);
|
head->setDeltaYaw(estimatedRotation.y);
|
||||||
} else {
|
} else {
|
||||||
|
@ -297,7 +312,7 @@ void MyAvatar::updateFromTrackers(float deltaTime) {
|
||||||
head->setDeltaRoll(estimatedRotation.z);
|
head->setDeltaRoll(estimatedRotation.z);
|
||||||
|
|
||||||
// the priovr can give us exact lean
|
// the priovr can give us exact lean
|
||||||
if (Application::getInstance()->getPrioVR()->isActive()) {
|
if (Application::getInstance()->getPrioVR()->isActive() && !isPlaying()) {
|
||||||
glm::vec3 eulers = glm::degrees(safeEulerAngles(Application::getInstance()->getPrioVR()->getTorsoRotation()));
|
glm::vec3 eulers = glm::degrees(safeEulerAngles(Application::getInstance()->getPrioVR()->getTorsoRotation()));
|
||||||
head->setLeanSideways(eulers.z);
|
head->setLeanSideways(eulers.z);
|
||||||
head->setLeanForward(eulers.x);
|
head->setLeanForward(eulers.x);
|
||||||
|
@ -474,6 +489,45 @@ bool MyAvatar::setJointReferential(int id, int jointIndex) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool MyAvatar::isRecording() const {
|
||||||
|
return _recorder && _recorder->isRecording();
|
||||||
|
}
|
||||||
|
|
||||||
|
RecorderPointer MyAvatar::startRecording() {
|
||||||
|
if (!_recorder) {
|
||||||
|
_recorder = RecorderPointer(new Recorder(this));
|
||||||
|
}
|
||||||
|
_recorder->startRecording();
|
||||||
|
return _recorder;
|
||||||
|
}
|
||||||
|
|
||||||
|
void MyAvatar::stopRecording() {
|
||||||
|
if (_recorder) {
|
||||||
|
_recorder->stopRecording();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool MyAvatar::isPlaying() const {
|
||||||
|
return _player && _player->isPlaying();
|
||||||
|
}
|
||||||
|
|
||||||
|
PlayerPointer MyAvatar::startPlaying() {
|
||||||
|
if (!_player) {
|
||||||
|
_player = PlayerPointer(new Player(this));
|
||||||
|
}
|
||||||
|
if (_recorder) {
|
||||||
|
_player->loadRecording(_recorder->getRecording());
|
||||||
|
_player->startPlaying();
|
||||||
|
}
|
||||||
|
return _player;
|
||||||
|
}
|
||||||
|
|
||||||
|
void MyAvatar::stopPlaying() {
|
||||||
|
if (_player) {
|
||||||
|
_player->stopPlaying();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void MyAvatar::setLocalGravity(glm::vec3 gravity) {
|
void MyAvatar::setLocalGravity(glm::vec3 gravity) {
|
||||||
_motionBehaviors |= AVATAR_MOTION_OBEY_LOCAL_GRAVITY;
|
_motionBehaviors |= AVATAR_MOTION_OBEY_LOCAL_GRAVITY;
|
||||||
// Environmental and Local gravities are incompatible. Since Local is being set here
|
// Environmental and Local gravities are incompatible. Since Local is being set here
|
||||||
|
|
|
@ -155,6 +155,15 @@ public slots:
|
||||||
bool setModelReferential(int id);
|
bool setModelReferential(int id);
|
||||||
bool setJointReferential(int id, int jointIndex);
|
bool setJointReferential(int id, int jointIndex);
|
||||||
|
|
||||||
|
bool isRecording() const;
|
||||||
|
RecorderPointer startRecording();
|
||||||
|
void stopRecording();
|
||||||
|
|
||||||
|
bool isPlaying() const;
|
||||||
|
PlayerPointer startPlaying();
|
||||||
|
void stopPlaying();
|
||||||
|
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void transformChanged();
|
void transformChanged();
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue