From e60c671c0533395747138b3d7c74d7b503432666 Mon Sep 17 00:00:00 2001 From: barnold1953 Date: Wed, 4 Jun 2014 17:24:20 -0700 Subject: [PATCH 1/6] Switched Oculus UI to hemisphere. Added curved semicircle UI --- interface/src/Application.cpp | 6 - interface/src/ui/ApplicationOverlay.cpp | 239 ++++++++++++++++++++---- interface/src/ui/ApplicationOverlay.h | 14 +- 3 files changed, 215 insertions(+), 44 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index c877822a45..721eb86410 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -1007,12 +1007,6 @@ void Application::keyPressEvent(QKeyEvent* event) { case Qt::Key_At: Menu::getInstance()->goTo(); break; - case Qt::Key_B: - _applicationOverlay.setOculusAngle(_applicationOverlay.getOculusAngle() - RADIANS_PER_DEGREE); - break; - case Qt::Key_N: - _applicationOverlay.setOculusAngle(_applicationOverlay.getOculusAngle() + RADIANS_PER_DEGREE); - break; default: event->ignore(); break; diff --git a/interface/src/ui/ApplicationOverlay.cpp b/interface/src/ui/ApplicationOverlay.cpp index 5869394f04..823e7b93e6 100644 --- a/interface/src/ui/ApplicationOverlay.cpp +++ b/interface/src/ui/ApplicationOverlay.cpp @@ -22,7 +22,8 @@ ApplicationOverlay::ApplicationOverlay() : _framebufferObject(NULL), _oculusAngle(65.0f * RADIANS_PER_DEGREE), - _distance(0.5f) { + _distance(0.5f), + _uiType(HEMISPHERE) { } @@ -305,6 +306,8 @@ inline float min(float a, float b) { return (a < b) ? a : b; } +const float textureFov = PI / 2.5f; + // Draws the FBO texture for Oculus rift. TODO: Draw a curved texture instead of plane. void ApplicationOverlay::displayOverlayTextureOculus(Camera& whichCamera) { @@ -316,8 +319,8 @@ void ApplicationOverlay::displayOverlayTextureOculus(Camera& whichCamera) { int mouseX = application->getMouseX(); int mouseY = application->getMouseY(); - int widgetWidth = glWidget->width(); - int widgetHeight = glWidget->height(); + const int widgetWidth = glWidget->width(); + const int widgetHeight = glWidget->height(); float magnifyWidth = 80.0f; float magnifyHeight = 60.0f; const float magnification = 4.0f; @@ -327,17 +330,22 @@ void ApplicationOverlay::displayOverlayTextureOculus(Camera& whichCamera) { const float verticalAngle = halfVerticalAngle * 2.0f; const float overlayAspectRatio = glWidget->width() / (float)glWidget->height(); const float halfOverlayHeight = _distance * tan(halfVerticalAngle); + const float overlayHeight = halfOverlayHeight * 2.0f; // The more vertices, the better the curve const int numHorizontalVertices = 20; + const int numVerticalVertices = 20; // U texture coordinate width at each quad const float quadTexWidth = 1.0f / (numHorizontalVertices - 1); + const float quadTexHeight = 1.0f / (numVerticalVertices - 1); // Get horizontal angle and angle increment from vertical angle and aspect ratio const float horizontalAngle = halfVerticalAngle * 2.0f * overlayAspectRatio; const float angleIncrement = horizontalAngle / (numHorizontalVertices - 1); const float halfHorizontalAngle = horizontalAngle / 2; + const float verticalAngleIncrement = verticalAngle / (numVerticalVertices - 1); + glActiveTexture(GL_TEXTURE0); glEnable(GL_BLEND); @@ -391,9 +399,10 @@ void ApplicationOverlay::displayOverlayTextureOculus(Camera& whichCamera) { magnifyHeight = widgetHeight - mouseY; } + const float halfMagnifyHeight = magnifyHeight / 2.0f; + float newWidth = magnifyWidth * magnification; float newHeight = magnifyHeight * magnification; - float tmp; // Magnification Texture Coordinates float magnifyULeft = mouseX / (float)widgetWidth; @@ -408,55 +417,118 @@ void ApplicationOverlay::displayOverlayTextureOculus(Camera& whichCamera) { // Get angle on the UI float leftAngle = (newMouseX / (float)widgetWidth) * horizontalAngle - halfHorizontalAngle; float rightAngle = ((newMouseX + newWidth) / (float)widgetWidth) * horizontalAngle - halfHorizontalAngle; - - float halfMagnifyHeight = magnifyHeight / 2.0f; + float bottomAngle = (newMouseY / (float)widgetHeight) * verticalAngle - halfVerticalAngle; + float topAngle = ((newMouseY - newHeight) / (float)widgetHeight) * verticalAngle - halfVerticalAngle; - float leftX, rightX, leftZ, rightZ; + + float leftX, rightX, leftZ, rightZ, topZ, bottomZ; // Get position on hemisphere using angle - leftX = sin(leftAngle) * _distance; - rightX = sin(rightAngle) * _distance; - leftZ = -cos(leftAngle) * _distance; - rightZ = -cos(rightAngle) * _distance; - - float bottomY = (1.0 - newMouseY / (float)widgetHeight) * halfOverlayHeight * 2.0f - halfOverlayHeight; - float topY = bottomY + (newHeight / widgetHeight) * halfOverlayHeight * 2; + if (_uiType == HEMISPHERE) { - //TODO: Remove immediate mode in favor of VBO - glBegin(GL_QUADS); + //Get new UV coordinates from our magnification window + float newULeft = newMouseX / widgetWidth; + float newURight = (newMouseX + newWidth) / widgetWidth; + float newVBottom = 1.0 - newMouseY / widgetHeight; + float newVTop = 1.0 - (newMouseY - newHeight) / widgetHeight; - glTexCoord2f(magnifyULeft, magnifyVBottom); glVertex3f(leftX, topY, leftZ); - glTexCoord2f(magnifyURight, magnifyVBottom); glVertex3f(rightX, topY, rightZ); - glTexCoord2f(magnifyURight, magnifyVTop); glVertex3f(rightX, bottomY, rightZ); - glTexCoord2f(magnifyULeft, magnifyVTop); glVertex3f(leftX, bottomY, leftZ); + // Project our position onto the hemisphere using the UV coordinates + float lX = sin((newULeft - 0.5f) * textureFov); + float rX = sin((newURight - 0.5f) * textureFov); + float bY = sin((newVBottom - 0.5f) * textureFov); + float tY = sin((newVTop - 0.5f) * textureFov); + + float dist; + //Bottom Left + dist = sqrt(lX * lX + bY * bY); + float blZ = sqrt(1.0f - dist * dist); + //Top Left + dist = sqrt(lX * lX + tY * tY); + float tlZ = sqrt(1.0f - dist * dist); + //Bottom Right + dist = sqrt(rX * rX + bY * bY); + float brZ = sqrt(1.0f - dist * dist); + //Top Right + dist = sqrt(rX * rX + tY * tY); + float trZ = sqrt(1.0f - dist * dist); - glEnd(); + glBegin(GL_QUADS); + glTexCoord2f(magnifyULeft, magnifyVBottom); glVertex3f(lX, tY, -tlZ); + glTexCoord2f(magnifyURight, magnifyVBottom); glVertex3f(rX, tY, -trZ); + glTexCoord2f(magnifyURight, magnifyVTop); glVertex3f(rX, bY, -brZ); + glTexCoord2f(magnifyULeft, magnifyVTop); glVertex3f(lX, bY, -blZ); + + glEnd(); + + } else { + leftX = sin(leftAngle) * _distance; + rightX = sin(rightAngle) * _distance; + leftZ = -cos(leftAngle) * _distance; + rightZ = -cos(rightAngle) * _distance; + if (_uiType == CURVED_SEMICIRCLE) { + topZ = -cos(topAngle * overlayAspectRatio) * _distance; + bottomZ = -cos(bottomAngle * overlayAspectRatio) * _distance; + } else { + // Dont want to use topZ or bottomZ for SEMICIRCLE + topZ = -99999; + bottomZ = -99999; + } + + float bottomY = (1.0 - newMouseY / (float)widgetHeight) * halfOverlayHeight * 2.0f - halfOverlayHeight; + float topY = bottomY + (newHeight / widgetHeight) * halfOverlayHeight * 2; + + //TODO: Remove immediate mode in favor of VBO + glBegin(GL_QUADS); + + glTexCoord2f(magnifyULeft, magnifyVBottom); glVertex3f(leftX, topY, max(topZ, leftZ)); + glTexCoord2f(magnifyURight, magnifyVBottom); glVertex3f(rightX, topY, max(topZ, rightZ)); + glTexCoord2f(magnifyURight, magnifyVTop); glVertex3f(rightX, bottomY, max(bottomZ, rightZ)); + glTexCoord2f(magnifyULeft, magnifyVTop); glVertex3f(leftX, bottomY, max(bottomZ, leftZ)); + + glEnd(); + } glDepthMask(GL_FALSE); glDisable(GL_ALPHA_TEST); //TODO: Remove immediate mode in favor of VBO - glBegin(GL_QUADS); - // Place the vertices in a semicircle curve around the camera - for (int i = 0; i < numHorizontalVertices-1; i++) { + if (_uiType == HEMISPHERE) { + renderTexturedHemisphere(); + } else{ + glBegin(GL_QUADS); + // Place the vertices in a semicircle curve around the camera + for (int i = 0; i < numHorizontalVertices - 1; i++) { + for (int j = 0; j < numVerticalVertices - 1; j++) { - // Calculate the X and Z coordinates from the angles and radius from camera - leftX = sin(angleIncrement * i - halfHorizontalAngle) * _distance; - rightX = sin(angleIncrement * (i + 1) - halfHorizontalAngle) * _distance; - leftZ = -cos(angleIncrement * i - halfHorizontalAngle) * _distance; - rightZ = -cos(angleIncrement * (i + 1) - halfHorizontalAngle) * _distance; + // Calculate the X and Z coordinates from the angles and radius from camera + leftX = sin(angleIncrement * i - halfHorizontalAngle) * _distance; + rightX = sin(angleIncrement * (i + 1) - halfHorizontalAngle) * _distance; + leftZ = -cos(angleIncrement * i - halfHorizontalAngle) * _distance; + rightZ = -cos(angleIncrement * (i + 1) - halfHorizontalAngle) * _distance; + if (_uiType == 2) { + topZ = -cos((verticalAngleIncrement * (j + 1) - halfVerticalAngle) * overlayAspectRatio) * _distance; + bottomZ = -cos((verticalAngleIncrement * j - halfVerticalAngle) * overlayAspectRatio) * _distance; + } else { + topZ = -99999; + bottomZ = -99999; + } - glTexCoord2f(quadTexWidth * i, 1); glVertex3f(leftX, halfOverlayHeight, leftZ); - glTexCoord2f(quadTexWidth * (i + 1), 1); glVertex3f(rightX, halfOverlayHeight, rightZ); - glTexCoord2f(quadTexWidth * (i + 1), 0); glVertex3f(rightX, -halfOverlayHeight, rightZ); - glTexCoord2f(quadTexWidth * i, 0); glVertex3f(leftX, -halfOverlayHeight, leftZ); + glTexCoord2f(quadTexWidth * i, (j + 1) * quadTexHeight); + glVertex3f(leftX, (j + 1) * quadTexHeight * overlayHeight - halfOverlayHeight, max(topZ, leftZ)); + glTexCoord2f(quadTexWidth * (i + 1), (j + 1) * quadTexHeight); + glVertex3f(rightX, (j + 1) * quadTexHeight * overlayHeight - halfOverlayHeight, max(topZ, rightZ)); + glTexCoord2f(quadTexWidth * (i + 1), j * quadTexHeight); + glVertex3f(rightX, j * quadTexHeight * overlayHeight - halfOverlayHeight, max(bottomZ, rightZ)); + glTexCoord2f(quadTexWidth * i, j * quadTexHeight); + glVertex3f(leftX, j * quadTexHeight * overlayHeight - halfOverlayHeight, max(bottomZ, leftZ)); + } + } + + glEnd(); } - - glEnd(); glPopMatrix(); - glDepthMask(GL_TRUE); glBindTexture(GL_TEXTURE_2D, 0); glDisable(GL_TEXTURE_2D); @@ -466,13 +538,106 @@ void ApplicationOverlay::displayOverlayTextureOculus(Camera& whichCamera) { } +void ApplicationOverlay::renderTexturedHemisphere() { + const int slices = 80; + const int stacks = 80; + + static VerticesIndices vbo(0, 0); + int vertices = slices * (stacks - 1) + 1; + int indices = slices * 2 * 3 * (stacks - 2) + slices * 3; + if (vbo.first == 0) { + TextureVertex* vertexData = new TextureVertex[vertices]; + TextureVertex* vertex = vertexData; + for (int i = 0; i < stacks - 1; i++) { + float phi = PI_OVER_TWO * (float)i / (float)(stacks - 1); + float z = -sinf(phi), radius = cosf(phi); + + for (int j = 0; j < slices; j++) { + float theta = TWO_PI * (float)j / (float)slices; + + vertex->position.x = sinf(theta) * radius; + vertex->position.y = cosf(theta) * radius; + vertex->position.z = z; + vertex->uv.x = asin(vertex->position.x) / (textureFov) + 0.5f; + vertex->uv.y = asin(vertex->position.y) / (textureFov) + 0.5f; + vertex++; + } + } + vertex->position.x = 0.0f; + vertex->position.y = 0.0f; + vertex->position.z = -1.0f; + vertex->uv.x = 0.5f; + vertex->uv.y = 0.5f; + vertex++; + + glGenBuffers(1, &vbo.first); + glBindBuffer(GL_ARRAY_BUFFER, vbo.first); + const int BYTES_PER_VERTEX = sizeof(TextureVertex); + glBufferData(GL_ARRAY_BUFFER, vertices * BYTES_PER_VERTEX, vertexData, GL_STATIC_DRAW); + delete[] vertexData; + + GLushort* indexData = new GLushort[indices]; + GLushort* index = indexData; + for (int i = 0; i < stacks - 2; i++) { + GLushort bottom = i * slices; + GLushort top = bottom + slices; + for (int j = 0; j < slices; j++) { + int next = (j + 1) % slices; + + *(index++) = bottom + j; + *(index++) = top + next; + *(index++) = top + j; + + *(index++) = bottom + j; + *(index++) = bottom + next; + *(index++) = top + next; + } + } + GLushort bottom = (stacks - 2) * slices; + GLushort top = bottom + slices; + for (int i = 0; i < slices; i++) { + *(index++) = bottom + i; + *(index++) = bottom + (i + 1) % slices; + *(index++) = top; + } + + glGenBuffers(1, &vbo.second); + glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, vbo.second); + const int BYTES_PER_INDEX = sizeof(GLushort); + glBufferData(GL_ELEMENT_ARRAY_BUFFER, indices * BYTES_PER_INDEX, indexData, GL_STATIC_DRAW); + delete[] indexData; + + } else { + glBindBuffer(GL_ARRAY_BUFFER, vbo.first); + glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, vbo.second); + } + + glEnableClientState(GL_VERTEX_ARRAY); + glEnableClientState(GL_TEXTURE_COORD_ARRAY); + + glVertexPointer(3, GL_FLOAT, sizeof(TextureVertex), (void*)0); + glTexCoordPointer(2, GL_FLOAT, sizeof(TextureVertex), (void*)12); + + glDrawRangeElements(GL_TRIANGLES, 0, vertices - 1, indices, GL_UNSIGNED_SHORT, 0); + + glDisableClientState(GL_VERTEX_ARRAY); + glDisableClientState(GL_TEXTURE_COORD_ARRAY); + + glBindBuffer(GL_ARRAY_BUFFER, 0); + glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); + +} + QOpenGLFramebufferObject* ApplicationOverlay::getFramebufferObject() { if (!_framebufferObject) { _framebufferObject = new QOpenGLFramebufferObject(Application::getInstance()->getGLWidget()->size()); - glBindTexture(GL_TEXTURE_2D, _framebufferObject->texture()); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); + GLfloat borderColor[4] = { 0.0f, 0.0f, 0.0f, 0.0f }; + glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_BORDER); + glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_BORDER); + glTexParameterfv(GL_TEXTURE_2D, GL_TEXTURE_BORDER_COLOR, borderColor); glBindTexture(GL_TEXTURE_2D, 0); } return _framebufferObject; diff --git a/interface/src/ui/ApplicationOverlay.h b/interface/src/ui/ApplicationOverlay.h index 4faa0b69f5..84cdabae4a 100644 --- a/interface/src/ui/ApplicationOverlay.h +++ b/interface/src/ui/ApplicationOverlay.h @@ -19,6 +19,8 @@ class QOpenGLFramebufferObject; class ApplicationOverlay { public: + static enum UITYPES { HEMISPHERE, SEMICIRCLE, CURVED_SEMICIRCLE }; + ApplicationOverlay(); ~ApplicationOverlay(); @@ -32,14 +34,24 @@ public: // Setters void setOculusAngle(float oculusAngle) { _oculusAngle = oculusAngle; } + void setUiType(UITYPES uiType) { _uiType = uiType; } private: + // Interleaved vertex data + struct TextureVertex { + glm::vec3 position; + glm::vec2 uv; + }; + + typedef QPair VerticesIndices; + + void renderTexturedHemisphere(); - ProgramObject _textureProgram; QOpenGLFramebufferObject* _framebufferObject; float _trailingAudioLoudness; float _oculusAngle; float _distance; + int _uiType; }; #endif // hifi_ApplicationOverlay_h \ No newline at end of file From 4e699c0f84fa101a89faf788020c4a566fbf4405 Mon Sep 17 00:00:00 2001 From: barnold1953 Date: Thu, 5 Jun 2014 10:34:06 -0700 Subject: [PATCH 2/6] Fixed coding standard and build error --- interface/src/ui/ApplicationOverlay.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/interface/src/ui/ApplicationOverlay.h b/interface/src/ui/ApplicationOverlay.h index 84cdabae4a..8817549277 100644 --- a/interface/src/ui/ApplicationOverlay.h +++ b/interface/src/ui/ApplicationOverlay.h @@ -19,7 +19,7 @@ class QOpenGLFramebufferObject; class ApplicationOverlay { public: - static enum UITYPES { HEMISPHERE, SEMICIRCLE, CURVED_SEMICIRCLE }; + enum UIType { HEMISPHERE, SEMICIRCLE, CURVED_SEMICIRCLE }; ApplicationOverlay(); ~ApplicationOverlay(); @@ -34,7 +34,7 @@ public: // Setters void setOculusAngle(float oculusAngle) { _oculusAngle = oculusAngle; } - void setUiType(UITYPES uiType) { _uiType = uiType; } + void setUIType(UIType uiType) { _uiType = uiType; } private: // Interleaved vertex data @@ -51,7 +51,7 @@ private: float _trailingAudioLoudness; float _oculusAngle; float _distance; - int _uiType; + UIType _uiType; }; #endif // hifi_ApplicationOverlay_h \ No newline at end of file From 8d908a12a30b11b3dbc1a225999b4d9f2005df66 Mon Sep 17 00:00:00 2001 From: Andrzej Kapolka Date: Thu, 5 Jun 2014 12:28:02 -0700 Subject: [PATCH 3/6] Fix build. --- interface/src/ui/ApplicationOverlay.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/interface/src/ui/ApplicationOverlay.cpp b/interface/src/ui/ApplicationOverlay.cpp index bfd3e63ea9..49ec8ecddb 100644 --- a/interface/src/ui/ApplicationOverlay.cpp +++ b/interface/src/ui/ApplicationOverlay.cpp @@ -343,7 +343,7 @@ void ApplicationOverlay::displayOverlayTextureOculus(Camera& whichCamera) { const float angleIncrement = horizontalAngle / (numHorizontalVertices - 1); const float halfHorizontalAngle = horizontalAngle / 2; - const float verticalAngleIncrement = verticalAngle / (numVerticalVertices - 1); + const float verticalAngleIncrement = _oculusAngle / (numVerticalVertices - 1); glActiveTexture(GL_TEXTURE0); @@ -417,8 +417,8 @@ void ApplicationOverlay::displayOverlayTextureOculus(Camera& whichCamera) { float leftAngle = (newMouseX / (float)widgetWidth) * horizontalAngle - halfHorizontalAngle; float rightAngle = ((newMouseX + newWidth) / (float)widgetWidth) * horizontalAngle - halfHorizontalAngle; - float bottomAngle = (newMouseY / (float)widgetHeight) * verticalAngle - halfVerticalAngle; - float topAngle = ((newMouseY - newHeight) / (float)widgetHeight) * verticalAngle - halfVerticalAngle; + float bottomAngle = (newMouseY / (float)widgetHeight) * _oculusAngle - halfVerticalAngle; + float topAngle = ((newMouseY - newHeight) / (float)widgetHeight) * _oculusAngle - halfVerticalAngle; float leftX, rightX, leftZ, rightZ, topZ, bottomZ; From c689d826f4498208bfc94da411cf5e9bbfe389b6 Mon Sep 17 00:00:00 2001 From: Andrew Meadows Date: Thu, 5 Jun 2014 15:48:18 -0700 Subject: [PATCH 4/6] fix for broken windows build with PrioVR libs The Model API changed but this code path was not updated. --- interface/src/devices/PrioVR.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/interface/src/devices/PrioVR.cpp b/interface/src/devices/PrioVR.cpp index 65cdb962e1..e96f4f04d5 100644 --- a/interface/src/devices/PrioVR.cpp +++ b/interface/src/devices/PrioVR.cpp @@ -76,20 +76,21 @@ static void setPalm(float deltaTime, int index) { } } + // NOTE: this math is done in the worl-frame with unecessary complexity. + // TODO: transfom this to stay in the model-frame. glm::vec3 position; glm::quat rotation; - SkeletonModel* skeletonModel = &Application::getInstance()->getAvatar()->getSkeletonModel(); int jointIndex; glm::quat inverseRotation = glm::inverse(Application::getInstance()->getAvatar()->getOrientation()); if (index == LEFT_HAND_INDEX) { jointIndex = skeletonModel->getLeftHandJointIndex(); - skeletonModel->getJointRotation(jointIndex, rotation, true); + skeletonModel->getJointRotationInWorldFrame(jointIndex, rotation); rotation = inverseRotation * rotation * glm::quat(glm::vec3(0.0f, PI_OVER_TWO, 0.0f)); } else { jointIndex = skeletonModel->getRightHandJointIndex(); - skeletonModel->getJointRotation(jointIndex, rotation, true); + skeletonModel->getJointRotationInWorldFrame(jointIndex, rotation); rotation = inverseRotation * rotation * glm::quat(glm::vec3(0.0f, -PI_OVER_TWO, 0.0f)); } skeletonModel->getJointPositionInWorldFrame(jointIndex, position); From 6bef0c1a6a72f00e4bd7db25af9a7ded43cf8313 Mon Sep 17 00:00:00 2001 From: Philip Rosedale Date: Thu, 5 Jun 2014 17:03:58 -0700 Subject: [PATCH 5/6] both left and right hands in animation --- examples/squeezeHands.js | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/examples/squeezeHands.js b/examples/squeezeHands.js index 3f24fa86b7..e53dd9569c 100644 --- a/examples/squeezeHands.js +++ b/examples/squeezeHands.js @@ -9,8 +9,8 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -var rightHandAnimation = "https://s3-us-west-1.amazonaws.com/highfidelity-public/animations/HandAnim.fbx"; -var leftHandAnimation = ""; +var rightHandAnimation = "https://s3-us-west-1.amazonaws.com/highfidelity-public/animations/RightHandAnim.fbx"; +var leftHandAnimation = "https://s3-us-west-1.amazonaws.com/highfidelity-public/animations/LeftHandAnim.fbx"; var LEFT = 0; var RIGHT = 1; @@ -18,17 +18,20 @@ var RIGHT = 1; var lastLeftFrame = 0; var lastRightFrame = 0; -var LAST_FRAME = 15.0; // What is the number of the last frame we want to use in the animation? +var LAST_FRAME = 11.0; // What is the number of the last frame we want to use in the animation? +var SMOOTH_FACTOR = 0.80; + Script.update.connect(function(deltaTime) { - var leftTriggerValue = Controller.getTriggerValue(LEFT); - var rightTriggerValue = Controller.getTriggerValue(RIGHT); + var leftTriggerValue = Math.sqrt(Controller.getTriggerValue(LEFT)); + var rightTriggerValue = Math.sqrt(Controller.getTriggerValue(RIGHT)); var leftFrame, rightFrame; - // Average last two trigger frames together for a bit of smoothing - leftFrame = (leftTriggerValue * LAST_FRAME) * 0.5 + lastLeftFrame * 0.5; - rightFrame = (rightTriggerValue * LAST_FRAME) * 0.5 + lastRightFrame * 0.5; + // Average last few trigger frames together for a bit of smoothing + leftFrame = (leftTriggerValue * LAST_FRAME) * (1.0 - SMOOTH_FACTOR) + lastLeftFrame * SMOOTH_FACTOR; + rightFrame = (rightTriggerValue * LAST_FRAME) * (1.0 - SMOOTH_FACTOR) + lastRightFrame * SMOOTH_FACTOR; + if ((leftFrame != lastLeftFrame) && leftHandAnimation.length){ MyAvatar.stopAnimation(leftHandAnimation); From 83c2938c2ea2e0a75340962167e680bb7eb7920c Mon Sep 17 00:00:00 2001 From: Andrzej Kapolka Date: Thu, 5 Jun 2014 17:05:57 -0700 Subject: [PATCH 6/6] Temporarily disable enum streamers, which are crashing on Windows startup. --- interface/src/devices/PrioVR.cpp | 4 ++-- libraries/metavoxels/src/Bitstream.cpp | 15 ++++++++------- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/interface/src/devices/PrioVR.cpp b/interface/src/devices/PrioVR.cpp index 65cdb962e1..0cfe127b2f 100644 --- a/interface/src/devices/PrioVR.cpp +++ b/interface/src/devices/PrioVR.cpp @@ -84,12 +84,12 @@ static void setPalm(float deltaTime, int index) { glm::quat inverseRotation = glm::inverse(Application::getInstance()->getAvatar()->getOrientation()); if (index == LEFT_HAND_INDEX) { jointIndex = skeletonModel->getLeftHandJointIndex(); - skeletonModel->getJointRotation(jointIndex, rotation, true); + skeletonModel->getJointRotationInWorldFrame(jointIndex, rotation); rotation = inverseRotation * rotation * glm::quat(glm::vec3(0.0f, PI_OVER_TWO, 0.0f)); } else { jointIndex = skeletonModel->getRightHandJointIndex(); - skeletonModel->getJointRotation(jointIndex, rotation, true); + skeletonModel->getJointRotationInWorldFrame(jointIndex, rotation); rotation = inverseRotation * rotation * glm::quat(glm::vec3(0.0f, -PI_OVER_TWO, 0.0f)); } skeletonModel->getJointPositionInWorldFrame(jointIndex, position); diff --git a/libraries/metavoxels/src/Bitstream.cpp b/libraries/metavoxels/src/Bitstream.cpp index 30d34580d7..387b41a839 100644 --- a/libraries/metavoxels/src/Bitstream.cpp +++ b/libraries/metavoxels/src/Bitstream.cpp @@ -92,13 +92,14 @@ int Bitstream::registerMetaObject(const char* className, const QMetaObject* meta } // register the streamers for all enumerators - for (int i = 0; i < metaObject->enumeratorCount(); i++) { - QMetaEnum metaEnum = metaObject->enumerator(i); - const TypeStreamer*& streamer = getEnumStreamers()[QPair(metaEnum.scope(), metaEnum.name())]; - if (!streamer) { - getEnumStreamersByName().insert(getEnumName(metaEnum), streamer = new EnumTypeStreamer(metaEnum)); - } - } + // temporarily disabled: crashes on Windows + //for (int i = 0; i < metaObject->enumeratorCount(); i++) { + // QMetaEnum metaEnum = metaObject->enumerator(i); + // const TypeStreamer*& streamer = getEnumStreamers()[QPair(metaEnum.scope(), metaEnum.name())]; + // if (!streamer) { + // getEnumStreamersByName().insert(getEnumName(metaEnum), streamer = new EnumTypeStreamer(metaEnum)); + // } + //} return 0; }