home button is circle instead of sphere, fixed positioning, fix lasers on tablet

This commit is contained in:
SamGondelman 2017-11-17 14:00:01 -08:00
parent 42d047c572
commit 393ad0079c
6 changed files with 24 additions and 39 deletions

View file

@ -58,7 +58,6 @@
static int MAX_WINDOW_SIZE = 4096; static int MAX_WINDOW_SIZE = 4096;
static const float INCHES_TO_METERS = 1.0f / 39.3701f;
static const float METERS_TO_INCHES = 39.3701f; static const float METERS_TO_INCHES = 39.3701f;
static const float OPAQUE_ALPHA_THRESHOLD = 0.99f; static const float OPAQUE_ALPHA_THRESHOLD = 0.99f;

View file

@ -137,12 +137,15 @@ WebTablet = function (url, width, dpi, hand, clientOnly, location, visible) {
visible: visible visible: visible
}); });
var HOME_BUTTON_Y_OFFSET = ((tabletHeight / 2) - (tabletHeight / 20)) * (1 / sensorScaleFactor); var HOME_BUTTON_Y_OFFSET = ((tabletHeight / 2) - (tabletHeight / 20)) * (1 / sensorScaleFactor) - 0.003;
this.homeButtonID = Overlays.addOverlay("sphere", { // FIXME: Circle3D overlays currently at the wrong dimensions, so we need to account for that here
var homeButtonDim = 4.0 * tabletScaleFactor / 3.0;
this.homeButtonID = Overlays.addOverlay("circle3d", {
name: "homeButton", name: "homeButton",
localPosition: {x: 0.0, y: -HOME_BUTTON_Y_OFFSET, z: 0.0}, localPosition: { x: 0.0, y: -HOME_BUTTON_Y_OFFSET, z: -WEB_ENTITY_Z_OFFSET },
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: homeButtonDim, y: homeButtonDim, z: homeButtonDim },
solid: true,
alpha: 0.0, alpha: 0.0,
visible: visible, visible: visible,
drawInFront: false, drawInFront: false,
@ -152,14 +155,14 @@ WebTablet = function (url, width, dpi, hand, clientOnly, location, visible) {
this.homeButtonHighlightID = Overlays.addOverlay("circle3d", { this.homeButtonHighlightID = Overlays.addOverlay("circle3d", {
name: "homeButtonHighlight", name: "homeButtonHighlight",
localPosition: { x: 0, y: -HOME_BUTTON_Y_OFFSET + 0.003, z: -0.0158 }, localPosition: { x: 0, y: -HOME_BUTTON_Y_OFFSET, z: -WEB_ENTITY_Z_OFFSET },
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: homeButtonDim, y: homeButtonDim, z: homeButtonDim },
color: { red: 255, green: 255, blue: 255 },
solid: true, solid: true,
innerRadius: 0.9, innerRadius: 0.9,
ignoreIntersection: true, ignoreIntersection: true,
alpha: 1.0, alpha: 1.0,
color: { red: 255, green: 255, blue: 255 },
visible: visible, visible: visible,
drawInFront: false, drawInFront: false,
parentID: this.tabletEntityID, parentID: this.tabletEntityID,

View file

@ -255,22 +255,8 @@ projectOntoEntityXYPlane = function (entityID, worldPos, props) {
projectOntoOverlayXYPlane = function projectOntoOverlayXYPlane(overlayID, worldPos) { projectOntoOverlayXYPlane = function projectOntoOverlayXYPlane(overlayID, worldPos) {
var position = Overlays.getProperty(overlayID, "position"); var position = Overlays.getProperty(overlayID, "position");
var rotation = Overlays.getProperty(overlayID, "rotation"); var rotation = Overlays.getProperty(overlayID, "rotation");
var dimensions; var dimensions = Overlays.getProperty(overlayID, "dimensions");
dimensions.z = 0.01; // we are projecting onto the XY plane of the overlay, so ignore the z dimension
var dpi = Overlays.getProperty(overlayID, "dpi");
if (dpi) {
// Calculate physical dimensions for web3d overlay from resolution and dpi; "dimensions" property is used as a scale.
var resolution = Overlays.getProperty(overlayID, "resolution");
resolution.z = 1; // Circumvent divide-by-zero.
var scale = Overlays.getProperty(overlayID, "dimensions");
scale.z = 0.01; // overlay dimensions are 2D, not 3D.
dimensions = Vec3.multiplyVbyV(Vec3.multiply(resolution, INCHES_TO_METERS / dpi), scale);
} else {
dimensions = Overlays.getProperty(overlayID, "dimensions");
if (dimensions.z) {
dimensions.z = 0.01; // overlay dimensions are 2D, not 3D.
}
}
return projectOntoXYPlane(worldPos, position, rotation, dimensions, DEFAULT_REGISTRATION_POINT); return projectOntoXYPlane(worldPos, position, rotation, dimensions, DEFAULT_REGISTRATION_POINT);
}; };

View file

@ -174,9 +174,7 @@ function calculateTouchTargetFromOverlay(touchTip, overlayID) {
if (dimensions === undefined) { if (dimensions === undefined) {
return; return;
} }
if (!dimensions.z) { dimensions.z = 0.01; // we are projecting onto the XY plane of the overlay, so ignore the z dimension
dimensions.z = 0.01; // sometimes overlay dimensions are 2D, not 3D.
}
var invDimensions = { x: 1 / dimensions.x, y: 1 / dimensions.y, z: 1 / dimensions.z }; var invDimensions = { x: 1 / dimensions.x, y: 1 / dimensions.y, z: 1 / dimensions.z };
var normalizedPosition = Vec3.sum(Vec3.multiplyVbyV(localPos, invDimensions), DEFAULT_REGISTRATION_POINT); var normalizedPosition = Vec3.sum(Vec3.multiplyVbyV(localPos, invDimensions), DEFAULT_REGISTRATION_POINT);

View file

@ -185,7 +185,7 @@ logTrace = function(str) {
// (the vector that would move the point outside the sphere) // (the vector that would move the point outside the sphere)
// otherwise returns false // otherwise returns false
findSphereHit = function(point, sphereRadius) { findSphereHit = function(point, sphereRadius) {
var EPSILON = 0.000001; //smallish positive number - used as margin of error for some computations var EPSILON = 0.000001; //smallish positive number - used as margin of error for some computations
var vectorLength = Vec3.length(point); var vectorLength = Vec3.length(point);
if (vectorLength < EPSILON) { if (vectorLength < EPSILON) {
return true; return true;
@ -406,22 +406,21 @@ resizeTablet = function (width, newParentJointIndex, sensorToWorldScaleOverride)
var screenHeight = 0.81 * tabletHeight; var screenHeight = 0.81 * tabletHeight;
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: screenWidth, y: screenHeight, z: 0.1}, dimensions: { x: screenWidth, y: screenHeight, z: 0.1 },
dpi: tabletDpi dpi: tabletDpi
}); });
// update homeButton // update homeButton
var HOME_BUTTON_Y_OFFSET = ((tabletHeight / 2) - (tabletHeight / 20)) * sensorScaleOffsetOverride; var HOME_BUTTON_Y_OFFSET = ((tabletHeight / 2) - (tabletHeight / 20) - 0.003 * sensorScaleFactor) * sensorScaleOffsetOverride;
var homeButtonDim = 4 * tabletScaleFactor; // FIXME: Circle3D overlays currently at the wrong dimensions, so we need to account for that here
var homeButtonDim = 4.0 * tabletScaleFactor / 3.0;
Overlays.editOverlay(HMD.homeButtonID, { Overlays.editOverlay(HMD.homeButtonID, {
localPosition: {x: 0, y: -HOME_BUTTON_Y_OFFSET, z: 0 }, localPosition: { x: 0, y: -HOME_BUTTON_Y_OFFSET, z: -WEB_ENTITY_Z_OFFSET },
dimensions: { x: homeButtonDim, y: homeButtonDim, z: homeButtonDim} dimensions: { x: homeButtonDim, y: homeButtonDim, z: homeButtonDim }
}); });
// Circle3D overlays render at 1.5x their proper dimensions
var highlightDim = homeButtonDim / 3.0;
Overlays.editOverlay(HMD.homeButtonHighlightID, { Overlays.editOverlay(HMD.homeButtonHighlightID, {
localPosition: { x: 0, y: -HOME_BUTTON_Y_OFFSET + 0.003 * sensorScaleFactor * sensorScaleOffsetOverride, z: -0.0158 * sensorScaleFactor * sensorScaleOffsetOverride }, localPosition: { x: 0, y: -HOME_BUTTON_Y_OFFSET, z: -WEB_ENTITY_Z_OFFSET },
dimensions: { x: highlightDim, y: highlightDim, z: highlightDim } dimensions: { x: homeButtonDim, y: homeButtonDim, z: homeButtonDim }
}); });
}; };

View file

@ -47,7 +47,7 @@
} }
return false; return false;
} }
if (Overlays.getProperty(HMD.homeButtonID, "type") != "sphere" || if (Overlays.getProperty(HMD.homeButtonID, "type") != "circle3d" ||
Overlays.getProperty(HMD.tabletScreenID, "type") != "web3d") { Overlays.getProperty(HMD.tabletScreenID, "type") != "web3d") {
if (debugTablet) { if (debugTablet) {
print("TABLET is invalid due to other"); print("TABLET is invalid due to other");