OpenVR: More usable UI Sphere overlay location

Also, added a debug option to display SensorToWorld matrix in Developer > Avatar menu.
This commit is contained in:
Anthony Thibault 2016-03-09 16:24:08 -08:00
parent 4af3766804
commit 5df616be37
6 changed files with 33 additions and 9 deletions

View file

@ -3288,14 +3288,6 @@ void Application::update(float deltaTime) {
// update sensorToWorldMatrix for rendering camera.
myAvatar->updateSensorToWorldMatrix();
// AJT: TODO: make this a menu item.
const bool DRAW_SENSOR_TO_WORLD_MATRIX = true;
if (DRAW_SENSOR_TO_WORLD_MATRIX) {
// draw the origin of the room in world space.
glm::mat4 m = myAvatar->getSensorToWorldMatrix();
DebugDraw::getInstance().addMarker("room", glmExtractRotation(m), extractTranslation(m), glm::vec4(1));
}
}

View file

@ -471,6 +471,8 @@ Menu::Menu() {
avatar, SLOT(setUseAnimPreAndPostRotations(bool)));
addCheckableActionToQMenuAndActionHash(avatarDebugMenu, MenuOption::EnableInverseKinematics, 0, true,
avatar, SLOT(setEnableInverseKinematics(bool)));
addCheckableActionToQMenuAndActionHash(avatarDebugMenu, MenuOption::RenderSensorToWorldMatrix, 0, false,
avatar, SLOT(setEnableDebugDrawSensorToWorldMatrix(bool)));
addCheckableActionToQMenuAndActionHash(avatarDebugMenu, MenuOption::KeyboardMotorControl,
Qt::CTRL | Qt::SHIFT | Qt::Key_K, true, avatar, SLOT(updateMotionBehaviorFromMenu()),

View file

@ -144,6 +144,7 @@ namespace MenuOption {
const QString RenderResolutionHalf = "1/2";
const QString RenderResolutionThird = "1/3";
const QString RenderResolutionQuarter = "1/4";
const QString RenderSensorToWorldMatrix = "Show SensorToWorld Matrix";
const QString ResetAvatarSize = "Reset Avatar Size";
const QString ResetSensors = "Reset Sensors";
const QString RunningScripts = "Running Scripts...";

View file

@ -442,6 +442,10 @@ void MyAvatar::updateSensorToWorldMatrix() {
_sensorToWorldMatrix = desiredMat * glm::inverse(_bodySensorMatrix);
lateUpdatePalms();
if (_enableDebugDrawSensorToWorldMatrix) {
DebugDraw::getInstance().addMarker("sensorToWorldMatrix", glmExtractRotation(_sensorToWorldMatrix), extractTranslation(_sensorToWorldMatrix), glm::vec4(1));
}
}
// Update avatar head rotation with sensor data
@ -695,6 +699,14 @@ void MyAvatar::setEnableDebugDrawPosition(bool isEnabled) {
}
}
void MyAvatar::setEnableDebugDrawSensorToWorldMatrix(bool isEnabled) {
_enableDebugDrawSensorToWorldMatrix = isEnabled;
if (!isEnabled) {
DebugDraw::getInstance().removeMarker("sensorToWorldMatrix");
}
}
void MyAvatar::setEnableMeshVisible(bool isEnabled) {
render::ScenePointer scene = qApp->getMain3DScene();
_skeletonModel.setVisibleInScene(isEnabled, scene);

View file

@ -267,6 +267,7 @@ public slots:
void setEnableDebugDrawDefaultPose(bool isEnabled);
void setEnableDebugDrawAnimPose(bool isEnabled);
void setEnableDebugDrawPosition(bool isEnabled);
void setEnableDebugDrawSensorToWorldMatrix(bool isEnabled);
bool getEnableMeshVisible() const { return _skeletonModel.isVisible(); }
void setEnableMeshVisible(bool isEnabled);
void setUseAnimPreAndPostRotations(bool isEnabled);
@ -429,6 +430,7 @@ private:
bool _enableDebugDrawDefaultPose { false };
bool _enableDebugDrawAnimPose { false };
bool _enableDebugDrawSensorToWorldMatrix { false };
AudioListenerMode _audioListenerMode;
glm::vec3 _customListenPosition;

View file

@ -68,6 +68,21 @@ void OpenVrDisplayPlugin::activate() {
_compositor = vr::VRCompositor();
Q_ASSERT(_compositor);
HmdDisplayPlugin::activate();
// set up default sensor space such that the UI overlay will align with the front of the room.
auto chaperone = vr::VRChaperone();
if (chaperone) {
float const UI_RADIUS = 1.0f;
float const UI_HEIGHT = 1.6f;
float const UI_Z_OFFSET = 0.5;
float xSize, zSize;
chaperone->GetPlayAreaSize(&xSize, &zSize);
glm::vec3 uiPos(0.0f, UI_HEIGHT, 0.5f * zSize - UI_RADIUS + UI_Z_OFFSET);
_sensorResetMat = glm::inverse(createMatFromQuatAndPos(Quaternions::Y_180, uiPos));
} else {
qDebug() << "OpenVR: error could not get chaperone pointer";
}
}
void OpenVrDisplayPlugin::deactivate() {
@ -115,7 +130,7 @@ glm::mat4 OpenVrDisplayPlugin::getHeadPose(uint32_t frameIndex) const {
#endif
vr::TrackedDevicePose_t predictedTrackedDevicePose[vr::k_unMaxTrackedDeviceCount];
_system->GetDeviceToAbsoluteTrackingPose(vr::TrackingUniverseSeated, predictedSecondsFromNow, predictedTrackedDevicePose, vr::k_unMaxTrackedDeviceCount);
_system->GetDeviceToAbsoluteTrackingPose(vr::TrackingUniverseStanding, predictedSecondsFromNow, predictedTrackedDevicePose, vr::k_unMaxTrackedDeviceCount);
// copy and process predictedTrackedDevicePoses
for (int i = 0; i < vr::k_unMaxTrackedDeviceCount; i++) {