History

Merge remote-tracking branch 'upstream/master'

LionTurtle committed 13 years ago

Commit b0803c12 parents ac878c9 e31ba3b22 files · +540 −251Browse files

Showing the changes to interface/src/Application.cpp (1 of 22 files). Show all

Unified · Split

interface/src/Application.cpp+53−14
@@ -48,7 +48,7 @@ · 47 unmodified lines
4848 #include <NodeTypes.h>
4949 #include <AudioInjectionManager.h>
5050 #include <AudioInjector.h>
51−#include <Logstash.h>
51+#include <Logging.h>
5252 #include <OctalCode.h>
5353 #include <PacketHeaders.h>
5454 #include <PairingHandler.h>
@@ -319,7 +319,7 @@ void Application::initializeGL() { · 264 unmodified lines
319319 const char LOGSTASH_INTERFACE_START_TIME_KEY[] = "interface-start-time";
320320
321321 // 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);
323323 }
324324
325325 // update before the first render
@@ -424,9 +424,6 @@ void Application::resizeGL(int width, int height) { · 98 unmodified lines
424424 resetCamerasOnResizeGL(_viewFrustumOffsetCamera, width, height);
425425 resetCamerasOnResizeGL(_myCamera, width, height);
426426
427− // Tell our viewFrustum about this change, using the application camera
428− loadViewFrustum(_myCamera, _viewFrustum);
429−
430427 glViewport(0, 0, width, height); // shouldn't this account for the menu???
431428
432429 updateProjectionMatrix();
@@ -437,9 +434,12 @@ void Application::updateProjectionMatrix() { · 4 unmodified lines
437434 glMatrixMode(GL_PROJECTION);
438435 glLoadIdentity();
439436
437+ // Tell our viewFrustum about this change, using the application camera
438+ loadViewFrustum(_myCamera, _viewFrustum);
439+
440440 float left, right, bottom, top, nearVal, farVal;
441441 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);
443443
444444 // If we're in Display Frustum mode, then we want to use the slightly adjust near/far clip values of the
445445 // _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
632632
633633 case Qt::Key_J:
634634 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+
637637 } else {
638638 _myCamera.setEyeOffsetPosition(_myCamera.getEyeOffsetPosition() + glm::vec3(-0.001, 0, 0));
639639 }
@@ -642,8 +642,8 @@ void Application::keyPressEvent(QKeyEvent* event) { · 2 unmodified lines
642642
643643 case Qt::Key_M:
644644 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+
647647 } else {
648648 _myCamera.setEyeOffsetPosition(_myCamera.getEyeOffsetPosition() + glm::vec3(0.001, 0, 0));
649649 }
@@ -1836,15 +1836,17 @@ void Application::update(float deltaTime) { · 1186 unmodified lines
18361836 }
18371837
18381838 if (Menu::getInstance()->isOptionChecked(MenuOption::OffAxisProjection)) {
1839+ float xSign = Menu::getInstance()->isOptionChecked(MenuOption::Mirror) ? 1.0f : -1.0f;
18391840 if (_faceshift.isActive()) {
1840− const float EYE_OFFSET_SCALE = 0.005f;
1841+ const float EYE_OFFSET_SCALE = 0.025f;
18411842 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));
18431844 updateProjectionMatrix();
18441845
18451846 } 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));
18481850 updateProjectionMatrix();
18491851 }
18501852 }
@@ -2166,6 +2168,19 @@ void Application::setupWorldLight(Camera& whichCamera) { · 315 unmodified lines
21662168 glMateriali(GL_FRONT, GL_SHININESS, 96);
21672169 }
21682170
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+
21692184 void Application::displaySide(Camera& whichCamera) {
21702185 // transform by eye offset
21712186
@@ -2969,6 +2984,30 @@ void Application::renderViewFrustum(ViewFrustum& viewFrustum) { · 797 unmodified lines
29692984 // left plane - top edge - viewFrustum.getNear to distant
29702985 glVertex3f(viewFrustum.getNearTopLeft().x, viewFrustum.getNearTopLeft().y, viewFrustum.getNearTopLeft().z);
29712986 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);
29723011 }
29733012 glEnd();
29743013 glEnable(GL_LIGHTING);

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