mirror of
https://github.com/lubosz/overte.git
synced 2025-04-05 21:22:00 +02:00
Fixes for scaling controller display
Adds MyAvatar.sensorToWorldScaleChanged signal.
This commit is contained in:
parent
f0912987a3
commit
23ff1b9ead
10 changed files with 146 additions and 42 deletions
|
@ -2651,6 +2651,9 @@ float MyAvatar::getUserHeight() const {
|
|||
|
||||
void MyAvatar::setUserHeight(float value) {
|
||||
_userHeight.set(value);
|
||||
|
||||
float sensorToWorldScale = getEyeHeight() / getUserEyeHeight();
|
||||
emit sensorToWorldScaleChanged(sensorToWorldScale);
|
||||
}
|
||||
|
||||
float MyAvatar::getUserEyeHeight() const {
|
||||
|
@ -3207,3 +3210,12 @@ void MyAvatar::updateHoldActions(const AnimPose& prePhysicsPose, const AnimPose&
|
|||
const MyHead* MyAvatar::getMyHead() const {
|
||||
return static_cast<const MyHead*>(getHead());
|
||||
}
|
||||
|
||||
void MyAvatar::setModelScale(float scale) {
|
||||
bool changed = (scale != getModelScale());
|
||||
Avatar::setModelScale(scale);
|
||||
if (changed) {
|
||||
float sensorToWorldScale = getEyeHeight() / getUserEyeHeight();
|
||||
emit sensorToWorldScaleChanged(sensorToWorldScale);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -590,6 +590,8 @@ public slots:
|
|||
glm::vec3 getPositionForAudio();
|
||||
glm::quat getOrientationForAudio();
|
||||
|
||||
virtual void setModelScale(float scale) override;
|
||||
|
||||
signals:
|
||||
void audioListenerModeChanged();
|
||||
void transformChanged();
|
||||
|
@ -602,6 +604,7 @@ signals:
|
|||
void wentActive();
|
||||
void skeletonChanged();
|
||||
void dominantHandChanged(const QString& hand);
|
||||
void sensorToWorldScaleChanged(float sensorToWorldScale);
|
||||
|
||||
private:
|
||||
|
||||
|
|
|
@ -261,8 +261,8 @@ public:
|
|||
*/
|
||||
Q_INVOKABLE float getEyeHeight() const;
|
||||
|
||||
float getModelScale() const { return _modelScale; }
|
||||
void setModelScale(float scale) { _modelScale = scale; }
|
||||
virtual float getModelScale() const { return _modelScale; }
|
||||
virtual void setModelScale(float scale) { _modelScale = scale; }
|
||||
|
||||
public slots:
|
||||
|
||||
|
|
|
@ -59,7 +59,8 @@ createControllerDisplay = function(config) {
|
|||
},
|
||||
|
||||
setPartVisible: function(partName, visible) {
|
||||
return;
|
||||
// Disabled
|
||||
/*
|
||||
if (partName in this.partOverlays) {
|
||||
for (var i = 0; i < this.partOverlays[partName].length; ++i) {
|
||||
Overlays.editOverlay(this.partOverlays[partName][i], {
|
||||
|
@ -67,6 +68,7 @@ createControllerDisplay = function(config) {
|
|||
});
|
||||
}
|
||||
}
|
||||
*/
|
||||
},
|
||||
|
||||
setLayerForPart: function(partName, layerName) {
|
||||
|
@ -85,12 +87,45 @@ createControllerDisplay = function(config) {
|
|||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
resize: function(sensorScaleFactor) {
|
||||
if (this.overlays.length >= 0) {
|
||||
var controller = config.controllers[0];
|
||||
var position = controller.position;
|
||||
|
||||
// first overlay is main body.
|
||||
var overlayID = this.overlays[0];
|
||||
var localPosition = Vec3.multiply(sensorScaleFactor, Vec3.sum(Vec3.multiplyQbyV(controller.rotation, controller.naturalPosition), position));
|
||||
var dimensions = Vec3.multiply(sensorScaleFactor, controller.dimensions);
|
||||
|
||||
Overlays.editOverlay(overlayID, {
|
||||
dimensions: dimensions,
|
||||
localPosition: localPosition
|
||||
});
|
||||
|
||||
if (controller.parts) {
|
||||
var i = 1;
|
||||
for (var partName in controller.parts) {
|
||||
overlayID = this.overlays[i++];
|
||||
var part = controller.parts[partName];
|
||||
var partPosition = Vec3.multiply(sensorScaleFactor, Vec3.sum(controller.position, Vec3.multiplyQbyV(controller.rotation, part.naturalPosition)));
|
||||
var partDimensions = Vec3.multiply(sensorScaleFactor, part.naturalDimensions);
|
||||
Overlays.editOverlay(overlayID, {
|
||||
dimensions: partDimensions,
|
||||
localPosition: partPosition
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
var mapping = Controller.newMapping(controllerDisplay.mappingName);
|
||||
for (var i = 0; i < config.controllers.length; ++i) {
|
||||
var controller = config.controllers[i];
|
||||
var position = controller.position;
|
||||
var sensorScaleFactor = MyAvatar.sensorToWorldScale;
|
||||
|
||||
if (controller.naturalPosition) {
|
||||
position = Vec3.sum(Vec3.multiplyQbyV(controller.rotation, controller.naturalPosition), position);
|
||||
|
@ -98,9 +133,9 @@ createControllerDisplay = function(config) {
|
|||
|
||||
var overlayID = Overlays.addOverlay("model", {
|
||||
url: controller.modelURL,
|
||||
dimensions: controller.dimensions,
|
||||
dimensions: Vec3.multiply(sensorScaleFactor, controller.dimensions),
|
||||
localRotation: controller.rotation,
|
||||
localPosition: position,
|
||||
localPosition: Vec3.multiply(sensorScaleFactor, position),
|
||||
parentID: PARENT_ID,
|
||||
parentJointIndex: controller.jointIndex,
|
||||
ignoreRayIntersection: true
|
||||
|
@ -176,8 +211,8 @@ createControllerDisplay = function(config) {
|
|||
});
|
||||
} else if (part.type === "joystick") {
|
||||
(function(controller, overlayID, part) {
|
||||
const xInput = resolveHardware(part.xInput);
|
||||
const yInput = resolveHardware(part.yInput);
|
||||
var xInput = resolveHardware(part.xInput);
|
||||
var yInput = resolveHardware(part.yInput);
|
||||
|
||||
var xvalue = 0;
|
||||
var yvalue = 0;
|
||||
|
@ -190,21 +225,20 @@ createControllerDisplay = function(config) {
|
|||
offset = Vec3.multiplyQbyV(rotation, part.originOffset);
|
||||
offset = Vec3.subtract(part.originOffset, offset);
|
||||
}
|
||||
|
||||
|
||||
var partPosition = Vec3.sum(controller.position,
|
||||
Vec3.multiplyQbyV(controller.rotation, Vec3.sum(offset, part.naturalPosition)));
|
||||
|
||||
var partRotation = Quat.multiply(controller.rotation, rotation)
|
||||
var partRotation = Quat.multiply(controller.rotation, rotation);
|
||||
|
||||
return {
|
||||
position: partPosition,
|
||||
rotation: partRotation
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
mapping.from([xInput]).peek().to(function(value) {
|
||||
xvalue = value;
|
||||
//print(overlayID, xvalue.toFixed(3), yvalue.toFixed(3));
|
||||
var posRot = calculatePositionAndRotation(xvalue, yvalue);
|
||||
Overlays.editOverlay(overlayID, {
|
||||
localPosition: posRot.position,
|
||||
|
@ -224,10 +258,9 @@ createControllerDisplay = function(config) {
|
|||
|
||||
} else if (part.type === "linear") {
|
||||
(function(controller, overlayID, part) {
|
||||
const input = resolveHardware(part.input);
|
||||
var input = resolveHardware(part.input);
|
||||
|
||||
mapping.from([input]).peek().to(function(value) {
|
||||
//print(value);
|
||||
var axis = Vec3.multiplyQbyV(controller.rotation, part.axis);
|
||||
var offset = Vec3.multiply(part.maxTranslation * value, axis);
|
||||
|
||||
|
@ -256,6 +289,7 @@ createControllerDisplay = function(config) {
|
|||
}
|
||||
}
|
||||
Controller.enableMapping(controllerDisplay.mappingName);
|
||||
controllerDisplay.resize(MyAvatar.sensorToWorldScale);
|
||||
return controllerDisplay;
|
||||
};
|
||||
|
||||
|
|
|
@ -56,7 +56,6 @@ ControllerDisplayManager = function() {
|
|||
}
|
||||
|
||||
if (leftConfig !== null && rightConfig !== null) {
|
||||
print("Loading controllers");
|
||||
if (controllerLeft === null) {
|
||||
controllerLeft = createControllerDisplay(leftConfig);
|
||||
controllerLeft.setVisible(true);
|
||||
|
@ -70,6 +69,7 @@ ControllerDisplayManager = function() {
|
|||
Script.clearInterval(controllerCheckerIntervalID);
|
||||
controllerCheckerIntervalID = null;
|
||||
}
|
||||
|
||||
} else {
|
||||
self.deleteControllerDisplays();
|
||||
if (!controllerCheckerIntervalID) {
|
||||
|
@ -86,6 +86,15 @@ ControllerDisplayManager = function() {
|
|||
}
|
||||
}
|
||||
|
||||
function resizeControllers(sensorScaleFactor) {
|
||||
if (controllerLeft) {
|
||||
controllerLeft.resize(sensorScaleFactor);
|
||||
}
|
||||
if (controllerRight) {
|
||||
controllerRight.resize(sensorScaleFactor);
|
||||
}
|
||||
};
|
||||
|
||||
var handleMessages = function(channel, message, sender) {
|
||||
var i, data, name, visible;
|
||||
if (!controllerLeft && !controllerRight) {
|
||||
|
@ -171,6 +180,7 @@ ControllerDisplayManager = function() {
|
|||
|
||||
HMD.displayModeChanged.connect(updateControllers);
|
||||
HMD.shouldShowHandControllersChanged.connect(updateControllers);
|
||||
MyAvatar.sensorToWorldScaleChanged.connect(resizeControllers);
|
||||
|
||||
updateControllers();
|
||||
};
|
||||
|
|
|
@ -3035,7 +3035,7 @@ function MyController(hand) {
|
|||
|
||||
if (this.grabbedIsOverlay) {
|
||||
Overlays.editOverlay(this.grabbedThingID, reparentProps);
|
||||
// AJT: resize tablet to allow it to counter scale.
|
||||
// resize tablet to allow it to counter scale.
|
||||
if (this.grabbedThingID === HMD.tabletID) {
|
||||
resizeTablet(getTabletWidthFromSettings(), reparentProps.parentJointIndex);
|
||||
}
|
||||
|
@ -3815,7 +3815,7 @@ function MyController(hand) {
|
|||
parentID: this.previousParentID[this.grabbedThingID],
|
||||
parentJointIndex: this.previousParentJointIndex[this.grabbedThingID],
|
||||
});
|
||||
// AJT: resizeTablet to counter adjust offsets to account for change of scale from sensorToWorldMatrix
|
||||
// resizeTablet to counter adjust offsets to account for change of scale from sensorToWorldMatrix
|
||||
if (this.grabbedThingID === HMD.tabletID) {
|
||||
resizeTablet(getTabletWidthFromSettings(), this.previousParentJointIndex[this.grabbedThingID]);
|
||||
}
|
||||
|
|
|
@ -62,7 +62,7 @@ var TIP_TEXTURE_BASE_URL = BASE_URL + "meshes/controller/vive_tips.fbm/";
|
|||
|
||||
var viveModelURL = BASE_URL + "meshes/controller/vive_body.fbx";
|
||||
var viveTipsModelURL = BASE_URL + "meshes/controller/vive_tips.fbx";
|
||||
var viveTriggerModelURL = "meshes/controller/vive_trigger.fbx"
|
||||
var viveTriggerModelURL = "meshes/controller/vive_trigger.fbx";
|
||||
|
||||
VIVE_CONTROLLER_CONFIGURATION_LEFT = {
|
||||
name: "Vive",
|
||||
|
@ -81,6 +81,7 @@ VIVE_CONTROLLER_CONFIGURATION_LEFT = {
|
|||
type: "static",
|
||||
modelURL: viveTipsModelURL,
|
||||
naturalPosition: {"x":-0.004377640783786774,"y":-0.034371938556432724,"z":0.06769277155399323},
|
||||
naturalDimensions: {x: 0.191437, y: 0.094095, z: 0.085656},
|
||||
|
||||
textureName: "Tex.Blank",
|
||||
defaultTextureLayer: "blank",
|
||||
|
@ -112,6 +113,7 @@ VIVE_CONTROLLER_CONFIGURATION_LEFT = {
|
|||
xInput: "Vive.LX",
|
||||
yInput: "Vive.LY",
|
||||
naturalPosition: {"x":0,"y":0.000979491975158453,"z":0.04872849956154823},
|
||||
naturalDimensions: {x: 0.042824, y: 0.012537, z: 0.043115},
|
||||
minValue: 0.0,
|
||||
maxValue: 1.0,
|
||||
minPosition: { x: -0.035, y: 0.004, z: -0.005 },
|
||||
|
@ -137,6 +139,7 @@ VIVE_CONTROLLER_CONFIGURATION_LEFT = {
|
|||
modelURL: BASE_URL + "meshes/controller/vive_trigger.fbx",
|
||||
input: Controller.Standard.LT,
|
||||
naturalPosition: {"x":0.000004500150680541992,"y":-0.027690507471561432,"z":0.04830199480056763},
|
||||
naturalDimensions: {x: 0.019105, y: 0.022189, z: 0.01909},
|
||||
origin: { x: 0, y: -0.015, z: -0.00 },
|
||||
minValue: 0.0,
|
||||
maxValue: 1.0,
|
||||
|
@ -147,10 +150,10 @@ VIVE_CONTROLLER_CONFIGURATION_LEFT = {
|
|||
defaultTextureLayer: "normal",
|
||||
textureLayers: {
|
||||
normal: {
|
||||
defaultTextureURL: BASE_URL + viveTriggerModelURL + "/Trigger.fbm/black.jpg",
|
||||
defaultTextureURL: BASE_URL + viveTriggerModelURL + "/Trigger.fbm/black.jpg"
|
||||
},
|
||||
highlight: {
|
||||
defaultTextureURL: BASE_URL + viveTriggerModelURL + "/Trigger.fbm/yellow.jpg",
|
||||
defaultTextureURL: BASE_URL + viveTriggerModelURL + "/Trigger.fbm/yellow.jpg"
|
||||
}
|
||||
}
|
||||
},
|
||||
|
@ -158,30 +161,35 @@ VIVE_CONTROLLER_CONFIGURATION_LEFT = {
|
|||
l_grip: {
|
||||
type: "static",
|
||||
modelURL: BASE_URL + "meshes/controller/vive_l_grip.fbx",
|
||||
naturalPosition: {"x":-0.01720449887216091,"y":-0.014324013143777847,"z":0.08714400231838226}
|
||||
naturalPosition: {"x":-0.01720449887216091,"y":-0.014324013143777847,"z":0.08714400231838226},
|
||||
naturalDimensions: {x: 0.010094, y: 0.015064, z: 0.029552}
|
||||
},
|
||||
|
||||
r_grip: {
|
||||
type: "static",
|
||||
modelURL: BASE_URL + "meshes/controller/vive_r_grip.fbx",
|
||||
naturalPosition: {"x":0.01720449887216091,"y":-0.014324013143777847,"z":0.08714400231838226}
|
||||
naturalPosition: {"x":0.01720449887216091,"y":-0.014324013143777847,"z":0.08714400231838226},
|
||||
naturalDimensions: {x: 0.010083, y: 0.015064, z: 0.029552}
|
||||
},
|
||||
|
||||
sys_button: {
|
||||
type: "static",
|
||||
modelURL: BASE_URL + "meshes/controller/vive_sys_button.fbx",
|
||||
naturalPosition: {"x":0,"y":0.0020399854984134436,"z":0.08825899660587311}
|
||||
naturalPosition: {"x":0,"y":0.0020399854984134436,"z":0.08825899660587311},
|
||||
naturalDimensions: {x: 0.009986, y: 0.004282, z: 0.010264}
|
||||
},
|
||||
|
||||
button: {
|
||||
type: "static",
|
||||
modelURL: BASE_URL + "meshes/controller/vive_button.fbx",
|
||||
naturalPosition: {"x":0,"y":0.005480996798723936,"z":0.019918499514460564}
|
||||
naturalPosition: {"x":0,"y":0.005480996798723936,"z":0.019918499514460564},
|
||||
naturalDimensions: {x: 0.009986, y: 0.004496, z: 0.010121}
|
||||
},
|
||||
button2: {
|
||||
type: "static",
|
||||
modelURL: BASE_URL + "meshes/controller/vive_button.fbx",
|
||||
naturalPosition: {"x":0,"y":0.005480996798723936,"z":0.019918499514460564}
|
||||
naturalPosition: {"x":0,"y":0.005480996798723936,"z":0.019918499514460564},
|
||||
naturalDimensions: {x: 0.009986, y: 0.004496, z: 0.010121}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -211,6 +219,7 @@ VIVE_CONTROLLER_CONFIGURATION_RIGHT = {
|
|||
type: "static",
|
||||
modelURL: viveTipsModelURL,
|
||||
naturalPosition: {"x":-0.004377640783786774,"y":-0.034371938556432724,"z":0.06769277155399323},
|
||||
naturalDimensions: {x: 0.191437, y: 0.094095, z: 0.085656},
|
||||
|
||||
textureName: "Tex.Blank",
|
||||
|
||||
|
@ -243,6 +252,7 @@ VIVE_CONTROLLER_CONFIGURATION_RIGHT = {
|
|||
xInput: "Vive.RX",
|
||||
yInput: "Vive.RY",
|
||||
naturalPosition: { x: 0, y: 0.000979491975158453, z: 0.04872849956154823 },
|
||||
naturalDimensions: {x: 0.042824, y: 0.012537, z: 0.043115},
|
||||
minValue: 0.0,
|
||||
maxValue: 1.0,
|
||||
minPosition: { x: -0.035, y: 0.004, z: -0.005 },
|
||||
|
@ -268,6 +278,7 @@ VIVE_CONTROLLER_CONFIGURATION_RIGHT = {
|
|||
modelURL: BASE_URL + "meshes/controller/vive_trigger.fbx",
|
||||
input: Controller.Standard.RT,
|
||||
naturalPosition: {"x":0.000004500150680541992,"y":-0.027690507471561432,"z":0.04830199480056763},
|
||||
naturalDimensions: {x: 0.019105, y: 0.022189, z: 0.01909},
|
||||
origin: { x: 0, y: -0.015, z: -0.00 },
|
||||
minValue: 0.0,
|
||||
maxValue: 1.0,
|
||||
|
@ -278,10 +289,10 @@ VIVE_CONTROLLER_CONFIGURATION_RIGHT = {
|
|||
defaultTextureLayer: "normal",
|
||||
textureLayers: {
|
||||
normal: {
|
||||
defaultTextureURL: BASE_URL + viveTriggerModelURL + "/Trigger.fbm/black.jpg",
|
||||
defaultTextureURL: BASE_URL + viveTriggerModelURL + "/Trigger.fbm/black.jpg"
|
||||
},
|
||||
highlight: {
|
||||
defaultTextureURL: BASE_URL + viveTriggerModelURL + "/Trigger.fbm/yellow.jpg",
|
||||
defaultTextureURL: BASE_URL + viveTriggerModelURL + "/Trigger.fbm/yellow.jpg"
|
||||
}
|
||||
}
|
||||
},
|
||||
|
@ -289,30 +300,35 @@ VIVE_CONTROLLER_CONFIGURATION_RIGHT = {
|
|||
l_grip: {
|
||||
type: "static",
|
||||
modelURL: BASE_URL + "meshes/controller/vive_l_grip.fbx",
|
||||
naturalPosition: {"x":-0.01720449887216091,"y":-0.014324013143777847,"z":0.08714400231838226}
|
||||
naturalPosition: {"x":-0.01720449887216091,"y":-0.014324013143777847,"z":0.08714400231838226},
|
||||
naturalDimensions: {x: 0.010094, y: 0.015064, z: 0.029552}
|
||||
},
|
||||
|
||||
r_grip: {
|
||||
type: "static",
|
||||
modelURL: BASE_URL + "meshes/controller/vive_r_grip.fbx",
|
||||
naturalPosition: {"x":0.01720449887216091,"y":-0.014324013143777847,"z":0.08714400231838226}
|
||||
naturalPosition: {"x":0.01720449887216091,"y":-0.014324013143777847,"z":0.08714400231838226},
|
||||
naturalDimensions: {x: 0.010083, y: 0.015064, z: 0.029552}
|
||||
},
|
||||
|
||||
sys_button: {
|
||||
type: "static",
|
||||
modelURL: BASE_URL + "meshes/controller/vive_sys_button.fbx",
|
||||
naturalPosition: {"x":0,"y":0.0020399854984134436,"z":0.08825899660587311}
|
||||
naturalPosition: {"x":0,"y":0.0020399854984134436,"z":0.08825899660587311},
|
||||
naturalDimensions: {x: 0.009986, y: 0.004282, z: 0.010264}
|
||||
},
|
||||
|
||||
button: {
|
||||
type: "static",
|
||||
modelURL: BASE_URL + "meshes/controller/vive_button.fbx",
|
||||
naturalPosition: {"x":0,"y":0.005480996798723936,"z":0.019918499514460564}
|
||||
naturalPosition: {"x":0,"y":0.005480996798723936,"z":0.019918499514460564},
|
||||
naturalDimensions: {x: 0.009986, y: 0.004496, z: 0.010121}
|
||||
},
|
||||
button2: {
|
||||
type: "static",
|
||||
modelURL: BASE_URL + "meshes/controller/vive_button.fbx",
|
||||
naturalPosition: {"x":0,"y":0.005480996798723936,"z":0.019918499514460564}
|
||||
naturalPosition: {"x":0,"y":0.005480996798723936,"z":0.019918499514460564},
|
||||
naturalDimensions: {x: 0.009986, y: 0.004496, z: 0.010121}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -368,13 +368,13 @@ getTabletWidthFromSettings = function () {
|
|||
return DEFAULT_TABLET_WIDTH * (tabletScalePercentage / 100);
|
||||
};
|
||||
|
||||
resizeTablet = function (width, newParentJointIndex) {
|
||||
resizeTablet = function (width, newParentJointIndex, sensorToWorldScaleOverride) {
|
||||
|
||||
if (!HMD.tabletID || !HMD.tabletScreenID || !HMD.homeButtonID) {
|
||||
return;
|
||||
}
|
||||
|
||||
var sensorScaleFactor = MyAvatar.sensorToWorldScale;
|
||||
var sensorScaleFactor = sensorToWorldScaleOverride || MyAvatar.sensorToWorldScale;
|
||||
var sensorScaleOffsetOverride = 1;
|
||||
var SENSOR_TO_ROOM_MATRIX = 65534;
|
||||
var parentJointIndex = newParentJointIndex || Overlays.getProperty(HMD.tabletID, "parentJointIndex");
|
||||
|
|
|
@ -28,7 +28,6 @@
|
|||
var MSECS_PER_SEC = 1000.0;
|
||||
var MUTE_MICROPHONE_MENU_ITEM = "Mute Microphone";
|
||||
var gTablet = null;
|
||||
var avatarSensorScale = MyAvatar.sensorToWorldScale;
|
||||
|
||||
Script.include("../libraries/WebTablet.js");
|
||||
|
||||
|
@ -74,7 +73,7 @@
|
|||
|
||||
function updateTabletWidthFromSettings(force) {
|
||||
var newTabletScalePercentage = getTabletScalePercentageFromSettings();
|
||||
if ((force || newTabletScalePercentage !== tabletScalePercentage) && UIWebTablet) {
|
||||
if ((force || (newTabletScalePercentage !== tabletScalePercentage)) && UIWebTablet) {
|
||||
tabletScalePercentage = newTabletScalePercentage;
|
||||
UIWebTablet.setWidth(DEFAULT_WIDTH * (tabletScalePercentage / 100));
|
||||
}
|
||||
|
@ -84,6 +83,11 @@
|
|||
updateTabletWidthFromSettings();
|
||||
}
|
||||
|
||||
function onSensorToWorldScaleChanged(sensorScaleFactor) {
|
||||
var newTabletScalePercentage = getTabletScalePercentageFromSettings();
|
||||
resizeTablet(DEFAULT_WIDTH * (newTabletScalePercentage / 100), undefined, sensorScaleFactor);
|
||||
}
|
||||
|
||||
function rezTablet() {
|
||||
if (debugTablet) {
|
||||
print("TABLET rezzing");
|
||||
|
@ -99,6 +103,7 @@
|
|||
HMD.homeButtonID = UIWebTablet.homeButtonID;
|
||||
HMD.tabletScreenID = UIWebTablet.webOverlayID;
|
||||
HMD.displayModeChanged.connect(onHmdChanged);
|
||||
MyAvatar.sensorToWorldScaleChanged.connect(onSensorToWorldScaleChanged);
|
||||
|
||||
tabletRezzed = true;
|
||||
}
|
||||
|
@ -188,13 +193,7 @@
|
|||
if (now - validCheckTime > MSECS_PER_SEC) {
|
||||
validCheckTime = now;
|
||||
|
||||
// force tablet to resize if sensorToWorldScale changes
|
||||
var force = false;
|
||||
if (avatarSensorScale !== MyAvatar.sensorToWorldScale) {
|
||||
force = true;
|
||||
avatarSensorScale = MyAvatar.sensorToWorldScale;
|
||||
}
|
||||
updateTabletWidthFromSettings(force);
|
||||
updateTabletWidthFromSettings();
|
||||
|
||||
if (UIWebTablet) {
|
||||
UIWebTablet.setLandscape(landscape);
|
||||
|
|
30
tools/dimensions.mel
Normal file
30
tools/dimensions.mel
Normal file
|
@ -0,0 +1,30 @@
|
|||
//
|
||||
// dimensions.mel
|
||||
//
|
||||
// Created by Anthony J. Thibault on September 5th, 2017.
|
||||
// Copyright 2017 High Fidelity, Inc.
|
||||
//
|
||||
// Distributed under the Apache License, Version 2.0.
|
||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
//
|
||||
// Maya Mel script to determine the High Fidelity "naturalDimensions" of a model.
|
||||
|
||||
// get a list of all mesh objects
|
||||
string $meshes[] = `ls -type mesh`;
|
||||
|
||||
// compute the bounding box
|
||||
float $boundingBox[] = `polyEvaluate -boundingBox $meshes`;
|
||||
|
||||
// copy values into variables for readability
|
||||
float $xmin = $boundingBox[0];
|
||||
float $xmax = $boundingBox[1];
|
||||
float $ymin = $boundingBox[2];
|
||||
float $ymax = $boundingBox[3];
|
||||
float $zmin = $boundingBox[4];
|
||||
float $zmax = $boundingBox[5];
|
||||
|
||||
// compute dimensions, and convert from cm to meters
|
||||
vector $dim = <<($xmax - $xmin) / 100.0, ($ymax - $ymin) / 100.0, ($zmax - $zmin) / 100.0>>;
|
||||
|
||||
// print result
|
||||
print $dim;
|
Loading…
Reference in a new issue