From 6f552b4a00495969c39026afe36494e1dd80ddf7 Mon Sep 17 00:00:00 2001 From: Andrzej Kapolka Date: Thu, 30 May 2013 16:26:15 -0700 Subject: [PATCH 1/4] Playing around with using the gyro acceleration to drive the eye offset. --- interface/src/Application.cpp | 7 +++++++ interface/src/Application.h | 1 + 2 files changed, 8 insertions(+) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 262bf6625a..e7b6ee1d80 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -1294,6 +1294,10 @@ void Application::updateAvatar(float deltaTime) { _headMouseY = max(_headMouseY, 0); _headMouseY = min(_headMouseY, _glWidget->height()); + _eyeOffsetVelocity += _serialPort.getLastAcceleration() * deltaTime; + _myCamera.setEyeOffsetPosition(_myCamera.getEyeOffsetPosition() + _eyeOffsetVelocity * deltaTime); + resizeGL(_glWidget->width(), _glWidget->height()); + if (OculusManager::isConnected()) { float yaw, pitch, roll; OculusManager::getEulerAngles(yaw, pitch, roll); @@ -2086,6 +2090,9 @@ void Application::resetSensors() { QCursor::setPos(_headMouseX, _headMouseY); _myAvatar.reset(); _myTransmitter.resetLevels(); + _myCamera.setEyeOffsetPosition(glm::vec3(0.0f, 0.0f, 0.0f)); + _eyeOffsetVelocity = glm::vec3(0.0f, 0.0f, 0.0f); + resizeGL(_glWidget->width(), _glWidget->height()); } static void setShortcutsEnabled(QWidget* widget, bool enabled) { diff --git a/interface/src/Application.h b/interface/src/Application.h index 64959f1274..540ce1796e 100644 --- a/interface/src/Application.h +++ b/interface/src/Application.h @@ -206,6 +206,7 @@ private: Camera _myCamera; // My view onto the world Camera _viewFrustumOffsetCamera; // The camera we use to sometimes show the view frustum from an offset mode + glm::vec3 _eyeOffsetVelocity; Environment _environment; From ffb3cf53aaf053063c26d6c2a2c58e03610e890e Mon Sep 17 00:00:00 2001 From: Andrzej Kapolka Date: Thu, 30 May 2013 16:34:59 -0700 Subject: [PATCH 2/4] Added "Gyro Eye Offset" menu option to drive the eye offset from the gyros. --- interface/src/Application.cpp | 15 ++++++++++----- interface/src/Application.h | 1 + 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index e7b6ee1d80..140d47dc3c 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -299,11 +299,13 @@ void Application::paintGL() { } else if (_myCamera.getMode() == CAMERA_MODE_FIRST_PERSON) { _myCamera.setTargetPosition(_myAvatar.getSpringyHeadPosition()); - _myCamera.setTargetRotation(_myAvatar.getHead().getWorldAlignedOrientation()); + _myCamera.setTargetRotation(_gyroEyeOffset->isChecked() ? _myAvatar.getWorldAlignedOrientation() : + _myAvatar.getHead().getWorldAlignedOrientation()); } else if (_myCamera.getMode() == CAMERA_MODE_THIRD_PERSON) { _myCamera.setTargetPosition(_myAvatar.getHeadPosition()); - _myCamera.setTargetRotation(_myAvatar.getHead().getWorldAlignedOrientation()); + _myCamera.setTargetRotation(_gyroEyeOffset->isChecked() ? _myAvatar.getWorldAlignedOrientation() : + _myAvatar.getHead().getWorldAlignedOrientation()); } // important... @@ -1124,6 +1126,7 @@ void Application::initMenu() { optionsMenu->addAction("Noise", this, SLOT(setNoise(bool)), Qt::Key_N)->setCheckable(true); (_gyroLook = optionsMenu->addAction("Gyro Look"))->setCheckable(true); _gyroLook->setChecked(true); + (_gyroEyeOffset = optionsMenu->addAction("Gyro Eye Offset"))->setCheckable(true); (_mouseLook = optionsMenu->addAction("Mouse Look"))->setCheckable(true); _mouseLook->setChecked(false); (_showHeadMouse = optionsMenu->addAction("Head Mouse"))->setCheckable(true); @@ -1294,9 +1297,11 @@ void Application::updateAvatar(float deltaTime) { _headMouseY = max(_headMouseY, 0); _headMouseY = min(_headMouseY, _glWidget->height()); - _eyeOffsetVelocity += _serialPort.getLastAcceleration() * deltaTime; - _myCamera.setEyeOffsetPosition(_myCamera.getEyeOffsetPosition() + _eyeOffsetVelocity * deltaTime); - resizeGL(_glWidget->width(), _glWidget->height()); + if (_gyroEyeOffset->isChecked()) { + _eyeOffsetVelocity += _serialPort.getLastAcceleration() * deltaTime; + _myCamera.setEyeOffsetPosition(_myCamera.getEyeOffsetPosition() + _eyeOffsetVelocity * deltaTime); + resizeGL(_glWidget->width(), _glWidget->height()); + } if (OculusManager::isConnected()) { float yaw, pitch, roll; diff --git a/interface/src/Application.h b/interface/src/Application.h index 540ce1796e..d4caeca329 100644 --- a/interface/src/Application.h +++ b/interface/src/Application.h @@ -143,6 +143,7 @@ private: QAction* _lookingInMirror; // Are we currently rendering one's own head as if in mirror? QAction* _echoAudioMode; // Are we asking the mixer to echo back our audio? QAction* _gyroLook; // Whether to allow the gyro data from head to move your view + QAction* _gyroEyeOffset; // Whether to allow the gyro data to move your eye offset QAction* _mouseLook; // Whether the have the mouse near edge of screen move your view QAction* _showHeadMouse; // Whether the have the mouse near edge of screen move your view QAction* _transmitterDrives; // Whether to have Transmitter data move/steer the Avatar From cb1e1cc3ddb86484dc069c47d067e6f8a7655a44 Mon Sep 17 00:00:00 2001 From: Andrzej Kapolka Date: Thu, 30 May 2013 16:51:08 -0700 Subject: [PATCH 3/4] Not going down that path. --- interface/src/Application.cpp | 16 ++-------------- interface/src/Application.h | 2 -- 2 files changed, 2 insertions(+), 16 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 140d47dc3c..262bf6625a 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -299,13 +299,11 @@ void Application::paintGL() { } else if (_myCamera.getMode() == CAMERA_MODE_FIRST_PERSON) { _myCamera.setTargetPosition(_myAvatar.getSpringyHeadPosition()); - _myCamera.setTargetRotation(_gyroEyeOffset->isChecked() ? _myAvatar.getWorldAlignedOrientation() : - _myAvatar.getHead().getWorldAlignedOrientation()); + _myCamera.setTargetRotation(_myAvatar.getHead().getWorldAlignedOrientation()); } else if (_myCamera.getMode() == CAMERA_MODE_THIRD_PERSON) { _myCamera.setTargetPosition(_myAvatar.getHeadPosition()); - _myCamera.setTargetRotation(_gyroEyeOffset->isChecked() ? _myAvatar.getWorldAlignedOrientation() : - _myAvatar.getHead().getWorldAlignedOrientation()); + _myCamera.setTargetRotation(_myAvatar.getHead().getWorldAlignedOrientation()); } // important... @@ -1126,7 +1124,6 @@ void Application::initMenu() { optionsMenu->addAction("Noise", this, SLOT(setNoise(bool)), Qt::Key_N)->setCheckable(true); (_gyroLook = optionsMenu->addAction("Gyro Look"))->setCheckable(true); _gyroLook->setChecked(true); - (_gyroEyeOffset = optionsMenu->addAction("Gyro Eye Offset"))->setCheckable(true); (_mouseLook = optionsMenu->addAction("Mouse Look"))->setCheckable(true); _mouseLook->setChecked(false); (_showHeadMouse = optionsMenu->addAction("Head Mouse"))->setCheckable(true); @@ -1297,12 +1294,6 @@ void Application::updateAvatar(float deltaTime) { _headMouseY = max(_headMouseY, 0); _headMouseY = min(_headMouseY, _glWidget->height()); - if (_gyroEyeOffset->isChecked()) { - _eyeOffsetVelocity += _serialPort.getLastAcceleration() * deltaTime; - _myCamera.setEyeOffsetPosition(_myCamera.getEyeOffsetPosition() + _eyeOffsetVelocity * deltaTime); - resizeGL(_glWidget->width(), _glWidget->height()); - } - if (OculusManager::isConnected()) { float yaw, pitch, roll; OculusManager::getEulerAngles(yaw, pitch, roll); @@ -2095,9 +2086,6 @@ void Application::resetSensors() { QCursor::setPos(_headMouseX, _headMouseY); _myAvatar.reset(); _myTransmitter.resetLevels(); - _myCamera.setEyeOffsetPosition(glm::vec3(0.0f, 0.0f, 0.0f)); - _eyeOffsetVelocity = glm::vec3(0.0f, 0.0f, 0.0f); - resizeGL(_glWidget->width(), _glWidget->height()); } static void setShortcutsEnabled(QWidget* widget, bool enabled) { diff --git a/interface/src/Application.h b/interface/src/Application.h index d4caeca329..64959f1274 100644 --- a/interface/src/Application.h +++ b/interface/src/Application.h @@ -143,7 +143,6 @@ private: QAction* _lookingInMirror; // Are we currently rendering one's own head as if in mirror? QAction* _echoAudioMode; // Are we asking the mixer to echo back our audio? QAction* _gyroLook; // Whether to allow the gyro data from head to move your view - QAction* _gyroEyeOffset; // Whether to allow the gyro data to move your eye offset QAction* _mouseLook; // Whether the have the mouse near edge of screen move your view QAction* _showHeadMouse; // Whether the have the mouse near edge of screen move your view QAction* _transmitterDrives; // Whether to have Transmitter data move/steer the Avatar @@ -207,7 +206,6 @@ private: Camera _myCamera; // My view onto the world Camera _viewFrustumOffsetCamera; // The camera we use to sometimes show the view frustum from an offset mode - glm::vec3 _eyeOffsetVelocity; Environment _environment; From 224e5d666dc005927d3931510a3c752e686fed9b Mon Sep 17 00:00:00 2001 From: Andrzej Kapolka Date: Thu, 30 May 2013 17:12:18 -0700 Subject: [PATCH 4/4] Fix for segmentation fault when the settings file doesn't exist. --- interface/src/Application.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 68f4e7bf19..4dd3dba178 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -774,9 +774,9 @@ void Application::readSettingsFile() { } } } - } - fclose(settingsFile); + fclose(settingsFile); + } } void Application::saveSettingsFile() {