From 30199106ecf5ea10ec5fdca726f3c6668e6ffae7 Mon Sep 17 00:00:00 2001 From: Philip Rosedale Date: Wed, 13 Jan 2016 20:47:05 -0800 Subject: [PATCH 1/3] Choice of hand ray pick or head pick --- examples/controllers/handControllerGrab.js | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/examples/controllers/handControllerGrab.js b/examples/controllers/handControllerGrab.js index be5fdd7edb..c40aa065b8 100644 --- a/examples/controllers/handControllerGrab.js +++ b/examples/controllers/handControllerGrab.js @@ -33,6 +33,8 @@ var BUMPER_ON_VALUE = 0.5; var HAND_HEAD_MIX_RATIO = 0.0; // 0 = only use hands for search/move. 1 = only use head for search/move. +var PICK_WITH_HAND_RAY = true; + // // distant manipulation // @@ -903,8 +905,9 @@ function MyController(hand) { var handDeltaRotation = Quat.multiply(currentHandRotation, Quat.inverse(this.startingHandRotation)); var distantPickRay = { - origin: Camera.position, - direction: Vec3.mix(Quat.getUp(this.getHandRotation()), Quat.getFront(Camera.orientation), HAND_HEAD_MIX_RATIO), + origin: PICK_WITH_HAND_RAY ? handPosition : Camera.position, + direction: PICK_WITH_HAND_RAY ? Quat.getUp(this.getHandRotation()) : + Vec3.mix(Quat.getUp(this.getHandRotation()), Quat.getFront(Camera.orientation), HAND_HEAD_MIX_RATIO), length: PICK_MAX_DISTANCE }; @@ -1143,10 +1146,6 @@ function MyController(hand) { this.handleParticleBeam(distantPickRay.origin, this.getHandRotation(), NO_INTERSECT_COLOR); } - if (USE_OVERLAY_LINES_FOR_SEARCHING === true) { - this.overlayLineOn(searchVisualizationPickRay.origin, Vec3.sum(searchVisualizationPickRay.origin, Vec3.multiply(searchVisualizationPickRay.direction, LINE_LENGTH)), NO_INTERSECT_COLOR); - } - if (this.intersectionDistance > 0) { var SPHERE_INTERSECTION_SIZE = 0.011; var SEARCH_SPHERE_FOLLOW_RATE = 0.50; @@ -1155,7 +1154,7 @@ function MyController(hand) { var searchSphereLocation = Vec3.sum(distantPickRay.origin, Vec3.multiply(distantPickRay.direction, this.searchSphereDistance)); searchSphereLocation.y -= ((this.intersectionDistance - this.searchSphereDistance) / this.intersectionDistance) * SEARCH_SPHERE_CHASE_DROP; this.searchSphereOn(searchSphereLocation, SPHERE_INTERSECTION_SIZE * this.intersectionDistance, this.triggerSmoothedGrab() ? INTERSECT_COLOR : NO_INTERSECT_COLOR); - if (USE_OVERLAY_LINES_FOR_SEARCHING === true) { + if ((USE_OVERLAY_LINES_FOR_SEARCHING === true) && PICK_WITH_HAND_RAY) { this.overlayLineOn(handPosition, searchSphereLocation, this.triggerSmoothedGrab() ? INTERSECT_COLOR : NO_INTERSECT_COLOR); } } From 23a8d57ca2c0e95453b1b88756ec0cd6d5799c31 Mon Sep 17 00:00:00 2001 From: Philip Rosedale Date: Sun, 17 Jan 2016 14:14:00 -0800 Subject: [PATCH 2/3] Always show search ray --- examples/controllers/handControllerGrab.js | 28 +++++++++++----------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/examples/controllers/handControllerGrab.js b/examples/controllers/handControllerGrab.js index fa38c3f56e..d4fcf6390f 100644 --- a/examples/controllers/handControllerGrab.js +++ b/examples/controllers/handControllerGrab.js @@ -304,8 +304,10 @@ function MyController(hand) { this.searchSphere = null; // how far from camera to search intersection? + var DEFAULT_SEARCH_SPHERE_DISTANCE = 1000; this.intersectionDistance = 0.0; - this.searchSphereDistance = 0.0; + this.searchSphereDistance = DEFAULT_SEARCH_SPHERE_DISTANCE; + this.ignoreIK = false; this.offsetPosition = Vec3.ZERO; @@ -458,7 +460,6 @@ function MyController(hand) { visible: true, alpha: 1 }; - this.overlayLine = Overlays.addOverlay("line3d", lineProperties); } else { @@ -701,10 +702,9 @@ function MyController(hand) { this.searchSphereOff = function() { if (this.searchSphere !== null) { - //Overlays.editOverlay(this.searchSphere, { visible: false }); Overlays.deleteOverlay(this.searchSphere); this.searchSphere = null; - this.searchSphereDistance = 0.0; + this.searchSphereDistance = DEFAULT_SEARCH_SPHERE_DISTANCE; this.intersectionDistance = 0.0; } @@ -945,18 +945,18 @@ function MyController(hand) { this.handleParticleBeam(distantPickRay.origin, this.getHandRotation(), NO_INTERSECT_COLOR); } - if (this.intersectionDistance > 0) { - var SPHERE_INTERSECTION_SIZE = 0.011; - var SEARCH_SPHERE_FOLLOW_RATE = 0.50; - var SEARCH_SPHERE_CHASE_DROP = 0.2; + var SPHERE_INTERSECTION_SIZE = 0.011; + var SEARCH_SPHERE_FOLLOW_RATE = 0.50; + if (this.intersectionDistance > 0) { + // If we hit something with our pick ray, move the search sphere toward that distance this.searchSphereDistance = this.searchSphereDistance * SEARCH_SPHERE_FOLLOW_RATE + this.intersectionDistance * (1.0 - SEARCH_SPHERE_FOLLOW_RATE); - var searchSphereLocation = Vec3.sum(distantPickRay.origin, Vec3.multiply(distantPickRay.direction, this.searchSphereDistance)); - searchSphereLocation.y -= ((this.intersectionDistance - this.searchSphereDistance) / this.intersectionDistance) * SEARCH_SPHERE_CHASE_DROP; - this.searchSphereOn(searchSphereLocation, SPHERE_INTERSECTION_SIZE * this.intersectionDistance, this.triggerSmoothedGrab() ? INTERSECT_COLOR : NO_INTERSECT_COLOR); - if ((USE_OVERLAY_LINES_FOR_SEARCHING === true) && PICK_WITH_HAND_RAY) { - this.overlayLineOn(handPosition, searchSphereLocation, this.triggerSmoothedGrab() ? INTERSECT_COLOR : NO_INTERSECT_COLOR); - } + } + + var searchSphereLocation = Vec3.sum(distantPickRay.origin, Vec3.multiply(distantPickRay.direction, this.searchSphereDistance)); + this.searchSphereOn(searchSphereLocation, SPHERE_INTERSECTION_SIZE * this.searchSphereDistance, this.triggerSmoothedGrab() ? INTERSECT_COLOR : NO_INTERSECT_COLOR); + if ((USE_OVERLAY_LINES_FOR_SEARCHING === true) && PICK_WITH_HAND_RAY) { + this.overlayLineOn(handPosition, searchSphereLocation, this.triggerSmoothedGrab() ? INTERSECT_COLOR : NO_INTERSECT_COLOR); } }; From 9b3155188da141ef1e78175e1a56cd03a3868ea8 Mon Sep 17 00:00:00 2001 From: Philip Rosedale Date: Sun, 17 Jan 2016 19:10:40 -0800 Subject: [PATCH 3/3] Squeeze a little to search, a lot to grab --- examples/controllers/handControllerGrab.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/examples/controllers/handControllerGrab.js b/examples/controllers/handControllerGrab.js index d4fcf6390f..7721366bab 100644 --- a/examples/controllers/handControllerGrab.js +++ b/examples/controllers/handControllerGrab.js @@ -853,7 +853,7 @@ function MyController(hand) { intersection = Entities.findRayIntersection(pickRayBacked, true, [], blacklist); } else { intersection = Entities.findRayIntersection(pickRayBacked, true); - } + } if (intersection.intersects) { rayPickedCandidateEntities.push(intersection.entityID); @@ -900,8 +900,8 @@ function MyController(hand) { grabbableData = grabbableDataForCandidate; } } - if (this.grabbedEntity !== null) { - // We've found an entity that we'll do something with. + if ((this.grabbedEntity !== null) && (this.triggerSmoothedGrab() || this.bumperSqueezed())) { + // We are squeezing enough to grab, and we've found an entity that we'll try to do something with. var near = (nearPickedCandidateEntities.indexOf(this.grabbedEntity) >= 0); var isPhysical = this.propsArePhysical(props); @@ -945,7 +945,7 @@ function MyController(hand) { this.handleParticleBeam(distantPickRay.origin, this.getHandRotation(), NO_INTERSECT_COLOR); } - var SPHERE_INTERSECTION_SIZE = 0.011; + var SEARCH_SPHERE_SIZE = 0.011; var SEARCH_SPHERE_FOLLOW_RATE = 0.50; if (this.intersectionDistance > 0) { @@ -954,9 +954,9 @@ function MyController(hand) { } var searchSphereLocation = Vec3.sum(distantPickRay.origin, Vec3.multiply(distantPickRay.direction, this.searchSphereDistance)); - this.searchSphereOn(searchSphereLocation, SPHERE_INTERSECTION_SIZE * this.searchSphereDistance, this.triggerSmoothedGrab() ? INTERSECT_COLOR : NO_INTERSECT_COLOR); + this.searchSphereOn(searchSphereLocation, SEARCH_SPHERE_SIZE * this.searchSphereDistance, (this.triggerSmoothedGrab() || this.bumperSqueezed()) ? INTERSECT_COLOR : NO_INTERSECT_COLOR); if ((USE_OVERLAY_LINES_FOR_SEARCHING === true) && PICK_WITH_HAND_RAY) { - this.overlayLineOn(handPosition, searchSphereLocation, this.triggerSmoothedGrab() ? INTERSECT_COLOR : NO_INTERSECT_COLOR); + this.overlayLineOn(handPosition, searchSphereLocation, (this.triggerSmoothedGrab() || this.bumperSqueezed()) ? INTERSECT_COLOR : NO_INTERSECT_COLOR); } };