History

Merge remote-tracking branch 'upstream/master'

wangyix committed 12 years ago

Commit 01005dc2 parents c6a9a89 49a33ff27 files · +1495 −339Browse files

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

Unified · Split

interface/src/ui/ApplicationOverlay.cpp+19−2
@@ -297,6 +297,25 @@ void ApplicationOverlay::displayOverlayTexture(Camera& whichCamera) { · 296 unmodified lines
297297 glDisable(GL_TEXTURE_2D);
298298 }
299299
300+const float textureFov = PI / 2.5f;
301+
302+void ApplicationOverlay::computeOculusPickRay(float x, float y, glm::vec3& direction) const {
303+ glm::quat rot = Application::getInstance()->getAvatar()->getOrientation();
304+
305+ //invert y direction
306+ y = 1.0 - y;
307+
308+ //Get position on hemisphere UI
309+ x = sin((x - 0.5f) * textureFov);
310+ y = sin((y - 0.5f) * textureFov);
311+
312+ float dist = sqrt(x * x + y * y);
313+ float z = -sqrt(1.0f - dist * dist);
314+
315+ //Rotate the UI pick ray by the avatar orientation
316+ direction = glm::normalize(rot * glm::vec3(x, y, z));
317+}
318+
300319 // Fast helper functions
301320 inline float max(float a, float b) {
302321 return (a > b) ? a : b;
@@ -306,8 +325,6 @@ inline float min(float a, float b) { · 3 unmodified lines
306325 return (a < b) ? a : b;
307326 }
308327
309−const float textureFov = PI / 2.5f;
310−
311328 // Draws the FBO texture for Oculus rift. TODO: Draw a curved texture instead of plane.
312329 void ApplicationOverlay::displayOverlayTextureOculus(Camera& whichCamera) {
313330