mirror of
https://github.com/overte-org/overte.git
synced 2025-04-12 09:42:11 +02:00
making overlays use precisionPicking and adjust tablet screen position
This commit is contained in:
parent
d57d087752
commit
6ddc768f57
18 changed files with 48 additions and 37 deletions
|
@ -283,7 +283,7 @@ QVariant Base3DOverlay::getProperty(const QString& property) {
|
|||
}
|
||||
|
||||
bool Base3DOverlay::findRayIntersection(const glm::vec3& origin, const glm::vec3& direction,
|
||||
float& distance, BoxFace& face, glm::vec3& surfaceNormal) {
|
||||
float& distance, BoxFace& face, glm::vec3& surfaceNormal, bool precisionPicking) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -68,11 +68,11 @@ public:
|
|||
virtual QVariant getProperty(const QString& property) override;
|
||||
|
||||
virtual bool findRayIntersection(const glm::vec3& origin, const glm::vec3& direction, float& distance,
|
||||
BoxFace& face, glm::vec3& surfaceNormal);
|
||||
BoxFace& face, glm::vec3& surfaceNormal, bool precisionPicking = false);
|
||||
|
||||
virtual bool findRayIntersectionExtraInfo(const glm::vec3& origin, const glm::vec3& direction,
|
||||
float& distance, BoxFace& face, glm::vec3& surfaceNormal, QVariantMap& extraInfo) {
|
||||
return findRayIntersection(origin, direction, distance, face, surfaceNormal);
|
||||
float& distance, BoxFace& face, glm::vec3& surfaceNormal, QVariantMap& extraInfo, bool precisionPicking = false) {
|
||||
return findRayIntersection(origin, direction, distance, face, surfaceNormal, precisionPicking);
|
||||
}
|
||||
|
||||
virtual SpatialParentTree* getParentTree() const override;
|
||||
|
|
|
@ -521,7 +521,7 @@ QVariant Circle3DOverlay::getProperty(const QString& property) {
|
|||
}
|
||||
|
||||
bool Circle3DOverlay::findRayIntersection(const glm::vec3& origin, const glm::vec3& direction, float& distance,
|
||||
BoxFace& face, glm::vec3& surfaceNormal) {
|
||||
BoxFace& face, glm::vec3& surfaceNormal, bool precisionPicking) {
|
||||
|
||||
// Scale the dimensions by the diameter
|
||||
glm::vec2 dimensions = getOuterRadius() * 2.0f * getDimensions();
|
||||
|
|
|
@ -55,7 +55,7 @@ public:
|
|||
void setMinorTickMarksColor(const xColor& value) { _minorTickMarksColor = value; }
|
||||
|
||||
virtual bool findRayIntersection(const glm::vec3& origin, const glm::vec3& direction, float& distance,
|
||||
BoxFace& face, glm::vec3& surfaceNormal) override;
|
||||
BoxFace& face, glm::vec3& surfaceNormal, bool precisionPicking = false) override;
|
||||
|
||||
virtual Circle3DOverlay* createClone() const override;
|
||||
|
||||
|
|
|
@ -35,7 +35,7 @@ public:
|
|||
virtual Grid3DOverlay* createClone() const override;
|
||||
|
||||
// Grids are UI tools, and may not be intersected (pickable)
|
||||
virtual bool findRayIntersection(const glm::vec3&, const glm::vec3&, float&, BoxFace&, glm::vec3&) override { return false; }
|
||||
virtual bool findRayIntersection(const glm::vec3&, const glm::vec3&, float&, BoxFace&, glm::vec3&, bool precisionPicking = false) override { return false; }
|
||||
|
||||
protected:
|
||||
Transform evalRenderTransform() override;
|
||||
|
|
|
@ -258,7 +258,7 @@ void Image3DOverlay::setURL(const QString& url) {
|
|||
}
|
||||
|
||||
bool Image3DOverlay::findRayIntersection(const glm::vec3& origin, const glm::vec3& direction,
|
||||
float& distance, BoxFace& face, glm::vec3& surfaceNormal) {
|
||||
float& distance, BoxFace& face, glm::vec3& surfaceNormal, bool precisionPicking) {
|
||||
if (_texture && _texture->isLoaded()) {
|
||||
// Make sure position and rotation is updated.
|
||||
Transform transform = getTransform();
|
||||
|
|
|
@ -43,7 +43,7 @@ public:
|
|||
bool isTransparent() override { return Base3DOverlay::isTransparent() || _alphaTexture; }
|
||||
|
||||
virtual bool findRayIntersection(const glm::vec3& origin, const glm::vec3& direction, float& distance,
|
||||
BoxFace& face, glm::vec3& surfaceNormal) override;
|
||||
BoxFace& face, glm::vec3& surfaceNormal, bool precisionPicking = false) override;
|
||||
|
||||
virtual Image3DOverlay* createClone() const override;
|
||||
|
||||
|
|
|
@ -477,16 +477,16 @@ QVariant ModelOverlay::getProperty(const QString& property) {
|
|||
}
|
||||
|
||||
bool ModelOverlay::findRayIntersection(const glm::vec3& origin, const glm::vec3& direction,
|
||||
float& distance, BoxFace& face, glm::vec3& surfaceNormal) {
|
||||
float& distance, BoxFace& face, glm::vec3& surfaceNormal, bool precisionPicking) {
|
||||
|
||||
QVariantMap extraInfo;
|
||||
return _model->findRayIntersectionAgainstSubMeshes(origin, direction, distance, face, surfaceNormal, extraInfo);
|
||||
return _model->findRayIntersectionAgainstSubMeshes(origin, direction, distance, face, surfaceNormal, extraInfo, precisionPicking);
|
||||
}
|
||||
|
||||
bool ModelOverlay::findRayIntersectionExtraInfo(const glm::vec3& origin, const glm::vec3& direction,
|
||||
float& distance, BoxFace& face, glm::vec3& surfaceNormal, QVariantMap& extraInfo) {
|
||||
float& distance, BoxFace& face, glm::vec3& surfaceNormal, QVariantMap& extraInfo, bool precisionPicking) {
|
||||
|
||||
return _model->findRayIntersectionAgainstSubMeshes(origin, direction, distance, face, surfaceNormal, extraInfo);
|
||||
return _model->findRayIntersectionAgainstSubMeshes(origin, direction, distance, face, surfaceNormal, extraInfo, precisionPicking);
|
||||
}
|
||||
|
||||
ModelOverlay* ModelOverlay::createClone() const {
|
||||
|
|
|
@ -44,9 +44,9 @@ public:
|
|||
void setProperties(const QVariantMap& properties) override;
|
||||
QVariant getProperty(const QString& property) override;
|
||||
virtual bool findRayIntersection(const glm::vec3& origin, const glm::vec3& direction, float& distance,
|
||||
BoxFace& face, glm::vec3& surfaceNormal) override;
|
||||
BoxFace& face, glm::vec3& surfaceNormal, bool precisionPicking = false) override;
|
||||
virtual bool findRayIntersectionExtraInfo(const glm::vec3& origin, const glm::vec3& direction,
|
||||
float& distance, BoxFace& face, glm::vec3& surfaceNormal, QVariantMap& extraInfo) override;
|
||||
float& distance, BoxFace& face, glm::vec3& surfaceNormal, QVariantMap& extraInfo, bool precisionPicking = false) override;
|
||||
|
||||
virtual ModelOverlay* createClone() const override;
|
||||
|
||||
|
|
|
@ -554,7 +554,7 @@ RayToOverlayIntersectionResult Overlays::findRayIntersectionVector(const PickRay
|
|||
glm::vec3 thisSurfaceNormal;
|
||||
QVariantMap thisExtraInfo;
|
||||
if (thisOverlay->findRayIntersectionExtraInfo(ray.origin, ray.direction, thisDistance,
|
||||
thisFace, thisSurfaceNormal, thisExtraInfo)) {
|
||||
thisFace, thisSurfaceNormal, thisExtraInfo, precisionPicking)) {
|
||||
bool isDrawInFront = thisOverlay->getDrawInFront();
|
||||
if ((bestIsFront && isDrawInFront && thisDistance < bestDistance)
|
||||
|| (!bestIsFront && (isDrawInFront || thisDistance < bestDistance))) {
|
||||
|
|
|
@ -71,7 +71,7 @@ QVariant Planar3DOverlay::getProperty(const QString& property) {
|
|||
}
|
||||
|
||||
bool Planar3DOverlay::findRayIntersection(const glm::vec3& origin, const glm::vec3& direction,
|
||||
float& distance, BoxFace& face, glm::vec3& surfaceNormal) {
|
||||
float& distance, BoxFace& face, glm::vec3& surfaceNormal, bool precisionPicking) {
|
||||
// FIXME - face and surfaceNormal not being returned
|
||||
return findRayRectangleIntersection(origin, direction, getWorldOrientation(), getWorldPosition(), getDimensions(), distance);
|
||||
}
|
||||
|
|
|
@ -31,7 +31,7 @@ public:
|
|||
virtual QVariant getProperty(const QString& property) override;
|
||||
|
||||
virtual bool findRayIntersection(const glm::vec3& origin, const glm::vec3& direction, float& distance,
|
||||
BoxFace& face, glm::vec3& surfaceNormal) override;
|
||||
BoxFace& face, glm::vec3& surfaceNormal, bool precisionPicking = false) override;
|
||||
|
||||
protected:
|
||||
glm::vec2 _dimensions;
|
||||
|
|
|
@ -76,7 +76,7 @@ QVariant Volume3DOverlay::getProperty(const QString& property) {
|
|||
}
|
||||
|
||||
bool Volume3DOverlay::findRayIntersection(const glm::vec3& origin, const glm::vec3& direction,
|
||||
float& distance, BoxFace& face, glm::vec3& surfaceNormal) {
|
||||
float& distance, BoxFace& face, glm::vec3& surfaceNormal, bool precisionPicking) {
|
||||
// extents is the entity relative, scaled, centered extents of the entity
|
||||
glm::mat4 worldToEntityMatrix;
|
||||
Transform transform = getTransform();
|
||||
|
|
|
@ -31,7 +31,7 @@ public:
|
|||
QVariant getProperty(const QString& property) override;
|
||||
|
||||
virtual bool findRayIntersection(const glm::vec3& origin, const glm::vec3& direction, float& distance,
|
||||
BoxFace& face, glm::vec3& surfaceNormal) override;
|
||||
BoxFace& face, glm::vec3& surfaceNormal, bool precisionPicking = false) override;
|
||||
|
||||
protected:
|
||||
// Centered local bounding box
|
||||
|
|
|
@ -622,7 +622,7 @@ void Web3DOverlay::setScriptURL(const QString& scriptURL) {
|
|||
}
|
||||
}
|
||||
|
||||
bool Web3DOverlay::findRayIntersection(const glm::vec3& origin, const glm::vec3& direction, float& distance, BoxFace& face, glm::vec3& surfaceNormal) {
|
||||
bool Web3DOverlay::findRayIntersection(const glm::vec3& origin, const glm::vec3& direction, float& distance, BoxFace& face, glm::vec3& surfaceNormal, bool precisionPicking) {
|
||||
glm::vec2 dimensions = getDimensions();
|
||||
glm::quat rotation = getWorldOrientation();
|
||||
glm::vec3 position = getWorldPosition();
|
||||
|
|
|
@ -53,7 +53,7 @@ public:
|
|||
QVariant getProperty(const QString& property) override;
|
||||
|
||||
virtual bool findRayIntersection(const glm::vec3& origin, const glm::vec3& direction, float& distance,
|
||||
BoxFace& face, glm::vec3& surfaceNormal) override;
|
||||
BoxFace& face, glm::vec3& surfaceNormal, bool precisionPicking = false) override;
|
||||
|
||||
virtual Web3DOverlay* createClone() const override;
|
||||
|
||||
|
|
|
@ -41,6 +41,8 @@ var LOCAL_BEZEL_HIGHLIGHT = Script.resourcesPath() + "images/buttonBezel_highlig
|
|||
var LOCAL_NORMAL_BEZEL = Script.resourcesPath() + "images/buttonBezel.png";
|
||||
|
||||
var LOCAL_TABLET_MODEL_PATH = Script.resourcesPath() + "meshes/tablet-with-home-button-small-bezel.fbx";
|
||||
var HIGH_PRIORITY = 1;
|
||||
var LOW_PRIORITY = 0;
|
||||
var SUBMESH = 3;
|
||||
|
||||
// returns object with two fields:
|
||||
|
@ -138,8 +140,7 @@ WebTablet = function (url, width, dpi, hand, clientOnly, location, visible) {
|
|||
Overlays.deleteOverlay(this.webOverlayID);
|
||||
}
|
||||
|
||||
var RAYPICK_OFFSET = 0.0007; // Sufficient for raypick to reliably intersect tablet screen before tablet model.
|
||||
var WEB_ENTITY_Z_OFFSET = (tabletDepth / 2.0) / sensorScaleFactor + RAYPICK_OFFSET;
|
||||
var WEB_ENTITY_Z_OFFSET = (tabletDepth / 2.5) / sensorScaleFactor;
|
||||
var WEB_ENTITY_Y_OFFSET = 1 * tabletScaleFactor;
|
||||
var screenWidth = 0.9275 * tabletWidth;
|
||||
var screenHeight = 0.8983 * tabletHeight;
|
||||
|
@ -147,7 +148,7 @@ WebTablet = function (url, width, dpi, hand, clientOnly, location, visible) {
|
|||
name: "WebTablet Web",
|
||||
url: url,
|
||||
localPosition: { x: 0, y: WEB_ENTITY_Y_OFFSET, z: -WEB_ENTITY_Z_OFFSET },
|
||||
localRotation: Quat.multiply(Quat.angleAxis(-0.25, X_AXIS), Quat.angleAxis(180, Y_AXIS)),
|
||||
localRotation: Quat.multiply(Quat.angleAxis(-0.5, X_AXIS), Quat.angleAxis(180, Y_AXIS)),
|
||||
dimensions: {x: screenWidth, y: screenHeight, z: 0.1},
|
||||
dpi: tabletDpi,
|
||||
color: { red: 255, green: 255, blue: 255 },
|
||||
|
@ -184,6 +185,9 @@ WebTablet = function (url, width, dpi, hand, clientOnly, location, visible) {
|
|||
albedoMap: HOME_BUTTON_TEXTURE
|
||||
}
|
||||
}),
|
||||
userData: JSON.stringify({
|
||||
"grabbableKey": {"grabbable": false}
|
||||
}),
|
||||
parentMaterialName: 4,
|
||||
parentID: this.tabletEntityID
|
||||
});
|
||||
|
@ -191,13 +195,17 @@ WebTablet = function (url, width, dpi, hand, clientOnly, location, visible) {
|
|||
this.homeButtonUnhighlightMaterial = Entities.addEntity({
|
||||
type: "Material",
|
||||
materialURL: "materialData",
|
||||
priority: 1,
|
||||
localPosition: { x: 0.0, y: 0.0, z: 0.0 },
|
||||
priority: HIGH_PRIORITY,
|
||||
materialData: JSON.stringify({
|
||||
materials: {
|
||||
albedoMap: LOCAL_NORMAL_BEZEL
|
||||
}
|
||||
|
||||
}),
|
||||
userData: JSON.stringify({
|
||||
"grabbableKey": {"grabbable": false}
|
||||
}),
|
||||
visible: false,
|
||||
parentMaterialName: SUBMESH,
|
||||
parentID: this.tabletEntityID
|
||||
|
@ -206,7 +214,8 @@ WebTablet = function (url, width, dpi, hand, clientOnly, location, visible) {
|
|||
this.homeButtonHighlightMaterial = Entities.addEntity({
|
||||
type: "Material",
|
||||
materialURL: "materialData",
|
||||
priority: 1,
|
||||
localPosition: { x: 0.0, y: 0.0, z: 0.0 },
|
||||
priority: LOW_PRIORITY,
|
||||
visible: false,
|
||||
materialData: JSON.stringify({
|
||||
materials: {
|
||||
|
@ -214,8 +223,11 @@ WebTablet = function (url, width, dpi, hand, clientOnly, location, visible) {
|
|||
}
|
||||
|
||||
}),
|
||||
userData: JSON.stringify({
|
||||
"grabbableKey": {"grabbable": false}
|
||||
}),
|
||||
parentMaterialName: SUBMESH,
|
||||
parentID: null
|
||||
parentID: this.tabletEntityID
|
||||
}, true);
|
||||
|
||||
this.receive = function (channel, senderID, senderUUID, localOnly) {
|
||||
|
@ -467,22 +479,22 @@ WebTablet.prototype.calculateWorldAttitudeRelativeToCamera = function (windowPos
|
|||
|
||||
WebTablet.prototype.onHoverEnterOverlay = function (overlayID, pointerEvent) {
|
||||
if (overlayID === this.homeButtonID) {
|
||||
Entities.editEntity(this.homeButtonUnhighlightMaterial, {parentID: null});
|
||||
Entities.editEntity(this.homeButtonHighlightMaterial, {parentID: this.tabletEntityID});
|
||||
Entities.editEntity(this.homeButtonUnhighlightMaterial, {priority: LOW_PRIORITY});
|
||||
Entities.editEntity(this.homeButtonHighlightMaterial, {priority: HIGH_PRIORITY});
|
||||
}
|
||||
};
|
||||
|
||||
WebTablet.prototype.onHoverOverOverlay = function (overlayID, pointerEvent) {
|
||||
if (overlayID !== this.homeButtonID) {
|
||||
Entities.editEntity(this.homeButtonUnhighlightMaterial, {parentID: this.tabletEntityID});
|
||||
Entities.editEntity(this.homeButtonHighlightMaterial, {parentID: null});
|
||||
Entities.editEntity(this.homeButtonUnhighlightMaterial, {priority: HIGH_PRIORITY});
|
||||
Entities.editEntity(this.homeButtonHighlightMaterial, {priority: LOW_PRIORITY});
|
||||
}
|
||||
};
|
||||
|
||||
WebTablet.prototype.onHoverLeaveOverlay = function (overlayID, pointerEvent) {
|
||||
if (overlayID === this.homeButtonID) {
|
||||
Entities.editEntity(this.homeButtonUnhighlightMaterial, {parentID: this.tabletEntityID});
|
||||
Entities.editEntity(this.homeButtonHighlightMaterial, {parentID: null});
|
||||
Entities.editEntity(this.homeButtonUnhighlightMaterial, {priority: HIGH_PRIORITY});
|
||||
Entities.editEntity(this.homeButtonHighlightMaterial, {priority: LOW_PRIORITY});
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -400,14 +400,13 @@ resizeTablet = function (width, newParentJointIndex, sensorToWorldScaleOverride)
|
|||
});
|
||||
|
||||
// update webOverlay
|
||||
var RAYPICK_OFFSET = 0.0007; // Sufficient for raypick to reliably intersect tablet screen before tablet model.
|
||||
var WEB_ENTITY_Z_OFFSET = (tabletDepth / 2.0) * sensorScaleOffsetOverride + RAYPICK_OFFSET;
|
||||
var WEB_ENTITY_Z_OFFSET = (tabletDepth / 2.5) * sensorScaleOffsetOverride;
|
||||
var WEB_ENTITY_Y_OFFSET = 1 * tabletScaleFactor * sensorScaleOffsetOverride;
|
||||
var screenWidth = 0.9275 * tabletWidth;
|
||||
var screenHeight = 0.8983 * tabletHeight;
|
||||
var landscape = Tablet.getTablet("com.highfidelity.interface.tablet.system").landscape;
|
||||
Overlays.editOverlay(HMD.tabletScreenID, {
|
||||
localPosition: { x: 0, y: WEB_ENTITY_Y_OFFSET, z: -WEB_ENTITY_Z_OFFSET },
|
||||
localPosition: { x: 0, y: WEB_ENTITY_Y_OFFSET, z: -WEB_ENTITY_Z_OFFSET},
|
||||
dimensions: {x: landscape ? screenHeight : screenWidth, y: landscape ? screenWidth : screenHeight, z: 0.1},
|
||||
dpi: tabletDpi
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue