From 5ffe3fa4b42797759da4cc30eca46b19e7fb6aa5 Mon Sep 17 00:00:00 2001 From: Mark Peng Date: Wed, 17 Jul 2013 13:52:05 -0700 Subject: [PATCH 1/9] Rendering of indicator circle in 3D space. Spacing edits in util. --- interface/src/Application.cpp | 31 +++++++++++++++++++++++++++---- interface/src/Application.h | 2 ++ interface/src/Util.cpp | 2 -- interface/src/Util.h | 1 - 4 files changed, 29 insertions(+), 7 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 1bfba999b1..c5153cb48a 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -55,6 +55,7 @@ #include #include #include +#include #include "Application.h" #include "InterfaceConfig.h" @@ -196,6 +197,7 @@ Application::Application(int& argc, char** argv, timeval &startup_time) : _mousePressed(false), _mouseVoxelScale(1.0f / 1024.0f), _justEditedVoxel(false), + _isLookingAtOtherAvatar(false), _paintOn(false), _dominantColor(0), _perfStatsOn(false), @@ -1881,6 +1883,7 @@ bool Application::isLookingAtOtherAvatar(glm::vec3& mouseRayOrigin, glm::vec3& m glm::vec3 headPosition = avatar->getHead().getPosition(); if (rayIntersectsSphere(mouseRayOrigin, mouseRayDirection, headPosition, HEAD_SPHERE_RADIUS)) { eyePosition = avatar->getHead().getEyeLevelPosition(); + renderLookatIndicator(headPosition); return true; } } @@ -1888,6 +1891,26 @@ bool Application::isLookingAtOtherAvatar(glm::vec3& mouseRayOrigin, glm::vec3& m return false; } +void Application::renderLookatIndicator(glm::vec3& pointOfInterest) { + // Render a circle between me and the avatar in question. + + // I need a vector that is perpendicular to the vector from my camera position to the head position. + // Start by locating point on vector that will be the center of the circle. + glm::vec3 direction = glm::normalize(pointOfInterest - _myCamera.getPosition()); + const float DISTANCE_FROM_HEAD_SPHERE = 0.1f; + glm::vec3 indicatorOrigin = pointOfInterest - DISTANCE_FROM_HEAD_SPHERE * direction; + // Then find a perpendicular vector/point + // const float ARB_X = 1.0f; + // const float ARB_Y = 1.0f; + + // float z = - (direction.x * ARB_X + direction.y * ARB_Y) / direction.z; + // glm::vec3 perpendicular(ARB_X, ARB_Y, z); + // perpendicular = glm::normalize(perpendicular); + // glm::vec3 startingVertex = indicatorOrigin + perpendicular; + renderCircle(indicatorOrigin, 0.1, direction, 30); + +} + void Application::update(float deltaTime) { // Use Transmitter Hand to move hand if connected, else use mouse if (_myTransmitter.isConnected()) { @@ -1915,7 +1938,7 @@ void Application::update(float deltaTime) { // Set where I am looking based on my mouse ray (so that other people can see) glm::vec3 eyePosition; - if (isLookingAtOtherAvatar(mouseRayOrigin, mouseRayDirection, eyePosition)) { + if (_isLookingAtOtherAvatar = isLookingAtOtherAvatar(mouseRayOrigin, mouseRayDirection, eyePosition)) { // If the mouse is over another avatar's head... glm::vec3 myLookAtFromMouse(eyePosition); _myAvatar.getHead().setLookAtPosition(myLookAtFromMouse); @@ -1932,7 +1955,7 @@ void Application::update(float deltaTime) { glm::vec3 front = orientation * IDENTITY_FRONT; glm::vec3 up = orientation * IDENTITY_UP; glm::vec3 towardVoxel = getMouseVoxelWorldCoordinates(_mouseVoxelDragging) - - _myAvatar.getCameraPosition(); + - _myAvatar.getCameraPosition(); // is this an error? getCameraPosition dne towardVoxel = front * glm::length(towardVoxel); glm::vec3 lateralToVoxel = glm::cross(up, glm::normalize(towardVoxel)) * glm::length(towardVoxel); _voxelThrust = glm::vec3(0, 0, 0); @@ -2176,7 +2199,7 @@ void Application::updateAvatar(float deltaTime) { _viewFrustum.computePickRay(MIDPOINT_OF_SCREEN, MIDPOINT_OF_SCREEN, screenCenterRayOrigin, screenCenterRayDirection); glm::vec3 eyePosition; - if (isLookingAtOtherAvatar(screenCenterRayOrigin, screenCenterRayDirection, eyePosition)) { + if (_isLookingAtOtherAvatar = isLookingAtOtherAvatar(screenCenterRayOrigin, screenCenterRayDirection, eyePosition)) { glm::vec3 myLookAtFromMouse(eyePosition); _myAvatar.getHead().setLookAtPosition(myLookAtFromMouse); } @@ -2204,7 +2227,7 @@ void Application::updateAvatar(float deltaTime) { // actually need to calculate the view frustum planes to send these details // to the server. loadViewFrustum(_myCamera, _viewFrustum); - _myAvatar.setCameraPosition(_viewFrustum.getPosition()); + _myAvatar.setCameraPosition(_viewFrustum.getPosition()); // setCameraPosition() dne _myAvatar.setCameraOrientation(_viewFrustum.getOrientation()); _myAvatar.setCameraFov(_viewFrustum.getFieldOfView()); _myAvatar.setCameraAspectRatio(_viewFrustum.getAspectRatio()); diff --git a/interface/src/Application.h b/interface/src/Application.h index 7a31ac96c7..ce8cfc4f80 100644 --- a/interface/src/Application.h +++ b/interface/src/Application.h @@ -353,6 +353,8 @@ private: float _mouseVoxelScale; // the scale for adding/removing voxels glm::vec3 _lastMouseVoxelPos; // the position of the last mouse voxel edit bool _justEditedVoxel; // set when we've just added/deleted/colored a voxel + + bool _isLookingAtOtherAvatar; bool _paintOn; // Whether to paint voxels as you fly around unsigned char _dominantColor; // The dominant color of the voxel we're painting diff --git a/interface/src/Util.cpp b/interface/src/Util.cpp index 20f33f924a..094caa7e74 100644 --- a/interface/src/Util.cpp +++ b/interface/src/Util.cpp @@ -525,8 +525,6 @@ void runTimingTests() { gettimeofday(&endTime, NULL); elapsedMsecs = diffclock(&startTime, &endTime); qDebug("vec3 assign and dot() usecs: %f\n", 1000.0f * elapsedMsecs / (float) numTests); - - } float loadSetting(QSettings* settings, const char* name, float defaultValue) { diff --git a/interface/src/Util.h b/interface/src/Util.h index 37bd0595ec..f569e5a409 100644 --- a/interface/src/Util.h +++ b/interface/src/Util.h @@ -68,7 +68,6 @@ void renderCircle(glm::vec3 position, float radius, glm::vec3 surfaceNormal, int void runTimingTests(); - float loadSetting(QSettings* settings, const char* name, float defaultValue); bool rayIntersectsSphere(glm::vec3& rayStarting, glm::vec3& rayNormalizedDirection, glm::vec3& sphereCenter, double sphereRadius); From 125bcc46f486ae06cc3be0099a19867bf55eb265 Mon Sep 17 00:00:00 2001 From: Mark Peng Date: Wed, 17 Jul 2013 17:27:15 -0700 Subject: [PATCH 2/9] Circle drawn with camera orientation as its normal for lookatIndicator. --- interface/src/Application.cpp | 29 ++++++++++++++-------------- interface/src/Application.h | 3 +++ libraries/voxels/src/ViewFrustum.cpp | 5 ++++- libraries/voxels/src/ViewFrustum.h | 2 ++ 4 files changed, 24 insertions(+), 15 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 10da14697b..2c2a197899 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -1676,6 +1676,8 @@ void Application::initMenu() { _renderFrameTimerOn->setChecked(false); (_renderLookatOn = renderMenu->addAction("Lookat Vectors"))->setCheckable(true); _renderLookatOn->setChecked(false); + (_renderLookatIndicatorOn = renderMenu->addAction("Lookat Indicator"))->setCheckable(true); + _renderLookatIndicatorOn->setChecked(true); (_manualFirstPerson = renderMenu->addAction( "First Person", this, SLOT(setRenderFirstPerson(bool)), Qt::Key_P))->setCheckable(true); (_manualThirdPerson = renderMenu->addAction( @@ -1887,7 +1889,7 @@ bool Application::isLookingAtOtherAvatar(glm::vec3& mouseRayOrigin, glm::vec3& m glm::vec3 headPosition = avatar->getHead().getPosition(); if (rayIntersectsSphere(mouseRayOrigin, mouseRayDirection, headPosition, HEAD_SPHERE_RADIUS)) { eyePosition = avatar->getHead().getEyeLevelPosition(); - renderLookatIndicator(headPosition); + _lookatOtherPosition = headPosition; return true; } } @@ -1895,24 +1897,19 @@ bool Application::isLookingAtOtherAvatar(glm::vec3& mouseRayOrigin, glm::vec3& m return false; } -void Application::renderLookatIndicator(glm::vec3& pointOfInterest) { - // Render a circle between me and the avatar in question. +void Application::renderLookatIndicator(glm::vec3 pointOfInterest, Camera& whichCamera) { - // I need a vector that is perpendicular to the vector from my camera position to the head position. - // Start by locating point on vector that will be the center of the circle. - glm::vec3 direction = glm::normalize(pointOfInterest - _myCamera.getPosition()); + glm::vec3 direction = glm::normalize(pointOfInterest - whichCamera.getPosition()); const float DISTANCE_FROM_HEAD_SPHERE = 0.1f; glm::vec3 indicatorOrigin = pointOfInterest - DISTANCE_FROM_HEAD_SPHERE * direction; - // Then find a perpendicular vector/point - // const float ARB_X = 1.0f; - // const float ARB_Y = 1.0f; - // float z = - (direction.x * ARB_X + direction.y * ARB_Y) / direction.z; - // glm::vec3 perpendicular(ARB_X, ARB_Y, z); - // perpendicular = glm::normalize(perpendicular); - // glm::vec3 startingVertex = indicatorOrigin + perpendicular; - renderCircle(indicatorOrigin, 0.1, direction, 30); + // glm::vec3 haloOrigin(pointOfInterest.x, pointOfInterest.y + DISTANCE_FROM_HEAD_SPHERE, pointOfInterest.z); + glColor3f(1.0f, 0.0f, 0.0f); + // renderCircle(haloOrigin, 0.1f, glm::vec3(0.0f, 1.0f, 0.0f), 30); + // glm::vec3 normal; + // _viewFrustum.computeNormalToNearClipPlane(normal); + renderCircle(indicatorOrigin, 0.1f, _viewFrustum.getDirection(), 30); } void Application::update(float deltaTime) { @@ -2605,6 +2602,10 @@ void Application::displaySide(Camera& whichCamera) { } _myAvatar.render(_lookingInMirror->isChecked(), _renderAvatarBalls->isChecked()); _myAvatar.setDisplayingLookatVectors(_renderLookatOn->isChecked()); + + if (_renderLookatIndicatorOn->isChecked() && _isLookingAtOtherAvatar) { + renderLookatIndicator(_lookatOtherPosition, whichCamera); + } } if (TESTING_PARTICLE_SYSTEM) { diff --git a/interface/src/Application.h b/interface/src/Application.h index 52e75ea446..b577fa3af2 100644 --- a/interface/src/Application.h +++ b/interface/src/Application.h @@ -195,6 +195,7 @@ private: void update(float deltaTime); bool isLookingAtOtherAvatar(glm::vec3& mouseRayOrigin, glm::vec3& mouseRayDirection, glm::vec3& eyePosition); + void renderLookatIndicator(glm::vec3 pointOfInterest, Camera& whichCamera); void updateAvatar(float deltaTime); void loadViewFrustum(Camera& camera, ViewFrustum& viewFrustum); @@ -250,6 +251,7 @@ private: 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* _manualFirstPerson; // Whether to force first-person mode QAction* _manualThirdPerson; // Whether to force third-person mode QAction* _logOn; // Whether to show on-screen log @@ -365,6 +367,7 @@ private: bool _justEditedVoxel; // set when we've just added/deleted/colored a voxel bool _isLookingAtOtherAvatar; + glm::vec3 _lookatOtherPosition; bool _paintOn; // Whether to paint voxels as you fly around unsigned char _dominantColor; // The dominant color of the voxel we're painting diff --git a/libraries/voxels/src/ViewFrustum.cpp b/libraries/voxels/src/ViewFrustum.cpp index c13da815f8..69fbeab54d 100644 --- a/libraries/voxels/src/ViewFrustum.cpp +++ b/libraries/voxels/src/ViewFrustum.cpp @@ -364,7 +364,10 @@ bool ViewFrustum::matches(const ViewFrustum& compareTo, bool debug) const { return result; } - +void ViewFrustum::computeNormalToNearClipPlane(glm::vec3& normal) const { + Plane nearClipPlane(_nearTopLeft, _nearTopRight, _nearBottomLeft); + normal = nearClipPlane.getNormal(); +} void ViewFrustum::computePickRay(float x, float y, glm::vec3& origin, glm::vec3& direction) const { origin = _nearTopLeft + x*(_nearTopRight - _nearTopLeft) + y*(_nearBottomLeft - _nearTopLeft); diff --git a/libraries/voxels/src/ViewFrustum.h b/libraries/voxels/src/ViewFrustum.h index 188b85c0de..4f34143b27 100644 --- a/libraries/voxels/src/ViewFrustum.h +++ b/libraries/voxels/src/ViewFrustum.h @@ -83,6 +83,8 @@ public: bool matches(const ViewFrustum& compareTo, bool debug = false) const; bool matches(const ViewFrustum* compareTo, bool debug = false) const { return matches(*compareTo, debug); }; + void computeNormalToNearClipPlane(glm::vec3& normal) const; + void computePickRay(float x, float y, glm::vec3& origin, glm::vec3& direction) const; void computeOffAxisFrustum(float& left, float& right, float& bottom, float& top, float& near, float& far, From 7ee0d8da2e67d12ba54be16777e1032836bfe92b Mon Sep 17 00:00:00 2001 From: Mark Peng Date: Thu, 18 Jul 2013 14:34:51 -0700 Subject: [PATCH 3/9] Render circle in 3D space for lookatIndicator. Still not normal to the screen. --- interface/src/Application.cpp | 9 ++++++--- interface/src/Application.h | 1 + libraries/voxels/src/ViewFrustum.cpp | 6 +++--- libraries/voxels/src/ViewFrustum.h | 2 +- 4 files changed, 11 insertions(+), 7 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 09a9ec611e..f800c5c6b1 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -1907,9 +1907,12 @@ void Application::renderLookatIndicator(glm::vec3 pointOfInterest, Camera& which glColor3f(1.0f, 0.0f, 0.0f); // renderCircle(haloOrigin, 0.1f, glm::vec3(0.0f, 1.0f, 0.0f), 30); - // glm::vec3 normal; - // _viewFrustum.computeNormalToNearClipPlane(normal); - renderCircle(indicatorOrigin, 0.1f, _viewFrustum.getDirection(), 30); + loadViewFrustum(_myCamera, _viewFrustum); + glm::vec3 normal; + _viewFrustum.computeNormalToOffset(normal); + + // Plane::Plane p(_viewFrustum.getOffsetPosition(), _viewFrustum.getOffsetUp(), _viewFrustum.getOffsetRight()); + renderCircle(indicatorOrigin, 0.1f, normal, 30); } void Application::update(float deltaTime) { diff --git a/interface/src/Application.h b/interface/src/Application.h index b577fa3af2..d09290c66e 100644 --- a/interface/src/Application.h +++ b/interface/src/Application.h @@ -42,6 +42,7 @@ #include "ViewFrustum.h" #include "VoxelSystem.h" #include "Webcam.h" +#include "Plane.h" class QAction; diff --git a/libraries/voxels/src/ViewFrustum.cpp b/libraries/voxels/src/ViewFrustum.cpp index 69fbeab54d..1122f6476e 100644 --- a/libraries/voxels/src/ViewFrustum.cpp +++ b/libraries/voxels/src/ViewFrustum.cpp @@ -364,9 +364,9 @@ bool ViewFrustum::matches(const ViewFrustum& compareTo, bool debug) const { return result; } -void ViewFrustum::computeNormalToNearClipPlane(glm::vec3& normal) const { - Plane nearClipPlane(_nearTopLeft, _nearTopRight, _nearBottomLeft); - normal = nearClipPlane.getNormal(); +void ViewFrustum::computeNormalToOffset(glm::vec3& normal) const { + Plane offsetPlane(_offsetPosition, _offsetRight, _offsetUp); + normal = offsetPlane.getNormal(); } void ViewFrustum::computePickRay(float x, float y, glm::vec3& origin, glm::vec3& direction) const { diff --git a/libraries/voxels/src/ViewFrustum.h b/libraries/voxels/src/ViewFrustum.h index 4f34143b27..9ecca573af 100644 --- a/libraries/voxels/src/ViewFrustum.h +++ b/libraries/voxels/src/ViewFrustum.h @@ -83,7 +83,7 @@ public: bool matches(const ViewFrustum& compareTo, bool debug = false) const; bool matches(const ViewFrustum* compareTo, bool debug = false) const { return matches(*compareTo, debug); }; - void computeNormalToNearClipPlane(glm::vec3& normal) const; + void computeNormalToOffset(glm::vec3& normal) const; void computePickRay(float x, float y, glm::vec3& origin, glm::vec3& direction) const; From 01e6891fd3d1403434c0b12f5e58b6ae1f2c7633 Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Thu, 18 Jul 2013 17:23:52 -0700 Subject: [PATCH 4/9] save custom domain server hostname to QSettings --- interface/src/Application.cpp | 48 +++++++++++++++++++------------ libraries/shared/src/NodeList.cpp | 26 +++++++++++++++++ libraries/shared/src/NodeList.h | 5 ++++ 3 files changed, 60 insertions(+), 19 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index eb99feca47..9b57ccd433 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -235,6 +235,31 @@ Application::Application(int& argc, char** argv, timeval &startup_time) : NodeList::getInstance()->getNodeSocket()->setBlocking(false); } + // setup QSettings +#ifdef Q_WS_MAC + QString resourcesPath = QCoreApplication::applicationDirPath() + "/../Resources"; +#else + QString resourcesPath = QCoreApplication::applicationDirPath() + "/resources"; +#endif + + // read the ApplicationInfo.ini file for Name/Version/Domain information + QSettings applicationInfo(resourcesPath + "/info/ApplicationInfo.ini", QSettings::IniFormat); + + // set the associated application properties + applicationInfo.beginGroup("INFO"); + + setApplicationName(applicationInfo.value("name").toString()); + setApplicationVersion(applicationInfo.value("version").toString()); + setOrganizationName(applicationInfo.value("organizationName").toString()); + setOrganizationDomain(applicationInfo.value("organizationDomain").toString()); + + _settings = new QSettings(this); + + // check if there is a saved domain server hostname + // this must be done now instead of with the other setting checks to allow manual override with + // --domain or --local options + NodeList::getInstance()->loadData(_settings); + const char* domainIP = getCmdOption(argc, constArgv, "--domain"); if (domainIP) { NodeList::getInstance()->setDomainIP(domainIP); @@ -268,23 +293,6 @@ Application::Application(int& argc, char** argv, timeval &startup_time) : _window->setCentralWidget(_glWidget); -#ifdef Q_WS_MAC - QString resourcesPath = QCoreApplication::applicationDirPath() + "/../Resources"; -#else - QString resourcesPath = QCoreApplication::applicationDirPath() + "/resources"; -#endif - - // read the ApplicationInfo.ini file for Name/Version/Domain information - QSettings applicationInfo(resourcesPath + "/info/ApplicationInfo.ini", QSettings::IniFormat); - - // set the associated application properties - applicationInfo.beginGroup("INFO"); - - setApplicationName(applicationInfo.value("name").toString()); - setApplicationVersion(applicationInfo.value("version").toString()); - setOrganizationName(applicationInfo.value("organizationName").toString()); - setOrganizationDomain(applicationInfo.value("organizationDomain").toString()); - #if defined(Q_WS_MAC) && defined(QT_NO_DEBUG) // if this is a release OS X build use fervor to check for an update FvUpdater::sharedUpdater()->SetFeedURL("https://s3-us-west-1.amazonaws.com/highfidelity/appcast.xml"); @@ -1781,7 +1789,6 @@ void Application::initMenu() { settingsMenu->addAction("Export settings", this, SLOT(exportSettings())); _networkAccessManager = new QNetworkAccessManager(this); - _settings = new QSettings(this); } void Application::updateFrustumRenderModeAction() { @@ -3451,7 +3458,7 @@ void Application::saveSettings(QSettings* settings) { if (!settings) { settings = getSettings(); } - + settings->setValue("headCameraPitchYawScale", _headCameraPitchYawScale); settings->setValue("audioJitterBufferSamples", _audioJitterBufferSamples); settings->setValue("horizontalFieldOfView", _horizontalFieldOfView); @@ -3466,6 +3473,9 @@ void Application::saveSettings(QSettings* settings) { scanMenuBar(&Application::saveAction, settings); getAvatar()->saveData(settings); _swatch.saveData(settings); + + // ask the NodeList to save its data + NodeList::getInstance()->saveData(settings); } void Application::importSettings() { diff --git a/libraries/shared/src/NodeList.cpp b/libraries/shared/src/NodeList.cpp index 91fe1f4a21..184cb346e8 100644 --- a/libraries/shared/src/NodeList.cpp +++ b/libraries/shared/src/NodeList.cpp @@ -499,6 +499,32 @@ void NodeList::startSilentNodeRemovalThread() { void NodeList::stopSilentNodeRemovalThread() { silentNodeThreadStopFlag = true; pthread_join(removeSilentNodesThread, NULL); + +} + +const QString QSETTINGS_GROUP_NAME = "NodeList"; +const QString DOMAIN_SERVER_SETTING_KEY = "domainServerHostname"; + +void NodeList::loadData(QSettings *settings) { + settings->beginGroup(DOMAIN_SERVER_SETTING_KEY); + + QString domainServerHostname = settings->value(DOMAIN_SERVER_SETTING_KEY).toString(); + + if (domainServerHostname.size() > 0) { + memset(_domainHostname, 0, MAX_HOSTNAME_BYTES); + memcpy(_domainHostname, domainServerHostname.toAscii().constData(), domainServerHostname.size()); + } + + settings->endGroup(); +} + +void NodeList::saveData(QSettings* settings) { + if (memcmp(_domainHostname, DEFAULT_DOMAIN_HOSTNAME, strlen(DEFAULT_DOMAIN_HOSTNAME)) != 0) { + // the user is using a different hostname, store it + settings->beginGroup(DOMAIN_SERVER_SETTING_KEY); + settings->setValue(DOMAIN_SERVER_SETTING_KEY, QVariant(_domainHostname)); + settings->endGroup(); + } } NodeList::iterator NodeList::begin() const { diff --git a/libraries/shared/src/NodeList.h b/libraries/shared/src/NodeList.h index 0c8a68d38c..2a66fc7374 100644 --- a/libraries/shared/src/NodeList.h +++ b/libraries/shared/src/NodeList.h @@ -14,6 +14,8 @@ #include #include +#include + #include "Node.h" #include "UDPSocket.h" @@ -99,6 +101,9 @@ public: void startSilentNodeRemovalThread(); void stopSilentNodeRemovalThread(); + void loadData(QSettings* settings); + void saveData(QSettings* settings); + friend class NodeListIterator; private: static NodeList* _sharedInstance; From ef7dc4a39abc40ce408b0713f94c1cd14688c05c Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Thu, 18 Jul 2013 17:42:25 -0700 Subject: [PATCH 5/9] if the hostname field is left blank reset to DEFAULT_DOMAIN_HOSTNAME --- interface/src/Application.cpp | 16 ++++++++++++---- libraries/shared/src/NodeList.cpp | 9 +++++++-- 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 9b57ccd433..c5c18c9fdb 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -1151,11 +1151,18 @@ void Application::editPreferences() { return; } - char newHostname[MAX_HOSTNAME_BYTES] = {}; - memcpy(newHostname, domainServerHostname->text().toAscii().data(), domainServerHostname->text().size()); + QByteArray newHostname; + + if (domainServerHostname->text().size() > 0) { + // the user input a new hostname, use that + newHostname = domainServerHostname->text().toAscii(); + } 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, strlen(newHostname)) != 0) { + if (memcmp(NodeList::getInstance()->getDomainHostname(), newHostname.constData(), newHostname.size()) != 0) { NodeList::getInstance()->clear(); @@ -1165,7 +1172,8 @@ void Application::editPreferences() { // reset the environment to default _environment.resetToDefault(); - NodeList::getInstance()->setDomainHostname(newHostname); + // set the new hostname + NodeList::getInstance()->setDomainHostname(newHostname.constData()); } QUrl url(avatarURL->text()); diff --git a/libraries/shared/src/NodeList.cpp b/libraries/shared/src/NodeList.cpp index 184cb346e8..9406c6b14d 100644 --- a/libraries/shared/src/NodeList.cpp +++ b/libraries/shared/src/NodeList.cpp @@ -519,12 +519,17 @@ void NodeList::loadData(QSettings *settings) { } void NodeList::saveData(QSettings* settings) { + settings->beginGroup(DOMAIN_SERVER_SETTING_KEY); + if (memcmp(_domainHostname, DEFAULT_DOMAIN_HOSTNAME, strlen(DEFAULT_DOMAIN_HOSTNAME)) != 0) { // the user is using a different hostname, store it - settings->beginGroup(DOMAIN_SERVER_SETTING_KEY); settings->setValue(DOMAIN_SERVER_SETTING_KEY, QVariant(_domainHostname)); - settings->endGroup(); + } else { + // the user has switched back to default, remove the current setting + settings->remove(DOMAIN_SERVER_SETTING_KEY); } + + settings->endGroup(); } NodeList::iterator NodeList::begin() const { From 927aea8bb4e06727dd58c67b1e0c84585f38faa7 Mon Sep 17 00:00:00 2001 From: Mark Peng Date: Fri, 19 Jul 2013 00:44:23 -0700 Subject: [PATCH 6/9] Bug fix on lookatVectors (fixed scale in head.cpp). Added bool isLookingAtOtherAvatar. Basic halo indicator in Application.cpp. --- interface/src/Application.cpp | 17 ++++------------- interface/src/Head.cpp | 2 +- 2 files changed, 5 insertions(+), 14 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 4129edd9df..d1b098eca3 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -1894,20 +1894,11 @@ bool Application::isLookingAtOtherAvatar(glm::vec3& mouseRayOrigin, glm::vec3& m void Application::renderLookatIndicator(glm::vec3 pointOfInterest, Camera& whichCamera) { - glm::vec3 direction = glm::normalize(pointOfInterest - whichCamera.getPosition()); const float DISTANCE_FROM_HEAD_SPHERE = 0.1f; - glm::vec3 indicatorOrigin = pointOfInterest - DISTANCE_FROM_HEAD_SPHERE * direction; - - // glm::vec3 haloOrigin(pointOfInterest.x, pointOfInterest.y + DISTANCE_FROM_HEAD_SPHERE, pointOfInterest.z); - - glColor3f(1.0f, 0.0f, 0.0f); - // renderCircle(haloOrigin, 0.1f, glm::vec3(0.0f, 1.0f, 0.0f), 30); - loadViewFrustum(_myCamera, _viewFrustum); - glm::vec3 normal; - _viewFrustum.computeNormalToOffset(normal); - - // Plane::Plane p(_viewFrustum.getOffsetPosition(), _viewFrustum.getOffsetUp(), _viewFrustum.getOffsetRight()); - renderCircle(indicatorOrigin, 0.1f, normal, 30); + const float YELLOW[] = { 1.0f, 1.0f, 0.0f }; + glm::vec3 haloOrigin(pointOfInterest.x, pointOfInterest.y + DISTANCE_FROM_HEAD_SPHERE, pointOfInterest.z); + glColor3f(YELLOW[0], YELLOW[1], YELLOW[2]); + renderCircle(haloOrigin, 0.1f, glm::vec3(0.0f, 1.0f, 0.0f), 30); } void Application::update(float deltaTime) { diff --git a/interface/src/Head.cpp b/interface/src/Head.cpp index a477910d67..178f927c6f 100644 --- a/interface/src/Head.cpp +++ b/interface/src/Head.cpp @@ -271,7 +271,7 @@ void Head::calculateGeometry() { + up * _scale * BODY_BALL_RADIUS_HEAD_BASE * EYE_UP_OFFSET + front * _scale * BODY_BALL_RADIUS_HEAD_BASE * EYE_FRONT_OFFSET; - _eyeLevelPosition = _position + up * _scale * EYE_UP_OFFSET; + _eyeLevelPosition = _position + up * _scale * BODY_BALL_RADIUS_HEAD_BASE * EYE_UP_OFFSET; //calculate the eyebrow positions _leftEyeBrowPosition = _leftEyePosition; From fc222405254d85fe127b18f0504a1e97011dc790 Mon Sep 17 00:00:00 2001 From: Mark Peng Date: Fri, 19 Jul 2013 00:55:31 -0700 Subject: [PATCH 7/9] Remove unnecessary import math.h. --- interface/src/Application.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 9e9dadb03f..da50e7c040 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -55,7 +55,7 @@ #include #include #include -#include +// #include #include "Application.h" #include "InterfaceConfig.h" From ceb743a65dc9c55b1bdeef42835edc81cf63d0ed Mon Sep 17 00:00:00 2001 From: Mark Peng Date: Fri, 19 Jul 2013 00:56:12 -0700 Subject: [PATCH 8/9] Remove unncessary import math.h (for reals). --- interface/src/Application.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index da50e7c040..a7d5629643 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -55,7 +55,6 @@ #include #include #include -// #include #include "Application.h" #include "InterfaceConfig.h" From a14768bb29b558250f66f79602d7607dbff5f320 Mon Sep 17 00:00:00 2001 From: Mark Peng Date: Fri, 19 Jul 2013 01:00:55 -0700 Subject: [PATCH 9/9] Remove more unnecessary additions. --- interface/src/Application.h | 1 - libraries/voxels/src/ViewFrustum.cpp | 5 ----- libraries/voxels/src/ViewFrustum.h | 2 -- 3 files changed, 8 deletions(-) diff --git a/interface/src/Application.h b/interface/src/Application.h index d09290c66e..b577fa3af2 100644 --- a/interface/src/Application.h +++ b/interface/src/Application.h @@ -42,7 +42,6 @@ #include "ViewFrustum.h" #include "VoxelSystem.h" #include "Webcam.h" -#include "Plane.h" class QAction; diff --git a/libraries/voxels/src/ViewFrustum.cpp b/libraries/voxels/src/ViewFrustum.cpp index 1122f6476e..ae48dbbe7d 100644 --- a/libraries/voxels/src/ViewFrustum.cpp +++ b/libraries/voxels/src/ViewFrustum.cpp @@ -364,11 +364,6 @@ bool ViewFrustum::matches(const ViewFrustum& compareTo, bool debug) const { return result; } -void ViewFrustum::computeNormalToOffset(glm::vec3& normal) const { - Plane offsetPlane(_offsetPosition, _offsetRight, _offsetUp); - normal = offsetPlane.getNormal(); -} - void ViewFrustum::computePickRay(float x, float y, glm::vec3& origin, glm::vec3& direction) const { origin = _nearTopLeft + x*(_nearTopRight - _nearTopLeft) + y*(_nearBottomLeft - _nearTopLeft); direction = glm::normalize(origin - _position); diff --git a/libraries/voxels/src/ViewFrustum.h b/libraries/voxels/src/ViewFrustum.h index 9ecca573af..188b85c0de 100644 --- a/libraries/voxels/src/ViewFrustum.h +++ b/libraries/voxels/src/ViewFrustum.h @@ -83,8 +83,6 @@ public: bool matches(const ViewFrustum& compareTo, bool debug = false) const; bool matches(const ViewFrustum* compareTo, bool debug = false) const { return matches(*compareTo, debug); }; - void computeNormalToOffset(glm::vec3& normal) const; - void computePickRay(float x, float y, glm::vec3& origin, glm::vec3& direction) const; void computeOffAxisFrustum(float& left, float& right, float& bottom, float& top, float& near, float& far,