adding class for creating overlay and lasers

This commit is contained in:
Wayne Chen 2018-11-05 17:29:01 -08:00
parent 9deeee6534
commit 77b47d4b32
8 changed files with 344 additions and 76 deletions

View file

@ -5889,6 +5889,9 @@ void Application::update(float deltaTime) {
if (keyboardMousePlugin && keyboardMousePlugin->isActive()) {
keyboardMousePlugin->pluginUpdate(deltaTime, calibrationData);
}
if (!_loginDialogOverlayID.isNull()) {
_loginPointerManager.update();
}
// Transfer the user inputs to the driveKeys
// FIXME can we drop drive keys and just have the avatar read the action states directly?
@ -8517,13 +8520,7 @@ void Application::checkReadyToCreateLoginDialogOverlay() {
if (qApp->isHMDMode() && qApp->getActiveDisplayPlugin()->isDisplayVisible() && qApp->getLoginDialogPoppedUp() && _loginDialogOverlayID.isNull()) {
createLoginDialogOverlay();
} else if (qApp->getLoginDialogPoppedUp() && !qApp->isHMDMode()) {
auto pointer = DependencyManager::get<PointerScriptingInterface>().data();
if (_leftLoginPointerID > 0) {
pointer->disablePointer(_leftLoginPointerID);
}
if (_rightLoginPointerID > 0) {
pointer->disablePointer(_rightLoginPointerID);
}
_loginPointerManager.~LoginPointerManager();
}
}
@ -8545,61 +8542,62 @@ void Application::createLoginDialogOverlay() {
{ "dpi", overlayDpi },
{ "visible", true }
};
auto pointer = DependencyManager::get<PointerScriptingInterface>().data();
auto standard = _controllerScriptingInterface->getStandard();
_loginPointerManager.init();
//auto pointer = DependencyManager::get<PointerScriptingInterface>().data();
//auto standard = _controllerScriptingInterface->getStandard();
glm::vec3 grabPointSphereOffsetLeft { 0.04, 0.13, 0.039 }; // x = upward, y = forward, z = lateral
glm::vec3 grabPointSphereOffsetRight { -0.04, 0.13, 0.039 }; // x = upward, y = forward, z = lateral
//glm::vec3 grabPointSphereOffsetLeft { 0.04, 0.13, 0.039 }; // x = upward, y = forward, z = lateral
//glm::vec3 grabPointSphereOffsetRight { -0.04, 0.13, 0.039 }; // x = upward, y = forward, z = lateral
QList<QVariant> leftPointerTriggerProperties;
QVariantMap ltClick1 {
{ "action", controller::StandardButtonChannel::LT_CLICK },
{ "button", "Focus" }
};
QVariantMap ltClick2 {
{ "action", controller::StandardButtonChannel::LT_CLICK },
{ "button", "Primary" }
};
//QList<QVariant> leftPointerTriggerProperties;
//QVariantMap ltClick1 {
// { "action", controller::StandardButtonChannel::LT_CLICK },
// { "button", "Focus" }
//};
//QVariantMap ltClick2 {
// { "action", controller::StandardButtonChannel::LT_CLICK },
// { "button", "Primary" }
//};
leftPointerTriggerProperties.append(ltClick1);
leftPointerTriggerProperties.append(ltClick2);
const unsigned int leftHand = 0;
QVariantMap leftPointerProperties {
{ "joint", "_CAMERA_RELATIVE_CONTROLLER_LEFTHAND" },
{ "filter", PickFilter::PICK_OVERLAYS },
{ "triggers", leftPointerTriggerProperties },
{ "posOffset", vec3toVariant(grabPointSphereOffsetLeft) },
{ "hover", true },
{ "distanceScaleEnd", true },
{ "hand", leftHand }
};
_leftLoginPointerID = pointer->createPointer(PickQuery::PickType::Ray, leftPointerProperties);
pointer->setRenderState(_leftLoginPointerID, "");
pointer->enablePointer(_leftLoginPointerID);
const unsigned int rightHand = 1;
QList<QVariant> rightPointerTriggerProperties;
QVariantMap rtClick1 {
{ "action", controller::StandardButtonChannel::RT_CLICK },
{ "button", "Focus" }
};
QVariantMap rtClick2 {
{ "action", controller::StandardButtonChannel::RT_CLICK },
{ "button", "Primary" }
};
rightPointerTriggerProperties.append(rtClick1);
rightPointerTriggerProperties.append(rtClick2);
QVariantMap rightPointerProperties{
{ "joint", "_CAMERA_RELATIVE_CONTROLLER_LEFTHAND" },
{ "filter", PickFilter::PICK_OVERLAYS },
{ "triggers", rightPointerTriggerProperties },
{ "posOffset", vec3toVariant(grabPointSphereOffsetRight) },
{ "hover", true },
{ "distanceScaleEnd", true },
{ "hand", rightHand }
};
_rightLoginPointerID = pointer->createPointer(PickQuery::PickType::Ray, rightPointerProperties);
pointer->setRenderState(_rightLoginPointerID, "");
pointer->enablePointer(_rightLoginPointerID);
//leftPointerTriggerProperties.append(ltClick1);
//leftPointerTriggerProperties.append(ltClick2);
//const unsigned int leftHand = 0;
//QVariantMap leftPointerProperties {
// { "joint", "_CAMERA_RELATIVE_CONTROLLER_LEFTHAND" },
// { "filter", PickFilter::PICK_OVERLAYS },
// { "triggers", leftPointerTriggerProperties },
// { "posOffset", vec3toVariant(grabPointSphereOffsetLeft) },
// { "hover", true },
// { "distanceScaleEnd", true },
// { "hand", leftHand }
//};
//_leftLoginPointerID = pointer->createPointer(PickQuery::PickType::Ray, leftPointerProperties);
//pointer->setRenderState(_leftLoginPointerID, "");
//pointer->enablePointer(_leftLoginPointerID);
//const unsigned int rightHand = 1;
//QList<QVariant> rightPointerTriggerProperties;
//QVariantMap rtClick1 {
// { "action", controller::StandardButtonChannel::RT_CLICK },
// { "button", "Focus" }
//};
//QVariantMap rtClick2 {
// { "action", controller::StandardButtonChannel::RT_CLICK },
// { "button", "Primary" }
//};
//rightPointerTriggerProperties.append(rtClick1);
//rightPointerTriggerProperties.append(rtClick2);
//QVariantMap rightPointerProperties{
// { "joint", "_CAMERA_RELATIVE_CONTROLLER_LEFTHAND" },
// { "filter", PickFilter::PICK_OVERLAYS },
// { "triggers", rightPointerTriggerProperties },
// { "posOffset", vec3toVariant(grabPointSphereOffsetRight) },
// { "hover", true },
// { "distanceScaleEnd", true },
// { "hand", rightHand }
//};
//_rightLoginPointerID = pointer->createPointer(PickQuery::PickType::Ray, rightPointerProperties);
//pointer->setRenderState(_rightLoginPointerID, "");
//pointer->enablePointer(_rightLoginPointerID);
_loginDialogOverlayID = overlays.addOverlay("web3d", overlayProperties);
}
@ -8613,12 +8611,6 @@ void Application::onDismissedLoginDialog() {
qDebug() << "Deleting overlay";
getOverlays().deleteOverlay(_loginDialogOverlayID);
}
if (_leftLoginPointerID > 0) {
pointer->disablePointer(_leftLoginPointerID);
}
if (_rightLoginPointerID > 0) {
pointer->disablePointer(_rightLoginPointerID);
}
resumeAfterLoginDialogActionTaken();
}

View file

@ -56,6 +56,7 @@
#include "ConnectionMonitor.h"
#include "CursorManager.h"
#include "gpu/Context.h"
#include "LoginPointerManager.h"
#include "Menu.h"
#include "octree/OctreePacketProcessor.h"
#include "render/Engine.h"
@ -688,8 +689,7 @@ private:
bool _loginDialogPoppedUp = false;
OverlayID _loginDialogOverlayID;
unsigned int _leftLoginPointerID { PointerEvent::INVALID_POINTER_ID };
unsigned int _rightLoginPointerID { PointerEvent::INVALID_POINTER_ID };
LoginPointerManager _loginPointerManager;
quint64 _lastFaceTrackerUpdate;

View file

@ -0,0 +1,240 @@
//
// LoginPointerManager.cpp
// interface/src
//
// Created by Wayne Chen on 11/5/18.
// Copyright 2018 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
//
#include "LoginPointerManager.h"
#include <QtCore/QString>
#include <QtCore/QVariantMap>
#include <RegisteredMetaTypes.h>
#include "controllers/StateController.h"
#include "controllers/UserInputMapper.h"
#include "raypick/PointerScriptingInterface.h"
#include "raypick/PickScriptingInterface.h"
#include "scripting/ControllerScriptingInterface.h"
static const float SEARCH_SPHERE_SIZE = 0.0132f;
static const QVariantMap SEARCH_SPHERE = {{"x", SEARCH_SPHERE_SIZE},
{"y", SEARCH_SPHERE_SIZE},
{"z", SEARCH_SPHERE_SIZE}};
static const int DEFAULT_SEARCH_SPHERE_DISTANCE = 1000; // how far from camera to search intersection?
static const QVariantMap COLORS_GRAB_SEARCHING_HALF_SQUEEZE = {{"red", 10},
{"green", 10},
{"blue", 255}};
static const QVariantMap COLORS_GRAB_SEARCHING_FULL_SQUEEZE = {{"red", 250},
{"green", 10},
{"blue", 10}};
static const QVariantMap COLORS_GRAB_DISTANCE_HOLD = {{"red", 238},
{"green", 75},
{"blue", 214}};
LoginPointerManager::~LoginPointerManager() {
auto pointers = DependencyManager::get<PointerManager>();
if (pointers) {
if (leftLoginPointerID() != PointerEvent::INVALID_POINTER_ID) {
pointers->removePointer(leftLoginPointerID());
}
if (rightLoginPointerID() != PointerEvent::INVALID_POINTER_ID) {
pointers->removePointer(rightLoginPointerID());
}
}
}
void LoginPointerManager::init() {
QVariantMap fullPathRenderState {
{"type", "line3d"},
{"color", COLORS_GRAB_SEARCHING_FULL_SQUEEZE},
{"visible", true},
{"alpha", 1.0f},
{"solid", true},
{"glow", 1.0f},
{"ignoreRayIntersection", true}, // always ignore this
{"drawInFront", true}, // Even when burried inside of something, show it.
{"drawHUDLayer", false}
};
QVariantMap fullEndRenderState {
{"type", "sphere"},
{"dimensions", SEARCH_SPHERE},
{"solid", true},
{"color", COLORS_GRAB_SEARCHING_FULL_SQUEEZE},
{"alpha", 0.9f},
{"ignoreRayIntersection", true},
{"drawInFront", true}, // Even when burried inside of something, show it.
{"drawHUDLayer", false},
{"visible", true}
};
QVariantMap halfPathRenderState {
{"type", "line3d"},
{"color", COLORS_GRAB_SEARCHING_HALF_SQUEEZE},
{"visible", true},
{"alpha", 1.0f},
{"solid", true},
{"glow", 1.0f},
{"ignoreRayIntersection", true}, // always ignore this
{"drawInFront", true}, // Even when burried inside of something, show it.
{"drawHUDLayer", false}
};
QVariantMap halfEndRenderState {
{"type", "sphere"},
{"dimensions", SEARCH_SPHERE},
{"solid", true},
{"color", COLORS_GRAB_SEARCHING_HALF_SQUEEZE},
{"alpha", 0.9f},
{"ignoreRayIntersection", true},
{"drawInFront", true}, // Even when burried inside of something, show it.
{"drawHUDLayer", false},
{"visible", true}
};
QVariantMap holdPathRenderState {
{"type", "line3d"},
{"color", COLORS_GRAB_DISTANCE_HOLD},
{"visible", true},
{"alpha", 1.0f},
{"solid", true},
{"glow", 1.0f},
{"ignoreRayIntersection", true}, // always ignore this
{"drawInFront", true}, // Even when burried inside of something, show it.
{"drawHUDLayer", false},
};
QVariantMap halfRenderStateIdentifier {
{"name", "half"},
{"path", halfPathRenderState},
{"end", halfEndRenderState}
};
QVariantMap fullRenderStateIdentifier {
{"name", "full"},
{"path", fullPathRenderState},
{"end", fullEndRenderState}
};
QVariantMap holdRenderStateIdentifier {
{"name", "hold"},
{"path", holdPathRenderState},
};
QVariantMap halfDefaultRenderStateIdentifier {
{"name", "half"},
{"distance", DEFAULT_SEARCH_SPHERE_DISTANCE},
{"path", halfPathRenderState}
};
QVariantMap fullDefaultRenderStateIdentifier {
{"name", "full"},
{"distance", DEFAULT_SEARCH_SPHERE_DISTANCE},
{"path", fullPathRenderState}
};
QVariantMap holdDefaultRenderStateIdentifier {
{"name", "hold"},
{"distance", DEFAULT_SEARCH_SPHERE_DISTANCE},
{"path", holdPathRenderState}
};
_renderStates = QList<QVariant>({halfRenderStateIdentifier, fullRenderStateIdentifier, holdRenderStateIdentifier});
_defaultRenderStates = QList<QVariant>({halfDefaultRenderStateIdentifier, fullDefaultRenderStateIdentifier, holdDefaultRenderStateIdentifier});
auto pointers = DependencyManager::get<PointerScriptingInterface>().data();
auto controller = DependencyManager::get<controller::ScriptingInterface>().data();
glm::vec3 grabPointSphereOffsetLeft { 0.04, 0.13, 0.039 }; // x = upward, y = forward, z = lateral
glm::vec3 grabPointSphereOffsetRight { -0.04, 0.13, 0.039 }; // x = upward, y = forward, z = lateral
QList<QVariant> leftPointerTriggerProperties;
QVariantMap ltClick1 {
//{ "action", controller::StandardButtonChannel::LT_CLICK },
{ "action", controller->getStandard()["LTClick"] },
{ "button", "Focus" }
};
QVariantMap ltClick2 {
//{ "action", controller::StandardButtonChannel::LT_CLICK },
{ "action", controller->getStandard()["LTClick"] },
{ "button", "Primary" }
};
leftPointerTriggerProperties.append(ltClick1);
leftPointerTriggerProperties.append(ltClick2);
const unsigned int leftHand = 0;
QVariantMap leftPointerProperties {
{ "joint", "_CAMERA_RELATIVE_CONTROLLER_LEFTHAND" },
// { "filter", PickFilter::PICK_OVERLAYS },
{ "filter", PickScriptingInterface::PICK_OVERLAYS() },
{ "triggers", leftPointerTriggerProperties },
{ "posOffset", vec3toVariant(grabPointSphereOffsetLeft) },
{ "hover", true },
{ "scaleWithParent", true },
{ "distanceScaleEnd", true },
{ "hand", leftHand }
};
leftPointerProperties["renderStates"] = _renderStates;
leftPointerProperties["defaultRenderStates"] = _defaultRenderStates;
withWriteLock([&] { _leftLoginPointerID = pointers->createPointer(PickQuery::PickType::Ray, leftPointerProperties); });
pointers->setRenderState(leftLoginPointerID(), "");
pointers->enablePointer(leftLoginPointerID());
const unsigned int rightHand = 1;
QList<QVariant> rightPointerTriggerProperties;
QVariantMap rtClick1 {
//{ "action", controller::StandardButtonChannel::RT_CLICK },
{ "action", controller->getStandard()["RTClick"] },
{ "button", "Focus" }
};
QVariantMap rtClick2 {
//{ "action", controller::StandardButtonChannel::RT_CLICK },
{ "action", controller->getStandard()["RTClick"] },
{ "button", "Primary" }
};
rightPointerTriggerProperties.append(rtClick1);
rightPointerTriggerProperties.append(rtClick2);
QVariantMap rightPointerProperties{
{ "joint", "_CAMERA_RELATIVE_CONTROLLER_RIGHTHAND" },
// { "filter", PickFilter::PICK_OVERLAYS },
{ "filter", PickScriptingInterface::PICK_OVERLAYS() },
{ "triggers", rightPointerTriggerProperties },
{ "posOffset", vec3toVariant(grabPointSphereOffsetRight) },
{ "hover", true },
{ "scaleWithParent", true },
{ "distanceScaleEnd", true },
{ "hand", rightHand }
};
rightPointerProperties["renderStates"] = _renderStates;
rightPointerProperties["defaultRenderStates"] = _defaultRenderStates;
withWriteLock([&] { _rightLoginPointerID = pointers->createPointer(PickQuery::PickType::Ray, rightPointerProperties); });
pointers->setRenderState(rightLoginPointerID(), "");
pointers->enablePointer(rightLoginPointerID());
}
void LoginPointerManager::update() {
auto pointers = DependencyManager::get<PointerScriptingInterface>();
if (pointers) {
QString mode = "";
// if (this.visible) {
// if (this.locked) {
// mode = "hold";
// if (triggerClicks[this.hand]) {
mode = "full";
// } else if (triggerValues[this.hand] > TRIGGER_ON_VALUE || this.allwaysOn) {
// mode = "half";
// }
// }
if (leftLoginPointerID() > PointerEvent::INVALID_POINTER_ID) {
pointers->setRenderState(leftLoginPointerID(), mode);
}
if (rightLoginPointerID() > PointerEvent::INVALID_POINTER_ID) {
pointers->setRenderState(rightLoginPointerID(), mode);
}
}
}

View file

@ -0,0 +1,43 @@
//
// LoginPointerManager.h
// interface/src
//
// Created by Wayne Chen on 11/5/18.
// Copyright 2018 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
//
#ifndef hifi_LoginPointerManager_h
#define hifi_LoginPointerManager_h
#include <QtCore/QList>
#include <QtCore/QVariant>
#include <PointerEvent.h>
#include <shared/ReadWriteLockable.h>
class LoginPointerManager : protected ReadWriteLockable {
public:
LoginPointerManager() {}
~LoginPointerManager();
void init();
void update();
const unsigned int leftLoginPointerID() const {
return resultWithReadLock<unsigned int>([&] { return _leftLoginPointerID; });
}
const unsigned int rightLoginPointerID() const {
return resultWithReadLock<unsigned int>([&] { return _rightLoginPointerID; });
}
private:
QList<QVariant> _renderStates {};
QList<QVariant> _defaultRenderStates {};
unsigned int _leftLoginPointerID { PointerEvent::INVALID_POINTER_ID };
unsigned int _rightLoginPointerID { PointerEvent::INVALID_POINTER_ID };
};
#endif // hifi_LoginPointerManager_h

View file

@ -25,7 +25,6 @@
#include "HMDToolsDialog.h"
#include "LodToolsDialog.h"
#include "LoginDialog.h"
#include "LoginScreenDialog.h"
#include "OctreeStatsDialog.h"
#include "PreferencesDialog.h"
#include "UpdateDialog.h"

View file

@ -71,6 +71,7 @@ void LoginDialog::showWithSelection() {
tablet->initialScreen(TABLET_LOGIN_DIALOG_URL);
} else {
// let Application handle creating login dialog overlay.
qApp->checkReadyToCreateLoginDialogOverlay();
}
}

View file

@ -162,10 +162,6 @@ void AddressManager::storeCurrentAddress() {
// url.scheme() == URL_SCHEME_HTTP ||
// url.scheme() == URL_SCHEME_HTTPS ||
bool isInErrorState = DependencyManager::get<NodeList>()->getDomainHandler().isInErrorState();
bool isInLoginScreenState = DependencyManager::get<NodeList>()->getDomainHandler().isInLoginScreenState();
if (isInLoginScreenState) {
qCWarning(networking) << "Ignoring attempt to save current address because in login screen domain:" << url;
}
if (isConnected()) {
if (isInErrorState) {
// save the last address visited before the problem url.
@ -829,9 +825,8 @@ bool AddressManager::setDomainInfo(const QUrl& domainURL, LookupTrigger trigger)
// Check if domain handler is in error state. always emit host changed if true.
bool isInErrorState = DependencyManager::get<NodeList>()->getDomainHandler().isInErrorState();
// Check if domain handler is in login screen state. always emit host changed if true.
bool isInLoginScreenState = DependencyManager::get<NodeList>()->getDomainHandler().isInLoginScreenState();
if (domainURL != _domainURL || isInErrorState || isInLoginScreenState) {
if (domainURL != _domainURL || isInErrorState) {
addCurrentAddressToHistory(trigger);
emitHostChanged = true;
}

View file

@ -179,7 +179,6 @@ public slots:
void setRedirectErrorState(QUrl errorUrl, QString reasonMessage = "", int reason = -1, const QString& extraInfo = "");
bool isInErrorState() { return _isInErrorState; }
bool isInLoginScreenState() { return _isInLoginScreenState; }
private slots:
void completedHostnameLookup(const QHostInfo& hostInfo);
@ -228,7 +227,6 @@ private:
NetworkPeer _icePeer;
bool _isConnected { false };
bool _isInErrorState { false };
bool _isInLoginScreenState { false };
QJsonObject _settingsObject;
QString _pendingPath;
QTimer _settingsTimer;