This commit is contained in:
atlante45 2013-08-16 20:24:18 -07:00
commit 6b58e1bfec
28 changed files with 1583 additions and 1446 deletions

View file

@ -2,4 +2,5 @@ MACRO(INCLUDE_GLM TARGET ROOT_DIR)
set(GLM_ROOT_DIR ${ROOT_DIR}/externals) set(GLM_ROOT_DIR ${ROOT_DIR}/externals)
find_package(GLM REQUIRED) find_package(GLM REQUIRED)
include_directories(${GLM_INCLUDE_DIRS}) include_directories(${GLM_INCLUDE_DIRS})
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -isystem ${GLM_INCLUDE_DIRS}")
ENDMACRO(INCLUDE_GLM _target _root_dir) ENDMACRO(INCLUDE_GLM _target _root_dir)

View file

@ -45,6 +45,12 @@ endforeach(SUBDIR)
# project subdirectories # project subdirectories
add_subdirectory(src/starfield) add_subdirectory(src/starfield)
find_package(Qt5Core REQUIRED)
find_package(Qt5Gui REQUIRED)
find_package(Qt5Network REQUIRED)
find_package(Qt5OpenGL REQUIRED)
find_package(Qt5Svg REQUIRED)
if (APPLE) if (APPLE)
# set how the icon shows up in the Info.plist file # set how the icon shows up in the Info.plist file
SET(MACOSX_BUNDLE_ICON_FILE interface.icns) SET(MACOSX_BUNDLE_ICON_FILE interface.icns)
@ -64,15 +70,8 @@ if (APPLE)
SET(INTERFACE_SRCS ${INTERFACE_SRCS} ${DIR_CONTENTS}) SET(INTERFACE_SRCS ${INTERFACE_SRCS} ${DIR_CONTENTS})
endif() endif()
endforeach() endforeach()
endif (APPLE) endif (APPLE)
find_package(Qt5Core REQUIRED)
find_package(Qt5Gui REQUIRED)
find_package(Qt5Network REQUIRED)
find_package(Qt5OpenGL REQUIRED)
find_package(Qt5Svg REQUIRED)
set(QUAZIP_ROOT_DIR ${CMAKE_CURRENT_SOURCE_DIR}/external/quazip) set(QUAZIP_ROOT_DIR ${CMAKE_CURRENT_SOURCE_DIR}/external/quazip)
add_subdirectory(external/fervor/) add_subdirectory(external/fervor/)
include_directories(external/fervor/) include_directories(external/fervor/)
@ -101,12 +100,12 @@ find_package(UVCCameraControl)
find_package(ZLIB) find_package(ZLIB)
# let the source know that we have OpenNI/NITE for Kinect # let the source know that we have OpenNI/NITE for Kinect
if (OPENNI_FOUND) if (OPENNI_FOUND AND NOT DISABLE_OPENNI)
add_definitions(-DHAVE_OPENNI) add_definitions(-DHAVE_OPENNI)
include_directories(SYSTEM ${OPENNI_INCLUDE_DIRS}) include_directories(SYSTEM ${OPENNI_INCLUDE_DIRS})
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -isystem ${OPENNI_INCLUDE_DIRS}") SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -isystem ${OPENNI_INCLUDE_DIRS}")
target_link_libraries(${TARGET_NAME} ${OPENNI_LIBRARIES}) target_link_libraries(${TARGET_NAME} ${OPENNI_LIBRARIES})
endif (OPENNI_FOUND) endif (OPENNI_FOUND AND NOT DISABLE_OPENNI)
qt5_use_modules(${TARGET_NAME} Core Gui Network OpenGL Svg) qt5_use_modules(${TARGET_NAME} Core Gui Network OpenGL Svg)

View file

@ -9,7 +9,7 @@
#include "quazip.h" #include "quazip.h"
#include "quazipfile.h" #include "quazipfile.h"
#ifdef Q_WS_MAC #ifdef Q_OS_MAC
#include "CoreFoundation/CoreFoundation.h" #include "CoreFoundation/CoreFoundation.h"
#endif #endif
@ -228,7 +228,7 @@ void FvUpdater::httpUpdateDownloadFinished()
{ {
if (reply->isReadable()) if (reply->isReadable())
{ {
#ifdef Q_WS_MAC #ifdef Q_OS_MAC
CFURLRef appURLRef = CFBundleCopyBundleURL(CFBundleGetMainBundle()); CFURLRef appURLRef = CFBundleCopyBundleURL(CFBundleGetMainBundle());
char path[PATH_MAX]; char path[PATH_MAX];
if (!CFURLGetFileSystemRepresentation(appURLRef, TRUE, (UInt8 *)path, PATH_MAX)) { if (!CFURLGetFileSystemRepresentation(appURLRef, TRUE, (UInt8 *)path, PATH_MAX)) {

File diff suppressed because it is too large Load diff

View file

@ -30,8 +30,8 @@
#include "BandwidthMeter.h" #include "BandwidthMeter.h"
#include "Camera.h" #include "Camera.h"
#include "Environment.h" #include "Environment.h"
#include "GLCanvas.h"
#include "PacketHeaders.h" #include "PacketHeaders.h"
#include "ParticleSystem.h"
#include "SerialInterface.h" #include "SerialInterface.h"
#include "Stars.h" #include "Stars.h"
#include "Swatch.h" #include "Swatch.h"
@ -112,101 +112,56 @@ public:
Camera* getCamera() { return &_myCamera; } Camera* getCamera() { return &_myCamera; }
ViewFrustum* getViewFrustum() { return &_viewFrustum; } ViewFrustum* getViewFrustum() { return &_viewFrustum; }
VoxelSystem* getVoxels() { return &_voxels; } VoxelSystem* getVoxels() { return &_voxels; }
QSettings* getSettings() { return _settings; }
Environment* getEnvironment() { return &_environment; } Environment* getEnvironment() { return &_environment; }
SerialInterface* getSerialHeadSensor() { return &_serialHeadSensor; } SerialInterface* getSerialHeadSensor() { return &_serialHeadSensor; }
Webcam* getWebcam() { return &_webcam; } Webcam* getWebcam() { return &_webcam; }
BandwidthMeter* getBandwidthMeter() { return &_bandwidthMeter; } BandwidthMeter* getBandwidthMeter() { return &_bandwidthMeter; }
bool shouldEchoAudio() { return _echoAudioMode->isChecked(); } QSettings* getSettings() { return _settings; }
bool shouldLowPassFilter() { return _shouldLowPassFilter->isChecked(); } Swatch* getSwatch() { return &_swatch; }
QMainWindow* getWindow() { return _window; }
bool shouldDynamicallySetJitterBuffer() { return _audioJitterBufferSamples == 0; } VoxelSceneStats* getVoxelSceneStats() { return &_voxelSceneStats; }
QNetworkAccessManager* getNetworkAccessManager() { return _networkAccessManager; } QNetworkAccessManager* getNetworkAccessManager() { return _networkAccessManager; }
GeometryCache* getGeometryCache() { return &_geometryCache; } GeometryCache* getGeometryCache() { return &_geometryCache; }
TextureCache* getTextureCache() { return &_textureCache; } TextureCache* getTextureCache() { return &_textureCache; }
GlowEffect* getGlowEffect() { return &_glowEffect; } GlowEffect* getGlowEffect() { return &_glowEffect; }
void resetSongMixMenuItem(); static void controlledBroadcastToNodes(unsigned char* broadcastData, size_t dataBytes,
const char* nodeTypes, int numNodeTypes);
void setupWorldLight(Camera& whichCamera); void setupWorldLight(Camera& whichCamera);
virtual void nodeAdded(Node* node); virtual void nodeAdded(Node* node);
virtual void nodeKilled(Node* node); virtual void nodeKilled(Node* node);
public slots: public slots:
void sendAvatarFaceVideoMessage(int frameCount, const QByteArray& data); void sendAvatarFaceVideoMessage(int frameCount, const QByteArray& data);
private slots:
void timer();
void idle();
void terminate();
void bandwidthDetails();
void editPreferences();
void bandwidthDetailsClosed();
void voxelStatsDetails();
void voxelStatsDetailsClosed();
void pair();
void setRenderMirrored(bool mirrored);
void setNoise(bool noise);
void setFullscreen(bool fullscreen);
void setRenderFirstPerson(bool firstPerson);
void setRenderThirdPerson(bool thirdPerson);
void increaseAvatarSize();
void decreaseAvatarSize();
void resetAvatarSize();
void renderThrustAtVoxel(const glm::vec3& thrust);
void renderLineToTouchedVoxel();
void setFrustumOffset(bool frustumOffset);
void cycleFrustumRenderMode();
void setRenderWarnings(bool renderWarnings);
void setRenderVoxels(bool renderVoxels);
void doKillLocalVoxels();
void doRandomizeVoxelColors();
void doFalseRandomizeVoxelColors();
void doFalseRandomizeEveryOtherVoxelColors();
void doFalseColorizeByDistance();
void doFalseColorizeOccluded();
void doFalseColorizeOccludedV2();
void doFalseColorizeBySource();
void doFalseColorizeInView();
void doTrueVoxelColors();
void doTreeStats();
void setWantsMonochrome(bool wantsMonochrome);
void disableLowResMoving(bool disableLowResMoving);
void disableDeltaSending(bool disableDeltaSending);
void disableOcclusionCulling(bool disableOcclusionCulling);
void updateVoxelModeActions();
void decreaseVoxelSize();
void increaseVoxelSize();
void resetSwatchColors();
void chooseVoxelPaintColor();
void loadSettings(QSettings* set = NULL);
void saveSettings(QSettings* set = NULL);
void importSettings();
void exportSettings();
void exportVoxels(); void exportVoxels();
void importVoxels(); void importVoxels();
void importVoxelsToClipboard(); void importVoxelsToClipboard();
void cutVoxels(); void cutVoxels();
void copyVoxels(); void copyVoxels();
void pasteVoxels(); void pasteVoxels();
void runTests();
void setRenderVoxels(bool renderVoxels);
void doKillLocalVoxels();
void decreaseVoxelSize();
void increaseVoxelSize();
void setListenModeNormal(); void setListenModeNormal();
void setListenModePoint(); void setListenModePoint();
void setListenModeSingleSource(); void setListenModeSingleSource();
void toggleMixedSong();
void toggleWantCollisionsOn(); private slots:
void timer();
void idle();
void terminate();
void setFullscreen(bool fullscreen);
void renderThrustAtVoxel(const glm::vec3& thrust);
void renderLineToTouchedVoxel();
void renderCoverageMap(); void renderCoverageMap();
void renderCoverageMapsRecursively(CoverageMap* map); void renderCoverageMapsRecursively(CoverageMap* map);
@ -214,24 +169,17 @@ private slots:
void renderCoverageMapsV2Recursively(CoverageMapV2* map); void renderCoverageMapsV2Recursively(CoverageMapV2* map);
glm::vec2 getScaledScreenPoint(glm::vec2 projectedPoint); glm::vec2 getScaledScreenPoint(glm::vec2 projectedPoint);
void goHome();
void toggleFollowMode(); void toggleFollowMode();
private: private:
void resetCamerasOnResizeGL(Camera& camera, int width, int height); void resetCamerasOnResizeGL(Camera& camera, int width, int height);
static void controlledBroadcastToNodes(unsigned char* broadcastData, size_t dataBytes,
const char* nodeTypes, int numNodeTypes);
static bool sendVoxelsOperation(VoxelNode* node, void* extraData); static bool sendVoxelsOperation(VoxelNode* node, void* extraData);
static void sendAvatarVoxelURLMessage(const QUrl& url);
static void processAvatarVoxelURLMessage(unsigned char* packetData, size_t dataBytes); static void processAvatarVoxelURLMessage(unsigned char* packetData, size_t dataBytes);
static void processAvatarFaceVideoMessage(unsigned char* packetData, size_t dataBytes); static void processAvatarFaceVideoMessage(unsigned char* packetData, size_t dataBytes);
static void sendPingPackets(); static void sendPingPackets();
void initMenu();
void updateFrustumRenderModeAction();
void initDisplay(); void initDisplay();
void init(); void init();
@ -263,75 +211,15 @@ private:
void updateCursor(); void updateCursor();
QAction* checkedVoxelModeAction() const;
static void attachNewHeadToNode(Node *newNode); static void attachNewHeadToNode(Node *newNode);
static void* networkReceive(void* args); // network receive thread static void* networkReceive(void* args); // network receive thread
// methodes handling menu settings
typedef void(*settingsAction)(QSettings*, QAction*);
static void loadAction(QSettings* set, QAction* action);
static void saveAction(QSettings* set, QAction* action);
void scanMenuBar(settingsAction modifySetting, QSettings* set);
void scanMenu(QMenu* menu, settingsAction modifySetting, QSettings* set);
QMainWindow* _window; QMainWindow* _window;
QGLWidget* _glWidget; QGLWidget* _glWidget;
QAction* _lookingInMirror; // Are we currently rendering one's own head as if in mirror?
QAction* _echoAudioMode; // Are we asking the mixer to echo back our audio?
QAction* _shouldLowPassFilter; // Use test lowpass filter
QAction* _gyroLook; // Whether to allow the gyro data from head to move your view
QAction* _renderAvatarBalls; // Switch between voxels and joints/balls for avatar render
QAction* _showHeadMouse; // Whether the have the mouse near edge of screen move your view
QAction* _transmitterDrives; // Whether to have Transmitter data move/steer the Avatar
QAction* _gravityUse; // Whether gravity is on or not
QAction* _testPing; // Whether to display ping or not
QAction* _renderVoxels; // Whether to render voxels
QAction* _renderVoxelTextures; // Whether to render noise textures on voxels
QAction* _renderStarsOn; // Whether to display the stars
QAction* _renderAtmosphereOn; // Whether to display the atmosphere
QAction* _renderGroundPlaneOn; // Whether to display the ground plane
QAction* _renderAvatarsOn; // Whether to render avatars
QAction* _renderStatsOn; // Whether to show onscreen text overlay with stats
QAction* _renderFrameTimerOn; // Whether to show onscreen text overlay with stats
QAction* _renderLookatOn; // Whether to show lookat vectors from avatar eyes if looking at something
QAction* _renderLookatIndicatorOn;
QAction* _renderParticleSystemOn;
QAction* _manualFirstPerson; // Whether to force first-person mode
QAction* _manualThirdPerson; // Whether to force third-person mode
QAction* _logOn; // Whether to show on-screen log
QAction* _oscilloscopeOn; // Whether to show the oscilloscope
QAction* _bandwidthDisplayOn; // Whether to show on-screen bandwidth bars
QActionGroup* _voxelModeActions; // The group of voxel edit mode actions
QAction* _addVoxelMode; // Whether add voxel mode is enabled
QAction* _deleteVoxelMode; // Whether delete voxel mode is enabled
QAction* _colorVoxelMode; // Whether color voxel mode is enabled
QAction* _selectVoxelMode; // Whether select voxel mode is enabled
QAction* _eyedropperMode; // Whether voxel color eyedropper mode is enabled
QAction* _voxelPaintColor; // The color with which to paint voxels
QAction* _destructiveAddVoxel; // when doing voxel editing do we want them to be destructive
QAction* _frustumOn; // Whether or not to display the debug view frustum
QAction* _fullScreenMode; // whether we are in full screen mode
QAction* _frustumRenderModeAction;
QAction* _settingsAutosave; // Whether settings are saved automatically
QAction* _rawAudioMicrophoneMix; // Mixing of a RAW audio file with microphone stream for rave gloves
QAction* _noise;
QAction* _occlusionCulling;
QAction* _wantCollisionsOn;
QAction* _renderPipelineWarnings;
QAction* _renderCoverageMapV2;
QAction* _renderCoverageMap;
QAction* _simulateLeapHand; // When there's no Leap, use this to pretend there is one and feed fake hand data
QAction* _testRaveGlove; // Test fancy sparkle-rave-glove mode
QAction* _followMode; QAction* _followMode;
BandwidthMeter _bandwidthMeter; BandwidthMeter _bandwidthMeter;
BandwidthDialog* _bandwidthDialog;
VoxelStatsDialog* _voxelStatsDialog;
SerialInterface _serialHeadSensor; SerialInterface _serialHeadSensor;
QNetworkAccessManager* _networkAccessManager; QNetworkAccessManager* _networkAccessManager;
@ -347,8 +235,6 @@ private:
timeval _timerStart, _timerEnd; timeval _timerStart, _timerEnd;
timeval _lastTimeUpdated; timeval _lastTimeUpdated;
bool _justStarted; bool _justStarted;
bool _particleSystemInitialized;
int _coolDemoParticleEmitter;
Stars _stars; Stars _stars;
@ -360,16 +246,6 @@ private:
bool _wantToKillLocalVoxels; bool _wantToKillLocalVoxels;
ViewFrustum _viewFrustum; // current state of view frustum, perspective, orientation, etc. 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_KEYHOLE, 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;
Oscilloscope _audioScope; Oscilloscope _audioScope;
@ -385,11 +261,6 @@ private:
Environment _environment; Environment _environment;
int _headMouseX, _headMouseY; int _headMouseX, _headMouseY;
float _gyroCameraSensitivity;
int _audioJitterBufferSamples; // Number of extra samples to wait before starting audio playback
float _fieldOfView; // In Degrees, doesn't apply to HMD like Oculus
HandControl _handControl; HandControl _handControl;
@ -444,7 +315,6 @@ private:
GeometryCache _geometryCache; GeometryCache _geometryCache;
TextureCache _textureCache; TextureCache _textureCache;
ParticleSystem _particleSystem;
GlowEffect _glowEffect; GlowEffect _glowEffect;
#ifndef _WIN32 #ifndef _WIN32

View file

@ -23,6 +23,7 @@
#include "Application.h" #include "Application.h"
#include "Audio.h" #include "Audio.h"
#include "Menu.h"
#include "Util.h" #include "Util.h"
// Uncomment the following definition to test audio device latency by copying output to input // Uncomment the following definition to test audio device latency by copying output to input
@ -112,7 +113,7 @@ inline void Audio::performIO(int16_t* inputLeft, int16_t* outputLeft, int16_t* o
// + 12 for 3 floats for position + float for bearing + 1 attenuation byte // + 12 for 3 floats for position + float for bearing + 1 attenuation byte
unsigned char dataPacket[MAX_PACKET_SIZE]; unsigned char dataPacket[MAX_PACKET_SIZE];
PACKET_TYPE packetType = (Application::getInstance()->shouldEchoAudio()) PACKET_TYPE packetType = Menu::getInstance()->isOptionChecked(MenuOption::EchoAudio)
? PACKET_TYPE_MICROPHONE_AUDIO_WITH_ECHO ? PACKET_TYPE_MICROPHONE_AUDIO_WITH_ECHO
: PACKET_TYPE_MICROPHONE_AUDIO_NO_ECHO; : PACKET_TYPE_MICROPHONE_AUDIO_NO_ECHO;
@ -153,38 +154,6 @@ inline void Audio::performIO(int16_t* inputLeft, int16_t* outputLeft, int16_t* o
memcpy(currentPacketPtr, &headOrientation, sizeof(headOrientation)); memcpy(currentPacketPtr, &headOrientation, sizeof(headOrientation));
currentPacketPtr += sizeof(headOrientation); currentPacketPtr += sizeof(headOrientation);
// check if we have a song to add to our audio
if (_songFileBytes > 0 && _songFileStream->tellg() != -1) {
// iterate over BUFFER_LENGTH_SAMPLES_PER_CHANNEL from the song file and add that to our audio
for (int i = 0; i < BUFFER_LENGTH_SAMPLES_PER_CHANNEL; i++) {
int16_t songSample = 0;
_songFileStream->read((char*) &songSample, sizeof(songSample));
// attenuate the song samples since they will be loud
const float SONG_SAMPLE_ATTENUATION = 0.25;
songSample *= SONG_SAMPLE_ATTENUATION;
// add the song sample to the output and input buffersg
inputLeft[i] = inputLeft[i] + songSample;
outputLeft[i] = outputLeft[i] + songSample;
outputRight[i] = outputLeft[i] + songSample;
}
} else if (_songFileStream) {
// close the stream
_songFileStream->close();
// delete the _songFileStream
delete _songFileStream;
_songFileStream = NULL;
// reset the _songFileBytes back to zero
_songFileBytes = 0;
// call Application stopMixingSong method to fix menu item
Application::getInstance()->resetSongMixMenuItem();
}
// copy the audio data to the last BUFFER_LENGTH_BYTES bytes of the data packet // copy the audio data to the last BUFFER_LENGTH_BYTES bytes of the data packet
memcpy(currentPacketPtr, inputLeft, BUFFER_LENGTH_BYTES_PER_CHANNEL); memcpy(currentPacketPtr, inputLeft, BUFFER_LENGTH_BYTES_PER_CHANNEL);
@ -415,8 +384,6 @@ Audio::Audio(Oscilloscope* scope, int16_t initialJitterBufferSamples) :
_collisionSoundDuration(0.0f), _collisionSoundDuration(0.0f),
_proceduralEffectSample(0), _proceduralEffectSample(0),
_heartbeatMagnitude(0.0f), _heartbeatMagnitude(0.0f),
_songFileStream(NULL),
_songFileBytes(0),
_listenMode(AudioRingBuffer::NORMAL), _listenMode(AudioRingBuffer::NORMAL),
_listenRadius(0.0f) _listenRadius(0.0f)
{ {
@ -489,24 +456,6 @@ Audio::~Audio() {
delete[] _echoSamplesLeft; delete[] _echoSamplesLeft;
} }
void Audio::importSongToMixWithMicrophone(const char* filename) {
_songFileStream = new std::ifstream(filename);
long begin = _songFileStream->tellg();
_songFileStream->seekg(0, std::ios::end);
long end = _songFileStream->tellg();
// go back to the beginning
_songFileStream->seekg(0);
_songFileBytes = end - begin;
}
void Audio::stopMixingSongWithMicrophone() {
_songFileBytes = 0;
}
void Audio::addReceivedAudioToBuffer(unsigned char* receivedData, int receivedBytes) { void Audio::addReceivedAudioToBuffer(unsigned char* receivedData, int receivedBytes) {
const int NUM_INITIAL_PACKETS_DISCARD = 3; const int NUM_INITIAL_PACKETS_DISCARD = 3;
const int STANDARD_DEVIATION_SAMPLE_COUNT = 500; const int STANDARD_DEVIATION_SAMPLE_COUNT = 500;
@ -528,7 +477,7 @@ void Audio::addReceivedAudioToBuffer(unsigned char* receivedData, int receivedBy
// Set jitter buffer to be a multiple of the measured standard deviation // Set jitter buffer to be a multiple of the measured standard deviation
const int MAX_JITTER_BUFFER_SAMPLES = RING_BUFFER_LENGTH_SAMPLES / 2; const int MAX_JITTER_BUFFER_SAMPLES = RING_BUFFER_LENGTH_SAMPLES / 2;
const float NUM_STANDARD_DEVIATIONS = 3.f; const float NUM_STANDARD_DEVIATIONS = 3.f;
if (Application::getInstance()->shouldDynamicallySetJitterBuffer()) { if (Menu::getInstance()->getAudioJitterBufferSamples() == 0) {
float newJitterBufferSamples = (NUM_STANDARD_DEVIATIONS * _measuredJitter) float newJitterBufferSamples = (NUM_STANDARD_DEVIATIONS * _measuredJitter)
/ 1000.f / 1000.f
* SAMPLE_RATE; * SAMPLE_RATE;
@ -646,7 +595,7 @@ void Audio::render(int screenWidth, int screenHeight) {
sprintf(out, "%.0f\n", getJitterBufferSamples() / SAMPLE_RATE * 1000.f); sprintf(out, "%.0f\n", getJitterBufferSamples() / SAMPLE_RATE * 1000.f);
drawtext(startX + jitterBufferPels - 5, topY - 9, 0.10, 0, 1, 0, out, 1, 0, 0); drawtext(startX + jitterBufferPels - 5, topY - 9, 0.10, 0, 1, 0, out, 1, 0, 0);
sprintf(out, "j %.1f\n", _measuredJitter); sprintf(out, "j %.1f\n", _measuredJitter);
if (Application::getInstance()->shouldDynamicallySetJitterBuffer()) { if (Menu::getInstance()->getAudioJitterBufferSamples() == 0) {
drawtext(startX + jitterBufferPels - 5, bottomY + 12, 0.10, 0, 1, 0, out, 1, 0, 0); drawtext(startX + jitterBufferPels - 5, bottomY + 12, 0.10, 0, 1, 0, out, 1, 0, 0);
} else { } else {
drawtext(startX, bottomY + 12, 0.10, 0, 1, 0, out, 1, 0, 0); drawtext(startX, bottomY + 12, 0.10, 0, 1, 0, out, 1, 0, 0);

View file

@ -54,8 +54,6 @@ public:
float getCollisionSoundMagnitude() { return _collisionSoundMagnitude; }; float getCollisionSoundMagnitude() { return _collisionSoundMagnitude; };
int getSongFileBytes() { return _songFileBytes; }
void ping(); void ping();
// Call periodically to eventually perform round trip time analysis, // Call periodically to eventually perform round trip time analysis,
@ -68,11 +66,6 @@ public:
void addListenSource(int sourceID); void addListenSource(int sourceID);
void removeListenSource(int sourceID); void removeListenSource(int sourceID);
void clearListenSources(); void clearListenSources();
void importSongToMixWithMicrophone(const char* filename);
public slots:
void stopMixingSongWithMicrophone();
private: private:
PaStream* _stream; PaStream* _stream;
@ -109,9 +102,7 @@ private:
float _collisionSoundDuration; float _collisionSoundDuration;
int _proceduralEffectSample; int _proceduralEffectSample;
float _heartbeatMagnitude; float _heartbeatMagnitude;
std::ifstream* _songFileStream;
int _songFileBytes;
AudioRingBuffer::ListenMode _listenMode; AudioRingBuffer::ListenMode _listenMode;
float _listenRadius; float _listenRadius;
std::vector<int> _listenSources; std::vector<int> _listenSources;

View file

@ -0,0 +1,70 @@
//
// GLCanvas.cpp
// hifi
//
// Created by Stephen Birarda on 8/14/13.
// Copyright (c) 2013 HighFidelity, Inc. All rights reserved.
//
#include "Application.h"
#include "GLCanvas.h"
GLCanvas::GLCanvas() : QGLWidget(QGLFormat(QGL::NoDepthBuffer, QGL::NoStencilBuffer)) {
}
void GLCanvas::initializeGL() {
Application::getInstance()->initializeGL();
setAttribute(Qt::WA_AcceptTouchEvents);
}
void GLCanvas::paintGL() {
Application::getInstance()->paintGL();
}
void GLCanvas::resizeGL(int width, int height) {
Application::getInstance()->resizeGL(width, height);
}
void GLCanvas::keyPressEvent(QKeyEvent* event) {
Application::getInstance()->keyPressEvent(event);
}
void GLCanvas::keyReleaseEvent(QKeyEvent* event) {
Application::getInstance()->keyReleaseEvent(event);
}
void GLCanvas::mouseMoveEvent(QMouseEvent* event) {
Application::getInstance()->mouseMoveEvent(event);
}
void GLCanvas::mousePressEvent(QMouseEvent* event) {
Application::getInstance()->mousePressEvent(event);
}
void GLCanvas::mouseReleaseEvent(QMouseEvent* event) {
Application::getInstance()->mouseReleaseEvent(event);
}
int updateTime = 0;
bool GLCanvas::event(QEvent* event) {
switch (event->type()) {
case QEvent::TouchBegin:
Application::getInstance()->touchBeginEvent(static_cast<QTouchEvent*>(event));
event->accept();
return true;
case QEvent::TouchEnd:
Application::getInstance()->touchEndEvent(static_cast<QTouchEvent*>(event));
return true;
case QEvent::TouchUpdate:
Application::getInstance()->touchUpdateEvent(static_cast<QTouchEvent*>(event));
return true;
default:
break;
}
return QGLWidget::event(event);
}
void GLCanvas::wheelEvent(QWheelEvent* event) {
Application::getInstance()->wheelEvent(event);
}

36
interface/src/GLCanvas.h Normal file
View file

@ -0,0 +1,36 @@
//
// GLCanvas.h
// hifi
//
// Created by Stephen Birarda on 8/14/13.
// Copyright (c) 2013 HighFidelity, Inc. All rights reserved.
//
#ifndef __hifi__GLCanvas__
#define __hifi__GLCanvas__
#include <QGLWidget>
/// customized canvas that simply forwards requests/events to the singleton application
class GLCanvas : public QGLWidget {
public:
GLCanvas();
protected:
virtual void initializeGL();
virtual void paintGL();
virtual void resizeGL(int width, int height);
virtual void keyPressEvent(QKeyEvent* event);
virtual void keyReleaseEvent(QKeyEvent* event);
virtual void mouseMoveEvent(QMouseEvent* event);
virtual void mousePressEvent(QMouseEvent* event);
virtual void mouseReleaseEvent(QMouseEvent* event);
virtual bool event(QEvent* event);
virtual void wheelEvent(QWheelEvent* event);
};
#endif /* defined(__hifi__GLCanvas__) */

779
interface/src/Menu.cpp Normal file
View file

@ -0,0 +1,779 @@
//
// Menu.cpp
// hifi
//
// Created by Stephen Birarda on 8/12/13.
// Copyright (c) 2013 HighFidelity, Inc. All rights reserved.
//
#include <cstdlib>
#include <QMenuBar>
#include <QBoxLayout>
#include <QColorDialog>
#include <QDialogButtonBox>
#include <QDoubleSpinBox>
#include <QFileDialog>
#include <QFormLayout>
#include <QLineEdit>
#include <QMainWindow>
#include <QStandardPaths>
#include "Application.h"
#include "PairingHandler.h"
#include "Menu.h"
#include "Util.h"
Menu* Menu::_instance = NULL;
Menu* Menu::getInstance() {
if (!_instance) {
qDebug("First call to Menu::getInstance() - initing menu.\n");
_instance = new Menu();
}
return _instance;
}
const ViewFrustumOffset DEFAULT_FRUSTUM_OFFSET = {-135.0f, 0.0f, 0.0f, 25.0f, 0.0f};
Menu::Menu() :
_actionHash(),
_audioJitterBufferSamples(0),
_bandwidthDialog(NULL),
_fieldOfView(DEFAULT_FIELD_OF_VIEW_DEGREES),
_frustumDrawMode(FRUSTUM_DRAW_MODE_ALL),
_viewFrustumOffset(DEFAULT_FRUSTUM_OFFSET),
_voxelModeActionsGroup(NULL),
_voxelStatsDialog(NULL)
{
Application *appInstance = Application::getInstance();
QMenu* fileMenu = addMenu("File");
(addActionToQMenuAndActionHash(fileMenu,
MenuOption::Quit,
Qt::CTRL | Qt::Key_Q,
appInstance,
SLOT(quit())))->setMenuRole(QAction::QuitRole);
(addActionToQMenuAndActionHash(fileMenu,
MenuOption::Preferences,
Qt::CTRL | Qt::Key_Comma,
this,
SLOT(editPreferences())))->setMenuRole(QAction::PreferencesRole);
QMenu* pairMenu = addMenu("Pair");
addActionToQMenuAndActionHash(pairMenu, MenuOption::Pair, 0, PairingHandler::getInstance(), SLOT(sendPairRequest()));
QMenu* optionsMenu = addMenu("Options");
addCheckableActionToQMenuAndActionHash(optionsMenu, MenuOption::Mirror, Qt::Key_H);
addCheckableActionToQMenuAndActionHash(optionsMenu, MenuOption::GyroLook, 0, true);
addCheckableActionToQMenuAndActionHash(optionsMenu, MenuOption::HeadMouse);
addCheckableActionToQMenuAndActionHash(optionsMenu, MenuOption::TransmitterDrive, 0, true);
addCheckableActionToQMenuAndActionHash(optionsMenu, MenuOption::Gravity, Qt::SHIFT | Qt::Key_G, true);
addCheckableActionToQMenuAndActionHash(optionsMenu, MenuOption::TestPing, 0, true);
addCheckableActionToQMenuAndActionHash(optionsMenu,
MenuOption::Fullscreen,
Qt::Key_F,
false,
appInstance,
SLOT(setFullscreen(bool)));
addCheckableActionToQMenuAndActionHash(optionsMenu,
MenuOption::Webcam,
0,
false,
appInstance->getWebcam(),
SLOT(setEnabled(bool)));
addCheckableActionToQMenuAndActionHash(optionsMenu,
MenuOption::SkeletonTracking,
0,
false,
appInstance->getWebcam(),
SLOT(setSkeletonTrackingOn(bool)));
addCheckableActionToQMenuAndActionHash(optionsMenu,
MenuOption::Collisions,
0,
true,
appInstance->getAvatar(),
SLOT(setWantCollisionsOn(bool)));
addActionToQMenuAndActionHash(optionsMenu,
MenuOption::WebcamMode,
0,
appInstance->getWebcam()->getGrabber(),
SLOT(cycleVideoSendMode()));
addCheckableActionToQMenuAndActionHash(optionsMenu,
MenuOption::WebcamTexture,
0,
false,
appInstance->getWebcam()->getGrabber(),
SLOT(setDepthOnly(bool)));
addActionToQMenuAndActionHash(optionsMenu,
MenuOption::GoHome,
Qt::CTRL | Qt::Key_G,
appInstance->getAvatar(),
SLOT(goHome()));
QMenu* audioMenu = addMenu("Audio");
addCheckableActionToQMenuAndActionHash(audioMenu, MenuOption::EchoAudio);
QMenu* renderMenu = addMenu("Render");
addCheckableActionToQMenuAndActionHash(renderMenu,
MenuOption::Voxels,
Qt::SHIFT | Qt::Key_V,
true,
appInstance,
SLOT(setRenderVoxels(bool)));
addCheckableActionToQMenuAndActionHash(renderMenu, MenuOption::VoxelTextures);
addCheckableActionToQMenuAndActionHash(renderMenu, MenuOption::Stars, 0, true);
addCheckableActionToQMenuAndActionHash(renderMenu, MenuOption::Atmosphere, Qt::SHIFT | Qt::Key_A, true);
addCheckableActionToQMenuAndActionHash(renderMenu, MenuOption::GroundPlane, 0, true);
addCheckableActionToQMenuAndActionHash(renderMenu, MenuOption::Avatars, 0, true);
addCheckableActionToQMenuAndActionHash(renderMenu, MenuOption::AvatarAsBalls);
addActionToQMenuAndActionHash(renderMenu,
MenuOption::VoxelMode,
0,
appInstance->getAvatar()->getVoxels(),
SLOT(cycleMode()));
addActionToQMenuAndActionHash(renderMenu,
MenuOption::FaceMode,
0,
&appInstance->getAvatar()->getHead().getFace(),
SLOT(cycleRenderMode()));
addCheckableActionToQMenuAndActionHash(renderMenu, MenuOption::FrameTimer);
addCheckableActionToQMenuAndActionHash(renderMenu, MenuOption::LookAtVectors);
addCheckableActionToQMenuAndActionHash(renderMenu, MenuOption::LookAtIndicator, 0, true);
addCheckableActionToQMenuAndActionHash(renderMenu, MenuOption::FirstPerson, Qt::Key_P, true);
addActionToQMenuAndActionHash(renderMenu,
MenuOption::IncreaseAvatarSize,
Qt::Key_Plus,
appInstance->getAvatar(),
SLOT(increaseSize()));
addActionToQMenuAndActionHash(renderMenu,
MenuOption::DecreaseAvatarSize,
Qt::Key_Minus,
appInstance->getAvatar(),
SLOT(decreaseSize()));
addActionToQMenuAndActionHash(renderMenu,
MenuOption::ResetAvatarSize,
0,
appInstance->getAvatar(),
SLOT(resetSize()));
QMenu* toolsMenu = addMenu("Tools");
addCheckableActionToQMenuAndActionHash(toolsMenu, MenuOption::Stats, Qt::Key_Slash);
addCheckableActionToQMenuAndActionHash(toolsMenu, MenuOption::Log, Qt::CTRL | Qt::Key_L);
addCheckableActionToQMenuAndActionHash(toolsMenu, MenuOption::Oscilloscope, 0, true);
addCheckableActionToQMenuAndActionHash(toolsMenu, MenuOption::Bandwidth, 0, true);
addActionToQMenuAndActionHash(toolsMenu, MenuOption::BandwidthDetails, 0, this, SLOT(bandwidthDetails()));
addActionToQMenuAndActionHash(toolsMenu, MenuOption::VoxelStats, 0, this, SLOT(voxelStatsDetails()));
QMenu* voxelMenu = addMenu("Voxels");
_voxelModeActionsGroup = new QActionGroup(this);
_voxelModeActionsGroup->setExclusive(false);
QAction* addVoxelMode = addCheckableActionToQMenuAndActionHash(voxelMenu, MenuOption::VoxelAddMode, Qt::Key_V);
_voxelModeActionsGroup->addAction(addVoxelMode);
QAction* deleteVoxelMode = addCheckableActionToQMenuAndActionHash(voxelMenu, MenuOption::VoxelDeleteMode, Qt::Key_R);
_voxelModeActionsGroup->addAction(deleteVoxelMode);
QAction* colorVoxelMode = addCheckableActionToQMenuAndActionHash(voxelMenu, MenuOption::VoxelColorMode, Qt::Key_B);
_voxelModeActionsGroup->addAction(colorVoxelMode);
QAction* selectVoxelMode = addCheckableActionToQMenuAndActionHash(voxelMenu, MenuOption::VoxelSelectMode, Qt::Key_O);
_voxelModeActionsGroup->addAction(selectVoxelMode);
QAction* getColorMode = addCheckableActionToQMenuAndActionHash(voxelMenu, MenuOption::VoxelGetColorMode, Qt::Key_G);
_voxelModeActionsGroup->addAction(getColorMode);
// connect each of the voxel mode actions to the updateVoxelModeActionsSlot
foreach (QAction* action, _voxelModeActionsGroup->actions()) {
connect(action, SIGNAL(triggered()), this, SLOT(updateVoxelModeActions()));
}
QAction* voxelPaintColor = addActionToQMenuAndActionHash(voxelMenu,
MenuOption::VoxelPaintColor,
Qt::META | Qt::Key_C,
this,
SLOT(chooseVoxelPaintColor()));
Application::getInstance()->getSwatch()->setAction(voxelPaintColor);
QColor paintColor(128, 128, 128);
voxelPaintColor->setData(paintColor);
voxelPaintColor->setIcon(Swatch::createIcon(paintColor));
addActionToQMenuAndActionHash(voxelMenu,
MenuOption::DecreaseVoxelSize,
QKeySequence::ZoomOut,
appInstance,
SLOT(decreaseVoxelSize()));
addActionToQMenuAndActionHash(voxelMenu,
MenuOption::IncreaseVoxelSize,
QKeySequence::ZoomIn,
appInstance,
SLOT(increaseVoxelSize()));
addActionToQMenuAndActionHash(voxelMenu, MenuOption::ResetSwatchColors, 0, this, SLOT(resetSwatchColors()));
addCheckableActionToQMenuAndActionHash(voxelMenu, MenuOption::DestructiveAddVoxel);
addActionToQMenuAndActionHash(voxelMenu, MenuOption::ExportVoxels, Qt::CTRL | Qt::Key_E, appInstance, SLOT(exportVoxels()));
addActionToQMenuAndActionHash(voxelMenu, MenuOption::ImportVoxels, Qt::CTRL | Qt::Key_I, appInstance, SLOT(importVoxels()));
addActionToQMenuAndActionHash(voxelMenu,
MenuOption::ImportVoxelsClipboard,
Qt::SHIFT | Qt::CTRL | Qt::Key_I,
appInstance,
SLOT(importVoxelsToClipboard()));
addActionToQMenuAndActionHash(voxelMenu, MenuOption::CutVoxels, Qt::CTRL | Qt::Key_X, appInstance, SLOT(cutVoxels()));
addActionToQMenuAndActionHash(voxelMenu, MenuOption::CopyVoxels, Qt::CTRL | Qt::Key_C, appInstance, SLOT(copyVoxels()));
addActionToQMenuAndActionHash(voxelMenu, MenuOption::PasteVoxels, Qt::CTRL | Qt::Key_V, appInstance, SLOT(pasteVoxels()));
QMenu* debugMenu = addMenu("Debug");
QMenu* frustumMenu = debugMenu->addMenu("View Frustum Debugging Tools");
addCheckableActionToQMenuAndActionHash(frustumMenu, MenuOption::DisplayFrustum, Qt::SHIFT | Qt::Key_F);
addActionToQMenuAndActionHash(frustumMenu,
MenuOption::FrustumRenderMode,
Qt::SHIFT | Qt::Key_R,
this,
SLOT(cycleFrustumRenderMode()));
updateFrustumRenderModeAction();
addActionToQMenuAndActionHash(debugMenu, MenuOption::RunTimingTests, 0, this, SLOT(runTests()));
addActionToQMenuAndActionHash(debugMenu,
MenuOption::TreeStats,
Qt::SHIFT | Qt::Key_S,
appInstance->getVoxels(),
SLOT(collectStatsForTreesAndVBOs()));
QMenu* renderDebugMenu = debugMenu->addMenu("Render Debugging Tools");
addCheckableActionToQMenuAndActionHash(renderDebugMenu, MenuOption::PipelineWarnings);
addActionToQMenuAndActionHash(renderDebugMenu,
MenuOption::KillLocalVoxels,
Qt::CTRL | Qt::Key_K,
appInstance, SLOT(doKillLocalVoxels()));
addActionToQMenuAndActionHash(renderDebugMenu,
MenuOption::RandomizeVoxelColors,
Qt::CTRL | Qt::Key_R,
appInstance->getVoxels(),
SLOT(randomizeVoxelColors()));
addActionToQMenuAndActionHash(renderDebugMenu,
MenuOption::FalseColorRandomly,
0,
appInstance->getVoxels(),
SLOT(falseColorizeRandom()));
addActionToQMenuAndActionHash(renderDebugMenu,
MenuOption::FalseColorEveryOtherVoxel,
0,
appInstance->getVoxels(),
SLOT(falseColorizeRandomEveryOther()));
addActionToQMenuAndActionHash(renderDebugMenu,
MenuOption::FalseColorByDistance,
0,
appInstance->getVoxels(),
SLOT(falseColorizeDistanceFromView()));
addActionToQMenuAndActionHash(renderDebugMenu,
MenuOption::FalseColorOutOfView,
0,
appInstance->getVoxels(),
SLOT(falseColorizeInView()));
addActionToQMenuAndActionHash(renderDebugMenu,
MenuOption::FalseColorOccluded,
0,
appInstance->getVoxels(),
SLOT(falseColorizeOccluded()));
addActionToQMenuAndActionHash(renderDebugMenu,
MenuOption::FalseColorOccludedV2,
0,
appInstance->getVoxels(),
SLOT(falseColorizeOccludedV2()));
addActionToQMenuAndActionHash(renderDebugMenu,
MenuOption::FalseColorBySource,
0,
appInstance->getVoxels(),
SLOT(falseColorizeBySource()));
addActionToQMenuAndActionHash(renderDebugMenu,
MenuOption::ShowTrueColors,
Qt::CTRL | Qt::Key_T,
appInstance->getVoxels(),
SLOT(trueColorize()));
addCheckableActionToQMenuAndActionHash(debugMenu,
MenuOption::SendVoxelColors,
0,
true,
appInstance->getAvatar(),
SLOT(setWantColor(bool)));
addCheckableActionToQMenuAndActionHash(debugMenu,
MenuOption::LowRes,
0,
true,
appInstance->getAvatar(),
SLOT(setWantLowResMoving(bool)));
addCheckableActionToQMenuAndActionHash(debugMenu,
MenuOption::DeltaSending,
0,
true,
appInstance->getAvatar(),
SLOT(setWantDelta(bool)));
addCheckableActionToQMenuAndActionHash(debugMenu,
MenuOption::OcclusionCulling,
Qt::SHIFT | Qt::Key_C,
true,
appInstance->getAvatar(),
SLOT(setWantOcclusionCulling(bool)));
addCheckableActionToQMenuAndActionHash(debugMenu, MenuOption::CoverageMap, Qt::SHIFT | Qt::CTRL | Qt::Key_O);
addCheckableActionToQMenuAndActionHash(debugMenu, MenuOption::CoverageMapV2, Qt::SHIFT | Qt::CTRL | Qt::Key_P);
addCheckableActionToQMenuAndActionHash(debugMenu, MenuOption::SimulateLeapHand);
addCheckableActionToQMenuAndActionHash(debugMenu, MenuOption::TestRaveGlove);
QMenu* audioDebugMenu = debugMenu->addMenu("Audio Debugging Tools");
addActionToQMenuAndActionHash(audioDebugMenu,
MenuOption::ListenModeNormal,
Qt::CTRL | Qt::Key_1,
appInstance,
SLOT(setListenModeNormal()));
addActionToQMenuAndActionHash(audioDebugMenu,
MenuOption::ListenModePoint,
Qt::CTRL | Qt::Key_2,
appInstance,
SLOT(setListenModePoint()));
addActionToQMenuAndActionHash(audioDebugMenu,
MenuOption::ListenModeSingleSource,
Qt::CTRL | Qt::Key_3,
appInstance,
SLOT(setListenModeSingleSource()));
QMenu* settingsMenu = addMenu("Settings");
addCheckableActionToQMenuAndActionHash(settingsMenu, MenuOption::SettingsAutosave, 0, true);
addActionToQMenuAndActionHash(settingsMenu, MenuOption::SettingsLoad, 0, this, SLOT(loadSettings()));
addActionToQMenuAndActionHash(settingsMenu, MenuOption::SettingsSave, 0, this, SLOT(saveSettings()));
addActionToQMenuAndActionHash(settingsMenu, MenuOption::SettingsImport, 0, this, SLOT(importSettings()));
addActionToQMenuAndActionHash(settingsMenu, MenuOption::SettingsExport, 0, this, SLOT(exportSettings()));
}
void Menu::loadSettings(QSettings* settings) {
if (!settings) {
settings = Application::getInstance()->getSettings();
}
_gyroCameraSensitivity = loadSetting(settings, "gyroCameraSensitivity", 0.5f);
_audioJitterBufferSamples = loadSetting(settings, "audioJitterBufferSamples", 0);
_fieldOfView = loadSetting(settings, "fieldOfView", DEFAULT_FIELD_OF_VIEW_DEGREES);
settings->beginGroup("View Frustum Offset Camera");
// in case settings is corrupt or missing loadSetting() will check for NaN
_viewFrustumOffset.yaw = loadSetting(settings, "viewFrustumOffsetYaw", 0.0f);
_viewFrustumOffset.pitch = loadSetting(settings, "viewFrustumOffsetPitch", 0.0f);
_viewFrustumOffset.roll = loadSetting(settings, "viewFrustumOffsetRoll", 0.0f);
_viewFrustumOffset.distance = loadSetting(settings, "viewFrustumOffsetDistance", 0.0f);
_viewFrustumOffset.up = loadSetting(settings, "viewFrustumOffsetUp", 0.0f);
settings->endGroup();
scanMenuBar(&loadAction, settings);
Application::getInstance()->getAvatar()->loadData(settings);
Application::getInstance()->getSwatch()->loadData(settings);
}
void Menu::saveSettings(QSettings* settings) {
if (!settings) {
settings = Application::getInstance()->getSettings();
}
settings->setValue("gyroCameraSensitivity", _gyroCameraSensitivity);
settings->setValue("audioJitterBufferSamples", _audioJitterBufferSamples);
settings->setValue("fieldOfView", _fieldOfView);
settings->beginGroup("View Frustum Offset Camera");
settings->setValue("viewFrustumOffsetYaw", _viewFrustumOffset.yaw);
settings->setValue("viewFrustumOffsetPitch", _viewFrustumOffset.pitch);
settings->setValue("viewFrustumOffsetRoll", _viewFrustumOffset.roll);
settings->setValue("viewFrustumOffsetDistance", _viewFrustumOffset.distance);
settings->setValue("viewFrustumOffsetUp", _viewFrustumOffset.up);
settings->endGroup();
scanMenuBar(&saveAction, settings);
Application::getInstance()->getAvatar()->saveData(settings);
Application::getInstance()->getSwatch()->saveData(settings);
// ask the NodeList to save its data
NodeList::getInstance()->saveData(settings);
}
void Menu::importSettings() {
QString locationDir(QStandardPaths::displayName(QStandardPaths::DesktopLocation));
QString fileName = QFileDialog::getOpenFileName(Application::getInstance()->getWindow(),
tr("Open .ini config file"),
locationDir,
tr("Text files (*.ini)"));
if (fileName != "") {
QSettings tmp(fileName, QSettings::IniFormat);
loadSettings(&tmp);
}
}
void Menu::exportSettings() {
QString locationDir(QStandardPaths::displayName(QStandardPaths::DesktopLocation));
QString fileName = QFileDialog::getSaveFileName(Application::getInstance()->getWindow(),
tr("Save .ini config file"),
locationDir,
tr("Text files (*.ini)"));
if (fileName != "") {
QSettings tmp(fileName, QSettings::IniFormat);
saveSettings(&tmp);
tmp.sync();
}
}
void Menu::loadAction(QSettings* set, QAction* action) {
if (action->isChecked() != set->value(action->text(), action->isChecked()).toBool()) {
action->trigger();
}
}
void Menu::saveAction(QSettings* set, QAction* action) {
set->setValue(action->text(), action->isChecked());
}
void Menu::scanMenuBar(settingsAction modifySetting, QSettings* set) {
QList<QMenu*> menus = this->findChildren<QMenu *>();
for (QList<QMenu *>::const_iterator it = menus.begin(); menus.end() != it; ++it) {
scanMenu(*it, modifySetting, set);
}
}
void Menu::scanMenu(QMenu* menu, settingsAction modifySetting, QSettings* set) {
QList<QAction*> actions = menu->actions();
set->beginGroup(menu->title());
for (QList<QAction *>::const_iterator it = actions.begin(); actions.end() != it; ++it) {
if ((*it)->menu()) {
scanMenu((*it)->menu(), modifySetting, set);
}
if ((*it)->isCheckable()) {
modifySetting(set, *it);
}
}
set->endGroup();
}
void Menu::handleViewFrustumOffsetKeyModifier(int key) {
const float VIEW_FRUSTUM_OFFSET_DELTA = 0.5f;
const float VIEW_FRUSTUM_OFFSET_UP_DELTA = 0.05f;
switch (key) {
case Qt::Key_BracketLeft:
_viewFrustumOffset.yaw -= VIEW_FRUSTUM_OFFSET_DELTA;
break;
case Qt::Key_BracketRight:
_viewFrustumOffset.yaw += VIEW_FRUSTUM_OFFSET_DELTA;
break;
case Qt::Key_BraceLeft:
_viewFrustumOffset.pitch -= VIEW_FRUSTUM_OFFSET_DELTA;
break;
case Qt::Key_BraceRight:
_viewFrustumOffset.pitch += VIEW_FRUSTUM_OFFSET_DELTA;
break;
case Qt::Key_ParenLeft:
_viewFrustumOffset.roll -= VIEW_FRUSTUM_OFFSET_DELTA;
break;
case Qt::Key_ParenRight:
_viewFrustumOffset.roll += VIEW_FRUSTUM_OFFSET_DELTA;
break;
case Qt::Key_Less:
_viewFrustumOffset.distance -= VIEW_FRUSTUM_OFFSET_DELTA;
break;
case Qt::Key_Greater:
_viewFrustumOffset.distance += VIEW_FRUSTUM_OFFSET_DELTA;
break;
case Qt::Key_Comma:
_viewFrustumOffset.up -= VIEW_FRUSTUM_OFFSET_UP_DELTA;
break;
case Qt::Key_Period:
_viewFrustumOffset.up += VIEW_FRUSTUM_OFFSET_UP_DELTA;
break;
default:
break;
}
}
QAction* Menu::addActionToQMenuAndActionHash(QMenu* destinationMenu,
const QString actionName,
const QKeySequence& shortcut,
const QObject* receiver,
const char* member) {
QAction* action;
if (receiver && member) {
action = destinationMenu->addAction(actionName, receiver, member, shortcut);
} else {
action = destinationMenu->addAction(actionName);
action->setShortcut(shortcut);
}
_actionHash.insert(actionName, action);
return action;
}
QAction* Menu::addCheckableActionToQMenuAndActionHash(QMenu* destinationMenu,
const QString actionName,
const QKeySequence& shortcut,
const bool checked,
const QObject* receiver,
const char* member) {
QAction* action = addActionToQMenuAndActionHash(destinationMenu, actionName, shortcut, receiver, member);
action->setCheckable(true);
action->setChecked(checked);
return action;
}
bool Menu::isOptionChecked(const QString& menuOption) {
return _actionHash.value(menuOption)->isChecked();
}
void Menu::triggerOption(const QString& menuOption) {
_actionHash.value(menuOption)->trigger();
}
QAction* Menu::getActionForOption(const QString& menuOption) {
return _actionHash.value(menuOption);
}
bool Menu::isVoxelModeActionChecked() {
foreach (QAction* action, _voxelModeActionsGroup->actions()) {
if (action->isChecked()) {
return true;
}
}
return false;
}
void Menu::editPreferences() {
Application *applicationInstance = Application::getInstance();
QDialog dialog(applicationInstance->getGLWidget());
dialog.setWindowTitle("Interface Preferences");
QBoxLayout* layout = new QBoxLayout(QBoxLayout::TopToBottom);
dialog.setLayout(layout);
QFormLayout* form = new QFormLayout();
layout->addLayout(form, 1);
const int QLINE_MINIMUM_WIDTH = 400;
QLineEdit* domainServerHostname = new QLineEdit(QString(NodeList::getInstance()->getDomainHostname()));
domainServerHostname->setMinimumWidth(QLINE_MINIMUM_WIDTH);
form->addRow("Domain server:", domainServerHostname);
QLineEdit* avatarURL = new QLineEdit(applicationInstance->getAvatar()->getVoxels()->getVoxelURL().toString());
avatarURL->setMinimumWidth(QLINE_MINIMUM_WIDTH);
form->addRow("Avatar URL:", avatarURL);
QSpinBox* fieldOfView = new QSpinBox();
fieldOfView->setMaximum(180);
fieldOfView->setMinimum(1);
fieldOfView->setValue(_fieldOfView);
form->addRow("Vertical Field of View (Degrees):", fieldOfView);
QDoubleSpinBox* gyroCameraSensitivity = new QDoubleSpinBox();
gyroCameraSensitivity->setValue(_gyroCameraSensitivity);
form->addRow("Gyro Camera Sensitivity (0 - 1):", gyroCameraSensitivity);
QDoubleSpinBox* leanScale = new QDoubleSpinBox();
leanScale->setValue(applicationInstance->getAvatar()->getLeanScale());
form->addRow("Lean Scale:", leanScale);
QSpinBox* audioJitterBufferSamples = new QSpinBox();
audioJitterBufferSamples->setMaximum(10000);
audioJitterBufferSamples->setMinimum(-10000);
audioJitterBufferSamples->setValue(_audioJitterBufferSamples);
form->addRow("Audio Jitter Buffer Samples (0 for automatic):", audioJitterBufferSamples);
QDialogButtonBox* buttons = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
dialog.connect(buttons, SIGNAL(accepted()), SLOT(accept()));
dialog.connect(buttons, SIGNAL(rejected()), SLOT(reject()));
layout->addWidget(buttons);
if (dialog.exec() != QDialog::Accepted) {
return;
}
QByteArray newHostname;
if (domainServerHostname->text().size() > 0) {
// the user input a new hostname, use that
newHostname = domainServerHostname->text().toLocal8Bit();
} else {
// the user left the field blank, use the default hostname
newHostname = QByteArray(DEFAULT_DOMAIN_HOSTNAME);
}
// check if the domain server hostname is new
if (memcmp(NodeList::getInstance()->getDomainHostname(), newHostname.constData(), newHostname.size()) != 0) {
NodeList::getInstance()->clear();
// kill the local voxels
applicationInstance->getVoxels()->killLocalVoxels();
// reset the environment to default
applicationInstance->getEnvironment()->resetToDefault();
// set the new hostname
NodeList::getInstance()->setDomainHostname(newHostname.constData());
}
QUrl url(avatarURL->text());
applicationInstance->getAvatar()->getVoxels()->setVoxelURL(url);
Avatar::sendAvatarVoxelURLMessage(url);
_gyroCameraSensitivity = gyroCameraSensitivity->value();
applicationInstance->getAvatar()->setLeanScale(leanScale->value());
_audioJitterBufferSamples = audioJitterBufferSamples->value();
if (_audioJitterBufferSamples != 0) {
applicationInstance->getAudio()->setJitterBufferSamples(_audioJitterBufferSamples);
}
_fieldOfView = fieldOfView->value();
applicationInstance->resizeGL(applicationInstance->getGLWidget()->width(), applicationInstance->getGLWidget()->height());
}
void Menu::bandwidthDetails() {
if (! _bandwidthDialog) {
_bandwidthDialog = new BandwidthDialog(Application::getInstance()->getGLWidget(),
Application::getInstance()->getBandwidthMeter());
connect(_bandwidthDialog, SIGNAL(closed()), SLOT(bandwidthDetailsClosed()));
_bandwidthDialog->show();
}
_bandwidthDialog->raise();
}
void Menu::bandwidthDetailsClosed() {
delete _bandwidthDialog;
_bandwidthDialog = NULL;
}
void Menu::voxelStatsDetails() {
if (!_voxelStatsDialog) {
_voxelStatsDialog = new VoxelStatsDialog(Application::getInstance()->getGLWidget(),
Application::getInstance()->getVoxelSceneStats());
connect(_voxelStatsDialog, SIGNAL(closed()), SLOT(voxelStatsDetailsClosed()));
_voxelStatsDialog->show();
}
_voxelStatsDialog->raise();
}
void Menu::voxelStatsDetailsClosed() {
delete _voxelStatsDialog;
_voxelStatsDialog = NULL;
}
void Menu::cycleFrustumRenderMode() {
_frustumDrawMode = (FrustumDrawMode)((_frustumDrawMode + 1) % FRUSTUM_DRAW_MODE_COUNT);
updateFrustumRenderModeAction();
}
void Menu::updateVoxelModeActions() {
// only the sender can be checked
foreach (QAction* action, _voxelModeActionsGroup->actions()) {
if (action->isChecked() && action != sender()) {
action->setChecked(false);
}
}
}
void Menu::chooseVoxelPaintColor() {
Application* appInstance = Application::getInstance();
QAction* paintColor = _actionHash.value(MenuOption::VoxelPaintColor);
QColor selected = QColorDialog::getColor(paintColor->data().value<QColor>(),
appInstance->getGLWidget(),
"Voxel Paint Color");
if (selected.isValid()) {
paintColor->setData(selected);
paintColor->setIcon(Swatch::createIcon(selected));
}
// restore the main window's active state
appInstance->getWindow()->activateWindow();
}
void Menu::runTests() {
runTimingTests();
}
void Menu::resetSwatchColors() {
Application::getInstance()->getSwatch()->reset();
}
void Menu::updateFrustumRenderModeAction() {
QAction* frustumRenderModeAction = _actionHash.value(MenuOption::FrustumRenderMode);
switch (_frustumDrawMode) {
default:
case FRUSTUM_DRAW_MODE_ALL:
frustumRenderModeAction->setText("Render Mode - All");
break;
case FRUSTUM_DRAW_MODE_VECTORS:
frustumRenderModeAction->setText("Render Mode - Vectors");
break;
case FRUSTUM_DRAW_MODE_PLANES:
frustumRenderModeAction->setText("Render Mode - Planes");
break;
case FRUSTUM_DRAW_MODE_NEAR_PLANE:
frustumRenderModeAction->setText("Render Mode - Near");
break;
case FRUSTUM_DRAW_MODE_FAR_PLANE:
frustumRenderModeAction->setText("Render Mode - Far");
break;
case FRUSTUM_DRAW_MODE_KEYHOLE:
frustumRenderModeAction->setText("Render Mode - Keyhole");
break;
}
}

198
interface/src/Menu.h Normal file
View file

@ -0,0 +1,198 @@
//
// Menu.h
// hifi
//
// Created by Stephen Birarda on 8/12/13.
// Copyright (c) 2013 HighFidelity, Inc. All rights reserved.
//
#ifndef __hifi__Menu__
#define __hifi__Menu__
#include <QMenuBar>
#include <QHash>
#include <QKeySequence>
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_KEYHOLE,
FRUSTUM_DRAW_MODE_COUNT
};
struct ViewFrustumOffset {
float yaw;
float pitch;
float roll;
float distance;
float up;
};
class Menu : public QMenuBar {
Q_OBJECT
public:
static Menu* getInstance();
bool isOptionChecked(const QString& menuOption);
void triggerOption(const QString& menuOption);
QAction* getActionForOption(const QString& menuOption);
bool isVoxelModeActionChecked();
float getAudioJitterBufferSamples() const { return _audioJitterBufferSamples; }
float getFieldOfView() const { return _fieldOfView; }
float getGyroCameraSensitivity() const { return _gyroCameraSensitivity; }
BandwidthDialog* getBandwidthDialog() const { return _bandwidthDialog; }
FrustumDrawMode getFrustumDrawMode() const { return _frustumDrawMode; }
ViewFrustumOffset getViewFrustumOffset() const { return _viewFrustumOffset; }
VoxelStatsDialog* getVoxelStatsDialog() const { return _voxelStatsDialog; }
void handleViewFrustumOffsetKeyModifier(int key);
public slots:
void bandwidthDetails();
void voxelStatsDetails();
void loadSettings(QSettings* settings = NULL);
void saveSettings(QSettings* settings = NULL);
void importSettings();
void exportSettings();
private slots:
void editPreferences();
void bandwidthDetailsClosed();
void voxelStatsDetailsClosed();
void cycleFrustumRenderMode();
void updateVoxelModeActions();
void chooseVoxelPaintColor();
void runTests();
void resetSwatchColors();
private:
static Menu* _instance;
Menu();
typedef void(*settingsAction)(QSettings*, QAction*);
static void loadAction(QSettings* set, QAction* action);
static void saveAction(QSettings* set, QAction* action);
void scanMenuBar(settingsAction modifySetting, QSettings* set);
void scanMenu(QMenu* menu, settingsAction modifySetting, QSettings* set);
QAction* addActionToQMenuAndActionHash(QMenu* destinationMenu,
const QString actionName,
const QKeySequence& shortcut = 0,
const QObject* receiver = NULL,
const char* member = NULL);
QAction* addCheckableActionToQMenuAndActionHash(QMenu* destinationMenu,
const QString actionName,
const QKeySequence& shortcut = 0,
const bool checked = false,
const QObject* receiver = NULL,
const char* member = NULL);
void updateFrustumRenderModeAction();
QHash<QString, QAction*> _actionHash;
int _audioJitterBufferSamples; /// number of extra samples to wait before starting audio playback
BandwidthDialog* _bandwidthDialog;
float _fieldOfView; /// in Degrees, doesn't apply to HMD like Oculus
FrustumDrawMode _frustumDrawMode;
float _gyroCameraSensitivity;
ViewFrustumOffset _viewFrustumOffset;
QActionGroup* _voxelModeActionsGroup;
VoxelStatsDialog* _voxelStatsDialog;
};
namespace MenuOption {
const QString Avatars = "Avatars";
const QString AvatarAsBalls = "Avatar as Balls";
const QString Atmosphere = "Atmosphere";
const QString Bandwidth = "Bandwidth Display";
const QString BandwidthDetails = "Bandwidth Details";
const QString Collisions = "Collisions";
const QString CopyVoxels = "Copy Voxels";
const QString CoverageMap = "Render Coverage Map";
const QString CoverageMapV2 = "Render Coverage Map V2";
const QString CutVoxels = "Cut Voxels";
const QString DecreaseAvatarSize = "Decrease Avatar Size";
const QString DecreaseVoxelSize = "Decrease Voxel Size";
const QString DestructiveAddVoxel = "Create Voxel is Destructive";
const QString DeltaSending = "Delta Sending";
const QString DisplayFrustum = "Display Frustum";
const QString EchoAudio = "Echo Audio";
const QString ExportVoxels = "Export Voxels";
const QString HeadMouse = "Head Mouse";
const QString FaceMode = "Cycle Face Mode";
const QString FalseColorByDistance = "FALSE Color By Distance";
const QString FalseColorBySource = "FALSE Color By Source";
const QString FalseColorEveryOtherVoxel = "FALSE Color Every Other Randomly";
const QString FalseColorOccluded = "FALSE Color Occluded Voxels";
const QString FalseColorOccludedV2 = "FALSE Color Occluded V2 Voxels";
const QString FalseColorOutOfView = "FALSE Color Voxel Out of View";
const QString FalseColorRandomly = "FALSE Color Voxels Randomly";
const QString FirstPerson = "First Person";
const QString FrameTimer = "Show Timer";
const QString FrustumRenderMode = "Render Mode";
const QString Fullscreen = "Fullscreen";
const QString ImportVoxels = "Import Voxels";
const QString ImportVoxelsClipboard = "Import Voxels to Clipboard";
const QString IncreaseAvatarSize = "Increase Avatar Size";
const QString IncreaseVoxelSize = "Increase Voxel Size";
const QString KillLocalVoxels = "Kill Local Voxels";
const QString GoHome = "Go Home";
const QString Gravity = "Use Gravity";
const QString GroundPlane = "Ground Plane";
const QString GyroLook = "Smooth Gyro Look";
const QString ListenModeNormal = "Listen Mode Normal";
const QString ListenModePoint = "Listen Mode Point";
const QString ListenModeSingleSource = "Listen Mode Single Source";
const QString Log = "Log";
const QString LookAtIndicator = "Look-at Indicator";
const QString LookAtVectors = "Look-at Vectors";
const QString LowRes = "Lower Resolution While Moving";
const QString Mirror = "Mirror";
const QString OcclusionCulling = "Occlusion Culling";
const QString Oscilloscope = "Audio Oscilloscope";
const QString Pair = "Pair";
const QString PasteVoxels = "Paste Voxels";
const QString PipelineWarnings = "Show Render Pipeline Warnings";
const QString Preferences = "Preferences...";
const QString RandomizeVoxelColors = "Randomize Voxel TRUE Colors";
const QString ResetAvatarSize = "Reset Avatar Size";
const QString ResetSwatchColors = "Reset Swatch Colors";
const QString RunTimingTests = "Run Timing Tests";
const QString SendVoxelColors = "Colored Voxels";
const QString SettingsAutosave = "Autosave";
const QString SettingsLoad = "Load Settings";
const QString SettingsSave = "Save Settings";
const QString SettingsImport = "Import Settings";
const QString SettingsExport = "Export Settings";
const QString ShowTrueColors = "Show TRUE Colors";
const QString SimulateLeapHand = "Simulate Leap Hand";
const QString SkeletonTracking = "Skeleton Tracking";
const QString Stars = "Stars";
const QString Stats = "Stats";
const QString TestPing = "Test Ping";
const QString TestRaveGlove = "Test Rave Glove";
const QString TreeStats = "Calculate Tree Stats";
const QString TransmitterDrive = "Transmitter Drive";
const QString Quit = "Quit";
const QString Webcam = "Webcam";
const QString WebcamMode = "Cycle Webcam Send Mode";
const QString WebcamTexture = "Webcam Texture";
const QString Voxels = "Voxels";
const QString VoxelAddMode = "Add Voxel Mode";
const QString VoxelColorMode = "Color Voxel Mode";
const QString VoxelDeleteMode = "Delete Voxel Mode";
const QString VoxelGetColorMode = "Get Color Mode";
const QString VoxelMode = "Cycle Voxel Mode";
const QString VoxelPaintColor = "Voxel Paint Color";
const QString VoxelSelectMode = "Select Voxel Mode";
const QString VoxelStats = "Voxel Stats";
const QString VoxelTextures = "Voxel Textures";
}
#endif /* defined(__hifi__Menu__) */

View file

@ -17,6 +17,16 @@
const char PAIRING_SERVER_HOSTNAME[] = "pairing.highfidelity.io"; const char PAIRING_SERVER_HOSTNAME[] = "pairing.highfidelity.io";
const int PAIRING_SERVER_PORT = 7247; const int PAIRING_SERVER_PORT = 7247;
PairingHandler* PairingHandler::getInstance() {
static PairingHandler* instance = NULL;
if (!instance) {
instance = new PairingHandler();
}
return instance;
}
void PairingHandler::sendPairRequest() { void PairingHandler::sendPairRequest() {
// grab the node socket from the NodeList singleton // grab the node socket from the NodeList singleton
UDPSocket *nodeSocket = NodeList::getInstance()->getNodeSocket(); UDPSocket *nodeSocket = NodeList::getInstance()->getNodeSocket();

View file

@ -9,11 +9,14 @@
#ifndef __hifi__PairingHandler__ #ifndef __hifi__PairingHandler__
#define __hifi__PairingHandler__ #define __hifi__PairingHandler__
#include <iostream> #include <QtCore/QObject>
class PairingHandler { class PairingHandler : public QObject {
Q_OBJECT
public: public:
static void sendPairRequest(); static PairingHandler* getInstance();
public slots:
void sendPairRequest();
}; };
#endif /* defined(__hifi__PairingHandler__) */ #endif /* defined(__hifi__PairingHandler__) */

View file

@ -1,6 +1,20 @@
//
// Swatch.h
// interface
//
// Copyright (c) 2013 High Fidelity, Inc. All rights reserved.
//
#include "Swatch.h" #include "Swatch.h"
#include <iostream> #include <iostream>
QIcon Swatch::createIcon(const QColor& color) {
QPixmap map(16, 16);
map.fill(color);
return QIcon(map);
}
Swatch::Swatch(QAction* action) : Swatch::Swatch(QAction* action) :
Tool(action, 0, -1, -1), Tool(action, 0, -1, -1),
_textRenderer(MONO_FONT_FAMILY, 10, 100), _textRenderer(MONO_FONT_FAMILY, 10, 100),

View file

@ -23,6 +23,8 @@ static const int colorBase[8][3] = {{237, 175, 0},
class Swatch : public Tool { class Swatch : public Tool {
public: public:
static QIcon createIcon(const QColor& color);
Swatch(QAction* action); Swatch(QAction* action);
QColor getColor(); QColor getColor();

View file

@ -11,6 +11,7 @@
#include <PerfStat.h> #include <PerfStat.h>
#include "Application.h" #include "Application.h"
#include "Menu.h"
#include "VoxelEditPacketSender.h" #include "VoxelEditPacketSender.h"
VoxelEditPacketSender::VoxelEditPacketSender(Application* app) : VoxelEditPacketSender::VoxelEditPacketSender(Application* app) :
@ -21,7 +22,7 @@ VoxelEditPacketSender::VoxelEditPacketSender(Application* app) :
void VoxelEditPacketSender::sendVoxelEditMessage(PACKET_TYPE type, VoxelDetail& detail) { void VoxelEditPacketSender::sendVoxelEditMessage(PACKET_TYPE type, VoxelDetail& detail) {
// if the app has Voxels disabled, we don't do any of this... // if the app has Voxels disabled, we don't do any of this...
if (!_app->_renderVoxels->isChecked()) { if (!Menu::getInstance()->isOptionChecked(MenuOption::Voxels)) {
return; // bail early return; // bail early
} }

View file

@ -11,6 +11,7 @@
#include <PerfStat.h> #include <PerfStat.h>
#include "Application.h" #include "Application.h"
#include "Menu.h"
#include "VoxelPacketProcessor.h" #include "VoxelPacketProcessor.h"
VoxelPacketProcessor::VoxelPacketProcessor(Application* app) : VoxelPacketProcessor::VoxelPacketProcessor(Application* app) :
@ -18,7 +19,8 @@ VoxelPacketProcessor::VoxelPacketProcessor(Application* app) :
} }
void VoxelPacketProcessor::processPacket(sockaddr& senderAddress, unsigned char* packetData, ssize_t packetLength) { void VoxelPacketProcessor::processPacket(sockaddr& senderAddress, unsigned char* packetData, ssize_t packetLength) {
PerformanceWarning warn(_app->_renderPipelineWarnings->isChecked(),"VoxelPacketProcessor::processPacket()"); PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings),
"VoxelPacketProcessor::processPacket()");
ssize_t messageLength = packetLength; ssize_t messageLength = packetLength;
// check to see if the UI thread asked us to kill the voxel tree. since we're the only thread allowed to do that // check to see if the UI thread asked us to kill the voxel tree. since we're the only thread allowed to do that
@ -44,7 +46,7 @@ void VoxelPacketProcessor::processPacket(sockaddr& senderAddress, unsigned char*
} }
} // fall through to piggyback message } // fall through to piggyback message
if (_app->_renderVoxels->isChecked()) { if (Menu::getInstance()->isOptionChecked(MenuOption::Voxels)) {
Node* voxelServer = NodeList::getInstance()->nodeWithAddress(&senderAddress); Node* voxelServer = NodeList::getInstance()->nodeWithAddress(&senderAddress);
if (voxelServer && socketMatch(voxelServer->getActiveSocket(), &senderAddress)) { if (voxelServer && socketMatch(voxelServer->getActiveSocket(), &senderAddress)) {
voxelServer->lock(); voxelServer->lock();

View file

@ -28,6 +28,7 @@
#include "CoverageMap.h" #include "CoverageMap.h"
#include "CoverageMapV2.h" #include "CoverageMapV2.h"
#include "InterfaceConfig.h" #include "InterfaceConfig.h"
#include "Menu.h"
#include "renderer/ProgramObject.h" #include "renderer/ProgramObject.h"
#include "VoxelConstants.h" #include "VoxelConstants.h"
#include "VoxelSystem.h" #include "VoxelSystem.h"
@ -189,14 +190,16 @@ int VoxelSystem::parseData(unsigned char* sourceBuffer, int numBytes) {
switch(command) { switch(command) {
case PACKET_TYPE_VOXEL_DATA: { case PACKET_TYPE_VOXEL_DATA: {
PerformanceWarning warn(_renderWarningsOn, "readBitstreamToTree()"); PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings),
"readBitstreamToTree()");
// ask the VoxelTree to read the bitstream into the tree // ask the VoxelTree to read the bitstream into the tree
ReadBitstreamToTreeParams args(WANT_COLOR, WANT_EXISTS_BITS, NULL, getDataSourceID()); ReadBitstreamToTreeParams args(WANT_COLOR, WANT_EXISTS_BITS, NULL, getDataSourceID());
_tree->readBitstreamToTree(voxelData, numBytes - numBytesPacketHeader, args); _tree->readBitstreamToTree(voxelData, numBytes - numBytesPacketHeader, args);
} }
break; break;
case PACKET_TYPE_VOXEL_DATA_MONOCHROME: { case PACKET_TYPE_VOXEL_DATA_MONOCHROME: {
PerformanceWarning warn(_renderWarningsOn, "readBitstreamToTree()"); PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings),
"readBitstreamToTree()");
// ask the VoxelTree to read the MONOCHROME bitstream into the tree // ask the VoxelTree to read the MONOCHROME bitstream into the tree
ReadBitstreamToTreeParams args(NO_COLOR, WANT_EXISTS_BITS, NULL, getDataSourceID()); ReadBitstreamToTreeParams args(NO_COLOR, WANT_EXISTS_BITS, NULL, getDataSourceID());
_tree->readBitstreamToTree(voxelData, numBytes - numBytesPacketHeader, args); _tree->readBitstreamToTree(voxelData, numBytes - numBytesPacketHeader, args);
@ -238,7 +241,8 @@ int VoxelSystem::parseData(unsigned char* sourceBuffer, int numBytes) {
} }
void VoxelSystem::setupNewVoxelsForDrawing() { void VoxelSystem::setupNewVoxelsForDrawing() {
PerformanceWarning warn(_renderWarningsOn, "setupNewVoxelsForDrawing()"); // would like to include _voxelsInArrays, _voxelsUpdated PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings),
"setupNewVoxelsForDrawing()"); // would like to include _voxelsInArrays, _voxelsUpdated
uint64_t start = usecTimestampNow(); uint64_t start = usecTimestampNow();
uint64_t sinceLastTime = (start - _setupNewVoxelsForDrawingLastFinished) / 1000; uint64_t sinceLastTime = (start - _setupNewVoxelsForDrawingLastFinished) / 1000;
@ -273,10 +277,10 @@ void VoxelSystem::setupNewVoxelsForDrawing() {
bool didWriteFullVBO = _writeRenderFullVBO; bool didWriteFullVBO = _writeRenderFullVBO;
if (_tree->isDirty()) { if (_tree->isDirty()) {
static char buffer[64] = { 0 }; static char buffer[64] = { 0 };
if (_renderWarningsOn) { if (Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings)) {
sprintf(buffer, "newTreeToArrays() _writeRenderFullVBO=%s", debug::valueOf(_writeRenderFullVBO)); sprintf(buffer, "newTreeToArrays() _writeRenderFullVBO=%s", debug::valueOf(_writeRenderFullVBO));
}; };
PerformanceWarning warn(_renderWarningsOn, buffer); PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings), buffer);
_callsToTreesToArrays++; _callsToTreesToArrays++;
if (_writeRenderFullVBO) { if (_writeRenderFullVBO) {
_voxelsInWriteArrays = 0; // reset our VBO _voxelsInWriteArrays = 0; // reset our VBO
@ -315,7 +319,7 @@ void VoxelSystem::setupNewVoxelsForDrawing() {
} }
void VoxelSystem::cleanupRemovedVoxels() { void VoxelSystem::cleanupRemovedVoxels() {
PerformanceWarning warn(_renderWarningsOn, "cleanupRemovedVoxels()"); PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings), "cleanupRemovedVoxels()");
// This handles cleanup of voxels that were culled as part of our regular out of view culling operation // This handles cleanup of voxels that were culled as part of our regular out of view culling operation
if (!_removedVoxels.isEmpty()) { if (!_removedVoxels.isEmpty()) {
while (!_removedVoxels.isEmpty()) { while (!_removedVoxels.isEmpty()) {
@ -391,7 +395,8 @@ void VoxelSystem::copyWrittenDataSegmentToReadArrays(glBufferIndex segmentStart,
} }
void VoxelSystem::copyWrittenDataToReadArrays(bool fullVBOs) { void VoxelSystem::copyWrittenDataToReadArrays(bool fullVBOs) {
PerformanceWarning warn(_renderWarningsOn, "copyWrittenDataToReadArrays()"); PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings),
"copyWrittenDataToReadArrays()");
if (_voxelsDirty && _voxelsUpdated) { if (_voxelsDirty && _voxelsUpdated) {
if (fullVBOs) { if (fullVBOs) {
copyWrittenDataToReadArraysFullVBOs(); copyWrittenDataToReadArraysFullVBOs();
@ -525,8 +530,6 @@ glm::vec3 VoxelSystem::computeVoxelVertex(const glm::vec3& startVertex, float vo
ProgramObject* VoxelSystem::_perlinModulateProgram = 0; ProgramObject* VoxelSystem::_perlinModulateProgram = 0;
void VoxelSystem::init() { void VoxelSystem::init() {
_renderWarningsOn = false;
_callsToTreesToArrays = 0; _callsToTreesToArrays = 0;
_setupNewVoxelsForDrawingLastFinished = 0; _setupNewVoxelsForDrawingLastFinished = 0;
_setupNewVoxelsForDrawingLastElapsed = 0; _setupNewVoxelsForDrawingLastElapsed = 0;
@ -657,10 +660,11 @@ void VoxelSystem::updatePartialVBOs() {
void VoxelSystem::updateVBOs() { void VoxelSystem::updateVBOs() {
static char buffer[40] = { 0 }; static char buffer[40] = { 0 };
if (_renderWarningsOn) { if (Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings)) {
sprintf(buffer, "updateVBOs() _readRenderFullVBO=%s", debug::valueOf(_readRenderFullVBO)); sprintf(buffer, "updateVBOs() _readRenderFullVBO=%s", debug::valueOf(_readRenderFullVBO));
}; };
PerformanceWarning warn(_renderWarningsOn, buffer); // would like to include _callsToTreesToArrays // would like to include _callsToTreesToArrays
PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings), buffer);
if (_voxelsDirty) { if (_voxelsDirty) {
if (_readRenderFullVBO) { if (_readRenderFullVBO) {
updateFullVBOs(); updateFullVBOs();
@ -688,7 +692,7 @@ void VoxelSystem::updateVBOSegment(glBufferIndex segmentStart, glBufferIndex seg
} }
void VoxelSystem::render(bool texture) { void VoxelSystem::render(bool texture) {
PerformanceWarning warn(_renderWarningsOn, "render()"); PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings), "render()");
// get the lock so that the update thread won't change anything // get the lock so that the update thread won't change anything
pthread_mutex_lock(&_bufferWriteLock); pthread_mutex_lock(&_bufferWriteLock);
@ -824,7 +828,9 @@ bool VoxelSystem::falseColorizeInViewOperation(VoxelNode* node, void* extraData)
return true; // keep going! return true; // keep going!
} }
void VoxelSystem::falseColorizeInView(ViewFrustum* viewFrustum) { void VoxelSystem::falseColorizeInView() {
ViewFrustum* viewFrustum = Application::getInstance()->getViewFrustum();
_nodeCount = 0; _nodeCount = 0;
_tree->recurseTreeWithOperation(falseColorizeInViewOperation,(void*)viewFrustum); _tree->recurseTreeWithOperation(falseColorizeInViewOperation,(void*)viewFrustum);
qDebug("setting in view false color for %d nodes\n", _nodeCount); qDebug("setting in view false color for %d nodes\n", _nodeCount);
@ -951,14 +957,16 @@ bool VoxelSystem::getDistanceFromViewRangeOperation(VoxelNode* node, void* extra
return true; // keep going! return true; // keep going!
} }
void VoxelSystem::falseColorizeDistanceFromView(ViewFrustum* viewFrustum) { void VoxelSystem::falseColorizeDistanceFromView() {
ViewFrustum* viewFrustum = Application::getInstance()->getViewFrustum();
_nodeCount = 0; _nodeCount = 0;
_maxDistance = 0.0; _maxDistance = 0.0;
_minDistance = FLT_MAX; _minDistance = FLT_MAX;
_tree->recurseTreeWithOperation(getDistanceFromViewRangeOperation,(void*)viewFrustum); _tree->recurseTreeWithOperation(getDistanceFromViewRangeOperation, (void*) viewFrustum);
qDebug("determining distance range for %d nodes\n", _nodeCount); qDebug("determining distance range for %d nodes\n", _nodeCount);
_nodeCount = 0; _nodeCount = 0;
_tree->recurseTreeWithOperation(falseColorizeDistanceFromViewOperation,(void*)viewFrustum); _tree->recurseTreeWithOperation(falseColorizeDistanceFromViewOperation, (void*) viewFrustum);
qDebug("setting in distance false color for %d nodes\n", _nodeCount); qDebug("setting in distance false color for %d nodes\n", _nodeCount);
_tree->setDirtyBit(); _tree->setDirtyBit();
setupNewVoxelsForDrawing(); setupNewVoxelsForDrawing();
@ -1063,7 +1071,7 @@ bool VoxelSystem::hasViewChanged() {
} }
void VoxelSystem::removeOutOfView() { void VoxelSystem::removeOutOfView() {
PerformanceWarning warn(_renderWarningsOn, "removeOutOfView()"); PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings), "removeOutOfView()");
removeOutOfViewArgs args(this); removeOutOfViewArgs args(this);
_tree->recurseTreeWithOperation(removeOutOfViewOperation,(void*)&args); _tree->recurseTreeWithOperation(removeOutOfViewOperation,(void*)&args);

View file

@ -1,13 +1,13 @@
// //
// Cube.h // VoxelSystem.h
// interface // interface
// //
// Created by Philip on 12/31/12. // Created by Philip on 12/31/12.
// Copyright (c) 2012 High Fidelity, Inc. All rights reserved. // Copyright (c) 2012 High Fidelity, Inc. All rights reserved.
// //
#ifndef __interface__Cube__ #ifndef __interface__VoxelSystem__
#define __interface__Cube__ #define __interface__VoxelSystem__
#include "InterfaceConfig.h" #include "InterfaceConfig.h"
#include <glm/glm.hpp> #include <glm/glm.hpp>
@ -29,6 +29,7 @@ class ProgramObject;
const int NUM_CHILDREN = 8; const int NUM_CHILDREN = 8;
class VoxelSystem : public NodeData, public VoxelNodeDeleteHook, public NodeListHook { class VoxelSystem : public NodeData, public VoxelNodeDeleteHook, public NodeListHook {
Q_OBJECT
public: public:
VoxelSystem(float treeScale = TREE_SCALE, int maxVoxels = MAX_VOXELS_PER_SYSTEM); VoxelSystem(float treeScale = TREE_SCALE, int maxVoxels = MAX_VOXELS_PER_SYSTEM);
~VoxelSystem(); ~VoxelSystem();
@ -60,21 +61,7 @@ public:
float getVoxelsColoredPerSecondAverage(); float getVoxelsColoredPerSecondAverage();
float getVoxelsBytesReadPerSecondAverage(); float getVoxelsBytesReadPerSecondAverage();
// Methods that recurse tree
void randomizeVoxelColors();
void falseColorizeRandom();
void trueColorize();
void falseColorizeInView(ViewFrustum* viewFrustum);
void falseColorizeDistanceFromView(ViewFrustum* viewFrustum);
void falseColorizeRandomEveryOther();
void falseColorizeOccluded();
void falseColorizeOccludedV2();
void falseColorizeBySource();
void killLocalVoxels(); void killLocalVoxels();
void setRenderPipelineWarnings(bool on) { _renderWarningsOn = on; };
bool getRenderPipelineWarnings() const { return _renderWarningsOn; };
virtual void removeOutOfView(); virtual void removeOutOfView();
bool hasViewChanged(); bool hasViewChanged();
@ -85,8 +72,6 @@ public:
bool findSpherePenetration(const glm::vec3& center, float radius, glm::vec3& penetration); bool findSpherePenetration(const glm::vec3& center, float radius, glm::vec3& penetration);
bool findCapsulePenetration(const glm::vec3& start, const glm::vec3& end, float radius, glm::vec3& penetration); bool findCapsulePenetration(const glm::vec3& start, const glm::vec3& end, float radius, glm::vec3& penetration);
void collectStatsForTreesAndVBOs();
void deleteVoxelAt(float x, float y, float z, float s); void deleteVoxelAt(float x, float y, float z, float s);
VoxelNode* getVoxelAt(float x, float y, float z, float s) const; VoxelNode* getVoxelAt(float x, float y, float z, float s) const;
@ -105,6 +90,20 @@ public:
virtual void nodeDeleted(VoxelNode* node); virtual void nodeDeleted(VoxelNode* node);
virtual void nodeAdded(Node* node); virtual void nodeAdded(Node* node);
virtual void nodeKilled(Node* node); virtual void nodeKilled(Node* node);
public slots:
void collectStatsForTreesAndVBOs();
// Methods that recurse tree
void randomizeVoxelColors();
void falseColorizeRandom();
void trueColorize();
void falseColorizeInView();
void falseColorizeDistanceFromView();
void falseColorizeRandomEveryOther();
void falseColorizeOccluded();
void falseColorizeOccludedV2();
void falseColorizeBySource();
protected: protected:
float _treeScale; float _treeScale;
@ -130,7 +129,6 @@ private:
int _callsToTreesToArrays; int _callsToTreesToArrays;
VoxelNodeBag _removedVoxels; VoxelNodeBag _removedVoxels;
bool _renderWarningsOn;
// Operation functions for tree recursion methods // Operation functions for tree recursion methods
static int _nodeCount; static int _nodeCount;
static bool randomColorOperation(VoxelNode* node, void* extraData); static bool randomColorOperation(VoxelNode* node, void* extraData);

View file

@ -63,6 +63,28 @@ bool usingBigSphereCollisionTest = true;
float chatMessageScale = 0.0015; float chatMessageScale = 0.0015;
float chatMessageHeight = 0.20; float chatMessageHeight = 0.20;
void Avatar::sendAvatarVoxelURLMessage(const QUrl& url) {
uint16_t ownerID = NodeList::getInstance()->getOwnerID();
if (ownerID == UNKNOWN_NODE_ID) {
return; // we don't yet know who we are
}
QByteArray message;
char packetHeader[MAX_PACKET_HEADER_BYTES];
int numBytesPacketHeader = populateTypeAndVersion((unsigned char*) packetHeader, PACKET_TYPE_AVATAR_VOXEL_URL);
message.append(packetHeader, numBytesPacketHeader);
message.append((const char*)&ownerID, sizeof(ownerID));
message.append(url.toEncoded());
Application::controlledBroadcastToNodes((unsigned char*)message.data(),
message.size(),
&NODE_TYPE_AVATAR_MIXER,
1);
}
Avatar::Avatar(Node* owningNode) : Avatar::Avatar(Node* owningNode) :
AvatarData(owningNode), AvatarData(owningNode),
_initialized(false), _initialized(false),
@ -1632,6 +1654,30 @@ void Avatar::renderJointConnectingCone(glm::vec3 position1, glm::vec3 position2,
glEnd(); glEnd();
} }
void Avatar::goHome() {
qDebug("Going Home!\n");
setPosition(START_LOCATION);
}
void Avatar::increaseSize() {
if ((1.f + SCALING_RATIO) * _newScale < MAX_SCALE) {
_newScale *= (1.f + SCALING_RATIO);
qDebug("Changed scale to %f\n", _newScale);
}
}
void Avatar::decreaseSize() {
if (MIN_SCALE < (1.f - SCALING_RATIO) * _newScale) {
_newScale *= (1.f - SCALING_RATIO);
qDebug("Changed scale to %f\n", _newScale);
}
}
void Avatar::resetSize() {
_newScale = 1.0f;
qDebug("Reseted scale to %f\n", _newScale);
}
void Avatar::setNewScale(const float scale) { void Avatar::setNewScale(const float scale) {
_newScale = scale; _newScale = scale;
} }

View file

@ -58,8 +58,7 @@ const float BODY_BALL_RADIUS_RIGHT_KNEE = 0.025;
const float BODY_BALL_RADIUS_RIGHT_HEEL = 0.025; const float BODY_BALL_RADIUS_RIGHT_HEEL = 0.025;
const float BODY_BALL_RADIUS_RIGHT_TOES = 0.025; const float BODY_BALL_RADIUS_RIGHT_TOES = 0.025;
enum AvatarBodyBallID enum AvatarBodyBallID {
{
BODY_BALL_NULL = -1, BODY_BALL_NULL = -1,
BODY_BALL_PELVIS, BODY_BALL_PELVIS,
BODY_BALL_TORSO, BODY_BALL_TORSO,
@ -91,8 +90,7 @@ enum AvatarBodyBallID
NUM_AVATAR_BODY_BALLS NUM_AVATAR_BODY_BALLS
}; };
enum DriveKeys enum DriveKeys {
{
FWD = 0, FWD = 0,
BACK, BACK,
LEFT, LEFT,
@ -104,16 +102,14 @@ enum DriveKeys
MAX_DRIVE_KEYS MAX_DRIVE_KEYS
}; };
enum AvatarMode enum AvatarMode {
{
AVATAR_MODE_STANDING = 0, AVATAR_MODE_STANDING = 0,
AVATAR_MODE_WALKING, AVATAR_MODE_WALKING,
AVATAR_MODE_INTERACTING, AVATAR_MODE_INTERACTING,
NUM_AVATAR_MODES NUM_AVATAR_MODES
}; };
enum ScreenTintLayer enum ScreenTintLayer {
{
SCREEN_TINT_BEFORE_LANDSCAPE = 0, SCREEN_TINT_BEFORE_LANDSCAPE = 0,
SCREEN_TINT_BEFORE_AVATARS, SCREEN_TINT_BEFORE_AVATARS,
SCREEN_TINT_BEFORE_MY_AVATAR, SCREEN_TINT_BEFORE_MY_AVATAR,
@ -121,8 +117,16 @@ enum ScreenTintLayer
NUM_SCREEN_TINT_LAYERS NUM_SCREEN_TINT_LAYERS
}; };
// Where one's own Avatar begins in the world (will be overwritten if avatar data file is found)
// this is basically in the center of the ground plane. Slightly adjusted. This was asked for by
// Grayson as he's building a street around here for demo dinner 2
const glm::vec3 START_LOCATION(0.485f * TREE_SCALE, 0.f, 0.5f * TREE_SCALE);
class Avatar : public AvatarData { class Avatar : public AvatarData {
Q_OBJECT
public: public:
static void sendAvatarVoxelURLMessage(const QUrl& url);
Avatar(Node* owningNode = NULL); Avatar(Node* owningNode = NULL);
~Avatar(); ~Avatar();
@ -139,52 +143,51 @@ public:
void renderScreenTint(ScreenTintLayer layer, Camera& whichCamera); void renderScreenTint(ScreenTintLayer layer, Camera& whichCamera);
//setters //setters
void setMousePressed (bool mousePressed ) { _mousePressed = mousePressed;} void setMousePressed(bool mousePressed) { _mousePressed = mousePressed; }
void setNoise (float mag ) { _head.noise = mag;} void setMovedHandOffset(glm::vec3 movedHandOffset) { _movedHandOffset = movedHandOffset;}
void setMovedHandOffset (glm::vec3 movedHandOffset ) { _movedHandOffset = movedHandOffset;} void setThrust(glm::vec3 newThrust) { _thrust = newThrust; }
void setThrust (glm::vec3 newThrust ) { _thrust = newThrust; }; void setDisplayingLookatVectors(bool displayingLookatVectors) { _head.setRenderLookatVectors(displayingLookatVectors); }
void setDisplayingLookatVectors(bool displayingLookatVectors) { _head.setRenderLookatVectors(displayingLookatVectors);} void setVelocity(const glm::vec3 velocity) { _velocity = velocity; };
void setVelocity (const glm::vec3 velocity ) { _velocity = velocity; }; void setLeanScale(float scale) { _leanScale = scale;}
void setLeanScale (float scale ) { _leanScale = scale;}
void setGravity (glm::vec3 gravity); void setGravity(glm::vec3 gravity);
void setMouseRay (const glm::vec3 &origin, const glm::vec3 &direction); void setMouseRay(const glm::vec3 &origin, const glm::vec3 &direction);
void setOrientation (const glm::quat& orientation); void setOrientation(const glm::quat& orientation);
void setNewScale (const float scale); void setNewScale(const float scale);
void setWantCollisionsOn (bool wantCollisionsOn ) { _isCollisionsOn = wantCollisionsOn; }
//getters //getters
bool isInitialized () const { return _initialized;} bool isInitialized() const { return _initialized;}
bool isMyAvatar () const { return _owningNode == NULL; } bool isMyAvatar() const { return _owningNode == NULL; }
const Skeleton& getSkeleton () const { return _skeleton;} const Skeleton& getSkeleton() const { return _skeleton;}
float getHeadYawRate () const { return _head.yawRate;} float getHeadYawRate() const { return _head.yawRate;}
float getBodyYaw () const { return _bodyYaw;} float getBodyYaw() const { return _bodyYaw;}
bool getIsNearInteractingOther () const { return _avatarTouch.getAbleToReachOtherAvatar();} bool getIsNearInteractingOther() const { return _avatarTouch.getAbleToReachOtherAvatar();}
const glm::vec3& getHeadJointPosition () const { return _skeleton.joint[ AVATAR_JOINT_HEAD_BASE ].position;} const glm::vec3& getHeadJointPosition() const { return _skeleton.joint[ AVATAR_JOINT_HEAD_BASE ].position;}
const glm::vec3& getBallPosition (AvatarJointID j) const { return _bodyBall[j].position;} const glm::vec3& getBallPosition(AvatarJointID j) const { return _bodyBall[j].position;}
glm::vec3 getBodyRightDirection () const { return getOrientation() * IDENTITY_RIGHT; } glm::vec3 getBodyRightDirection() const { return getOrientation() * IDENTITY_RIGHT; }
glm::vec3 getBodyUpDirection () const { return getOrientation() * IDENTITY_UP; } glm::vec3 getBodyUpDirection() const { return getOrientation() * IDENTITY_UP; }
glm::vec3 getBodyFrontDirection () const { return getOrientation() * IDENTITY_FRONT; } glm::vec3 getBodyFrontDirection() const { return getOrientation() * IDENTITY_FRONT; }
float getScale () const { return _scale;} float getScale() const { return _scale;}
float getNewScale () const { return _newScale;} float getNewScale() const { return _newScale;}
const glm::vec3& getVelocity () const { return _velocity;} const glm::vec3& getVelocity() const { return _velocity;}
float getSpeed () const { return _speed;} float getSpeed() const { return _speed;}
float getHeight () const { return _height;} float getHeight() const { return _height;}
AvatarMode getMode () const { return _mode;} AvatarMode getMode() const { return _mode;}
float getLeanScale () const { return _leanScale;} float getLeanScale() const { return _leanScale;}
float getElapsedTimeStopped () const { return _elapsedTimeStopped;} float getElapsedTimeStopped() const { return _elapsedTimeStopped;}
float getElapsedTimeMoving () const { return _elapsedTimeMoving;} float getElapsedTimeMoving() const { return _elapsedTimeMoving;}
float getElapsedTimeSinceCollision() const { return _elapsedTimeSinceCollision;} float getElapsedTimeSinceCollision() const { return _elapsedTimeSinceCollision;}
const glm::vec3& getLastCollisionPosition () const { return _lastCollisionPosition;} const glm::vec3& getLastCollisionPosition() const { return _lastCollisionPosition;}
float getAbsoluteHeadYaw () const; float getAbsoluteHeadYaw() const;
float getAbsoluteHeadPitch () const; float getAbsoluteHeadPitch() const;
Head& getHead () {return _head; } Head& getHead() {return _head; }
Hand& getHand () {return _hand; } Hand& getHand() {return _hand; }
glm::quat getOrientation () const; glm::quat getOrientation() const;
glm::quat getWorldAlignedOrientation() const; glm::quat getWorldAlignedOrientation() const;
const glm::vec3& getMouseRayOrigin () const { return _mouseRayOrigin; } const glm::vec3& getMouseRayOrigin() const { return _mouseRayOrigin; }
const glm::vec3& getMouseRayDirection () const { return _mouseRayDirection; } const glm::vec3& getMouseRayDirection() const { return _mouseRayDirection; }
Avatar* getLeadingAvatar () const { return _leadingAvatar; } Avatar* getLeadingAvatar() const { return _leadingAvatar; }
glm::vec3 getGravity () const { return _gravity; } glm::vec3 getGravity() const { return _gravity; }
glm::vec3 getUprightHeadPosition() const; glm::vec3 getUprightHeadPosition() const;
glm::vec3 getUprightEyeLevelPosition() const; glm::vec3 getUprightEyeLevelPosition() const;
@ -209,14 +212,20 @@ public:
void getBodyBallTransform(AvatarJointID jointID, glm::vec3& position, glm::quat& rotation) const; void getBodyBallTransform(AvatarJointID jointID, glm::vec3& position, glm::quat& rotation) const;
static void renderJointConnectingCone(glm::vec3 position1, glm::vec3 position2, float radius1, float radius2); static void renderJointConnectingCone(glm::vec3 position1, glm::vec3 position2, float radius1, float radius2);
public slots:
void setWantCollisionsOn(bool wantCollisionsOn) { _isCollisionsOn = wantCollisionsOn; }
void goHome();
void increaseSize();
void decreaseSize();
void resetSize();
private: private:
// privatize copy constructor and assignment operator to avoid copying // privatize copy constructor and assignment operator to avoid copying
Avatar(const Avatar&); Avatar(const Avatar&);
Avatar& operator= (const Avatar&); Avatar& operator= (const Avatar&);
struct AvatarBall struct AvatarBall {
{
AvatarJointID parentJoint; // the skeletal joint that serves as a reference for determining the position AvatarJointID parentJoint; // the skeletal joint that serves as a reference for determining the position
glm::vec3 parentOffset; // a 3D vector in the frame of reference of the parent skeletal joint glm::vec3 parentOffset; // a 3D vector in the frame of reference of the parent skeletal joint
AvatarBodyBallID parentBall; // the ball to which this ball is constrained for spring forces AvatarBodyBallID parentBall; // the ball to which this ball is constrained for spring forces

View file

@ -384,6 +384,12 @@ void Head::renderMohawk() {
if (!_mohawkTriangleFan) { if (!_mohawkTriangleFan) {
createMohawk(); createMohawk();
// if we get here and still don't have a mohawk then we don't know who we are
// so return out since we can't render it yet
if (!_mohawkTriangleFan) {
return;
}
} }
if (USING_PHYSICAL_MOHAWK) { if (USING_PHYSICAL_MOHAWK) {

View file

@ -23,8 +23,7 @@
#include "SerialInterface.h" #include "SerialInterface.h"
#include "world.h" #include "world.h"
enum eyeContactTargets enum eyeContactTargets {
{
LEFT_EYE, LEFT_EYE,
RIGHT_EYE, RIGHT_EYE,
MOUTH MOUTH
@ -45,19 +44,18 @@ public:
void render(float alpha); void render(float alpha);
void renderMohawk(); void renderMohawk();
void setScale (float scale ); void setScale(float scale);
void setPosition (glm::vec3 position ) { _position = position; } void setPosition(glm::vec3 position) { _position = position; }
void setBodyRotation (glm::vec3 bodyRotation ) { _bodyRotation = bodyRotation; } void setBodyRotation(glm::vec3 bodyRotation) { _bodyRotation = bodyRotation; }
void setGravity (glm::vec3 gravity ) { _gravity = gravity; } void setGravity(glm::vec3 gravity) { _gravity = gravity; }
void setSkinColor (glm::vec3 skinColor ) { _skinColor = skinColor; } void setSkinColor(glm::vec3 skinColor) { _skinColor = skinColor; }
void setSpringScale (float returnSpringScale ) { _returnSpringScale = returnSpringScale; } void setSpringScale(float returnSpringScale) { _returnSpringScale = returnSpringScale; }
void setAverageLoudness(float averageLoudness ) { _averageLoudness = averageLoudness; } void setAverageLoudness(float averageLoudness) { _averageLoudness = averageLoudness; }
void setReturnToCenter (bool returnHeadToCenter) { _returnHeadToCenter = returnHeadToCenter; } void setReturnToCenter (bool returnHeadToCenter) { _returnHeadToCenter = returnHeadToCenter; }
void setRenderLookatVectors(bool onOff ) { _renderLookatVectors = onOff; } void setRenderLookatVectors(bool onOff) { _renderLookatVectors = onOff; }
void setCameraFollowsHead(bool cameraFollowsHead) { _cameraFollowsHead = cameraFollowsHead; } void setCameraFollowsHead(bool cameraFollowsHead) { _cameraFollowsHead = cameraFollowsHead; }
float getMousePitch() { return _mousePitch; } float getMousePitch() const { return _mousePitch; }
void setMousePitch(float mousePitch) { _mousePitch = mousePitch; } void setMousePitch(float mousePitch) { _mousePitch = mousePitch; }
glm::quat getOrientation() const; glm::quat getOrientation() const;
@ -67,7 +65,7 @@ public:
glm::vec3 getPosition() const { return _position; } glm::vec3 getPosition() const { return _position; }
const glm::vec3& getEyePosition() const { return _eyePosition; } const glm::vec3& getEyePosition() const { return _eyePosition; }
glm::vec3 getRightDirection() const { return getOrientation() * IDENTITY_RIGHT; } glm::vec3 getRightDirection() const { return getOrientation() * IDENTITY_RIGHT; }
glm::vec3 getUpDirection () const { return getOrientation() * IDENTITY_UP; } glm::vec3 getUpDirection() const { return getOrientation() * IDENTITY_UP; }
glm::vec3 getFrontDirection() const { return getOrientation() * IDENTITY_FRONT; } glm::vec3 getFrontDirection() const { return getOrientation() * IDENTITY_FRONT; }
Face& getFace() { return _face; } Face& getFace() { return _face; }
@ -77,61 +75,59 @@ public:
glm::vec3 calculateAverageEyePosition() { return _leftEyePosition + (_rightEyePosition - _leftEyePosition ) * ONE_HALF; } glm::vec3 calculateAverageEyePosition() { return _leftEyePosition + (_rightEyePosition - _leftEyePosition ) * ONE_HALF; }
float yawRate; float yawRate;
float noise;
private: private:
// disallow copies of the Head, copy of owning Avatar is disallowed too // disallow copies of the Head, copy of owning Avatar is disallowed too
Head(const Head&); Head(const Head&);
Head& operator= (const Head&); Head& operator= (const Head&);
struct Nose struct Nose {
{
glm::vec3 top; glm::vec3 top;
glm::vec3 left; glm::vec3 left;
glm::vec3 right; glm::vec3 right;
glm::vec3 front; glm::vec3 front;
}; };
float _renderAlpha; float _renderAlpha;
bool _returnHeadToCenter; bool _returnHeadToCenter;
glm::vec3 _skinColor; glm::vec3 _skinColor;
glm::vec3 _position; glm::vec3 _position;
glm::vec3 _rotation; glm::vec3 _rotation;
glm::vec3 _leftEyePosition; glm::vec3 _leftEyePosition;
glm::vec3 _rightEyePosition; glm::vec3 _rightEyePosition;
glm::vec3 _eyePosition; glm::vec3 _eyePosition;
glm::vec3 _leftEyeBrowPosition; glm::vec3 _leftEyeBrowPosition;
glm::vec3 _rightEyeBrowPosition; glm::vec3 _rightEyeBrowPosition;
glm::vec3 _leftEarPosition; glm::vec3 _leftEarPosition;
glm::vec3 _rightEarPosition; glm::vec3 _rightEarPosition;
glm::vec3 _mouthPosition; glm::vec3 _mouthPosition;
Nose _nose; Nose _nose;
float _scale; float _scale;
float _browAudioLift; float _browAudioLift;
glm::vec3 _gravity; glm::vec3 _gravity;
float _lastLoudness; float _lastLoudness;
float _averageLoudness; float _averageLoudness;
float _audioAttack; float _audioAttack;
float _returnSpringScale; //strength of return springs float _returnSpringScale; //strength of return springs
glm::vec3 _bodyRotation; glm::vec3 _bodyRotation;
bool _renderLookatVectors; bool _renderLookatVectors;
BendyLine _hairTuft[NUM_HAIR_TUFTS]; BendyLine _hairTuft[NUM_HAIR_TUFTS];
glm::vec3* _mohawkTriangleFan; glm::vec3* _mohawkTriangleFan;
glm::vec3* _mohawkColors; glm::vec3* _mohawkColors;
glm::vec3 _saccade; glm::vec3 _saccade;
glm::vec3 _saccadeTarget; glm::vec3 _saccadeTarget;
float _leftEyeBlink; float _leftEyeBlink;
float _rightEyeBlink; float _rightEyeBlink;
float _leftEyeBlinkVelocity; float _leftEyeBlinkVelocity;
float _rightEyeBlinkVelocity; float _rightEyeBlinkVelocity;
float _timeWithoutTalking; float _timeWithoutTalking;
float _cameraPitch; // Used to position the camera differently from the head float _cameraPitch; // Used to position the camera differently from the head
float _mousePitch; float _mousePitch;
float _cameraYaw; float _cameraYaw;
bool _isCameraMoving; bool _isCameraMoving;
bool _cameraFollowsHead; bool _cameraFollowsHead;
float _cameraFollowHeadRate; float _cameraFollowHeadRate;
Face _face; Face _face;
static ProgramObject* _irisProgram; static ProgramObject* _irisProgram;
static GLuint _irisTextureID; static GLuint _irisTextureID;

View file

@ -18,12 +18,19 @@
#include "Application.h" #include "Application.h"
#include <QDebug> #include <QDebug>
#include <QDir>
int main(int argc, const char * argv[]) { int main(int argc, const char * argv[]) {
timeval startup_time; timeval startup_time;
gettimeofday(&startup_time, NULL); gettimeofday(&startup_time, NULL);
#if defined(Q_OS_MAC)
const QString QT_RELEASE_PLUGIN_PATH = "/usr/local/lib/qt5/plugins";
QCoreApplication::addLibraryPath(QT_RELEASE_PLUGIN_PATH);
#endif
Application app(argc, const_cast<char**>(argv), startup_time); Application app(argc, const_cast<char**>(argv), startup_time);
qDebug( "Created QT Application.\n" ); qDebug( "Created QT Application.\n" );
int exitCode = app.exec(); int exitCode = app.exec();
qDebug("Normal exit.\n"); qDebug("Normal exit.\n");

View file

@ -143,13 +143,16 @@ parameterizedJob.with {
doxygenJob = hifiJob('docs', false) doxygenJob = hifiJob('docs', false)
doxygenJob.with { doxygenJob.with {
scm {
git(GIT_REPO_URL, 'master') {}
}
configure { project -> configure { project ->
(project / builders).setValue('') (project / builders).setValue('')
project / publishers / 'hudson.plugins.doxygen.DoxygenArchiver' { }
doxyfilePath 'Doxyfile'
keepAll false steps {
folderWhereYouRunDoxygen '' shell('doxygen')
}
} }
} }

View file

@ -56,8 +56,8 @@ public:
const glm::vec3& getPosition() const { return _position; } const glm::vec3& getPosition() const { return _position; }
void setPosition (const glm::vec3 position ) { _position = position; } void setPosition(const glm::vec3 position) { _position = position; }
void setHandPosition (const glm::vec3 handPosition ) { _handPosition = handPosition; } void setHandPosition(const glm::vec3 handPosition) { _handPosition = handPosition; }
void setPositionFromVariantMap(QVariantMap positionMap); void setPositionFromVariantMap(QVariantMap positionMap);
QVariantMap getPositionVariantMap(); QVariantMap getPositionVariantMap();
@ -82,22 +82,22 @@ public:
char getHandState() const {return _handState; }; char getHandState() const {return _handState; };
// getters for camera details // getters for camera details
const glm::vec3& getCameraPosition() const { return _cameraPosition; }; const glm::vec3& getCameraPosition() const { return _cameraPosition; };
const glm::quat& getCameraOrientation() const { return _cameraOrientation; } const glm::quat& getCameraOrientation() const { return _cameraOrientation; }
float getCameraFov() const { return _cameraFov; } float getCameraFov() const { return _cameraFov; }
float getCameraAspectRatio() const { return _cameraAspectRatio; } float getCameraAspectRatio() const { return _cameraAspectRatio; }
float getCameraNearClip() const { return _cameraNearClip; } float getCameraNearClip() const { return _cameraNearClip; }
float getCameraFarClip() const { return _cameraFarClip; } float getCameraFarClip() const { return _cameraFarClip; }
glm::vec3 calculateCameraDirection() const; glm::vec3 calculateCameraDirection() const;
// setters for camera details // setters for camera details
void setCameraPosition(const glm::vec3& position) { _cameraPosition = position; } void setCameraPosition(const glm::vec3& position) { _cameraPosition = position; }
void setCameraOrientation(const glm::quat& orientation) { _cameraOrientation = orientation; } void setCameraOrientation(const glm::quat& orientation) { _cameraOrientation = orientation; }
void setCameraFov(float fov) { _cameraFov = fov; } void setCameraFov(float fov) { _cameraFov = fov; }
void setCameraAspectRatio(float aspectRatio) { _cameraAspectRatio = aspectRatio; } void setCameraAspectRatio(float aspectRatio) { _cameraAspectRatio = aspectRatio; }
void setCameraNearClip(float nearClip) { _cameraNearClip = nearClip; } void setCameraNearClip(float nearClip) { _cameraNearClip = nearClip; }
void setCameraFarClip(float farClip) { _cameraFarClip = farClip; } void setCameraFarClip(float farClip) { _cameraFarClip = farClip; }
// key state // key state
void setKeyState(KeyState s) { _keyState = s; } void setKeyState(KeyState s) { _keyState = s; }
@ -110,22 +110,21 @@ public:
QString getQStringChatMessage() { return QString(_chatMessage.data()); } QString getQStringChatMessage() { return QString(_chatMessage.data()); }
// related to Voxel Sending strategies // related to Voxel Sending strategies
bool getWantColor() const { return _wantColor; } bool getWantColor() const { return _wantColor; }
bool getWantDelta() const { return _wantDelta; } bool getWantDelta() const { return _wantDelta; }
bool getWantLowResMoving() const { return _wantLowResMoving; } bool getWantLowResMoving() const { return _wantLowResMoving; }
bool getWantOcclusionCulling() const { return _wantOcclusionCulling; } bool getWantOcclusionCulling() const { return _wantOcclusionCulling; }
uint16_t getLeaderID() const { return _leaderID; } uint16_t getLeaderID() const { return _leaderID; }
void setWantColor(bool wantColor) { _wantColor = wantColor; }
void setWantDelta(bool wantDelta) { _wantDelta = wantDelta; }
void setWantLowResMoving(bool wantLowResMoving) { _wantLowResMoving = wantLowResMoving; }
void setWantOcclusionCulling(bool wantOcclusionCulling) { _wantOcclusionCulling = wantOcclusionCulling; }
void setHeadData(HeadData* headData) { _headData = headData; } void setHeadData(HeadData* headData) { _headData = headData; }
void setHandData(HandData* handData) { _handData = handData; } void setHandData(HandData* handData) { _handData = handData; }
public slots: public slots:
void sendData(); void sendData();
void setWantLowResMoving(bool wantLowResMoving) { _wantLowResMoving = wantLowResMoving; }
void setWantColor(bool wantColor) { _wantColor = wantColor; }
void setWantDelta(bool wantDelta) { _wantDelta = wantDelta; }
void setWantOcclusionCulling(bool wantOcclusionCulling) { _wantOcclusionCulling = wantOcclusionCulling; }
protected: protected:
glm::vec3 _position; glm::vec3 _position;

View file

@ -63,7 +63,7 @@ NodeList::NodeList(char newOwnerType, unsigned short int newSocketListenPort) :
_ownerType(newOwnerType), _ownerType(newOwnerType),
_nodeTypesOfInterest(NULL), _nodeTypesOfInterest(NULL),
_ownerID(UNKNOWN_NODE_ID), _ownerID(UNKNOWN_NODE_ID),
_lastNodeID(0) _lastNodeID(UNKNOWN_NODE_ID + 1)
{ {
memcpy(_domainHostname, DEFAULT_DOMAIN_HOSTNAME, sizeof(DEFAULT_DOMAIN_HOSTNAME)); memcpy(_domainHostname, DEFAULT_DOMAIN_HOSTNAME, sizeof(DEFAULT_DOMAIN_HOSTNAME));
memcpy(_domainIP, DEFAULT_DOMAIN_IP, sizeof(DEFAULT_DOMAIN_IP)); memcpy(_domainIP, DEFAULT_DOMAIN_IP, sizeof(DEFAULT_DOMAIN_IP));

View file

@ -41,7 +41,7 @@ extern const char DEFAULT_DOMAIN_HOSTNAME[MAX_HOSTNAME_BYTES];
extern const char DEFAULT_DOMAIN_IP[INET_ADDRSTRLEN]; // IP Address will be re-set by lookup on startup extern const char DEFAULT_DOMAIN_IP[INET_ADDRSTRLEN]; // IP Address will be re-set by lookup on startup
extern const int DEFAULT_DOMAINSERVER_PORT; extern const int DEFAULT_DOMAINSERVER_PORT;
const int UNKNOWN_NODE_ID = -1; const int UNKNOWN_NODE_ID = 0;
class NodeListIterator; class NodeListIterator;