History

close button on rear mirror view

stojce committed 13 years ago

Commit 2fcb2461 parent 890313b5 files · +107 −29Browse files

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

Unified · Split

interface/src/Application.cpp+85−27
@@ -69,6 +69,11 @@ · 68 unmodified lines
69#include "ui/TextRenderer.h"69#include "ui/TextRenderer.h"
70#include "InfoView.h"70#include "InfoView.h"
71 71
72#include <QSvgRenderer>
73#include <QPainter>
74#include <QGLWidget>
75#include <SharedUtil.h>
76
72using namespace std;77using namespace std;
73 78
74// Starfield information79// Starfield information
@@ -85,11 +90,12 @@ const int STARTUP_JITTER_SAMPLES = PACKET_LENGTH_SAMPLES_PER_CHANNEL / 2; · 10 unmodified lines
85 // Startup optimistically with small jitter buffer that 90 // Startup optimistically with small jitter buffer that
86 // will start playback on the second received audio packet.91 // will start playback on the second received audio packet.
87 92
88
89const int MIRROR_VIEW_TOP_PADDING = 5;93const int MIRROR_VIEW_TOP_PADDING = 5;
90const int MIRROR_VIEW_LEFT_PADDING = 10;94const int MIRROR_VIEW_LEFT_PADDING = 10;
91const int MIRROR_VIEW_WIDTH = 265;95const int MIRROR_VIEW_WIDTH = 265;
92const int MIRROR_VIEW_HEIGHT = 215;96const int MIRROR_VIEW_HEIGHT = 215;
97const int MIRROR_ICON_SIZE = 16;
98const int MIRROR_CLOSE_ICON_PADDING = 5;
93 99
94void messageHandler(QtMsgType type, const QMessageLogContext& context, const QString &message) {100void messageHandler(QtMsgType type, const QMessageLogContext& context, const QString &message) {
95 fprintf(stdout, "%s", message.toLocal8Bit().constData());101 fprintf(stdout, "%s", message.toLocal8Bit().constData());
@@ -258,12 +264,12 @@ void Application::restoreSizeAndPosition() { · 162 unmodified lines
258 264
259 settings->beginGroup("Window");265 settings->beginGroup("Window");
260 266
261 float x = loadSetting(settings, "x", 0);267 int x = (int) loadSetting(settings, "x", 0);
262 float y = loadSetting(settings, "y", 0);268 int y = (int) loadSetting(settings, "y", 0);
263 _window->move(x, y);269 _window->move(x, y);
264 270
265 int width = loadSetting(settings, "width", available.width());271 int width = (int) loadSetting(settings, "width", available.width());
266 int height = loadSetting(settings, "height", available.height());272 int height = (int) loadSetting(settings, "height", available.height());
267 _window->resize(width, height);273 _window->resize(width, height);
268 274
269 settings->endGroup();275 settings->endGroup();
@@ -427,7 +433,6 @@ void Application::paintGL() { · 157 unmodified lines
427 _glowEffect.render();433 _glowEffect.render();
428 434
429 if (Menu::getInstance()->isOptionChecked(MenuOption::Mirror)) {435 if (Menu::getInstance()->isOptionChecked(MenuOption::Mirror)) {
430
431 glm::vec3 targetPosition = _myAvatar.getEyeLevelPosition();436 glm::vec3 targetPosition = _myAvatar.getEyeLevelPosition();
432 if (_myAvatar.getHead().getBlendFace().isActive()) {437 if (_myAvatar.getHead().getBlendFace().isActive()) {
433 // make sure we're aligned to the blend face eyes438 // make sure we're aligned to the blend face eyes
@@ -441,21 +446,30 @@ void Application::paintGL() { · 7 unmodified lines
441 _mirrorCamera.setTargetRotation(_myAvatar.getWorldAlignedOrientation() * glm::quat(glm::vec3(0.0f, PIf, 0.0f)));446 _mirrorCamera.setTargetRotation(_myAvatar.getWorldAlignedOrientation() * glm::quat(glm::vec3(0.0f, PIf, 0.0f)));
442 _mirrorCamera.update(1.0f/_fps);447 _mirrorCamera.update(1.0f/_fps);
443 448
444 glViewport(MIRROR_VIEW_LEFT_PADDING, _glWidget->height() - MIRROR_VIEW_HEIGHT - MIRROR_VIEW_TOP_PADDING, MIRROR_VIEW_WIDTH, MIRROR_VIEW_HEIGHT);449 // set the bounds of rear mirror view
445 glScissor(MIRROR_VIEW_LEFT_PADDING, _glWidget->height() - MIRROR_VIEW_HEIGHT - MIRROR_VIEW_TOP_PADDING, MIRROR_VIEW_WIDTH, MIRROR_VIEW_HEIGHT);450 glViewport(_mirrorViewRect.x(), _glWidget->height() - _mirrorViewRect.y() - _mirrorViewRect.height(), _mirrorViewRect.width(), _mirrorViewRect.height());
446 451 glScissor(_mirrorViewRect.x(), _glWidget->height() - _mirrorViewRect.y() - _mirrorViewRect.height(), _mirrorViewRect.width(), _mirrorViewRect.height());
447 updateProjectionMatrix(_mirrorCamera);452 updateProjectionMatrix(_mirrorCamera);
448
449 glEnable(GL_SCISSOR_TEST);453 glEnable(GL_SCISSOR_TEST);
450 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);454 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
455
456 // render rear mirror view
451 glPushMatrix();457 glPushMatrix();
452 displaySide(_mirrorCamera);458 displaySide(_mirrorCamera);
453 glPopMatrix();459 glPopMatrix();
454 460
455 // reset Viewport461 // render rear view tools if mouse is in the bounds
462 QPoint mousePosition = _glWidget->mapFromGlobal(QCursor::pos());
463
464 qDebug("mouse pos: x = %d, y = %d\n", mousePosition.x(), mousePosition.y());
465
466 if (_mirrorViewRect.contains(mousePosition.x(), mousePosition.y())) {
467 displayRearMirrorTools();
468 }
469
470 // reset Viewport and projection matrix
456 glViewport(0, 0, _glWidget->width(), _glWidget->height());471 glViewport(0, 0, _glWidget->width(), _glWidget->height());
457 glDisable(GL_SCISSOR_TEST);472 glDisable(GL_SCISSOR_TEST);
458
459 updateProjectionMatrix();473 updateProjectionMatrix();
460 }474 }
461 475
@@ -481,6 +495,8 @@ void Application::resetCamerasOnResizeGL(Camera& camera, int width, int height) · 19 unmodified lines
481void Application::resizeGL(int width, int height) {495void Application::resizeGL(int width, int height) {
482 resetCamerasOnResizeGL(_viewFrustumOffsetCamera, width, height);496 resetCamerasOnResizeGL(_viewFrustumOffsetCamera, width, height);
483 resetCamerasOnResizeGL(_myCamera, width, height);497 resetCamerasOnResizeGL(_myCamera, width, height);
498
499 _mirrorViewRect = QRect(MIRROR_VIEW_LEFT_PADDING, MIRROR_VIEW_TOP_PADDING, MIRROR_VIEW_WIDTH, MIRROR_VIEW_HEIGHT);
484 500
485 glViewport(0, 0, width, height); // shouldn't this account for the menu???501 glViewport(0, 0, width, height); // shouldn't this account for the menu???
486 502
@@ -1024,7 +1040,7 @@ void Application::mouseMoveEvent(QMouseEvent* event) { · 537 unmodified lines
1024 if (activeWindow() == _window) {1040 if (activeWindow() == _window) {
1025 _mouseX = event->x();1041 _mouseX = event->x();
1026 _mouseY = event->y();1042 _mouseY = event->y();
1027 1043
1028 // detect drag1044 // detect drag
1029 glm::vec3 mouseVoxelPos(_mouseVoxel.x, _mouseVoxel.y, _mouseVoxel.z);1045 glm::vec3 mouseVoxelPos(_mouseVoxel.x, _mouseVoxel.y, _mouseVoxel.z);
1030 if (!_justEditedVoxel && mouseVoxelPos != _lastMouseVoxelPos) {1046 if (!_justEditedVoxel && mouseVoxelPos != _lastMouseVoxelPos) {
@@ -1062,6 +1078,15 @@ void Application::mousePressEvent(QMouseEvent* event) { · 31 unmodified lines
1062 return;1078 return;
1063 }1079 }
1064 1080
1081 if (Menu::getInstance()->isOptionChecked(MenuOption::Mirror)) {
1082
1083 QRect closeIconRect = QRect(MIRROR_CLOSE_ICON_PADDING + _mirrorViewRect.left(), MIRROR_CLOSE_ICON_PADDING + _mirrorViewRect.top(), MIRROR_ICON_SIZE, MIRROR_ICON_SIZE);
1084
1085 if (closeIconRect.contains(_mouseX, _mouseY)) {
1086 Menu::getInstance()->triggerOption(MenuOption::Mirror);
1087 }
1088 }
1089
1065 if (!_palette.isActive() && (!_isHoverVoxel || _lookatTargetAvatar)) {1090 if (!_palette.isActive() && (!_isHoverVoxel || _lookatTargetAvatar)) {
1066 _pieMenu.mousePressEvent(_mouseX, _mouseY);1091 _pieMenu.mousePressEvent(_mouseX, _mouseY);
1067 }1092 }
@@ -1636,11 +1661,14 @@ void Application::init() { · 568 unmodified lines
1636 _myAvatar.setPosition(START_LOCATION);1661 _myAvatar.setPosition(START_LOCATION);
1637 _myCamera.setMode(CAMERA_MODE_FIRST_PERSON);1662 _myCamera.setMode(CAMERA_MODE_FIRST_PERSON);
1638 _myCamera.setModeShiftRate(1.0f);1663 _myCamera.setModeShiftRate(1.0f);
1639 _myAvatar.setDisplayingLookatVectors(false); 1664 _myAvatar.setDisplayingLookatVectors(false);
1665
1640 _mirrorCamera.setMode(CAMERA_MODE_MIRROR);1666 _mirrorCamera.setMode(CAMERA_MODE_MIRROR);
1641 _mirrorCamera.setModeShiftRate(1.0f);
1642 _mirrorCamera.setAspectRatio((float)MIRROR_VIEW_WIDTH / (float)MIRROR_VIEW_HEIGHT);1667 _mirrorCamera.setAspectRatio((float)MIRROR_VIEW_WIDTH / (float)MIRROR_VIEW_HEIGHT);
1643 _mirrorCamera.setFieldOfView(DEFAULT_FIELD_OF_VIEW_DEGREES);1668 _mirrorViewRect = QRect(MIRROR_VIEW_LEFT_PADDING, MIRROR_VIEW_TOP_PADDING, MIRROR_VIEW_WIDTH, MIRROR_VIEW_HEIGHT);
1669
1670 switchToResourcesParentIfRequired();
1671 _closeTextureId = _glWidget->bindTexture(QImage("./resources/images/close.png"));
1644 1672
1645 OculusManager::connect();1673 OculusManager::connect();
1646 if (OculusManager::isConnected()) {1674 if (OculusManager::isConnected()) {
@@ -2472,15 +2500,6 @@ void Application::computeOffAxisFrustum(float& left, float& right, float& bottom · 825 unmodified lines
2472 float& far, glm::vec4& nearClipPlane, glm::vec4& farClipPlane) const {2500 float& far, glm::vec4& nearClipPlane, glm::vec4& farClipPlane) const {
2473 2501
2474 _viewFrustum.computeOffAxisFrustum(left, right, bottom, top, near, far, nearClipPlane, farClipPlane);2502 _viewFrustum.computeOffAxisFrustum(left, right, bottom, top, near, far, nearClipPlane, farClipPlane);
2475
2476 /*
2477 // when mirrored, we must flip left and right
2478 if (_myCamera.getMode() == CAMERA_MODE_MIRROR) {
2479 float tmp = left;
2480 left = -right;
2481 right = -tmp;
2482 }
2483 */
2484}2503}
2485 2504
2486void Application::displaySide(Camera& whichCamera) {2505void Application::displaySide(Camera& whichCamera) {
@@ -2730,7 +2749,7 @@ void Application::displaySide(Camera& whichCamera) { · 243 unmodified lines
2730 }2749 }
2731 2750
2732 // brad's frustum for debugging2751 // brad's frustum for debugging
2733 if (Menu::getInstance()->isOptionChecked(MenuOption::DisplayFrustum)) {2752 if (Menu::getInstance()->isOptionChecked(MenuOption::DisplayFrustum) && whichCamera.getMode() != CAMERA_MODE_MIRROR) {
2734 PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings), 2753 PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings),
2735 "Application::displaySide() ... renderViewFrustum...");2754 "Application::displaySide() ... renderViewFrustum...");
2736 renderViewFrustum(_viewFrustum);2755 renderViewFrustum(_viewFrustum);
@@ -2962,7 +2981,7 @@ void Application::displayOverlay() { · 225 unmodified lines
2962 if (_pieMenu.isDisplayed()) {2981 if (_pieMenu.isDisplayed()) {
2963 _pieMenu.render();2982 _pieMenu.render();
2964 }2983 }
2965 2984
2966 glPopMatrix();2985 glPopMatrix();
2967}2986}
2968 2987
@@ -3781,3 +3800,42 @@ void* Application::networkReceive(void* args) { · 812 unmodified lines
3781void Application::packetSentNotification(ssize_t length) {3800void Application::packetSentNotification(ssize_t length) {
3782 _bandwidthMeter.outputStream(BandwidthMeter::VOXELS).updateValue(length); 3801 _bandwidthMeter.outputStream(BandwidthMeter::VOXELS).updateValue(length);
3783}3802}
3803
3804void Application::displayRearMirrorTools() {
3805
3806 glMatrixMode(GL_PROJECTION);
3807 glPushMatrix();
3808 glLoadIdentity();
3809 gluOrtho2D(_mirrorViewRect.left(), _mirrorViewRect.right(), _mirrorViewRect.bottom(), _mirrorViewRect.top());
3810 glDisable(GL_DEPTH_TEST);
3811 glDisable(GL_LIGHTING);
3812
3813 glEnable(GL_TEXTURE_2D);
3814 glBindTexture(GL_TEXTURE_2D, _closeTextureId);
3815
3816 glColor3f(1, 1, 1);
3817 glBegin(GL_QUADS);
3818
3819 int lp = MIRROR_CLOSE_ICON_PADDING + _mirrorViewRect.left();
3820 int tp = MIRROR_CLOSE_ICON_PADDING + _mirrorViewRect.top();
3821 int lwp = MIRROR_ICON_SIZE + lp;
3822 int twp = MIRROR_ICON_SIZE + tp;
3823
3824 glTexCoord2f(1, 1);
3825 glVertex2f(lp, tp);
3826
3827 glTexCoord2f(0, 1);
3828 glVertex2f(lwp, tp);
3829
3830 glTexCoord2f(0, 0);
3831 glVertex2f(lwp, twp);
3832
3833 glTexCoord2f(1, 0);
3834 glVertex2f(lp, twp);
3835
3836 glEnd();
3837
3838 glPopMatrix();
3839
3840 glDisable(GL_TEXTURE_2D);
3841}

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