diff --git a/BUILD_OSX.md b/BUILD_OSX.md index 54360ad4b8..c8f19710ca 100644 --- a/BUILD_OSX.md +++ b/BUILD_OSX.md @@ -7,11 +7,18 @@ Please read the [general build guide](BUILD.md) for information on dependencies We no longer require install of qt5 via our [homebrew formulas repository](https://github.com/highfidelity/homebrew-formulas). Versions of Qt that are 5.5.x and above provide a mechanism to disable the wireless scanning we previously had a custom patch for. -###Qt +###OpenSSL and Qt -Assuming you've installed Qt 5 using the homebrew instructions above, you'll need to set QT_CMAKE_PREFIX_PATH so CMake can find your installation of Qt. For Qt 5.5.1 installed via homebrew, set QT_CMAKE_PREFIX_PATH as follows. +Assuming you've installed OpenSSL or Qt 5 using the homebrew instructions above, you'll need to set OPENSSL_ROOT_DIR and QT_CMAKE_PREFIX_PATH so CMake can find your installations. +For OpenSSL installed via homebrew, set OPENSSL_ROOT_DIR: - export QT_CMAKE_PREFIX_PATH=/usr/local/Cellar/qt5/5.5.1/lib/cmake + export OPENSSL_ROOT_DIR=/usr/local/Cellar/openssl/1.0.2d_1 + +For Qt 5.5.1 installed via homebrew, set QT_CMAKE_PREFIX_PATH as follows. + + export QT_CMAKE_PREFIX_PATH=/usr/local/Cellar/qt5/5.5.1_2/lib/cmake + +Not that these use the versions from homebrew formulae at the time of this writing, and the version in the path will likely change. ###Xcode If Xcode is your editor of choice, you can ask CMake to generate Xcode project files instead of Unix Makefiles. diff --git a/cmake/externals/quazip/CMakeLists.txt b/cmake/externals/quazip/CMakeLists.txt index ddac942692..ac19e7d680 100644 --- a/cmake/externals/quazip/CMakeLists.txt +++ b/cmake/externals/quazip/CMakeLists.txt @@ -4,7 +4,14 @@ cmake_policy(SET CMP0046 OLD) include(ExternalProject) -string(REPLACE \\ / QT_CMAKE_PREFIX_PATH $ENV{QT_CMAKE_PREFIX_PATH}) +if (WIN32) + # windows shell does not like backslashes expanded on the command line, + # so convert all backslashes in the QT path to forward slashes + string(REPLACE \\ / QT_CMAKE_PREFIX_PATH $ENV{QT_CMAKE_PREFIX_PATH}) +elseif ($ENV{QT_CMAKE_PREFIX_PATH}) + set(QT_CMAKE_PREFIX_PATH $ENV{QT_CMAKE_PREFIX_PATH}) +endif () + ExternalProject_Add( ${EXTERNAL_NAME} URL http://s3-us-west-1.amazonaws.com/hifi-production/dependencies/quazip-0.6.2.zip diff --git a/examples/toybox/bow/bow.js b/examples/toybox/bow/bow.js new file mode 100644 index 0000000000..f38aa64921 --- /dev/null +++ b/examples/toybox/bow/bow.js @@ -0,0 +1,628 @@ +// +// bow.js +// +// This script attaches to a bow that you can pick up with a hand controller. +// Created by James B. Pollack @imgntn on 10/19/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 +// + +(function() { + + Script.include("../../libraries/utils.js"); + + var NOTCH_ARROW_SOUND_URL = 'http://hifi-content.s3.amazonaws.com/james/bow_and_arrow/sounds/notch.wav'; + var SHOOT_ARROW_SOUND_URL = 'http://hifi-content.s3.amazonaws.com/james/bow_and_arrow/sounds/String_release2.L.wav'; + var STRING_PULL_SOUND_URL = 'http://hifi-content.s3.amazonaws.com/james/bow_and_arrow/sounds/Bow_draw.1.L.wav'; + var ARROW_HIT_SOUND_URL = 'http://hifi-content.s3.amazonaws.com/james/bow_and_arrow/sounds/Arrow_impact1.L.wav' + + var ARROW_DIMENSIONS = { + x: 0.02, + y: 0.02, + z: 0.72 + }; + + var ARROW_OFFSET = -0.44; + var ARROW_TIP_OFFSET = 0.32; + var ARROW_GRAVITY = { + x: 0, + y: -4.8, + z: 0 + }; + + var ARROW_MODEL_URL = "http://hifi-content.s3.amazonaws.com/james/bow_and_arrow/models/newarrow_textured.fbx"; + var ARROW_COLLISION_HULL_URL = "http://hifi-content.s3.amazonaws.com/james/bow_and_arrow/models/newarrow_collision_hull.obj"; + + var ARROW_DIMENSIONS = { + x: 0.02, + y: 0.02, + z: 0.64 + }; + + + var TOP_NOTCH_OFFSET = 0.6; + var BOTTOM_NOTCH_OFFSET = 0.6; + + var LINE_DIMENSIONS = { + x: 5, + y: 5, + z: 5 + }; + + var DRAW_STRING_THRESHOLD = 0.80; + + var LEFT_TIP = 1; + var RIGHT_TIP = 3; + + var NOTCH_OFFSET_FORWARD = 0.08; + var NOTCH_OFFSET_UP = 0.035; + + var SHOT_SCALE = { + min1: 0, + max1: 0.6, + min2: 1, + max2: 15 + } + + var BOW_SPATIAL_KEY = { + relativePosition: { + x: 0, + y: 0.06, + z: 0.11 + }, + relativeRotation: Quat.fromPitchYawRollDegrees(0, -90, 90) + } + + + var USE_DEBOUNCE = false; + + var TRIGGER_CONTROLS = [ + Controller.Standard.LT, + Controller.Standard.RT, + ]; + + function interval() { + var lastTime = new Date().getTime(); + + return function getInterval() { + var newTime = new Date().getTime(); + var delta = newTime - lastTime; + lastTime = newTime; + return delta; + }; + } + + var checkInterval = interval(); + + var _this; + + function Bow() { + _this = this; + return; + } + + Bow.prototype = { + isGrabbed: false, + stringDrawn: false, + aiming: false, + arrowTipPosition: null, + preNotchString: null, + hasArrowNotched: false, + arrow: null, + stringData: { + currentColor: { + red: 255, + green: 255, + blue: 255 + } + }, + sinceLastUpdate: 0, + preload: function(entityID) { + this.entityID = entityID; + this.stringPullSound = SoundCache.getSound(STRING_PULL_SOUND_URL); + this.shootArrowSound = SoundCache.getSound(SHOOT_ARROW_SOUND_URL); + this.arrowHitSound = SoundCache.getSound(ARROW_HIT_SOUND_URL); + this.arrowNotchSound = SoundCache.getSound(NOTCH_ARROW_SOUND_URL); + + }, + + unload: function() { + this.deleteStrings(); + Entities.deleteEntity(this.preNotchString); + Entities.deleteEntity(this.arrow); + }, + + setLeftHand: function() { + if (this.isGrabbed === true) { + return false; + } + this.hand = 'left'; + }, + + setRightHand: function() { + if (this.isGrabbed === true) { + return false; + } + this.hand = 'right'; + }, + + startNearGrab: function() { + + print('START BOW GRAB') + if (this.isGrabbed === true) { + return false; + } + + this.isGrabbed = true; + + this.initialHand = this.hand; + + //disable the opposite hand in handControllerGrab.js by message + var handToDisable = this.initialHand === 'right' ? 'left' : 'right'; + Messages.sendMessage('Hifi-Hand-Disabler', handToDisable); + + setEntityCustomData('grabbableKey', this.entityID, { + grabbable: false, + invertSolidWhileHeld: true, + spatialKey: BOW_SPATIAL_KEY + }); + + }, + continueNearGrab: function() { + this.deltaTime = checkInterval(); + + //debounce during debugging -- maybe we're updating too fast? + if (USE_DEBOUNCE === true) { + this.sinceLastUpdate = this.sinceLastUpdate + this.deltaTime; + + if (this.sinceLastUpdate > 60) { + this.sinceLastUpdate = 0; + } else { + return; + } + } + + this.bowProperties = Entities.getEntityProperties(this.entityID); + + //create a string across the bow when we pick it up + if (this.preNotchString === null) { + this.createPreNotchString(); + } + + if (this.preNotchString !== null && this.aiming === false) { + // print('DRAW PRE NOTCH STRING') + this.drawPreNotchStrings(); + } + + // create the notch detector that arrows will look for + + if (this.aiming === true) { + Entities.editEntity(this.preNotchString, { + visible: false + }) + } else { + Entities.editEntity(this.preNotchString, { + visible: true + }) + } + + this.checkStringHand(); + + }, + + releaseGrab: function() { + // print('RELEASE GRAB EVENT') + if (this.isGrabbed === true && this.hand === this.initialHand) { + + Messages.sendMessage('Hifi-Beam-Disabler', "none") + + this.isGrabbed = false; + this.stringDrawn = false; + this.deleteStrings(); + setEntityCustomData('grabbableKey', this.entityID, { + grabbable: true, + invertSolidWhileHeld: true, + spatialKey: BOW_SPATIAL_KEY + }); + Entities.deleteEntity(this.preNotchString); + Entities.deleteEntity(this.arrow); + this.aiming = false; + this.hasArrowNotched = false; + this.preNotchString = null; + + } + }, + + createArrow: function() { + print('create arrow') + this.playArrowNotchSound(); + + var arrow = Entities.addEntity({ + name: 'Hifi-Arrow', + type: 'Model', + modelURL: ARROW_MODEL_URL, + shapeType: 'compound', + compoundShapeURL: ARROW_COLLISION_HULL_URL, + dimensions: ARROW_DIMENSIONS, + position: this.bowProperties.position, + collisionsWillMove: false, + ignoreForCollisions: true, + collisionSoundURL: ARROW_HIT_SOUND_URL, + damping: 0.01, + userData: JSON.stringify({ + grabbableKey: { + grabbable: false + } + }) + + }); + + var makeArrowStick = function(entityA, entityB, collision) { + Entities.editEntity(entityA, { + angularVelocity: { + x: 0, + y: 0, + z: 0 + }, + velocity: { + x: 0, + y: 0, + z: 0 + }, + gravity: { + x: 0, + y: 0, + z: 0 + }, + position: collision.contactPoint, + collisionsWillMove: false + }) + // print('ARROW COLLIDED WITH::' + entityB); + Script.removeEventHandler(arrow, "collisionWithEntity", makeArrowStick) + } + + Script.addEventHandler(arrow, "collisionWithEntity", makeArrowStick); + + return arrow + }, + + createStrings: function() { + this.createTopString(); + this.createBottomString(); + }, + + createTopString: function() { + var stringProperties = { + name: 'Hifi-Bow-Top-String', + type: 'Line', + position: Vec3.sum(this.bowProperties.position, TOP_NOTCH_OFFSET), + dimensions: LINE_DIMENSIONS, + collisionsWillMove: false, + ignoreForCollisions: true, + userData: JSON.stringify({ + grabbableKey: { + grabbable: false + } + }) + }; + + this.topString = Entities.addEntity(stringProperties); + }, + + createBottomString: function() { + var stringProperties = { + name: 'Hifi-Bow-Bottom-String', + type: 'Line', + position: Vec3.sum(this.bowProperties.position, BOTTOM_NOTCH_OFFSET), + dimensions: LINE_DIMENSIONS, + collisionsWillMove: false, + ignoreForCollisions: true, + userData: JSON.stringify({ + grabbableKey: { + grabbable: false + } + }) + }; + + this.bottomString = Entities.addEntity(stringProperties); + }, + + deleteStrings: function() { + Entities.deleteEntity(this.topString); + Entities.deleteEntity(this.bottomString); + }, + + updateStringPositions: function() { + // print('update string positions!!!') + var upVector = Quat.getUp(this.bowProperties.rotation); + var upOffset = Vec3.multiply(upVector, TOP_NOTCH_OFFSET); + var downVector = Vec3.multiply(-1, Quat.getUp(this.bowProperties.rotation)); + var downOffset = Vec3.multiply(downVector, BOTTOM_NOTCH_OFFSET); + var backOffset = Vec3.multiply(-0.1, Quat.getFront(this.bowProperties.rotation)); + + var topStringPosition = Vec3.sum(this.bowProperties.position, upOffset); + this.topStringPosition = Vec3.sum(topStringPosition, backOffset); + var bottomStringPosition = Vec3.sum(this.bowProperties.position, downOffset); + this.bottomStringPosition = Vec3.sum(bottomStringPosition, backOffset); + + Entities.editEntity(this.preNotchString, { + position: this.topStringPosition + }); + + Entities.editEntity(this.topString, { + position: this.topStringPosition + }); + + Entities.editEntity(this.bottomString, { + position: this.bottomStringPosition + }); + + }, + + drawStrings: function() { + + this.updateStringPositions(); + var lineVectors = this.getLocalLineVectors(); + + Entities.editEntity(this.topString, { + linePoints: [{ + x: 0, + y: 0, + z: 0 + }, lineVectors[0]], + lineWidth: 5, + color: this.stringData.currentColor + }); + + Entities.editEntity(this.bottomString, { + linePoints: [{ + x: 0, + y: 0, + z: 0 + }, lineVectors[1]], + lineWidth: 5, + color: this.stringData.currentColor + }); + + }, + + getLocalLineVectors: function() { + var topVector = Vec3.subtract(this.arrowRearPosition, this.topStringPosition); + var bottomVector = Vec3.subtract(this.arrowRearPosition, this.bottomStringPosition); + return [topVector, bottomVector]; + }, + + createPreNotchString: function() { + this.bowProperties = Entities.getEntityProperties(_this.entityID, ["position", "rotation", "userData"]); + + var stringProperties = { + type: 'Line', + position: Vec3.sum(this.bowProperties.position, TOP_NOTCH_OFFSET), + dimensions: LINE_DIMENSIONS, + visible: true, + collisionsWillMove: false, + ignoreForCollisions: true, + userData: JSON.stringify({ + grabbableKey: { + grabbable: false + } + }) + }; + + this.preNotchString = Entities.addEntity(stringProperties); + }, + + drawPreNotchStrings: function() { + this.bowProperties = Entities.getEntityProperties(_this.entityID, ["position", "rotation", "userData"]); + + this.updateStringPositions(); + + var downVector = Vec3.multiply(-1, Quat.getUp(this.bowProperties.rotation)); + var downOffset = Vec3.multiply(downVector, BOTTOM_NOTCH_OFFSET * 2); + + Entities.editEntity(this.preNotchString, { + name: 'Hifi-Pre-Notch-String', + linePoints: [{ + x: 0, + y: 0, + z: 0 + }, Vec3.sum({ + x: 0, + y: 0, + z: 0 + }, downOffset)], + lineWidth: 5, + color: this.stringData.currentColor, + }); + }, + + checkStringHand: function() { + //invert the hands because our string will be held with the opposite hand of the first one we pick up the bow with + var triggerLookup; + if (this.initialHand === 'left') { + triggerLookup = 1; + this.getStringHandPosition = MyAvatar.getRightPalmPosition; + } else if (this.initialHand === 'right') { + this.getStringHandPosition = MyAvatar.getLeftPalmPosition; + triggerLookup = 0; + } + + this.triggerValue = Controller.getValue(TRIGGER_CONTROLS[triggerLookup]); + + + if (this.triggerValue < DRAW_STRING_THRESHOLD && this.stringDrawn === true) { + // firing the arrow + // print('HIT RELEASE LOOP IN CHECK'); + + this.drawStrings(); + this.hasArrowNotched = false; + this.aiming = false; + this.stringDrawn = false; + this.updateArrowPositionInNotch(true); + + + } else if (this.triggerValue > DRAW_STRING_THRESHOLD && this.stringDrawn === true) { + // print('HIT CONTINUE LOOP IN CHECK') + //continuing to aim the arrow + + this.aiming = true; + this.drawStrings(); + this.updateArrowPositionInNotch(); + + } else if (this.triggerValue > DRAW_STRING_THRESHOLD && this.stringDrawn === false) { + // print('HIT START LOOP IN CHECK'); + this.arrow = this.createArrow(); + this.playStringPullSound(); + + //the first time aiming the arrow + this.stringDrawn = true; + this.createStrings(); + this.drawStrings(); + this.updateArrowPositionInNotch(); + + } + }, + + setArrowRearPosition: function(arrowPosition, arrowRotation) { + var frontVector = Quat.getFront(arrowRotation); + var frontOffset = Vec3.multiply(frontVector, -ARROW_TIP_OFFSET); + var arrorRearPosition = Vec3.sum(arrowPosition, frontOffset); + this.arrowRearPosition = arrorRearPosition; + return arrorRearPosition; + + }, + + updateArrowPositionInNotch: function(shouldReleaseArrow) { + var bowProperties = Entities.getEntityProperties(this.entityID); + //set the notch that the arrow should go through + var frontVector = Quat.getFront(bowProperties.rotation); + var notchVectorForward = Vec3.multiply(frontVector, NOTCH_OFFSET_FORWARD); + var upVector = Quat.getUp(bowProperties.rotation); + var notchVectorUp = Vec3.multiply(upVector, NOTCH_OFFSET_UP); + var notchPosition; + notchPosition = Vec3.sum(bowProperties.position, notchVectorForward); + notchPosition = Vec3.sum(notchPosition, notchVectorUp); + + //set the arrow rotation to be between the notch and other hand + var stringHandPosition = this.getStringHandPosition(); + var handToNotch = Vec3.subtract(notchPosition, stringHandPosition); + var arrowRotation = Quat.rotationBetween(Vec3.FRONT, handToNotch); + + + + var pullBackDistance = Vec3.length(handToNotch); + // this.changeStringPullSoundVolume(pullBackDistance); + + if (pullBackDistance > 0.6) { + pullBackDistance = 0.6; + } + + // //pull the arrow back a bit + var pullBackOffset = Vec3.multiply(handToNotch, -pullBackDistance); + var arrowPosition = Vec3.sum(notchPosition, pullBackOffset); + + // // move it forward a bit + var pushForwardOffset = Vec3.multiply(handToNotch, -ARROW_OFFSET); + var finalArrowPosition = Vec3.sum(arrowPosition, pushForwardOffset); + + //we draw strings to the rear of the arrow + this.setArrowRearPosition(finalArrowPosition, arrowRotation); + + //if we're not shooting, we're updating the arrow's orientation + if (shouldReleaseArrow !== true) { + Entities.editEntity(this.arrow, { + position: finalArrowPosition, + rotation: arrowRotation + }) + } + + //shoot the arrow + if (shouldReleaseArrow === true) { + var arrowProps = Entities.getEntityProperties(this.arrow); + + //scale the shot strength by the distance you've pulled the arrow back and set its release velocity to be in the direction of the v + var arrowForce = this.scaleArrowShotStrength(pullBackDistance); + var handToNotch = Vec3.normalize(handToNotch); + + var releaseVelocity = Vec3.multiply(handToNotch, arrowForce); + // var releaseVelocity2 = Vec3.multiply() + + //make the arrow physical, give it gravity, a lifetime, and set our velocity + var arrowProperties = { + collisionsWillMove: true, + ignoreForCollisions: false, + velocity: releaseVelocity, + gravity: ARROW_GRAVITY, + lifetime: 10, + // position: arrowProps.position, + // rotation: arrowProps.rotation + }; + + //actually shoot the arrow and play its sound + Entities.editEntity(this.arrow, arrowProperties); + this.playShootArrowSound(); + + //clear the strings back to only the single straight one + this.deleteStrings(); + Entities.editEntity(this.preNotchString, { + visible: true + }); + + } + + }, + + scaleArrowShotStrength: function(value) { + var min1 = SHOT_SCALE.min1; + var max1 = SHOT_SCALE.max1; + var min2 = SHOT_SCALE.min2; + var max2 = SHOT_SCALE.max2; + return min2 + (max2 - min2) * ((value - min1) / (max1 - min1)); + }, + + playStringPullSound: function() { + var audioProperties = { + volume: 0.10, + position: this.bowProperties.position + }; + this.stringPullInjector = Audio.playSound(this.stringPullSound, audioProperties); + }, + + playShootArrowSound: function(sound) { + var audioProperties = { + volume: 0.15, + position: this.bowProperties.position + }; + Audio.playSound(this.shootArrowSound, audioProperties); + }, + + playArrowNotchSound: function() { + var audioProperties = { + volume: 0.15, + position: this.bowProperties.position + }; + Audio.playSound(this.arrowNotchSound, audioProperties); + }, + + changeStringPullSoundVolume: function(pullBackDistance) { + var audioProperties = { + volume: this.scaleSoundVolume(pullBackDistance), + position: this.bowProperties.position + } + + this.stringPullInjector.options = audioProperties; + }, + scaleSoundVolume: function(value) { + var min1 = SHOT_SCALE.min1; + var max1 = SHOT_SCALE.max1; + var min2 = 0; + var max2 = 0.2; + return min2 + (max2 - min2) * ((value - min1) / (max1 - min1)); + } + + }; + + return new Bow(); +}); \ No newline at end of file diff --git a/examples/toybox/bow/createBow.js b/examples/toybox/bow/createBow.js new file mode 100644 index 0000000000..880b0920e8 --- /dev/null +++ b/examples/toybox/bow/createBow.js @@ -0,0 +1,66 @@ +// +// createBow.js +// +// Created byJames Pollack @imgntn on 10/19/2015 +// Copyright 2015 High Fidelity, Inc. +// +// This script creates a bow you can use to shoot an arrow. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html +// + + +var SCRIPT_URL = Script.resolvePath('bow.js'); + +var MODEL_URL = "https://hifi-public.s3.amazonaws.com/models/bow/new/bow-deadly.fbx"; +var COLLISION_HULL_URL = "https://hifi-public.s3.amazonaws.com/models/bow/new/bow_collision_hull.obj"; +var BOW_DIMENSIONS = { + x: 0.04, + y: 1.3, + z: 0.21 +}; + +var BOW_GRAVITY = { + x: 0, + y: 0, + z: 0 +} + +var center = Vec3.sum(Vec3.sum(MyAvatar.position, { + x: 0, + y: 0.5, + z: 0 +}), Vec3.multiply(1, Quat.getFront(Camera.getOrientation()))); + +var bow = Entities.addEntity({ + name: 'Hifi-Bow', + type: "Model", + modelURL: MODEL_URL, + position: center, + dimensions: BOW_DIMENSIONS, + collisionsWillMove: true, + gravity: BOW_GRAVITY, + shapeType: 'compound', + compoundShapeURL: COLLISION_HULL_URL, + script: SCRIPT_URL, + userData: JSON.stringify({ + grabbableKey: { + invertSolidWhileHeld: true, + spatialKey: { + relativePosition: { + x: 0, + y: 0.06, + z: 0.11 + }, + relativeRotation: Quat.fromPitchYawRollDegrees(0, -90, 90) + } + } + }) +}); + +function cleanup() { + Entities.deleteEntity(bow); +} + +Script.scriptEnding.connect(cleanup); \ No newline at end of file diff --git a/examples/toybox/ping_pong_gun/createTargets.js b/examples/toybox/ping_pong_gun/createTargets.js index fde0d6f54a..c421352a9d 100644 --- a/examples/toybox/ping_pong_gun/createTargets.js +++ b/examples/toybox/ping_pong_gun/createTargets.js @@ -39,6 +39,8 @@ var startPosition = { z: 509.74 }; +startPosition = MyAvatar.position; + var rotation = Quat.fromPitchYawRollDegrees(0, -55.25, 0); var targetIntervalClearer = Entities.addEntity({ diff --git a/interface/src/Menu.cpp b/interface/src/Menu.cpp index 2b82587bbc..41e65daaf8 100644 --- a/interface/src/Menu.cpp +++ b/interface/src/Menu.cpp @@ -949,6 +949,7 @@ void Menu::addMenuItem(const MenuItemProperties& properties) { QShortcut* shortcut = NULL; if (!properties.shortcutKeySequence.isEmpty()) { shortcut = new QShortcut(properties.shortcutKeySequence, this); + shortcut->setContext(Qt::WidgetWithChildrenShortcut); } // check for positioning requests diff --git a/libraries/ui/src/VrMenu.cpp b/libraries/ui/src/VrMenu.cpp index 211e0e0f72..41cf27efb2 100644 --- a/libraries/ui/src/VrMenu.cpp +++ b/libraries/ui/src/VrMenu.cpp @@ -183,6 +183,10 @@ void VrMenu::insertAction(QAction* before, QAction* action) { } void VrMenu::removeAction(QAction* action) { + if (!action) { + qWarning("Attempted to remove invalid menu action"); + return; + } MenuUserData* userData = MenuUserData::forObject(action); if (!userData) { qWarning("Attempted to remove menu action with no found QML object"); diff --git a/unpublishedScripts/hiddenEntityReset.js b/unpublishedScripts/hiddenEntityReset.js index cf9eaaa451..6ffa3fdecf 100644 --- a/unpublishedScripts/hiddenEntityReset.js +++ b/unpublishedScripts/hiddenEntityReset.js @@ -22,6 +22,7 @@ var dollScriptURL = Script.resolvePath("../examples/toybox/doll/doll.js"); var lightsScriptURL = Script.resolvePath("../examples/toybox/lights/lightSwitch.js"); var targetsScriptURL = Script.resolvePath('../examples/toybox/ping_pong_gun/wallTarget.js'); + var bowScriptURL = Script.resolvePath('../examples/toybox/bow/bow.js'); var basketballResetterScriptURL = Script.resolvePath('basketballsResetter.js'); var targetsResetterScriptURL = Script.resolvePath('targetsResetter.js'); @@ -134,6 +135,9 @@ y: 495.6, z: 503.91 }); + + createBow(); + } function deleteAllToys() { @@ -148,6 +152,63 @@ }); } + function createBow() { + + var startPosition = { + x: 546.41, + y: 495.33, + z: 506.46 + }; + + var BOW_ROTATION = Quat.fromPitchYawRollDegrees(-103.05, -178.60, -87.27); + + var MODEL_URL = "https://hifi-public.s3.amazonaws.com/models/bow/new/bow-deadly.fbx"; + var COLLISION_HULL_URL = "https://hifi-public.s3.amazonaws.com/models/bow/new/bow_collision_hull.obj"; + var BOW_DIMENSIONS = { + x: 0.04, + y: 1.3, + z: 0.21 + }; + + var BOW_GRAVITY = { + x: 0, + y: -9.8, + z: 0 + }; + + var bow = Entities.addEntity({ + name: 'Hifi-Bow', + type: "Model", + modelURL: MODEL_URL, + position: startPosition, + rotation: BOW_ROTATION, + dimensions: BOW_DIMENSIONS, + collisionsWillMove: true, + gravity: BOW_GRAVITY, + shapeType: 'compound', + compoundShapeURL: COLLISION_HULL_URL, + script: bowScriptURL, + userData: JSON.stringify({ + resetMe: { + resetMe: true + }, + grabbableKey: { + invertSolidWhileHeld: true, + spatialKey: { + relativePosition: { + x: 0, + y: 0.06, + z: 0.11 + }, + relativeRotation: Quat.fromPitchYawRollDegrees(0, -90, 90) + } + } + }) + }); + + } + + function createFire() { @@ -1250,6 +1311,7 @@ } } + function cleanup() { deleteAllToys(); } diff --git a/unpublishedScripts/masterReset.js b/unpublishedScripts/masterReset.js index 60b4e7a72f..faee936edc 100644 --- a/unpublishedScripts/masterReset.js +++ b/unpublishedScripts/masterReset.js @@ -21,6 +21,7 @@ var pingPongScriptURL = Script.resolvePath('../examples/toybox/ping_pong_gun/pin var wandScriptURL = Script.resolvePath("../examples/toybox/bubblewand/wand.js"); var dollScriptURL = Script.resolvePath("../examples/toybox/doll/doll.js"); var lightsScriptURL = Script.resolvePath("../examples/toybox/lights/lightSwitch.js"); +var bowScriptURL = Script.resolvePath("../examples/toybox/bow/bow.js"); var targetsScriptURL = Script.resolvePath('../examples/toybox/ping_pong_gun/wallTarget.js'); var basketballResetterScriptURL = Script.resolvePath('basketballsResetter.js'); var targetsResetterScriptURL = Script.resolvePath('targetsResetter.js'); @@ -36,6 +37,8 @@ MasterReset = function() { deleteAllToys(); createAllToys(); + + function createAllToys() { createBlocks({ x: 548.3, @@ -111,7 +114,7 @@ MasterReset = function() { z: 503.91 }); - + createBow(); } @@ -127,6 +130,62 @@ MasterReset = function() { }); } + function createBow() { + + var startPosition = { + x: 546.41, + y: 495.33, + z: 506.46 + }; + + var BOW_ROTATION = Quat.fromPitchYawRollDegrees(-103.05, -178.60, -87.27); + + var MODEL_URL = "https://hifi-public.s3.amazonaws.com/models/bow/new/bow-deadly.fbx"; + var COLLISION_HULL_URL = "https://hifi-public.s3.amazonaws.com/models/bow/new/bow_collision_hull.obj"; + var BOW_DIMENSIONS = { + x: 0.04, + y: 1.3, + z: 0.21 + }; + + var BOW_GRAVITY = { + x: 0, + y: -9.8, + z: 0 + }; + + var bow = Entities.addEntity({ + name: 'Hifi-Bow', + type: "Model", + modelURL: MODEL_URL, + position: startPosition, + rotation: BOW_ROTATION, + dimensions: BOW_DIMENSIONS, + collisionsWillMove: true, + gravity: BOW_GRAVITY, + shapeType: 'compound', + compoundShapeURL: COLLISION_HULL_URL, + script: bowScriptURL, + userData: JSON.stringify({ + resetMe: { + resetMe: true + }, + grabbableKey: { + invertSolidWhileHeld: true, + spatialKey: { + relativePosition: { + x: 0, + y: 0.06, + z: 0.11 + }, + relativeRotation: Quat.fromPitchYawRollDegrees(0, -90, 90) + } + } + }) + }); + + } + function createFire() { @@ -883,7 +942,7 @@ MasterReset = function() { type: "Model", modelURL: MODEL_URL, shapeType: 'compound', - compoundShapeURL:COLLISION_HULL_URL, + compoundShapeURL: COLLISION_HULL_URL, script: pingPongScriptURL, position: position, rotation: rotation,