Showing the changes to interface/src/ui/ApplicationOverlay.cpp (1 of 27 files). Show all
Unified · Split
| @@ -297,6 +297,25 @@ void ApplicationOverlay::displayOverlayTexture(Camera& whichCamera) { · 296 unmodified lines | ||
| 297 | 297 | glDisable(GL_TEXTURE_2D); |
| 298 | 298 | } |
| 299 | 299 | |
| 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 | + | |
| 300 | 319 | // Fast helper functions |
| 301 | 320 | inline float max(float a, float b) { |
| 302 | 321 | return (a > b) ? a : b; |
| @@ -306,8 +325,6 @@ inline float min(float a, float b) { · 3 unmodified lines | ||
| 306 | 325 | return (a < b) ? a : b; |
| 307 | 326 | } |
| 308 | 327 | |
| 309 | −const float textureFov = PI / 2.5f; | |
| 310 | − | |
| 311 | 328 | // Draws the FBO texture for Oculus rift. TODO: Draw a curved texture instead of plane. |
| 312 | 329 | void ApplicationOverlay::displayOverlayTextureOculus(Camera& whichCamera) { |
| 313 | 330 | |