Merge pull request #13321 from danteruiz/tablet-imporvments

Tablet improvements
This commit is contained in:
John Conklin II 2018-06-14 12:38:20 -07:00 committed by GitHub
commit d023d6adef
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
24 changed files with 117 additions and 104 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

View file

@ -56,7 +56,8 @@ class QScriptEngine;
* @property {Uuid} tabletID - The UUID of the tablet body model overlay. * @property {Uuid} tabletID - The UUID of the tablet body model overlay.
* @property {Uuid} tabletScreenID - The UUID of the tablet's screen overlay. * @property {Uuid} tabletScreenID - The UUID of the tablet's screen overlay.
* @property {Uuid} homeButtonID - The UUID of the tablet's "home" button overlay. * @property {Uuid} homeButtonID - The UUID of the tablet's "home" button overlay.
* @property {Uuid} homeButtonHighlightID - The UUID of the tablet's "home" button highlight overlay. * @property {Uuid} homeButtonHighlightMaterialID - The UUID of the material entity used to highlight tablet button
* @property {Uuid} homeButtonUnhighlightMaterialID - The UUID of the material entity use to unhighlight the entity
*/ */
class HMDScriptingInterface : public AbstractHMDScriptingInterface, public Dependency { class HMDScriptingInterface : public AbstractHMDScriptingInterface, public Dependency {
Q_OBJECT Q_OBJECT
@ -67,8 +68,9 @@ class HMDScriptingInterface : public AbstractHMDScriptingInterface, public Depen
Q_PROPERTY(bool tabletContextualMode READ getTabletContextualMode) Q_PROPERTY(bool tabletContextualMode READ getTabletContextualMode)
Q_PROPERTY(QUuid tabletID READ getCurrentTabletFrameID WRITE setCurrentTabletFrameID) Q_PROPERTY(QUuid tabletID READ getCurrentTabletFrameID WRITE setCurrentTabletFrameID)
Q_PROPERTY(QUuid homeButtonID READ getCurrentHomeButtonID WRITE setCurrentHomeButtonID) Q_PROPERTY(QUuid homeButtonID READ getCurrentHomeButtonID WRITE setCurrentHomeButtonID)
Q_PROPERTY(QUuid homeButtonHighlightID READ getCurrentHomeButtonHightlightID WRITE setCurrentHomeButtonHightlightID)
Q_PROPERTY(QUuid tabletScreenID READ getCurrentTabletScreenID WRITE setCurrentTabletScreenID) Q_PROPERTY(QUuid tabletScreenID READ getCurrentTabletScreenID WRITE setCurrentTabletScreenID)
Q_PROPERTY(QUuid homeButtonHighlightMaterialID READ getCurrentHomeButtonHighlightMaterialID WRITE setCurrentHomeButtonHighlightMaterialID)
Q_PROPERTY(QUuid homeButtonUnhighlightMaterialID READ getCurrentHomeButtonUnhighlightMaterialID WRITE setCurrentHomeButtonUnhighlightMaterialID)
public: public:
@ -372,20 +374,24 @@ public:
void setCurrentHomeButtonID(QUuid homeButtonID) { _homeButtonID = homeButtonID; } void setCurrentHomeButtonID(QUuid homeButtonID) { _homeButtonID = homeButtonID; }
QUuid getCurrentHomeButtonID() const { return _homeButtonID; } QUuid getCurrentHomeButtonID() const { return _homeButtonID; }
void setCurrentHomeButtonHightlightID(QUuid homeButtonHightlightID) { _homeButtonHightlightID = homeButtonHightlightID; }
QUuid getCurrentHomeButtonHightlightID() const { return _homeButtonHightlightID; }
void setCurrentTabletScreenID(QUuid tabletID) { _tabletScreenID = tabletID; } void setCurrentTabletScreenID(QUuid tabletID) { _tabletScreenID = tabletID; }
QUuid getCurrentTabletScreenID() const { return _tabletScreenID; } QUuid getCurrentTabletScreenID() const { return _tabletScreenID; }
void setCurrentHomeButtonHighlightMaterialID(QUuid homeButtonHighlightMaterialID) { _homeButtonHighlightMaterialID = homeButtonHighlightMaterialID; }
QUuid getCurrentHomeButtonHighlightMaterialID() { return _homeButtonHighlightMaterialID; }
void setCurrentHomeButtonUnhighlightMaterialID(QUuid homeButtonUnhighlightMaterialID) { _homeButtonUnhighlightMaterialID = homeButtonUnhighlightMaterialID; }
QUuid getCurrentHomeButtonUnhighlightMaterialID() { return _homeButtonUnhighlightMaterialID; }
private: private:
bool _showTablet { false }; bool _showTablet { false };
bool _tabletContextualMode { false }; bool _tabletContextualMode { false };
QUuid _tabletUIID; // this is the entityID of the tablet frame QUuid _tabletUIID; // this is the entityID of the tablet frame
QUuid _tabletScreenID; // this is the overlayID which is part of (a child of) the tablet-ui. QUuid _tabletScreenID; // this is the overlayID which is part of (a child of) the tablet-ui.
QUuid _homeButtonID; QUuid _homeButtonID;
QUuid _homeButtonHightlightID;
QUuid _tabletEntityID; QUuid _tabletEntityID;
QUuid _homeButtonHighlightMaterialID;
QUuid _homeButtonUnhighlightMaterialID;
// Get the position of the HMD // Get the position of the HMD
glm::vec3 getPosition() const; glm::vec3 getPosition() const;

View file

@ -283,7 +283,7 @@ QVariant Base3DOverlay::getProperty(const QString& property) {
} }
bool Base3DOverlay::findRayIntersection(const glm::vec3& origin, const glm::vec3& direction, 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; return false;
} }

View file

@ -69,11 +69,11 @@ public:
virtual QVariant getProperty(const QString& property) override; virtual QVariant getProperty(const QString& property) override;
virtual bool findRayIntersection(const glm::vec3& origin, const glm::vec3& direction, float& distance, 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, virtual bool 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 = false) {
return findRayIntersection(origin, direction, distance, face, surfaceNormal); return findRayIntersection(origin, direction, distance, face, surfaceNormal, precisionPicking);
} }
virtual SpatialParentTree* getParentTree() const override; virtual SpatialParentTree* getParentTree() const override;

View file

@ -521,7 +521,7 @@ QVariant Circle3DOverlay::getProperty(const QString& property) {
} }
bool Circle3DOverlay::findRayIntersection(const glm::vec3& origin, const glm::vec3& direction, float& distance, 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 // Scale the dimensions by the diameter
glm::vec2 dimensions = getOuterRadius() * 2.0f * getDimensions(); glm::vec2 dimensions = getOuterRadius() * 2.0f * getDimensions();

View file

@ -55,7 +55,7 @@ public:
void setMinorTickMarksColor(const xColor& value) { _minorTickMarksColor = value; } void setMinorTickMarksColor(const xColor& value) { _minorTickMarksColor = value; }
virtual bool findRayIntersection(const glm::vec3& origin, const glm::vec3& direction, float& distance, 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; virtual Circle3DOverlay* createClone() const override;

View file

@ -35,7 +35,7 @@ public:
virtual Grid3DOverlay* createClone() const override; virtual Grid3DOverlay* createClone() const override;
// Grids are UI tools, and may not be intersected (pickable) // 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: protected:
Transform evalRenderTransform() override; Transform evalRenderTransform() override;

View file

@ -258,7 +258,7 @@ void Image3DOverlay::setURL(const QString& url) {
} }
bool Image3DOverlay::findRayIntersection(const glm::vec3& origin, const glm::vec3& direction, 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()) { if (_texture && _texture->isLoaded()) {
// Make sure position and rotation is updated. // Make sure position and rotation is updated.
Transform transform = getTransform(); Transform transform = getTransform();

View file

@ -43,7 +43,7 @@ public:
bool isTransparent() override { return Base3DOverlay::isTransparent() || _alphaTexture; } bool isTransparent() override { return Base3DOverlay::isTransparent() || _alphaTexture; }
virtual bool findRayIntersection(const glm::vec3& origin, const glm::vec3& direction, float& distance, 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; virtual Image3DOverlay* createClone() const override;

View file

@ -509,16 +509,16 @@ QVariant ModelOverlay::getProperty(const QString& property) {
} }
bool ModelOverlay::findRayIntersection(const glm::vec3& origin, const glm::vec3& direction, 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; 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, 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 { ModelOverlay* ModelOverlay::createClone() const {

View file

@ -45,9 +45,9 @@ public:
void setProperties(const QVariantMap& properties) override; void setProperties(const QVariantMap& properties) override;
QVariant getProperty(const QString& property) override; QVariant getProperty(const QString& property) override;
virtual bool findRayIntersection(const glm::vec3& origin, const glm::vec3& direction, float& distance, 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, 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; virtual ModelOverlay* createClone() const override;

View file

@ -554,7 +554,7 @@ RayToOverlayIntersectionResult Overlays::findRayIntersectionVector(const PickRay
glm::vec3 thisSurfaceNormal; glm::vec3 thisSurfaceNormal;
QVariantMap thisExtraInfo; QVariantMap thisExtraInfo;
if (thisOverlay->findRayIntersectionExtraInfo(ray.origin, ray.direction, thisDistance, if (thisOverlay->findRayIntersectionExtraInfo(ray.origin, ray.direction, thisDistance,
thisFace, thisSurfaceNormal, thisExtraInfo)) { thisFace, thisSurfaceNormal, thisExtraInfo, precisionPicking)) {
bool isDrawInFront = thisOverlay->getDrawInFront(); bool isDrawInFront = thisOverlay->getDrawInFront();
if ((bestIsFront && isDrawInFront && thisDistance < bestDistance) if ((bestIsFront && isDrawInFront && thisDistance < bestDistance)
|| (!bestIsFront && (isDrawInFront || thisDistance < bestDistance))) { || (!bestIsFront && (isDrawInFront || thisDistance < bestDistance))) {

View file

@ -71,7 +71,7 @@ QVariant Planar3DOverlay::getProperty(const QString& property) {
} }
bool Planar3DOverlay::findRayIntersection(const glm::vec3& origin, const glm::vec3& direction, 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 // FIXME - face and surfaceNormal not being returned
return findRayRectangleIntersection(origin, direction, getWorldOrientation(), getWorldPosition(), getDimensions(), distance); return findRayRectangleIntersection(origin, direction, getWorldOrientation(), getWorldPosition(), getDimensions(), distance);
} }

View file

@ -31,7 +31,7 @@ public:
virtual QVariant getProperty(const QString& property) override; virtual QVariant getProperty(const QString& property) override;
virtual bool findRayIntersection(const glm::vec3& origin, const glm::vec3& direction, float& distance, 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: protected:
glm::vec2 _dimensions; glm::vec2 _dimensions;

View file

@ -76,7 +76,7 @@ QVariant Volume3DOverlay::getProperty(const QString& property) {
} }
bool Volume3DOverlay::findRayIntersection(const glm::vec3& origin, const glm::vec3& direction, 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 // extents is the entity relative, scaled, centered extents of the entity
glm::mat4 worldToEntityMatrix; glm::mat4 worldToEntityMatrix;
Transform transform = getTransform(); Transform transform = getTransform();

View file

@ -31,7 +31,7 @@ public:
QVariant getProperty(const QString& property) override; QVariant getProperty(const QString& property) override;
virtual bool findRayIntersection(const glm::vec3& origin, const glm::vec3& direction, float& distance, 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: protected:
// Centered local bounding box // Centered local bounding box

View file

@ -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::vec2 dimensions = getDimensions();
glm::quat rotation = getWorldOrientation(); glm::quat rotation = getWorldOrientation();
glm::vec3 position = getWorldPosition(); glm::vec3 position = getWorldPosition();

View file

@ -53,7 +53,7 @@ public:
QVariant getProperty(const QString& property) override; QVariant getProperty(const QString& property) override;
virtual bool findRayIntersection(const glm::vec3& origin, const glm::vec3& direction, float& distance, 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; virtual Web3DOverlay* createClone() const override;

View file

@ -15,6 +15,7 @@ Script.include(Script.resolvePath("../libraries/controllers.js"));
Script.include(Script.resolvePath("../libraries/Xform.js")); Script.include(Script.resolvePath("../libraries/Xform.js"));
var Y_AXIS = {x: 0, y: 1, z: 0}; var Y_AXIS = {x: 0, y: 1, z: 0};
var X_AXIS = {x: 1, y: 0, z: 0};
var DEFAULT_DPI = 31; var DEFAULT_DPI = 31;
var DEFAULT_WIDTH = 0.4375; var DEFAULT_WIDTH = 0.4375;
var DEFAULT_VERTICAL_FIELD_OF_VIEW = 45; // degrees var DEFAULT_VERTICAL_FIELD_OF_VIEW = 45; // degrees
@ -33,10 +34,16 @@ var DELAY_FOR_30HZ = 33; // milliseconds
// will need to be recaclulated if dimensions of fbx model change. // will need to be recaclulated if dimensions of fbx model change.
var TABLET_NATURAL_DIMENSIONS = {x: 32.083, y: 48.553, z: 2.269}; var TABLET_NATURAL_DIMENSIONS = {x: 32.083, y: 48.553, z: 2.269};
var HOME_BUTTON_TEXTURE = "http://hifi-content.s3.amazonaws.com/alan/dev/tablet-with-home-button.fbx/tablet-with-home-button.fbm/button-close.png"; var HOME_BUTTON_TEXTURE = Script.resourcesPath() + "images/button-close.png";
// var HOME_BUTTON_TEXTURE = Script.resourcesPath() + "meshes/tablet-with-home-button.fbx/tablet-with-home-button.fbm/button-close.png"; // var HOME_BUTTON_TEXTURE = Script.resourcesPath() + "meshes/tablet-with-home-button.fbx/tablet-with-home-button.fbm/button-close.png";
// var TABLET_MODEL_PATH = "http://hifi-content.s3.amazonaws.com/alan/dev/tablet-with-home-button.fbx"; // var TABLET_MODEL_PATH = "http://hifi-content.s3.amazonaws.com/alan/dev/tablet-with-home-button.fbx";
var LOCAL_BEZEL_HIGHLIGHT = Script.resourcesPath() + "images/buttonBezel_highlight.png";
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 LOCAL_TABLET_MODEL_PATH = Script.resourcesPath() + "meshes/tablet-with-home-button-small-bezel.fbx";
var HIGH_PRIORITY = 1;
var LOW_PRIORITY = 0;
var SUBMESH = 2;
// returns object with two fields: // returns object with two fields:
// * position - position in front of the user // * position - position in front of the user
@ -134,11 +141,10 @@ WebTablet = function (url, width, dpi, hand, clientOnly, location, visible) {
Overlays.deleteOverlay(this.webOverlayID); 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.5) * sensorScaleFactor;
var WEB_ENTITY_Z_OFFSET = (tabletDepth / 2.0) / sensorScaleFactor + RAYPICK_OFFSET; var WEB_ENTITY_Y_OFFSET = 1.25 * tabletScaleFactor;
var WEB_ENTITY_Y_OFFSET = 1 * tabletScaleFactor; var screenWidth = 0.9367 * tabletWidth;
var screenWidth = 0.9275 * tabletWidth; var screenHeight = 0.9000 * tabletHeight;
var screenHeight = 0.8983 * tabletHeight;
this.webOverlayID = Overlays.addOverlay("web3d", { this.webOverlayID = Overlays.addOverlay("web3d", {
name: "WebTablet Web", name: "WebTablet Web",
url: url, url: url,
@ -154,12 +160,14 @@ WebTablet = function (url, width, dpi, hand, clientOnly, location, visible) {
visible: visible visible: visible
}); });
var HOME_BUTTON_Y_OFFSET = (tabletHeight / 2) - (tabletHeight / 20) + 0.003 * sensorScaleFactor;
// FIXME: Circle3D overlays currently at the wrong dimensions, so we need to account for that here // 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 / 3.0;
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;
this.homeButtonID = Overlays.addOverlay("circle3d", { this.homeButtonID = Overlays.addOverlay("circle3d", {
name: "homeButton", name: "homeButton",
localPosition: { x: 0.0, y: -HOME_BUTTON_Y_OFFSET, z: -WEB_ENTITY_Z_OFFSET }, localPosition: { x: HOME_BUTTON_X_OFFSET, y: HOME_BUTTON_Y_OFFSET, z: -HOME_BUTTON_Z_OFFSET },
localRotation: { x: 0, y: 1, z: 0, w: 0}, localRotation: { x: 0, y: 1, z: 0, w: 0},
dimensions: { x: homeButtonDim, y: homeButtonDim, z: homeButtonDim }, dimensions: { x: homeButtonDim, y: homeButtonDim, z: homeButtonDim },
solid: true, solid: true,
@ -170,24 +178,46 @@ WebTablet = function (url, width, dpi, hand, clientOnly, location, visible) {
parentJointIndex: -1 parentJointIndex: -1
}); });
this.homeButtonHighlightID = Overlays.addOverlay("circle3d", { this.homeButtonUnhighlightMaterial = Entities.addEntity({
name: "homeButtonHighlight", type: "Material",
localPosition: { x: 0, y: -HOME_BUTTON_Y_OFFSET, z: -WEB_ENTITY_Z_OFFSET }, materialURL: "materialData",
localRotation: { x: 0, y: 1, z: 0, w: 0 }, localPosition: { x: 0.0, y: 0.0, z: 0.0 },
dimensions: { x: homeButtonDim, y: homeButtonDim, z: homeButtonDim }, priority: HIGH_PRIORITY,
color: { red: 255, green: 255, blue: 255 }, materialData: JSON.stringify({
solid: true, materials: {
innerRadius: 0.9, albedoMap: LOCAL_NORMAL_BEZEL
ignoreIntersection: true, }
alpha: 1.0,
visible: visible, }),
drawInFront: false, userData: JSON.stringify({
parentID: this.tabletEntityID, "grabbableKey": {"grabbable": false}
parentJointIndex: -1 }),
}); visible: false,
parentMaterialName: SUBMESH,
parentID: this.tabletEntityID
}, true);
this.homeButtonHighlightMaterial = Entities.addEntity({
type: "Material",
materialURL: "materialData",
localPosition: { x: 0.0, y: 0.0, z: 0.0 },
priority: LOW_PRIORITY,
visible: false,
materialData: JSON.stringify({
materials: {
emissiveMap: LOCAL_BEZEL_HIGHLIGHT
}
}),
userData: JSON.stringify({
"grabbableKey": {"grabbable": false}
}),
parentMaterialName: SUBMESH,
parentID: this.tabletEntityID
}, true);
this.receive = function (channel, senderID, senderUUID, localOnly) { this.receive = function (channel, senderID, senderUUID, localOnly) {
if (_this.homeButtonID == 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();
var isMessageOpen; var isMessageOpen;
@ -339,7 +369,8 @@ WebTablet.prototype.destroy = function () {
Overlays.deleteOverlay(this.webOverlayID); Overlays.deleteOverlay(this.webOverlayID);
Overlays.deleteOverlay(this.tabletEntityID); Overlays.deleteOverlay(this.tabletEntityID);
Overlays.deleteOverlay(this.homeButtonID); Overlays.deleteOverlay(this.homeButtonID);
Overlays.deleteOverlay(this.homeButtonHighlightID); Entities.deleteEntity(this.homeButtonUnhighlightMaterial);
Entities.deleteEntity(this.homeButtonHighlightMaterial);
HMD.displayModeChanged.disconnect(this.myOnHmdChanged); HMD.displayModeChanged.disconnect(this.myOnHmdChanged);
Controller.mousePressEvent.disconnect(this.myMousePressEvent); Controller.mousePressEvent.disconnect(this.myMousePressEvent);
@ -433,21 +464,24 @@ WebTablet.prototype.calculateWorldAttitudeRelativeToCamera = function (windowPos
WebTablet.prototype.onHoverEnterOverlay = function (overlayID, pointerEvent) { WebTablet.prototype.onHoverEnterOverlay = function (overlayID, pointerEvent) {
if (overlayID === this.homeButtonID) { if (overlayID === this.homeButtonID) {
Overlays.editOverlay(this.homeButtonHighlightID, { alpha: 1.0 }); Entities.editEntity(this.homeButtonUnhighlightMaterial, {priority: LOW_PRIORITY});
Entities.editEntity(this.homeButtonHighlightMaterial, {priority: HIGH_PRIORITY});
} }
} };
WebTablet.prototype.onHoverOverOverlay = function (overlayID, pointerEvent) { WebTablet.prototype.onHoverOverOverlay = function (overlayID, pointerEvent) {
if (overlayID !== this.homeButtonID) { if (overlayID !== this.homeButtonID) {
Overlays.editOverlay(this.homeButtonHighlightID, { alpha: 0.0 }); Entities.editEntity(this.homeButtonUnhighlightMaterial, {priority: HIGH_PRIORITY});
Entities.editEntity(this.homeButtonHighlightMaterial, {priority: LOW_PRIORITY});
} }
} };
WebTablet.prototype.onHoverLeaveOverlay = function (overlayID, pointerEvent) { WebTablet.prototype.onHoverLeaveOverlay = function (overlayID, pointerEvent) {
if (overlayID === this.homeButtonID) { if (overlayID === this.homeButtonID) {
Overlays.editOverlay(this.homeButtonHighlightID, { alpha: 0.0 }); Entities.editEntity(this.homeButtonUnhighlightMaterial, {priority: HIGH_PRIORITY});
Entities.editEntity(this.homeButtonHighlightMaterial, {priority: LOW_PRIORITY});
} }
} };
// compute position, rotation & parentJointIndex of the tablet // compute position, rotation & parentJointIndex of the tablet
WebTablet.prototype.calculateTabletAttachmentProperties = function (hand, useMouse, tabletProperties) { WebTablet.prototype.calculateTabletAttachmentProperties = function (hand, useMouse, tabletProperties) {
@ -575,22 +609,6 @@ 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 });
}
WebTablet.prototype.mouseMoveEvent = function (event) { WebTablet.prototype.mouseMoveEvent = function (event) {
if (this.dragging) { if (this.dragging) {
this.currentMouse = { this.currentMouse = {
@ -598,8 +616,6 @@ WebTablet.prototype.mouseMoveEvent = function (event) {
y: event.y y: event.y
}; };
this.scheduleMouseMoveProcessor(); this.scheduleMouseMoveProcessor();
} else {
this.handleHomeButtonHover(event.x, event.y);
} }
}; };
@ -626,8 +642,6 @@ WebTablet.prototype.mouseMoveProcessor = function () {
}); });
} }
this.scheduleMouseMoveProcessor(); this.scheduleMouseMoveProcessor();
} else {
this.handleHomeButtonHover(this.currentMouse.x, this.currentMouse.y);
} }
}; };

View file

@ -32,7 +32,7 @@ if (!Function.prototype.bind) {
if (this.prototype) { if (this.prototype) {
// Function.prototype doesn't have a prototype property // Function.prototype doesn't have a prototype property
fNOP.prototype = this.prototype; fNOP.prototype = this.prototype;
} }
fBound.prototype = new fNOP(); fBound.prototype = new fNOP();
@ -370,7 +370,7 @@ getTabletWidthFromSettings = function () {
resizeTablet = function (width, newParentJointIndex, sensorToWorldScaleOverride) { resizeTablet = function (width, newParentJointIndex, sensorToWorldScaleOverride) {
if (!HMD.tabletID || !HMD.tabletScreenID || !HMD.homeButtonID || !HMD.homeButtonHighlightID) { if (!HMD.tabletID || !HMD.tabletScreenID || !HMD.homeButtonID) {
return; return;
} }
var sensorScaleFactor = sensorToWorldScaleOverride || MyAvatar.sensorToWorldScale; var sensorScaleFactor = sensorToWorldScaleOverride || MyAvatar.sensorToWorldScale;
@ -381,6 +381,7 @@ resizeTablet = function (width, newParentJointIndex, sensorToWorldScaleOverride)
sensorScaleOffsetOverride = 1 / sensorScaleFactor; sensorScaleOffsetOverride = 1 / sensorScaleFactor;
} }
// will need to be recaclulated if dimensions of fbx model change. // will need to be recaclulated if dimensions of fbx model change.
var TABLET_NATURAL_DIMENSIONS = {x: 32.083, y: 48.553, z: 2.269}; var TABLET_NATURAL_DIMENSIONS = {x: 32.083, y: 48.553, z: 2.269};
var DEFAULT_DPI = 31; var DEFAULT_DPI = 31;
@ -399,32 +400,26 @@ resizeTablet = function (width, newParentJointIndex, sensorToWorldScaleOverride)
}); });
// update webOverlay // 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.5) * sensorScaleOffsetOverride;
var WEB_ENTITY_Z_OFFSET = (tabletDepth / 2.0) * sensorScaleOffsetOverride + RAYPICK_OFFSET; var WEB_ENTITY_Y_OFFSET = 1.25 * tabletScaleFactor * sensorScaleOffsetOverride;
var WEB_ENTITY_Y_OFFSET = 1 * tabletScaleFactor; var screenWidth = 0.9367 * tabletWidth;
print(WEB_ENTITY_Y_OFFSET); var screenHeight = 0.9000 * tabletHeight;
var screenWidth = 0.9275 * tabletWidth;
var screenHeight = 0.8983 * tabletHeight;
var landscape = Tablet.getTablet("com.highfidelity.interface.tablet.system").landscape; var landscape = Tablet.getTablet("com.highfidelity.interface.tablet.system").landscape;
Overlays.editOverlay(HMD.tabletScreenID, { 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}, dimensions: {x: landscape ? screenHeight : screenWidth, y: landscape ? screenWidth : screenHeight, z: 0.1},
dpi: tabletDpi dpi: tabletDpi
}); });
// update homeButton // update homeButton
var HOME_BUTTON_Y_OFFSET = ((tabletHeight / 2) - (tabletHeight / 20) + 0.003 * sensorScaleFactor) * sensorScaleOffsetOverride;
// FIXME: Circle3D overlays currently at the wrong dimensions, so we need to account for that here // 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 / 3.0;
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;
Overlays.editOverlay(HMD.homeButtonID, { Overlays.editOverlay(HMD.homeButtonID, {
localPosition: { x: 0, y: -HOME_BUTTON_Y_OFFSET, z: -WEB_ENTITY_Z_OFFSET }, localPosition: { x: HOME_BUTTON_X_OFFSET, y: HOME_BUTTON_Y_OFFSET, z: -HOME_BUTTON_Z_OFFSET },
localRotation: Quat.angleAxis(180, Vec3.UNIT_Y), localRotation: { x: 0, y: 1, z: 0, w: 0 },
dimensions: { x: homeButtonDim, y: homeButtonDim, z: homeButtonDim }
});
Overlays.editOverlay(HMD.homeButtonHighlightID, {
localPosition: { x: 0, y: -HOME_BUTTON_Y_OFFSET, z: -WEB_ENTITY_Z_OFFSET },
localRotation: Quat.angleAxis(180, Vec3.UNIT_Y),
dimensions: { x: homeButtonDim, y: homeButtonDim, z: homeButtonDim } dimensions: { x: homeButtonDim, y: homeButtonDim, z: homeButtonDim }
}); });
}; };

View file

@ -114,7 +114,6 @@ var selectionDisplay = null; // for gridTool.js to ignore
Overlays.editOverlay(HMD.tabletID, { isVisibleInSecondaryCamera : visibleInSecondaryCam }); Overlays.editOverlay(HMD.tabletID, { isVisibleInSecondaryCamera : visibleInSecondaryCam });
Overlays.editOverlay(HMD.homeButtonID, { isVisibleInSecondaryCamera : visibleInSecondaryCam }); Overlays.editOverlay(HMD.homeButtonID, { isVisibleInSecondaryCamera : visibleInSecondaryCam });
Overlays.editOverlay(HMD.homeButtonHighlightIDtabletID, { isVisibleInSecondaryCamera : visibleInSecondaryCam });
Overlays.editOverlay(HMD.tabletScreenID, { isVisibleInSecondaryCamera : visibleInSecondaryCam }); Overlays.editOverlay(HMD.tabletScreenID, { isVisibleInSecondaryCamera : visibleInSecondaryCam });
} }

View file

@ -24,7 +24,7 @@
var validCheckTime = Date.now(); var validCheckTime = Date.now();
var debugTablet = false; var debugTablet = false;
var tabletScalePercentage = 70.0; var tabletScalePercentage = 70.0;
UIWebTablet = null; var UIWebTablet = null;
var MSECS_PER_SEC = 1000.0; var MSECS_PER_SEC = 1000.0;
var MUTE_MICROPHONE_MENU_ITEM = "Mute Microphone"; var MUTE_MICROPHONE_MENU_ITEM = "Mute Microphone";
var gTablet = null; var gTablet = null;
@ -103,8 +103,9 @@
UIWebTablet.register(); UIWebTablet.register();
HMD.tabletID = UIWebTablet.tabletEntityID; HMD.tabletID = UIWebTablet.tabletEntityID;
HMD.homeButtonID = UIWebTablet.homeButtonID; HMD.homeButtonID = UIWebTablet.homeButtonID;
HMD.homeButtonHighlightID = UIWebTablet.homeButtonHighlightID;
HMD.tabletScreenID = UIWebTablet.webOverlayID; HMD.tabletScreenID = UIWebTablet.webOverlayID;
HMD.homeButtonHighlightMaterialID = UIWebTablet.homeButtonHighlightMaterial;
HMD.homeButtonUnhighlightMaterialID = UIWebTablet.homeButtonUnhighlightMaterial;
HMD.displayModeChanged.connect(onHmdChanged); HMD.displayModeChanged.connect(onHmdChanged);
MyAvatar.sensorToWorldScaleChanged.connect(onSensorToWorldScaleChanged); MyAvatar.sensorToWorldScaleChanged.connect(onSensorToWorldScaleChanged);
@ -130,7 +131,6 @@
tabletProperties.visible = true; tabletProperties.visible = true;
Overlays.editOverlay(HMD.tabletID, tabletProperties); Overlays.editOverlay(HMD.tabletID, tabletProperties);
Overlays.editOverlay(HMD.homeButtonID, { visible: true }); Overlays.editOverlay(HMD.homeButtonID, { visible: true });
Overlays.editOverlay(HMD.homeButtonHighlightID, { visible: true });
Overlays.editOverlay(HMD.tabletScreenID, { visible: true }); Overlays.editOverlay(HMD.tabletScreenID, { visible: true });
Overlays.editOverlay(HMD.tabletScreenID, { maxFPS: 90 }); Overlays.editOverlay(HMD.tabletScreenID, { maxFPS: 90 });
updateTabletWidthFromSettings(true); updateTabletWidthFromSettings(true);
@ -151,7 +151,6 @@
Overlays.editOverlay(HMD.tabletID, { visible: false }); Overlays.editOverlay(HMD.tabletID, { visible: false });
Overlays.editOverlay(HMD.homeButtonID, { visible: false }); Overlays.editOverlay(HMD.homeButtonID, { visible: false });
Overlays.editOverlay(HMD.homeButtonHighlightID, { visible: false });
Overlays.editOverlay(HMD.tabletScreenID, { visible: false }); Overlays.editOverlay(HMD.tabletScreenID, { visible: false });
Overlays.editOverlay(HMD.tabletScreenID, { maxFPS: 1 }); Overlays.editOverlay(HMD.tabletScreenID, { maxFPS: 1 });
} }
@ -172,7 +171,6 @@
UIWebTablet = null; UIWebTablet = null;
HMD.tabletID = null; HMD.tabletID = null;
HMD.homeButtonID = null; HMD.homeButtonID = null;
HMD.homeButtonHighlightID = null;
HMD.tabletScreenID = null; HMD.tabletScreenID = null;
} else if (debugTablet) { } else if (debugTablet) {
print("TABLET closeTabletUI, UIWebTablet is null"); print("TABLET closeTabletUI, UIWebTablet is null");
@ -325,7 +323,8 @@
Overlays.deleteOverlay(tabletID); Overlays.deleteOverlay(tabletID);
HMD.tabletID = null; HMD.tabletID = null;
HMD.homeButtonID = null; HMD.homeButtonID = null;
HMD.homeButtonHighlightID = null;
HMD.tabletScreenID = null; HMD.tabletScreenID = null;
HMD.homeButtonHighlightMaterialID = null;
HMD.homeButtonUnhighlightMaterialID = null;
}); });
}()); // END LOCAL_SCOPE }()); // END LOCAL_SCOPE