From 82dbdec78c074b8eb6b5690edfc349b61407fb3e Mon Sep 17 00:00:00 2001 From: ericrius1 Date: Tue, 3 Nov 2015 11:54:01 -0800 Subject: [PATCH 01/30] helicopter --- examples/helicopter/helicopter.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 examples/helicopter/helicopter.js diff --git a/examples/helicopter/helicopter.js b/examples/helicopter/helicopter.js new file mode 100644 index 0000000000..3ce084c305 --- /dev/null +++ b/examples/helicopter/helicopter.js @@ -0,0 +1,16 @@ +var modelURL= "https://s3.amazonaws.com/hifi-public/eric/models/helicopter.fbx"; +var center = Vec3.sum(MyAvatar.position, Vec3.multiply(3, Quat.getFront(Camera.getOrientation()))); + +var helicopter = Entities.addEntity({ + type: "Model", + modelURL: modelURL, + position: center +}); + + + +function cleanup() { + Entities.deleteEntity(helicopter); +} + +Script.scriptEnding.connect(cleanup); \ No newline at end of file From 443df042a4b050a18a64934a28b491c53bba6128 Mon Sep 17 00:00:00 2001 From: ericrius1 Date: Tue, 3 Nov 2015 12:40:41 -0800 Subject: [PATCH 02/30] playing with light pos/rot --- examples/helicopter/helicopter.js | 50 ++++++++++++++++++++++++++++++- 1 file changed, 49 insertions(+), 1 deletion(-) diff --git a/examples/helicopter/helicopter.js b/examples/helicopter/helicopter.js index 3ce084c305..7631f166f9 100644 --- a/examples/helicopter/helicopter.js +++ b/examples/helicopter/helicopter.js @@ -1,16 +1,64 @@ -var modelURL= "https://s3.amazonaws.com/hifi-public/eric/models/helicopter.fbx"; +var modelURL = "https://s3.amazonaws.com/hifi-public/eric/models/helicopter.fbx"; var center = Vec3.sum(MyAvatar.position, Vec3.multiply(3, Quat.getFront(Camera.getOrientation()))); +// These constants define the Spotlight position and orientation relative to the model +var MODEL_LIGHT_POSITION = { + x: -2, + y: 0, + z: 0 +}; +var MODEL_LIGHT_ROTATION = Quat.angleAxis(-90, { + x: 0, + y: 1, + z: 0 +}); + +// Evaluate the world light entity positions and orientations from the model ones +function evalLightWorldTransform(modelPos, modelRot) { + + return { + p: Vec3.sum(modelPos, Vec3.multiplyQbyV(modelRot, MODEL_LIGHT_POSITION)), + q: Quat.multiply(modelRot, MODEL_LIGHT_ROTATION) + }; +} + + var helicopter = Entities.addEntity({ type: "Model", + name: "Helicopter", modelURL: modelURL, position: center }); +var modelProperties = Entities.getEntityProperties(helicopter, ['position', 'rotation']); +var lightTransform = evalLightWorldTransform(modelProperties.position, modelProperties.rotation); +var spotlight = Entities.addEntity({ + type: "Light", + name: "helicopter light", + position: lightTransform.p, + rotation: lightTransform.q, + intensity: 2, + color: {red: 200, green: 200, blue: 255}, + intensity: 2, + exponent: 0.3, + cutoff: 20 +}); + +var debugLight = Entities.addEntity({ + type: "Box", + position: lightTransform.p, + rotation: lightTransform.q, + dimensions: {x: 4, y: 1, z: 1}, + color: {red: 200, green: 200, blue: 0} +}); + function cleanup() { + Entities.deleteEntity(debugLight); Entities.deleteEntity(helicopter); + Entities.deleteEntity(spotlight); + } Script.scriptEnding.connect(cleanup); \ No newline at end of file From 58587a5780aa6eba447af94f987690aed3c6165b Mon Sep 17 00:00:00 2001 From: ericrius1 Date: Tue, 3 Nov 2015 13:26:39 -0800 Subject: [PATCH 03/30] spotlight --- examples/helicopter/helicopter.js | 70 ++++++++++++++++++++++--------- 1 file changed, 50 insertions(+), 20 deletions(-) diff --git a/examples/helicopter/helicopter.js b/examples/helicopter/helicopter.js index 7631f166f9..22df9e56b7 100644 --- a/examples/helicopter/helicopter.js +++ b/examples/helicopter/helicopter.js @@ -1,16 +1,16 @@ -var modelURL = "https://s3.amazonaws.com/hifi-public/eric/models/helicopter.fbx"; -var center = Vec3.sum(MyAvatar.position, Vec3.multiply(3, Quat.getFront(Camera.getOrientation()))); +var modelURL = "https://s3.amazonaws.com/hifi-public/eric/models/helicopter.fbx?v3"; +var center = Vec3.sum(MyAvatar.position, Vec3.multiply(2, Quat.getFront(Camera.getOrientation()))); // These constants define the Spotlight position and orientation relative to the model var MODEL_LIGHT_POSITION = { - x: -2, + x: 2, y: 0, - z: 0 + z: -5 }; -var MODEL_LIGHT_ROTATION = Quat.angleAxis(-90, { +var MODEL_LIGHT_ROTATION = Quat.angleAxis(0, { x: 0, - y: 1, - z: 0 + y: 0, + z: 1 }); // Evaluate the world light entity positions and orientations from the model ones @@ -27,31 +27,46 @@ var helicopter = Entities.addEntity({ type: "Model", name: "Helicopter", modelURL: modelURL, - position: center + dimensions: {x: 12.13, y: 3.14, z: 9.92}, + // rotation: Quat.fromPitchYawRollDegrees(0, -90, 0), + position: center, + collisionsWillMove: true }); -var modelProperties = Entities.getEntityProperties(helicopter, ['position', 'rotation']); -var lightTransform = evalLightWorldTransform(modelProperties.position, modelProperties.rotation); var spotlight = Entities.addEntity({ type: "Light", name: "helicopter light", - position: lightTransform.p, - rotation: lightTransform.q, intensity: 2, - color: {red: 200, green: 200, blue: 255}, - intensity: 2, - exponent: 0.3, - cutoff: 20 + color: { + red: 200, + green: 200, + blue: 255 + }, + intensity: 10, + dimensions: { + x: 2, + y: 2, + z: 200 + }, + exponent: .1, + cutoff: 10, + isSpotlight: true }); var debugLight = Entities.addEntity({ type: "Box", - position: lightTransform.p, - rotation: lightTransform.q, - dimensions: {x: 4, y: 1, z: 1}, - color: {red: 200, green: 200, blue: 0} + dimensions: { + x: .1, + y: .1, + z: .3 + }, + color: { + red: 200, + green: 200, + blue: 0 + } }); function cleanup() { @@ -61,4 +76,19 @@ function cleanup() { } +function update() { + var modelProperties = Entities.getEntityProperties(helicopter, ['position', 'rotation']); + var lightTransform = evalLightWorldTransform(modelProperties.position, modelProperties.rotation); + Entities.editEntity(spotlight, { + position: lightTransform.p, + // rotation: lightTransform.q + }); + Entities.editEntity(debugLight, { + position: lightTransform.p, + rotation: lightTransform.q + }); +} + + +Script.update.connect(update); Script.scriptEnding.connect(cleanup); \ No newline at end of file From 0846c3bef4702177969837bab9867669ec173927 Mon Sep 17 00:00:00 2001 From: ericrius1 Date: Tue, 3 Nov 2015 14:12:56 -0800 Subject: [PATCH 04/30] moving --- examples/helicopter/helicopter.js | 29 ++++++++++++++++++++++++----- 1 file changed, 24 insertions(+), 5 deletions(-) diff --git a/examples/helicopter/helicopter.js b/examples/helicopter/helicopter.js index 22df9e56b7..748d1d62c3 100644 --- a/examples/helicopter/helicopter.js +++ b/examples/helicopter/helicopter.js @@ -1,5 +1,13 @@ var modelURL = "https://s3.amazonaws.com/hifi-public/eric/models/helicopter.fbx?v3"; -var center = Vec3.sum(MyAvatar.position, Vec3.multiply(2, Quat.getFront(Camera.getOrientation()))); +var spawnPosition = {x: 1031, y: 135, z: 1041}; + +var speed = .1; + +var helicopterSound = SoundCache.getSound("https://hifi-public.s3.amazonaws.com/ryan/helicopter.L.wav"); +var audioInjector = Audio.playSound(helicopterSound, { + volume: 1, + loop: true +}); // These constants define the Spotlight position and orientation relative to the model var MODEL_LIGHT_POSITION = { @@ -29,8 +37,7 @@ var helicopter = Entities.addEntity({ modelURL: modelURL, dimensions: {x: 12.13, y: 3.14, z: 9.92}, // rotation: Quat.fromPitchYawRollDegrees(0, -90, 0), - position: center, - collisionsWillMove: true + position: spawnPosition, }); @@ -50,8 +57,8 @@ var spotlight = Entities.addEntity({ y: 2, z: 200 }, - exponent: .1, - cutoff: 10, + exponent: 1, + cutoff: 40, isSpotlight: true }); @@ -87,6 +94,18 @@ function update() { position: lightTransform.p, rotation: lightTransform.q }); + + audioInjector.setOptions({ + position: modelProperties.position, + }); + + //Move forward + var newRotation = Quat.multiply(modelProperties.rotation, {x: 0, y: .001, z: 0, w: 1}) + var newPosition = Vec3.sum(modelProperties.position, Vec3.multiply(speed, Quat.getFront(modelProperties.rotation))); + Entities.editEntity(helicopter, { + position: newPosition, + rotation: newRotation + }) } From ed2bd075859c20c48c1942ec215aa93fed930153 Mon Sep 17 00:00:00 2001 From: ericrius1 Date: Tue, 3 Nov 2015 14:54:05 -0800 Subject: [PATCH 05/30] rotating blade --- examples/helicopter/helicopter.js | 50 +++++++++++++++++++++---------- 1 file changed, 35 insertions(+), 15 deletions(-) diff --git a/examples/helicopter/helicopter.js b/examples/helicopter/helicopter.js index 748d1d62c3..154613f20c 100644 --- a/examples/helicopter/helicopter.js +++ b/examples/helicopter/helicopter.js @@ -1,5 +1,10 @@ var modelURL = "https://s3.amazonaws.com/hifi-public/eric/models/helicopter.fbx?v3"; -var spawnPosition = {x: 1031, y: 135, z: 1041}; +var animationURL = "https://s3.amazonaws.com/hifi-public/eric/models/bladeAnimation.fbx?v7"; +var spawnPosition = { + x: 1031, + y: 135, + z: 1041 +}; var speed = .1; @@ -15,7 +20,7 @@ var MODEL_LIGHT_POSITION = { y: 0, z: -5 }; -var MODEL_LIGHT_ROTATION = Quat.angleAxis(0, { +var MODEL_LIGHT_ROTATION = Quat.angleAxis(0, { x: 0, y: 0, z: 1 @@ -35,7 +40,17 @@ var helicopter = Entities.addEntity({ type: "Model", name: "Helicopter", modelURL: modelURL, - dimensions: {x: 12.13, y: 3.14, z: 9.92}, + animation: { + url: animationURL, + running: true, + fps: 180 + + }, + dimensions: { + x: 12.13, + y: 3.14, + z: 9.92 + }, // rotation: Quat.fromPitchYawRollDegrees(0, -90, 0), position: spawnPosition, }); @@ -87,25 +102,30 @@ function update() { var modelProperties = Entities.getEntityProperties(helicopter, ['position', 'rotation']); var lightTransform = evalLightWorldTransform(modelProperties.position, modelProperties.rotation); Entities.editEntity(spotlight, { - position: lightTransform.p, - // rotation: lightTransform.q + position: lightTransform.p, + // rotation: lightTransform.q }); - Entities.editEntity(debugLight, { - position: lightTransform.p, - rotation: lightTransform.q + Entities.editEntity(debugLight, { + position: lightTransform.p, + rotation: lightTransform.q }); - audioInjector.setOptions({ + audioInjector.setOptions({ position: modelProperties.position, - }); + }); - //Move forward - var newRotation = Quat.multiply(modelProperties.rotation, {x: 0, y: .001, z: 0, w: 1}) - var newPosition = Vec3.sum(modelProperties.position, Vec3.multiply(speed, Quat.getFront(modelProperties.rotation))); - Entities.editEntity(helicopter, { + //Move forward + var newRotation = Quat.multiply(modelProperties.rotation, { + x: 0, + y: .001, + z: 0, + w: 1 + }) + var newPosition = Vec3.sum(modelProperties.position, Vec3.multiply(speed, Quat.getFront(modelProperties.rotation))); + Entities.editEntity(helicopter, { position: newPosition, rotation: newRotation - }) + }) } From 0650280fb665f60a54858a3831d75ab35b27ee46 Mon Sep 17 00:00:00 2001 From: ericrius1 Date: Tue, 3 Nov 2015 15:14:56 -0800 Subject: [PATCH 06/30] tweaks --- examples/helicopter/helicopter.js | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/examples/helicopter/helicopter.js b/examples/helicopter/helicopter.js index 154613f20c..44482e1c85 100644 --- a/examples/helicopter/helicopter.js +++ b/examples/helicopter/helicopter.js @@ -2,15 +2,15 @@ var modelURL = "https://s3.amazonaws.com/hifi-public/eric/models/helicopter.fbx? var animationURL = "https://s3.amazonaws.com/hifi-public/eric/models/bladeAnimation.fbx?v7"; var spawnPosition = { x: 1031, - y: 135, + y: 145, z: 1041 }; -var speed = .1; +var speed = .15; var helicopterSound = SoundCache.getSound("https://hifi-public.s3.amazonaws.com/ryan/helicopter.L.wav"); var audioInjector = Audio.playSound(helicopterSound, { - volume: 1, + volume: 0.3, loop: true }); @@ -20,10 +20,10 @@ var MODEL_LIGHT_POSITION = { y: 0, z: -5 }; -var MODEL_LIGHT_ROTATION = Quat.angleAxis(0, { - x: 0, +var MODEL_LIGHT_ROTATION = Quat.angleAxis(-90, { + x: 1, y: 0, - z: 1 + z: 0 }); // Evaluate the world light entity positions and orientations from the model ones @@ -66,14 +66,14 @@ var spotlight = Entities.addEntity({ green: 200, blue: 255 }, - intensity: 10, + intensity: 1, dimensions: { x: 2, y: 2, z: 200 }, - exponent: 1, - cutoff: 40, + exponent: 0.01, + cutoff: 10, isSpotlight: true }); @@ -103,7 +103,7 @@ function update() { var lightTransform = evalLightWorldTransform(modelProperties.position, modelProperties.rotation); Entities.editEntity(spotlight, { position: lightTransform.p, - // rotation: lightTransform.q + rotation: lightTransform.q }); Entities.editEntity(debugLight, { position: lightTransform.p, @@ -117,7 +117,7 @@ function update() { //Move forward var newRotation = Quat.multiply(modelProperties.rotation, { x: 0, - y: .001, + y: .002, z: 0, w: 1 }) From 3c227db08ddd32b3e372e14c47ff45a09a0be43a Mon Sep 17 00:00:00 2001 From: ericrius1 Date: Wed, 4 Nov 2015 11:27:16 -0800 Subject: [PATCH 07/30] explode heli --- examples/helicopter/explodeHelicopter.js | 62 ++++++++++++++++++++++++ examples/helicopter/helicopter.js | 2 +- 2 files changed, 63 insertions(+), 1 deletion(-) create mode 100644 examples/helicopter/explodeHelicopter.js diff --git a/examples/helicopter/explodeHelicopter.js b/examples/helicopter/explodeHelicopter.js new file mode 100644 index 0000000000..98e806dbfd --- /dev/null +++ b/examples/helicopter/explodeHelicopter.js @@ -0,0 +1,62 @@ +var partsURLS = [ + "https://s3.amazonaws.com/hifi-public/eric/models/blade.fbx", + "https://s3.amazonaws.com/hifi-public/eric/models/body.fbx", + "https://s3.amazonaws.com/hifi-public/eric/models/tail.fbx", +] + +var parts = []; + +var explodePosition; +var helicopter; +var entities = Entities.findEntities(MyAvatar.position, 2000); +for (i = 0; i < entities.length; i++) { + var name = Entities.getEntityProperties(entities[i], 'name').name; + if (name === "Helicopter") { + helicopter = entities[i]; + explodeHelicopter(Entities.getEntityProperties(helicopter, 'position').position); + } +} + + +function explodeHelicopter(explodePosition) { + Entities.deleteEntity(helicopter); + for (var i = 0; i < partsURLS.length; i++) { + var part = Entities.addEntity({ + type: "Model", + modelURL: partsURLS[i], + position: explodePosition, + shapeType: "box", + damping: 0 + }); + parts.push(part); + } + + Script.setTimeout(function() { + parts.forEach(function(part) { + var naturalDimensions = Entities.getEntityProperties(part, "naturalDimensions").naturalDimensions; + Entities.editEntity(part, { + dimensions: naturalDimensions, + gravity: { + x: 0, + y: -9.6, + z: 0 + }, + velocity: { + x: Math.random(), + y: -10, + z: Math.random() + }, + collisionsWillMove: true + }); + }); + }, 1000); + +} + +function cleanup() { + parts.forEach(function(part) { + Entities.deleteEntity(part); + }); +} + +Script.scriptEnding.connect(cleanup); \ No newline at end of file diff --git a/examples/helicopter/helicopter.js b/examples/helicopter/helicopter.js index 44482e1c85..c1ad0f9d30 100644 --- a/examples/helicopter/helicopter.js +++ b/examples/helicopter/helicopter.js @@ -6,7 +6,7 @@ var spawnPosition = { z: 1041 }; -var speed = .15; +var speed = 0; var helicopterSound = SoundCache.getSound("https://hifi-public.s3.amazonaws.com/ryan/helicopter.L.wav"); var audioInjector = Audio.playSound(helicopterSound, { From b7840fdd6b48f4a921e72e54817187dc26f874f6 Mon Sep 17 00:00:00 2001 From: ericrius1 Date: Wed, 4 Nov 2015 15:01:55 -0800 Subject: [PATCH 08/30] explosion --- examples/helicopter/explodeHelicopter.js | 136 ++++++++++++++++++----- 1 file changed, 109 insertions(+), 27 deletions(-) diff --git a/examples/helicopter/explodeHelicopter.js b/examples/helicopter/explodeHelicopter.js index 98e806dbfd..efca1a91cc 100644 --- a/examples/helicopter/explodeHelicopter.js +++ b/examples/helicopter/explodeHelicopter.js @@ -1,10 +1,30 @@ -var partsURLS = [ - "https://s3.amazonaws.com/hifi-public/eric/models/blade.fbx", - "https://s3.amazonaws.com/hifi-public/eric/models/body.fbx", - "https://s3.amazonaws.com/hifi-public/eric/models/tail.fbx", -] +var explosionSound = SoundCache.getSound("https://s3.amazonaws.com/hifi-public/eric/sounds/explosion.wav"); + +var partsURLS = [{ + url: "https://s3.amazonaws.com/hifi-public/eric/models/blade.fbx", + dimensions: { + x: 2, + y: 2, + z: 2 + } +}, { + url: "https://s3.amazonaws.com/hifi-public/eric/models/body.fbx", + dimensions: { + x: 2.2, + y: 2.98, + z: 7.96 + } +}, { + url: "https://s3.amazonaws.com/hifi-public/eric/models/tail.fbx", + dimensions: { + x: 1, + y: 1, + z: 1 + } +}]; var parts = []; +var emitters = []; var explodePosition; var helicopter; @@ -12,44 +32,103 @@ var entities = Entities.findEntities(MyAvatar.position, 2000); for (i = 0; i < entities.length; i++) { var name = Entities.getEntityProperties(entities[i], 'name').name; if (name === "Helicopter") { - helicopter = entities[i]; + var helicopter = entities[i]; explodeHelicopter(Entities.getEntityProperties(helicopter, 'position').position); } } function explodeHelicopter(explodePosition) { + Audio.playSound(explosionSound, { + position: explodePosition, + volume: 0.5 + }); Entities.deleteEntity(helicopter); for (var i = 0; i < partsURLS.length; i++) { + var position = Vec3.sum(explodePosition, { + x: 1, + y: 1, + z: 1 + }); var part = Entities.addEntity({ type: "Model", - modelURL: partsURLS[i], - position: explodePosition, + modelURL: partsURLS[i].url, + dimensions: partsURLS[i].dimensions, + position: position, shapeType: "box", - damping: 0 + collisionsWillMove: true, + damping: 0, + gravity: { + x: 0, + y: -9.6, + z: 0 + }, + velocity: { + x: Math.random(), + y: -10, + z: Math.random() + } }); + + var emitter = Entities.addEntity({ + type: "ParticleEffect", + name: "fire", + isEmitting: true, + textures: "https://hifi-public.s3.amazonaws.com/alan/Particles/Particle-Sprite-Smoke-1.png", + position: explodePosition, + emitRate: 100, + colorStart: { + red: 70, + green: 70, + blue: 137 + }, + color: { + red: 200, + green: 99, + blue: 42 + }, + colorFinish: { + red: 255, + green: 99, + blue: 32 + }, + radiusSpread: 0.2, + radiusStart: 0.3, + radiusEnd: 0.04, + particleRadius: 0.09, + radiusFinish: 0.0, + emitSpeed: 0.1, + speedSpread: 0.1, + alphaStart: 0.1, + alpha: 0.7, + alphaFinish: 0.1, + emitOrientation: Quat.fromPitchYawRollDegrees(-90, 0, 0), + emitDimensions: { + x: 1, + y: 1, + z: 0.1 + }, + polarFinish: Math.PI, + polarStart: 0, + + accelerationSpread: { + x: 0.1, + y: 0.01, + z: 0.1 + }, + lifespan: 1, + }); + emitters.push(emitter) parts.push(part); } Script.setTimeout(function() { - parts.forEach(function(part) { - var naturalDimensions = Entities.getEntityProperties(part, "naturalDimensions").naturalDimensions; - Entities.editEntity(part, { - dimensions: naturalDimensions, - gravity: { - x: 0, - y: -9.6, - z: 0 - }, - velocity: { - x: Math.random(), - y: -10, - z: Math.random() - }, - collisionsWillMove: true - }); - }); - }, 1000); + var pos = Entities.getEntityProperties(parts[1], "position").position; + Entities.editEntity(emitters[0], {position: Vec3.sum(pos, {x: Math.random(), y: Math.random(), z: Math.random()})}); + Entities.editEntity(emitters[1], {position: Vec3.sum(pos, {x: Math.random(), y: Math.random(), z: Math.random()})}); + Entities.editEntity(emitters[2], {position: Vec3.sum(pos, {x: Math.random(), y: Math.random(), z: Math.random()})}); + }, 5000) + } @@ -57,6 +136,9 @@ function cleanup() { parts.forEach(function(part) { Entities.deleteEntity(part); }); + emitters.forEach(function(emitter){ + Entities.deleteEntity(emitter); + }) } Script.scriptEnding.connect(cleanup); \ No newline at end of file From c002888808765940fc0b4dd42d444f6be25645d5 Mon Sep 17 00:00:00 2001 From: "Anthony J. Thibault" Date: Fri, 6 Nov 2015 14:52:12 -0800 Subject: [PATCH 09/30] Added cache extractor to the tools directory It should find the local High Fidelity/Interface qt cache, iterate over each file in the cache and output each corresponding file into the High Fidelity/Interface/extracted dir. The file path will be determined from the source url. Untested on windows. --- tools/CMakeLists.txt | 3 + tools/cache-extract/CMakeLists.txt | 6 + tools/cache-extract/src/CacheExtractApp.cpp | 125 ++++++++++++++++++++ tools/cache-extract/src/CacheExtractApp.h | 47 ++++++++ tools/cache-extract/src/main.cpp | 17 +++ 5 files changed, 198 insertions(+) create mode 100644 tools/cache-extract/CMakeLists.txt create mode 100644 tools/cache-extract/src/CacheExtractApp.cpp create mode 100644 tools/cache-extract/src/CacheExtractApp.h create mode 100644 tools/cache-extract/src/main.cpp diff --git a/tools/CMakeLists.txt b/tools/CMakeLists.txt index 2056044a4b..9bc7031720 100644 --- a/tools/CMakeLists.txt +++ b/tools/CMakeLists.txt @@ -10,3 +10,6 @@ set_target_properties(udt-test PROPERTIES FOLDER "Tools") add_subdirectory(vhacd-util) set_target_properties(vhacd-util PROPERTIES FOLDER "Tools") + +add_subdirectory(cache-extract) +set_target_properties(cache-extract PROPERTIES FOLDER "Tools") diff --git a/tools/cache-extract/CMakeLists.txt b/tools/cache-extract/CMakeLists.txt new file mode 100644 index 0000000000..045fa996d2 --- /dev/null +++ b/tools/cache-extract/CMakeLists.txt @@ -0,0 +1,6 @@ +set(TARGET_NAME cache-extract) + +setup_hifi_project() + +link_hifi_libraries() + diff --git a/tools/cache-extract/src/CacheExtractApp.cpp b/tools/cache-extract/src/CacheExtractApp.cpp new file mode 100644 index 0000000000..e7e60973af --- /dev/null +++ b/tools/cache-extract/src/CacheExtractApp.cpp @@ -0,0 +1,125 @@ +// +// CacheExtractApp.cpp +// tools/cache-extract/src +// +// Created by Anthony Thibault on 11/6/2015. +// 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 +// + +#include "CacheExtractApp.h" +#include +#include +#include +#include + +// extracted from qnetworkdiskcache.cpp +#define CACHE_VERSION 8 +enum { + CacheMagic = 0xe8, + CurrentCacheVersion = CACHE_VERSION +}; +#define DATA_DIR QLatin1String("data") + +CacheExtractApp::CacheExtractApp(int& argc, char** argv) : + QCoreApplication(argc, argv) +{ + QString myDataLoc = QStandardPaths::writableLocation(QStandardPaths::DataLocation); + int lastSlash = myDataLoc.lastIndexOf(QDir::separator()); + QString cachePath = myDataLoc.leftRef(lastSlash).toString() + QDir::separator() + + "High Fidelity" + QDir::separator() + "Interface" + QDir::separator() + + DATA_DIR + QString::number(CACHE_VERSION) + QLatin1Char('/'); + + QString outputPath = myDataLoc.leftRef(lastSlash).toString() + QDir::separator() + + "High Fidelity" + QDir::separator() + "Interface" + QDir::separator() + "extracted"; + + qDebug() << "Searching cachePath = " << cachePath << "..."; + + // build list of files + QList fileList; + QDir dir(cachePath); + dir.setFilter(QDir::AllDirs | QDir::NoDotAndDotDot); + QFileInfoList list = dir.entryInfoList(); + for (int i = 0; i < list.size(); ++i) { + QFileInfo fileInfo = list.at(i); + if (fileInfo.isDir()) { + QDir subDir(fileInfo.filePath()); + subDir.setFilter(QDir::Files); + QFileInfoList subList = subDir.entryInfoList(); + for (int j = 0; j < subList.size(); ++j) { + fileList << subList.at(j).filePath(); + } + } + } + + // dump each cache file into the outputPath + for (int i = 0; i < fileList.size(); ++i) { + QByteArray contents; + MyMetaData metaData; + if (extractFile(fileList.at(i), metaData, contents)) { + QString outFileName = outputPath + metaData.url.path(); + int lastSlash = outFileName.lastIndexOf(QDir::separator()); + QString outDirName = outFileName.leftRef(lastSlash).toString(); + QDir dir(outputPath); + dir.mkpath(outDirName); + QFile out(outFileName); + if (out.open(QIODevice::WriteOnly)) { + out.write(contents); + out.close(); + } + } else { + qCritical() << "Error extracting = " << fileList.at(i); + } + } + + QMetaObject::invokeMethod(this, "quit", Qt::QueuedConnection); +} + +bool CacheExtractApp::extractFile(const QString& filePath, MyMetaData& metaData, QByteArray& data) const { + QFile f(filePath); + if (!f.open(QIODevice::ReadOnly)) { + qDebug() << "error opening " << filePath; + return false; + } + QDataStream in(&f); + // from qnetworkdiskcache.cpp QCacheItem::read() + qint32 marker, version, streamVersion; + in >> marker; + if (marker != CacheMagic) { + return false; + } + in >> version; + if (version != CurrentCacheVersion) { + return false; + } + in >> streamVersion; + if (streamVersion > in.version()) + return false; + in.setVersion(streamVersion); + + bool compressed; + in >> metaData; + in >> compressed; + if (compressed) { + QByteArray compressedData; + in >> compressedData; + QBuffer buffer; + buffer.setData(qUncompress(compressedData)); + buffer.open(QBuffer::ReadOnly); + data = buffer.readAll(); + } else { + data = f.readAll(); + } + return true; +} + +QDataStream &operator>>(QDataStream& in, MyMetaData& metaData) { + in >> metaData.url; + in >> metaData.expirationDate; + in >> metaData.lastModified; + in >> metaData.saveToDisk; + in >> metaData.attributes; + in >> metaData.rawHeaders; +} diff --git a/tools/cache-extract/src/CacheExtractApp.h b/tools/cache-extract/src/CacheExtractApp.h new file mode 100644 index 0000000000..3dde1f684d --- /dev/null +++ b/tools/cache-extract/src/CacheExtractApp.h @@ -0,0 +1,47 @@ +// +// CacheExtractApp.h +// tools/cache-extract/src +// +// Created by Anthony Thibault on 11/6/2015 +// 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 +// + +#ifndef hifi_CacheExtractApp_h +#define hifi_CacheExtractApp_h + +#include +#include +#include +#include +#include +#include + +// copy of QNetworkCacheMetaData +class MyMetaData { +public: + typedef QPair RawHeader; + typedef QList RawHeaderList; + typedef QHash AttributesMap; + + QUrl url; + QDateTime expirationDate; + QDateTime lastModified; + bool saveToDisk; + AttributesMap attributes; + RawHeaderList rawHeaders; +}; + +QDataStream &operator>>(QDataStream &, MyMetaData &); + +class CacheExtractApp : public QCoreApplication { + Q_OBJECT +public: + CacheExtractApp(int& argc, char** argv); + + bool extractFile(const QString& filePath, MyMetaData& metaData, QByteArray& data) const; +}; + +#endif // hifi_CacheExtractApp_h diff --git a/tools/cache-extract/src/main.cpp b/tools/cache-extract/src/main.cpp new file mode 100644 index 0000000000..71a364ed3e --- /dev/null +++ b/tools/cache-extract/src/main.cpp @@ -0,0 +1,17 @@ +// +// main.cpp +// tools/cache-extract/src +// +// Created by Anthony Thibault on 11/6/2015. +// 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 + +#include +#include "CacheExtractApp.h" + +int main (int argc, char** argv) { + CacheExtractApp app(argc, argv); + return app.exec(); +} From 086b0645273f33c9fc00cfd99cb82b82fef0725e Mon Sep 17 00:00:00 2001 From: "Anthony J. Thibault" Date: Fri, 6 Nov 2015 15:07:38 -0800 Subject: [PATCH 10/30] Dumps all urls extracted to stdout. --- tools/cache-extract/src/CacheExtractApp.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/tools/cache-extract/src/CacheExtractApp.cpp b/tools/cache-extract/src/CacheExtractApp.cpp index e7e60973af..a0d0bf54ec 100644 --- a/tools/cache-extract/src/CacheExtractApp.cpp +++ b/tools/cache-extract/src/CacheExtractApp.cpp @@ -68,6 +68,7 @@ CacheExtractApp::CacheExtractApp(int& argc, char** argv) : if (out.open(QIODevice::WriteOnly)) { out.write(contents); out.close(); + qDebug().noquote() << metaData.url.toDisplayString(); } } else { qCritical() << "Error extracting = " << fileList.at(i); From 9a484ff00dd71b94c34712759fc4a863a99c910a Mon Sep 17 00:00:00 2001 From: "Anthony J. Thibault" Date: Fri, 6 Nov 2015 15:33:06 -0800 Subject: [PATCH 11/30] Fixes for windows --- tools/cache-extract/CMakeLists.txt | 1 + tools/cache-extract/src/CacheExtractApp.cpp | 22 ++++++++++++--------- 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/tools/cache-extract/CMakeLists.txt b/tools/cache-extract/CMakeLists.txt index 045fa996d2..1aaa4d9d04 100644 --- a/tools/cache-extract/CMakeLists.txt +++ b/tools/cache-extract/CMakeLists.txt @@ -3,4 +3,5 @@ set(TARGET_NAME cache-extract) setup_hifi_project() link_hifi_libraries() +copy_dlls_beside_windows_executable() diff --git a/tools/cache-extract/src/CacheExtractApp.cpp b/tools/cache-extract/src/CacheExtractApp.cpp index a0d0bf54ec..0cfaef3f83 100644 --- a/tools/cache-extract/src/CacheExtractApp.cpp +++ b/tools/cache-extract/src/CacheExtractApp.cpp @@ -14,6 +14,7 @@ #include #include #include +#include // extracted from qnetworkdiskcache.cpp #define CACHE_VERSION 8 @@ -21,19 +22,18 @@ enum { CacheMagic = 0xe8, CurrentCacheVersion = CACHE_VERSION }; -#define DATA_DIR QLatin1String("data") CacheExtractApp::CacheExtractApp(int& argc, char** argv) : QCoreApplication(argc, argv) { QString myDataLoc = QStandardPaths::writableLocation(QStandardPaths::DataLocation); - int lastSlash = myDataLoc.lastIndexOf(QDir::separator()); - QString cachePath = myDataLoc.leftRef(lastSlash).toString() + QDir::separator() + - "High Fidelity" + QDir::separator() + "Interface" + QDir::separator() + - DATA_DIR + QString::number(CACHE_VERSION) + QLatin1Char('/'); + int lastSlash = myDataLoc.lastIndexOf("/"); + QString cachePath = myDataLoc.leftRef(lastSlash).toString() + "/" + + "High Fidelity" + "/" + "Interface" + "/" + + "data" + QString::number(CACHE_VERSION) + "/"; - QString outputPath = myDataLoc.leftRef(lastSlash).toString() + QDir::separator() + - "High Fidelity" + QDir::separator() + "Interface" + QDir::separator() + "extracted"; + QString outputPath = myDataLoc.leftRef(lastSlash).toString() + "/" + + "High Fidelity" + "/" + "Interface" + "/" + "extracted"; qDebug() << "Searching cachePath = " << cachePath << "..."; @@ -60,9 +60,9 @@ CacheExtractApp::CacheExtractApp(int& argc, char** argv) : MyMetaData metaData; if (extractFile(fileList.at(i), metaData, contents)) { QString outFileName = outputPath + metaData.url.path(); - int lastSlash = outFileName.lastIndexOf(QDir::separator()); + int lastSlash = outFileName.lastIndexOf("/"); QString outDirName = outFileName.leftRef(lastSlash).toString(); - QDir dir(outputPath); + QDir dir; dir.mkpath(outDirName); QFile out(outFileName); if (out.open(QIODevice::WriteOnly)) { @@ -70,6 +70,9 @@ CacheExtractApp::CacheExtractApp(int& argc, char** argv) : out.close(); qDebug().noquote() << metaData.url.toDisplayString(); } + else { + qCritical() << "Error opening outputFile = " << outFileName; + } } else { qCritical() << "Error extracting = " << fileList.at(i); } @@ -123,4 +126,5 @@ QDataStream &operator>>(QDataStream& in, MyMetaData& metaData) { in >> metaData.saveToDisk; in >> metaData.attributes; in >> metaData.rawHeaders; + return in; } From 82b26b75f4024099e569ef6703594adf3321759b Mon Sep 17 00:00:00 2001 From: "Anthony J. Thibault" Date: Mon, 9 Nov 2015 08:14:27 -0800 Subject: [PATCH 12/30] Code convention fixes --- tools/cache-extract/src/CacheExtractApp.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tools/cache-extract/src/CacheExtractApp.h b/tools/cache-extract/src/CacheExtractApp.h index 3dde1f684d..3b34ff891d 100644 --- a/tools/cache-extract/src/CacheExtractApp.h +++ b/tools/cache-extract/src/CacheExtractApp.h @@ -22,9 +22,9 @@ // copy of QNetworkCacheMetaData class MyMetaData { public: - typedef QPair RawHeader; - typedef QList RawHeaderList; - typedef QHash AttributesMap; + using RawHeader = QPair; + using RawHeaderList = QList; + using AttributesMap = QHash; QUrl url; QDateTime expirationDate; @@ -34,7 +34,7 @@ public: RawHeaderList rawHeaders; }; -QDataStream &operator>>(QDataStream &, MyMetaData &); +QDataStream &operator>>(QDataStream& in, MyMetaData& metaData); class CacheExtractApp : public QCoreApplication { Q_OBJECT From b8357112660a0955077056d138acbe1e9d5e9d81 Mon Sep 17 00:00:00 2001 From: Ryan Huffman Date: Mon, 9 Nov 2015 12:04:17 -0800 Subject: [PATCH 13/30] Update script engine path resolution behavior The path resolution will now be relative to the script currently being evaluated *on its initial evaluation.* The previous behavior was that all paths would be resolved relative to the root script for client scripts, and inconsistent for entity scripts depending on the order that scripts were loaded. The entity script situation was particularly bad because including more than 1 level deep produced inconsistent results. --- libraries/script-engine/src/ScriptEngine.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/libraries/script-engine/src/ScriptEngine.cpp b/libraries/script-engine/src/ScriptEngine.cpp index 381eef63db..e2a3143026 100644 --- a/libraries/script-engine/src/ScriptEngine.cpp +++ b/libraries/script-engine/src/ScriptEngine.cpp @@ -901,14 +901,19 @@ void ScriptEngine::include(const QStringList& includeFiles, QScriptValue callbac BatchLoader* loader = new BatchLoader(urls); auto evaluateScripts = [=](const QMap& data) { + auto parentURL = _parentURL; for (QUrl url : urls) { QString contents = data[url]; if (contents.isNull()) { qCDebug(scriptengine) << "Error loading file: " << url << "line:" << __LINE__; } else { + // Set the parent url so that path resolution will be relative + // to this script's url during its initial evaluation + _parentURL = url.toString(); QScriptValue result = evaluate(contents, url.toString()); } } + _parentURL = parentURL; if (callback.isFunction()) { QScriptValue(callback).call(); From 53ca4c857d8d10752b9b0c6f82b55bd8ce01bcfb Mon Sep 17 00:00:00 2001 From: Ryan Huffman Date: Tue, 10 Nov 2015 08:52:37 -0800 Subject: [PATCH 14/30] Fix relative include path in entityCameraTool.js --- examples/libraries/entityCameraTool.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/libraries/entityCameraTool.js b/examples/libraries/entityCameraTool.js index 88e01b29fe..e3e86cedb3 100644 --- a/examples/libraries/entityCameraTool.js +++ b/examples/libraries/entityCameraTool.js @@ -9,7 +9,7 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -Script.include("libraries/overlayUtils.js"); +Script.include("overlayUtils.js"); var MOUSE_SENSITIVITY = 0.9; var SCROLL_SENSITIVITY = 0.05; From f5308530e680641260250b7fb55d2b475d36dec2 Mon Sep 17 00:00:00 2001 From: ericrius1 Date: Tue, 10 Nov 2015 09:35:35 -0800 Subject: [PATCH 15/30] Removed commented out line --- examples/helicopter/helicopter.js | 1 - 1 file changed, 1 deletion(-) diff --git a/examples/helicopter/helicopter.js b/examples/helicopter/helicopter.js index c1ad0f9d30..7073722e1e 100644 --- a/examples/helicopter/helicopter.js +++ b/examples/helicopter/helicopter.js @@ -51,7 +51,6 @@ var helicopter = Entities.addEntity({ y: 3.14, z: 9.92 }, - // rotation: Quat.fromPitchYawRollDegrees(0, -90, 0), position: spawnPosition, }); From b802da4fef56d06638b863843b3519f1a1865b89 Mon Sep 17 00:00:00 2001 From: Ryan Huffman Date: Tue, 10 Nov 2015 09:37:36 -0800 Subject: [PATCH 16/30] Fix include in satellite.js --- examples/example/games/satellite.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/example/games/satellite.js b/examples/example/games/satellite.js index db65198b87..9ae0105917 100644 --- a/examples/example/games/satellite.js +++ b/examples/example/games/satellite.js @@ -15,7 +15,7 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -Script.include('../utilities/tools/vector.js'); +Script.include('../../utilities/tools/vector.js'); var URL = "https://s3.amazonaws.com/hifi-public/marketplace/hificontent/Scripts/planets/"; From 37d9d98594681c92a22c5d7b1fc6d0d224a98244 Mon Sep 17 00:00:00 2001 From: Ryan Huffman Date: Tue, 10 Nov 2015 09:37:53 -0800 Subject: [PATCH 17/30] Fix breakdance include paths --- .../libraries/omniTool/modules/breakdanceOmniToolModule.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/libraries/omniTool/modules/breakdanceOmniToolModule.js b/examples/libraries/omniTool/modules/breakdanceOmniToolModule.js index 36ee6b1fee..3764c5e381 100644 --- a/examples/libraries/omniTool/modules/breakdanceOmniToolModule.js +++ b/examples/libraries/omniTool/modules/breakdanceOmniToolModule.js @@ -11,7 +11,7 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -Script.include("../toys/breakdanceCore.js"); +Script.include("../../../breakdanceCore.js"); OmniToolModules.Breakdance = function() { print("OmniToolModules.Breakdance..."); @@ -32,4 +32,4 @@ OmniToolModules.Breakdance.prototype.onUpdate = function(deltaTime) { breakdanceEnd(); } -OmniToolModuleType = "Breakdance"; \ No newline at end of file +OmniToolModuleType = "Breakdance"; From 29fd352169427959c315323f43fe295ac5ea62f6 Mon Sep 17 00:00:00 2001 From: Ryan Huffman Date: Tue, 10 Nov 2015 09:38:21 -0800 Subject: [PATCH 18/30] Fix omniTool test module include path --- examples/libraries/omniTool/modules/test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/libraries/omniTool/modules/test.js b/examples/libraries/omniTool/modules/test.js index 9f7191b2d0..83472ee0f1 100644 --- a/examples/libraries/omniTool/modules/test.js +++ b/examples/libraries/omniTool/modules/test.js @@ -1,5 +1,5 @@ -Script.include("avatarRelativeOverlays.js"); +Script.include("../../avatarRelativeOverlays.js"); OmniToolModules.Test = function(omniTool, activeEntityId) { this.omniTool = omniTool; From 2ad4c5b9e22118843b100fcfaed24b78f09ea6e9 Mon Sep 17 00:00:00 2001 From: Ryan Huffman Date: Tue, 10 Nov 2015 09:38:40 -0800 Subject: [PATCH 19/30] Fix walkApi include paths --- examples/libraries/walkApi.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/libraries/walkApi.js b/examples/libraries/walkApi.js index 8935380150..3a51491cac 100644 --- a/examples/libraries/walkApi.js +++ b/examples/libraries/walkApi.js @@ -14,7 +14,7 @@ // // included here to ensure walkApi.js can be used as an API, separate from walk.js -Script.include("./libraries/walkConstants.js"); +Script.include("walkConstants.js"); Avatar = function() { // if Hydras are connected, the only way to enable use is to never set any arm joint rotation From 6577c7a13c792632e8f9b558033cde8cbf8acb9c Mon Sep 17 00:00:00 2001 From: Ryan Huffman Date: Tue, 10 Nov 2015 09:38:52 -0800 Subject: [PATCH 20/30] Fix magBalls include paths --- examples/magBalls.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/examples/magBalls.js b/examples/magBalls.js index c9b45164ab..465e5f8e57 100644 --- a/examples/magBalls.js +++ b/examples/magBalls.js @@ -7,11 +7,11 @@ // // FIXME Script paths have to be relative to the caller, in this case libraries/OmniTool.js -Script.include("../magBalls/constants.js"); -Script.include("../magBalls/graph.js"); -Script.include("../magBalls/edgeSpring.js"); -Script.include("../magBalls/magBalls.js"); -Script.include("avatarRelativeOverlays.js"); +Script.include("magBalls/constants.js"); +Script.include("magBalls/graph.js"); +Script.include("magBalls/edgeSpring.js"); +Script.include("magBalls/magBalls.js"); +Script.include("libraries/avatarRelativeOverlays.js"); OmniToolModuleType = "MagBallsController" From e7e6c63c64b8c20520331cff2f2443874c5a6063 Mon Sep 17 00:00:00 2001 From: Ryan Huffman Date: Tue, 10 Nov 2015 11:36:53 -0800 Subject: [PATCH 21/30] Fix edit.js resolvePath calls --- examples/libraries/entityList.js | 4 +++- examples/libraries/gridTool.js | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/examples/libraries/entityList.js b/examples/libraries/entityList.js index bb84ce27b4..1aa08fbe2d 100644 --- a/examples/libraries/entityList.js +++ b/examples/libraries/entityList.js @@ -1,7 +1,9 @@ +var ENTITY_LIST_HTML_URL = Script.resolvePath('../html/entityList.html'); + EntityListTool = function(opts) { var that = {}; - var url = Script.resolvePath('html/entityList.html'); + var url = ENTITY_LIST_HTML_URL; var webView = new WebWindow('Entities', url, 200, 280, true); var searchRadius = 100; diff --git a/examples/libraries/gridTool.js b/examples/libraries/gridTool.js index ed4e999be8..35d9858ace 100644 --- a/examples/libraries/gridTool.js +++ b/examples/libraries/gridTool.js @@ -1,3 +1,5 @@ +var GRID_CONTROLS_HTML_URL = Script.resolvePath('../html/gridControls.html'); + Grid = function(opts) { var that = {}; @@ -228,7 +230,7 @@ GridTool = function(opts) { var verticalGrid = opts.verticalGrid; var listeners = []; - var url = Script.resolvePath('html/gridControls.html'); + var url = GRID_CONTROLS_HTML_URL; var webView = new WebWindow('Grid', url, 200, 280, true); horizontalGrid.addListener(function(data) { From 2a349620eef3c094efbbd383e261209a55a11ebb Mon Sep 17 00:00:00 2001 From: Ryan Huffman Date: Tue, 10 Nov 2015 11:37:59 -0800 Subject: [PATCH 22/30] Fix walkSettings.js resolvePath calls --- examples/libraries/walkSettings.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/examples/libraries/walkSettings.js b/examples/libraries/walkSettings.js index 3e5ac53572..0378f305b5 100644 --- a/examples/libraries/walkSettings.js +++ b/examples/libraries/walkSettings.js @@ -13,6 +13,8 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // +var WALK_SETTINGS_HTML_URL = Script.resolvePath('../html/walkSettings.html'); + WalkSettings = function() { var _visible = false; var _innerWidth = Window.innerWidth; @@ -69,7 +71,7 @@ WalkSettings = function() { // web window const PANEL_WIDTH = 200; const PANEL_HEIGHT = 180; - var _url = Script.resolvePath('html/walkSettings.html'); + var _url = WALK_SETTINGS_HTML_URL; var _webWindow = new WebWindow('Walk Settings', _url, PANEL_WIDTH, PANEL_HEIGHT, false); _webWindow.setVisible(false); _webWindow.eventBridge.webEventReceived.connect(function(data) { From 90a1fbe04eecadbf5e7f0db5c19e645ffb8ab73d Mon Sep 17 00:00:00 2001 From: Ryan Huffman Date: Tue, 10 Nov 2015 11:38:16 -0800 Subject: [PATCH 23/30] Fix magBalls.js resolvePath calls --- examples/magBalls.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/magBalls.js b/examples/magBalls.js index 465e5f8e57..bda6ccd9c3 100644 --- a/examples/magBalls.js +++ b/examples/magBalls.js @@ -34,7 +34,7 @@ MODE_INFO[BALL_EDIT_MODE_ADD] = { }, colors: [ COLORS.GREEN, COLORS.BLUE ], // FIXME use an http path or find a way to get the relative path to the file - url: Script.resolvePath('../html/magBalls/addMode.html'), + url: Script.resolvePath('html/magBalls/addMode.html'), }; MODE_INFO[BALL_EDIT_MODE_DELETE] = { @@ -45,7 +45,7 @@ MODE_INFO[BALL_EDIT_MODE_DELETE] = { }, colors: [ COLORS.RED, COLORS.BLUE ], // FIXME use an http path or find a way to get the relative path to the file - url: Script.resolvePath('../html/magBalls/deleteMode.html'), + url: Script.resolvePath('html/magBalls/deleteMode.html'), }; var UI_POSITION_MODE_LABEL = Vec3.multiply(0.5, From a6bc1a2b5b75d0b7d2abcc6beb73ec47e20045bc Mon Sep 17 00:00:00 2001 From: Ryan Huffman Date: Tue, 10 Nov 2015 11:38:36 -0800 Subject: [PATCH 24/30] Fix closePaint.js Script.include --- examples/painting/closePaint.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/painting/closePaint.js b/examples/painting/closePaint.js index d9f70aab3c..563ed1dafb 100644 --- a/examples/painting/closePaint.js +++ b/examples/painting/closePaint.js @@ -11,7 +11,7 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -Script.include("libraries/utils.js"); +Script.include("../libraries/utils.js"); var RIGHT_HAND = 1; From a264ed479547e12b9bfb08d7ba935df08eb1cc51 Mon Sep 17 00:00:00 2001 From: Ryan Huffman Date: Tue, 10 Nov 2015 11:38:57 -0800 Subject: [PATCH 25/30] Remove old includes in bubblewand --- examples/toybox/bubblewand/createWand.js | 1 - examples/toybox/bubblewand/wand.js | 1 - 2 files changed, 2 deletions(-) diff --git a/examples/toybox/bubblewand/createWand.js b/examples/toybox/bubblewand/createWand.js index d62c2064cf..4f4bc39e2c 100644 --- a/examples/toybox/bubblewand/createWand.js +++ b/examples/toybox/bubblewand/createWand.js @@ -10,7 +10,6 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html /*global MyAvatar, Entities, AnimationCache, SoundCache, Scene, Camera, Overlays, HMD, AvatarList, AvatarManager, Controller, UndoStack, Window, Account, GlobalServices, Script, ScriptDiscoveryService, LODManager, Menu, Vec3, Quat, AudioDevice, Paths, Clipboard, Settings, XMLHttpRequest, randFloat, randInt */ -Script.include("../../utilities.js"); Script.include("../../libraries/utils.js"); var WAND_MODEL = 'http://hifi-public.s3.amazonaws.com/models/bubblewand/wand.fbx'; diff --git a/examples/toybox/bubblewand/wand.js b/examples/toybox/bubblewand/wand.js index c8ba51f51d..4bdc789612 100644 --- a/examples/toybox/bubblewand/wand.js +++ b/examples/toybox/bubblewand/wand.js @@ -14,7 +14,6 @@ (function () { - Script.include("../../utilities.js"); Script.include("../../libraries/utils.js"); var BUBBLE_MODEL = "http://hifi-public.s3.amazonaws.com/models/bubblewand/bubble.fbx"; From 5f084730d928605929e4d939c73f65bde2dacc14 Mon Sep 17 00:00:00 2001 From: Ryan Huffman Date: Tue, 10 Nov 2015 11:39:12 -0800 Subject: [PATCH 26/30] Remove old includes in doll.js --- examples/toybox/doll/doll.js | 1 - 1 file changed, 1 deletion(-) diff --git a/examples/toybox/doll/doll.js b/examples/toybox/doll/doll.js index 8f8a8cd840..577f86cae2 100644 --- a/examples/toybox/doll/doll.js +++ b/examples/toybox/doll/doll.js @@ -13,7 +13,6 @@ /*global MyAvatar, Entities, AnimationCache, SoundCache, Scene, Camera, Overlays, Audio, HMD, AvatarList, AvatarManager, Controller, UndoStack, Window, Account, GlobalServices, Script, ScriptDiscoveryService, LODManager, Menu, Vec3, Quat, AudioDevice, Paths, Clipboard, Settings, XMLHttpRequest, randFloat, randInt */ (function() { - Script.include("../../utilities.js"); Script.include("../../libraries/utils.js"); var _this; // this is the "constructor" for the entity as a JS object we don't do much here From 031a93cb0ea774f7aab30157a3c462c04e191a97 Mon Sep 17 00:00:00 2001 From: Ryan Huffman Date: Tue, 10 Nov 2015 11:39:31 -0800 Subject: [PATCH 27/30] Fix utils include in createPingPongGun.js --- examples/toybox/ping_pong_gun/createPingPongGun.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/toybox/ping_pong_gun/createPingPongGun.js b/examples/toybox/ping_pong_gun/createPingPongGun.js index 9639f75320..705671e784 100644 --- a/examples/toybox/ping_pong_gun/createPingPongGun.js +++ b/examples/toybox/ping_pong_gun/createPingPongGun.js @@ -9,7 +9,7 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // /*global MyAvatar, Entities, AnimationCache, SoundCache, Scene, Camera, Overlays, HMD, AvatarList, AvatarManager, Controller, UndoStack, Window, Account, GlobalServices, Script, ScriptDiscoveryService, LODManager, Menu, Vec3, Quat, AudioDevice, Paths, Clipboard, Settings, XMLHttpRequest, randFloat, randInt */ -Script.include("../../utilities.js"); +Script.include("../../libraries/utils.js"); var scriptURL = Script.resolvePath('pingPongGun.js'); From 08c27599472978cce6310e9ea4275efc94f1d203 Mon Sep 17 00:00:00 2001 From: Ryan Huffman Date: Tue, 10 Nov 2015 11:39:50 -0800 Subject: [PATCH 28/30] Remove unused include in createTargets.js --- examples/toybox/ping_pong_gun/createTargets.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/toybox/ping_pong_gun/createTargets.js b/examples/toybox/ping_pong_gun/createTargets.js index fb286b1928..fde0d6f54a 100644 --- a/examples/toybox/ping_pong_gun/createTargets.js +++ b/examples/toybox/ping_pong_gun/createTargets.js @@ -10,7 +10,7 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // /*global MyAvatar, Entities, AnimationCache, SoundCache, Scene, Camera, Overlays, HMD, AvatarList, AvatarManager, Controller, UndoStack, Window, Account, GlobalServices, Script, ScriptDiscoveryService, LODManager, Menu, Vec3, Quat, AudioDevice, Paths, Clipboard, Settings, XMLHttpRequest, randFloat, randInt */ -Script.include("../../utilities.js"); + Script.include("../../libraries/utils.js"); var scriptURL = Script.resolvePath('wallTarget.js'); From bf0677a0cea84edcba4887ded70e4f3e1500b7d1 Mon Sep 17 00:00:00 2001 From: ericrius1 Date: Tue, 10 Nov 2015 13:42:15 -0800 Subject: [PATCH 29/30] Moved helicopter scripts into drylake folder --- examples/{helicopter => drylake}/explodeHelicopter.js | 0 examples/{helicopter => drylake}/helicopter.js | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename examples/{helicopter => drylake}/explodeHelicopter.js (100%) rename examples/{helicopter => drylake}/helicopter.js (100%) diff --git a/examples/helicopter/explodeHelicopter.js b/examples/drylake/explodeHelicopter.js similarity index 100% rename from examples/helicopter/explodeHelicopter.js rename to examples/drylake/explodeHelicopter.js diff --git a/examples/helicopter/helicopter.js b/examples/drylake/helicopter.js similarity index 100% rename from examples/helicopter/helicopter.js rename to examples/drylake/helicopter.js From a76385808041f4e6a3dc2b9576c242176bed9668 Mon Sep 17 00:00:00 2001 From: "Anthony J. Thibault" Date: Wed, 11 Nov 2015 11:22:05 -0800 Subject: [PATCH 30/30] Revert cache-extract This reverts these commits: * 82b26b7 Code convention fixes * 9a484ff Fixes for windows * 086b064 Dumps all urls extracted to stdout. * c002888 Added cache extractor to the tools directory --- tools/CMakeLists.txt | 3 - tools/cache-extract/CMakeLists.txt | 7 -- tools/cache-extract/src/CacheExtractApp.cpp | 130 -------------------- tools/cache-extract/src/CacheExtractApp.h | 47 ------- tools/cache-extract/src/main.cpp | 17 --- 5 files changed, 204 deletions(-) delete mode 100644 tools/cache-extract/CMakeLists.txt delete mode 100644 tools/cache-extract/src/CacheExtractApp.cpp delete mode 100644 tools/cache-extract/src/CacheExtractApp.h delete mode 100644 tools/cache-extract/src/main.cpp diff --git a/tools/CMakeLists.txt b/tools/CMakeLists.txt index 9bc7031720..2056044a4b 100644 --- a/tools/CMakeLists.txt +++ b/tools/CMakeLists.txt @@ -10,6 +10,3 @@ set_target_properties(udt-test PROPERTIES FOLDER "Tools") add_subdirectory(vhacd-util) set_target_properties(vhacd-util PROPERTIES FOLDER "Tools") - -add_subdirectory(cache-extract) -set_target_properties(cache-extract PROPERTIES FOLDER "Tools") diff --git a/tools/cache-extract/CMakeLists.txt b/tools/cache-extract/CMakeLists.txt deleted file mode 100644 index 1aaa4d9d04..0000000000 --- a/tools/cache-extract/CMakeLists.txt +++ /dev/null @@ -1,7 +0,0 @@ -set(TARGET_NAME cache-extract) - -setup_hifi_project() - -link_hifi_libraries() -copy_dlls_beside_windows_executable() - diff --git a/tools/cache-extract/src/CacheExtractApp.cpp b/tools/cache-extract/src/CacheExtractApp.cpp deleted file mode 100644 index 0cfaef3f83..0000000000 --- a/tools/cache-extract/src/CacheExtractApp.cpp +++ /dev/null @@ -1,130 +0,0 @@ -// -// CacheExtractApp.cpp -// tools/cache-extract/src -// -// Created by Anthony Thibault on 11/6/2015. -// 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 -// - -#include "CacheExtractApp.h" -#include -#include -#include -#include -#include - -// extracted from qnetworkdiskcache.cpp -#define CACHE_VERSION 8 -enum { - CacheMagic = 0xe8, - CurrentCacheVersion = CACHE_VERSION -}; - -CacheExtractApp::CacheExtractApp(int& argc, char** argv) : - QCoreApplication(argc, argv) -{ - QString myDataLoc = QStandardPaths::writableLocation(QStandardPaths::DataLocation); - int lastSlash = myDataLoc.lastIndexOf("/"); - QString cachePath = myDataLoc.leftRef(lastSlash).toString() + "/" + - "High Fidelity" + "/" + "Interface" + "/" + - "data" + QString::number(CACHE_VERSION) + "/"; - - QString outputPath = myDataLoc.leftRef(lastSlash).toString() + "/" + - "High Fidelity" + "/" + "Interface" + "/" + "extracted"; - - qDebug() << "Searching cachePath = " << cachePath << "..."; - - // build list of files - QList fileList; - QDir dir(cachePath); - dir.setFilter(QDir::AllDirs | QDir::NoDotAndDotDot); - QFileInfoList list = dir.entryInfoList(); - for (int i = 0; i < list.size(); ++i) { - QFileInfo fileInfo = list.at(i); - if (fileInfo.isDir()) { - QDir subDir(fileInfo.filePath()); - subDir.setFilter(QDir::Files); - QFileInfoList subList = subDir.entryInfoList(); - for (int j = 0; j < subList.size(); ++j) { - fileList << subList.at(j).filePath(); - } - } - } - - // dump each cache file into the outputPath - for (int i = 0; i < fileList.size(); ++i) { - QByteArray contents; - MyMetaData metaData; - if (extractFile(fileList.at(i), metaData, contents)) { - QString outFileName = outputPath + metaData.url.path(); - int lastSlash = outFileName.lastIndexOf("/"); - QString outDirName = outFileName.leftRef(lastSlash).toString(); - QDir dir; - dir.mkpath(outDirName); - QFile out(outFileName); - if (out.open(QIODevice::WriteOnly)) { - out.write(contents); - out.close(); - qDebug().noquote() << metaData.url.toDisplayString(); - } - else { - qCritical() << "Error opening outputFile = " << outFileName; - } - } else { - qCritical() << "Error extracting = " << fileList.at(i); - } - } - - QMetaObject::invokeMethod(this, "quit", Qt::QueuedConnection); -} - -bool CacheExtractApp::extractFile(const QString& filePath, MyMetaData& metaData, QByteArray& data) const { - QFile f(filePath); - if (!f.open(QIODevice::ReadOnly)) { - qDebug() << "error opening " << filePath; - return false; - } - QDataStream in(&f); - // from qnetworkdiskcache.cpp QCacheItem::read() - qint32 marker, version, streamVersion; - in >> marker; - if (marker != CacheMagic) { - return false; - } - in >> version; - if (version != CurrentCacheVersion) { - return false; - } - in >> streamVersion; - if (streamVersion > in.version()) - return false; - in.setVersion(streamVersion); - - bool compressed; - in >> metaData; - in >> compressed; - if (compressed) { - QByteArray compressedData; - in >> compressedData; - QBuffer buffer; - buffer.setData(qUncompress(compressedData)); - buffer.open(QBuffer::ReadOnly); - data = buffer.readAll(); - } else { - data = f.readAll(); - } - return true; -} - -QDataStream &operator>>(QDataStream& in, MyMetaData& metaData) { - in >> metaData.url; - in >> metaData.expirationDate; - in >> metaData.lastModified; - in >> metaData.saveToDisk; - in >> metaData.attributes; - in >> metaData.rawHeaders; - return in; -} diff --git a/tools/cache-extract/src/CacheExtractApp.h b/tools/cache-extract/src/CacheExtractApp.h deleted file mode 100644 index 3b34ff891d..0000000000 --- a/tools/cache-extract/src/CacheExtractApp.h +++ /dev/null @@ -1,47 +0,0 @@ -// -// CacheExtractApp.h -// tools/cache-extract/src -// -// Created by Anthony Thibault on 11/6/2015 -// 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 -// - -#ifndef hifi_CacheExtractApp_h -#define hifi_CacheExtractApp_h - -#include -#include -#include -#include -#include -#include - -// copy of QNetworkCacheMetaData -class MyMetaData { -public: - using RawHeader = QPair; - using RawHeaderList = QList; - using AttributesMap = QHash; - - QUrl url; - QDateTime expirationDate; - QDateTime lastModified; - bool saveToDisk; - AttributesMap attributes; - RawHeaderList rawHeaders; -}; - -QDataStream &operator>>(QDataStream& in, MyMetaData& metaData); - -class CacheExtractApp : public QCoreApplication { - Q_OBJECT -public: - CacheExtractApp(int& argc, char** argv); - - bool extractFile(const QString& filePath, MyMetaData& metaData, QByteArray& data) const; -}; - -#endif // hifi_CacheExtractApp_h diff --git a/tools/cache-extract/src/main.cpp b/tools/cache-extract/src/main.cpp deleted file mode 100644 index 71a364ed3e..0000000000 --- a/tools/cache-extract/src/main.cpp +++ /dev/null @@ -1,17 +0,0 @@ -// -// main.cpp -// tools/cache-extract/src -// -// Created by Anthony Thibault on 11/6/2015. -// 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 - -#include -#include "CacheExtractApp.h" - -int main (int argc, char** argv) { - CacheExtractApp app(argc, argv); - return app.exec(); -}