mirror of
https://github.com/overte-org/overte.git
synced 2025-04-08 05:52:38 +02:00
fix tablet home button
This commit is contained in:
parent
a8dbe5e761
commit
9aae9d13f6
5 changed files with 31 additions and 63 deletions
|
@ -615,10 +615,6 @@ void DdeFaceTracker::setEyeClosingThreshold(float eyeClosingThreshold) {
|
|||
|
||||
static const int CALIBRATION_BILLBOARD_WIDTH = 300;
|
||||
static const int CALIBRATION_BILLBOARD_HEIGHT = 120;
|
||||
static const int CALIBRATION_BILLBOARD_TOP_MARGIN = 30;
|
||||
static const int CALIBRATION_BILLBOARD_LEFT_MARGIN = 30;
|
||||
static const int CALIBRATION_BILLBOARD_FONT_SIZE = 16;
|
||||
static const float CALIBRATION_BILLBOARD_ALPHA = 0.5f;
|
||||
static QString CALIBRATION_INSTRUCTION_MESSAGE = "Hold still to calibrate camera";
|
||||
|
||||
void DdeFaceTracker::calibrate() {
|
||||
|
|
|
@ -397,6 +397,20 @@ EntityItemProperties Overlays::convertOverlayToEntityProperties(QVariantMap& ove
|
|||
}
|
||||
overlayProps["rotation"] = quatToVariant(glm::angleAxis(-(float)M_PI_2, rotation * Vectors::RIGHT) * rotation);
|
||||
}
|
||||
if (add || overlayProps.contains("localRotation")) {
|
||||
glm::quat rotation;
|
||||
{
|
||||
auto iter = overlayProps.find("localRotation");
|
||||
if (iter != overlayProps.end()) {
|
||||
rotation = quatFromVariant(iter.value());
|
||||
} else if (!add) {
|
||||
EntityPropertyFlags desiredProperties;
|
||||
desiredProperties += PROP_LOCAL_ROTATION;
|
||||
rotation = DependencyManager::get<EntityScriptingInterface>()->getEntityProperties(id, desiredProperties).getLocalRotation();
|
||||
}
|
||||
}
|
||||
overlayProps["localRotation"] = quatToVariant(glm::angleAxis(-(float)M_PI_2, rotation * Vectors::RIGHT) * rotation);
|
||||
}
|
||||
|
||||
{
|
||||
RENAME_PROP(color, innerStartColor);
|
||||
|
@ -536,8 +550,6 @@ QVariantMap Overlays::convertEntityToOverlayProperties(const EntityItemPropertie
|
|||
RENAME_PROP(position, point);
|
||||
RENAME_PROP(dimensions, scale);
|
||||
RENAME_PROP(dimensions, size);
|
||||
RENAME_PROP(rotation, orientation);
|
||||
RENAME_PROP(localRotation, localOrientation);
|
||||
RENAME_PROP(ignorePickIntersection, ignoreRayIntersection);
|
||||
|
||||
{
|
||||
|
@ -586,13 +598,17 @@ QVariantMap Overlays::convertEntityToOverlayProperties(const EntityItemPropertie
|
|||
RENAME_PROP(sourceUrl, url);
|
||||
RENAME_PROP_CONVERT(inputMode, inputMode, [](const QVariant& v) { return v.toString() == "mouse" ? "Mouse" : "Touch"; });
|
||||
} else if (type == "Gizmo") {
|
||||
RENAME_PROP_CONVERT(dimensions, outerRadius, [](const QVariant& v) { return vec3FromVariant(v).x; });
|
||||
RENAME_PROP_CONVERT(dimensions, outerRadius, [](const QVariant& v) { return 2.0f * vec3FromVariant(v).x; });
|
||||
RENAME_PROP(outerRadius, radius);
|
||||
|
||||
RENAME_PROP_CONVERT(rotation, rotation, [](const QVariant& v) {
|
||||
glm::quat rot = quatFromVariant(v);
|
||||
return quatToVariant(glm::angleAxis((float)M_PI_2, rot * Vectors::RIGHT) * rot);
|
||||
});
|
||||
RENAME_PROP_CONVERT(localRotation, localRotation, [](const QVariant& v) {
|
||||
glm::quat rot = quatFromVariant(v);
|
||||
return quatToVariant(glm::angleAxis((float)M_PI_2, rot * Vectors::RIGHT) * rot);
|
||||
});
|
||||
|
||||
GROUP_ENTITY_TO_OVERLAY_PROP(ring, startAngle, startAt);
|
||||
GROUP_ENTITY_TO_OVERLAY_PROP(ring, endAngle, endAt);
|
||||
|
@ -638,6 +654,10 @@ QVariantMap Overlays::convertEntityToOverlayProperties(const EntityItemPropertie
|
|||
RENAME_PROP_CONVERT(glow, glow, [](const QVariant& v) { return v.toBool() ? 1.0f : 0.0f; });
|
||||
}
|
||||
|
||||
// Do at the end, in case this type was rotated above
|
||||
RENAME_PROP(rotation, orientation);
|
||||
RENAME_PROP(localRotation, localOrientation);
|
||||
|
||||
return overlayProps;
|
||||
}
|
||||
|
||||
|
|
|
@ -358,8 +358,10 @@ public slots:
|
|||
* @param {boolean} [precisionPicking=false] - <em>Unused</em>; exists to match Entity API.
|
||||
* @param {Array.<Uuid>} [include=[]] - If not empty then the search is restricted to these overlays.
|
||||
* @param {Array.<Uuid>} [discard=[]] - Overlays to ignore during the search.
|
||||
* @param {boolean} [visibleOnly=false] - <em>Unused</em>; exists to match Entity API.
|
||||
* @param {boolean} [collidableOnly=false] - <em>Unused</em>; exists to match Entity API.
|
||||
* @param {boolean} [visibleOnly=false] - If <code>true</code> then only entities that are
|
||||
* <code>{@link Entities.EntityProperties|visible}<code> are searched.
|
||||
* @param {boolean} [collideableOnly=false] - If <code>true</code> then only entities that are not
|
||||
* <code>{@link Entities.EntityProperties|collisionless}</code> are searched.
|
||||
* @returns {Overlays.RayToOverlayIntersectionResult} The closest 3D overlay intersected by <code>pickRay</code>, taking
|
||||
* into account <code>overlayIDsToInclude</code> and <code>overlayIDsToExclude</code> if they're not empty.
|
||||
* @example <caption>Create a cube overlay in front of your avatar. Report 3D overlay intersection details for mouse
|
||||
|
|
|
@ -170,8 +170,7 @@ WebTablet = function (url, width, dpi, hand, location, visible) {
|
|||
visible: visible
|
||||
});
|
||||
|
||||
// FIXME: Circle3D overlays currently at the wrong dimensions, so we need to account for that here
|
||||
var homeButtonDim = 4.0 * tabletScaleFactor / 3.0;
|
||||
var homeButtonDim = 4.0 * tabletScaleFactor / 1.5;
|
||||
var HOME_BUTTON_X_OFFSET = 0.00079 * sensorScaleFactor;
|
||||
var HOME_BUTTON_Y_OFFSET = -1 * ((tabletHeight / 2) - (4.0 * tabletScaleFactor / 2));
|
||||
var HOME_BUTTON_Z_OFFSET = (tabletDepth / 1.9) * sensorScaleFactor;
|
||||
|
@ -224,23 +223,6 @@ WebTablet = function (url, width, dpi, hand, location, visible) {
|
|||
}
|
||||
};
|
||||
|
||||
this.myOnHoverEnterOverlay = function (overlayID, pointerEvent) {
|
||||
_this.onHoverEnterOverlay(overlayID, pointerEvent);
|
||||
};
|
||||
|
||||
Overlays.hoverEnterOverlay.connect(this.myOnHoverEnterOverlay);
|
||||
|
||||
this.myOnHoverLeaveOverlay = function (overlayID, pointerEvent) {
|
||||
_this.onHoverLeaveOverlay(overlayID, pointerEvent);
|
||||
};
|
||||
|
||||
Overlays.hoverLeaveOverlay.connect(this.myOnHoverLeaveOverlay);
|
||||
|
||||
this.myOnHoverOverOverlay = function (overlayID, pointerEvent) {
|
||||
_this.onHoverOverOverlay(overlayID, pointerEvent);
|
||||
};
|
||||
Overlays.hoverOverOverlay.connect(this.myOnHoverOverOverlay);
|
||||
|
||||
this.state = "idle";
|
||||
|
||||
this.getRoot = function() {
|
||||
|
@ -350,10 +332,6 @@ WebTablet.prototype.setWidth = function (width) {
|
|||
};
|
||||
|
||||
WebTablet.prototype.destroy = function () {
|
||||
Overlays.hoverEnterOverlay.disconnect(this.myOnHoverEnterOverlay);
|
||||
Overlays.hoverLeaveOverlay.disconnect(this.myOnHoverLeaveOverlay);
|
||||
Overlays.hoverOverOverlay.disconnect(this.myOnHoverOverOverlay);
|
||||
|
||||
Overlays.deleteOverlay(this.webOverlayID);
|
||||
Overlays.deleteOverlay(this.tabletEntityID);
|
||||
Overlays.deleteOverlay(this.homeButtonID);
|
||||
|
@ -449,24 +427,6 @@ WebTablet.prototype.calculateWorldAttitudeRelativeToCamera = function (windowPos
|
|||
};
|
||||
};
|
||||
|
||||
WebTablet.prototype.onHoverEnterOverlay = function (overlayID, pointerEvent) {
|
||||
if (overlayID === this.homeButtonID) {
|
||||
Overlays.editOverlay(this.homeButtonHighlightID, { alpha: 1.0 });
|
||||
}
|
||||
};
|
||||
|
||||
WebTablet.prototype.onHoverOverOverlay = function (overlayID, pointerEvent) {
|
||||
if (overlayID !== this.homeButtonID) {
|
||||
Overlays.editOverlay(this.homeButtonHighlightID, { alpha: 0.0 });
|
||||
}
|
||||
};
|
||||
|
||||
WebTablet.prototype.onHoverLeaveOverlay = function (overlayID, pointerEvent) {
|
||||
if (overlayID === this.homeButtonID) {
|
||||
Overlays.editOverlay(this.homeButtonHighlightID, { alpha: 0.0 });
|
||||
}
|
||||
};
|
||||
|
||||
// compute position, rotation & parentJointIndex of the tablet
|
||||
WebTablet.prototype.calculateTabletAttachmentProperties = function (hand, useMouse, tabletProperties) {
|
||||
if (HMD.active) {
|
||||
|
@ -595,17 +555,8 @@ WebTablet.prototype.scheduleMouseMoveProcessor = function() {
|
|||
|
||||
WebTablet.prototype.handleHomeButtonHover = function(x, y) {
|
||||
var pickRay = Camera.computePickRay(x, y);
|
||||
var entityPickResults;
|
||||
var homebuttonHovered = false;
|
||||
entityPickResults = Overlays.findRayIntersection(pickRay, true, [this.tabletEntityID]);
|
||||
if (entityPickResults.intersects && (entityPickResults.entityID === this.tabletEntityID ||
|
||||
entityPickResults.overlayID === this.tabletEntityID)) {
|
||||
var overlayPickResults = Overlays.findRayIntersection(pickRay, true, [this.homeButtonID], []);
|
||||
if (overlayPickResults.intersects && overlayPickResults.overlayID === this.homeButtonID) {
|
||||
homebuttonHovered = true;
|
||||
}
|
||||
}
|
||||
Overlays.editOverlay(this.homeButtonHighlightID, { alpha: homebuttonHovered ? 1.0 : 0.0 });
|
||||
var homePickResult = Overlays.findRayIntersection(pickRay, true, [this.homeButtonID]);
|
||||
Overlays.editOverlay(this.homeButtonHighlightID, { alpha: homePickResult.intersects ? 1.0 : 0.0 });
|
||||
};
|
||||
|
||||
WebTablet.prototype.mouseMoveEvent = function (event) {
|
||||
|
|
|
@ -412,8 +412,7 @@ resizeTablet = function (width, newParentJointIndex, sensorToWorldScaleOverride)
|
|||
});
|
||||
|
||||
// update homeButton
|
||||
// FIXME: Circle3D overlays currently at the wrong dimensions, so we need to account for that here
|
||||
var homeButtonDim = 4.0 * tabletScaleFactor / 3.0;
|
||||
var homeButtonDim = 4.0 * tabletScaleFactor / 1.5;
|
||||
var HOME_BUTTON_X_OFFSET = 0.00079 * sensorScaleOffsetOverride * sensorScaleFactor;
|
||||
var HOME_BUTTON_Y_OFFSET = -1 * ((tabletHeight / 2) - (4.0 * tabletScaleFactor / 2)) * sensorScaleOffsetOverride;
|
||||
var HOME_BUTTON_Z_OFFSET = (tabletDepth / 1.9) * sensorScaleOffsetOverride;
|
||||
|
|
Loading…
Reference in a new issue