mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-08-09 17:10:41 +02:00
More work on PrioVR integration.
This commit is contained in:
parent
f2ba2a48f2
commit
eceb600de7
6 changed files with 108 additions and 21 deletions
|
@ -2752,6 +2752,9 @@ void Application::displayOverlay() {
|
||||||
drawText(_glWidget->width() - 100, _glWidget->height() - timerBottom, 0.30f, 0.0f, 0, frameTimer, WHITE_TEXT);
|
drawText(_glWidget->width() - 100, _glWidget->height() - timerBottom, 0.30f, 0.0f, 0, frameTimer, WHITE_TEXT);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// give external parties a change to hook in
|
||||||
|
emit renderingOverlay();
|
||||||
|
|
||||||
_overlays.render2D();
|
_overlays.render2D();
|
||||||
|
|
||||||
glPopMatrix();
|
glPopMatrix();
|
||||||
|
@ -3060,6 +3063,8 @@ void Application::resetSensors() {
|
||||||
OculusManager::reset();
|
OculusManager::reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_prioVR.reset();
|
||||||
|
|
||||||
QCursor::setPos(_mouseX, _mouseY);
|
QCursor::setPos(_mouseX, _mouseY);
|
||||||
_myAvatar->reset();
|
_myAvatar->reset();
|
||||||
|
|
||||||
|
|
|
@ -195,6 +195,7 @@ public:
|
||||||
Visage* getVisage() { return &_visage; }
|
Visage* getVisage() { return &_visage; }
|
||||||
FaceTracker* getActiveFaceTracker();
|
FaceTracker* getActiveFaceTracker();
|
||||||
SixenseManager* getSixenseManager() { return &_sixenseManager; }
|
SixenseManager* getSixenseManager() { return &_sixenseManager; }
|
||||||
|
PrioVR* getPrioVR() { return &_prioVR; }
|
||||||
BandwidthMeter* getBandwidthMeter() { return &_bandwidthMeter; }
|
BandwidthMeter* getBandwidthMeter() { return &_bandwidthMeter; }
|
||||||
QUndoStack* getUndoStack() { return &_undoStack; }
|
QUndoStack* getUndoStack() { return &_undoStack; }
|
||||||
|
|
||||||
|
@ -268,6 +269,9 @@ signals:
|
||||||
/// Fired when we're rendering in-world interface elements; allows external parties to hook in.
|
/// Fired when we're rendering in-world interface elements; allows external parties to hook in.
|
||||||
void renderingInWorldInterface();
|
void renderingInWorldInterface();
|
||||||
|
|
||||||
|
/// Fired when we're rendering the overlay.
|
||||||
|
void renderingOverlay();
|
||||||
|
|
||||||
/// Fired when the import window is closed
|
/// Fired when the import window is closed
|
||||||
void importDone();
|
void importDone();
|
||||||
|
|
||||||
|
|
|
@ -244,23 +244,28 @@ void MyAvatar::simulate(float deltaTime) {
|
||||||
void MyAvatar::updateFromTrackers(float deltaTime) {
|
void MyAvatar::updateFromTrackers(float deltaTime) {
|
||||||
glm::vec3 estimatedPosition, estimatedRotation;
|
glm::vec3 estimatedPosition, estimatedRotation;
|
||||||
|
|
||||||
FaceTracker* tracker = Application::getInstance()->getActiveFaceTracker();
|
if (Application::getInstance()->getPrioVR()->isActive()) {
|
||||||
if (tracker) {
|
estimatedRotation = glm::degrees(safeEulerAngles(Application::getInstance()->getPrioVR()->getHeadRotation()));
|
||||||
estimatedPosition = tracker->getHeadTranslation();
|
|
||||||
estimatedRotation = glm::degrees(safeEulerAngles(tracker->getHeadRotation()));
|
} else {
|
||||||
|
FaceTracker* tracker = Application::getInstance()->getActiveFaceTracker();
|
||||||
// Rotate the body if the head is turned beyond the screen
|
if (tracker) {
|
||||||
if (Menu::getInstance()->isOptionChecked(MenuOption::TurnWithHead)) {
|
estimatedPosition = tracker->getHeadTranslation();
|
||||||
const float TRACKER_YAW_TURN_SENSITIVITY = 0.5f;
|
estimatedRotation = glm::degrees(safeEulerAngles(tracker->getHeadRotation()));
|
||||||
const float TRACKER_MIN_YAW_TURN = 15.0f;
|
}
|
||||||
const float TRACKER_MAX_YAW_TURN = 50.0f;
|
}
|
||||||
if ( (fabs(estimatedRotation.y) > TRACKER_MIN_YAW_TURN) &&
|
|
||||||
(fabs(estimatedRotation.y) < TRACKER_MAX_YAW_TURN) ) {
|
// Rotate the body if the head is turned beyond the screen
|
||||||
if (estimatedRotation.y > 0.0f) {
|
if (Menu::getInstance()->isOptionChecked(MenuOption::TurnWithHead)) {
|
||||||
_bodyYawDelta += (estimatedRotation.y - TRACKER_MIN_YAW_TURN) * TRACKER_YAW_TURN_SENSITIVITY;
|
const float TRACKER_YAW_TURN_SENSITIVITY = 0.5f;
|
||||||
} else {
|
const float TRACKER_MIN_YAW_TURN = 15.0f;
|
||||||
_bodyYawDelta += (estimatedRotation.y + TRACKER_MIN_YAW_TURN) * TRACKER_YAW_TURN_SENSITIVITY;
|
const float TRACKER_MAX_YAW_TURN = 50.0f;
|
||||||
}
|
if ( (fabs(estimatedRotation.y) > TRACKER_MIN_YAW_TURN) &&
|
||||||
|
(fabs(estimatedRotation.y) < TRACKER_MAX_YAW_TURN) ) {
|
||||||
|
if (estimatedRotation.y > 0.0f) {
|
||||||
|
_bodyYawDelta += (estimatedRotation.y - TRACKER_MIN_YAW_TURN) * TRACKER_YAW_TURN_SENSITIVITY;
|
||||||
|
} else {
|
||||||
|
_bodyYawDelta += (estimatedRotation.y + TRACKER_MIN_YAW_TURN) * TRACKER_YAW_TURN_SENSITIVITY;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -278,6 +283,14 @@ void MyAvatar::updateFromTrackers(float deltaTime) {
|
||||||
head->setDeltaYaw(estimatedRotation.y * magnifyFieldOfView);
|
head->setDeltaYaw(estimatedRotation.y * magnifyFieldOfView);
|
||||||
head->setDeltaRoll(estimatedRotation.z);
|
head->setDeltaRoll(estimatedRotation.z);
|
||||||
|
|
||||||
|
// the priovr can give us exact lean
|
||||||
|
if (Application::getInstance()->getPrioVR()->isActive()) {
|
||||||
|
glm::vec3 eulers = glm::degrees(safeEulerAngles(Application::getInstance()->getPrioVR()->getTorsoRotation()));
|
||||||
|
head->setLeanSideways(eulers.z);
|
||||||
|
head->setLeanForward(eulers.x);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// Update torso lean distance based on accelerometer data
|
// Update torso lean distance based on accelerometer data
|
||||||
const float TORSO_LENGTH = 0.5f;
|
const float TORSO_LENGTH = 0.5f;
|
||||||
glm::vec3 relativePosition = estimatedPosition - glm::vec3(0.0f, -TORSO_LENGTH, 0.0f);
|
glm::vec3 relativePosition = estimatedPosition - glm::vec3(0.0f, -TORSO_LENGTH, 0.0f);
|
||||||
|
|
|
@ -33,14 +33,28 @@ void SkeletonModel::simulate(float deltaTime, bool fullUpdate) {
|
||||||
return; // only simulate for own avatar
|
return; // only simulate for own avatar
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const FBXGeometry& geometry = _geometry->getFBXGeometry();
|
||||||
|
PrioVR* prioVR = Application::getInstance()->getPrioVR();
|
||||||
|
if (prioVR->isActive()) {
|
||||||
|
for (int i = 0; i < prioVR->getJointRotations().size(); i++) {
|
||||||
|
int humanIKJointIndex = prioVR->getHumanIKJointIndices().at(i);
|
||||||
|
if (humanIKJointIndex == -1) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
int jointIndex = geometry.humanIKJointIndices.at(humanIKJointIndex);
|
||||||
|
if (jointIndex != -1) {
|
||||||
|
setJointRotation(jointIndex, _rotation * prioVR->getJointRotations().at(i), true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// find the left and rightmost active Leap palms
|
// find the left and rightmost active Leap palms
|
||||||
int leftPalmIndex, rightPalmIndex;
|
int leftPalmIndex, rightPalmIndex;
|
||||||
Hand* hand = _owningAvatar->getHand();
|
Hand* hand = _owningAvatar->getHand();
|
||||||
hand->getLeftRightPalmIndices(leftPalmIndex, rightPalmIndex);
|
hand->getLeftRightPalmIndices(leftPalmIndex, rightPalmIndex);
|
||||||
|
|
||||||
const float HAND_RESTORATION_RATE = 0.25f;
|
const float HAND_RESTORATION_RATE = 0.25f;
|
||||||
|
|
||||||
const FBXGeometry& geometry = _geometry->getFBXGeometry();
|
|
||||||
if (leftPalmIndex == -1) {
|
if (leftPalmIndex == -1) {
|
||||||
// no Leap data; set hands from mouse
|
// no Leap data; set hands from mouse
|
||||||
if (_owningAvatar->getHandState() == HAND_STATE_NULL) {
|
if (_owningAvatar->getHandState() == HAND_STATE_NULL) {
|
||||||
|
|
|
@ -13,7 +13,9 @@
|
||||||
|
|
||||||
#include <FBXReader.h>
|
#include <FBXReader.h>
|
||||||
|
|
||||||
|
#include "Application.h"
|
||||||
#include "PrioVR.h"
|
#include "PrioVR.h"
|
||||||
|
#include "ui/TextRenderer.h"
|
||||||
|
|
||||||
const unsigned int SERIAL_LIST[] = { 0x00000001, 0x00000000, 0x00000008, 0x00000009, 0x0000000A,
|
const unsigned int SERIAL_LIST[] = { 0x00000001, 0x00000000, 0x00000008, 0x00000009, 0x0000000A,
|
||||||
0x0000000C, 0x0000000D, 0x0000000E, 0x00000004, 0x00000005, 0x00000010, 0x00000011 };
|
0x0000000C, 0x0000000D, 0x0000000E, 0x00000004, 0x00000005, 0x00000010, 0x00000011 };
|
||||||
|
@ -49,7 +51,6 @@ PrioVR::PrioVR() {
|
||||||
for (int i = 0; i < LIST_LENGTH; i++) {
|
for (int i = 0; i < LIST_LENGTH; i++) {
|
||||||
_humanIKJointIndices.append(jointsDiscovered[i] ? indexOfHumanIKJoint(JOINT_NAMES[i]) : -1);
|
_humanIKJointIndices.append(jointsDiscovered[i] ? indexOfHumanIKJoint(JOINT_NAMES[i]) : -1);
|
||||||
}
|
}
|
||||||
yei_tareSensors(_skeletalDevice);
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -61,6 +62,16 @@ PrioVR::~PrioVR() {
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
glm::quat PrioVR::getHeadRotation() const {
|
||||||
|
const int HEAD_ROTATION_INDEX = 0;
|
||||||
|
return _jointRotations.size() > HEAD_ROTATION_INDEX ? _jointRotations.at(HEAD_ROTATION_INDEX) : glm::quat();
|
||||||
|
}
|
||||||
|
|
||||||
|
glm::quat PrioVR::getTorsoRotation() const {
|
||||||
|
const int TORSO_ROTATION_INDEX = 1;
|
||||||
|
return _jointRotations.size() > TORSO_ROTATION_INDEX ? _jointRotations.at(TORSO_ROTATION_INDEX) : glm::quat();
|
||||||
|
}
|
||||||
|
|
||||||
void PrioVR::update() {
|
void PrioVR::update() {
|
||||||
#ifdef HAVE_PRIOVR
|
#ifdef HAVE_PRIOVR
|
||||||
if (!_skeletalDevice) {
|
if (!_skeletalDevice) {
|
||||||
|
@ -71,3 +82,30 @@ void PrioVR::update() {
|
||||||
_jointRotations.size() * sizeof(glm::quat), ×tamp);
|
_jointRotations.size() * sizeof(glm::quat), ×tamp);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void PrioVR::reset() {
|
||||||
|
#ifdef HAVE_PRIOVR
|
||||||
|
if (!_skeletalDevice) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
connect(Application::getInstance(), SIGNAL(renderingOverlay()), SLOT(renderCalibrationCountdown()));
|
||||||
|
_calibrationCountdownStarted = QDateTime::currentDateTime();
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
void PrioVR::renderCalibrationCountdown() {
|
||||||
|
#ifdef HAVE_PRIOVR
|
||||||
|
const int COUNTDOWN_SECONDS = 3;
|
||||||
|
int secondsRemaining = COUNTDOWN_SECONDS - _calibrationCountdownStarted.secsTo(QDateTime::currentDateTime());
|
||||||
|
if (secondsRemaining == 0) {
|
||||||
|
yei_tareSensors(_skeletalDevice);
|
||||||
|
Application::getInstance()->disconnect(this);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
static TextRenderer textRenderer(MONO_FONT_FAMILY, 18, QFont::Bold, false, TextRenderer::OUTLINE_EFFECT, 2);
|
||||||
|
QByteArray text = "Assume T-Pose in " + QByteArray::number(secondsRemaining) + "...";
|
||||||
|
textRenderer.draw((Application::getInstance()->getGLWidget()->width() - textRenderer.computeWidth(text.constData())) / 2,
|
||||||
|
Application::getInstance()->getGLWidget()->height() / 2,
|
||||||
|
text);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
|
@ -12,6 +12,7 @@
|
||||||
#ifndef hifi_PrioVR_h
|
#ifndef hifi_PrioVR_h
|
||||||
#define hifi_PrioVR_h
|
#define hifi_PrioVR_h
|
||||||
|
|
||||||
|
#include <QDateTime>
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QVector>
|
#include <QVector>
|
||||||
|
|
||||||
|
@ -32,10 +33,20 @@ public:
|
||||||
PrioVR();
|
PrioVR();
|
||||||
virtual ~PrioVR();
|
virtual ~PrioVR();
|
||||||
|
|
||||||
|
bool isActive() const { return !_jointRotations.isEmpty(); }
|
||||||
|
|
||||||
|
glm::quat getHeadRotation() const;
|
||||||
|
glm::quat getTorsoRotation() const;
|
||||||
|
|
||||||
const QVector<int>& getHumanIKJointIndices() const { return _humanIKJointIndices; }
|
const QVector<int>& getHumanIKJointIndices() const { return _humanIKJointIndices; }
|
||||||
const QVector<glm::quat>& getJointRotations() const { return _jointRotations; }
|
const QVector<glm::quat>& getJointRotations() const { return _jointRotations; }
|
||||||
|
|
||||||
void update();
|
void update();
|
||||||
|
void reset();
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
|
||||||
|
void renderCalibrationCountdown();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
#ifdef HAVE_PRIOVR
|
#ifdef HAVE_PRIOVR
|
||||||
|
@ -44,6 +55,8 @@ private:
|
||||||
|
|
||||||
QVector<int> _humanIKJointIndices;
|
QVector<int> _humanIKJointIndices;
|
||||||
QVector<glm::quat> _jointRotations;
|
QVector<glm::quat> _jointRotations;
|
||||||
|
|
||||||
|
QDateTime _calibrationCountdownStarted;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // hifi_PrioVR_h
|
#endif // hifi_PrioVR_h
|
||||||
|
|
Loading…
Reference in a new issue