History

Hydra reticule rendering for Oculus

Atlante45 committed 11 years ago

Commit d2b0cdb1 parent 9f444581 file · +13 −71Browse files

Showing the changes to interface/src/ui/ApplicationOverlay.cpp (1 of 1 file). Show all

Unified · Split

interface/src/ui/ApplicationOverlay.cpp+13−71
@@ -29,6 +29,7 @@ const quint64 MSECS_TO_USECS = 1000ULL; · 28 unmodified lines
2929
3030 const float WHITE_TEXT[] = { 0.93f, 0.93f, 0.93f };
3131 const float RETICLE_COLOR[] = { 0.0f, 198.0f / 255.0f, 244.0f / 255.0f };
32+const float reticleSize = TWO_PI / 100.0f;
3233
3334
3435 const float CONNECTION_STATUS_BORDER_COLOR[] = { 1.0f, 0.0f, 0.0f };
@@ -103,8 +104,6 @@ bool raySphereIntersect(const glm::vec3 &dir, const glm::vec3 &origin, float r, · 68 unmodified lines
103104 }
104105
105106 void renderReticule(glm::quat orientation, float alpha) {
106− const float reticleSize = TWO_PI / 80.0f;
107−
108107 glm::vec3 topLeft = getPoint(reticleSize / 2.0f, -reticleSize / 2.0f);
109108 glm::vec3 topRight = getPoint(-reticleSize / 2.0f, -reticleSize / 2.0f);
110109 glm::vec3 bottomLeft = getPoint(reticleSize / 2.0f, reticleSize / 2.0f);
@@ -523,7 +522,7 @@ void ApplicationOverlay::renderPointers() { · 412 unmodified lines
523522 //If we are in oculus, render reticle later
524523 _reticleActive[MOUSE] = true;
525524 _magActive[MOUSE] = true;
526− _reticulePosition[MOUSE] = glm::vec2(application->getTrueMouseX(), application->getTrueMouseY());
525+ _reticulePosition[MOUSE] = glm::vec2(application->getMouseX(), application->getMouseY());
527526 _reticleActive[LEFT_CONTROLLER] = false;
528527 _reticleActive[RIGHT_CONTROLLER] = false;
529528
@@ -658,70 +657,17 @@ void ApplicationOverlay::renderPointersOculus(const glm::vec3& eyePos) { · 128 unmodified lines
658657 MyAvatar* myAvatar = Application::getInstance()->getAvatar();
659658 for (int i = 0; i < (int)myAvatar->getHand()->getNumPalms(); i++) {
660659
661−// PalmData& palm = myAvatar->getHand()->getPalms()[i];
662−// if (palm.isActive()) {
663−// glm::vec3 tip = myAvatar->getLaserPointerTipPosition(&palm);
664−// glm::vec3 tipPos = (tip - eyePos);
665−//
666−// float length = glm::length(eyePos - tip);
667−// float size = 0.03f * length;
668−//
669−// glm::vec3 up = glm::vec3(0.0, 1.0, 0.0) * size;
670−// glm::vec3 right = glm::vec3(1.0, 0.0, 0.0) * size;
671−//
672−// cursorVerts[0] = -right + up;
673−// cursorVerts[1] = right + up;
674−// cursorVerts[2] = right - up;
675−// cursorVerts[3] = -right - up;
676−//
677−// glPushMatrix();
678−//
679−// // objToCamProj is the vector in world coordinates from the
680−// // local origin to the camera projected in the XZ plane
681−// glm::vec3 cursorToCameraXZ(-tipPos.x, 0, -tipPos.z);
682−// cursorToCameraXZ = glm::normalize(cursorToCameraXZ);
683−//
684−// //Translate the cursor to the tip of the oculus ray
685−// glTranslatef(tip.x, tip.y, tip.z);
686−//
687−// glm::vec3 direction(0, 0, 1);
688−// // easy fix to determine wether the angle is negative or positive
689−// // for positive angles upAux will be a vector pointing in the
690−// // positive y direction, otherwise upAux will point downwards
691−// // effectively reversing the rotation.
692−// glm::vec3 upAux = glm::cross(direction, cursorToCameraXZ);
693−//
694−// // compute the angle
695−// float angleCosine = glm::dot(direction, cursorToCameraXZ);
696−//
697−// //Rotate in XZ direction
698−// glRotatef(acos(angleCosine) * DEGREES_PER_RADIAN, upAux[0], upAux[1], upAux[2]);
699−//
700−// glm::vec3 cursorToCamera = glm::normalize(-tipPos);
701−//
702−// // Compute the angle between cursorToCameraXZ and cursorToCamera,
703−// angleCosine = glm::dot(cursorToCameraXZ, cursorToCamera);
704−//
705−// //Rotate in Y direction
706−// if (cursorToCamera.y < 0) {
707−// glRotatef(acos(angleCosine) * DEGREES_PER_RADIAN, 1, 0, 0);
708−// } else {
709−// glRotatef(acos(angleCosine) * DEGREES_PER_RADIAN, -1, 0, 0);
710−// }
711−//
712−// glBegin(GL_QUADS);
713−//
714−// glColor4f(RETICLE_COLOR[0], RETICLE_COLOR[1], RETICLE_COLOR[2], _alpha);
715−//
716−// glTexCoord2f(0.0f, 0.0f); glVertex3f(cursorVerts[0].x, cursorVerts[0].y, cursorVerts[0].z);
717−// glTexCoord2f(1.0f, 0.0f); glVertex3f(cursorVerts[1].x, cursorVerts[1].y, cursorVerts[1].z);
718−// glTexCoord2f(1.0f, 1.0f); glVertex3f(cursorVerts[2].x, cursorVerts[2].y, cursorVerts[2].z);
719−// glTexCoord2f(0.0f, 1.0f); glVertex3f(cursorVerts[3].x, cursorVerts[3].y, cursorVerts[3].z);
720−//
721−// glEnd();
722−//
723−// glPopMatrix();
724−// }
660+ PalmData& palm = myAvatar->getHand()->getPalms()[i];
661+ if (palm.isActive()) {
662+ glm::vec3 tip = myAvatar->getLaserPointerTipPosition(&palm);
663+ glm::vec3 tipDirection = glm::normalize(glm::inverse(myAvatar->getOrientation()) * (tip - eyePos));
664+ float pitch = -glm::asin(tipDirection.y);
665+ float yawSign = glm::sign(-tipDirection.x);
666+ float yaw = glm::acos(-tipDirection.z) *
667+ ((yawSign == 0.0f) ? 1.0f : yawSign);
668+ glm::quat orientation = glm::quat(glm::vec3(pitch, yaw, 0.0f));
669+ renderReticule(orientation, _alpha);
670+ }
725671 }
726672
727673 //Mouse Pointer
@@ -791,8 +737,6 @@ void ApplicationOverlay::renderMagnifier(glm::vec2 magPos, float sizeMult, bool · 63 unmodified lines
791737 } glPopMatrix();
792738 }
793739
794−
795−
796740 void ApplicationOverlay::renderAudioMeter() {
797741
798742 Application* application = Application::getInstance();
@@ -990,8 +934,6 @@ void ApplicationOverlay::renderDomainConnectionStatusBorder() { · 191 unmodified lines
990934 }
991935 }
992936
993−
994−
995937 ApplicationOverlay::TexturedHemisphere::TexturedHemisphere() :
996938 _vertices(0),
997939 _indices(0),