Showing the changes to interface/src/ui/ApplicationOverlay.cpp (1 of 3 files). Show all
Unified · Split
| @@ -45,70 +45,76 @@ void renderControllerPointer() { · 44 unmodified lines | ||
| 45 | 45 | |
| 46 | 46 | |
| 47 | 47 | int palmIndex; |
| 48 | − if (Menu::getInstance()->isOptionChecked(MenuOption::SixenseLeftHanded)) { | |
| 48 | + /*if (Menu::getInstance()->isOptionChecked(MenuOption::SixenseLeftHanded)) { | |
| 49 | 49 | palmIndex = 2; |
| 50 | 50 | } else { |
| 51 | 51 | palmIndex = 3; |
| 52 | − } | |
| 53 | − const PalmData* palmData = NULL; | |
| 52 | + }*/ | |
| 53 | + for (palmIndex = 2; palmIndex < 4; palmIndex++) { | |
| 54 | + const PalmData* palmData = NULL; | |
| 54 | 55 | |
| 55 | − if (palmIndex >= handData->getPalms().size()) { | |
| 56 | − return; | |
| 57 | − } | |
| 56 | + if (palmIndex >= handData->getPalms().size()) { | |
| 57 | + return; | |
| 58 | + } | |
| 58 | 59 | |
| 59 | − if (handData->getPalms()[palmIndex].isActive()) { | |
| 60 | − palmData = &handData->getPalms()[palmIndex]; | |
| 61 | − } else { | |
| 62 | − return; | |
| 63 | − } | |
| 64 | − | |
| 65 | − // Get directon relative to avatar orientation | |
| 66 | − glm::vec3 direction = glm::inverse(myAvatar->getOrientation()) * palmData->getFingerDirection(); | |
| 60 | + if (handData->getPalms()[palmIndex].isActive()) { | |
| 61 | + palmData = &handData->getPalms()[palmIndex]; | |
| 62 | + } else { | |
| 63 | + return; | |
| 64 | + } | |
| 67 | 65 | |
| 68 | − // Get the angles, scaled between 0-1 | |
| 69 | − float xAngle = (atan2(direction.z, direction.x) + M_PI_2) + 0.5f; | |
| 70 | − float yAngle = 1.0f - ((atan2(direction.z, direction.y) + M_PI_2) + 0.5f); | |
| 66 | + // Get directon relative to avatar orientation | |
| 67 | + glm::vec3 direction = glm::inverse(myAvatar->getOrientation()) * palmData->getFingerDirection(); | |
| 71 | 68 | |
| 72 | − float cursorRange = glWidget->width(); | |
| 69 | + // Get the angles, scaled between 0-1 | |
| 70 | + float xAngle = (atan2(direction.z, direction.x) + M_PI_2) + 0.5f; | |
| 71 | + float yAngle = 1.0f - ((atan2(direction.z, direction.y) + M_PI_2) + 0.5f); | |
| 73 | 72 | |
| 74 | − int mouseX = cursorRange * xAngle; | |
| 75 | − int mouseY = cursorRange * yAngle; | |
| 73 | + float cursorRange = glWidget->width(); | |
| 76 | 74 | |
| 77 | − if (mouseX < 0) { | |
| 78 | − mouseX = 0; | |
| 79 | − } else if (mouseX > glWidget->width()) { | |
| 80 | − mouseX = glWidget->width(); | |
| 81 | − } | |
| 82 | − if (mouseY < 0) { | |
| 83 | − mouseY = 0; | |
| 84 | − } else if (mouseY > glWidget->width()) { | |
| 85 | − mouseY = glWidget->width(); | |
| 86 | − } | |
| 75 | + int mouseX = cursorRange * xAngle; | |
| 76 | + int mouseY = cursorRange * yAngle; | |
| 87 | 77 | |
| 88 | − const float pointerWidth = 40; | |
| 89 | − const float pointerHeight = 40; | |
| 90 | − const float crossPad = 16; | |
| 78 | + if (mouseX < 0) { | |
| 79 | + //mouseX = 0; | |
| 80 | + continue; | |
| 81 | + } else if (mouseX > glWidget->width()) { | |
| 82 | + //mouseX = glWidget->width(); | |
| 83 | + continue; | |
| 84 | + } | |
| 85 | + if (mouseY < 0) { | |
| 86 | + //mouseY = 0; | |
| 87 | + continue; | |
| 88 | + } else if (mouseY > glWidget->width()) { | |
| 89 | + //mouseY = glWidget->width(); | |
| 90 | + continue; | |
| 91 | + } | |
| 91 | 92 | |
| 92 | − mouseX -= pointerWidth / 2.0f; | |
| 93 | − mouseY += pointerHeight / 2.0f; | |
| 93 | + const float pointerWidth = 40; | |
| 94 | + const float pointerHeight = 40; | |
| 95 | + const float crossPad = 16; | |
| 94 | 96 | |
| 95 | − glBegin(GL_QUADS); | |
| 97 | + mouseX -= pointerWidth / 2.0f; | |
| 98 | + mouseY += pointerHeight / 2.0f; | |
| 96 | 99 | |
| 97 | − glColor3f(0, 0, 1); | |
| 100 | + glBegin(GL_QUADS); | |
| 98 | 101 | |
| 99 | − //Horizontal crosshair | |
| 100 | − glVertex2i(mouseX, mouseY - crossPad); | |
| 101 | − glVertex2i(mouseX + pointerWidth, mouseY - crossPad); | |
| 102 | − glVertex2i(mouseX + pointerWidth, mouseY - pointerHeight + crossPad); | |
| 103 | − glVertex2i(mouseX, mouseY - pointerHeight + crossPad); | |
| 102 | + glColor3f(0.0f, 0.0f, 1.0f); | |
| 104 | 103 | |
| 105 | − //Vertical crosshair | |
| 106 | − glVertex2i(mouseX + crossPad, mouseY); | |
| 107 | − glVertex2i(mouseX + pointerWidth - crossPad, mouseY); | |
| 108 | − glVertex2i(mouseX + pointerWidth - crossPad, mouseY - pointerHeight); | |
| 109 | − glVertex2i(mouseX + crossPad, mouseY - pointerHeight); | |
| 104 | + //Horizontal crosshair | |
| 105 | + glVertex2i(mouseX, mouseY - crossPad); | |
| 106 | + glVertex2i(mouseX + pointerWidth, mouseY - crossPad); | |
| 107 | + glVertex2i(mouseX + pointerWidth, mouseY - pointerHeight + crossPad); | |
| 108 | + glVertex2i(mouseX, mouseY - pointerHeight + crossPad); | |
| 110 | 109 | |
| 111 | − glEnd(); | |
| 110 | + //Vertical crosshair | |
| 111 | + glVertex2i(mouseX + crossPad, mouseY); | |
| 112 | + glVertex2i(mouseX + pointerWidth - crossPad, mouseY); | |
| 113 | + glVertex2i(mouseX + pointerWidth - crossPad, mouseY - pointerHeight); | |
| 114 | + glVertex2i(mouseX + crossPad, mouseY - pointerHeight); | |
| 115 | + | |
| 116 | + glEnd(); | |
| 117 | + } | |
| 112 | 118 | } |
| 113 | 119 | |
| 114 | 120 | // Renders the overlays either to a texture or to the screen |