mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-08-08 23:07:26 +02:00
RearView Tools
- moved to separate class - new icon/button for restore view -
This commit is contained in:
parent
8cbf5a88e5
commit
f675b198cb
4 changed files with 162 additions and 58 deletions
|
@ -89,8 +89,6 @@ const int MIRROR_VIEW_TOP_PADDING = 5;
|
||||||
const int MIRROR_VIEW_LEFT_PADDING = 10;
|
const int MIRROR_VIEW_LEFT_PADDING = 10;
|
||||||
const int MIRROR_VIEW_WIDTH = 265;
|
const int MIRROR_VIEW_WIDTH = 265;
|
||||||
const int MIRROR_VIEW_HEIGHT = 215;
|
const int MIRROR_VIEW_HEIGHT = 215;
|
||||||
const int MIRROR_ICON_SIZE = 16;
|
|
||||||
const int MIRROR_CLOSE_ICON_PADDING = 5;
|
|
||||||
|
|
||||||
void messageHandler(QtMsgType type, const QMessageLogContext& context, const QString &message) {
|
void messageHandler(QtMsgType type, const QMessageLogContext& context, const QString &message) {
|
||||||
fprintf(stdout, "%s", message.toLocal8Bit().constData());
|
fprintf(stdout, "%s", message.toLocal8Bit().constData());
|
||||||
|
@ -109,6 +107,7 @@ Application::Application(int& argc, char** argv, timeval &startup_time) :
|
||||||
_wantToKillLocalVoxels(false),
|
_wantToKillLocalVoxels(false),
|
||||||
_audioScope(256, 200, true),
|
_audioScope(256, 200, true),
|
||||||
_profile(QString()),
|
_profile(QString()),
|
||||||
|
_mirrorViewRect(QRect(MIRROR_VIEW_LEFT_PADDING, MIRROR_VIEW_TOP_PADDING, MIRROR_VIEW_WIDTH, MIRROR_VIEW_HEIGHT)),
|
||||||
_mouseX(0),
|
_mouseX(0),
|
||||||
_mouseY(0),
|
_mouseY(0),
|
||||||
_lastMouseMove(usecTimestampNow()),
|
_lastMouseMove(usecTimestampNow()),
|
||||||
|
@ -454,11 +453,7 @@ void Application::paintGL() {
|
||||||
displaySide(_mirrorCamera, selfAvatarOnly);
|
displaySide(_mirrorCamera, selfAvatarOnly);
|
||||||
glPopMatrix();
|
glPopMatrix();
|
||||||
|
|
||||||
// render rear view tools if mouse is in the bounds
|
_rearMirrorTools->render();
|
||||||
QPoint mousePosition = _glWidget->mapFromGlobal(QCursor::pos());
|
|
||||||
if (_mirrorViewRect.contains(mousePosition.x(), mousePosition.y())) {
|
|
||||||
displayRearMirrorTools();
|
|
||||||
}
|
|
||||||
|
|
||||||
// reset Viewport and projection matrix
|
// reset Viewport and projection matrix
|
||||||
glViewport(0, 0, _glWidget->width(), _glWidget->height());
|
glViewport(0, 0, _glWidget->width(), _glWidget->height());
|
||||||
|
@ -489,8 +484,6 @@ void Application::resizeGL(int width, int height) {
|
||||||
resetCamerasOnResizeGL(_viewFrustumOffsetCamera, width, height);
|
resetCamerasOnResizeGL(_viewFrustumOffsetCamera, width, height);
|
||||||
resetCamerasOnResizeGL(_myCamera, width, height);
|
resetCamerasOnResizeGL(_myCamera, width, height);
|
||||||
|
|
||||||
_mirrorViewRect = QRect(MIRROR_VIEW_LEFT_PADDING, MIRROR_VIEW_TOP_PADDING, MIRROR_VIEW_WIDTH, MIRROR_VIEW_HEIGHT);
|
|
||||||
|
|
||||||
glViewport(0, 0, width, height); // shouldn't this account for the menu???
|
glViewport(0, 0, width, height); // shouldn't this account for the menu???
|
||||||
|
|
||||||
updateProjectionMatrix();
|
updateProjectionMatrix();
|
||||||
|
@ -1085,12 +1078,9 @@ void Application::mousePressEvent(QMouseEvent* event) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Menu::getInstance()->isOptionChecked(MenuOption::Mirror)) {
|
if (_rearMirrorTools->mousePressEvent(_mouseX, _mouseY)) {
|
||||||
QRect closeIconRect = QRect(MIRROR_CLOSE_ICON_PADDING + _mirrorViewRect.left(), MIRROR_CLOSE_ICON_PADDING + _mirrorViewRect.top(), MIRROR_ICON_SIZE, MIRROR_ICON_SIZE);
|
// stop propagation
|
||||||
|
return;
|
||||||
if (closeIconRect.contains(_mouseX, _mouseY)) {
|
|
||||||
Menu::getInstance()->triggerOption(MenuOption::Mirror);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!_palette.isActive() && (!_isHoverVoxel || _lookatTargetAvatar)) {
|
if (!_palette.isActive() && (!_isHoverVoxel || _lookatTargetAvatar)) {
|
||||||
|
@ -1675,10 +1665,6 @@ void Application::init() {
|
||||||
_mirrorCamera.setMode(CAMERA_MODE_MIRROR);
|
_mirrorCamera.setMode(CAMERA_MODE_MIRROR);
|
||||||
_mirrorCamera.setAspectRatio((float)MIRROR_VIEW_WIDTH / (float)MIRROR_VIEW_HEIGHT);
|
_mirrorCamera.setAspectRatio((float)MIRROR_VIEW_WIDTH / (float)MIRROR_VIEW_HEIGHT);
|
||||||
_mirrorCamera.setFieldOfView(30);
|
_mirrorCamera.setFieldOfView(30);
|
||||||
_mirrorViewRect = QRect(MIRROR_VIEW_LEFT_PADDING, MIRROR_VIEW_TOP_PADDING, MIRROR_VIEW_WIDTH, MIRROR_VIEW_HEIGHT);
|
|
||||||
|
|
||||||
switchToResourcesParentIfRequired();
|
|
||||||
_closeTextureId = _glWidget->bindTexture(QImage("./resources/images/close.png"));
|
|
||||||
|
|
||||||
OculusManager::connect();
|
OculusManager::connect();
|
||||||
if (OculusManager::isConnected()) {
|
if (OculusManager::isConnected()) {
|
||||||
|
@ -1731,8 +1717,22 @@ void Application::init() {
|
||||||
_pieMenu.addAction(_followMode);
|
_pieMenu.addAction(_followMode);
|
||||||
|
|
||||||
_audio.init(_glWidget);
|
_audio.init(_glWidget);
|
||||||
|
|
||||||
|
_rearMirrorTools = new RearMirrorTools(_glWidget, _mirrorViewRect);
|
||||||
|
connect(_rearMirrorTools, SIGNAL(closeView()), SLOT(closeMirrorView()));
|
||||||
|
connect(_rearMirrorTools, SIGNAL(restoreView()), SLOT(restoreMirrorView()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Application::closeMirrorView() {
|
||||||
|
Menu::getInstance()->triggerOption(MenuOption::Mirror);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Application::restoreMirrorView() {
|
||||||
|
Menu::getInstance()->triggerOption(MenuOption::Mirror);
|
||||||
|
if (!Menu::getInstance()->isOptionChecked(MenuOption::FullscreenMirror)) {
|
||||||
|
Menu::getInstance()->triggerOption(MenuOption::FullscreenMirror);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const float MAX_AVATAR_EDIT_VELOCITY = 1.0f;
|
const float MAX_AVATAR_EDIT_VELOCITY = 1.0f;
|
||||||
const float MAX_VOXEL_EDIT_DISTANCE = 20.0f;
|
const float MAX_VOXEL_EDIT_DISTANCE = 20.0f;
|
||||||
|
@ -3958,41 +3958,3 @@ void Application::packetSentNotification(ssize_t length) {
|
||||||
_bandwidthMeter.outputStream(BandwidthMeter::VOXELS).updateValue(length);
|
_bandwidthMeter.outputStream(BandwidthMeter::VOXELS).updateValue(length);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Application::displayRearMirrorTools() {
|
|
||||||
|
|
||||||
glMatrixMode(GL_PROJECTION);
|
|
||||||
glPushMatrix();
|
|
||||||
glLoadIdentity();
|
|
||||||
gluOrtho2D(_mirrorViewRect.left(), _mirrorViewRect.right(), _mirrorViewRect.bottom(), _mirrorViewRect.top());
|
|
||||||
glDisable(GL_DEPTH_TEST);
|
|
||||||
glDisable(GL_LIGHTING);
|
|
||||||
|
|
||||||
glEnable(GL_TEXTURE_2D);
|
|
||||||
glBindTexture(GL_TEXTURE_2D, _closeTextureId);
|
|
||||||
|
|
||||||
glColor3f(1, 1, 1);
|
|
||||||
glBegin(GL_QUADS);
|
|
||||||
|
|
||||||
int lp = MIRROR_CLOSE_ICON_PADDING + _mirrorViewRect.left();
|
|
||||||
int tp = MIRROR_CLOSE_ICON_PADDING + _mirrorViewRect.top();
|
|
||||||
int lwp = MIRROR_ICON_SIZE + lp;
|
|
||||||
int twp = MIRROR_ICON_SIZE + tp;
|
|
||||||
|
|
||||||
glTexCoord2f(1, 1);
|
|
||||||
glVertex2f(lp, tp);
|
|
||||||
|
|
||||||
glTexCoord2f(0, 1);
|
|
||||||
glVertex2f(lwp, tp);
|
|
||||||
|
|
||||||
glTexCoord2f(0, 0);
|
|
||||||
glVertex2f(lwp, twp);
|
|
||||||
|
|
||||||
glTexCoord2f(1, 0);
|
|
||||||
glVertex2f(lp, twp);
|
|
||||||
|
|
||||||
glEnd();
|
|
||||||
|
|
||||||
glPopMatrix();
|
|
||||||
|
|
||||||
glDisable(GL_TEXTURE_2D);
|
|
||||||
}
|
|
||||||
|
|
|
@ -59,6 +59,7 @@
|
||||||
#include "ui/BandwidthDialog.h"
|
#include "ui/BandwidthDialog.h"
|
||||||
#include "ui/ChatEntry.h"
|
#include "ui/ChatEntry.h"
|
||||||
#include "ui/VoxelStatsDialog.h"
|
#include "ui/VoxelStatsDialog.h"
|
||||||
|
#include "ui/RearMirrorTools.h"
|
||||||
|
|
||||||
class QAction;
|
class QAction;
|
||||||
class QActionGroup;
|
class QActionGroup;
|
||||||
|
@ -175,6 +176,7 @@ public slots:
|
||||||
void decreaseVoxelSize();
|
void decreaseVoxelSize();
|
||||||
void increaseVoxelSize();
|
void increaseVoxelSize();
|
||||||
|
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
|
|
||||||
void timer();
|
void timer();
|
||||||
|
@ -195,6 +197,9 @@ private slots:
|
||||||
glm::vec2 getScaledScreenPoint(glm::vec2 projectedPoint);
|
glm::vec2 getScaledScreenPoint(glm::vec2 projectedPoint);
|
||||||
|
|
||||||
void toggleFollowMode();
|
void toggleFollowMode();
|
||||||
|
|
||||||
|
void closeMirrorView();
|
||||||
|
void restoreMirrorView();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void resetCamerasOnResizeGL(Camera& camera, int width, int height);
|
void resetCamerasOnResizeGL(Camera& camera, int width, int height);
|
||||||
|
@ -303,7 +308,7 @@ private:
|
||||||
Camera _viewFrustumOffsetCamera; // The camera we use to sometimes show the view frustum from an offset mode
|
Camera _viewFrustumOffsetCamera; // The camera we use to sometimes show the view frustum from an offset mode
|
||||||
Camera _mirrorCamera; // Cammera for mirror view
|
Camera _mirrorCamera; // Cammera for mirror view
|
||||||
QRect _mirrorViewRect;
|
QRect _mirrorViewRect;
|
||||||
GLuint _closeTextureId;
|
RearMirrorTools* _rearMirrorTools;
|
||||||
|
|
||||||
Environment _environment;
|
Environment _environment;
|
||||||
|
|
||||||
|
|
100
interface/src/ui/RearMirrorTools.cpp
Normal file
100
interface/src/ui/RearMirrorTools.cpp
Normal file
|
@ -0,0 +1,100 @@
|
||||||
|
//
|
||||||
|
// RearMirrorTools.cpp
|
||||||
|
// interface
|
||||||
|
//
|
||||||
|
// Created by stojce on 23.10.2013.
|
||||||
|
// Copyright (c) 2013 High Fidelity, Inc. All rights reserved.
|
||||||
|
|
||||||
|
#include "RearMirrorTools.h"
|
||||||
|
#include <SharedUtil.h>
|
||||||
|
#include <QMouseEvent>
|
||||||
|
|
||||||
|
const int MIRROR_ICON_SIZE = 16;
|
||||||
|
const int MIRROR_ICON_PADDING = 5;
|
||||||
|
|
||||||
|
RearMirrorTools::RearMirrorTools(QGLWidget* parent, QRect& bounds) : _parent(parent), _bounds(bounds), _visible(false) {
|
||||||
|
switchToResourcesParentIfRequired();
|
||||||
|
_closeTextureId = _parent->bindTexture(QImage("./resources/images/close.png"));
|
||||||
|
_restoreTextureId = _parent->bindTexture(QImage("./resources/images/close.png"));
|
||||||
|
};
|
||||||
|
|
||||||
|
void RearMirrorTools::render() {
|
||||||
|
// render rear view tools if mouse is in the bounds
|
||||||
|
QPoint mousePosition = _parent->mapFromGlobal(QCursor::pos());
|
||||||
|
_visible = _bounds.contains(mousePosition.x(), mousePosition.y());
|
||||||
|
if (_visible) {
|
||||||
|
displayTools();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool RearMirrorTools::mousePressEvent(int x, int y) {
|
||||||
|
QRect closeIconRect = QRect(MIRROR_ICON_PADDING + _bounds.left(), MIRROR_ICON_PADDING + _bounds.top(), MIRROR_ICON_SIZE, MIRROR_ICON_SIZE);
|
||||||
|
QRect restoreIconRect = QRect(_bounds.width() - _bounds.left() - MIRROR_ICON_PADDING, MIRROR_ICON_PADDING + _bounds.top(), MIRROR_ICON_SIZE, MIRROR_ICON_SIZE);
|
||||||
|
|
||||||
|
if (closeIconRect.contains(x, y)) {
|
||||||
|
emit closeView();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (restoreIconRect.contains(x, y)) {
|
||||||
|
emit restoreView();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
void RearMirrorTools::displayTools() {
|
||||||
|
int closeLeft = MIRROR_ICON_PADDING + _bounds.left();
|
||||||
|
int resoreLeft = _bounds.width() - _bounds.left() - MIRROR_ICON_PADDING;
|
||||||
|
|
||||||
|
int iconTop = MIRROR_ICON_PADDING + _bounds.top();
|
||||||
|
int twp = MIRROR_ICON_SIZE + iconTop;
|
||||||
|
|
||||||
|
glMatrixMode(GL_PROJECTION);
|
||||||
|
glPushMatrix();
|
||||||
|
glLoadIdentity();
|
||||||
|
gluOrtho2D(_bounds.left(), _bounds.right(), _bounds.bottom(), _bounds.top());
|
||||||
|
glDisable(GL_DEPTH_TEST);
|
||||||
|
glDisable(GL_LIGHTING);
|
||||||
|
glEnable(GL_TEXTURE_2D);
|
||||||
|
|
||||||
|
glColor3f(1, 1, 1);
|
||||||
|
|
||||||
|
glBindTexture(GL_TEXTURE_2D, _closeTextureId);
|
||||||
|
glBegin(GL_QUADS);
|
||||||
|
{
|
||||||
|
glTexCoord2f(1, 1);
|
||||||
|
glVertex2f(closeLeft, iconTop);
|
||||||
|
|
||||||
|
glTexCoord2f(0, 1);
|
||||||
|
glVertex2f(MIRROR_ICON_SIZE + closeLeft, iconTop);
|
||||||
|
|
||||||
|
glTexCoord2f(0, 0);
|
||||||
|
glVertex2f(MIRROR_ICON_SIZE + closeLeft, twp);
|
||||||
|
|
||||||
|
glTexCoord2f(1, 0);
|
||||||
|
glVertex2f(closeLeft, twp);
|
||||||
|
}
|
||||||
|
glEnd();
|
||||||
|
|
||||||
|
glBindTexture(GL_TEXTURE_2D, _restoreTextureId);
|
||||||
|
glBegin(GL_QUADS);
|
||||||
|
{
|
||||||
|
glTexCoord2f(1, 1);
|
||||||
|
glVertex2f(resoreLeft, iconTop);
|
||||||
|
|
||||||
|
glTexCoord2f(0, 1);
|
||||||
|
glVertex2f(MIRROR_ICON_SIZE + resoreLeft, iconTop);
|
||||||
|
|
||||||
|
glTexCoord2f(0, 0);
|
||||||
|
glVertex2f(MIRROR_ICON_SIZE + resoreLeft, twp);
|
||||||
|
|
||||||
|
glTexCoord2f(1, 0);
|
||||||
|
glVertex2f(resoreLeft, twp);
|
||||||
|
}
|
||||||
|
glEnd();
|
||||||
|
|
||||||
|
glPopMatrix();
|
||||||
|
glDisable(GL_TEXTURE_2D);
|
||||||
|
}
|
37
interface/src/ui/RearMirrorTools.h
Normal file
37
interface/src/ui/RearMirrorTools.h
Normal file
|
@ -0,0 +1,37 @@
|
||||||
|
//
|
||||||
|
// RearMirrorTools.h
|
||||||
|
// interface
|
||||||
|
//
|
||||||
|
// Created by stojce on 23.10.2013.
|
||||||
|
// Copyright (c) 2013 High Fidelity, Inc. All rights reserved.
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef __hifi__RearMirrorTools__
|
||||||
|
#define __hifi__RearMirrorTools__
|
||||||
|
|
||||||
|
#include "InterfaceConfig.h"
|
||||||
|
|
||||||
|
#include <QGLWidget>
|
||||||
|
|
||||||
|
class RearMirrorTools : public QObject {
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
RearMirrorTools(QGLWidget* parent, QRect& bounds);
|
||||||
|
void render();
|
||||||
|
bool mousePressEvent(int x, int y);
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void closeView();
|
||||||
|
void restoreView();
|
||||||
|
|
||||||
|
private:
|
||||||
|
QGLWidget* _parent;
|
||||||
|
QRect _bounds;
|
||||||
|
GLuint _closeTextureId;
|
||||||
|
GLuint _restoreTextureId;
|
||||||
|
bool _visible;
|
||||||
|
|
||||||
|
void displayTools();
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif /* defined(__hifi__RearMirrorTools__) */
|
Loading…
Reference in a new issue