Showing the changes to scripts/developer (5 of 5 files). Show all
Unified · Split
| @@ -1,99 +0,0 @@ | ||
| 1 | −"use strict"; | |
| 2 | − | |
| 3 | −// | |
| 4 | −// testSimulationWorkload.js | |
| 5 | −// tablet-workload-engine test app | |
| 6 | −// | |
| 7 | −// Copyright 2018 High Fidelity, Inc. | |
| 8 | −// | |
| 9 | −// Distributed under the Apache License, Version 2.0. | |
| 10 | −// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html | |
| 11 | −// | |
| 12 | −Script.include("./test_physics_scene.js") | |
| 13 | − | |
| 14 | −(function() { | |
| 15 | − var TABLET_BUTTON_NAME = "Test Sim"; | |
| 16 | − var QMLAPP_URL = Script.resolvePath("./testSimulationWorkload.qml"); | |
| 17 | − var ICON_URL = Script.resolvePath("../../../system/assets/images/luci-i.svg"); | |
| 18 | − var ACTIVE_ICON_URL = Script.resolvePath("../../../system/assets/images/luci-a.svg"); | |
| 19 | − | |
| 20 | − var onAppScreen = false; | |
| 21 | − | |
| 22 | − function onClicked() { | |
| 23 | − if (onAppScreen) { | |
| 24 | − tablet.gotoHomeScreen(); | |
| 25 | − } else { | |
| 26 | − tablet.loadQMLSource(QMLAPP_URL); | |
| 27 | − } | |
| 28 | − } | |
| 29 | − | |
| 30 | − var tablet = Tablet.getTablet("com.highfidelity.interface.tablet.system"); | |
| 31 | − var button = tablet.addButton({ | |
| 32 | − text: TABLET_BUTTON_NAME, | |
| 33 | − icon: ICON_URL, | |
| 34 | − activeIcon: ACTIVE_ICON_URL | |
| 35 | − }); | |
| 36 | − | |
| 37 | − var hasEventBridge = false; | |
| 38 | − | |
| 39 | − function wireEventBridge(on) { | |
| 40 | − if (!tablet) { | |
| 41 | − print("Warning in wireEventBridge(): 'tablet' undefined!"); | |
| 42 | − return; | |
| 43 | − } | |
| 44 | − if (on) { | |
| 45 | − if (!hasEventBridge) { | |
| 46 | − tablet.fromQml.connect(fromQml); | |
| 47 | − hasEventBridge = true; | |
| 48 | − } | |
| 49 | − } else { | |
| 50 | − if (hasEventBridge) { | |
| 51 | − tablet.fromQml.disconnect(fromQml); | |
| 52 | − hasEventBridge = false; | |
| 53 | − } | |
| 54 | − } | |
| 55 | − } | |
| 56 | − | |
| 57 | − function onScreenChanged(type, url) { | |
| 58 | − if (url === QMLAPP_URL) { | |
| 59 | − onAppScreen = true; | |
| 60 | − } else { | |
| 61 | − onAppScreen = false; | |
| 62 | − } | |
| 63 | − | |
| 64 | − button.editProperties({isActive: onAppScreen}); | |
| 65 | − wireEventBridge(onAppScreen); | |
| 66 | − } | |
| 67 | − | |
| 68 | − button.clicked.connect(onClicked); | |
| 69 | − tablet.screenChanged.connect(onScreenChanged); | |
| 70 | − | |
| 71 | − | |
| 72 | − Script.scriptEnding.connect(function () { | |
| 73 | − if (onAppScreen) { | |
| 74 | − tablet.gotoHomeScreen(); | |
| 75 | − } | |
| 76 | − button.clicked.disconnect(onClicked); | |
| 77 | − tablet.screenChanged.disconnect(onScreenChanged); | |
| 78 | − tablet.removeButton(button); | |
| 79 | − clearScene(); | |
| 80 | − }); | |
| 81 | − | |
| 82 | − | |
| 83 | − function fromQml(message) { | |
| 84 | − switch (message.method) { | |
| 85 | − case "createScene": | |
| 86 | − createScene(); | |
| 87 | − break; | |
| 88 | − case "clearScene": | |
| 89 | − clearScene(); | |
| 90 | − break; | |
| 91 | − } | |
| 92 | − | |
| 93 | − } | |
| 94 | − | |
| 95 | − function sendToQml(message) { | |
| 96 | − tablet.sendToQml(message); | |
| 97 | − } | |
| 98 | − | |
| 99 | −}()); | |
| @@ -1,73 +0,0 @@ | ||
| 1 | −// | |
| 2 | −// _workload.qml | |
| 3 | −// | |
| 4 | −// Created by Sam Gateau on 3/1/2018 | |
| 5 | −// Copyright 2018 High Fidelity, Inc. | |
| 6 | −// | |
| 7 | −// Distributed under the Apache License, Version 2.0. | |
| 8 | −// See the accompanying file LICENSE or https://www.apache.org/licenses/LICENSE-2.0.html | |
| 9 | −// | |
| 10 | −import QtQuick 2.7 | |
| 11 | −import QtQuick.Controls 1.4 | |
| 12 | −import QtQuick.Layouts 1.3 | |
| 13 | − | |
| 14 | −import "qrc:///qml/styles-uit" | |
| 15 | −import "qrc:///qml/controls-uit" as HifiControls | |
| 16 | −import "../render/configSlider" | |
| 17 | −//import "./test_simulation_scene.js" as Sim | |
| 18 | − | |
| 19 | − | |
| 20 | −Rectangle { | |
| 21 | − HifiConstants { id: hifi;} | |
| 22 | − id: _test; | |
| 23 | − | |
| 24 | − width: parent ? parent.width : 400 | |
| 25 | − height: parent ? parent.height : 600 | |
| 26 | − anchors.margins: hifi.dimensions.contentMargin.x | |
| 27 | − | |
| 28 | − color: hifi.colors.baseGray; | |
| 29 | − | |
| 30 | − Component.onCompleted: { | |
| 31 | − } | |
| 32 | − Component.onDestruction: { | |
| 33 | − } | |
| 34 | − | |
| 35 | − function broadcastCreateScene() { | |
| 36 | − sendToScript({method: "createScene", params: { count:2 }}); | |
| 37 | − } | |
| 38 | − | |
| 39 | − function broadcastClearScene() { | |
| 40 | − sendToScript({method: "clearScene", params: { count:2 }}); | |
| 41 | − } | |
| 42 | − | |
| 43 | − function fromScript(message) { | |
| 44 | − switch (message.method) { | |
| 45 | − } | |
| 46 | − } | |
| 47 | − | |
| 48 | − Column { | |
| 49 | − spacing: 5 | |
| 50 | − anchors.left: parent.left | |
| 51 | − anchors.right: parent.right | |
| 52 | − anchors.margins: hifi.dimensions.contentMargin.x | |
| 53 | − //padding: hifi.dimensions.contentMargin.x | |
| 54 | − | |
| 55 | − | |
| 56 | − | |
| 57 | − Separator {} | |
| 58 | − HifiControls.Label { | |
| 59 | − text: "Display" | |
| 60 | − } | |
| 61 | − | |
| 62 | − HifiControls.Button { | |
| 63 | − text: "create scene" | |
| 64 | − onClicked: { | |
| 65 | − print("pressed") | |
| 66 | − _test.broadcastCreateScene() | |
| 67 | − } | |
| 68 | − } | |
| 69 | − | |
| 70 | − Separator {} | |
| 71 | − | |
| 72 | − } | |
| 73 | −} | |
| @@ -1,22 +1,34 @@ | ||
| 1 | 1 | |
| 2 | −var DEFAULT_LIFETIME = 120; | |
| 2 | + var DEFAULT_LIFETIME = 120; | |
| 3 | + var GRID_WORLD_SIZE = 100.0; | |
| 4 | + var GRID_WORLD_MARGIN = 5.0; | |
| 5 | + var GRID_WORLD_RESOLUTION = 30.0; | |
| 3 | 6 | |
| 4 | −var GRID_WORLD_SIZE = 100.0; | |
| 5 | −var GRID_WORLD_RESOLUTION = 2.0; | |
| 6 | 7 | |
| 7 | −var BACKDROP_SIZE = GRID_WORLD_SIZE / GRID_WORLD_RESOLUTION; | |
| 8 | −var BACKDROP_HALFSIZE = BACKDROP_SIZE *0.5; | |
| 9 | −var BACKDROP_MIN_C = -2; | |
| 8 | + var BACKDROP_SIZE = GRID_WORLD_RESOLUTION; | |
| 9 | + var BACKDROP_HALFSIZE = BACKDROP_SIZE *0.5; | |
| 10 | + var BACKDROP_MIN_C = -2; | |
| 10 | 11 | |
| 11 | −var ROOT_Z_OFFSET = -3; | |
| 12 | −var ROOT_Y_OFFSET = -0.1; | |
| 12 | + var ROOT_Z_OFFSET = -3; | |
| 13 | + var ROOT_Y_OFFSET = -0.1; | |
| 13 | 14 | |
| 14 | −var TILE_UNIT = GRID_WORLD_RESOLUTION; | |
| 15 | −var TILE_DIM = { x: TILE_UNIT, y: TILE_UNIT, z: TILE_UNIT}; | |
| 16 | −var GRID_TILE_OFFSET = Vec3.multiply(0.5, TILE_DIM); | |
| 15 | + var TILE_UNIT = GRID_WORLD_SIZE / BACKDROP_SIZE; | |
| 16 | + var TILE_DIM = { x: TILE_UNIT, y: TILE_UNIT, z: TILE_UNIT}; | |
| 17 | + var GRID_TILE_OFFSET = Vec3.multiply(0.5, TILE_DIM); | |
| 17 | 18 | |
| 18 | −var OBJECT_DIM = { x: 0.5, y: 0.5, z: 0.5}; | |
| 19 | 19 | |
| 20 | + function updateWorldResolution(res) { | |
| 21 | + GRID_WORLD_RESOLUTION = res; | |
| 22 | + | |
| 23 | + BACKDROP_SIZE = GRID_WORLD_RESOLUTION; | |
| 24 | + BACKDROP_HALFSIZE = BACKDROP_SIZE *0.5; | |
| 25 | + | |
| 26 | + TILE_UNIT = GRID_WORLD_SIZE / BACKDROP_SIZE; | |
| 27 | + TILE_DIM = { x: TILE_UNIT, y: TILE_UNIT, z: TILE_UNIT}; | |
| 28 | + GRID_TILE_OFFSET = Vec3.multiply(0.5, TILE_DIM); | |
| 29 | + } | |
| 30 | + | |
| 31 | + var OBJECT_DIM = { x: 0.5, y: 0.5, z: 0.5}; | |
| 20 | 32 | |
| 21 | 33 | var shapeTypes = [ |
| 22 | 34 | "none", |
| @@ -69,7 +81,7 @@ function addObjectGrid(backdrop, lifetime) { · 46 unmodified lines | ||
| 69 | 81 | } |
| 70 | 82 | |
| 71 | 83 | function addFloor(lifetime) { |
| 72 | − var floorDim = { x:BACKDROP_SIZE * TILE_DIM.x, y:TILE_DIM.y, z:BACKDROP_SIZE *TILE_DIM.x}; | |
| 84 | + var floorDim = { x:GRID_WORLD_SIZE + 2 * GRID_WORLD_MARGIN, y:TILE_DIM.y, z:GRID_WORLD_SIZE + 2 * GRID_WORLD_MARGIN}; | |
| 73 | 85 | var center = getStagePosOriAt(0, 0, -1).pos; |
| 74 | 86 | |
| 75 | 87 | return (Entities.addEntity({ |
| @@ -87,15 +99,15 @@ function addFloor(lifetime) { · 11 unmodified lines | ||
| 87 | 99 | // gravity:{"x":0,"y":-9.8,"z":0}, |
| 88 | 100 | // velocity:{"x":0,"y":0.01,"z":0}, |
| 89 | 101 | restitution:0.999, |
| 90 | − friction:0.000, | |
| 91 | − damping:0.0, | |
| 102 | + friction:0.001, | |
| 103 | + damping:0.3, | |
| 92 | 104 | |
| 93 | 105 | })); |
| 94 | 106 | } |
| 95 | 107 | |
| 96 | 108 | function addZone(hasKeyLight, hasAmbient, lifetime) { |
| 97 | − var zoneDim = Vec3.multiply(BACKDROP_SIZE, TILE_DIM); | |
| 98 | − var center = getStagePosOriAt(0, 0, 0).pos; | |
| 109 | + var zoneDim = { x:GRID_WORLD_SIZE + 2 * GRID_WORLD_MARGIN, y:GRID_WORLD_SIZE, z:GRID_WORLD_SIZE + 2 * GRID_WORLD_MARGIN}; | |
| 110 | + var center = getStagePosOriAt(0, 0, -2).pos; | |
| 99 | 111 | |
| 100 | 112 | var lightDir = Vec3.normalize(Vec3.sum(Vec3.multiply(-1, Quat.getUp(stageOrientation)), Vec3.multiply(-1, Quat.getRight(stageOrientation)))) |
| 101 | 113 | |
| @@ -197,14 +209,20 @@ clearScene = function() { · 95 unmodified lines | ||
| 197 | 209 | } |
| 198 | 210 | |
| 199 | 211 | changeResolution = function(res) { |
| 200 | − GRID_WORLD_RESOLUTION = res; | |
| 212 | + updateWorldResolution(res); | |
| 213 | +} | |
| 201 | 214 | |
| 202 | − BACKDROP_SIZE = GRID_WORLD_SIZE / GRID_WORLD_RESOLUTION; | |
| 203 | − BACKDROP_HALFSIZE = BACKDROP_SIZE *0.5; | |
| 204 | − | |
| 205 | − TILE_UNIT = GRID_WORLD_RESOLUTION; | |
| 215 | +getResolution = function() { | |
| 216 | + return GRID_WORLD_RESOLUTION; | |
| 206 | 217 | } |
| 207 | −// clean up after test | |
| 208 | −Script.scriptEnding.connect(function () { | |
| 209 | − clearScene() | |
| 210 | −}); | |
| 218 | + | |
| 219 | +getNumObjects = function() { | |
| 220 | + return BACKDROP_SIZE * BACKDROP_SIZE; | |
| 221 | +} | |
| 222 | + | |
| 223 | +bumpUpFloor = function() { | |
| 224 | + print("bumpUpFloor") | |
| 225 | + if (scene.length > 0) { | |
| 226 | + Entities.editEntity(scene[0],{ velocity: {x: 0, y:-2.0,z: 0}}) | |
| 227 | + } | |
| 228 | +} | |
| @@ -87,19 +87,26 @@ · 86 unmodified lines | ||
| 87 | 87 | switch (message.method) { |
| 88 | 88 | case "createScene": |
| 89 | 89 | createScene(); |
| 90 | + sendToQml({method: "objectCount", params: { v: getNumObjects() }}) | |
| 90 | 91 | break; |
| 91 | 92 | case "clearScene": |
| 92 | 93 | clearScene(); |
| 94 | + sendToQml({method: "objectCount", params: { v: getNumObjects() }}) | |
| 93 | 95 | break; |
| 94 | 96 | case "changeResolution": |
| 95 | 97 | changeResolution(message.params.count); |
| 98 | + sendToQml({method: "objectCount", params: { v: getNumObjects() }}) | |
| 99 | + break; | |
| 100 | + case "bumpUpFloor": | |
| 101 | + bumpUpFloor(); | |
| 96 | 102 | break; |
| 97 | 103 | } |
| 98 | 104 | |
| 99 | 105 | } |
| 100 | 106 | |
| 107 | + sendToQml({method: "objectCount", params: { v: getNumObjects() }}) | |
| 108 | + | |
| 101 | 109 | function sendToQml(message) { |
| 102 | 110 | tablet.sendToQml(message); |
| 103 | 111 | } |
| 104 | − | |
| 105 | 112 | }()); |
| @@ -39,8 +39,20 @@ Rectangle { · 38 unmodified lines | ||
| 39 | 39 | sendToScript({method: "changeResolution", params: { count:value }}); |
| 40 | 40 | } |
| 41 | 41 | |
| 42 | + function broadcastBumpUpFloor(value) { | |
| 43 | + sendToScript({method: "bumpUpFloor", params: { count:0 }}); | |
| 44 | + } | |
| 45 | + | |
| 42 | 46 | function fromScript(message) { |
| 43 | 47 | switch (message.method) { |
| 48 | + case "resolution": | |
| 49 | + print("assigned value! " + message.params.v) | |
| 50 | + resolution.setValue(message.params.v) | |
| 51 | + break; | |
| 52 | + case "objectCount": | |
| 53 | + print("assigned objectCount! " + message.params.v) | |
| 54 | + objectCount.text = ("Num objects = " + message.params.v) | |
| 55 | + break; | |
| 44 | 56 | } |
| 45 | 57 | } |
| 46 | 58 | |
| @@ -156,7 +168,7 @@ Rectangle { · 109 unmodified lines | ||
| 156 | 168 | HifiControls.Label { |
| 157 | 169 | text: "Test" |
| 158 | 170 | } |
| 159 | − RowLayout { | |
| 171 | + Row { | |
| 160 | 172 | anchors.left: parent.left |
| 161 | 173 | anchors.right: parent.right |
| 162 | 174 | HifiControls.Button { |
| @@ -173,6 +185,20 @@ Rectangle { · 10 unmodified lines | ||
| 173 | 185 | _workload.broadcastClearScene() |
| 174 | 186 | } |
| 175 | 187 | } |
| 188 | + HifiControls.Button { | |
| 189 | + text: "bump floor" | |
| 190 | + onClicked: { | |
| 191 | + print("pressed") | |
| 192 | + _workload.broadcastBumpUpFloor() | |
| 193 | + } | |
| 194 | + } | |
| 195 | + } | |
| 196 | + | |
| 197 | + HifiControls.Label { | |
| 198 | + id: objectCount | |
| 199 | + anchors.left: parent.left | |
| 200 | + anchors.right: parent.right | |
| 201 | + text: "Num objects" | |
| 176 | 202 | } |
| 177 | 203 | HifiControls.Slider { |
| 178 | 204 | id: resolution |
| @@ -180,14 +206,14 @@ Rectangle { · 1 unmodified line | ||
| 180 | 206 | anchors.left: parent.left |
| 181 | 207 | anchors.right: parent.right |
| 182 | 208 | anchors.rightMargin: 0 |
| 183 | − anchors.top: root.top | |
| 184 | 209 | anchors.topMargin: 0 |
| 185 | − minimumValue: 1 | |
| 186 | − maximumValue: 10 | |
| 210 | + minimumValue: 5 | |
| 211 | + maximumValue: 50 | |
| 212 | + value: 3 | |
| 187 | 213 | |
| 188 | 214 | onValueChanged: { _workload.broadcastChangeResolution(value) } |
| 189 | 215 | } |
| 190 | − | |
| 216 | + | |
| 191 | 217 | Separator {} |
| 192 | 218 | |
| 193 | 219 | /*Jet.TaskList { |