From a117e73ea489fb49fd1f52f0e9cc9ec755a06649 Mon Sep 17 00:00:00 2001 From: Howard Stearns Date: Fri, 29 Jan 2016 11:56:08 -0800 Subject: [PATCH 1/6] Update away.js to use an image instead of text. --- examples/away.js | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/examples/away.js b/examples/away.js index 0a86815d68..c37e588734 100644 --- a/examples/away.js +++ b/examples/away.js @@ -13,12 +13,11 @@ // // Goes into "paused" when the '.' key (and automatically when started in HMD), and normal when pressing any key. // See MAIN CONTROL, below, for what "paused" actually does. - +var OVERLAY_RATIO = 1920 / 1080; var OVERLAY_DATA = { - text: "Paused:\npress any key to continue", - font: {size: 75}, - color: {red: 200, green: 255, blue: 255}, - alpha: 0.9 + imageURL: "http://hifi-content.s3.amazonaws.com/alan/production/images/images/Overlay-Viz-blank.png", + color: {red: 255, green: 255, blue: 255}, + alpha: 1 }; // ANIMATION @@ -64,10 +63,24 @@ function stopAwayAnimation() { } // OVERLAY -var overlay = Overlays.addOverlay("text", OVERLAY_DATA); +var overlay = Overlays.addOverlay("image", OVERLAY_DATA); function showOverlay() { - var screen = Controller.getViewportDimensions(); - Overlays.editOverlay(overlay, {visible: true, x: screen.x / 4, y: screen.y / 4}); + var properties = {visible: true}, + // Update for current screen size, keeping overlay proportions constant. + screen = Controller.getViewportDimensions(), + screenRatio = screen.x / screen.y; + if (screenRatio < OVERLAY_RATIO) { + properties.width = screen.x; + properties.height = screen.x / OVERLAY_RATIO; + properties.x = 0; + properties.y = (screen.y - properties.height) / 2; + } else { + properties.height = screen.y; + properties.width = screen.y * OVERLAY_RATIO; + properties.y = 0; + properties.x = (screen.x - properties.width) / 2; + } + Overlays.editOverlay(overlay, properties); } function hideOverlay() { Overlays.editOverlay(overlay, {visible: false}); From 9a2af26906c9340c216efa21465d821fe397a34f Mon Sep 17 00:00:00 2001 From: Ryan Huffman Date: Fri, 29 Jan 2016 14:12:27 -0800 Subject: [PATCH 2/6] Fix 'Import Entities' causing error when cancelling --- examples/edit.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/examples/edit.js b/examples/edit.js index 900eaf8e82..286542a91f 100644 --- a/examples/edit.js +++ b/examples/edit.js @@ -1277,9 +1277,12 @@ function handeMenuEvent(menuItem) { } } else if (menuItem == "Import Entities" || menuItem == "Import Entities from URL") { - var importURL; + var importURL = null; if (menuItem == "Import Entities") { - importURL = "file:///" + Window.browse("Select models to import", "", "*.json"); + var fullPath = Window.browse("Select models to import", "", "*.json"); + if (fullPath) { + importURL = "file:///" + fullPath; + } } else { importURL = Window.prompt("URL of SVO to import", ""); } From 5e5c6158bbf2026b44cf84822a590c8090cc8e79 Mon Sep 17 00:00:00 2001 From: "James B. Pollack" Date: Fri, 29 Jan 2016 14:22:21 -0800 Subject: [PATCH 3/6] show how to use an ac to spawn and respawn entities --- examples/acScripts/entitySpawnerAC.js | 102 ++++++++++++++++++++++++++ 1 file changed, 102 insertions(+) create mode 100644 examples/acScripts/entitySpawnerAC.js diff --git a/examples/acScripts/entitySpawnerAC.js b/examples/acScripts/entitySpawnerAC.js new file mode 100644 index 0000000000..49ca32c278 --- /dev/null +++ b/examples/acScripts/entitySpawnerAC.js @@ -0,0 +1,102 @@ +// entitySpawnerAC +// +// Created by James B. Pollack @imgntn on 1/29/2016 +// +// This script shows how to use an AC to create entities, and delete and recreate those entities if the AC gets restarted. +// Copyright 2015 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 + +var basePosition = { + x: 0, + y: 0, + z: 0 +}; + +var NUMBER_OF_BOXES = 4; +Agent.isAvatar = true; + +function makeBoxes() { + var i; + for (i = 0; i < NUMBER_OF_BOXES; i++) { + createBox(); + } +} + +function createBox() { + var boxProps = { + dimensions: { + x: 1, + y: 1, + z: 1 + }, + color: { + red: 0, + green: 255, + blue: 0 + }, + type: 'Box', + name: 'TestBox', + position: { + x: basePosition.x + Math.random() * 5, + y: basePosition.y + Math.random() * 5, + z: basePosition.z + Math.random() * 5 + } + } + Entities.addEntity(boxProps) +} + +var secondaryInit = false; + +function deleteBoxes() { + if (secondaryInit === true) { + return; + } + + if (EntityViewer.getOctreeElementsCount() <= 1) { + Script.setTimeout(function() { + deleteBoxes(); + }, 1000) + return; + } + + var results = Entities.findEntities(basePosition, 2000); + results.forEach(function(r) { + var name = Entities.getEntityProperties(r, 'name').name; + if (name === "TestBox") { + Entities.deleteEntity(r); + } + + }) + + makeBoxes(); + secondaryInit = true; +} + +var initialized = false; + +function update(deltaTime) { + if (!initialized) { + if (Entities.serversExist() && Entities.canRez()) { + Entities.setPacketsPerSecond(6000); + deleteBoxes() + initialized = true; + Script.update.disconnect(update); + } + return; + } +} + + +EntityViewer.setPosition({ + x: 0, + y: 0, + z: 0 +}); +EntityViewer.setKeyholeRadius(60000); +Script.setInterval(function() { + EntityViewer.queryOctree(); +}, 1000); + +Script.update.connect(update); \ No newline at end of file From cb2fbd7e7fc1653418ff3ccc802f26860995dd33 Mon Sep 17 00:00:00 2001 From: "James B. Pollack" Date: Fri, 29 Jan 2016 14:29:27 -0800 Subject: [PATCH 4/6] clear octree interval --- examples/acScripts/entitySpawnerAC.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/examples/acScripts/entitySpawnerAC.js b/examples/acScripts/entitySpawnerAC.js index 49ca32c278..8fb2e259bb 100644 --- a/examples/acScripts/entitySpawnerAC.js +++ b/examples/acScripts/entitySpawnerAC.js @@ -22,6 +22,7 @@ function makeBoxes() { for (i = 0; i < NUMBER_OF_BOXES; i++) { createBox(); } + Script.clearInterval(octreeQueryInterval); } function createBox() { @@ -95,7 +96,7 @@ EntityViewer.setPosition({ z: 0 }); EntityViewer.setKeyholeRadius(60000); -Script.setInterval(function() { +var octreeQueryInterval = Script.setInterval(function() { EntityViewer.queryOctree(); }, 1000); From acf96a401f8aeb8cd05270562f41e72fbf9b90c7 Mon Sep 17 00:00:00 2001 From: Ryan Huffman Date: Fri, 29 Jan 2016 15:48:08 -0800 Subject: [PATCH 5/6] Fix marketplace imports failing silently if edit.js not running --- interface/src/Application.cpp | 5 ++--- .../src/scripting/WindowScriptingInterface.cpp | 13 ++++++++++++- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 14e0ea2a6d..daa8e1ace9 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -1691,9 +1691,8 @@ void Application::resizeGL() { } bool Application::importSVOFromURL(const QString& urlString) { - QUrl url(urlString); - emit svoImportRequested(url.url()); - return true; // assume it's accepted + emit svoImportRequested(urlString); + return true; } bool Application::event(QEvent* event) { diff --git a/interface/src/scripting/WindowScriptingInterface.cpp b/interface/src/scripting/WindowScriptingInterface.cpp index 5e5576b154..73c0098995 100644 --- a/interface/src/scripting/WindowScriptingInterface.cpp +++ b/interface/src/scripting/WindowScriptingInterface.cpp @@ -34,8 +34,19 @@ WindowScriptingInterface::WindowScriptingInterface() : { const DomainHandler& domainHandler = DependencyManager::get()->getDomainHandler(); connect(&domainHandler, &DomainHandler::connectedToDomain, this, &WindowScriptingInterface::domainChanged); - connect(qApp, &Application::svoImportRequested, this, &WindowScriptingInterface::svoImportRequested); connect(qApp, &Application::domainConnectionRefused, this, &WindowScriptingInterface::domainConnectionRefused); + + connect(qApp, &Application::svoImportRequested, [this](const QString& urlString) { + static const QMetaMethod svoImportRequestedSignal = + QMetaMethod::fromSignal(&WindowScriptingInterface::svoImportRequested); + + if (isSignalConnected(svoImportRequestedSignal)) { + QUrl url(urlString); + emit svoImportRequested(url.url()); + } else { + OffscreenUi::warning("Import SVO Error", "You need to be running edit.js to import entities."); + } + }); } WebWindowClass* WindowScriptingInterface::doCreateWebWindow(const QString& title, const QString& url, int width, int height) { From 8f6e7018bd08b273483e2ca81a84b387fefb4991 Mon Sep 17 00:00:00 2001 From: Thijs Wenker Date: Sun, 31 Jan 2016 23:39:43 +0100 Subject: [PATCH 6/6] Fix for Hydra scaling This PR fixes the hydra (and probably other hand controllers) while scaling. Testing notes: - Enable your hydra's - Grow your avatar (x5 or x10) (With the `+` key) - Spreading your arms in a T-pose should work without any scaling issues - Reset your scale using the `=` key --- interface/src/Application.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index bd571b9f5e..fd2b7a32d3 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -5007,7 +5007,7 @@ void Application::setPalmData(Hand* hand, const controller::Pose& pose, float de palm.setActive(pose.isValid()); // transform from sensor space, to world space, to avatar model space. - glm::mat4 poseMat = createMatFromQuatAndPos(pose.getRotation(), pose.getTranslation()); + glm::mat4 poseMat = createMatFromQuatAndPos(pose.getRotation(), pose.getTranslation() * myAvatar->getScale()); glm::mat4 sensorToWorldMat = myAvatar->getSensorToWorldMatrix(); glm::mat4 modelMat = createMatFromQuatAndPos(myAvatar->getOrientation(), myAvatar->getPosition()); glm::mat4 objectPose = glm::inverse(modelMat) * sensorToWorldMat * poseMat;