Showing the changes to interface/src/Application.cpp (1 of 22 files). Show all
Unified · Split
| @@ -48,7 +48,7 @@ · 47 unmodified lines | ||
| 48 | 48 | #include <NodeTypes.h> |
| 49 | 49 | #include <AudioInjectionManager.h> |
| 50 | 50 | #include <AudioInjector.h> |
| 51 | −#include <Logstash.h> | |
| 51 | +#include <Logging.h> | |
| 52 | 52 | #include <OctalCode.h> |
| 53 | 53 | #include <PacketHeaders.h> |
| 54 | 54 | #include <PairingHandler.h> |
| @@ -319,7 +319,7 @@ void Application::initializeGL() { · 264 unmodified lines | ||
| 319 | 319 | const char LOGSTASH_INTERFACE_START_TIME_KEY[] = "interface-start-time"; |
| 320 | 320 | |
| 321 | 321 | // ask the Logstash class to record the startup time |
| 322 | − Logstash::stashValue(STAT_TYPE_TIMER, LOGSTASH_INTERFACE_START_TIME_KEY, startupTime); | |
| 322 | + Logging::stashValue(STAT_TYPE_TIMER, LOGSTASH_INTERFACE_START_TIME_KEY, startupTime); | |
| 323 | 323 | } |
| 324 | 324 | |
| 325 | 325 | // update before the first render |
| @@ -424,9 +424,6 @@ void Application::resizeGL(int width, int height) { · 98 unmodified lines | ||
| 424 | 424 | resetCamerasOnResizeGL(_viewFrustumOffsetCamera, width, height); |
| 425 | 425 | resetCamerasOnResizeGL(_myCamera, width, height); |
| 426 | 426 | |
| 427 | − // Tell our viewFrustum about this change, using the application camera | |
| 428 | − loadViewFrustum(_myCamera, _viewFrustum); | |
| 429 | − | |
| 430 | 427 | glViewport(0, 0, width, height); // shouldn't this account for the menu??? |
| 431 | 428 | |
| 432 | 429 | updateProjectionMatrix(); |
| @@ -437,9 +434,12 @@ void Application::updateProjectionMatrix() { · 4 unmodified lines | ||
| 437 | 434 | glMatrixMode(GL_PROJECTION); |
| 438 | 435 | glLoadIdentity(); |
| 439 | 436 | |
| 437 | + // Tell our viewFrustum about this change, using the application camera | |
| 438 | + loadViewFrustum(_myCamera, _viewFrustum); | |
| 439 | + | |
| 440 | 440 | float left, right, bottom, top, nearVal, farVal; |
| 441 | 441 | glm::vec4 nearClipPlane, farClipPlane; |
| 442 | − _viewFrustum.computeOffAxisFrustum(left, right, bottom, top, nearVal, farVal, nearClipPlane, farClipPlane); | |
| 442 | + computeOffAxisFrustum(left, right, bottom, top, nearVal, farVal, nearClipPlane, farClipPlane); | |
| 443 | 443 | |
| 444 | 444 | // If we're in Display Frustum mode, then we want to use the slightly adjust near/far clip values of the |
| 445 | 445 | // _viewFrustumOffsetCamera, so that we can see more of the application content in the application's frustum |
| @@ -632,8 +632,8 @@ void Application::keyPressEvent(QKeyEvent* event) { · 186 unmodified lines | ||
| 632 | 632 | |
| 633 | 633 | case Qt::Key_J: |
| 634 | 634 | if (isShifted) { |
| 635 | − _myCamera.setEyeOffsetOrientation(glm::normalize( | |
| 636 | − glm::quat(glm::vec3(0, 0.002f, 0)) * _myCamera.getEyeOffsetOrientation())); | |
| 635 | + _viewFrustum.setFocalLength(_viewFrustum.getFocalLength() - 0.1f); | |
| 636 | + | |
| 637 | 637 | } else { |
| 638 | 638 | _myCamera.setEyeOffsetPosition(_myCamera.getEyeOffsetPosition() + glm::vec3(-0.001, 0, 0)); |
| 639 | 639 | } |
| @@ -642,8 +642,8 @@ void Application::keyPressEvent(QKeyEvent* event) { · 2 unmodified lines | ||
| 642 | 642 | |
| 643 | 643 | case Qt::Key_M: |
| 644 | 644 | if (isShifted) { |
| 645 | − _myCamera.setEyeOffsetOrientation(glm::normalize( | |
| 646 | − glm::quat(glm::vec3(0, -0.002f, 0)) * _myCamera.getEyeOffsetOrientation())); | |
| 645 | + _viewFrustum.setFocalLength(_viewFrustum.getFocalLength() + 0.1f); | |
| 646 | + | |
| 647 | 647 | } else { |
| 648 | 648 | _myCamera.setEyeOffsetPosition(_myCamera.getEyeOffsetPosition() + glm::vec3(0.001, 0, 0)); |
| 649 | 649 | } |
| @@ -1836,15 +1836,17 @@ void Application::update(float deltaTime) { · 1186 unmodified lines | ||
| 1836 | 1836 | } |
| 1837 | 1837 | |
| 1838 | 1838 | if (Menu::getInstance()->isOptionChecked(MenuOption::OffAxisProjection)) { |
| 1839 | + float xSign = Menu::getInstance()->isOptionChecked(MenuOption::Mirror) ? 1.0f : -1.0f; | |
| 1839 | 1840 | if (_faceshift.isActive()) { |
| 1840 | − const float EYE_OFFSET_SCALE = 0.005f; | |
| 1841 | + const float EYE_OFFSET_SCALE = 0.025f; | |
| 1841 | 1842 | glm::vec3 position = _faceshift.getHeadTranslation() * EYE_OFFSET_SCALE; |
| 1842 | − _myCamera.setEyeOffsetPosition(glm::vec3(-position.x, position.y, position.z)); | |
| 1843 | + _myCamera.setEyeOffsetPosition(glm::vec3(position.x * xSign, position.y, position.z)); | |
| 1843 | 1844 | updateProjectionMatrix(); |
| 1844 | 1845 | |
| 1845 | 1846 | } else if (_webcam.isActive()) { |
| 1846 | − const float EYE_OFFSET_SCALE = 5.0f; | |
| 1847 | − _myCamera.setEyeOffsetPosition(_webcam.getEstimatedPosition() * EYE_OFFSET_SCALE); | |
| 1847 | + const float EYE_OFFSET_SCALE = 0.5f; | |
| 1848 | + glm::vec3 position = _webcam.getEstimatedPosition() * EYE_OFFSET_SCALE; | |
| 1849 | + _myCamera.setEyeOffsetPosition(glm::vec3(position.x * xSign, -position.y, position.z)); | |
| 1848 | 1850 | updateProjectionMatrix(); |
| 1849 | 1851 | } |
| 1850 | 1852 | } |
| @@ -2166,6 +2168,19 @@ void Application::setupWorldLight(Camera& whichCamera) { · 315 unmodified lines | ||
| 2166 | 2168 | glMateriali(GL_FRONT, GL_SHININESS, 96); |
| 2167 | 2169 | } |
| 2168 | 2170 | |
| 2171 | +void Application::computeOffAxisFrustum(float& left, float& right, float& bottom, float& top, float& near, | |
| 2172 | + float& far, glm::vec4& nearClipPlane, glm::vec4& farClipPlane) const { | |
| 2173 | + | |
| 2174 | + _viewFrustum.computeOffAxisFrustum(left, right, bottom, top, near, far, nearClipPlane, farClipPlane); | |
| 2175 | + | |
| 2176 | + // when mirrored, we must flip left and right | |
| 2177 | + if (Menu::getInstance()->isOptionChecked(MenuOption::Mirror)) { | |
| 2178 | + float tmp = left; | |
| 2179 | + left = -right; | |
| 2180 | + right = -tmp; | |
| 2181 | + } | |
| 2182 | +} | |
| 2183 | + | |
| 2169 | 2184 | void Application::displaySide(Camera& whichCamera) { |
| 2170 | 2185 | // transform by eye offset |
| 2171 | 2186 | |
| @@ -2969,6 +2984,30 @@ void Application::renderViewFrustum(ViewFrustum& viewFrustum) { · 797 unmodified lines | ||
| 2969 | 2984 | // left plane - top edge - viewFrustum.getNear to distant |
| 2970 | 2985 | glVertex3f(viewFrustum.getNearTopLeft().x, viewFrustum.getNearTopLeft().y, viewFrustum.getNearTopLeft().z); |
| 2971 | 2986 | glVertex3f(viewFrustum.getFarTopLeft().x, viewFrustum.getFarTopLeft().y, viewFrustum.getFarTopLeft().z); |
| 2987 | + | |
| 2988 | + // focal plane - bottom edge | |
| 2989 | + glColor3f(1.0f, 0.0f, 1.0f); | |
| 2990 | + float focalProportion = (viewFrustum.getFocalLength() - viewFrustum.getNearClip()) / | |
| 2991 | + (viewFrustum.getFarClip() - viewFrustum.getNearClip()); | |
| 2992 | + glm::vec3 focalBottomLeft = glm::mix(viewFrustum.getNearBottomLeft(), viewFrustum.getFarBottomLeft(), focalProportion); | |
| 2993 | + glm::vec3 focalBottomRight = glm::mix(viewFrustum.getNearBottomRight(), | |
| 2994 | + viewFrustum.getFarBottomRight(), focalProportion); | |
| 2995 | + glVertex3f(focalBottomLeft.x, focalBottomLeft.y, focalBottomLeft.z); | |
| 2996 | + glVertex3f(focalBottomRight.x, focalBottomRight.y, focalBottomRight.z); | |
| 2997 | + | |
| 2998 | + // focal plane - top edge | |
| 2999 | + glm::vec3 focalTopLeft = glm::mix(viewFrustum.getNearTopLeft(), viewFrustum.getFarTopLeft(), focalProportion); | |
| 3000 | + glm::vec3 focalTopRight = glm::mix(viewFrustum.getNearTopRight(), viewFrustum.getFarTopRight(), focalProportion); | |
| 3001 | + glVertex3f(focalTopLeft.x, focalTopLeft.y, focalTopLeft.z); | |
| 3002 | + glVertex3f(focalTopRight.x, focalTopRight.y, focalTopRight.z); | |
| 3003 | + | |
| 3004 | + // focal plane - left edge | |
| 3005 | + glVertex3f(focalBottomLeft.x, focalBottomLeft.y, focalBottomLeft.z); | |
| 3006 | + glVertex3f(focalTopLeft.x, focalTopLeft.y, focalTopLeft.z); | |
| 3007 | + | |
| 3008 | + // focal plane - right edge | |
| 3009 | + glVertex3f(focalBottomRight.x, focalBottomRight.y, focalBottomRight.z); | |
| 3010 | + glVertex3f(focalTopRight.x, focalTopRight.y, focalTopRight.z); | |
| 2972 | 3011 | } |
| 2973 | 3012 | glEnd(); |
| 2974 | 3013 | glEnable(GL_LIGHTING); |