History

Experimenting with ambidextrous sixense mouse input

barnold1953 committed 12 years ago

Commit d0b18801 parent 32a9eed3 files · +117 −87Browse files

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

Unified · Split

interface/src/ui/ApplicationOverlay.cpp+54−48
@@ -45,70 +45,76 @@ void renderControllerPointer() { · 44 unmodified lines
45 45
46 46
47 int palmIndex;47 int palmIndex;
48 if (Menu::getInstance()->isOptionChecked(MenuOption::SixenseLeftHanded)) {48 /*if (Menu::getInstance()->isOptionChecked(MenuOption::SixenseLeftHanded)) {
49 palmIndex = 2;49 palmIndex = 2;
50 } else {50 } else {
51 palmIndex = 3;51 palmIndex = 3;
52 }52 }*/
53 const PalmData* palmData = NULL;53 for (palmIndex = 2; palmIndex < 4; palmIndex++) {
54 const PalmData* palmData = NULL;
54 55
55 if (palmIndex >= handData->getPalms().size()) {56 if (palmIndex >= handData->getPalms().size()) {
56 return;57 return;
57 }58 }
58 59
59 if (handData->getPalms()[palmIndex].isActive()) {60 if (handData->getPalms()[palmIndex].isActive()) {
60 palmData = &handData->getPalms()[palmIndex];61 palmData = &handData->getPalms()[palmIndex];
61 } else {62 } else {
62 return;63 return;
63 }64 }
64
65 // Get directon relative to avatar orientation
66 glm::vec3 direction = glm::inverse(myAvatar->getOrientation()) * palmData->getFingerDirection();
67 65
68 // Get the angles, scaled between 0-166 // Get directon relative to avatar orientation
69 float xAngle = (atan2(direction.z, direction.x) + M_PI_2) + 0.5f;67 glm::vec3 direction = glm::inverse(myAvatar->getOrientation()) * palmData->getFingerDirection();
70 float yAngle = 1.0f - ((atan2(direction.z, direction.y) + M_PI_2) + 0.5f);
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;73 float cursorRange = glWidget->width();
75 int mouseY = cursorRange * yAngle;
76 74
77 if (mouseX < 0) {75 int mouseX = cursorRange * xAngle;
78 mouseX = 0;76 int mouseY = cursorRange * yAngle;
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 }
87 77
88 const float pointerWidth = 40;78 if (mouseX < 0) {
89 const float pointerHeight = 40;79 //mouseX = 0;
90 const float crossPad = 16;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 const float pointerWidth = 40;
93 mouseY += pointerHeight / 2.0f;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 crosshair102 glColor3f(0.0f, 0.0f, 1.0f);
100 glVertex2i(mouseX, mouseY - crossPad);
101 glVertex2i(mouseX + pointerWidth, mouseY - crossPad);
102 glVertex2i(mouseX + pointerWidth, mouseY - pointerHeight + crossPad);
103 glVertex2i(mouseX, mouseY - pointerHeight + crossPad);
104 103
105 //Vertical crosshair104 //Horizontal crosshair
106 glVertex2i(mouseX + crossPad, mouseY);105 glVertex2i(mouseX, mouseY - crossPad);
107 glVertex2i(mouseX + pointerWidth - crossPad, mouseY);106 glVertex2i(mouseX + pointerWidth, mouseY - crossPad);
108 glVertex2i(mouseX + pointerWidth - crossPad, mouseY - pointerHeight);107 glVertex2i(mouseX + pointerWidth, mouseY - pointerHeight + crossPad);
109 glVertex2i(mouseX + crossPad, mouseY - pointerHeight);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// Renders the overlays either to a texture or to the screen120// Renders the overlays either to a texture or to the screen

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t