mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-08-17 17:03:25 +02:00
Improve hand controller + overlay interaction
This commit is contained in:
commit
5c74a3bbeb
2 changed files with 31 additions and 27 deletions
|
@ -27,6 +27,7 @@ ContextOverlayInterface::ContextOverlayInterface() {
|
|||
|
||||
_entityPropertyFlags += PROP_POSITION;
|
||||
_entityPropertyFlags += PROP_ROTATION;
|
||||
_entityPropertyFlags += PROP_MARKETPLACE_ID;
|
||||
|
||||
auto entityTreeRenderer = DependencyManager::get<EntityTreeRenderer>().data();
|
||||
connect(entityTreeRenderer, SIGNAL(mousePressOnEntity(const EntityItemID&, const PointerEvent&)), this, SLOT(createOrDestroyContextOverlay(const EntityItemID&, const PointerEvent&)));
|
||||
|
@ -34,28 +35,31 @@ ContextOverlayInterface::ContextOverlayInterface() {
|
|||
|
||||
void ContextOverlayInterface::createOrDestroyContextOverlay(const EntityItemID& entityItemID, const PointerEvent& event) {
|
||||
if (event.getButton() == PointerEvent::SecondaryButton) {
|
||||
qCDebug(context_overlay) << "Creating Context Overlay on top of entity with ID: " << entityItemID;
|
||||
setCurrentEntityWithContextOverlay(entityItemID);
|
||||
|
||||
EntityItemProperties entityProperties = _entityScriptingInterface->getEntityProperties(entityItemID, _entityPropertyFlags);
|
||||
if (entityProperties.getMarketplaceID().length() != 0) {
|
||||
qCDebug(context_overlay) << "Creating Context Overlay on top of entity with ID: " << entityItemID;
|
||||
_entityMarketplaceID = entityProperties.getMarketplaceID();
|
||||
setCurrentEntityWithContextOverlay(entityItemID);
|
||||
|
||||
if (_contextOverlayID == UNKNOWN_OVERLAY_ID || !qApp->getOverlays().isAddedOverlay(_contextOverlayID)) {
|
||||
_contextOverlay = std::make_shared<Image3DOverlay>();
|
||||
_contextOverlay->setAlpha(1.0f);
|
||||
_contextOverlay->setPulseMin(0.75f);
|
||||
_contextOverlay->setPulseMax(1.0f);
|
||||
_contextOverlay->setColorPulse(1.0f);
|
||||
_contextOverlay->setIgnoreRayIntersection(false);
|
||||
_contextOverlay->setDrawInFront(true);
|
||||
_contextOverlay->setURL("http://i.imgur.com/gksZygp.png");
|
||||
_contextOverlay->setIsFacingAvatar(true);
|
||||
_contextOverlayID = qApp->getOverlays().addOverlay(_contextOverlay);
|
||||
if (_contextOverlayID == UNKNOWN_OVERLAY_ID || !qApp->getOverlays().isAddedOverlay(_contextOverlayID)) {
|
||||
_contextOverlay = std::make_shared<Image3DOverlay>();
|
||||
_contextOverlay->setAlpha(1.0f);
|
||||
_contextOverlay->setPulseMin(0.75f);
|
||||
_contextOverlay->setPulseMax(1.0f);
|
||||
_contextOverlay->setColorPulse(1.0f);
|
||||
_contextOverlay->setIgnoreRayIntersection(false);
|
||||
_contextOverlay->setDrawInFront(true);
|
||||
_contextOverlay->setURL("http://i.imgur.com/gksZygp.png");
|
||||
_contextOverlay->setIsFacingAvatar(true);
|
||||
_contextOverlayID = qApp->getOverlays().addOverlay(_contextOverlay);
|
||||
}
|
||||
|
||||
_contextOverlay->setDimensions(glm::vec2(0.05f, 0.05f) * glm::distance(entityProperties.getPosition(), qApp->getCamera().getPosition()));
|
||||
_contextOverlay->setPosition(entityProperties.getPosition());
|
||||
_contextOverlay->setRotation(entityProperties.getRotation());
|
||||
_contextOverlay->setVisible(true);
|
||||
}
|
||||
|
||||
_contextOverlay->setDimensions(glm::vec2(0.1f, 0.1f) * glm::distance(entityProperties.getPosition(), qApp->getCamera().getPosition()));
|
||||
_contextOverlay->setPosition(entityProperties.getPosition());
|
||||
_contextOverlay->setRotation(entityProperties.getRotation());
|
||||
_contextOverlay->setVisible(true);
|
||||
} else if (_currentEntityWithContextOverlay == entityItemID) {
|
||||
destroyContextOverlay(entityItemID, event);
|
||||
}
|
||||
|
@ -68,6 +72,7 @@ void ContextOverlayInterface::destroyContextOverlay(const EntityItemID& entityIt
|
|||
qApp->getOverlays().deleteOverlay(_contextOverlayID);
|
||||
_contextOverlay = NULL;
|
||||
_contextOverlayID = UNKNOWN_OVERLAY_ID;
|
||||
_entityMarketplaceID.clear();
|
||||
}
|
||||
|
||||
void ContextOverlayInterface::destroyContextOverlay(const EntityItemID& entityItemID) {
|
||||
|
@ -87,14 +92,11 @@ void ContextOverlayInterface::openMarketplace() {
|
|||
// lets open the tablet and go to the current item in
|
||||
// the marketplace (if the current entity has a
|
||||
// marketplaceID)
|
||||
if (!_currentEntityWithContextOverlay.isNull()) {
|
||||
auto entity = qApp->getEntities()->getTree()->findEntityByID(_currentEntityWithContextOverlay);
|
||||
if (entity->getMarketplaceID().length() > 0) {
|
||||
auto tablet = dynamic_cast<TabletProxy*>(_tabletScriptingInterface->getTablet("com.highfidelity.interface.tablet.system"));
|
||||
// construct the url to the marketplace item
|
||||
QString url = MARKETPLACE_BASE_URL + entity->getMarketplaceID();
|
||||
tablet->gotoWebScreen(url);
|
||||
_hmdScriptingInterface->openTablet();
|
||||
}
|
||||
if (!_currentEntityWithContextOverlay.isNull() && _entityMarketplaceID.length() > 0) {
|
||||
auto tablet = dynamic_cast<TabletProxy*>(_tabletScriptingInterface->getTablet("com.highfidelity.interface.tablet.system"));
|
||||
// construct the url to the marketplace item
|
||||
QString url = MARKETPLACE_BASE_URL + _entityMarketplaceID;
|
||||
tablet->gotoWebScreen(url);
|
||||
_hmdScriptingInterface->openTablet();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -56,6 +56,8 @@ public slots:
|
|||
private:
|
||||
bool _verboseLogging { true };
|
||||
QUuid _currentEntityWithContextOverlay{};
|
||||
QString _entityMarketplaceID;
|
||||
|
||||
void openMarketplace();
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in a new issue