mirror of
https://github.com/lubosz/overte.git
synced 2025-04-24 07:34:02 +02:00
Merge pull request #304 from ey6es/master
Changed main globals to Application private members; switched from GLUT to Qt for windowing, input, menus.
This commit is contained in:
commit
5d6dbfbb01
6 changed files with 2221 additions and 2197 deletions
|
@ -55,7 +55,7 @@ if (APPLE)
|
|||
SET(INTERFACE_SRCS ${INTERFACE_SRCS} ${INTERFACE_RSRCS})
|
||||
endif (APPLE)
|
||||
|
||||
find_package(Qt4 REQUIRED QtCore QtGui)
|
||||
find_package(Qt4 REQUIRED QtCore QtGui QtOpenGL)
|
||||
include(${QT_USE_FILE})
|
||||
|
||||
# run qt moc on qt-enabled headers
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -9,16 +9,223 @@
|
|||
#ifndef __interface__Application__
|
||||
#define __interface__Application__
|
||||
|
||||
#include <pthread.h>
|
||||
#include <time.h>
|
||||
|
||||
#include <QApplication>
|
||||
|
||||
#include <AgentList.h>
|
||||
|
||||
#ifndef _WIN32
|
||||
#include "Audio.h"
|
||||
#endif
|
||||
|
||||
#include "Camera.h"
|
||||
#include "Environment.h"
|
||||
#include "HandControl.h"
|
||||
#include "SerialInterface.h"
|
||||
#include "Stars.h"
|
||||
#include "ViewFrustum.h"
|
||||
#include "VoxelSystem.h"
|
||||
#include "ui/ChatEntry.h"
|
||||
|
||||
class QAction;
|
||||
class QGLWidget;
|
||||
class QKeyEvent;
|
||||
class QMainWindow;
|
||||
class QMouseEvent;
|
||||
class QWheelEvent;
|
||||
|
||||
class Agent;
|
||||
class ProgramObject;
|
||||
|
||||
class Application : public QApplication {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
Application(int& argc, char** argv);
|
||||
|
||||
public slots:
|
||||
void initializeGL();
|
||||
void paintGL();
|
||||
void resizeGL(int width, int height);
|
||||
|
||||
void keyPressEvent(QKeyEvent* event);
|
||||
void keyReleaseEvent(QKeyEvent* event);
|
||||
|
||||
void mouseMoveEvent(QMouseEvent* event);
|
||||
void mousePressEvent(QMouseEvent* event);
|
||||
void mouseReleaseEvent(QMouseEvent* event);
|
||||
|
||||
void wheelEvent(QWheelEvent* event);
|
||||
|
||||
private slots:
|
||||
|
||||
void timer();
|
||||
void idle();
|
||||
void terminate();
|
||||
|
||||
void pair();
|
||||
|
||||
void setHead(bool head);
|
||||
void setNoise(bool noise);
|
||||
void setFullscreen(bool fullscreen);
|
||||
|
||||
void setRenderFirstPerson(bool firstPerson);
|
||||
void setOculus(bool oculus);
|
||||
|
||||
void setFrustumOffset(bool frustumOffset);
|
||||
void cycleFrustumRenderMode();
|
||||
|
||||
void setRenderWarnings(bool renderWarnings);
|
||||
void doKillLocalVoxels();
|
||||
void doRandomizeVoxelColors();
|
||||
void doFalseRandomizeVoxelColors();
|
||||
void doFalseRandomizeEveryOtherVoxelColors();
|
||||
void doFalseColorizeByDistance();
|
||||
void doFalseColorizeInView();
|
||||
void doTrueVoxelColors();
|
||||
void doTreeStats();
|
||||
void setWantsMonochrome(bool wantsMonochrome);
|
||||
void setWantsResIn(bool wantsResIn);
|
||||
|
||||
private:
|
||||
|
||||
void initMenu();
|
||||
void updateFrustumRenderModeAction();
|
||||
void initDisplay();
|
||||
void init();
|
||||
|
||||
void updateAvatar(float deltaTime);
|
||||
void loadViewFrustum(ViewFrustum& viewFrustum);
|
||||
|
||||
void displayOculus(Camera& whichCamera);
|
||||
void displaySide(Camera& whichCamera);
|
||||
void displayOverlay();
|
||||
void displayStats();
|
||||
|
||||
void renderViewFrustum(ViewFrustum& viewFrustum);
|
||||
|
||||
void setupPaintingVoxel();
|
||||
void shiftPaintingColor();
|
||||
void addVoxelInFrontOfAvatar();
|
||||
void addVoxelUnderCursor();
|
||||
void deleteVoxelUnderCursor();
|
||||
|
||||
void resetSensors();
|
||||
|
||||
void setMenuShortcutsEnabled(bool enabled);
|
||||
|
||||
static void attachNewHeadToAgent(Agent *newAgent);
|
||||
#ifndef _WIN32
|
||||
static void audioMixerUpdate(in_addr_t newMixerAddress, in_port_t newMixerPort);
|
||||
#endif
|
||||
static void* networkReceive(void* args);
|
||||
|
||||
QMainWindow* _window;
|
||||
QGLWidget* _glWidget;
|
||||
|
||||
QAction* _lookingInMirror; // Are we currently rendering one's own head as if in mirror?
|
||||
QAction* _gyroLook; // Whether to allow the gyro data from head to move your view
|
||||
QAction* _renderVoxels; // Whether to render voxels
|
||||
QAction* _renderStarsOn; // Whether to display the stars
|
||||
QAction* _renderAtmosphereOn; // Whether to display the atmosphere
|
||||
QAction* _renderAvatarsOn; // Whether to render avatars
|
||||
QAction* _oculusOn; // Whether to configure the display for the Oculus Rift
|
||||
QAction* _renderStatsOn; // Whether to show onscreen text overlay with stats
|
||||
QAction* _logOn; // Whether to show on-screen log
|
||||
QAction* _frustumOn; // Whether or not to display the debug view frustum
|
||||
QAction* _viewFrustumFromOffset; // Whether or not to offset the view of the frustum
|
||||
QAction* _cameraFrustum; // which frustum to look at
|
||||
QAction* _frustumRenderModeAction;
|
||||
|
||||
SerialInterface _serialPort;
|
||||
bool _displayLevels;
|
||||
|
||||
glm::vec3 _gravity;
|
||||
|
||||
// Frame Rate Measurement
|
||||
int _frameCount;
|
||||
float _fps;
|
||||
timeval _applicationStartupTime;
|
||||
timeval _timerStart, _timerEnd;
|
||||
timeval _lastTimeIdle;
|
||||
bool _justStarted;
|
||||
|
||||
Stars _stars;
|
||||
|
||||
VoxelSystem _voxels;
|
||||
QByteArray _voxelsFilename;
|
||||
bool _wantToKillLocalVoxels;
|
||||
|
||||
ViewFrustum _viewFrustum; // current state of view frustum, perspective, orientation, etc.
|
||||
|
||||
enum FrustumDrawMode { FRUSTUM_DRAW_MODE_ALL, FRUSTUM_DRAW_MODE_VECTORS, FRUSTUM_DRAW_MODE_PLANES,
|
||||
FRUSTUM_DRAW_MODE_NEAR_PLANE, FRUSTUM_DRAW_MODE_FAR_PLANE, FRUSTUM_DRAW_MODE_COUNT };
|
||||
FrustumDrawMode _frustumDrawingMode;
|
||||
|
||||
float _viewFrustumOffsetYaw; // the following variables control yaw, pitch, roll and distance form regular
|
||||
float _viewFrustumOffsetPitch; // camera to the offset camera
|
||||
float _viewFrustumOffsetRoll;
|
||||
float _viewFrustumOffsetDistance;
|
||||
float _viewFrustumOffsetUp;
|
||||
|
||||
float _mouseViewShiftYaw;
|
||||
float _mouseViewShiftPitch;
|
||||
|
||||
Oscilloscope _audioScope;
|
||||
|
||||
Avatar _myAvatar; // The rendered avatar of oneself
|
||||
Camera _myCamera; // My view onto the world
|
||||
Camera _viewFrustumOffsetCamera; // The camera we use to sometimes show the view frustum from an offset mode
|
||||
|
||||
Environment _environment;
|
||||
|
||||
int _headMouseX, _headMouseY;
|
||||
|
||||
HandControl _handControl;
|
||||
|
||||
int _mouseX;
|
||||
int _mouseY;
|
||||
bool _mousePressed; // true if mouse has been pressed (clear when finished)
|
||||
|
||||
// The current mode for mouse interaction
|
||||
enum MouseMode { NO_EDIT_MODE, ADD_VOXEL_MODE, DELETE_VOXEL_MODE, COLOR_VOXEL_MODE };
|
||||
MouseMode _mouseMode;
|
||||
VoxelDetail _mouseVoxel; // details of the voxel under the mouse cursor
|
||||
float _mouseVoxelScale; // the scale for adding/removing voxels
|
||||
|
||||
bool _paintOn; // Whether to paint voxels as you fly around
|
||||
unsigned char _dominantColor; // The dominant color of the voxel we're painting
|
||||
VoxelDetail _paintingVoxel; // The voxel we're painting if we're painting
|
||||
|
||||
bool _perfStatsOn; // Do we want to display perfStats?
|
||||
|
||||
ChatEntry _chatEntry; // chat entry field
|
||||
bool _chatEntryOn; // Whether to show the chat entry
|
||||
|
||||
GLuint _oculusTextureID; // The texture to which we render for Oculus distortion
|
||||
ProgramObject* _oculusProgram; // The GLSL program containing the distortion shader
|
||||
float _oculusDistortionScale; // Controls the Oculus field of view
|
||||
int _textureLocation;
|
||||
int _lensCenterLocation;
|
||||
int _screenCenterLocation;
|
||||
int _scaleLocation;
|
||||
int _scaleInLocation;
|
||||
int _hmdWarpParamLocation;
|
||||
|
||||
#ifndef _WIN32
|
||||
Audio _audio;
|
||||
#endif
|
||||
|
||||
bool _enableNetworkThread;
|
||||
pthread_t _networkReceiveThread;
|
||||
bool _stopNetworkReceiveThread;
|
||||
|
||||
unsigned char _incomingPacket[MAX_PACKET_SIZE];
|
||||
int _packetCount;
|
||||
int _packetsPerSecond;
|
||||
int _bytesPerSecond;
|
||||
int _bytesCount;
|
||||
};
|
||||
|
||||
#endif /* defined(__interface__Application__) */
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -5,60 +5,71 @@
|
|||
// Created by Andrzej Kapolka on 4/24/13.
|
||||
// Copyright (c) 2013 High Fidelity, Inc. All rights reserved.
|
||||
|
||||
#include "InterfaceConfig.h"
|
||||
#include <QKeyEvent>
|
||||
|
||||
#include "ChatEntry.h"
|
||||
#include "InterfaceConfig.h"
|
||||
#include "Util.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
const int MAX_CONTENT_LENGTH = 140;
|
||||
|
||||
ChatEntry::ChatEntry() : _cursorPos(0) {
|
||||
}
|
||||
|
||||
void ChatEntry::clear() {
|
||||
_contents.clear();
|
||||
_cursorPos = 0;
|
||||
}
|
||||
|
||||
bool ChatEntry::key(unsigned char k) {
|
||||
switch (k) {
|
||||
case '\r':
|
||||
bool ChatEntry::keyPressEvent(QKeyEvent* event) {
|
||||
event->accept();
|
||||
switch (event->key()) {
|
||||
case Qt::Key_Return:
|
||||
case Qt::Key_Enter:
|
||||
return false;
|
||||
|
||||
case '\b':
|
||||
case Qt::Key_Escape:
|
||||
clear();
|
||||
return false;
|
||||
|
||||
case Qt::Key_Backspace:
|
||||
if (_cursorPos != 0) {
|
||||
_contents.erase(_cursorPos - 1, 1);
|
||||
_cursorPos--;
|
||||
}
|
||||
return true;
|
||||
|
||||
case 127: // delete
|
||||
case Qt::Key_Delete:
|
||||
if (_cursorPos < _contents.size()) {
|
||||
_contents.erase(_cursorPos, 1);
|
||||
}
|
||||
return true;
|
||||
|
||||
default:
|
||||
if (_contents.size() != MAX_CONTENT_LENGTH) {
|
||||
_contents.insert(_cursorPos, 1, k);
|
||||
_cursorPos++;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
void ChatEntry::specialKey(unsigned char k) {
|
||||
switch (k) {
|
||||
case GLUT_KEY_LEFT:
|
||||
|
||||
case Qt::Key_Left:
|
||||
if (_cursorPos != 0) {
|
||||
_cursorPos--;
|
||||
}
|
||||
break;
|
||||
return true;
|
||||
|
||||
case GLUT_KEY_RIGHT:
|
||||
case Qt::Key_Right:
|
||||
if (_cursorPos != _contents.size()) {
|
||||
_cursorPos++;
|
||||
}
|
||||
break;
|
||||
return true;
|
||||
|
||||
default:
|
||||
QString text = event->text();
|
||||
if (text.isEmpty()) {
|
||||
event->ignore();
|
||||
return true;
|
||||
}
|
||||
if (_contents.size() != MAX_CONTENT_LENGTH) {
|
||||
_contents.insert(_cursorPos, 1, text.at(0).toAscii());
|
||||
_cursorPos++;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -74,5 +85,4 @@ void ChatEntry::render(int screenWidth, int screenHeight) {
|
|||
glVertex2f(20 + width, screenHeight - 165);
|
||||
glVertex2f(20 + width, screenHeight - 150);
|
||||
glEnd();
|
||||
glEnable(GL_LINE_SMOOTH);
|
||||
}
|
||||
|
|
|
@ -11,15 +11,18 @@
|
|||
|
||||
#include <string>
|
||||
|
||||
class QKeyEvent;
|
||||
|
||||
class ChatEntry {
|
||||
public:
|
||||
|
||||
ChatEntry();
|
||||
|
||||
const std::string& getContents() const { return _contents; }
|
||||
|
||||
void clear();
|
||||
|
||||
bool key(unsigned char k);
|
||||
void specialKey(unsigned char k);
|
||||
bool keyPressEvent(QKeyEvent* event);
|
||||
|
||||
void render(int screenWidth, int screenHeight);
|
||||
|
||||
|
|
Loading…
Reference in a new issue