diff --git a/examples/ControlledAC.js b/examples/acScripts/ControlledAC.js similarity index 100% rename from examples/ControlledAC.js rename to examples/acScripts/ControlledAC.js diff --git a/examples/PlayRecordingOnAC.js b/examples/acScripts/PlayRecordingOnAC.js similarity index 100% rename from examples/PlayRecordingOnAC.js rename to examples/acScripts/PlayRecordingOnAC.js diff --git a/examples/acScripts/ambiance.js b/examples/acScripts/ambiance.js new file mode 100644 index 0000000000..0149d5d3ff --- /dev/null +++ b/examples/acScripts/ambiance.js @@ -0,0 +1,42 @@ +// +// ambiance.js +// examples +// +// Created by Clément Brisset on 11/18/14. +// Copyright 2014 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html +// + +var soundURL = "https://s3.amazonaws.com/hifi-public/sounds/08_Funny_Bone.wav"; +var position = { x: 700, y: 25, z: 725 }; +var audioOptions = { + position: position, + volume: 0.4, + loop: true, + stereo: false +}; + +var sound = SoundCache.getSound(soundURL, audioOptions.isStereo); +var injector = null; +var count = 100; + +Script.update.connect(function() { + if (count > 0) { + count--; + return; + } + + if (sound.downloaded && injector === null) { + print("Sound downloaded."); + injector = Audio.playSound(sound, audioOptions); + print("Playing: " + injector); + } +}); + +Script.scriptEnding.connect(function() { + if (injector !== null) { + injector.stop(); + } +}); \ No newline at end of file diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 7cc7267f03..66b96cf132 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -2929,6 +2929,13 @@ void Application::displaySide(Camera& whichCamera, bool selfAvatarOnly, RenderAr if (whichCamera.getMode() == CAMERA_MODE_MIRROR) { viewTransform.setScale(Transform::Vec3(-1.0f, 1.0f, 1.0f)); } + if (renderSide != RenderArgs::MONO) { + glm::mat4 invView = glm::inverse(_untranslatedViewMatrix); + + viewTransform.evalFromRawMatrix(invView); + viewTransform.preTranslate(_viewMatrixTranslation); + } + setViewTransform(viewTransform); glTranslatef(_viewMatrixTranslation.x, _viewMatrixTranslation.y, _viewMatrixTranslation.z); diff --git a/interface/src/avatar/Avatar.cpp b/interface/src/avatar/Avatar.cpp index e29f68e585..5741d6b265 100644 --- a/interface/src/avatar/Avatar.cpp +++ b/interface/src/avatar/Avatar.cpp @@ -18,6 +18,7 @@ #include #include #include +#include #include #include @@ -664,8 +665,18 @@ void Avatar::renderDisplayName() { // we need "always facing camera": we must remove the camera rotation from the stack glm::quat rotation = Application::getInstance()->getCamera()->getRotation(); - glm::vec3 axis = glm::axis(rotation); - glRotatef(glm::degrees(glm::angle(rotation)), axis.x, axis.y, axis.z); + + glm::vec3 frontAxis(1.f, 0.f, 0.f); + frontAxis = glm::rotate(rotation, frontAxis); + frontAxis = glm::normalize(glm::vec3(frontAxis.x, 0.f, frontAxis.z)); + + // TODO : test this secodn solution which should be better wfor occulus + //glm::vec3 camPosition = Application::getInstance()->getCamera()->getPosition(); + //glm::vec3 frontAxis = camPosition - textPosition; + //frontAxis = glm::normalize(glm::vec3(frontAxis.z, 0.f, -frontAxis.x)); + + float angle = acos(frontAxis.x) * ((frontAxis.z < 0) ? 1.f : -1.f); + glRotatef(glm::degrees(angle), 0.0f, 1.0f, 0.0f); // We need to compute the scale factor such as the text remains with fixed size respect to window coordinates // We project a unit vector and check the difference in screen coordinates, to check which is the @@ -695,7 +706,8 @@ void Avatar::renderDisplayName() { if (success) { double textWindowHeight = abs(result1[1] - result0[1]); - float scaleFactor = Application::getInstance()->getRenderResolutionScale() * + float scaleFactor = Application::getInstance()->getRenderResolutionScale() * // Scale compensate for the resolution + QApplication::desktop()->windowHandle()->devicePixelRatio() * // And the device pixel ratio ((textWindowHeight > EPSILON) ? 1.0f / textWindowHeight : 1.0f); glScalef(scaleFactor, scaleFactor, 1.0); diff --git a/interface/src/devices/OculusManager.cpp b/interface/src/devices/OculusManager.cpp index 80ad9e5ef5..8d6d11dd68 100644 --- a/interface/src/devices/OculusManager.cpp +++ b/interface/src/devices/OculusManager.cpp @@ -524,13 +524,15 @@ void OculusManager::display(const glm::quat &bodyOrientation, const glm::vec3 &p glViewport(_eyeRenderViewport[eye].Pos.x, _eyeRenderViewport[eye].Pos.y, _eyeRenderViewport[eye].Size.w, _eyeRenderViewport[eye].Size.h); - // Apply the offset for the left or right eye on the projection matrix - glTranslatef(_eyeRenderDesc[eye].ViewAdjust.x, _eyeRenderDesc[eye].ViewAdjust.y, _eyeRenderDesc[eye].ViewAdjust.z); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); + + // HACK: instead of passing the stereo eye offset directly in the matrix, pass it in the camera offset + //glTranslatef(_eyeRenderDesc[eye].ViewAdjust.x, _eyeRenderDesc[eye].ViewAdjust.y, _eyeRenderDesc[eye].ViewAdjust.z); - Application::getInstance()->displaySide(*_camera, false, renderSide); + _camera->setEyeOffsetPosition(glm::vec3(-_eyeRenderDesc[eye].ViewAdjust.x, -_eyeRenderDesc[eye].ViewAdjust.y, -_eyeRenderDesc[eye].ViewAdjust.z)); + Application::getInstance()->displaySide(*_camera, false, RenderArgs::MONO); applicationOverlay.displayOverlayTextureOculus(*_camera); _activeEyeIndex = -1; diff --git a/interface/src/ui/TextRenderer.cpp b/interface/src/ui/TextRenderer.cpp index 65725ab4ec..395847f265 100644 --- a/interface/src/ui/TextRenderer.cpp +++ b/interface/src/ui/TextRenderer.cpp @@ -95,7 +95,7 @@ int TextRenderer::draw(int x, int y, const char* str, float alpha) { maxHeight = glyph.bounds().height(); } //glBindTexture(GL_TEXTURE_2D, glyph.textureID()); - + int left = x + glyph.bounds().x(); int right = x + glyph.bounds().x() + glyph.bounds().width(); int bottom = y + glyph.bounds().y(); diff --git a/interface/src/ui/ToolWindow.cpp b/interface/src/ui/ToolWindow.cpp index 44ea44c47d..de88d75b3d 100644 --- a/interface/src/ui/ToolWindow.cpp +++ b/interface/src/ui/ToolWindow.cpp @@ -17,6 +17,7 @@ const int DEFAULT_WIDTH = 300; ToolWindow::ToolWindow(QWidget* parent) : QMainWindow(parent), + _selfHidden(false), _hasShown(false), _lastGeometry() { diff --git a/libraries/shared/src/LogHandler.cpp b/libraries/shared/src/LogHandler.cpp index a13f3a9dad..4ed6666161 100644 --- a/libraries/shared/src/LogHandler.cpp +++ b/libraries/shared/src/LogHandler.cpp @@ -10,8 +10,6 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -#include - #ifdef _WIN32 #include #define getpid _getpid @@ -21,6 +19,7 @@ #include // for getpid() on linux #endif +#include #include #include @@ -38,6 +37,10 @@ LogHandler::LogHandler() : QTimer* logFlushTimer = new QTimer(this); connect(logFlushTimer, &QTimer::timeout, this, &LogHandler::flushRepeatedMessages); logFlushTimer->start(VERBOSE_LOG_INTERVAL_SECONDS * 1000); + + // when the log handler is first setup we should print our timezone + QString timezoneString = "Time zone: " + QDateTime::currentDateTime().toString("t"); + printf("%s\n", qPrintable(timezoneString)); } const char* stringForLogType(LogMsgType msgType) { @@ -57,8 +60,8 @@ const char* stringForLogType(LogMsgType msgType) { } } -// the following will produce 2000-10-02 13:55:36 -0700 -const char DATE_STRING_FORMAT[] = "%Y-%m-%d %H:%M:%S %z"; +// the following will produce 11/18 13:55:36 +const QString DATE_STRING_FORMAT = "MM/dd hh:mm:ss"; void LogHandler::flushRepeatedMessages() { QHash::iterator message = _repeatMessageCountHash.begin(); @@ -108,18 +111,11 @@ QString LogHandler::printMessage(LogMsgType type, const QMessageLogContext& cont } // log prefix is in the following format - // [DEBUG] [TIMESTAMP] [PID:PARENT_PID] [TARGET] logged string + // [DEBUG] [TIMESTAMP] [PID] [TARGET] logged string QString prefixString = QString("[%1]").arg(stringForLogType(type)); - time_t rawTime; - time(&rawTime); - struct tm* localTime = localtime(&rawTime); - - char dateString[100]; - strftime(dateString, sizeof(dateString), DATE_STRING_FORMAT, localTime); - - prefixString.append(QString(" [%1]").arg(dateString)); + prefixString.append(QString(" [%1]").arg(QDateTime::currentDateTime().toString(DATE_STRING_FORMAT))); if (_shouldOutputPID) { prefixString.append(QString(" [%1").arg(getpid()));