From 3c9f3f392736b56a0641a6f6707c00077b2871bf Mon Sep 17 00:00:00 2001 From: Zander Otavka Date: Wed, 22 Jun 2016 16:22:14 -0700 Subject: [PATCH 1/7] Automatically enter first person when in HMD mode --- interface/src/Application.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index d20a62fc7b..ddfa5dae8b 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -5350,7 +5350,13 @@ void Application::updateDisplayMode() { // reset the avatar, to set head and hand palms back to a reasonable default pose. getMyAvatar()->reset(false); - Q_ASSERT_X(_displayPlugin, "Application::updateDisplayMode", "could not find an activated display plugin"); + // go into first person when they are in HMD mode, since 3rd person HMD is dumb + if (isHMDMode() && !menu->isOptionChecked(MenuOption::FirstPerson)) { + menu->setIsOptionChecked(MenuOption::FirstPerson, true); + cameraMenuChanged(); + } + + Q_ASSERT_X(_displayPlugin, "Application::updateDisplayMode", "could not find an activated display plugin"); } mat4 Application::getEyeProjection(int eye) const { From 7e5b9db13a688100d9d587c1a4147e6a65f15e78 Mon Sep 17 00:00:00 2001 From: Zander Otavka Date: Wed, 22 Jun 2016 16:50:47 -0700 Subject: [PATCH 2/7] Uses spaces, not tabs --- interface/src/Application.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index ddfa5dae8b..53b9c18360 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -5349,14 +5349,14 @@ void Application::updateDisplayMode() { // reset the avatar, to set head and hand palms back to a reasonable default pose. getMyAvatar()->reset(false); - - // go into first person when they are in HMD mode, since 3rd person HMD is dumb - if (isHMDMode() && !menu->isOptionChecked(MenuOption::FirstPerson)) { - menu->setIsOptionChecked(MenuOption::FirstPerson, true); - cameraMenuChanged(); - } - - Q_ASSERT_X(_displayPlugin, "Application::updateDisplayMode", "could not find an activated display plugin"); + + // go into first person when they are in HMD mode, since 3rd person HMD is dumb + if (isHMDMode() && !menu->isOptionChecked(MenuOption::FirstPerson)) { + menu->setIsOptionChecked(MenuOption::FirstPerson, true); + cameraMenuChanged(); + } + + Q_ASSERT_X(_displayPlugin, "Application::updateDisplayMode", "could not find an activated display plugin"); } mat4 Application::getEyeProjection(int eye) const { From 88ad570024a927d80b24fbc036897fa7bb0b971f Mon Sep 17 00:00:00 2001 From: Zander Otavka Date: Fri, 24 Jun 2016 10:16:26 -0700 Subject: [PATCH 3/7] Revert "Uses spaces, not tabs" This reverts commit 7e5b9db13a688100d9d587c1a4147e6a65f15e78. --- interface/src/Application.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 53b9c18360..ddfa5dae8b 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -5349,14 +5349,14 @@ void Application::updateDisplayMode() { // reset the avatar, to set head and hand palms back to a reasonable default pose. getMyAvatar()->reset(false); - - // go into first person when they are in HMD mode, since 3rd person HMD is dumb - if (isHMDMode() && !menu->isOptionChecked(MenuOption::FirstPerson)) { - menu->setIsOptionChecked(MenuOption::FirstPerson, true); - cameraMenuChanged(); - } - - Q_ASSERT_X(_displayPlugin, "Application::updateDisplayMode", "could not find an activated display plugin"); + + // go into first person when they are in HMD mode, since 3rd person HMD is dumb + if (isHMDMode() && !menu->isOptionChecked(MenuOption::FirstPerson)) { + menu->setIsOptionChecked(MenuOption::FirstPerson, true); + cameraMenuChanged(); + } + + Q_ASSERT_X(_displayPlugin, "Application::updateDisplayMode", "could not find an activated display plugin"); } mat4 Application::getEyeProjection(int eye) const { From 41d38ab63045405b7379a1516ebd7056460e97bf Mon Sep 17 00:00:00 2001 From: Zander Otavka Date: Fri, 24 Jun 2016 10:16:40 -0700 Subject: [PATCH 4/7] Revert "Automatically enter first person when in HMD mode" This reverts commit 3c9f3f392736b56a0641a6f6707c00077b2871bf. --- interface/src/Application.cpp | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index ddfa5dae8b..d20a62fc7b 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -5350,13 +5350,7 @@ void Application::updateDisplayMode() { // reset the avatar, to set head and hand palms back to a reasonable default pose. getMyAvatar()->reset(false); - // go into first person when they are in HMD mode, since 3rd person HMD is dumb - if (isHMDMode() && !menu->isOptionChecked(MenuOption::FirstPerson)) { - menu->setIsOptionChecked(MenuOption::FirstPerson, true); - cameraMenuChanged(); - } - - Q_ASSERT_X(_displayPlugin, "Application::updateDisplayMode", "could not find an activated display plugin"); + Q_ASSERT_X(_displayPlugin, "Application::updateDisplayMode", "could not find an activated display plugin"); } mat4 Application::getEyeProjection(int eye) const { From d45694836fe3ffbfe21b8cc0b2642bbadd05e72c Mon Sep 17 00:00:00 2001 From: Zander Otavka Date: Fri, 24 Jun 2016 11:57:12 -0700 Subject: [PATCH 5/7] Add signal for display mode change in HMD --- interface/src/scripting/HMDScriptingInterface.cpp | 3 +++ .../src/display-plugins/AbstractHMDScriptingInterface.h | 1 + 2 files changed, 4 insertions(+) diff --git a/interface/src/scripting/HMDScriptingInterface.cpp b/interface/src/scripting/HMDScriptingInterface.cpp index 7bf1547a3c..9b633ef96d 100644 --- a/interface/src/scripting/HMDScriptingInterface.cpp +++ b/interface/src/scripting/HMDScriptingInterface.cpp @@ -19,6 +19,9 @@ #include "Application.h" HMDScriptingInterface::HMDScriptingInterface() { + connect(qApp, &Application::activeDisplayPluginChanged, [this]{ + emit displayModeChanged(isHMDMode()); + }); } glm::vec3 HMDScriptingInterface::calculateRayUICollisionPoint(const glm::vec3& position, const glm::vec3& direction) const { diff --git a/libraries/display-plugins/src/display-plugins/AbstractHMDScriptingInterface.h b/libraries/display-plugins/src/display-plugins/AbstractHMDScriptingInterface.h index 5df58ce677..f260fa959f 100644 --- a/libraries/display-plugins/src/display-plugins/AbstractHMDScriptingInterface.h +++ b/libraries/display-plugins/src/display-plugins/AbstractHMDScriptingInterface.h @@ -31,6 +31,7 @@ public: signals: void IPDScaleChanged(); + void displayModeChanged(bool isHMDMode); private: float _IPDScale{ 1.0 }; From 0c56af7ae8042982eb1f0969261c7908e513d5f7 Mon Sep 17 00:00:00 2001 From: Zander Otavka Date: Fri, 24 Jun 2016 11:57:50 -0700 Subject: [PATCH 6/7] Add default script to enter first person for HMD --- scripts/defaultScripts.js | 1 + scripts/system/firstPersonHMD.js | 17 +++++++++++++++++ 2 files changed, 18 insertions(+) create mode 100644 scripts/system/firstPersonHMD.js diff --git a/scripts/defaultScripts.js b/scripts/defaultScripts.js index 2a050d183e..f6d9d95ada 100644 --- a/scripts/defaultScripts.js +++ b/scripts/defaultScripts.js @@ -21,3 +21,4 @@ Script.load("system/controllers/handControllerPointer.js"); Script.load("system/controllers/squeezeHands.js"); Script.load("system/controllers/grab.js"); Script.load("system/dialTone.js"); +Script.load("system/firstPersonHMD.js"); diff --git a/scripts/system/firstPersonHMD.js b/scripts/system/firstPersonHMD.js new file mode 100644 index 0000000000..082c6304be --- /dev/null +++ b/scripts/system/firstPersonHMD.js @@ -0,0 +1,17 @@ +// +// firstPersonHMD.js +// system +// +// Created by Zander Otavka on 6/24/16 +// Copyright 2016 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html +// + +// Automatically enter first person mode when entering HMD mode +HMD.displayModeChanged.connect(function(isHMDMode) { + if (isHMDMode) { + Camera.setModeString("first person"); + } +}); From dd023e16fd53c500b6741fd6b7ff60ff05a61501 Mon Sep 17 00:00:00 2001 From: Zander Otavka Date: Fri, 24 Jun 2016 13:16:24 -0700 Subject: [PATCH 7/7] Tabs -> spaces --- interface/src/scripting/HMDScriptingInterface.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/interface/src/scripting/HMDScriptingInterface.cpp b/interface/src/scripting/HMDScriptingInterface.cpp index 9b633ef96d..49c6635fb3 100644 --- a/interface/src/scripting/HMDScriptingInterface.cpp +++ b/interface/src/scripting/HMDScriptingInterface.cpp @@ -19,9 +19,9 @@ #include "Application.h" HMDScriptingInterface::HMDScriptingInterface() { - connect(qApp, &Application::activeDisplayPluginChanged, [this]{ - emit displayModeChanged(isHMDMode()); - }); + connect(qApp, &Application::activeDisplayPluginChanged, [this]{ + emit displayModeChanged(isHMDMode()); + }); } glm::vec3 HMDScriptingInterface::calculateRayUICollisionPoint(const glm::vec3& position, const glm::vec3& direction) const {