From 63c2b4192993da7a8c6bf79dea2b62e4967cf0bb Mon Sep 17 00:00:00 2001 From: luiscuenca Date: Thu, 17 Oct 2019 13:26:42 -0700 Subject: [PATCH] Restate legacy first person camera mode --- .../settingsApp/general/General.qml | 6 +-- interface/src/Application.cpp | 50 +++++++++++-------- interface/src/Menu.cpp | 2 +- interface/src/Menu.h | 3 +- interface/src/avatar/MyAvatar.cpp | 28 ++++++----- .../src/avatars-renderer/Avatar.cpp | 3 +- libraries/shared/src/shared/Camera.cpp | 14 +++++- libraries/shared/src/shared/Camera.h | 1 + scripts/simplifiedUI/ui/simplifiedUI.js | 2 +- scripts/system/firstPersonHMD.js | 2 +- scripts/system/interstitialPage.js | 2 +- scripts/system/libraries/WebTablet.js | 4 +- scripts/system/miniTablet.js | 4 +- 13 files changed, 72 insertions(+), 49 deletions(-) diff --git a/interface/resources/qml/hifi/simplifiedUI/settingsApp/general/General.qml b/interface/resources/qml/hifi/simplifiedUI/settingsApp/general/General.qml index 7a98849b95..6a59816af8 100644 --- a/interface/resources/qml/hifi/simplifiedUI/settingsApp/general/General.qml +++ b/interface/resources/qml/hifi/simplifiedUI/settingsApp/general/General.qml @@ -225,9 +225,9 @@ Flickable { SimplifiedControls.RadioButton { id: firstPerson text: "First Person View" - checked: Camera.mode === "first person" + checked: Camera.mode === "first person look at" onClicked: { - Camera.mode = "first person" + Camera.mode = "first person look at" } } @@ -254,7 +254,7 @@ Flickable { target: Camera onModeUpdated: { - if (Camera.mode === "first person") { + if (Camera.mode === "first person look at") { firstPerson.checked = true } else if (Camera.mode === "look at") { thirdPerson.checked = true diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index a10e17c010..d11c1ac5e0 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -717,7 +717,8 @@ private: static const QString STATE_IN_HMD = "InHMD"; static const QString STATE_CAMERA_FULL_SCREEN_MIRROR = "CameraFSM"; -static const QString STATE_CAMERA_FIRST_PERSON = "CameraFirstPerson"; +static const QString STATE_CAMERA_FIRST_PERSON = "CameraFirstPersonLegacy"; +static const QString STATE_CAMERA_FIRST_PERSON_LOOK_AT = "CameraFirstPersonLookat"; static const QString STATE_CAMERA_THIRD_PERSON = "CameraThirdPerson"; static const QString STATE_CAMERA_ENTITY = "CameraEntity"; static const QString STATE_CAMERA_INDEPENDENT = "CameraIndependent"; @@ -939,7 +940,8 @@ bool setupEssentials(int& argc, char** argv, bool runningMarkerExisted) { DependencyManager::set(); DependencyManager::set(); controller::StateController::setStateVariables({ { STATE_IN_HMD, STATE_CAMERA_FULL_SCREEN_MIRROR, - STATE_CAMERA_FIRST_PERSON, STATE_CAMERA_THIRD_PERSON, STATE_CAMERA_ENTITY, STATE_CAMERA_INDEPENDENT, STATE_CAMERA_LOOK_AT, STATE_CAMERA_SELFIE, + STATE_CAMERA_FIRST_PERSON, STATE_CAMERA_FIRST_PERSON_LOOK_AT, STATE_CAMERA_THIRD_PERSON, + STATE_CAMERA_ENTITY, STATE_CAMERA_INDEPENDENT, STATE_CAMERA_LOOK_AT, STATE_CAMERA_SELFIE, STATE_SNAP_TURN, STATE_ADVANCED_MOVEMENT_CONTROLS, STATE_GROUNDED, STATE_NAV_FOCUSED, STATE_PLATFORM_WINDOWS, STATE_PLATFORM_MAC, STATE_PLATFORM_ANDROID, STATE_LEFT_HAND_DOMINANT, STATE_RIGHT_HAND_DOMINANT, STATE_STRAFE_ENABLED } }); DependencyManager::set(); @@ -1887,6 +1889,9 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo _applicationStateDevice->setInputVariant(STATE_CAMERA_FIRST_PERSON, []() -> float { return qApp->getCamera().getMode() == CAMERA_MODE_FIRST_PERSON ? 1 : 0; }); + _applicationStateDevice->setInputVariant(STATE_CAMERA_FIRST_PERSON_LOOK_AT, []() -> float { + return qApp->getCamera().getMode() == CAMERA_MODE_FIRST_PERSON_LOOK_AT ? 1 : 0; + }); _applicationStateDevice->setInputVariant(STATE_CAMERA_THIRD_PERSON, []() -> float { return qApp->getCamera().getMode() == CAMERA_MODE_THIRD_PERSON ? 1 : 0; }); @@ -1996,7 +2001,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo settingsTimer->start(); }, QThread::LowestPriority); - if (Menu::getInstance()->isOptionChecked(MenuOption::FirstPerson)) { + if (Menu::getInstance()->isOptionChecked(MenuOption::FirstPersonLookAt)) { getMyAvatar()->setBoomLength(MyAvatar::ZOOM_MIN); // So that camera doesn't auto-switch to third person. } @@ -3627,12 +3632,15 @@ void Application::updateCamera(RenderArgs& renderArgs, float deltaTime) { // Using the latter will cause the camera to wobble with idle animations, // or with changes from the face tracker CameraMode mode = _myCamera.getMode(); - if (mode == CAMERA_MODE_FIRST_PERSON) { + if (mode == CAMERA_MODE_FIRST_PERSON || mode == CAMERA_MODE_FIRST_PERSON_LOOK_AT) { _thirdPersonHMDCameraBoomValid= false; if (isHMDMode()) { mat4 camMat = myAvatar->getSensorToWorldMatrix() * myAvatar->getHMDSensorMatrix(); _myCamera.setPosition(extractTranslation(camMat)); _myCamera.setOrientation(glmExtractRotation(camMat)); + } else if (mode == CAMERA_MODE_FIRST_PERSON) { + _myCamera.setPosition(myAvatar->getDefaultEyePosition()); + _myCamera.setOrientation(myAvatar->getMyHead()->getHeadOrientation()); } else { _myCamera.setPosition(myAvatar->getCameraEyesPosition(deltaTime)); _myCamera.setOrientation(myAvatar->getLookAtRotation()); @@ -4423,7 +4431,7 @@ void Application::keyPressEvent(QKeyEvent* event) { case Qt::Key_1: { Menu* menu = Menu::getInstance(); - menu->triggerOption(MenuOption::FirstPerson); + menu->triggerOption(MenuOption::FirstPersonLookAt); break; } case Qt::Key_2: { @@ -5508,7 +5516,7 @@ void Application::loadSettings() { isFirstPerson = menu->isOptionChecked(MenuOption::FirstPersonHMD); } else { // if HMD is not active, only use first person if the menu option is checked - isFirstPerson = menu->isOptionChecked(MenuOption::FirstPerson); + isFirstPerson = menu->isOptionChecked(MenuOption::FirstPersonLookAt); } } } @@ -5523,9 +5531,9 @@ void Application::loadSettings() { // finish initializing the camera, based on everything we checked above. Third person camera will be used if no settings // dictated that we should be in first person - Menu::getInstance()->setIsOptionChecked(MenuOption::FirstPerson, isFirstPerson); + Menu::getInstance()->setIsOptionChecked(MenuOption::FirstPersonLookAt, isFirstPerson); Menu::getInstance()->setIsOptionChecked(MenuOption::ThirdPerson, !isFirstPerson); - _myCamera.setMode((isFirstPerson) ? CAMERA_MODE_FIRST_PERSON : CAMERA_MODE_LOOK_AT); + _myCamera.setMode((isFirstPerson) ? CAMERA_MODE_FIRST_PERSON_LOOK_AT : CAMERA_MODE_LOOK_AT); cameraMenuChanged(); auto inputs = pluginManager->getInputPlugins(); @@ -5689,7 +5697,7 @@ void Application::pauseUntilLoginDetermined() { menu->getMenu("Developer")->setVisible(false); } _previousCameraMode = _myCamera.getMode(); - _myCamera.setMode(CAMERA_MODE_FIRST_PERSON); + _myCamera.setMode(CAMERA_MODE_FIRST_PERSON_LOOK_AT); cameraModeChanged(); // disconnect domain handler. @@ -5878,11 +5886,11 @@ void Application::cycleCamera() { if (menu->isOptionChecked(MenuOption::FullscreenMirror)) { menu->setIsOptionChecked(MenuOption::FullscreenMirror, false); - menu->setIsOptionChecked(MenuOption::FirstPerson, true); + menu->setIsOptionChecked(MenuOption::FirstPersonLookAt, true); - } else if (menu->isOptionChecked(MenuOption::FirstPerson)) { + } else if (menu->isOptionChecked(MenuOption::FirstPersonLookAt)) { - menu->setIsOptionChecked(MenuOption::FirstPerson, false); + menu->setIsOptionChecked(MenuOption::FirstPersonLookAt, false); menu->setIsOptionChecked(MenuOption::LookAtCamera, true); } else if (menu->isOptionChecked(MenuOption::LookAtCamera)) { @@ -5901,8 +5909,8 @@ void Application::cycleCamera() { void Application::cameraModeChanged() { switch (_myCamera.getMode()) { - case CAMERA_MODE_FIRST_PERSON: - Menu::getInstance()->setIsOptionChecked(MenuOption::FirstPerson, true); + case CAMERA_MODE_FIRST_PERSON_LOOK_AT: + Menu::getInstance()->setIsOptionChecked(MenuOption::FirstPersonLookAt, true); break; case CAMERA_MODE_LOOK_AT: Menu::getInstance()->setIsOptionChecked(MenuOption::LookAtCamera, true); @@ -5922,12 +5930,12 @@ void Application::changeViewAsNeeded(float boomLength) { // This is called when the boom length has changed bool boomLengthGreaterThanMinimum = (boomLength > MyAvatar::ZOOM_MIN); - if (_myCamera.getMode() == CAMERA_MODE_FIRST_PERSON && boomLengthGreaterThanMinimum) { - Menu::getInstance()->setIsOptionChecked(MenuOption::FirstPerson, false); + if (_myCamera.getMode() == CAMERA_MODE_FIRST_PERSON_LOOK_AT && boomLengthGreaterThanMinimum) { + Menu::getInstance()->setIsOptionChecked(MenuOption::FirstPersonLookAt, false); Menu::getInstance()->setIsOptionChecked(MenuOption::LookAtCamera, true); cameraMenuChanged(); } else if (_myCamera.getMode() == CAMERA_MODE_LOOK_AT && !boomLengthGreaterThanMinimum) { - Menu::getInstance()->setIsOptionChecked(MenuOption::FirstPerson, true); + Menu::getInstance()->setIsOptionChecked(MenuOption::FirstPersonLookAt, true); Menu::getInstance()->setIsOptionChecked(MenuOption::LookAtCamera, false); cameraMenuChanged(); } @@ -5935,9 +5943,9 @@ void Application::changeViewAsNeeded(float boomLength) { void Application::cameraMenuChanged() { auto menu = Menu::getInstance(); - if (menu->isOptionChecked(MenuOption::FirstPerson)) { - if (_myCamera.getMode() != CAMERA_MODE_FIRST_PERSON) { - _myCamera.setMode(CAMERA_MODE_FIRST_PERSON); + if (menu->isOptionChecked(MenuOption::FirstPersonLookAt)) { + if (_myCamera.getMode() != CAMERA_MODE_FIRST_PERSON_LOOK_AT) { + _myCamera.setMode(CAMERA_MODE_FIRST_PERSON_LOOK_AT); getMyAvatar()->setBoomLength(MyAvatar::ZOOM_MIN); } } else if (menu->isOptionChecked(MenuOption::LookAtCamera)) { @@ -9038,7 +9046,7 @@ void Application::setDisplayPlugin(DisplayPluginPointer newDisplayPlugin) { } if (isHmd && menu->isOptionChecked(MenuOption::FirstPersonHMD)) { - menu->setIsOptionChecked(MenuOption::FirstPerson, true); + menu->setIsOptionChecked(MenuOption::FirstPersonLookAt, true); cameraMenuChanged(); } diff --git a/interface/src/Menu.cpp b/interface/src/Menu.cpp index 5be4db46a0..5a3bb36ca2 100644 --- a/interface/src/Menu.cpp +++ b/interface/src/Menu.cpp @@ -172,7 +172,7 @@ Menu::Menu() { // View > First Person auto firstPersonAction = cameraModeGroup->addAction(addCheckableActionToQMenuAndActionHash( - viewMenu, MenuOption::FirstPerson, 0, + viewMenu, MenuOption::FirstPersonLookAt, 0, true, qApp, SLOT(cameraMenuChanged()))); firstPersonAction->setProperty(EXCLUSION_GROUP_KEY, QVariant::fromValue(cameraModeGroup)); diff --git a/interface/src/Menu.h b/interface/src/Menu.h index e3080e60aa..4a2a97b168 100644 --- a/interface/src/Menu.h +++ b/interface/src/Menu.h @@ -111,7 +111,8 @@ namespace MenuOption { const QString ExpandSimulationTiming = "Expand /simulation"; const QString ExpandPhysicsTiming = "Expand /physics"; const QString ExpandUpdateTiming = "Expand /update"; - const QString FirstPerson = "First Person"; + const QString FirstPerson = "First Person Legacy"; + const QString FirstPersonLookAt = "First Person"; const QString FirstPersonHMD = "Enter First Person Mode in HMD"; const QString FivePointCalibration = "5 Point Calibration"; const QString FixGaze = "Fix Gaze (no saccade)"; diff --git a/interface/src/avatar/MyAvatar.cpp b/interface/src/avatar/MyAvatar.cpp index 207460c0c4..6e0bfab69b 100644 --- a/interface/src/avatar/MyAvatar.cpp +++ b/interface/src/avatar/MyAvatar.cpp @@ -958,7 +958,8 @@ void MyAvatar::simulate(float deltaTime, bool inView) { head->setScale(getModelScale()); head->simulate(deltaTime); CameraMode mode = qApp->getCamera().getMode(); - if (_scriptControlsHeadLookAt || mode == CAMERA_MODE_FIRST_PERSON || mode == CAMERA_MODE_LOOK_AT || mode == CAMERA_MODE_SELFIE) { + if (_scriptControlsHeadLookAt || mode == CAMERA_MODE_FIRST_PERSON_LOOK_AT || mode == CAMERA_MODE_FIRST_PERSON || + mode == CAMERA_MODE_LOOK_AT || mode == CAMERA_MODE_SELFIE) { if (!_pointAtActive || !_isPointTargetValid) { updateHeadLookAt(deltaTime); } else { @@ -2178,7 +2179,7 @@ void MyAvatar::computeMyLookAtTarget(const AvatarHash& hash) { glm::vec3 myForward = _lookAtYaw * IDENTITY_FORWARD; glm::vec3 myPosition = getHead()->getEyePosition(); CameraMode mode = qApp->getCamera().getMode(); - if (mode == CAMERA_MODE_FIRST_PERSON) { + if (mode == CAMERA_MODE_FIRST_PERSON_LOOK_AT || mode == CAMERA_MODE_FIRST_PERSON) { myPosition = qApp->getCamera().getPosition(); } @@ -2719,7 +2720,7 @@ void MyAvatar::updateMotors() { if (_characterController.getState() == CharacterController::State::Hover || _characterController.computeCollisionMask() == BULLET_COLLISION_MASK_COLLISIONLESS) { CameraMode mode = qApp->getCamera().getMode(); - if (!qApp->isHMDMode() && (mode == CAMERA_MODE_FIRST_PERSON || mode == CAMERA_MODE_LOOK_AT || mode == CAMERA_MODE_SELFIE)) { + if (!qApp->isHMDMode() && (mode == CAMERA_MODE_FIRST_PERSON_LOOK_AT || mode == CAMERA_MODE_LOOK_AT || mode == CAMERA_MODE_SELFIE)) { motorRotation = getLookAtRotation(); } else { motorRotation = getMyHead()->getHeadOrientation(); @@ -3399,7 +3400,8 @@ bool MyAvatar::cameraInsideHead(const glm::vec3& cameraPosition) const { bool MyAvatar::shouldRenderHead(const RenderArgs* renderArgs) const { bool defaultMode = renderArgs->_renderMode == RenderArgs::DEFAULT_RENDER_MODE; - bool firstPerson = qApp->getCamera().getMode() == CAMERA_MODE_FIRST_PERSON; + bool firstPerson = qApp->getCamera().getMode() == CAMERA_MODE_FIRST_PERSON_LOOK_AT || + qApp->getCamera().getMode() == CAMERA_MODE_FIRST_PERSON; bool overrideAnim = _skeletonModel ? _skeletonModel->getRig().isPlayingOverrideAnimation() : false; bool insideHead = cameraInsideHead(renderArgs->getViewFrustum().getPosition()); return !defaultMode || (!firstPerson && !insideHead) || (overrideAnim && !insideHead); @@ -3444,8 +3446,8 @@ void MyAvatar::updateOrientation(float deltaTime) { float targetSpeed = getDriveKey(YAW) * _yawSpeed; CameraMode mode = qApp->getCamera().getMode(); bool computeLookAt = isReadyForPhysics() && !qApp->isHMDMode() && - (mode == CAMERA_MODE_FIRST_PERSON || mode == CAMERA_MODE_LOOK_AT || mode == CAMERA_MODE_SELFIE); - bool smoothCameraYaw = computeLookAt && mode != CAMERA_MODE_FIRST_PERSON; + (mode == CAMERA_MODE_FIRST_PERSON_LOOK_AT || mode == CAMERA_MODE_LOOK_AT || mode == CAMERA_MODE_SELFIE); + bool smoothCameraYaw = computeLookAt && mode != CAMERA_MODE_FIRST_PERSON_LOOK_AT; if (smoothCameraYaw) { // For "Look At" and "Selfie" camera modes we also smooth the yaw rotation from right-click mouse movement. float speedFromDeltaYaw = deltaTime > FLT_EPSILON ? getDriveKey(DELTA_YAW) / deltaTime : 0.0f; @@ -3569,11 +3571,11 @@ void MyAvatar::updateOrientation(float deltaTime) { if (isMovingFwdBwd) { if (isMovingSideways) { // Reorient avatar to face camera diagonal - blend = mode == CAMERA_MODE_FIRST_PERSON ? 1.0f : DIAGONAL_TURN_BLEND; + blend = mode == CAMERA_MODE_FIRST_PERSON_LOOK_AT ? 1.0f : DIAGONAL_TURN_BLEND; float turnSign = getDriveKey(TRANSLATE_Z) < 0.0f ? -1.0f : 1.0f; turnSign = getDriveKey(TRANSLATE_X) > 0.0f ? -turnSign : turnSign; faceRotation = _lookAtYaw * glm::angleAxis(turnSign * 0.25f * PI, Vectors::UP); - } else if (mode == CAMERA_MODE_FIRST_PERSON) { + } else if (mode == CAMERA_MODE_FIRST_PERSON_LOOK_AT) { blend = 1.0f; } } @@ -3644,11 +3646,11 @@ void MyAvatar::updateOrientation(float deltaTime) { glm::vec3 ajustedYawVector = cameraYawVector; float limitAngle = 0.0f; float triggerAngle = -glm::sin(glm::radians(TRIGGER_REORIENT_ANGLE)); - if (mode == CAMERA_MODE_FIRST_PERSON) { + if (mode == CAMERA_MODE_FIRST_PERSON_LOOK_AT) { limitAngle = glm::sin(glm::radians(90.0f - FIRST_PERSON_TRIGGER_REORIENT_ANGLE)); triggerAngle = limitAngle; } - float reorientAngle = mode == CAMERA_MODE_FIRST_PERSON ? FIRST_PERSON_REORIENT_ANGLE : DEFAULT_REORIENT_ANGLE; + float reorientAngle = mode == CAMERA_MODE_FIRST_PERSON_LOOK_AT ? FIRST_PERSON_REORIENT_ANGLE : DEFAULT_REORIENT_ANGLE; if (frontBackDot < limitAngle) { if (frontBackDot < 0.0f) { ajustedYawVector = (leftRightDot < 0.0f ? -avatarVectorRight : avatarVectorRight); @@ -3684,7 +3686,7 @@ void MyAvatar::updateOrientation(float deltaTime) { } _headLookAtActive = true; const float FIRST_PERSON_RECENTER_SECONDS = 15.0f; - if (mode == CAMERA_MODE_FIRST_PERSON) { + if (mode == CAMERA_MODE_FIRST_PERSON_LOOK_AT) { if (getDriveKey(YAW) + getDriveKey(STEP_YAW) + getDriveKey(DELTA_YAW) == 0.0f) { if (_firstPersonSteadyHeadTimer < FIRST_PERSON_RECENTER_SECONDS) { if (_firstPersonSteadyHeadTimer > 0.0f) { @@ -3772,7 +3774,7 @@ glm::vec3 MyAvatar::scaleMotorSpeed(const glm::vec3 forward, const glm::vec3 rig // Desktop mode. direction = (zSpeed * forward) + (xSpeed * right); CameraMode mode = qApp->getCamera().getMode(); - if ((mode == CAMERA_MODE_LOOK_AT || mode == CAMERA_MODE_FIRST_PERSON || mode == CAMERA_MODE_SELFIE) && + if ((mode == CAMERA_MODE_LOOK_AT || mode == CAMERA_MODE_FIRST_PERSON_LOOK_AT || mode == CAMERA_MODE_SELFIE) && zSpeed != 0.0f && xSpeed != 0.0f && !isFlying()){ direction = (zSpeed * forward); } @@ -5437,7 +5439,7 @@ glm::quat MyAvatar::getOrientationForAudio() { case AudioListenerMode::FROM_HEAD: { // Using the camera's orientation instead, when the current mode is controlling the avatar's head. CameraMode mode = qApp->getCamera().getMode(); - bool headFollowsCamera = mode == CAMERA_MODE_FIRST_PERSON || mode == CAMERA_MODE_LOOK_AT || mode == CAMERA_MODE_SELFIE; + bool headFollowsCamera = mode == CAMERA_MODE_FIRST_PERSON_LOOK_AT || mode == CAMERA_MODE_LOOK_AT || mode == CAMERA_MODE_SELFIE; result = headFollowsCamera ? qApp->getCamera().getOrientation() : getHead()->getFinalOrientationInWorldFrame(); break; } diff --git a/libraries/avatars-renderer/src/avatars-renderer/Avatar.cpp b/libraries/avatars-renderer/src/avatars-renderer/Avatar.cpp index 7a2ea5321f..d6db75180d 100644 --- a/libraries/avatars-renderer/src/avatars-renderer/Avatar.cpp +++ b/libraries/avatars-renderer/src/avatars-renderer/Avatar.cpp @@ -854,7 +854,8 @@ void Avatar::render(RenderArgs* renderArgs) { float distanceToTarget = glm::length(toTarget); const float DISPLAYNAME_DISTANCE = 20.0f; updateDisplayNameAlpha(distanceToTarget < DISPLAYNAME_DISTANCE); - if (!isMyAvatar() || renderArgs->_cameraMode != (int8_t)CAMERA_MODE_FIRST_PERSON) { + if (!isMyAvatar() || renderArgs->_cameraMode != (int8_t)CAMERA_MODE_FIRST_PERSON_LOOK_AT + || renderArgs->_cameraMode != (int8_t)CAMERA_MODE_FIRST_PERSON) { auto& frustum = renderArgs->getViewFrustum(); auto textPosition = getDisplayNamePosition(); if (frustum.pointIntersectsFrustum(textPosition)) { diff --git a/libraries/shared/src/shared/Camera.cpp b/libraries/shared/src/shared/Camera.cpp index b39b8b9169..6727f89d29 100644 --- a/libraries/shared/src/shared/Camera.cpp +++ b/libraries/shared/src/shared/Camera.cpp @@ -25,8 +25,14 @@ * * First Person * "first person" - * The camera is positioned such that you have the same view as your avatar. The camera moves and rotates with your - * avatar. + * Legacy first person camera mode. The camera is positioned such that you have the same view as your avatar. + * The camera moves and rotates with your avatar. + * + * + * First Person Look At + * "first person look at" + * Default first person camera mode. The camera is positioned such that you have the same view as your avatar. + * The camera moves and rotates with your avatar's head. * * * Third Person @@ -73,6 +79,8 @@ CameraMode stringToMode(const QString& mode) { return CAMERA_MODE_THIRD_PERSON; } else if (mode == "first person") { return CAMERA_MODE_FIRST_PERSON; + } else if (mode == "first person look at") { + return CAMERA_MODE_FIRST_PERSON_LOOK_AT; } else if (mode == "mirror") { return CAMERA_MODE_MIRROR; } else if (mode == "independent") { @@ -92,6 +100,8 @@ QString modeToString(CameraMode mode) { return "third person"; } else if (mode == CAMERA_MODE_FIRST_PERSON) { return "first person"; + } else if (mode == CAMERA_MODE_FIRST_PERSON_LOOK_AT) { + return "first person look at"; } else if (mode == CAMERA_MODE_MIRROR) { return "mirror"; } else if (mode == CAMERA_MODE_INDEPENDENT) { diff --git a/libraries/shared/src/shared/Camera.h b/libraries/shared/src/shared/Camera.h index eecad34838..48cd814d86 100644 --- a/libraries/shared/src/shared/Camera.h +++ b/libraries/shared/src/shared/Camera.h @@ -19,6 +19,7 @@ enum CameraMode { CAMERA_MODE_NULL = -1, CAMERA_MODE_THIRD_PERSON, + CAMERA_MODE_FIRST_PERSON_LOOK_AT, CAMERA_MODE_FIRST_PERSON, CAMERA_MODE_MIRROR, CAMERA_MODE_INDEPENDENT, diff --git a/scripts/simplifiedUI/ui/simplifiedUI.js b/scripts/simplifiedUI/ui/simplifiedUI.js index fc0dd9fddd..3025b938cb 100644 --- a/scripts/simplifiedUI/ui/simplifiedUI.js +++ b/scripts/simplifiedUI/ui/simplifiedUI.js @@ -663,7 +663,7 @@ function handleSecondLaunchWindowVisibleChanged(shouldBeVisible) { function onDisplayModeChanged(isHMDMode) { if (isHMDMode) { - Camera.setModeString("first person"); + Camera.setModeString("first person look at"); } if (isHMDMode) { diff --git a/scripts/system/firstPersonHMD.js b/scripts/system/firstPersonHMD.js index 5fdee1b7b5..5e81d53f6b 100644 --- a/scripts/system/firstPersonHMD.js +++ b/scripts/system/firstPersonHMD.js @@ -16,7 +16,7 @@ // Automatically enter first person mode when entering HMD mode HMD.displayModeChanged.connect(function(isHMDMode) { if (isHMDMode) { - Camera.setModeString("first person"); + Camera.setModeString("first person look at"); } }); diff --git a/scripts/system/interstitialPage.js b/scripts/system/interstitialPage.js index 8ecc982dab..2d225fd2a6 100644 --- a/scripts/system/interstitialPage.js +++ b/scripts/system/interstitialPage.js @@ -272,7 +272,7 @@ currentProgress = 0.0; connectionToDomainFailed = false; previousCameraMode = Camera.mode; - Camera.mode = "first person"; + Camera.mode = "first person look at"; updateProgressBar(0.0); scaleInterstitialPage(MyAvatar.sensorToWorldScale); timer = Script.setTimeout(update, 2000); diff --git a/scripts/system/libraries/WebTablet.js b/scripts/system/libraries/WebTablet.js index 0ee5259ffa..a92fbf1065 100644 --- a/scripts/system/libraries/WebTablet.js +++ b/scripts/system/libraries/WebTablet.js @@ -52,8 +52,8 @@ function calcSpawnInfo(hand, landscape) { var LEFT_HAND = Controller.Standard.LeftHand; var sensorToWorldScale = MyAvatar.sensorToWorldScale; - var headPos = (HMD.active && Camera.mode === "first person") ? HMD.position : Camera.position; - var headRot = Quat.cancelOutRollAndPitch((HMD.active && Camera.mode === "first person") ? + var headPos = (HMD.active && (Camera.mode === "first person" || Camera.mode === "first person look at")) ? HMD.position : Camera.position; + var headRot = Quat.cancelOutRollAndPitch((HMD.active && (Camera.mode === "first person" || Camera.mode === "first person look at")) ? HMD.orientation : Camera.orientation); var right = Quat.getRight(headRot); diff --git a/scripts/system/miniTablet.js b/scripts/system/miniTablet.js index 91c8b1edcf..f5b5ecf0a1 100644 --- a/scripts/system/miniTablet.js +++ b/scripts/system/miniTablet.js @@ -53,7 +53,7 @@ function handJointName(hand) { var jointName; if (hand === LEFT_HAND) { - if (Camera.mode === "first person") { + if (Camera.mode === "first person" || Camera.mode === "first person look at") { jointName = "_CONTROLLER_LEFTHAND"; } else if (Camera.mode === "third person") { jointName = "_CAMERA_RELATIVE_CONTROLLER_LEFTHAND"; @@ -61,7 +61,7 @@ jointName = "LeftHand"; } } else { - if (Camera.mode === "first person") { + if (Camera.mode === "first person" || Camera.mode === "first person look at") { jointName = "_CONTROLLER_RIGHTHAND"; } else if (Camera.mode === "third person") { jointName = "_CAMERA_RELATIVE_CONTROLLER_RIGHTHAND";