From 6808e25fdf330d2c11282a76af1e97822bd32009 Mon Sep 17 00:00:00 2001 From: Thijs Wenker Date: Wed, 13 Jan 2016 01:26:32 +0100 Subject: [PATCH 01/31] zone ranges to min and max variables, this way it is more oversee-able with the new negative positioning system --- assignment-client/src/audio/AudioMixer.cpp | 59 +++++++++---------- .../resources/describe-settings.json | 36 ++++++++--- 2 files changed, 56 insertions(+), 39 deletions(-) diff --git a/assignment-client/src/audio/AudioMixer.cpp b/assignment-client/src/audio/AudioMixer.cpp index 8fda0ead8e..345900f17a 100644 --- a/assignment-client/src/audio/AudioMixer.cpp +++ b/assignment-client/src/audio/AudioMixer.cpp @@ -999,41 +999,40 @@ void AudioMixer::parseSettingsObject(const QJsonObject &settingsObject) { if (audioEnvGroupObject[AUDIO_ZONES].isObject()) { const QJsonObject& zones = audioEnvGroupObject[AUDIO_ZONES].toObject(); - const QString X_RANGE = "x_range"; - const QString Y_RANGE = "y_range"; - const QString Z_RANGE = "z_range"; + const QString X_MIN = "x_min"; + const QString X_MAX = "x_max"; + const QString Y_MIN = "y_min"; + const QString Y_MAX = "y_max"; + const QString Z_MIN = "z_min"; + const QString Z_MAX = "z_max"; foreach (const QString& zone, zones.keys()) { QJsonObject zoneObject = zones[zone].toObject(); - if (zoneObject.contains(X_RANGE) && zoneObject.contains(Y_RANGE) && zoneObject.contains(Z_RANGE)) { - QStringList xRange = zoneObject.value(X_RANGE).toString().split("-", QString::SkipEmptyParts); - QStringList yRange = zoneObject.value(Y_RANGE).toString().split("-", QString::SkipEmptyParts); - QStringList zRange = zoneObject.value(Z_RANGE).toString().split("-", QString::SkipEmptyParts); + if (zoneObject.contains(X_MIN) && zoneObject.contains(X_MAX) && zoneObject.contains(Y_MIN) && + zoneObject.contains(Y_MAX) && zoneObject.contains(Z_MIN) && zoneObject.contains(Z_MAX)) { - if (xRange.size() == 2 && yRange.size() == 2 && zRange.size() == 2) { - float xMin, xMax, yMin, yMax, zMin, zMax; - bool ok, allOk = true; - xMin = xRange[0].toFloat(&ok); - allOk &= ok; - xMax = xRange[1].toFloat(&ok); - allOk &= ok; - yMin = yRange[0].toFloat(&ok); - allOk &= ok; - yMax = yRange[1].toFloat(&ok); - allOk &= ok; - zMin = zRange[0].toFloat(&ok); - allOk &= ok; - zMax = zRange[1].toFloat(&ok); - allOk &= ok; + float xMin, xMax, yMin, yMax, zMin, zMax; + bool ok, allOk = true; + xMin = zoneObject.value(X_MIN).toString().toFloat(&ok); + allOk &= ok; + xMax = zoneObject.value(X_MAX).toString().toFloat(&ok); + allOk &= ok; + yMin = zoneObject.value(Y_MIN).toString().toFloat(&ok); + allOk &= ok; + yMax = zoneObject.value(Y_MAX).toString().toFloat(&ok); + allOk &= ok; + zMin = zoneObject.value(Z_MIN).toString().toFloat(&ok); + allOk &= ok; + zMax = zoneObject.value(Z_MAX).toString().toFloat(&ok); + allOk &= ok; - if (allOk) { - glm::vec3 corner(xMin, yMin, zMin); - glm::vec3 dimensions(xMax - xMin, yMax - yMin, zMax - zMin); - AABox zoneAABox(corner, dimensions); - _audioZones.insert(zone, zoneAABox); - qDebug() << "Added zone:" << zone << "(corner:" << corner - << ", dimensions:" << dimensions << ")"; - } + if (allOk) { + glm::vec3 corner(xMin, yMin, zMin); + glm::vec3 dimensions(xMax - xMin, yMax - yMin, zMax - zMin); + AABox zoneAABox(corner, dimensions); + _audioZones.insert(zone, zoneAABox); + qDebug() << "Added zone:" << zone << "(corner:" << corner + << ", dimensions:" << dimensions << ")"; } } } diff --git a/domain-server/resources/describe-settings.json b/domain-server/resources/describe-settings.json index 2332f25dfa..459e1661eb 100644 --- a/domain-server/resources/describe-settings.json +++ b/domain-server/resources/describe-settings.json @@ -222,22 +222,40 @@ }, "columns": [ { - "name": "x_range", - "label": "X range", + "name": "x_min", + "label": "X start", "can_set": true, - "placeholder": "0-16384" + "placeholder": "-16384.0" }, { - "name": "y_range", - "label": "Y range", + "name": "x_max", + "label": "X end", "can_set": true, - "placeholder": "0-16384" + "placeholder": "16384.0" + }, + { + "name": "y_min", + "label": "Y start", + "can_set": true, + "placeholder": "-16384.0" }, { - "name": "z_range", - "label": "Z range", + "name": "y_max", + "label": "Y end", "can_set": true, - "placeholder": "0-16384" + "placeholder": "16384.0" + }, + { + "name": "z_min", + "label": "Z start", + "can_set": true, + "placeholder": "-16384.0" + }, + { + "name": "z_max", + "label": "Z end", + "can_set": true, + "placeholder": "16384.0" } ] }, From 8b07bd00f8bfb8af8960a6802c1d12b11dad211c Mon Sep 17 00:00:00 2001 From: ericrius1 Date: Wed, 24 Feb 2016 11:05:02 -0800 Subject: [PATCH 02/31] basic firework --- .../fireworksLaunchButtonEntityScript.js | 120 ++++++++++++++++++ .../fireworks/fireworksLaunchButtonSpawner.js | 48 +++++++ 2 files changed, 168 insertions(+) create mode 100644 examples/playa/fireworks/fireworksLaunchButtonEntityScript.js create mode 100644 examples/playa/fireworks/fireworksLaunchButtonSpawner.js diff --git a/examples/playa/fireworks/fireworksLaunchButtonEntityScript.js b/examples/playa/fireworks/fireworksLaunchButtonEntityScript.js new file mode 100644 index 0000000000..27c19f140f --- /dev/null +++ b/examples/playa/fireworks/fireworksLaunchButtonEntityScript.js @@ -0,0 +1,120 @@ + // + // fireworksLaunchEntityScript.js + // examples/playa/fireworks + // + // Created by Eric Levina on 2/24/16. + // Copyright 2015 High Fidelity, Inc. + // + // Run this script to spawn a big fireworks launch button that a user can press + // + // Distributed under the Apache License, Version 2.0. + // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html + + (function() { + var _this; + Fireworks = function() { + _this = this; + + }; + + Fireworks.prototype = { + + startNearTrigger: function() { + print("EBL NEAR TRIGGER") + _this.shootFirework(); + }, + + clickReleaseOnEntity: function() { + _this.shootFirework(); + }, + + shootFirework: function() { + var fireworkSettings = { + name: "fireworks emitter", + position: _this.position, + type: "ParticleEffect", + color: { + red: 205, + green: 84, + blue: 84 + }, + maxParticles: 1000, + lifetime: 20, + lifespan: 4, + emitRate: 1000, + emitSpeed: 1.5, + speedSpread: 1.0, + emitOrientation: { + x: -0.2, + y: 0, + z: 0, + w: 0.7 + }, + emitDimensions: { + x: 0, + y: 0, + z: 0 + }, + emitRadiusStart: 0.5, + polarStart: 1, + polarFinish: 1.2, + azimuthStart: -Math.PI, + azimuthFinish: Math.PI, + emitAcceleration: { + x: 0, + y: -0.7, + z: 0 + }, + accelerationSpread: { + x: 0, + y: 0, + z: 0 + }, + particleRadius: 0.04, + radiusSpread: 0, + radiusStart: 0.14, + radiusFinish: 0.14, + colorSpread: { + red: 0, + green: 0, + blue: 0 + }, + colorStart: { + red: 255, + green: 255, + blue: 255 + }, + colorFinish: { + red: 255, + green: 255, + blue: 255 + }, + alpha: 1, + alphaSpread: 0, + alphaStart: 0, + alphaFinish: 1, + textures: "https://hifi-public.s3.amazonaws.com/alan/Particles/spark_2.png", + }; + + _this.firework = Entities.addEntity(fireworkSettings); + }, + + preload: function(entityID) { + _this.entityID = entityID; + _this.position = Entities.getEntityProperties(_this.entityID, "position").position; + print("EBL RELOAD ENTITY SCRIPT!!!"); + + }, + + unload: function() { + if (_this.firework) { + Entities.deleteEntity(_this.firework); + } + } + + + }; + + // entity scripts always need to return a newly constructed object of our type + return new Fireworks(); + }); \ No newline at end of file diff --git a/examples/playa/fireworks/fireworksLaunchButtonSpawner.js b/examples/playa/fireworks/fireworksLaunchButtonSpawner.js new file mode 100644 index 0000000000..b21aad6d08 --- /dev/null +++ b/examples/playa/fireworks/fireworksLaunchButtonSpawner.js @@ -0,0 +1,48 @@ + // + // fireworksLaunchButtonSpawner.js + // examples/playa/fireworks + // + // Created by Eric Levina on 2/24/16. + // Copyright 2015 High Fidelity, Inc. + // + // Run this script to spawn a big fireworks launch button that a user can press + // + // Distributed under the Apache License, Version 2.0. + // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html + + var orientation = Camera.getOrientation(); + orientation = Quat.safeEulerAngles(orientation); + orientation.x = 0; + orientation = Quat.fromVec3Degrees(orientation); + var center = Vec3.sum(MyAvatar.position, Vec3.multiply(3, Quat.getFront(orientation))); + + // Math.random ensures no caching of script + var SCRIPT_URL = Script.resolvePath("fireworksLaunchButtonEntityScript.js?v1" + Math.random()) + + var myEntity = Entities.addEntity({ + type: "Box", + color: { + red: 200, + green: 10, + blue: 10 + }, + position: center, + dimensions: { + x: 0.1, + y: 0.1, + z: 0.1 + }, + script: SCRIPT_URL, + userData: JSON.stringify({ + grabbableKey: { + wantsTrigger: true + } + }) + }) + + + function cleanup() { + Entities.deleteEntity(myEntity); + } + + Script.scriptEnding.connect(cleanup); \ No newline at end of file From 5520094baca6c2d5bfc3a0bb0fc3ea1b93d944a1 Mon Sep 17 00:00:00 2001 From: ericrius1 Date: Wed, 24 Feb 2016 12:29:54 -0800 Subject: [PATCH 03/31] exploding fireworks --- .../particle_explorer/particleExplorer.js | 4 +- .../fireworksLaunchButtonEntityScript.js | 87 ++++++++++++++++--- 2 files changed, 76 insertions(+), 15 deletions(-) diff --git a/examples/particle_explorer/particleExplorer.js b/examples/particle_explorer/particleExplorer.js index a3cfd32676..307e361ff1 100644 --- a/examples/particle_explorer/particleExplorer.js +++ b/examples/particle_explorer/particleExplorer.js @@ -43,10 +43,10 @@ var keysToAllow = [ 'emitSpeed', 'speedSpread', 'emitOrientation', - 'emitDimensios', - 'emitRadiusStart', + 'emitDimensions', 'polarStart', 'polarFinish', + 'azimuthStart', 'azimuthFinish', 'emitAcceleration', 'accelerationSpread', diff --git a/examples/playa/fireworks/fireworksLaunchButtonEntityScript.js b/examples/playa/fireworks/fireworksLaunchButtonEntityScript.js index 27c19f140f..a40327d7f5 100644 --- a/examples/playa/fireworks/fireworksLaunchButtonEntityScript.js +++ b/examples/playa/fireworks/fireworksLaunchButtonEntityScript.js @@ -29,9 +29,72 @@ }, shootFirework: function() { + var position = Vec3.sum(_this.position, {x: 0, y: 0.5, z: 0}); + _this.missle = Entities.addEntity({ + type: "Sphere", + position: position, + color: {red: 200, green : 10, blue: 200}, + dimensions: {x: 0.2, y: 0.4, z: 0.2}, + damping: 0, + dynamic: true, + velocity: {x: 0.0, y: 0.1, z: 0}, + gravity: {x: 0, y: 0.7, z: 0} + }); + + var smokeSettings = { + type: "ParticleEffect", + position: position, + name: "Smoke Trail", + maxParticles: 1000, + emitRate: 20, + emitSpeed: 0, + speedSpread: 0, + dimensions: {x: 1000, y: 1000, z: 1000}, + polarStart: 0, + polarFinish: 0, + azimuthStart: -3.14, + azimuthFinish: 3.14, + emitAcceleration: { + x: 0, + y: -0.5, + z: 0 + }, + accelerationSpread: { + x: 0.2, + y: 0, + z: 0.2 + }, + radiusSpread: 0.04, + particleRadius: 0.07, + radiusStart: 0.07, + radiusFinish: 0.07, + alpha: 0.7, + alphaSpread: 0, + alphaStart: 0, + alphaFinish: 0, + additiveBlending: 0, + textures: "https://hifi-public.s3.amazonaws.com/alan/Particles/Particle-Sprite-Smoke-1.png", + emitterShouldTrail: true, + parentID: _this.missle + }; + + _this.smoke = Entities.addEntity(smokeSettings); + + + Script.setTimeout(function() { + var explodePosition = Entities.getEntityProperties(_this.missle, "position").position; + Entities.deleteEntity(_this.missle); + Entities.deleteEntity(_this.smoke); + _this.explodeFirework(explodePosition); + }, 2500) + + + }, + + explodeFirework: function(explodePosition) { var fireworkSettings = { name: "fireworks emitter", - position: _this.position, + position: explodePosition, type: "ParticleEffect", color: { red: 205, @@ -50,12 +113,6 @@ z: 0, w: 0.7 }, - emitDimensions: { - x: 0, - y: 0, - z: 0 - }, - emitRadiusStart: 0.5, polarStart: 1, polarFinish: 1.2, azimuthStart: -Math.PI, @@ -72,8 +129,8 @@ }, particleRadius: 0.04, radiusSpread: 0, - radiusStart: 0.14, - radiusFinish: 0.14, + radiusStart: 0.06, + radiusFinish: 0.05, colorSpread: { red: 0, green: 0, @@ -92,11 +149,16 @@ alpha: 1, alphaSpread: 0, alphaStart: 0, - alphaFinish: 1, + alphaFinish: 0, textures: "https://hifi-public.s3.amazonaws.com/alan/Particles/spark_2.png", }; _this.firework = Entities.addEntity(fireworkSettings); + + Script.setTimeout(function() { + Entities.editEntity(_this.firework, {isEmitting: false}); + }, 1000) + }, preload: function(entityID) { @@ -107,9 +169,8 @@ }, unload: function() { - if (_this.firework) { - Entities.deleteEntity(_this.firework); - } + Entities.deleteEntity(_this.smoke); + Entities.deleteEntity(_this.missle); } From e245ad93d6c165b47c6f792ac4a901e9a1fe6235 Mon Sep 17 00:00:00 2001 From: ericrius1 Date: Wed, 24 Feb 2016 15:58:09 -0800 Subject: [PATCH 04/31] smoke and fire --- .../fireworksLaunchButtonEntityScript.js | 75 +++++++++++-------- 1 file changed, 45 insertions(+), 30 deletions(-) diff --git a/examples/playa/fireworks/fireworksLaunchButtonEntityScript.js b/examples/playa/fireworks/fireworksLaunchButtonEntityScript.js index a40327d7f5..f96d39fc33 100644 --- a/examples/playa/fireworks/fireworksLaunchButtonEntityScript.js +++ b/examples/playa/fireworks/fireworksLaunchButtonEntityScript.js @@ -11,10 +11,13 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html (function() { + Script.include("../../libraries/utils.js"); var _this; Fireworks = function() { _this = this; - + _this.launchSound = SoundCache.getSound("https://s3-us-west-1.amazonaws.com/hifi-content/eric/Sounds/missle+launch.wav"); + _this.explosionSound = SoundCache.getSound("https://s3-us-west-1.amazonaws.com/hifi-content/eric/Sounds/fireworksExplosion.wav"); + _this.timeToExplosionRange = {min: 1000, max: 2000}; }; Fireworks.prototype = { @@ -29,24 +32,30 @@ }, shootFirework: function() { - var position = Vec3.sum(_this.position, {x: 0, y: 0.5, z: 0}); + var rocketPosition = Vec3.sum(_this.position, {x: 0, y: 0.1, z: 0}); + Audio.playSound(_this.launchSound, {position: rocketPosition}); + + var MODEL_URL = "file:///C:/Users/Eric/Desktop/Rocket-2.fbx" _this.missle = Entities.addEntity({ - type: "Sphere", - position: position, + type: "Model", + modelURL: MODEL_URL, + position: rocketPosition, color: {red: 200, green : 10, blue: 200}, dimensions: {x: 0.2, y: 0.4, z: 0.2}, damping: 0, dynamic: true, velocity: {x: 0.0, y: 0.1, z: 0}, - gravity: {x: 0, y: 0.7, z: 0} + acceleration: {x: 0, y: 1, z: 0} }); + var smokeTrailPosition = Vec3.sum(rocketPosition, {x: 0, y: -0.15, z: 0}); var smokeSettings = { type: "ParticleEffect", - position: position, + position: smokeTrailPosition, + lifespan: 2, name: "Smoke Trail", - maxParticles: 1000, - emitRate: 20, + maxParticles: 3000, + emitRate: 50, emitSpeed: 0, speedSpread: 0, dimensions: {x: 1000, y: 1000, z: 1000}, @@ -56,23 +65,22 @@ azimuthFinish: 3.14, emitAcceleration: { x: 0, - y: -0.5, + y: 0.1, z: 0 }, accelerationSpread: { - x: 0.2, + x: 0.1, y: 0, - z: 0.2 + z: 0.1 }, - radiusSpread: 0.04, - particleRadius: 0.07, - radiusStart: 0.07, - radiusFinish: 0.07, - alpha: 0.7, + radiusSpread: 0.001, + particleRadius: 0.06, + radiusStart: 0.06, + radiusFinish: 0.2, + alpha: 0.1, alphaSpread: 0, alphaStart: 0, alphaFinish: 0, - additiveBlending: 0, textures: "https://hifi-public.s3.amazonaws.com/alan/Particles/Particle-Sprite-Smoke-1.png", emitterShouldTrail: true, parentID: _this.missle @@ -80,18 +88,31 @@ _this.smoke = Entities.addEntity(smokeSettings); + smokeSettings.colorStart = {red: 75, green: 193, blue: 254}; + smokeSettings.color = {red: 202, green: 132, blue: 151}; + smokeSettings.colorFinish = {red: 250, green: 132, blue: 21}; + smokeSettings.lifespan = 0.7; + smokeSettings.emitAcceleration.y= -1;; + smokeSettings.alphaStart = 0.7; + smokeSettings.alphaFinish = 0.2; + smokeSettings.radiusFinish = 0.06; + smokeSettings.particleRadius = 0.06; + smokeSettings.emitRate = 200; + smokeSettings.emitterShouldTrail = false; + _this.fire = Entities.addEntity(smokeSettings); - Script.setTimeout(function() { - var explodePosition = Entities.getEntityProperties(_this.missle, "position").position; - Entities.deleteEntity(_this.missle); - Entities.deleteEntity(_this.smoke); - _this.explodeFirework(explodePosition); - }, 2500) + // Script.setTimeout(function() { + // var explodePosition = Entities.getEntityProperties(_this.missle, "position").position; + // Entities.deleteEntity(_this.missle); + // Entities.deleteEntity(_this.smoke); + // _this.explodeFirework(explodePosition); + // }, randFloat(_this.timeToExplosionRange.min, _this.timeToExplosionRange.max)); }, explodeFirework: function(explodePosition) { + Audio.playSound(_this.explosionSound, {position: explodePosition}); var fireworkSettings = { name: "fireworks emitter", position: explodePosition, @@ -150,7 +171,7 @@ alphaSpread: 0, alphaStart: 0, alphaFinish: 0, - textures: "https://hifi-public.s3.amazonaws.com/alan/Particles/spark_2.png", + textures: "http://ericrius1.github.io/PlatosCave/assets/star.png", }; _this.firework = Entities.addEntity(fireworkSettings); @@ -166,14 +187,8 @@ _this.position = Entities.getEntityProperties(_this.entityID, "position").position; print("EBL RELOAD ENTITY SCRIPT!!!"); - }, - - unload: function() { - Entities.deleteEntity(_this.smoke); - Entities.deleteEntity(_this.missle); } - }; // entity scripts always need to return a newly constructed object of our type From dea41edf9c9966099f270dc1f0b543e1b7fd2502 Mon Sep 17 00:00:00 2001 From: ericrius1 Date: Wed, 24 Feb 2016 16:01:38 -0800 Subject: [PATCH 05/31] tweaks --- .../fireworksLaunchButtonEntityScript.js | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/examples/playa/fireworks/fireworksLaunchButtonEntityScript.js b/examples/playa/fireworks/fireworksLaunchButtonEntityScript.js index f96d39fc33..7a2c77ff6b 100644 --- a/examples/playa/fireworks/fireworksLaunchButtonEntityScript.js +++ b/examples/playa/fireworks/fireworksLaunchButtonEntityScript.js @@ -53,6 +53,7 @@ type: "ParticleEffect", position: smokeTrailPosition, lifespan: 2, + lifetime: 20, name: "Smoke Trail", maxParticles: 3000, emitRate: 50, @@ -94,24 +95,26 @@ smokeSettings.lifespan = 0.7; smokeSettings.emitAcceleration.y= -1;; smokeSettings.alphaStart = 0.7; - smokeSettings.alphaFinish = 0.2; + smokeSettings.alphaFinish = 0.1; smokeSettings.radiusFinish = 0.06; smokeSettings.particleRadius = 0.06; smokeSettings.emitRate = 200; smokeSettings.emitterShouldTrail = false; _this.fire = Entities.addEntity(smokeSettings); - // Script.setTimeout(function() { - // var explodePosition = Entities.getEntityProperties(_this.missle, "position").position; - // Entities.deleteEntity(_this.missle); - // Entities.deleteEntity(_this.smoke); - // _this.explodeFirework(explodePosition); - // }, randFloat(_this.timeToExplosionRange.min, _this.timeToExplosionRange.max)); + Script.setTimeout(function() { + var explodePosition = Entities.getEntityProperties(_this.missle, "position").position; + _this.explodeFirework(explodePosition); + }, randFloat(_this.timeToExplosionRange.min, _this.timeToExplosionRange.max)); }, explodeFirework: function(explodePosition) { + // We just exploded firework, so stop emitting its fire and smoke + Entities.editEntity(_this.smoke, {parentID: null, isEmitting: false}); + Entities.editEntity(_this.fire, {parentID: null, isEmitting: false}); + Entities.deleteEntity(_this.missle); Audio.playSound(_this.explosionSound, {position: explodePosition}); var fireworkSettings = { name: "fireworks emitter", From 04993349382b1ce7fdfb892e1c1f43818448053b Mon Sep 17 00:00:00 2001 From: ericrius1 Date: Wed, 24 Feb 2016 16:14:46 -0800 Subject: [PATCH 06/31] toadd: different colors for fireworks --- .../fireworksLaunchButtonEntityScript.js | 198 +++++++++++------- .../fireworks/fireworksLaunchButtonSpawner.js | 20 +- 2 files changed, 133 insertions(+), 85 deletions(-) diff --git a/examples/playa/fireworks/fireworksLaunchButtonEntityScript.js b/examples/playa/fireworks/fireworksLaunchButtonEntityScript.js index 7a2c77ff6b..cfb81674cb 100644 --- a/examples/playa/fireworks/fireworksLaunchButtonEntityScript.js +++ b/examples/playa/fireworks/fireworksLaunchButtonEntityScript.js @@ -17,7 +17,10 @@ _this = this; _this.launchSound = SoundCache.getSound("https://s3-us-west-1.amazonaws.com/hifi-content/eric/Sounds/missle+launch.wav"); _this.explosionSound = SoundCache.getSound("https://s3-us-west-1.amazonaws.com/hifi-content/eric/Sounds/fireworksExplosion.wav"); - _this.timeToExplosionRange = {min: 1000, max: 2000}; + _this.timeToExplosionRange = { + min: 2000, + max: 3000 + }; }; Fireworks.prototype = { @@ -32,90 +35,137 @@ }, shootFirework: function() { - var rocketPosition = Vec3.sum(_this.position, {x: 0, y: 0.1, z: 0}); - Audio.playSound(_this.launchSound, {position: rocketPosition}); - - var MODEL_URL = "file:///C:/Users/Eric/Desktop/Rocket-2.fbx" - _this.missle = Entities.addEntity({ - type: "Model", - modelURL: MODEL_URL, - position: rocketPosition, - color: {red: 200, green : 10, blue: 200}, - dimensions: {x: 0.2, y: 0.4, z: 0.2}, - damping: 0, - dynamic: true, - velocity: {x: 0.0, y: 0.1, z: 0}, - acceleration: {x: 0, y: 1, z: 0} + var rocketPosition = Vec3.sum(_this.position, { + x: 0, + y: 0.1, + z: 0 + }); + Audio.playSound(_this.launchSound, { + position: rocketPosition }); - var smokeTrailPosition = Vec3.sum(rocketPosition, {x: 0, y: -0.15, z: 0}); - var smokeSettings = { - type: "ParticleEffect", - position: smokeTrailPosition, - lifespan: 2, - lifetime: 20, - name: "Smoke Trail", - maxParticles: 3000, - emitRate: 50, - emitSpeed: 0, - speedSpread: 0, - dimensions: {x: 1000, y: 1000, z: 1000}, - polarStart: 0, - polarFinish: 0, - azimuthStart: -3.14, - azimuthFinish: 3.14, - emitAcceleration: { - x: 0, - y: 0.1, - z: 0 - }, - accelerationSpread: { - x: 0.1, - y: 0, - z: 0.1 - }, - radiusSpread: 0.001, - particleRadius: 0.06, - radiusStart: 0.06, - radiusFinish: 0.2, - alpha: 0.1, - alphaSpread: 0, - alphaStart: 0, - alphaFinish: 0, - textures: "https://hifi-public.s3.amazonaws.com/alan/Particles/Particle-Sprite-Smoke-1.png", - emitterShouldTrail: true, - parentID: _this.missle + var MODEL_URL = "https://s3-us-west-1.amazonaws.com/hifi-content/eric/models/Rocket-2.fbx"; + var missleDimensions = { + x: 0.24, + y: 0.7, + z: 0.24 }; + _this.missle = Entities.addEntity({ + type: "Model", + modelURL: MODEL_URL, + position: rocketPosition, + dimensions: missleDimensions, + damping: 0, + dynamic: true, + velocity: { + x: 0.0, + y: 0.1, + z: 0 + }, + acceleration: { + x: 0, + y: 1, + z: 0 + } + }); - _this.smoke = Entities.addEntity(smokeSettings); + var smokeTrailPosition = Vec3.sum(rocketPosition, { + x: 0, + y: -missleDimensions.y/2 + 0.08, + z: 0 + }); + var smokeSettings = { + type: "ParticleEffect", + position: smokeTrailPosition, + lifespan: 1.6, + lifetime: 20, + name: "Smoke Trail", + maxParticles: 3000, + emitRate: 50, + emitSpeed: 0, + speedSpread: 0, + dimensions: { + x: 1000, + y: 1000, + z: 1000 + }, + polarStart: 0, + polarFinish: 0, + azimuthStart: -3.14, + azimuthFinish: 3.14, + emitAcceleration: { + x: 0, + y: 0.1, + z: 0 + }, + accelerationSpread: { + x: 0.1, + y: 0, + z: 0.1 + }, + radiusSpread: 0.001, + particleRadius: 0.06, + radiusStart: 0.06, + radiusFinish: 0.2, + alpha: 0.1, + alphaSpread: 0, + alphaStart: 0, + alphaFinish: 0, + textures: "https://hifi-public.s3.amazonaws.com/alan/Particles/Particle-Sprite-Smoke-1.png", + emitterShouldTrail: true, + parentID: _this.missle + }; - smokeSettings.colorStart = {red: 75, green: 193, blue: 254}; - smokeSettings.color = {red: 202, green: 132, blue: 151}; - smokeSettings.colorFinish = {red: 250, green: 132, blue: 21}; - smokeSettings.lifespan = 0.7; - smokeSettings.emitAcceleration.y= -1;; - smokeSettings.alphaStart = 0.7; - smokeSettings.alphaFinish = 0.1; - smokeSettings.radiusFinish = 0.06; - smokeSettings.particleRadius = 0.06; - smokeSettings.emitRate = 200; - smokeSettings.emitterShouldTrail = false; - _this.fire = Entities.addEntity(smokeSettings); + _this.smoke = Entities.addEntity(smokeSettings); - Script.setTimeout(function() { - var explodePosition = Entities.getEntityProperties(_this.missle, "position").position; - _this.explodeFirework(explodePosition); - }, randFloat(_this.timeToExplosionRange.min, _this.timeToExplosionRange.max)); + smokeSettings.colorStart = { + red: 75, + green: 193, + blue: 254 + }; + smokeSettings.color = { + red: 202, + green: 132, + blue: 151 + }; + smokeSettings.colorFinish = { + red: 250, + green: 132, + blue: 21 + }; + smokeSettings.lifespan = 0.7; + smokeSettings.emitAcceleration.y = -1;; + smokeSettings.alphaStart = 0.7; + smokeSettings.alphaFinish = 0.1; + smokeSettings.radiusFinish = 0.06; + smokeSettings.particleRadius = 0.06; + smokeSettings.emitRate = 200; + smokeSettings.emitterShouldTrail = false; + smokeSettings.name = "fire emitter"; + _this.fire = Entities.addEntity(smokeSettings); + + Script.setTimeout(function() { + var explodePosition = Entities.getEntityProperties(_this.missle, "position").position; + _this.explodeFirework(explodePosition); + }, randFloat(_this.timeToExplosionRange.min, _this.timeToExplosionRange.max)); }, explodeFirework: function(explodePosition) { // We just exploded firework, so stop emitting its fire and smoke - Entities.editEntity(_this.smoke, {parentID: null, isEmitting: false}); - Entities.editEntity(_this.fire, {parentID: null, isEmitting: false}); + Entities.editEntity(_this.smoke, { + parentID: null, + isEmitting: false + }); + Entities.editEntity(_this.fire, { + parentID: null, + isEmitting: false + }); Entities.deleteEntity(_this.missle); - Audio.playSound(_this.explosionSound, {position: explodePosition}); + Audio.playSound(_this.explosionSound, { + position: explodePosition + }); var fireworkSettings = { name: "fireworks emitter", position: explodePosition, @@ -180,7 +230,9 @@ _this.firework = Entities.addEntity(fireworkSettings); Script.setTimeout(function() { - Entities.editEntity(_this.firework, {isEmitting: false}); + Entities.editEntity(_this.firework, { + isEmitting: false + }); }, 1000) }, diff --git a/examples/playa/fireworks/fireworksLaunchButtonSpawner.js b/examples/playa/fireworks/fireworksLaunchButtonSpawner.js index b21aad6d08..831afc18f1 100644 --- a/examples/playa/fireworks/fireworksLaunchButtonSpawner.js +++ b/examples/playa/fireworks/fireworksLaunchButtonSpawner.js @@ -18,19 +18,15 @@ // Math.random ensures no caching of script var SCRIPT_URL = Script.resolvePath("fireworksLaunchButtonEntityScript.js?v1" + Math.random()) - - var myEntity = Entities.addEntity({ - type: "Box", - color: { - red: 200, - green: 10, - blue: 10 - }, + var MODEL_URL = "https://s3-us-west-1.amazonaws.com/hifi-content/eric/models/Launch-Button.fbx"; + var launchButton = Entities.addEntity({ + type: "Model", + modelURL: MODEL_URL, position: center, dimensions: { - x: 0.1, - y: 0.1, - z: 0.1 + x: 0.98, + y: 1.16, + z: 0.98 }, script: SCRIPT_URL, userData: JSON.stringify({ @@ -42,7 +38,7 @@ function cleanup() { - Entities.deleteEntity(myEntity); + Entities.deleteEntity(launchButton); } Script.scriptEnding.connect(cleanup); \ No newline at end of file From ca5de8d6a965aeb59df122239160868fcbe97303 Mon Sep 17 00:00:00 2001 From: Brad Hefta-Gaub Date: Wed, 24 Feb 2016 16:17:11 -0800 Subject: [PATCH 07/31] remove some unimplemented menu items --- interface/src/Menu.cpp | 23 ++++------------------- 1 file changed, 4 insertions(+), 19 deletions(-) diff --git a/interface/src/Menu.cpp b/interface/src/Menu.cpp index 9c7788851c..ea7f4bf7b8 100644 --- a/interface/src/Menu.cpp +++ b/interface/src/Menu.cpp @@ -70,17 +70,9 @@ Menu::Menu() { dialogsManager.data(), &DialogsManager::toggleLoginDialog); } - // File > Update -- FIXME: needs implementation - auto action = addActionToQMenuAndActionHash(fileMenu, "Update"); - action->setDisabled(true); - // File > Help addActionToQMenuAndActionHash(fileMenu, MenuOption::Help, 0, qApp, SLOT(showHelp())); - // File > Crash Reporter...-- FIXME: needs implementation - auto crashReporterAction = addActionToQMenuAndActionHash(fileMenu, "Crash Reporter..."); - crashReporterAction->setDisabled(true); - // File > About addActionToQMenuAndActionHash(fileMenu, MenuOption::AboutApp, 0, qApp, SLOT(aboutApp()), QAction::AboutRole); @@ -259,16 +251,10 @@ Menu::Menu() { // Navigate menu ---------------------------------- MenuWrapper* navigateMenu = addMenu("Navigate"); - // Navigate > Home -- FIXME: needs implementation - auto homeAction = addActionToQMenuAndActionHash(navigateMenu, "Home"); - homeAction->setDisabled(true); - + // Navigate > Show Address Bar addActionToQMenuAndActionHash(navigateMenu, MenuOption::AddressBar, Qt::CTRL | Qt::Key_L, dialogsManager.data(), SLOT(toggleAddressBar())); - // Navigate > Directory -- FIXME: needs implementation - addActionToQMenuAndActionHash(navigateMenu, "Directory"); - // Navigate > Bookmark related menus -- Note: the Bookmark class adds its own submenus here. qApp->getBookmarks()->setupMenus(this, navigateMenu); @@ -299,20 +285,19 @@ Menu::Menu() { DependencyManager::get()->toggle(QString("hifi/dialogs/GeneralPreferencesDialog.qml"), "GeneralPreferencesDialog"); }); - - // Settings > Avatar...-- FIXME: needs implementation + // Settings > Avatar... action = addActionToQMenuAndActionHash(settingsMenu, "Avatar..."); connect(action, &QAction::triggered, [] { DependencyManager::get()->toggle(QString("hifi/dialogs/AvatarPreferencesDialog.qml"), "AvatarPreferencesDialog"); }); - // Settings > Audio...-- FIXME: needs implementation + // Settings > Audio... action = addActionToQMenuAndActionHash(settingsMenu, "Audio..."); connect(action, &QAction::triggered, [] { DependencyManager::get()->toggle(QString("hifi/dialogs/AudioPreferencesDialog.qml"), "AudioPreferencesDialog"); }); - // Settings > LOD...-- FIXME: needs implementation + // Settings > LOD... action = addActionToQMenuAndActionHash(settingsMenu, "LOD..."); connect(action, &QAction::triggered, [] { DependencyManager::get()->toggle(QString("hifi/dialogs/LodPreferencesDialog.qml"), "LodPreferencesDialog"); From ecb03562d3e4805f47edd93f77e02b4a77bb6a81 Mon Sep 17 00:00:00 2001 From: Brad Hefta-Gaub Date: Wed, 24 Feb 2016 16:24:48 -0800 Subject: [PATCH 08/31] fix build buster --- interface/src/Menu.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/interface/src/Menu.cpp b/interface/src/Menu.cpp index ea7f4bf7b8..407e0fe64f 100644 --- a/interface/src/Menu.cpp +++ b/interface/src/Menu.cpp @@ -159,7 +159,7 @@ Menu::Menu() { QObject* avatar = avatarManager->getMyAvatar(); // Avatar > Attachments... - action = addActionToQMenuAndActionHash(avatarMenu, MenuOption::Attachments); + auto action = addActionToQMenuAndActionHash(avatarMenu, MenuOption::Attachments); connect(action, &QAction::triggered, [] { DependencyManager::get()->show(QString("hifi/dialogs/AttachmentsDialog.qml"), "AttachmentsDialog"); }); From 0a6a35ddd807ad7aae19cffa33ae9e04347348d2 Mon Sep 17 00:00:00 2001 From: ericrius1 Date: Wed, 24 Feb 2016 16:30:29 -0800 Subject: [PATCH 09/31] need multiple explosions at once --- examples/libraries/utils.js | 2 +- .../fireworksLaunchButtonEntityScript.js | 44 +++++-------------- 2 files changed, 12 insertions(+), 34 deletions(-) diff --git a/examples/libraries/utils.js b/examples/libraries/utils.js index b2b2902cb0..f4a431a657 100644 --- a/examples/libraries/utils.js +++ b/examples/libraries/utils.js @@ -199,7 +199,7 @@ pointInExtents = function(point, minPoint, maxPoint) { * @param Number l The lightness * @return Array The RGB representation */ -hslToRgb = function(hsl, hueOffset) { +hslToRgb = function(hsl) { var r, g, b; if (hsl.s == 0) { r = g = b = hsl.l; // achromatic diff --git a/examples/playa/fireworks/fireworksLaunchButtonEntityScript.js b/examples/playa/fireworks/fireworksLaunchButtonEntityScript.js index cfb81674cb..2abf96a86d 100644 --- a/examples/playa/fireworks/fireworksLaunchButtonEntityScript.js +++ b/examples/playa/fireworks/fireworksLaunchButtonEntityScript.js @@ -21,12 +21,12 @@ min: 2000, max: 3000 }; + _this.explodeTime = 500; }; Fireworks.prototype = { startNearTrigger: function() { - print("EBL NEAR TRIGGER") _this.shootFirework(); }, @@ -170,25 +170,18 @@ name: "fireworks emitter", position: explodePosition, type: "ParticleEffect", - color: { - red: 205, - green: 84, - blue: 84 - }, - maxParticles: 1000, + colorStart: hslToRgb({h: Math.random(), s: 0.5, l: 0.7}), + color: hslToRgb({h: Math.random(), s: 0.5, l: 0.5}), + colorFinish: hslToRgb({h: Math.random(), s: 0.5, l: 0.7}), + maxParticles: 10000, lifetime: 20, - lifespan: 4, - emitRate: 1000, - emitSpeed: 1.5, + lifespan: randFloat(1.5, 3), + emitRate: randInt(500, 3000), + emitSpeed: randFloat(0.5, 2), speedSpread: 1.0, - emitOrientation: { - x: -0.2, - y: 0, - z: 0, - w: 0.7 - }, + emitOrientation: Quat.fromPitchYawRollDegrees(randInt(0, 360), randInt(0, 360), randInt(0, 360)), polarStart: 1, - polarFinish: 1.2, + polarFinish: randFloat(1.2, 3), azimuthStart: -Math.PI, azimuthFinish: Math.PI, emitAcceleration: { @@ -205,21 +198,6 @@ radiusSpread: 0, radiusStart: 0.06, radiusFinish: 0.05, - colorSpread: { - red: 0, - green: 0, - blue: 0 - }, - colorStart: { - red: 255, - green: 255, - blue: 255 - }, - colorFinish: { - red: 255, - green: 255, - blue: 255 - }, alpha: 1, alphaSpread: 0, alphaStart: 0, @@ -233,7 +211,7 @@ Entities.editEntity(_this.firework, { isEmitting: false }); - }, 1000) + }, _this.explodeTime); }, From 769a5ecca9ef07465e5f55a50fb1731f16abf05e Mon Sep 17 00:00:00 2001 From: ericrius1 Date: Wed, 24 Feb 2016 16:33:28 -0800 Subject: [PATCH 10/31] tweaks --- .../fireworksLaunchButtonEntityScript.js | 26 +++++++++---------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/examples/playa/fireworks/fireworksLaunchButtonEntityScript.js b/examples/playa/fireworks/fireworksLaunchButtonEntityScript.js index 2abf96a86d..55df20cfda 100644 --- a/examples/playa/fireworks/fireworksLaunchButtonEntityScript.js +++ b/examples/playa/fireworks/fireworksLaunchButtonEntityScript.js @@ -176,9 +176,9 @@ maxParticles: 10000, lifetime: 20, lifespan: randFloat(1.5, 3), - emitRate: randInt(500, 3000), + emitRate: randInt(500, 10000), emitSpeed: randFloat(0.5, 2), - speedSpread: 1.0, + speedSpread: 0.2, emitOrientation: Quat.fromPitchYawRollDegrees(randInt(0, 360), randInt(0, 360), randInt(0, 360)), polarStart: 1, polarFinish: randFloat(1.2, 3), @@ -186,22 +186,22 @@ azimuthFinish: Math.PI, emitAcceleration: { x: 0, - y: -0.7, + y: randFloat(-1, -0.2), z: 0 }, accelerationSpread: { - x: 0, + x: Math.random(), y: 0, - z: 0 + z: Math.random() }, - particleRadius: 0.04, - radiusSpread: 0, - radiusStart: 0.06, - radiusFinish: 0.05, - alpha: 1, - alphaSpread: 0, - alphaStart: 0, - alphaFinish: 0, + particleRadius: randFloat(0.001, 0.1), + radiusSpread: Math.random() * 0.1, + radiusStart: randFloat(0.001, 0.1), + radiusFinish: randFloat(0.001, 0.1), + alpha: Math.random(), + alphaSpread: Math.random(), + alphaStart: Math.random(), + alphaFinish: Math.random(), textures: "http://ericrius1.github.io/PlatosCave/assets/star.png", }; From 208096f2e01d5c1c52cbc3f0f133f140b929587e Mon Sep 17 00:00:00 2001 From: ericrius1 Date: Wed, 24 Feb 2016 16:36:54 -0800 Subject: [PATCH 11/31] fireworks but no smoke --- .../fireworksLaunchButtonEntityScript.js | 27 +++++++++---------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/examples/playa/fireworks/fireworksLaunchButtonEntityScript.js b/examples/playa/fireworks/fireworksLaunchButtonEntityScript.js index 55df20cfda..286dbf0375 100644 --- a/examples/playa/fireworks/fireworksLaunchButtonEntityScript.js +++ b/examples/playa/fireworks/fireworksLaunchButtonEntityScript.js @@ -50,7 +50,7 @@ y: 0.7, z: 0.24 }; - _this.missle = Entities.addEntity({ + var missle = Entities.addEntity({ type: "Model", modelURL: MODEL_URL, position: rocketPosition, @@ -71,7 +71,7 @@ var smokeTrailPosition = Vec3.sum(rocketPosition, { x: 0, - y: -missleDimensions.y/2 + 0.08, + y: -missleDimensions.y/2 + 0.1, z: 0 }); var smokeSettings = { @@ -116,7 +116,7 @@ parentID: _this.missle }; - _this.smoke = Entities.addEntity(smokeSettings); + var smoke = Entities.addEntity(smokeSettings); smokeSettings.colorStart = { red: 75, @@ -142,31 +142,31 @@ smokeSettings.emitRate = 200; smokeSettings.emitterShouldTrail = false; smokeSettings.name = "fire emitter"; - _this.fire = Entities.addEntity(smokeSettings); + var fire = Entities.addEntity(smokeSettings); Script.setTimeout(function() { - var explodePosition = Entities.getEntityProperties(_this.missle, "position").position; - _this.explodeFirework(explodePosition); + var explodePosition = Entities.getEntityProperties(missle, "position").position; + _this.explodeFirework(smoke, fire, missle, explodePosition); }, randFloat(_this.timeToExplosionRange.min, _this.timeToExplosionRange.max)); }, - explodeFirework: function(explodePosition) { + explodeFirework: function(smoke, fire, missle, explodePosition) { // We just exploded firework, so stop emitting its fire and smoke - Entities.editEntity(_this.smoke, { + Entities.editEntity(smoke, { parentID: null, isEmitting: false }); - Entities.editEntity(_this.fire, { + Entities.editEntity(fire, { parentID: null, isEmitting: false }); - Entities.deleteEntity(_this.missle); + Entities.deleteEntity(missle); Audio.playSound(_this.explosionSound, { position: explodePosition }); - var fireworkSettings = { + var firework = Entities.addEntity({ name: "fireworks emitter", position: explodePosition, type: "ParticleEffect", @@ -203,12 +203,11 @@ alphaStart: Math.random(), alphaFinish: Math.random(), textures: "http://ericrius1.github.io/PlatosCave/assets/star.png", - }; + }); - _this.firework = Entities.addEntity(fireworkSettings); Script.setTimeout(function() { - Entities.editEntity(_this.firework, { + Entities.editEntity(firework, { isEmitting: false }); }, _this.explodeTime); From fdb5d33866266426a0125e3d580fbf75b85c9730 Mon Sep 17 00:00:00 2001 From: ericrius1 Date: Wed, 24 Feb 2016 16:42:24 -0800 Subject: [PATCH 12/31] MORE RANDOM YAHH --- .../fireworksLaunchButtonEntityScript.js | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/examples/playa/fireworks/fireworksLaunchButtonEntityScript.js b/examples/playa/fireworks/fireworksLaunchButtonEntityScript.js index 286dbf0375..deb67e5e83 100644 --- a/examples/playa/fireworks/fireworksLaunchButtonEntityScript.js +++ b/examples/playa/fireworks/fireworksLaunchButtonEntityScript.js @@ -19,9 +19,9 @@ _this.explosionSound = SoundCache.getSound("https://s3-us-west-1.amazonaws.com/hifi-content/eric/Sounds/fireworksExplosion.wav"); _this.timeToExplosionRange = { min: 2000, - max: 3000 + max: 4000 }; - _this.explodeTime = 500; + _this.explodeTime = randInt(500, 1000); }; Fireworks.prototype = { @@ -59,14 +59,16 @@ dynamic: true, velocity: { x: 0.0, - y: 0.1, + y: randFloat(0.4, 1.0), z: 0 }, acceleration: { x: 0, - y: 1, + y: randFloat(1.0, 2.0), z: 0 - } + }, + angularVelocity: {x: 0, y: randInt(0, 10), z: 0}, + angularDamping: 0 }); var smokeTrailPosition = Vec3.sum(rocketPosition, { @@ -113,7 +115,7 @@ alphaFinish: 0, textures: "https://hifi-public.s3.amazonaws.com/alan/Particles/Particle-Sprite-Smoke-1.png", emitterShouldTrail: true, - parentID: _this.missle + parentID: missle }; var smoke = Entities.addEntity(smokeSettings); @@ -133,7 +135,7 @@ green: 132, blue: 21 }; - smokeSettings.lifespan = 0.7; + smokeSettings.lifespan = 1; smokeSettings.emitAcceleration.y = -1;; smokeSettings.alphaStart = 0.7; smokeSettings.alphaFinish = 0.1; From c26ad2b9d0d182b088ec84074024a54feaecf604 Mon Sep 17 00:00:00 2001 From: ericrius1 Date: Wed, 24 Feb 2016 16:52:02 -0800 Subject: [PATCH 13/31] relative smoke trail --- .../fireworksLaunchButtonEntityScript.js | 70 +++++++++++-------- 1 file changed, 41 insertions(+), 29 deletions(-) diff --git a/examples/playa/fireworks/fireworksLaunchButtonEntityScript.js b/examples/playa/fireworks/fireworksLaunchButtonEntityScript.js index deb67e5e83..646f63cc91 100644 --- a/examples/playa/fireworks/fireworksLaunchButtonEntityScript.js +++ b/examples/playa/fireworks/fireworksLaunchButtonEntityScript.js @@ -45,35 +45,35 @@ }); var MODEL_URL = "https://s3-us-west-1.amazonaws.com/hifi-content/eric/models/Rocket-2.fbx"; - var missleDimensions = { - x: 0.24, - y: 0.7, - z: 0.24 - }; - var missle = Entities.addEntity({ - type: "Model", - modelURL: MODEL_URL, - position: rocketPosition, - dimensions: missleDimensions, - damping: 0, - dynamic: true, - velocity: { - x: 0.0, - y: randFloat(0.4, 1.0), - z: 0 - }, - acceleration: { - x: 0, - y: randFloat(1.0, 2.0), - z: 0 - }, - angularVelocity: {x: 0, y: randInt(0, 10), z: 0}, - angularDamping: 0 - }); + var missleDimensions = Vec3.multiply({ + x: 0.24, + y: 0.7, + z: 0.24 + }, randFloat(0.2, 1.5)); + var missleRotation = Quat.fromPitchYawRollDegrees(randInt(-30, 30), 0, randInt(-30, 30)); + var missleVelocity = Vec3.multiply(Quat.getUp(missleRotation), randFloat(1, 3)); + var missleAcceleration = Vec3.multiply(Quat.getUp(missleRotation), randFloat(0.7, 3)); + var missle = Entities.addEntity({ + type: "Model", + modelURL: MODEL_URL, + position: rocketPosition, + rotation: missleRotation, + dimensions: missleDimensions, + damping: 0, + dynamic: true, + velocity: missleVelocity, + acceleration: missleAcceleration, + angularVelocity: { + x: 0, + y: randInt(-5, 5), + z: 0 + }, + angularDamping: 0 + }); var smokeTrailPosition = Vec3.sum(rocketPosition, { x: 0, - y: -missleDimensions.y/2 + 0.1, + y: -missleDimensions.y / 2 + 0.1, z: 0 }); var smokeSettings = { @@ -172,9 +172,21 @@ name: "fireworks emitter", position: explodePosition, type: "ParticleEffect", - colorStart: hslToRgb({h: Math.random(), s: 0.5, l: 0.7}), - color: hslToRgb({h: Math.random(), s: 0.5, l: 0.5}), - colorFinish: hslToRgb({h: Math.random(), s: 0.5, l: 0.7}), + colorStart: hslToRgb({ + h: Math.random(), + s: 0.5, + l: 0.7 + }), + color: hslToRgb({ + h: Math.random(), + s: 0.5, + l: 0.5 + }), + colorFinish: hslToRgb({ + h: Math.random(), + s: 0.5, + l: 0.7 + }), maxParticles: 10000, lifetime: 20, lifespan: randFloat(1.5, 3), From 45e8287d1d926ad1a571c4e41ef7e8a28135a2e1 Mon Sep 17 00:00:00 2001 From: ericrius1 Date: Wed, 24 Feb 2016 16:55:31 -0800 Subject: [PATCH 14/31] particle trail in right spot --- .../playa/fireworks/fireworksLaunchButtonEntityScript.js | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/examples/playa/fireworks/fireworksLaunchButtonEntityScript.js b/examples/playa/fireworks/fireworksLaunchButtonEntityScript.js index 646f63cc91..f8ba98f3c6 100644 --- a/examples/playa/fireworks/fireworksLaunchButtonEntityScript.js +++ b/examples/playa/fireworks/fireworksLaunchButtonEntityScript.js @@ -71,11 +71,7 @@ angularDamping: 0 }); - var smokeTrailPosition = Vec3.sum(rocketPosition, { - x: 0, - y: -missleDimensions.y / 2 + 0.1, - z: 0 - }); + var smokeTrailPosition = Vec3.sum(rocketPosition, Vec3.multiply(-missleDimensions.y/2 + 0.1, Quat.getUp(missleRotation))); var smokeSettings = { type: "ParticleEffect", position: smokeTrailPosition, From 08e7adc5186bbf0fecdb8c5776bee2cd01bf67da Mon Sep 17 00:00:00 2001 From: ericrius1 Date: Wed, 24 Feb 2016 17:08:12 -0800 Subject: [PATCH 15/31] tweaks --- .../fireworksLaunchButtonEntityScript.js | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/examples/playa/fireworks/fireworksLaunchButtonEntityScript.js b/examples/playa/fireworks/fireworksLaunchButtonEntityScript.js index f8ba98f3c6..35c68fd488 100644 --- a/examples/playa/fireworks/fireworksLaunchButtonEntityScript.js +++ b/examples/playa/fireworks/fireworksLaunchButtonEntityScript.js @@ -27,10 +27,14 @@ Fireworks.prototype = { startNearTrigger: function() { - _this.shootFirework(); + _this.shootFireworks(); }, clickReleaseOnEntity: function() { + _this.shootFireworks(); + }, + + shootFireworks: function() { _this.shootFirework(); }, @@ -68,7 +72,8 @@ y: randInt(-5, 5), z: 0 }, - angularDamping: 0 + angularDamping: 0, + visible: false }); var smokeTrailPosition = Vec3.sum(rocketPosition, Vec3.multiply(-missleDimensions.y/2 + 0.1, Quat.getUp(missleRotation))); @@ -131,14 +136,9 @@ green: 132, blue: 21 }; - smokeSettings.lifespan = 1; - smokeSettings.emitAcceleration.y = -1;; - smokeSettings.alphaStart = 0.7; + smokeSettings.alphaStart = 0.1; smokeSettings.alphaFinish = 0.1; - smokeSettings.radiusFinish = 0.06; - smokeSettings.particleRadius = 0.06; - smokeSettings.emitRate = 200; - smokeSettings.emitterShouldTrail = false; + smokeSettings.name = "fire emitter"; var fire = Entities.addEntity(smokeSettings); From 857ccc7409826df89e7ae0b321a1a91490f9ece0 Mon Sep 17 00:00:00 2001 From: ericrius1 Date: Wed, 24 Feb 2016 17:53:46 -0800 Subject: [PATCH 16/31] move sound with thing --- .../fireworksLaunchButtonEntityScript.js | 69 +++++++++++-------- 1 file changed, 42 insertions(+), 27 deletions(-) diff --git a/examples/playa/fireworks/fireworksLaunchButtonEntityScript.js b/examples/playa/fireworks/fireworksLaunchButtonEntityScript.js index 35c68fd488..ac609418fd 100644 --- a/examples/playa/fireworks/fireworksLaunchButtonEntityScript.js +++ b/examples/playa/fireworks/fireworksLaunchButtonEntityScript.js @@ -21,7 +21,6 @@ min: 2000, max: 4000 }; - _this.explodeTime = randInt(500, 1000); }; Fireworks.prototype = { @@ -35,17 +34,21 @@ }, shootFireworks: function() { - _this.shootFirework(); + var numMissles = randInt(1, 5); + for(var i = 0; i < numMissles; i++) { + _this.shootMissle(); + } }, - shootFirework: function() { + shootMissle: function() { var rocketPosition = Vec3.sum(_this.position, { x: 0, y: 0.1, z: 0 }); Audio.playSound(_this.launchSound, { - position: rocketPosition + position: rocketPosition, + volume: 0.5 }); var MODEL_URL = "https://s3-us-west-1.amazonaws.com/hifi-content/eric/models/Rocket-2.fbx"; @@ -54,7 +57,7 @@ y: 0.7, z: 0.24 }, randFloat(0.2, 1.5)); - var missleRotation = Quat.fromPitchYawRollDegrees(randInt(-30, 30), 0, randInt(-30, 30)); + var missleRotation = Quat.fromPitchYawRollDegrees(randInt(-60, 60), 0, randInt(-60, 60)); var missleVelocity = Vec3.multiply(Quat.getUp(missleRotation), randFloat(1, 3)); var missleAcceleration = Vec3.multiply(Quat.getUp(missleRotation), randFloat(0.7, 3)); var missle = Entities.addEntity({ @@ -65,18 +68,19 @@ dimensions: missleDimensions, damping: 0, dynamic: true, + lifetime: 20, // Just in case velocity: missleVelocity, acceleration: missleAcceleration, angularVelocity: { x: 0, - y: randInt(-5, 5), + y: randInt(-1, 1), z: 0 }, angularDamping: 0, visible: false }); - var smokeTrailPosition = Vec3.sum(rocketPosition, Vec3.multiply(-missleDimensions.y/2 + 0.1, Quat.getUp(missleRotation))); + var smokeTrailPosition = Vec3.sum(rocketPosition, Vec3.multiply(-missleDimensions.y / 2 + 0.1, Quat.getUp(missleRotation))); var smokeSettings = { type: "ParticleEffect", position: smokeTrailPosition, @@ -110,7 +114,7 @@ particleRadius: 0.06, radiusStart: 0.06, radiusFinish: 0.2, - alpha: 0.1, + alpha: 0.7, alphaSpread: 0, alphaStart: 0, alphaFinish: 0, @@ -136,31 +140,42 @@ green: 132, blue: 21 }; - smokeSettings.alphaStart = 0.1; + smokeSettings.alphaStart = 0.6; smokeSettings.alphaFinish = 0.1; smokeSettings.name = "fire emitter"; var fire = Entities.addEntity(smokeSettings); Script.setTimeout(function() { - var explodePosition = Entities.getEntityProperties(missle, "position").position; - _this.explodeFirework(smoke, fire, missle, explodePosition); + Entities.editEntity(smoke, { + parentID: null, + isEmitting: false + }); + Entities.editEntity(fire, { + parentID: null, + isEmitting: false + }); + + var explodeBasePosition = Entities.getEntityProperties(missle, "position").position; + + Entities.deleteEntity(missle); + // Explode 1 firework immediately + _this.explodeFirework(explodeBasePosition); + var numAdditionalFireworks = randInt(4, 10); + for (var i = 0; i < numAdditionalFireworks; i++) { + Script.setTimeout(function() { + var explodePosition = Vec3.sum(explodeBasePosition, {x: randFloat(-3, 3), y: randFloat(-3, 3), z: randFloat(-3, 3)}); + _this.explodeFirework(explodePosition); + }, randInt(0, 1000)) + } }, randFloat(_this.timeToExplosionRange.min, _this.timeToExplosionRange.max)); }, - explodeFirework: function(smoke, fire, missle, explodePosition) { + explodeFirework: function(explodePosition) { // We just exploded firework, so stop emitting its fire and smoke - Entities.editEntity(smoke, { - parentID: null, - isEmitting: false - }); - Entities.editEntity(fire, { - parentID: null, - isEmitting: false - }); - Entities.deleteEntity(missle); + Audio.playSound(_this.explosionSound, { position: explodePosition }); @@ -186,7 +201,7 @@ maxParticles: 10000, lifetime: 20, lifespan: randFloat(1.5, 3), - emitRate: randInt(500, 10000), + emitRate: randInt(500, 5000), emitSpeed: randFloat(0.5, 2), speedSpread: 0.2, emitOrientation: Quat.fromPitchYawRollDegrees(randInt(0, 360), randInt(0, 360), randInt(0, 360)), @@ -208,10 +223,10 @@ radiusSpread: Math.random() * 0.1, radiusStart: randFloat(0.001, 0.1), radiusFinish: randFloat(0.001, 0.1), - alpha: Math.random(), - alphaSpread: Math.random(), - alphaStart: Math.random(), - alphaFinish: Math.random(), + alpha: randFloat(0.5, 1.0), + alphaSpread: randFloat(0.5, 1.0), + alphaStart: randFloat(0.5, 1.0), + alphaFinish: randFloat(0.5, 1.0), textures: "http://ericrius1.github.io/PlatosCave/assets/star.png", }); @@ -220,7 +235,7 @@ Entities.editEntity(firework, { isEmitting: false }); - }, _this.explodeTime); + }, randInt(500, 1000)); }, From 29c4ac83c0b7d503f0402c32a52db1d55550f455 Mon Sep 17 00:00:00 2001 From: ericrius1 Date: Wed, 24 Feb 2016 18:00:57 -0800 Subject: [PATCH 17/31] can set launch position in userdata --- .../fireworksLaunchButtonEntityScript.js | 18 ++++++++---------- .../fireworks/fireworksLaunchButtonSpawner.js | 1 + 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/examples/playa/fireworks/fireworksLaunchButtonEntityScript.js b/examples/playa/fireworks/fireworksLaunchButtonEntityScript.js index ac609418fd..15d9b7d4bd 100644 --- a/examples/playa/fireworks/fireworksLaunchButtonEntityScript.js +++ b/examples/playa/fireworks/fireworksLaunchButtonEntityScript.js @@ -34,20 +34,18 @@ }, shootFireworks: function() { + // Get launch position + var launchPosition = getEntityUserData(_this.entityID).launchPosition || _this.position; + var numMissles = randInt(1, 5); for(var i = 0; i < numMissles; i++) { - _this.shootMissle(); + _this.shootMissle(launchPosition); } }, - shootMissle: function() { - var rocketPosition = Vec3.sum(_this.position, { - x: 0, - y: 0.1, - z: 0 - }); + shootMissle: function(launchPosition) { Audio.playSound(_this.launchSound, { - position: rocketPosition, + position: launchPosition, volume: 0.5 }); @@ -63,7 +61,7 @@ var missle = Entities.addEntity({ type: "Model", modelURL: MODEL_URL, - position: rocketPosition, + position: launchPosition, rotation: missleRotation, dimensions: missleDimensions, damping: 0, @@ -80,7 +78,7 @@ visible: false }); - var smokeTrailPosition = Vec3.sum(rocketPosition, Vec3.multiply(-missleDimensions.y / 2 + 0.1, Quat.getUp(missleRotation))); + var smokeTrailPosition = Vec3.sum(launchPosition, Vec3.multiply(-missleDimensions.y / 2 + 0.1, Quat.getUp(missleRotation))); var smokeSettings = { type: "ParticleEffect", position: smokeTrailPosition, diff --git a/examples/playa/fireworks/fireworksLaunchButtonSpawner.js b/examples/playa/fireworks/fireworksLaunchButtonSpawner.js index 831afc18f1..9e0bca8a8d 100644 --- a/examples/playa/fireworks/fireworksLaunchButtonSpawner.js +++ b/examples/playa/fireworks/fireworksLaunchButtonSpawner.js @@ -30,6 +30,7 @@ }, script: SCRIPT_URL, userData: JSON.stringify({ + launchPosition: {x: 1, y: 1.8, z: -20.9}, grabbableKey: { wantsTrigger: true } From a1eab365ced574ba11b5a042ffb03e3036fe04d6 Mon Sep 17 00:00:00 2001 From: ericrius1 Date: Wed, 24 Feb 2016 18:11:08 -0800 Subject: [PATCH 18/31] added name to launch pad --- examples/playa/fireworks/fireworksLaunchButtonSpawner.js | 1 + 1 file changed, 1 insertion(+) diff --git a/examples/playa/fireworks/fireworksLaunchButtonSpawner.js b/examples/playa/fireworks/fireworksLaunchButtonSpawner.js index 9e0bca8a8d..dd82922aed 100644 --- a/examples/playa/fireworks/fireworksLaunchButtonSpawner.js +++ b/examples/playa/fireworks/fireworksLaunchButtonSpawner.js @@ -21,6 +21,7 @@ var MODEL_URL = "https://s3-us-west-1.amazonaws.com/hifi-content/eric/models/Launch-Button.fbx"; var launchButton = Entities.addEntity({ type: "Model", + name: "launch pad", modelURL: MODEL_URL, position: center, dimensions: { From 7cb57aa067bcf410f865224493aa15ed1bec13db Mon Sep 17 00:00:00 2001 From: ericrius1 Date: Wed, 24 Feb 2016 18:15:34 -0800 Subject: [PATCH 19/31] alpha tweaks --- .../playa/fireworks/fireworksLaunchButtonEntityScript.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/examples/playa/fireworks/fireworksLaunchButtonEntityScript.js b/examples/playa/fireworks/fireworksLaunchButtonEntityScript.js index 15d9b7d4bd..4e6309de41 100644 --- a/examples/playa/fireworks/fireworksLaunchButtonEntityScript.js +++ b/examples/playa/fireworks/fireworksLaunchButtonEntityScript.js @@ -221,10 +221,10 @@ radiusSpread: Math.random() * 0.1, radiusStart: randFloat(0.001, 0.1), radiusFinish: randFloat(0.001, 0.1), - alpha: randFloat(0.5, 1.0), - alphaSpread: randFloat(0.5, 1.0), - alphaStart: randFloat(0.5, 1.0), - alphaFinish: randFloat(0.5, 1.0), + alpha: randFloat(0.8, 1.0), + alphaSpread: randFloat(0.1, 0.2), + alphaStart: randFloat(0.7, 1.0), + alphaFinish: randFloat(0.7, 1.0), textures: "http://ericrius1.github.io/PlatosCave/assets/star.png", }); From ad49bcda72cd97df7049d923fb9a9413f5ff6524 Mon Sep 17 00:00:00 2001 From: ericrius1 Date: Wed, 24 Feb 2016 18:29:44 -0800 Subject: [PATCH 20/31] lowered num fireworks --- examples/playa/fireworks/fireworksLaunchButtonEntityScript.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/playa/fireworks/fireworksLaunchButtonEntityScript.js b/examples/playa/fireworks/fireworksLaunchButtonEntityScript.js index 4e6309de41..acfbce099e 100644 --- a/examples/playa/fireworks/fireworksLaunchButtonEntityScript.js +++ b/examples/playa/fireworks/fireworksLaunchButtonEntityScript.js @@ -37,7 +37,7 @@ // Get launch position var launchPosition = getEntityUserData(_this.entityID).launchPosition || _this.position; - var numMissles = randInt(1, 5); + var numMissles = randInt(1, 3); for(var i = 0; i < numMissles; i++) { _this.shootMissle(launchPosition); } @@ -159,7 +159,7 @@ Entities.deleteEntity(missle); // Explode 1 firework immediately _this.explodeFirework(explodeBasePosition); - var numAdditionalFireworks = randInt(4, 10); + var numAdditionalFireworks = randInt(1, 5); for (var i = 0; i < numAdditionalFireworks; i++) { Script.setTimeout(function() { var explodePosition = Vec3.sum(explodeBasePosition, {x: randFloat(-3, 3), y: randFloat(-3, 3), z: randFloat(-3, 3)}); From 8f914c6673ed105339aadb9f3fecdeaf30a2bb5b Mon Sep 17 00:00:00 2001 From: ericrius1 Date: Wed, 24 Feb 2016 20:08:35 -0800 Subject: [PATCH 21/31] removed query string on entity script --- examples/playa/fireworks/fireworksLaunchButtonSpawner.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/playa/fireworks/fireworksLaunchButtonSpawner.js b/examples/playa/fireworks/fireworksLaunchButtonSpawner.js index dd82922aed..20527a7e3a 100644 --- a/examples/playa/fireworks/fireworksLaunchButtonSpawner.js +++ b/examples/playa/fireworks/fireworksLaunchButtonSpawner.js @@ -17,7 +17,7 @@ var center = Vec3.sum(MyAvatar.position, Vec3.multiply(3, Quat.getFront(orientation))); // Math.random ensures no caching of script - var SCRIPT_URL = Script.resolvePath("fireworksLaunchButtonEntityScript.js?v1" + Math.random()) + var SCRIPT_URL = Script.resolvePath("fireworksLaunchButtonEntityScript.js"); var MODEL_URL = "https://s3-us-west-1.amazonaws.com/hifi-content/eric/models/Launch-Button.fbx"; var launchButton = Entities.addEntity({ type: "Model", From 728612f9a7892b3e8e70333a52200ef940123f19 Mon Sep 17 00:00:00 2001 From: ericrius1 Date: Thu, 25 Feb 2016 09:26:37 -0800 Subject: [PATCH 22/31] far trigger launches fireworks --- examples/playa/fireworks/fireworksLaunchButtonEntityScript.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/examples/playa/fireworks/fireworksLaunchButtonEntityScript.js b/examples/playa/fireworks/fireworksLaunchButtonEntityScript.js index acfbce099e..8c4480e24f 100644 --- a/examples/playa/fireworks/fireworksLaunchButtonEntityScript.js +++ b/examples/playa/fireworks/fireworksLaunchButtonEntityScript.js @@ -29,6 +29,10 @@ _this.shootFireworks(); }, + startFarTrigger: function() { + _this.shootFireworks(); + }, + clickReleaseOnEntity: function() { _this.shootFireworks(); }, From 9a108c298fb77e687f77860785cfac18287572c0 Mon Sep 17 00:00:00 2001 From: ericrius1 Date: Thu, 25 Feb 2016 09:34:22 -0800 Subject: [PATCH 23/31] smoke tweaks --- .../playa/fireworks/fireworksLaunchButtonEntityScript.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/examples/playa/fireworks/fireworksLaunchButtonEntityScript.js b/examples/playa/fireworks/fireworksLaunchButtonEntityScript.js index 8c4480e24f..560c55681d 100644 --- a/examples/playa/fireworks/fireworksLaunchButtonEntityScript.js +++ b/examples/playa/fireworks/fireworksLaunchButtonEntityScript.js @@ -86,11 +86,11 @@ var smokeSettings = { type: "ParticleEffect", position: smokeTrailPosition, - lifespan: 1.6, + lifespan: 4, lifetime: 20, name: "Smoke Trail", maxParticles: 3000, - emitRate: 50, + emitRate: 80, emitSpeed: 0, speedSpread: 0, dimensions: { @@ -115,8 +115,8 @@ radiusSpread: 0.001, particleRadius: 0.06, radiusStart: 0.06, - radiusFinish: 0.2, - alpha: 0.7, + radiusFinish: 0.6, + alpha: 0.5, alphaSpread: 0, alphaStart: 0, alphaFinish: 0, From d4d5aed51867f7b6cee3a60a3ff495774043211e Mon Sep 17 00:00:00 2001 From: ericrius1 Date: Thu, 25 Feb 2016 09:44:48 -0800 Subject: [PATCH 24/31] smoke tweaks --- .../fireworksLaunchButtonEntityScript.js | 44 +++++-------------- 1 file changed, 10 insertions(+), 34 deletions(-) diff --git a/examples/playa/fireworks/fireworksLaunchButtonEntityScript.js b/examples/playa/fireworks/fireworksLaunchButtonEntityScript.js index 560c55681d..7b82fbdada 100644 --- a/examples/playa/fireworks/fireworksLaunchButtonEntityScript.js +++ b/examples/playa/fireworks/fireworksLaunchButtonEntityScript.js @@ -86,7 +86,7 @@ var smokeSettings = { type: "ParticleEffect", position: smokeTrailPosition, - lifespan: 4, + lifespan: 10, lifetime: 20, name: "Smoke Trail", maxParticles: 3000, @@ -104,21 +104,21 @@ azimuthFinish: 3.14, emitAcceleration: { x: 0, - y: 0.1, + y: 0.01, z: 0 }, accelerationSpread: { - x: 0.1, + x: 0.01, y: 0, - z: 0.1 + z: 0.01 }, - radiusSpread: 0.001, - particleRadius: 0.06, + radiusSpread: 0.03, + particleRadius: 0.3, radiusStart: 0.06, - radiusFinish: 0.6, - alpha: 0.5, + radiusFinish: 0.9, + alpha: 0.4, alphaSpread: 0, - alphaStart: 0, + alphaStart: 0.7, alphaFinish: 0, textures: "https://hifi-public.s3.amazonaws.com/alan/Particles/Particle-Sprite-Smoke-1.png", emitterShouldTrail: true, @@ -127,36 +127,12 @@ var smoke = Entities.addEntity(smokeSettings); - smokeSettings.colorStart = { - red: 75, - green: 193, - blue: 254 - }; - smokeSettings.color = { - red: 202, - green: 132, - blue: 151 - }; - smokeSettings.colorFinish = { - red: 250, - green: 132, - blue: 21 - }; - smokeSettings.alphaStart = 0.6; - smokeSettings.alphaFinish = 0.1; - - smokeSettings.name = "fire emitter"; - var fire = Entities.addEntity(smokeSettings); - Script.setTimeout(function() { Entities.editEntity(smoke, { parentID: null, isEmitting: false }); - Entities.editEntity(fire, { - parentID: null, - isEmitting: false - }); + var explodeBasePosition = Entities.getEntityProperties(missle, "position").position; From f12acfb7f3e64a1741eab47579ce44b49c4c587e Mon Sep 17 00:00:00 2001 From: ericrius1 Date: Thu, 25 Feb 2016 09:49:44 -0800 Subject: [PATCH 25/31] simplfied --- .../playa/fireworks/fireworksLaunchButtonEntityScript.js | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/examples/playa/fireworks/fireworksLaunchButtonEntityScript.js b/examples/playa/fireworks/fireworksLaunchButtonEntityScript.js index 7b82fbdada..a97e334dec 100644 --- a/examples/playa/fireworks/fireworksLaunchButtonEntityScript.js +++ b/examples/playa/fireworks/fireworksLaunchButtonEntityScript.js @@ -83,7 +83,7 @@ }); var smokeTrailPosition = Vec3.sum(launchPosition, Vec3.multiply(-missleDimensions.y / 2 + 0.1, Quat.getUp(missleRotation))); - var smokeSettings = { + var smoke = Entities.addEntity({ type: "ParticleEffect", position: smokeTrailPosition, lifespan: 10, @@ -122,17 +122,15 @@ alphaFinish: 0, textures: "https://hifi-public.s3.amazonaws.com/alan/Particles/Particle-Sprite-Smoke-1.png", emitterShouldTrail: true, - parentID: missle - }; + parentID: missle, + }); - var smoke = Entities.addEntity(smokeSettings); Script.setTimeout(function() { Entities.editEntity(smoke, { parentID: null, isEmitting: false }); - var explodeBasePosition = Entities.getEntityProperties(missle, "position").position; From 54ee3d347c2098237146e4086e52727523eadc6d Mon Sep 17 00:00:00 2001 From: ericrius1 Date: Thu, 25 Feb 2016 09:53:17 -0800 Subject: [PATCH 26/31] more velocity --- .../playa/fireworks/fireworksLaunchButtonEntityScript.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/examples/playa/fireworks/fireworksLaunchButtonEntityScript.js b/examples/playa/fireworks/fireworksLaunchButtonEntityScript.js index a97e334dec..380bbec009 100644 --- a/examples/playa/fireworks/fireworksLaunchButtonEntityScript.js +++ b/examples/playa/fireworks/fireworksLaunchButtonEntityScript.js @@ -18,8 +18,8 @@ _this.launchSound = SoundCache.getSound("https://s3-us-west-1.amazonaws.com/hifi-content/eric/Sounds/missle+launch.wav"); _this.explosionSound = SoundCache.getSound("https://s3-us-west-1.amazonaws.com/hifi-content/eric/Sounds/fireworksExplosion.wav"); _this.timeToExplosionRange = { - min: 2000, - max: 4000 + min: 2500, + max: 4500 }; }; @@ -60,8 +60,8 @@ z: 0.24 }, randFloat(0.2, 1.5)); var missleRotation = Quat.fromPitchYawRollDegrees(randInt(-60, 60), 0, randInt(-60, 60)); - var missleVelocity = Vec3.multiply(Quat.getUp(missleRotation), randFloat(1, 3)); - var missleAcceleration = Vec3.multiply(Quat.getUp(missleRotation), randFloat(0.7, 3)); + var missleVelocity = Vec3.multiply(Quat.getUp(missleRotation), randFloat(2, 4)); + var missleAcceleration = Vec3.multiply(Quat.getUp(missleRotation), randFloat(1, 3)); var missle = Entities.addEntity({ type: "Model", modelURL: MODEL_URL, From b5b3a402338f091b64588a82454b46ac40e04221 Mon Sep 17 00:00:00 2001 From: "Anthony J. Thibault" Date: Thu, 25 Feb 2016 10:02:17 -0800 Subject: [PATCH 27/31] LogHandler: add option to display milliseconds in timestamp --- libraries/shared/src/LogHandler.cpp | 14 ++++++++++---- libraries/shared/src/LogHandler.h | 6 ++++-- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/libraries/shared/src/LogHandler.cpp b/libraries/shared/src/LogHandler.cpp index c1cf969f36..a338dfe8c2 100644 --- a/libraries/shared/src/LogHandler.cpp +++ b/libraries/shared/src/LogHandler.cpp @@ -26,9 +26,7 @@ LogHandler& LogHandler::getInstance() { return staticInstance; } -LogHandler::LogHandler() : - _shouldOutputProcessID(false), - _shouldOutputThreadID(false) +LogHandler::LogHandler() { // setup our timer to flush the verbose logs every 5 seconds QTimer* logFlushTimer = new QTimer(this); @@ -62,6 +60,9 @@ const char* stringForLogType(LogMsgType msgType) { // the following will produce 11/18 13:55:36 const QString DATE_STRING_FORMAT = "MM/dd hh:mm:ss"; +// the following will produce 11/18 13:55:36.999 +const QString DATE_STRING_FORMAT_WITH_MILLISECONDS = "MM/dd hh:mm:ss.zzz"; + void LogHandler::flushRepeatedMessages() { QMutexLocker locker(&_repeatedMessageLock); QHash::iterator message = _repeatMessageCountHash.begin(); @@ -132,7 +133,12 @@ QString LogHandler::printMessage(LogMsgType type, const QMessageLogContext& cont // log prefix is in the following format // [TIMESTAMP] [DEBUG] [PID] [TID] [TARGET] logged string - QString prefixString = QString("[%1]").arg(QDateTime::currentDateTime().toString(DATE_STRING_FORMAT)); + const QString* dateFormatPtr = &DATE_STRING_FORMAT; + if (_shouldDisplayMilliseconds) { + dateFormatPtr = &DATE_STRING_FORMAT_WITH_MILLISECONDS; + } + + QString prefixString = QString("[%1]").arg(QDateTime::currentDateTime().toString(*dateFormatPtr)); prefixString.append(QString(" [%1]").arg(stringForLogType(type))); diff --git a/libraries/shared/src/LogHandler.h b/libraries/shared/src/LogHandler.h index ee8e426c34..d346913dd3 100644 --- a/libraries/shared/src/LogHandler.h +++ b/libraries/shared/src/LogHandler.h @@ -42,6 +42,7 @@ public: void setShouldOutputProcessID(bool shouldOutputProcessID) { _shouldOutputProcessID = shouldOutputProcessID; } void setShouldOutputThreadID(bool shouldOutputThreadID) { _shouldOutputThreadID = shouldOutputThreadID; } + void setShouldDisplayMilliseconds(bool shouldDisplayMilliseconds) { _shouldDisplayMilliseconds = shouldDisplayMilliseconds; } QString printMessage(LogMsgType type, const QMessageLogContext& context, const QString &message); @@ -57,8 +58,9 @@ private: void flushRepeatedMessages(); QString _targetName; - bool _shouldOutputProcessID; - bool _shouldOutputThreadID; + bool _shouldOutputProcessID { false }; + bool _shouldOutputThreadID { false }; + bool _shouldDisplayMilliseconds { false }; QSet _repeatedMessageRegexes; QHash _repeatMessageCountHash; QHash _lastRepeatedMessage; From 9000c3479b0d3bccba705d4bf6e12d9162e22766 Mon Sep 17 00:00:00 2001 From: Zach Pomerantz Date: Wed, 24 Feb 2016 19:38:01 -0800 Subject: [PATCH 28/31] Avoid double-update of zone --- .../src/EntityTreeRenderer.cpp | 22 ++++++++++--------- .../src/EntityTreeRenderer.h | 4 ++-- 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/libraries/entities-renderer/src/EntityTreeRenderer.cpp b/libraries/entities-renderer/src/EntityTreeRenderer.cpp index 3bf1e7bc92..1609052d54 100644 --- a/libraries/entities-renderer/src/EntityTreeRenderer.cpp +++ b/libraries/entities-renderer/src/EntityTreeRenderer.cpp @@ -134,14 +134,14 @@ void EntityTreeRenderer::update() { EntityTreePointer tree = std::static_pointer_cast(_tree); tree->update(); - // check to see if the avatar has moved and if we need to handle enter/leave entity logic - checkEnterLeaveEntities(); + // Handle enter/leave entity logic + bool updated = checkEnterLeaveEntities(); - // even if we haven't changed positions, if we previously attempted to set the skybox, but - // have a pending download of the skybox texture, then we should attempt to reapply to - // get the correct texture. - if ((_pendingSkyboxTexture && _skyboxTexture && _skyboxTexture->isLoaded()) || - (_pendingAmbientTexture && _ambientTexture && _ambientTexture->isLoaded())) { + // If we haven't already updated and previously attempted to load a texture, + // check if the texture loaded and apply it + if (!updated && ( + (_pendingSkyboxTexture && _skyboxTexture && _skyboxTexture->isLoaded()) || + (_pendingAmbientTexture && _ambientTexture && _ambientTexture->isLoaded()))) { applyZonePropertiesToScene(_bestZone); } @@ -157,7 +157,7 @@ void EntityTreeRenderer::update() { deleteReleasedModels(); } -void EntityTreeRenderer::checkEnterLeaveEntities() { +bool EntityTreeRenderer::checkEnterLeaveEntities() { if (_tree && !_shuttingDown) { glm::vec3 avatarPosition = _viewState->getAvatarPosition(); @@ -172,7 +172,7 @@ void EntityTreeRenderer::checkEnterLeaveEntities() { std::static_pointer_cast(_tree)->findEntities(avatarPosition, radius, foundEntities); // Whenever you're in an intersection between zones, we will always choose the smallest zone. - _bestZone = NULL; // NOTE: Is this what we want? + _bestZone = nullptr; // NOTE: Is this what we want? _bestZoneVolume = std::numeric_limits::max(); // create a list of entities that actually contain the avatar's position @@ -205,7 +205,6 @@ void EntityTreeRenderer::checkEnterLeaveEntities() { } applyZonePropertiesToScene(_bestZone); - }); // Note: at this point we don't need to worry about the tree being locked, because we only deal with @@ -229,8 +228,11 @@ void EntityTreeRenderer::checkEnterLeaveEntities() { } _currentEntitiesInside = entitiesContainingAvatar; _lastAvatarPosition = avatarPosition; + + return true; } } + return false; } void EntityTreeRenderer::leaveAllEntities() { diff --git a/libraries/entities-renderer/src/EntityTreeRenderer.h b/libraries/entities-renderer/src/EntityTreeRenderer.h index f1598221dd..60f65cabe7 100644 --- a/libraries/entities-renderer/src/EntityTreeRenderer.h +++ b/libraries/entities-renderer/src/EntityTreeRenderer.h @@ -136,11 +136,11 @@ private: EntityItemID _currentClickingOnEntityID; QScriptValueList createEntityArgs(const EntityItemID& entityID); - void checkEnterLeaveEntities(); + bool checkEnterLeaveEntities(); void leaveAllEntities(); void forceRecheckEntities(); - glm::vec3 _lastAvatarPosition; + glm::vec3 _lastAvatarPosition { 0.0f }; QVector _currentEntitiesInside; bool _pendingSkyboxTexture { false }; From c20bd6cbbc0b9b368806711842b12ea56f9ed2e3 Mon Sep 17 00:00:00 2001 From: Zach Pomerantz Date: Wed, 24 Feb 2016 19:38:24 -0800 Subject: [PATCH 29/31] Update Scene on ZoneEntity update ZoneEntity is unique in that it is not updated every frame that it is rendered, but only when the avatar moves. This introduces custom code so that the RenderableZoneEntity initiates an update in the EntityTreeRenderer on update, to improve usability of zone editing. --- .../entities-renderer/src/EntityTreeRenderer.cpp | 16 ++++++++++++++++ .../entities-renderer/src/EntityTreeRenderer.h | 1 + .../src/RenderableZoneEntityItem.cpp | 5 +++++ .../src/RenderableZoneEntityItem.h | 2 ++ 4 files changed, 24 insertions(+) diff --git a/libraries/entities-renderer/src/EntityTreeRenderer.cpp b/libraries/entities-renderer/src/EntityTreeRenderer.cpp index 1609052d54..bc1f614f79 100644 --- a/libraries/entities-renderer/src/EntityTreeRenderer.cpp +++ b/libraries/entities-renderer/src/EntityTreeRenderer.cpp @@ -853,3 +853,19 @@ void EntityTreeRenderer::updateEntityRenderStatus(bool shouldRenderEntities) { } } } + +void EntityTreeRenderer::updateZone(const EntityItemID& id) { + if (!_bestZone) { + // Get in the zone! + auto zone = getTree()->findEntityByEntityItemID(id); + if (zone && zone->contains(_lastAvatarPosition)) { + _currentEntitiesInside << id; + emit enterEntity(id); + _entitiesScriptEngine->callEntityScriptMethod(id, "enterEntity"); + _bestZone = std::dynamic_pointer_cast(zone); + } + } + if (_bestZone && _bestZone->getID() == id) { + applyZonePropertiesToScene(_bestZone); + } +} diff --git a/libraries/entities-renderer/src/EntityTreeRenderer.h b/libraries/entities-renderer/src/EntityTreeRenderer.h index 60f65cabe7..5aadf7d299 100644 --- a/libraries/entities-renderer/src/EntityTreeRenderer.h +++ b/libraries/entities-renderer/src/EntityTreeRenderer.h @@ -109,6 +109,7 @@ public slots: void entitySciptChanging(const EntityItemID& entityID, const bool reload); void entityCollisionWithEntity(const EntityItemID& idA, const EntityItemID& idB, const Collision& collision); void updateEntityRenderStatus(bool shouldRenderEntities); + void updateZone(const EntityItemID& id); // optional slots that can be wired to menu items void setDisplayModelBounds(bool value) { _displayModelBounds = value; } diff --git a/libraries/entities-renderer/src/RenderableZoneEntityItem.cpp b/libraries/entities-renderer/src/RenderableZoneEntityItem.cpp index 44345ac0a2..ef47a777c2 100644 --- a/libraries/entities-renderer/src/RenderableZoneEntityItem.cpp +++ b/libraries/entities-renderer/src/RenderableZoneEntityItem.cpp @@ -18,6 +18,7 @@ #include #include +#include "EntityTreeRenderer.h" #include "RenderableEntityItem.h" // Sphere entities should fit inside a cube entity of the same size, so a sphere that has dimensions 1x1x1 @@ -62,6 +63,10 @@ bool RenderableZoneEntityItem::setProperties(const EntityItemProperties& propert return somethingChanged; } +void RenderableZoneEntityItem::somethingChangedNotification() { + DependencyManager::get()->updateZone(_id); +} + int RenderableZoneEntityItem::readEntitySubclassDataFromBuffer(const unsigned char* data, int bytesLeftToRead, ReadBitstreamToTreeParams& args, EntityPropertyFlags& propertyFlags, bool overwriteLocalData, diff --git a/libraries/entities-renderer/src/RenderableZoneEntityItem.h b/libraries/entities-renderer/src/RenderableZoneEntityItem.h index 6eb829a48f..4ba862fff8 100644 --- a/libraries/entities-renderer/src/RenderableZoneEntityItem.h +++ b/libraries/entities-renderer/src/RenderableZoneEntityItem.h @@ -28,6 +28,8 @@ public: { } virtual bool setProperties(const EntityItemProperties& properties); + virtual void somethingChangedNotification() override; + virtual int readEntitySubclassDataFromBuffer(const unsigned char* data, int bytesLeftToRead, ReadBitstreamToTreeParams& args, EntityPropertyFlags& propertyFlags, bool overwriteLocalData, From 98cf784c6f2aba50a4a44819c923846652da7dfd Mon Sep 17 00:00:00 2001 From: ericrius1 Date: Thu, 25 Feb 2016 10:32:21 -0800 Subject: [PATCH 30/31] more smoke fading --- examples/playa/fireworks/fireworksLaunchButtonEntityScript.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/playa/fireworks/fireworksLaunchButtonEntityScript.js b/examples/playa/fireworks/fireworksLaunchButtonEntityScript.js index 380bbec009..7e85f5695f 100644 --- a/examples/playa/fireworks/fireworksLaunchButtonEntityScript.js +++ b/examples/playa/fireworks/fireworksLaunchButtonEntityScript.js @@ -116,7 +116,7 @@ particleRadius: 0.3, radiusStart: 0.06, radiusFinish: 0.9, - alpha: 0.4, + alpha: 0.1, alphaSpread: 0, alphaStart: 0.7, alphaFinish: 0, From 4d27d5c9f2787e0d0051ee934b5632101cafa1bc Mon Sep 17 00:00:00 2001 From: Eric Levin Date: Thu, 25 Feb 2016 13:45:08 -0800 Subject: [PATCH 31/31] Update fireworksLaunchButtonEntityScript.js --- .../playa/fireworks/fireworksLaunchButtonEntityScript.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/examples/playa/fireworks/fireworksLaunchButtonEntityScript.js b/examples/playa/fireworks/fireworksLaunchButtonEntityScript.js index 7e85f5695f..63c4f3616e 100644 --- a/examples/playa/fireworks/fireworksLaunchButtonEntityScript.js +++ b/examples/playa/fireworks/fireworksLaunchButtonEntityScript.js @@ -2,8 +2,8 @@ // fireworksLaunchEntityScript.js // examples/playa/fireworks // - // Created by Eric Levina on 2/24/16. - // Copyright 2015 High Fidelity, Inc. + // Created by Eric Levin on 2/24/16. + // Copyright 2016 High Fidelity, Inc. // // Run this script to spawn a big fireworks launch button that a user can press // @@ -226,4 +226,4 @@ // entity scripts always need to return a newly constructed object of our type return new Fireworks(); - }); \ No newline at end of file + });