mirror of
https://github.com/overte-org/overte.git
synced 2025-07-23 17:44:13 +02:00
Better experimentation
This commit is contained in:
parent
6a7ae55d9c
commit
9c4c1bf10f
5 changed files with 84 additions and 205 deletions
|
@ -1,99 +0,0 @@
|
||||||
"use strict";
|
|
||||||
|
|
||||||
//
|
|
||||||
// testSimulationWorkload.js
|
|
||||||
// tablet-workload-engine test app
|
|
||||||
//
|
|
||||||
// Copyright 2018 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
|
|
||||||
//
|
|
||||||
Script.include("./test_physics_scene.js")
|
|
||||||
|
|
||||||
(function() {
|
|
||||||
var TABLET_BUTTON_NAME = "Test Sim";
|
|
||||||
var QMLAPP_URL = Script.resolvePath("./testSimulationWorkload.qml");
|
|
||||||
var ICON_URL = Script.resolvePath("../../../system/assets/images/luci-i.svg");
|
|
||||||
var ACTIVE_ICON_URL = Script.resolvePath("../../../system/assets/images/luci-a.svg");
|
|
||||||
|
|
||||||
var onAppScreen = false;
|
|
||||||
|
|
||||||
function onClicked() {
|
|
||||||
if (onAppScreen) {
|
|
||||||
tablet.gotoHomeScreen();
|
|
||||||
} else {
|
|
||||||
tablet.loadQMLSource(QMLAPP_URL);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
var tablet = Tablet.getTablet("com.highfidelity.interface.tablet.system");
|
|
||||||
var button = tablet.addButton({
|
|
||||||
text: TABLET_BUTTON_NAME,
|
|
||||||
icon: ICON_URL,
|
|
||||||
activeIcon: ACTIVE_ICON_URL
|
|
||||||
});
|
|
||||||
|
|
||||||
var hasEventBridge = false;
|
|
||||||
|
|
||||||
function wireEventBridge(on) {
|
|
||||||
if (!tablet) {
|
|
||||||
print("Warning in wireEventBridge(): 'tablet' undefined!");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (on) {
|
|
||||||
if (!hasEventBridge) {
|
|
||||||
tablet.fromQml.connect(fromQml);
|
|
||||||
hasEventBridge = true;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (hasEventBridge) {
|
|
||||||
tablet.fromQml.disconnect(fromQml);
|
|
||||||
hasEventBridge = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function onScreenChanged(type, url) {
|
|
||||||
if (url === QMLAPP_URL) {
|
|
||||||
onAppScreen = true;
|
|
||||||
} else {
|
|
||||||
onAppScreen = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
button.editProperties({isActive: onAppScreen});
|
|
||||||
wireEventBridge(onAppScreen);
|
|
||||||
}
|
|
||||||
|
|
||||||
button.clicked.connect(onClicked);
|
|
||||||
tablet.screenChanged.connect(onScreenChanged);
|
|
||||||
|
|
||||||
|
|
||||||
Script.scriptEnding.connect(function () {
|
|
||||||
if (onAppScreen) {
|
|
||||||
tablet.gotoHomeScreen();
|
|
||||||
}
|
|
||||||
button.clicked.disconnect(onClicked);
|
|
||||||
tablet.screenChanged.disconnect(onScreenChanged);
|
|
||||||
tablet.removeButton(button);
|
|
||||||
clearScene();
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
function fromQml(message) {
|
|
||||||
switch (message.method) {
|
|
||||||
case "createScene":
|
|
||||||
createScene();
|
|
||||||
break;
|
|
||||||
case "clearScene":
|
|
||||||
clearScene();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
function sendToQml(message) {
|
|
||||||
tablet.sendToQml(message);
|
|
||||||
}
|
|
||||||
|
|
||||||
}());
|
|
|
@ -1,73 +0,0 @@
|
||||||
//
|
|
||||||
// _workload.qml
|
|
||||||
//
|
|
||||||
// Created by Sam Gateau on 3/1/2018
|
|
||||||
// Copyright 2018 High Fidelity, Inc.
|
|
||||||
//
|
|
||||||
// Distributed under the Apache License, Version 2.0.
|
|
||||||
// See the accompanying file LICENSE or https://www.apache.org/licenses/LICENSE-2.0.html
|
|
||||||
//
|
|
||||||
import QtQuick 2.7
|
|
||||||
import QtQuick.Controls 1.4
|
|
||||||
import QtQuick.Layouts 1.3
|
|
||||||
|
|
||||||
import "qrc:///qml/styles-uit"
|
|
||||||
import "qrc:///qml/controls-uit" as HifiControls
|
|
||||||
import "../render/configSlider"
|
|
||||||
//import "./test_simulation_scene.js" as Sim
|
|
||||||
|
|
||||||
|
|
||||||
Rectangle {
|
|
||||||
HifiConstants { id: hifi;}
|
|
||||||
id: _test;
|
|
||||||
|
|
||||||
width: parent ? parent.width : 400
|
|
||||||
height: parent ? parent.height : 600
|
|
||||||
anchors.margins: hifi.dimensions.contentMargin.x
|
|
||||||
|
|
||||||
color: hifi.colors.baseGray;
|
|
||||||
|
|
||||||
Component.onCompleted: {
|
|
||||||
}
|
|
||||||
Component.onDestruction: {
|
|
||||||
}
|
|
||||||
|
|
||||||
function broadcastCreateScene() {
|
|
||||||
sendToScript({method: "createScene", params: { count:2 }});
|
|
||||||
}
|
|
||||||
|
|
||||||
function broadcastClearScene() {
|
|
||||||
sendToScript({method: "clearScene", params: { count:2 }});
|
|
||||||
}
|
|
||||||
|
|
||||||
function fromScript(message) {
|
|
||||||
switch (message.method) {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Column {
|
|
||||||
spacing: 5
|
|
||||||
anchors.left: parent.left
|
|
||||||
anchors.right: parent.right
|
|
||||||
anchors.margins: hifi.dimensions.contentMargin.x
|
|
||||||
//padding: hifi.dimensions.contentMargin.x
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Separator {}
|
|
||||||
HifiControls.Label {
|
|
||||||
text: "Display"
|
|
||||||
}
|
|
||||||
|
|
||||||
HifiControls.Button {
|
|
||||||
text: "create scene"
|
|
||||||
onClicked: {
|
|
||||||
print("pressed")
|
|
||||||
_test.broadcastCreateScene()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Separator {}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,22 +1,34 @@
|
||||||
|
|
||||||
var DEFAULT_LIFETIME = 120;
|
var DEFAULT_LIFETIME = 120;
|
||||||
|
var GRID_WORLD_SIZE = 100.0;
|
||||||
|
var GRID_WORLD_MARGIN = 5.0;
|
||||||
|
var GRID_WORLD_RESOLUTION = 30.0;
|
||||||
|
|
||||||
var GRID_WORLD_SIZE = 100.0;
|
|
||||||
var GRID_WORLD_RESOLUTION = 2.0;
|
|
||||||
|
|
||||||
var BACKDROP_SIZE = GRID_WORLD_SIZE / GRID_WORLD_RESOLUTION;
|
var BACKDROP_SIZE = GRID_WORLD_RESOLUTION;
|
||||||
var BACKDROP_HALFSIZE = BACKDROP_SIZE *0.5;
|
var BACKDROP_HALFSIZE = BACKDROP_SIZE *0.5;
|
||||||
var BACKDROP_MIN_C = -2;
|
var BACKDROP_MIN_C = -2;
|
||||||
|
|
||||||
var ROOT_Z_OFFSET = -3;
|
var ROOT_Z_OFFSET = -3;
|
||||||
var ROOT_Y_OFFSET = -0.1;
|
var ROOT_Y_OFFSET = -0.1;
|
||||||
|
|
||||||
var TILE_UNIT = GRID_WORLD_RESOLUTION;
|
var TILE_UNIT = GRID_WORLD_SIZE / BACKDROP_SIZE;
|
||||||
var TILE_DIM = { x: TILE_UNIT, y: TILE_UNIT, z: TILE_UNIT};
|
var TILE_DIM = { x: TILE_UNIT, y: TILE_UNIT, z: TILE_UNIT};
|
||||||
var GRID_TILE_OFFSET = Vec3.multiply(0.5, TILE_DIM);
|
var GRID_TILE_OFFSET = Vec3.multiply(0.5, TILE_DIM);
|
||||||
|
|
||||||
var OBJECT_DIM = { x: 0.5, y: 0.5, z: 0.5};
|
|
||||||
|
|
||||||
|
function updateWorldResolution(res) {
|
||||||
|
GRID_WORLD_RESOLUTION = res;
|
||||||
|
|
||||||
|
BACKDROP_SIZE = GRID_WORLD_RESOLUTION;
|
||||||
|
BACKDROP_HALFSIZE = BACKDROP_SIZE *0.5;
|
||||||
|
|
||||||
|
TILE_UNIT = GRID_WORLD_SIZE / BACKDROP_SIZE;
|
||||||
|
TILE_DIM = { x: TILE_UNIT, y: TILE_UNIT, z: TILE_UNIT};
|
||||||
|
GRID_TILE_OFFSET = Vec3.multiply(0.5, TILE_DIM);
|
||||||
|
}
|
||||||
|
|
||||||
|
var OBJECT_DIM = { x: 0.5, y: 0.5, z: 0.5};
|
||||||
|
|
||||||
var shapeTypes = [
|
var shapeTypes = [
|
||||||
"none",
|
"none",
|
||||||
|
@ -69,7 +81,7 @@ function addObjectGrid(backdrop, lifetime) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function addFloor(lifetime) {
|
function addFloor(lifetime) {
|
||||||
var floorDim = { x:BACKDROP_SIZE * TILE_DIM.x, y:TILE_DIM.y, z:BACKDROP_SIZE *TILE_DIM.x};
|
var floorDim = { x:GRID_WORLD_SIZE + 2 * GRID_WORLD_MARGIN, y:TILE_DIM.y, z:GRID_WORLD_SIZE + 2 * GRID_WORLD_MARGIN};
|
||||||
var center = getStagePosOriAt(0, 0, -1).pos;
|
var center = getStagePosOriAt(0, 0, -1).pos;
|
||||||
|
|
||||||
return (Entities.addEntity({
|
return (Entities.addEntity({
|
||||||
|
@ -87,15 +99,15 @@ function addFloor(lifetime) {
|
||||||
// gravity:{"x":0,"y":-9.8,"z":0},
|
// gravity:{"x":0,"y":-9.8,"z":0},
|
||||||
// velocity:{"x":0,"y":0.01,"z":0},
|
// velocity:{"x":0,"y":0.01,"z":0},
|
||||||
restitution:0.999,
|
restitution:0.999,
|
||||||
friction:0.000,
|
friction:0.001,
|
||||||
damping:0.0,
|
damping:0.3,
|
||||||
|
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
function addZone(hasKeyLight, hasAmbient, lifetime) {
|
function addZone(hasKeyLight, hasAmbient, lifetime) {
|
||||||
var zoneDim = Vec3.multiply(BACKDROP_SIZE, TILE_DIM);
|
var zoneDim = { x:GRID_WORLD_SIZE + 2 * GRID_WORLD_MARGIN, y:GRID_WORLD_SIZE, z:GRID_WORLD_SIZE + 2 * GRID_WORLD_MARGIN};
|
||||||
var center = getStagePosOriAt(0, 0, 0).pos;
|
var center = getStagePosOriAt(0, 0, -2).pos;
|
||||||
|
|
||||||
var lightDir = Vec3.normalize(Vec3.sum(Vec3.multiply(-1, Quat.getUp(stageOrientation)), Vec3.multiply(-1, Quat.getRight(stageOrientation))))
|
var lightDir = Vec3.normalize(Vec3.sum(Vec3.multiply(-1, Quat.getUp(stageOrientation)), Vec3.multiply(-1, Quat.getRight(stageOrientation))))
|
||||||
|
|
||||||
|
@ -197,14 +209,20 @@ clearScene = function() {
|
||||||
}
|
}
|
||||||
|
|
||||||
changeResolution = function(res) {
|
changeResolution = function(res) {
|
||||||
GRID_WORLD_RESOLUTION = res;
|
updateWorldResolution(res);
|
||||||
|
}
|
||||||
BACKDROP_SIZE = GRID_WORLD_SIZE / GRID_WORLD_RESOLUTION;
|
|
||||||
BACKDROP_HALFSIZE = BACKDROP_SIZE *0.5;
|
getResolution = function() {
|
||||||
|
return GRID_WORLD_RESOLUTION;
|
||||||
TILE_UNIT = GRID_WORLD_RESOLUTION;
|
}
|
||||||
|
|
||||||
|
getNumObjects = function() {
|
||||||
|
return BACKDROP_SIZE * BACKDROP_SIZE;
|
||||||
|
}
|
||||||
|
|
||||||
|
bumpUpFloor = function() {
|
||||||
|
print("bumpUpFloor")
|
||||||
|
if (scene.length > 0) {
|
||||||
|
Entities.editEntity(scene[0],{ velocity: {x: 0, y:-2.0,z: 0}})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// clean up after test
|
|
||||||
Script.scriptEnding.connect(function () {
|
|
||||||
clearScene()
|
|
||||||
});
|
|
|
@ -87,19 +87,26 @@
|
||||||
switch (message.method) {
|
switch (message.method) {
|
||||||
case "createScene":
|
case "createScene":
|
||||||
createScene();
|
createScene();
|
||||||
|
sendToQml({method: "objectCount", params: { v: getNumObjects() }})
|
||||||
break;
|
break;
|
||||||
case "clearScene":
|
case "clearScene":
|
||||||
clearScene();
|
clearScene();
|
||||||
|
sendToQml({method: "objectCount", params: { v: getNumObjects() }})
|
||||||
break;
|
break;
|
||||||
case "changeResolution":
|
case "changeResolution":
|
||||||
changeResolution(message.params.count);
|
changeResolution(message.params.count);
|
||||||
|
sendToQml({method: "objectCount", params: { v: getNumObjects() }})
|
||||||
|
break;
|
||||||
|
case "bumpUpFloor":
|
||||||
|
bumpUpFloor();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sendToQml({method: "objectCount", params: { v: getNumObjects() }})
|
||||||
|
|
||||||
function sendToQml(message) {
|
function sendToQml(message) {
|
||||||
tablet.sendToQml(message);
|
tablet.sendToQml(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
}());
|
}());
|
|
@ -39,8 +39,20 @@ Rectangle {
|
||||||
sendToScript({method: "changeResolution", params: { count:value }});
|
sendToScript({method: "changeResolution", params: { count:value }});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function broadcastBumpUpFloor(value) {
|
||||||
|
sendToScript({method: "bumpUpFloor", params: { count:0 }});
|
||||||
|
}
|
||||||
|
|
||||||
function fromScript(message) {
|
function fromScript(message) {
|
||||||
switch (message.method) {
|
switch (message.method) {
|
||||||
|
case "resolution":
|
||||||
|
print("assigned value! " + message.params.v)
|
||||||
|
resolution.setValue(message.params.v)
|
||||||
|
break;
|
||||||
|
case "objectCount":
|
||||||
|
print("assigned objectCount! " + message.params.v)
|
||||||
|
objectCount.text = ("Num objects = " + message.params.v)
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -156,7 +168,7 @@ Rectangle {
|
||||||
HifiControls.Label {
|
HifiControls.Label {
|
||||||
text: "Test"
|
text: "Test"
|
||||||
}
|
}
|
||||||
RowLayout {
|
Row {
|
||||||
anchors.left: parent.left
|
anchors.left: parent.left
|
||||||
anchors.right: parent.right
|
anchors.right: parent.right
|
||||||
HifiControls.Button {
|
HifiControls.Button {
|
||||||
|
@ -173,6 +185,20 @@ Rectangle {
|
||||||
_workload.broadcastClearScene()
|
_workload.broadcastClearScene()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
HifiControls.Button {
|
||||||
|
text: "bump floor"
|
||||||
|
onClicked: {
|
||||||
|
print("pressed")
|
||||||
|
_workload.broadcastBumpUpFloor()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
HifiControls.Label {
|
||||||
|
id: objectCount
|
||||||
|
anchors.left: parent.left
|
||||||
|
anchors.right: parent.right
|
||||||
|
text: "Num objects"
|
||||||
}
|
}
|
||||||
HifiControls.Slider {
|
HifiControls.Slider {
|
||||||
id: resolution
|
id: resolution
|
||||||
|
@ -180,10 +206,10 @@ Rectangle {
|
||||||
anchors.left: parent.left
|
anchors.left: parent.left
|
||||||
anchors.right: parent.right
|
anchors.right: parent.right
|
||||||
anchors.rightMargin: 0
|
anchors.rightMargin: 0
|
||||||
anchors.top: root.top
|
|
||||||
anchors.topMargin: 0
|
anchors.topMargin: 0
|
||||||
minimumValue: 1
|
minimumValue: 5
|
||||||
maximumValue: 10
|
maximumValue: 50
|
||||||
|
value: 3
|
||||||
|
|
||||||
onValueChanged: { _workload.broadcastChangeResolution(value) }
|
onValueChanged: { _workload.broadcastChangeResolution(value) }
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue