mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-07-11 00:27:23 +02:00
steps toward making mouse work on tablet
This commit is contained in:
parent
41ef7b8dbb
commit
37004e4347
6 changed files with 40 additions and 19 deletions
|
@ -6909,5 +6909,10 @@ OverlayID Application::getTabletScreenID() const {
|
||||||
|
|
||||||
OverlayID Application::getTabletHomeButtonID() const {
|
OverlayID Application::getTabletHomeButtonID() const {
|
||||||
auto HMD = DependencyManager::get<HMDScriptingInterface>();
|
auto HMD = DependencyManager::get<HMDScriptingInterface>();
|
||||||
return HMD->getCurrentHomeButtonUUID();
|
return HMD->getCurrentHomeButtonID();
|
||||||
|
}
|
||||||
|
|
||||||
|
QUuid Application::getTabletFrameID() const {
|
||||||
|
auto HMD = DependencyManager::get<HMDScriptingInterface>();
|
||||||
|
return HMD->getCurrentTabletFrameID();
|
||||||
}
|
}
|
||||||
|
|
|
@ -302,6 +302,7 @@ public:
|
||||||
|
|
||||||
OverlayID getTabletScreenID() const;
|
OverlayID getTabletScreenID() const;
|
||||||
OverlayID getTabletHomeButtonID() const;
|
OverlayID getTabletHomeButtonID() const;
|
||||||
|
QUuid getTabletFrameID() const; // may be an entity or an overlay
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void svoImportRequested(const QString& url);
|
void svoImportRequested(const QString& url);
|
||||||
|
|
|
@ -807,7 +807,7 @@ void MyAvatar::saveData() {
|
||||||
auto hmdInterface = DependencyManager::get<HMDScriptingInterface>();
|
auto hmdInterface = DependencyManager::get<HMDScriptingInterface>();
|
||||||
_avatarEntitiesLock.withReadLock([&] {
|
_avatarEntitiesLock.withReadLock([&] {
|
||||||
for (auto entityID : _avatarEntityData.keys()) {
|
for (auto entityID : _avatarEntityData.keys()) {
|
||||||
if (hmdInterface->getCurrentTabletUIID() == entityID) {
|
if (hmdInterface->getCurrentTabletFrameID() == entityID) {
|
||||||
// don't persist the tablet between domains / sessions
|
// don't persist the tablet between domains / sessions
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,8 +29,8 @@ class HMDScriptingInterface : public AbstractHMDScriptingInterface, public Depen
|
||||||
Q_PROPERTY(glm::quat orientation READ getOrientation)
|
Q_PROPERTY(glm::quat orientation READ getOrientation)
|
||||||
Q_PROPERTY(bool mounted READ isMounted)
|
Q_PROPERTY(bool mounted READ isMounted)
|
||||||
Q_PROPERTY(bool showTablet READ getShouldShowTablet)
|
Q_PROPERTY(bool showTablet READ getShouldShowTablet)
|
||||||
Q_PROPERTY(QUuid tabletID READ getCurrentTabletUIID WRITE setCurrentTabletUIID)
|
Q_PROPERTY(QUuid tabletID READ getCurrentTabletFrameID WRITE setCurrentTabletFrameID)
|
||||||
Q_PROPERTY(QUuid homeButtonID READ getCurrentHomeButtonUUID WRITE setCurrentHomeButtonUUID)
|
Q_PROPERTY(QUuid homeButtonID READ getCurrentHomeButtonID WRITE setCurrentHomeButtonID)
|
||||||
Q_PROPERTY(QUuid tabletScreenID READ getCurrentTabletScreenID WRITE setCurrentTabletScreenID)
|
Q_PROPERTY(QUuid tabletScreenID READ getCurrentTabletScreenID WRITE setCurrentTabletScreenID)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
@ -90,11 +90,11 @@ public:
|
||||||
void setShouldShowTablet(bool value) { _showTablet = value; }
|
void setShouldShowTablet(bool value) { _showTablet = value; }
|
||||||
bool getShouldShowTablet() const { return _showTablet; }
|
bool getShouldShowTablet() const { return _showTablet; }
|
||||||
|
|
||||||
void setCurrentTabletUIID(QUuid tabletID) { _tabletUIID = tabletID; }
|
void setCurrentTabletFrameID(QUuid tabletID) { _tabletUIID = tabletID; }
|
||||||
QUuid getCurrentTabletUIID() const { return _tabletUIID; }
|
QUuid getCurrentTabletFrameID() const { return _tabletUIID; }
|
||||||
|
|
||||||
void setCurrentHomeButtonUUID(QUuid homeButtonID) { _homeButtonID = homeButtonID; }
|
void setCurrentHomeButtonID(QUuid homeButtonID) { _homeButtonID = homeButtonID; }
|
||||||
QUuid getCurrentHomeButtonUUID() const { return _homeButtonID; }
|
QUuid getCurrentHomeButtonID() const { return _homeButtonID; }
|
||||||
|
|
||||||
void setCurrentTabletScreenID(QUuid tabletID) { _tabletScreenID = tabletID; }
|
void setCurrentTabletScreenID(QUuid tabletID) { _tabletScreenID = tabletID; }
|
||||||
QUuid getCurrentTabletScreenID() const { return _tabletScreenID; }
|
QUuid getCurrentTabletScreenID() const { return _tabletScreenID; }
|
||||||
|
|
|
@ -161,7 +161,7 @@ WebTablet = function (url, width, dpi, hand, clientOnly) {
|
||||||
});
|
});
|
||||||
|
|
||||||
var HOME_BUTTON_Y_OFFSET = (this.height / 2) - 0.035;
|
var HOME_BUTTON_Y_OFFSET = (this.height / 2) - 0.035;
|
||||||
this.homeButtonEntity = Overlays.addOverlay("sphere", {
|
this.homeButtonID = Overlays.addOverlay("sphere", {
|
||||||
name: "homeButton",
|
name: "homeButton",
|
||||||
localPosition: {x: 0.0, y: -HOME_BUTTON_Y_OFFSET, z: -0.01},
|
localPosition: {x: 0.0, y: -HOME_BUTTON_Y_OFFSET, z: -0.01},
|
||||||
localRotation: Quat.angleAxis(0, Y_AXIS),
|
localRotation: Quat.angleAxis(0, Y_AXIS),
|
||||||
|
@ -174,7 +174,7 @@ WebTablet = function (url, width, dpi, hand, clientOnly) {
|
||||||
});
|
});
|
||||||
|
|
||||||
this.receive = function (channel, senderID, senderUUID, localOnly) {
|
this.receive = function (channel, senderID, senderUUID, localOnly) {
|
||||||
if (_this.homeButtonEntity == senderID) {
|
if (_this.homeButtonID == senderID) {
|
||||||
var tablet = Tablet.getTablet("com.highfidelity.interface.tablet.system");
|
var tablet = Tablet.getTablet("com.highfidelity.interface.tablet.system");
|
||||||
var onHomeScreen = tablet.onHomeScreen();
|
var onHomeScreen = tablet.onHomeScreen();
|
||||||
if (onHomeScreen) {
|
if (onHomeScreen) {
|
||||||
|
@ -256,7 +256,7 @@ WebTablet.prototype.destroy = function () {
|
||||||
} else {
|
} else {
|
||||||
Entities.deleteEntity(this.tabletEntityID);
|
Entities.deleteEntity(this.tabletEntityID);
|
||||||
}
|
}
|
||||||
Overlays.deleteOverlay(this.homeButtonEntity);
|
Overlays.deleteOverlay(this.homeButtonID);
|
||||||
HMD.displayModeChanged.disconnect(this.myOnHmdChanged);
|
HMD.displayModeChanged.disconnect(this.myOnHmdChanged);
|
||||||
|
|
||||||
Controller.mousePressEvent.disconnect(this.myMousePressEvent);
|
Controller.mousePressEvent.disconnect(this.myMousePressEvent);
|
||||||
|
@ -439,10 +439,16 @@ WebTablet.prototype.getPosition = function () {
|
||||||
|
|
||||||
WebTablet.prototype.mousePressEvent = function (event) {
|
WebTablet.prototype.mousePressEvent = function (event) {
|
||||||
var pickRay = Camera.computePickRay(event.x, event.y);
|
var pickRay = Camera.computePickRay(event.x, event.y);
|
||||||
var entityPickResults = Entities.findRayIntersection(pickRay, true, [this.tabletEntityID]); // non-accurate picking
|
var entityPickResults;
|
||||||
if (entityPickResults.intersects && entityPickResults.entityID === this.tabletEntityID) {
|
if (this.tabletIsOverlay) {
|
||||||
var overlayPickResults = Overlays.findRayIntersection(pickRay);
|
entityPickResults = Overlays.findRayIntersection(pickRay, true, [this.tabletEntityID]);
|
||||||
if (overlayPickResults.intersects && overlayPickResults.overlayID === HMD.homeButtonID) {
|
} else {
|
||||||
|
entityPickResults = Entities.findRayIntersection(pickRay, true, [this.tabletEntityID]);
|
||||||
|
}
|
||||||
|
if (entityPickResults.intersects && (entityPickResults.entityID === this.tabletEntityID ||
|
||||||
|
entityPickResults.overlayID === this.tabletEntityID)) {
|
||||||
|
var overlayPickResults = Overlays.findRayIntersection(pickRay, true, [this.webOverlayID, this.homeButtonID], []);
|
||||||
|
if (overlayPickResults.intersects && overlayPickResults.overlayID === this.homeButtonID) {
|
||||||
var tablet = Tablet.getTablet("com.highfidelity.interface.tablet.system");
|
var tablet = Tablet.getTablet("com.highfidelity.interface.tablet.system");
|
||||||
var onHomeScreen = tablet.onHomeScreen();
|
var onHomeScreen = tablet.onHomeScreen();
|
||||||
if (onHomeScreen) {
|
if (onHomeScreen) {
|
||||||
|
@ -501,11 +507,17 @@ WebTablet.prototype.mouseMoveEvent = function (event) {
|
||||||
var localIntersectionPoint = Vec3.sum(localPickRay.origin, Vec3.multiply(localPickRay.direction, result.distance));
|
var localIntersectionPoint = Vec3.sum(localPickRay.origin, Vec3.multiply(localPickRay.direction, result.distance));
|
||||||
var localOffset = Vec3.subtract(localIntersectionPoint, this.initialLocalIntersectionPoint);
|
var localOffset = Vec3.subtract(localIntersectionPoint, this.initialLocalIntersectionPoint);
|
||||||
var localPosition = Vec3.sum(this.initialLocalPosition, localOffset);
|
var localPosition = Vec3.sum(this.initialLocalPosition, localOffset);
|
||||||
|
if (this.tabletIsOverlay) {
|
||||||
|
Overlays.editOverlay(this.tabletEntityID, {
|
||||||
|
localPosition: localPosition
|
||||||
|
});
|
||||||
|
} else {
|
||||||
Entities.editEntity(this.tabletEntityID, {
|
Entities.editEntity(this.tabletEntityID, {
|
||||||
localPosition: localPosition
|
localPosition: localPosition
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
WebTablet.prototype.mouseReleaseEvent = function (event) {
|
WebTablet.prototype.mouseReleaseEvent = function (event) {
|
||||||
|
|
|
@ -31,7 +31,8 @@
|
||||||
UIWebTablet = new WebTablet("qml/hifi/tablet/TabletRoot.qml", DEFAULT_WIDTH * (HMD_TABLET_SCALE / 100), null, activeHand, true);
|
UIWebTablet = new WebTablet("qml/hifi/tablet/TabletRoot.qml", DEFAULT_WIDTH * (HMD_TABLET_SCALE / 100), null, activeHand, true);
|
||||||
UIWebTablet.register();
|
UIWebTablet.register();
|
||||||
HMD.tabletID = UIWebTablet.tabletEntityID;
|
HMD.tabletID = UIWebTablet.tabletEntityID;
|
||||||
HMD.homeButtonID = UIWebTablet.homeButtonEntity;
|
HMD.homeButtonID = UIWebTablet.homeButtonID;
|
||||||
|
HMD.tabletScreenID = UIWebTablet.webOverlayID;
|
||||||
}
|
}
|
||||||
|
|
||||||
function hideTabletUI() {
|
function hideTabletUI() {
|
||||||
|
@ -48,6 +49,7 @@
|
||||||
UIWebTablet = null;
|
UIWebTablet = null;
|
||||||
HMD.tabletID = null;
|
HMD.tabletID = null;
|
||||||
HMD.homeButtonID = null;
|
HMD.homeButtonID = null;
|
||||||
|
HMD.tabletScreenID = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -126,5 +128,6 @@
|
||||||
Entities.deleteEntity(HMD.tabletID);
|
Entities.deleteEntity(HMD.tabletID);
|
||||||
HMD.tabletID = null;
|
HMD.tabletID = null;
|
||||||
HMD.homeButtonID = null;
|
HMD.homeButtonID = null;
|
||||||
|
HMD.tabletScreenID = null;
|
||||||
});
|
});
|
||||||
}()); // END LOCAL_SCOPE
|
}()); // END LOCAL_SCOPE
|
||||||
|
|
Loading…
Reference in a new issue