mirror of
https://github.com/overte-org/overte.git
synced 2025-04-14 22:47:54 +02:00
Change tablet dimensions as sensorToWorldScale changes
This commit is contained in:
parent
c9cdaadeb5
commit
6e6687c3a6
7 changed files with 40 additions and 13 deletions
|
@ -16,6 +16,9 @@
|
||||||
|
|
||||||
#include "Overlay.h"
|
#include "Overlay.h"
|
||||||
|
|
||||||
|
// AJT: keep or remove this.
|
||||||
|
// #define USE_SN_SCALE
|
||||||
|
|
||||||
class Base3DOverlay : public Overlay, public SpatiallyNestable {
|
class Base3DOverlay : public Overlay, public SpatiallyNestable {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
|
|
|
@ -47,7 +47,9 @@ void ModelOverlay::update(float deltatime) {
|
||||||
_updateModel = false;
|
_updateModel = false;
|
||||||
_model->setSnapModelToCenter(true);
|
_model->setSnapModelToCenter(true);
|
||||||
Transform transform = getTransform();
|
Transform transform = getTransform();
|
||||||
|
#ifndef USE_SN_SCALE
|
||||||
transform.setScale(1.0f); // disable inherited scale
|
transform.setScale(1.0f); // disable inherited scale
|
||||||
|
#endif
|
||||||
if (_scaleToFit) {
|
if (_scaleToFit) {
|
||||||
_model->setScaleToFit(true, transform.getScale() * getDimensions());
|
_model->setScaleToFit(true, transform.getScale() * getDimensions());
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -40,6 +40,9 @@ void Sphere3DOverlay::render(RenderArgs* args) {
|
||||||
|
|
||||||
if (batch) {
|
if (batch) {
|
||||||
Transform transform = getTransform();
|
Transform transform = getTransform();
|
||||||
|
#ifndef USE_SN_SCALE
|
||||||
|
transform.setScale(1.0f); // ignore inherited scale from SpatiallyNestable
|
||||||
|
#endif
|
||||||
transform.postScale(getDimensions() * SPHERE_OVERLAY_SCALE);
|
transform.postScale(getDimensions() * SPHERE_OVERLAY_SCALE);
|
||||||
batch->setModelTransform(transform);
|
batch->setModelTransform(transform);
|
||||||
|
|
||||||
|
|
|
@ -56,7 +56,11 @@ bool Volume3DOverlay::findRayIntersection(const glm::vec3& origin, const glm::ve
|
||||||
float& distance, BoxFace& face, glm::vec3& surfaceNormal) {
|
float& distance, BoxFace& face, glm::vec3& surfaceNormal) {
|
||||||
// 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;
|
||||||
getTransform().getInverseMatrix(worldToEntityMatrix);
|
Transform transform = getTransform();
|
||||||
|
#ifndef USE_SN_SCALE
|
||||||
|
transform.setScale(1.0f); // ignore any inherited scale from SpatiallyNestable
|
||||||
|
#endif
|
||||||
|
transform.getInverseMatrix(worldToEntityMatrix);
|
||||||
|
|
||||||
glm::vec3 overlayFrameOrigin = glm::vec3(worldToEntityMatrix * glm::vec4(origin, 1.0f));
|
glm::vec3 overlayFrameOrigin = glm::vec3(worldToEntityMatrix * glm::vec4(origin, 1.0f));
|
||||||
glm::vec3 overlayFrameDirection = glm::vec3(worldToEntityMatrix * glm::vec4(direction, 0.0f));
|
glm::vec3 overlayFrameDirection = glm::vec3(worldToEntityMatrix * glm::vec4(direction, 0.0f));
|
||||||
|
|
|
@ -305,7 +305,9 @@ void Web3DOverlay::render(RenderArgs* args) {
|
||||||
vec4 color(toGlm(getColor()), getAlpha());
|
vec4 color(toGlm(getColor()), getAlpha());
|
||||||
|
|
||||||
Transform transform = getTransform();
|
Transform transform = getTransform();
|
||||||
|
#ifndef USE_SN_SCALE
|
||||||
transform.setScale(1.0f); // ignore inherited scale factor from parents
|
transform.setScale(1.0f); // ignore inherited scale factor from parents
|
||||||
|
#endif
|
||||||
if (glm::length2(getDimensions()) != 1.0f) {
|
if (glm::length2(getDimensions()) != 1.0f) {
|
||||||
transform.postScale(vec3(getDimensions(), 1.0f));
|
transform.postScale(vec3(getDimensions(), 1.0f));
|
||||||
}
|
}
|
||||||
|
|
|
@ -106,8 +106,10 @@ WebTablet = function (url, width, dpi, hand, clientOnly, location, visible) {
|
||||||
|
|
||||||
var _this = this;
|
var _this = this;
|
||||||
|
|
||||||
|
var sensorScaleFactor = MyAvatar.sensorToWorldScale;
|
||||||
|
|
||||||
// scale factor of natural tablet dimensions.
|
// scale factor of natural tablet dimensions.
|
||||||
this.width = width || DEFAULT_WIDTH;
|
this.width = (width || DEFAULT_WIDTH) * sensorScaleFactor;
|
||||||
var tabletScaleFactor = this.width / TABLET_NATURAL_DIMENSIONS.x;
|
var tabletScaleFactor = this.width / TABLET_NATURAL_DIMENSIONS.x;
|
||||||
this.height = TABLET_NATURAL_DIMENSIONS.y * tabletScaleFactor;
|
this.height = TABLET_NATURAL_DIMENSIONS.y * tabletScaleFactor;
|
||||||
this.depth = TABLET_NATURAL_DIMENSIONS.z * tabletScaleFactor;
|
this.depth = TABLET_NATURAL_DIMENSIONS.z * tabletScaleFactor;
|
||||||
|
@ -152,8 +154,8 @@ WebTablet = function (url, width, dpi, hand, clientOnly, location, visible) {
|
||||||
Overlays.deleteOverlay(this.webOverlayID);
|
Overlays.deleteOverlay(this.webOverlayID);
|
||||||
}
|
}
|
||||||
|
|
||||||
var WEB_ENTITY_Z_OFFSET = (this.depth / 2);
|
var WEB_ENTITY_Z_OFFSET = (this.depth / 2) * (1 / sensorScaleFactor);
|
||||||
var WEB_ENTITY_Y_OFFSET = 0.004;
|
var WEB_ENTITY_Y_OFFSET = 0.004 * (1 / sensorScaleFactor);
|
||||||
|
|
||||||
this.webOverlayID = Overlays.addOverlay("web3d", {
|
this.webOverlayID = Overlays.addOverlay("web3d", {
|
||||||
name: "WebTablet Web",
|
name: "WebTablet Web",
|
||||||
|
@ -170,13 +172,13 @@ WebTablet = function (url, width, dpi, hand, clientOnly, location, visible) {
|
||||||
visible: visible
|
visible: visible
|
||||||
});
|
});
|
||||||
|
|
||||||
var HOME_BUTTON_Y_OFFSET = (this.height / 2) - (this.height / 20);
|
var HOME_BUTTON_Y_OFFSET = ((this.height / 2) - (this.height / 20)) * (1 / sensorScaleFactor);
|
||||||
this.homeButtonID = Overlays.addOverlay("sphere", {
|
this.homeButtonID = Overlays.addOverlay("sphere", {
|
||||||
name: "homeButton",
|
name: "homeButton",
|
||||||
localPosition: {x: -0.001, y: -HOME_BUTTON_Y_OFFSET, z: 0.0},
|
localPosition: {x: -0.001, y: -HOME_BUTTON_Y_OFFSET, z: 0.0},
|
||||||
localRotation: {x: 0, y: 1, z: 0, w: 0},
|
localRotation: {x: 0, y: 1, z: 0, w: 0},
|
||||||
dimensions: { x: 4 * tabletScaleFactor, y: 4 * tabletScaleFactor, z: 4 * tabletScaleFactor},
|
dimensions: { x: 4 * tabletScaleFactor, y: 4 * tabletScaleFactor, z: 4 * tabletScaleFactor},
|
||||||
alpha: 0.0,
|
alpha: 1.0,
|
||||||
visible: visible,
|
visible: visible,
|
||||||
drawInFront: false,
|
drawInFront: false,
|
||||||
parentID: this.tabletEntityID,
|
parentID: this.tabletEntityID,
|
||||||
|
@ -301,9 +303,10 @@ WebTablet.prototype.getOverlayObject = function () {
|
||||||
};
|
};
|
||||||
|
|
||||||
WebTablet.prototype.setWidth = function (width) {
|
WebTablet.prototype.setWidth = function (width) {
|
||||||
|
var sensorScaleFactor = MyAvatar.sensorToWorldScale;
|
||||||
|
|
||||||
// scale factor of natural tablet dimensions.
|
// scale factor of natural tablet dimensions.
|
||||||
this.width = width || DEFAULT_WIDTH;
|
this.width = (width || DEFAULT_WIDTH) * sensorScaleFactor;
|
||||||
var tabletScaleFactor = this.width / TABLET_NATURAL_DIMENSIONS.x;
|
var tabletScaleFactor = this.width / TABLET_NATURAL_DIMENSIONS.x;
|
||||||
this.height = TABLET_NATURAL_DIMENSIONS.y * tabletScaleFactor;
|
this.height = TABLET_NATURAL_DIMENSIONS.y * tabletScaleFactor;
|
||||||
this.depth = TABLET_NATURAL_DIMENSIONS.z * tabletScaleFactor;
|
this.depth = TABLET_NATURAL_DIMENSIONS.z * tabletScaleFactor;
|
||||||
|
@ -313,15 +316,15 @@ WebTablet.prototype.setWidth = function (width) {
|
||||||
Overlays.editOverlay(this.tabletEntityID, { dimensions: this.getDimensions() });
|
Overlays.editOverlay(this.tabletEntityID, { dimensions: this.getDimensions() });
|
||||||
|
|
||||||
// update webOverlay
|
// update webOverlay
|
||||||
var WEB_ENTITY_Z_OFFSET = (this.depth / 2);
|
var WEB_ENTITY_Z_OFFSET = (this.depth / 2) * (1 / sensorScaleFactor);
|
||||||
var WEB_ENTITY_Y_OFFSET = 0.004;
|
var WEB_ENTITY_Y_OFFSET = 0.004 * (1 / sensorScaleFactor);
|
||||||
Overlays.editOverlay(this.webOverlayID, {
|
Overlays.editOverlay(this.webOverlayID, {
|
||||||
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 },
|
||||||
dpi: this.dpi
|
dpi: this.dpi
|
||||||
});
|
});
|
||||||
|
|
||||||
// update homeButton
|
// update homeButton
|
||||||
var HOME_BUTTON_Y_OFFSET = (this.height / 2) - (this.height / 20);
|
var HOME_BUTTON_Y_OFFSET = ((this.height / 2) - (this.height / 20)) * (1 / sensorScaleFactor);
|
||||||
Overlays.editOverlay(this.homeButtonID, {
|
Overlays.editOverlay(this.homeButtonID, {
|
||||||
localPosition: {x: -0.001, y: -HOME_BUTTON_Y_OFFSET, z: 0.0},
|
localPosition: {x: -0.001, y: -HOME_BUTTON_Y_OFFSET, z: 0.0},
|
||||||
dimensions: { x: 4 * tabletScaleFactor, y: 4 * tabletScaleFactor, z: 4 * tabletScaleFactor}
|
dimensions: { x: 4 * tabletScaleFactor, y: 4 * tabletScaleFactor, z: 4 * tabletScaleFactor}
|
||||||
|
|
|
@ -28,6 +28,7 @@
|
||||||
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;
|
||||||
|
var avatarSensorScale = MyAvatar.sensorToWorldScale;
|
||||||
|
|
||||||
Script.include("../libraries/WebTablet.js");
|
Script.include("../libraries/WebTablet.js");
|
||||||
|
|
||||||
|
@ -71,9 +72,9 @@
|
||||||
return tabletScalePercentage;
|
return tabletScalePercentage;
|
||||||
}
|
}
|
||||||
|
|
||||||
function updateTabletWidthFromSettings() {
|
function updateTabletWidthFromSettings(force) {
|
||||||
var newTabletScalePercentage = getTabletScalePercentageFromSettings();
|
var newTabletScalePercentage = getTabletScalePercentageFromSettings();
|
||||||
if (newTabletScalePercentage !== tabletScalePercentage && UIWebTablet) {
|
if ((force || newTabletScalePercentage !== tabletScalePercentage) && UIWebTablet) {
|
||||||
tabletScalePercentage = newTabletScalePercentage;
|
tabletScalePercentage = newTabletScalePercentage;
|
||||||
UIWebTablet.setWidth(DEFAULT_WIDTH * (tabletScalePercentage / 100));
|
UIWebTablet.setWidth(DEFAULT_WIDTH * (tabletScalePercentage / 100));
|
||||||
}
|
}
|
||||||
|
@ -121,6 +122,7 @@
|
||||||
Overlays.editOverlay(HMD.homeButtonID, { visible: true });
|
Overlays.editOverlay(HMD.homeButtonID, { 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);
|
||||||
}
|
}
|
||||||
gTablet.tabletShown = true;
|
gTablet.tabletShown = true;
|
||||||
}
|
}
|
||||||
|
@ -185,7 +187,15 @@
|
||||||
|
|
||||||
if (now - validCheckTime > MSECS_PER_SEC) {
|
if (now - validCheckTime > MSECS_PER_SEC) {
|
||||||
validCheckTime = now;
|
validCheckTime = now;
|
||||||
updateTabletWidthFromSettings();
|
|
||||||
|
// force tablet to resize if sensorToWorldScale changes
|
||||||
|
var force = false;
|
||||||
|
if (avatarSensorScale !== MyAvatar.sensorToWorldScale) {
|
||||||
|
force = true;
|
||||||
|
avatarSensorScale = MyAvatar.sensorToWorldScale;
|
||||||
|
}
|
||||||
|
updateTabletWidthFromSettings(force);
|
||||||
|
|
||||||
if (UIWebTablet) {
|
if (UIWebTablet) {
|
||||||
UIWebTablet.setLandscape(landscape);
|
UIWebTablet.setLandscape(landscape);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue