From 0b31971592b1fc243cdb6976aa318969ff65b38c Mon Sep 17 00:00:00 2001 From: Atlante45 Date: Fri, 30 May 2014 10:42:54 -0700 Subject: [PATCH 1/6] Update joints list everytime I try to attach --- examples/editModels.js | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/examples/editModels.js b/examples/editModels.js index 1db6901e23..77bc14643f 100644 --- a/examples/editModels.js +++ b/examples/editModels.js @@ -157,9 +157,7 @@ function controller(wichSide) { this.release = function () { if (this.grabbing) { - if (jointList.length <= 0) { - jointList = MyAvatar.getJointNames(); - } + jointList = MyAvatar.getJointNames(); var closestJointIndex = -1; var closestJointDistance = 10; From 9d59251d2794791269f5eee8b28c219bb3b37864 Mon Sep 17 00:00:00 2001 From: Philip Rosedale Date: Fri, 30 May 2014 10:47:51 -0700 Subject: [PATCH 2/6] =?UTF-8?q?add=20keyboard=20shortcut=20(=E2=80=9C.?= =?UTF-8?q?=E2=80=9D)=20to=20toggle=20sitting,=20so=20that=20Oculus=20user?= =?UTF-8?q?=20can=20sit?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- examples/sit.js | 62 ++++++++++++++++++++++++++++++++++--------------- 1 file changed, 43 insertions(+), 19 deletions(-) diff --git a/examples/sit.js b/examples/sit.js index 1df877dba6..6ae8a712f1 100644 --- a/examples/sit.js +++ b/examples/sit.js @@ -40,6 +40,8 @@ var passedTime = 0.0; var startPosition = null; var animationLenght = 2.0; +var sitting = false; + // This is the pose we would like to end up var pose = [ {joint:"RightUpLeg", rotation: {x:100.0, y:15.0, z:0.0}}, @@ -101,31 +103,41 @@ var standingUpAnimation = function(deltaTime){ } } +function sitDown() { + sitting = true; + passedTime = 0.0; + startPosition = MyAvatar.position; + storeStartPoseAndTransition(); + try{ + Script.update.disconnect(standingUpAnimation); + } catch(e){ + // no need to handle. if it wasn't connected no harm done + } + Script.update.connect(sittingDownAnimation); + Overlays.editOverlay(sitDownButton, { visible: false }); + Overlays.editOverlay(standUpButton, { visible: true }); +} + +function standUp() { + sitting = false; + passedTime = 0.0; + startPosition = MyAvatar.position; + try{ + Script.update.disconnect(sittingDownAnimation); + } catch (e){} + Script.update.connect(standingUpAnimation); + Overlays.editOverlay(standUpButton, { visible: false }); + Overlays.editOverlay(sitDownButton, { visible: true }); +} + Controller.mousePressEvent.connect(function(event){ var clickedOverlay = Overlays.getOverlayAtPoint({x: event.x, y: event.y}); if (clickedOverlay == sitDownButton) { - passedTime = 0.0; - startPosition = MyAvatar.position; - storeStartPoseAndTransition(); - try{ - Script.update.disconnect(standingUpAnimation); - } catch(e){ - // no need to handle. if it wasn't connected no harm done - } - Script.update.connect(sittingDownAnimation); - Overlays.editOverlay(sitDownButton, { visible: false }); - Overlays.editOverlay(standUpButton, { visible: true }); + sitDown(); } else if (clickedOverlay == standUpButton) { - passedTime = 0.0; - startPosition = MyAvatar.position; - try{ - Script.update.disconnect(sittingDownAnimation); - } catch (e){} - Script.update.connect(standingUpAnimation); - Overlays.editOverlay(standUpButton, { visible: false }); - Overlays.editOverlay(sitDownButton, { visible: true }); + standUp(); } }) @@ -140,7 +152,19 @@ function update(deltaTime){ } } +function keyPressEvent(event) { + if (event.text === ".") { + if (sitting) { + standUp(); + } else { + sitDown(); + } + } +} + + Script.update.connect(update); +Controller.keyPressEvent.connect(keyPressEvent); Script.scriptEnding.connect(function() { From 164192fb508bb356b13928a4a76b941cf5e0175f Mon Sep 17 00:00:00 2001 From: Andrzej Kapolka Date: Fri, 30 May 2014 11:03:46 -0700 Subject: [PATCH 3/6] If the skeleton doesn't have eye joints (as with the Fuse models), make up some positions based on the head and neck joints. --- interface/src/avatar/SkeletonModel.cpp | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/interface/src/avatar/SkeletonModel.cpp b/interface/src/avatar/SkeletonModel.cpp index 3586e525ae..ef5fc3d34b 100644 --- a/interface/src/avatar/SkeletonModel.cpp +++ b/interface/src/avatar/SkeletonModel.cpp @@ -427,7 +427,25 @@ bool SkeletonModel::getEyePositions(glm::vec3& firstEyePosition, glm::vec3& seco return false; } const FBXGeometry& geometry = _geometry->getFBXGeometry(); - return getJointPosition(geometry.leftEyeJointIndex, firstEyePosition) && - getJointPosition(geometry.rightEyeJointIndex, secondEyePosition); + if (getJointPosition(geometry.leftEyeJointIndex, firstEyePosition) && + getJointPosition(geometry.rightEyeJointIndex, secondEyePosition)) { + return true; + } + // no eye joints; try to estimate based on head/neck joints + glm::vec3 neckPosition, headPosition; + if (getJointPosition(geometry.neckJointIndex, neckPosition) && + getJointPosition(geometry.headJointIndex, headPosition)) { + const float EYE_PROPORTION = 0.6f; + glm::vec3 baseEyePosition = glm::mix(neckPosition, headPosition, EYE_PROPORTION); + glm::quat headRotation; + getJointRotation(geometry.headJointIndex, headRotation); + const float EYES_FORWARD = 0.25f; + const float EYE_SEPARATION = 0.1f; + float headHeight = glm::distance(neckPosition, headPosition); + firstEyePosition = baseEyePosition + headRotation * glm::vec3(EYE_SEPARATION, 0.0f, EYES_FORWARD) * headHeight; + secondEyePosition = baseEyePosition + headRotation * glm::vec3(-EYE_SEPARATION, 0.0f, EYES_FORWARD) * headHeight; + return true; + } + return false; } From 8a4955d75bee591d3d4ed4689a36ea525226f2f1 Mon Sep 17 00:00:00 2001 From: ZappoMan Date: Fri, 30 May 2014 11:13:37 -0700 Subject: [PATCH 4/6] temporarily disable the model aligned box picking --- libraries/models/src/ModelTreeElement.cpp | 37 +++++++++++++++-------- 1 file changed, 25 insertions(+), 12 deletions(-) diff --git a/libraries/models/src/ModelTreeElement.cpp b/libraries/models/src/ModelTreeElement.cpp index c655a45b57..e5116e316c 100644 --- a/libraries/models/src/ModelTreeElement.cpp +++ b/libraries/models/src/ModelTreeElement.cpp @@ -192,21 +192,34 @@ bool ModelTreeElement::findDetailedRayIntersection(const glm::vec3& origin, cons // if it's in our AABOX for our rotated extents, then check to see if it's in our non-AABox if (rotatedExtentsBox.findRayIntersection(origin, direction, localDistance, localFace)) { + + // This is experimental code that doesn't quite work, so I'm disabling it by default, but + // leaving it in because I need to work on it and fix it to work properly. + bool pickAgainstModelAlignedBox = false; + + if (pickAgainstModelAlignedBox) { + // extents is the model relative, scaled, centered extents of the model + glm::mat4 rotation = glm::mat4_cast(model.getModelRotation()); + glm::mat4 translation = glm::translate(model.getPosition()); + glm::mat4 modelToWorldMatrix = translation * rotation; + glm::mat4 worldToModelMatrix = glm::inverse(modelToWorldMatrix); - // extents is the model relative, scaled, centered extents of the model - glm::mat4 rotation = glm::mat4_cast(model.getModelRotation()); - glm::mat4 translation = glm::translate(model.getPosition()); - glm::mat4 modelToWorldMatrix = translation * rotation; - glm::mat4 worldToModelMatrix = glm::inverse(modelToWorldMatrix); + AABox modelFrameBox(extents.minimum, (extents.maximum - extents.minimum)); - AABox modelFrameBox(extents.minimum, (extents.maximum - extents.minimum)); + glm::vec3 modelFrameOrigin = glm::vec3(worldToModelMatrix * glm::vec4(origin, 1.0f)); + glm::vec3 modelFrameDirection = glm::vec3(worldToModelMatrix * glm::vec4(direction, 1.0f)); - glm::vec3 modelFrameOrigin = glm::vec3(worldToModelMatrix * glm::vec4(origin, 1.0f)); - glm::vec3 modelFrameDirection = glm::vec3(worldToModelMatrix * glm::vec4(direction, 1.0f)); - - // we can use the AABox's ray intersection by mapping our origin and direction into the model frame - // and testing intersection there. - if (modelFrameBox.findRayIntersection(modelFrameOrigin, modelFrameDirection, localDistance, localFace)) { + // we can use the AABox's ray intersection by mapping our origin and direction into the model frame + // and testing intersection there. + if (modelFrameBox.findRayIntersection(modelFrameOrigin, modelFrameDirection, localDistance, localFace)) { + if (localDistance < distance) { + distance = localDistance; + face = localFace; + *intersectedObject = (void*)(&model); + somethingIntersected = true; + } + } + } else { if (localDistance < distance) { distance = localDistance; face = localFace; From d48a5dd3059d97283dca186d1470f7a880d5cf30 Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Fri, 30 May 2014 14:54:25 -0700 Subject: [PATCH 5/6] don't force OAuthWebViewHandler to stay on top --- interface/src/ui/OAuthWebViewHandler.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/interface/src/ui/OAuthWebViewHandler.cpp b/interface/src/ui/OAuthWebViewHandler.cpp index e93321212c..5415d5d9c3 100644 --- a/interface/src/ui/OAuthWebViewHandler.cpp +++ b/interface/src/ui/OAuthWebViewHandler.cpp @@ -82,7 +82,7 @@ void OAuthWebViewHandler::displayWebviewForAuthorizationURL(const QUrl& authoriz _activeWebView = new QWebView; // keep the window on top and delete it when it closes - _activeWebView->setWindowFlags(Qt::Sheet | Qt::WindowStaysOnTopHint); + _activeWebView->setWindowFlags(Qt::Sheet); _activeWebView->setAttribute(Qt::WA_DeleteOnClose); qDebug() << "Displaying QWebView for OAuth authorization at" << authorizationURL.toString(); From b212f9edca896abdc1a6cb8c9d42222b0f7b1a26 Mon Sep 17 00:00:00 2001 From: ZappoMan Date: Fri, 30 May 2014 15:07:54 -0700 Subject: [PATCH 6/6] fix ray picking at distances --- libraries/models/src/ModelTreeElement.cpp | 35 +++++++---------------- 1 file changed, 11 insertions(+), 24 deletions(-) diff --git a/libraries/models/src/ModelTreeElement.cpp b/libraries/models/src/ModelTreeElement.cpp index e5116e316c..b87557d073 100644 --- a/libraries/models/src/ModelTreeElement.cpp +++ b/libraries/models/src/ModelTreeElement.cpp @@ -193,33 +193,20 @@ bool ModelTreeElement::findDetailedRayIntersection(const glm::vec3& origin, cons // if it's in our AABOX for our rotated extents, then check to see if it's in our non-AABox if (rotatedExtentsBox.findRayIntersection(origin, direction, localDistance, localFace)) { - // This is experimental code that doesn't quite work, so I'm disabling it by default, but - // leaving it in because I need to work on it and fix it to work properly. - bool pickAgainstModelAlignedBox = false; - - if (pickAgainstModelAlignedBox) { - // extents is the model relative, scaled, centered extents of the model - glm::mat4 rotation = glm::mat4_cast(model.getModelRotation()); - glm::mat4 translation = glm::translate(model.getPosition()); - glm::mat4 modelToWorldMatrix = translation * rotation; - glm::mat4 worldToModelMatrix = glm::inverse(modelToWorldMatrix); + // extents is the model relative, scaled, centered extents of the model + glm::mat4 rotation = glm::mat4_cast(model.getModelRotation()); + glm::mat4 translation = glm::translate(model.getPosition()); + glm::mat4 modelToWorldMatrix = translation * rotation; + glm::mat4 worldToModelMatrix = glm::inverse(modelToWorldMatrix); - AABox modelFrameBox(extents.minimum, (extents.maximum - extents.minimum)); + AABox modelFrameBox(extents.minimum, (extents.maximum - extents.minimum)); - glm::vec3 modelFrameOrigin = glm::vec3(worldToModelMatrix * glm::vec4(origin, 1.0f)); - glm::vec3 modelFrameDirection = glm::vec3(worldToModelMatrix * glm::vec4(direction, 1.0f)); + glm::vec3 modelFrameOrigin = glm::vec3(worldToModelMatrix * glm::vec4(origin, 1.0f)); + glm::vec3 modelFrameDirection = glm::vec3(worldToModelMatrix * glm::vec4(direction, 0.0f)); - // we can use the AABox's ray intersection by mapping our origin and direction into the model frame - // and testing intersection there. - if (modelFrameBox.findRayIntersection(modelFrameOrigin, modelFrameDirection, localDistance, localFace)) { - if (localDistance < distance) { - distance = localDistance; - face = localFace; - *intersectedObject = (void*)(&model); - somethingIntersected = true; - } - } - } else { + // we can use the AABox's ray intersection by mapping our origin and direction into the model frame + // and testing intersection there. + if (modelFrameBox.findRayIntersection(modelFrameOrigin, modelFrameDirection, localDistance, localFace)) { if (localDistance < distance) { distance = localDistance; face = localFace;