mirror of
https://github.com/overte-org/overte.git
synced 2025-08-04 04:23:33 +02:00
commit
4771982c30
5 changed files with 191 additions and 60 deletions
BIN
interface/resources/images/reset.png
Normal file
BIN
interface/resources/images/reset.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.3 KiB |
|
@ -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,16 +453,14 @@ void Application::paintGL() {
|
||||||
displaySide(_mirrorCamera, selfAvatarOnly);
|
displaySide(_mirrorCamera, selfAvatarOnly);
|
||||||
glPopMatrix();
|
glPopMatrix();
|
||||||
|
|
||||||
// render rear view tools if mouse is in the bounds
|
_rearMirrorTools->render(false);
|
||||||
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());
|
||||||
glDisable(GL_SCISSOR_TEST);
|
glDisable(GL_SCISSOR_TEST);
|
||||||
updateProjectionMatrix(_myCamera, updateViewFrustum);
|
updateProjectionMatrix(_myCamera, updateViewFrustum);
|
||||||
|
} else if (Menu::getInstance()->isOptionChecked(MenuOption::FullscreenMirror)) {
|
||||||
|
_rearMirrorTools->render(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
displayOverlay();
|
displayOverlay();
|
||||||
|
@ -489,8 +486,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();
|
||||||
|
@ -690,7 +685,6 @@ void Application::keyPressEvent(QKeyEvent* event) {
|
||||||
|
|
||||||
case Qt::Key_Space:
|
case Qt::Key_Space:
|
||||||
resetSensors();
|
resetSensors();
|
||||||
_audio.reset();
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Qt::Key_G:
|
case Qt::Key_G:
|
||||||
|
@ -1085,12 +1079,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 +1666,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 +1718,39 @@ 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()));
|
||||||
|
connect(_rearMirrorTools, SIGNAL(shrinkView()), SLOT(shrinkMirrorView()));
|
||||||
|
connect(_rearMirrorTools, SIGNAL(resetView()), SLOT(resetSensors()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Application::closeMirrorView() {
|
||||||
|
if (Menu::getInstance()->isOptionChecked(MenuOption::Mirror)) {
|
||||||
|
Menu::getInstance()->triggerOption(MenuOption::Mirror);;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void Application::restoreMirrorView() {
|
||||||
|
if (Menu::getInstance()->isOptionChecked(MenuOption::Mirror)) {
|
||||||
|
Menu::getInstance()->triggerOption(MenuOption::Mirror);;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!Menu::getInstance()->isOptionChecked(MenuOption::FullscreenMirror)) {
|
||||||
|
Menu::getInstance()->triggerOption(MenuOption::FullscreenMirror);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void Application::shrinkMirrorView() {
|
||||||
|
if (!Menu::getInstance()->isOptionChecked(MenuOption::Mirror)) {
|
||||||
|
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;
|
||||||
|
@ -3758,6 +3776,8 @@ void Application::resetSensors() {
|
||||||
_myTransmitter.resetLevels();
|
_myTransmitter.resetLevels();
|
||||||
_myAvatar.setVelocity(glm::vec3(0,0,0));
|
_myAvatar.setVelocity(glm::vec3(0,0,0));
|
||||||
_myAvatar.setThrust(glm::vec3(0,0,0));
|
_myAvatar.setThrust(glm::vec3(0,0,0));
|
||||||
|
|
||||||
|
_audio.reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void setShortcutsEnabled(QWidget* widget, bool enabled) {
|
static void setShortcutsEnabled(QWidget* widget, bool enabled) {
|
||||||
|
@ -3957,41 +3977,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,11 @@ private slots:
|
||||||
glm::vec2 getScaledScreenPoint(glm::vec2 projectedPoint);
|
glm::vec2 getScaledScreenPoint(glm::vec2 projectedPoint);
|
||||||
|
|
||||||
void toggleFollowMode();
|
void toggleFollowMode();
|
||||||
|
|
||||||
|
void closeMirrorView();
|
||||||
|
void restoreMirrorView();
|
||||||
|
void shrinkMirrorView();
|
||||||
|
void resetSensors();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void resetCamerasOnResizeGL(Camera& camera, int width, int height);
|
void resetCamerasOnResizeGL(Camera& camera, int width, int height);
|
||||||
|
@ -235,7 +242,6 @@ private:
|
||||||
bool maybeEditVoxelUnderCursor();
|
bool maybeEditVoxelUnderCursor();
|
||||||
void deleteVoxelUnderCursor();
|
void deleteVoxelUnderCursor();
|
||||||
void eyedropperVoxelUnderCursor();
|
void eyedropperVoxelUnderCursor();
|
||||||
void resetSensors();
|
|
||||||
void injectVoxelAddedSoundEffect();
|
void injectVoxelAddedSoundEffect();
|
||||||
|
|
||||||
void setMenuShortcutsEnabled(bool enabled);
|
void setMenuShortcutsEnabled(bool enabled);
|
||||||
|
@ -303,7 +309,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;
|
||||||
|
|
||||||
|
|
103
interface/src/ui/RearMirrorTools.cpp
Normal file
103
interface/src/ui/RearMirrorTools.cpp
Normal file
|
@ -0,0 +1,103 @@
|
||||||
|
//
|
||||||
|
// 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 ICON_SIZE = 16;
|
||||||
|
const int ICON_PADDING = 5;
|
||||||
|
|
||||||
|
RearMirrorTools::RearMirrorTools(QGLWidget* parent, QRect& bounds) : _parent(parent), _bounds(bounds), _windowed(false), _fullScreen(false) {
|
||||||
|
switchToResourcesParentIfRequired();
|
||||||
|
_closeTextureId = _parent->bindTexture(QImage("./resources/images/close.png"));
|
||||||
|
_resetTextureId = _parent->bindTexture(QImage("./resources/images/reset.png"));
|
||||||
|
};
|
||||||
|
|
||||||
|
void RearMirrorTools::render(bool fullScreen) {
|
||||||
|
if (fullScreen) {
|
||||||
|
_fullScreen = true;
|
||||||
|
displayIcon(_parent->geometry(), ICON_PADDING, ICON_PADDING, _closeTextureId);
|
||||||
|
} else {
|
||||||
|
// render rear view tools if mouse is in the bounds
|
||||||
|
QPoint mousePosition = _parent->mapFromGlobal(QCursor::pos());
|
||||||
|
_windowed = _bounds.contains(mousePosition.x(), mousePosition.y());
|
||||||
|
if (_windowed) {
|
||||||
|
displayIcon(_bounds, _bounds.left() + ICON_PADDING, _bounds.top() + ICON_PADDING, _closeTextureId);
|
||||||
|
displayIcon(_bounds, _bounds.width() - ICON_SIZE - ICON_PADDING, _bounds.top() + ICON_PADDING, _resetTextureId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool RearMirrorTools::mousePressEvent(int x, int y) {
|
||||||
|
if (_windowed) {
|
||||||
|
QRect closeIconRect = QRect(_bounds.left() + ICON_PADDING, _bounds.top() + ICON_PADDING, ICON_SIZE, ICON_SIZE);
|
||||||
|
if (closeIconRect.contains(x, y)) {
|
||||||
|
_windowed = false;
|
||||||
|
emit closeView();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
QRect resetIconRect = QRect(_bounds.width() - ICON_SIZE - ICON_PADDING, _bounds.top() + ICON_PADDING, ICON_SIZE, ICON_SIZE);
|
||||||
|
if (resetIconRect.contains(x, y)) {
|
||||||
|
emit resetView();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_bounds.contains(x, y)) {
|
||||||
|
_windowed = false;
|
||||||
|
emit restoreView();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_fullScreen) {
|
||||||
|
QRect shrinkIconRect = QRect(ICON_PADDING, ICON_PADDING, ICON_SIZE, ICON_SIZE);
|
||||||
|
if (shrinkIconRect.contains(x, y)) {
|
||||||
|
_fullScreen = false;
|
||||||
|
emit shrinkView();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
void RearMirrorTools::displayIcon(QRect bounds, int left, int top, GLuint textureId) {
|
||||||
|
|
||||||
|
int twp = ICON_SIZE + top;
|
||||||
|
|
||||||
|
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, textureId);
|
||||||
|
glBegin(GL_QUADS);
|
||||||
|
{
|
||||||
|
glTexCoord2f(0, 0);
|
||||||
|
glVertex2f(left, top);
|
||||||
|
|
||||||
|
glTexCoord2f(1, 0);
|
||||||
|
glVertex2f(ICON_SIZE + left, top);
|
||||||
|
|
||||||
|
glTexCoord2f(1, 1);
|
||||||
|
glVertex2f(ICON_SIZE + left, twp);
|
||||||
|
|
||||||
|
glTexCoord2f(0, 1);
|
||||||
|
glVertex2f(left, twp);
|
||||||
|
}
|
||||||
|
glEnd();
|
||||||
|
glPopMatrix();
|
||||||
|
glBindTexture(GL_TEXTURE_2D, 0);
|
||||||
|
glDisable(GL_TEXTURE_2D);
|
||||||
|
}
|
40
interface/src/ui/RearMirrorTools.h
Normal file
40
interface/src/ui/RearMirrorTools.h
Normal file
|
@ -0,0 +1,40 @@
|
||||||
|
//
|
||||||
|
// 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 fullScreen);
|
||||||
|
bool mousePressEvent(int x, int y);
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void closeView();
|
||||||
|
void shrinkView();
|
||||||
|
void resetView();
|
||||||
|
void restoreView();
|
||||||
|
|
||||||
|
private:
|
||||||
|
QGLWidget* _parent;
|
||||||
|
QRect _bounds;
|
||||||
|
GLuint _closeTextureId;
|
||||||
|
GLuint _resetTextureId;
|
||||||
|
bool _windowed;
|
||||||
|
bool _fullScreen;
|
||||||
|
|
||||||
|
void displayIcon(QRect bounds, int left, int top, GLuint textureId);
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif /* defined(__hifi__RearMirrorTools__) */
|
Loading…
Reference in a new issue