mirror of
https://github.com/overte-org/overte.git
synced 2025-08-08 14:18:24 +02:00
Merge branch 'master' of https://github.com/highfidelity/hifi into red
This commit is contained in:
commit
1b5499b3d6
5 changed files with 144 additions and 15 deletions
103
examples/acScripts/entitySpawnerAC.js
Normal file
103
examples/acScripts/entitySpawnerAC.js
Normal file
|
@ -0,0 +1,103 @@
|
||||||
|
// 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();
|
||||||
|
}
|
||||||
|
Script.clearInterval(octreeQueryInterval);
|
||||||
|
}
|
||||||
|
|
||||||
|
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);
|
||||||
|
var octreeQueryInterval = Script.setInterval(function() {
|
||||||
|
EntityViewer.queryOctree();
|
||||||
|
}, 1000);
|
||||||
|
|
||||||
|
Script.update.connect(update);
|
|
@ -13,12 +13,11 @@
|
||||||
//
|
//
|
||||||
// Goes into "paused" when the '.' key (and automatically when started in HMD), and normal when pressing any key.
|
// 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.
|
// See MAIN CONTROL, below, for what "paused" actually does.
|
||||||
|
var OVERLAY_RATIO = 1920 / 1080;
|
||||||
var OVERLAY_DATA = {
|
var OVERLAY_DATA = {
|
||||||
text: "Paused:\npress any key to continue",
|
imageURL: "http://hifi-content.s3.amazonaws.com/alan/production/images/images/Overlay-Viz-blank.png",
|
||||||
font: {size: 75},
|
color: {red: 255, green: 255, blue: 255},
|
||||||
color: {red: 200, green: 255, blue: 255},
|
alpha: 1
|
||||||
alpha: 0.9
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// ANIMATION
|
// ANIMATION
|
||||||
|
@ -64,10 +63,24 @@ function stopAwayAnimation() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// OVERLAY
|
// OVERLAY
|
||||||
var overlay = Overlays.addOverlay("text", OVERLAY_DATA);
|
var overlay = Overlays.addOverlay("image", OVERLAY_DATA);
|
||||||
function showOverlay() {
|
function showOverlay() {
|
||||||
var screen = Controller.getViewportDimensions();
|
var properties = {visible: true},
|
||||||
Overlays.editOverlay(overlay, {visible: true, x: screen.x / 4, y: screen.y / 4});
|
// 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() {
|
function hideOverlay() {
|
||||||
Overlays.editOverlay(overlay, {visible: false});
|
Overlays.editOverlay(overlay, {visible: false});
|
||||||
|
|
|
@ -1277,9 +1277,12 @@ function handeMenuEvent(menuItem) {
|
||||||
}
|
}
|
||||||
} else if (menuItem == "Import Entities" || menuItem == "Import Entities from URL") {
|
} else if (menuItem == "Import Entities" || menuItem == "Import Entities from URL") {
|
||||||
|
|
||||||
var importURL;
|
var importURL = null;
|
||||||
if (menuItem == "Import Entities") {
|
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 {
|
} else {
|
||||||
importURL = Window.prompt("URL of SVO to import", "");
|
importURL = Window.prompt("URL of SVO to import", "");
|
||||||
}
|
}
|
||||||
|
|
|
@ -1695,9 +1695,8 @@ void Application::resizeGL() {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Application::importSVOFromURL(const QString& urlString) {
|
bool Application::importSVOFromURL(const QString& urlString) {
|
||||||
QUrl url(urlString);
|
emit svoImportRequested(urlString);
|
||||||
emit svoImportRequested(url.url());
|
return true;
|
||||||
return true; // assume it's accepted
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Application::event(QEvent* event) {
|
bool Application::event(QEvent* event) {
|
||||||
|
@ -5007,7 +5006,7 @@ void Application::setPalmData(Hand* hand, const controller::Pose& pose, float de
|
||||||
palm.setActive(pose.isValid());
|
palm.setActive(pose.isValid());
|
||||||
|
|
||||||
// transform from sensor space, to world space, to avatar model space.
|
// 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 sensorToWorldMat = myAvatar->getSensorToWorldMatrix();
|
||||||
glm::mat4 modelMat = createMatFromQuatAndPos(myAvatar->getOrientation(), myAvatar->getPosition());
|
glm::mat4 modelMat = createMatFromQuatAndPos(myAvatar->getOrientation(), myAvatar->getPosition());
|
||||||
glm::mat4 objectPose = glm::inverse(modelMat) * sensorToWorldMat * poseMat;
|
glm::mat4 objectPose = glm::inverse(modelMat) * sensorToWorldMat * poseMat;
|
||||||
|
|
|
@ -34,8 +34,19 @@ WindowScriptingInterface::WindowScriptingInterface() :
|
||||||
{
|
{
|
||||||
const DomainHandler& domainHandler = DependencyManager::get<NodeList>()->getDomainHandler();
|
const DomainHandler& domainHandler = DependencyManager::get<NodeList>()->getDomainHandler();
|
||||||
connect(&domainHandler, &DomainHandler::connectedToDomain, this, &WindowScriptingInterface::domainChanged);
|
connect(&domainHandler, &DomainHandler::connectedToDomain, this, &WindowScriptingInterface::domainChanged);
|
||||||
connect(qApp, &Application::svoImportRequested, this, &WindowScriptingInterface::svoImportRequested);
|
|
||||||
connect(qApp, &Application::domainConnectionRefused, this, &WindowScriptingInterface::domainConnectionRefused);
|
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) {
|
WebWindowClass* WindowScriptingInterface::doCreateWebWindow(const QString& title, const QString& url, int width, int height) {
|
||||||
|
|
Loading…
Reference in a new issue