From 16f4cffbd3c2d9d187ccf2cfbad1b171a60c28a0 Mon Sep 17 00:00:00 2001 From: David Rowe Date: Fri, 31 Oct 2014 12:19:26 -0700 Subject: [PATCH 1/6] Center HMD HUD and magnifiers on default eye position --- interface/src/ui/ApplicationOverlay.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/interface/src/ui/ApplicationOverlay.cpp b/interface/src/ui/ApplicationOverlay.cpp index d8d2213d8f..37bba98ecc 100644 --- a/interface/src/ui/ApplicationOverlay.cpp +++ b/interface/src/ui/ApplicationOverlay.cpp @@ -380,7 +380,7 @@ void ApplicationOverlay::displayOverlayTextureOculus(Camera& whichCamera) { glPushMatrix(); const glm::quat& orientation = myAvatar->getOrientation(); - const glm::vec3& position = myAvatar->getHead()->getEyePosition(); + const glm::vec3& position = myAvatar->getDefaultEyePosition(); glm::mat4 rotation = glm::toMat4(orientation); @@ -414,7 +414,7 @@ void ApplicationOverlay::displayOverlayTextureOculus(Camera& whichCamera) { renderTexturedHemisphere(); - renderPointersOculus(myAvatar->getHead()->getEyePosition()); + renderPointersOculus(myAvatar->getDefaultEyePosition()); glDepthMask(GL_TRUE); glBindTexture(GL_TEXTURE_2D, 0); @@ -1220,7 +1220,7 @@ void ApplicationOverlay::renderTexturedHemisphere() { Application* application = Application::getInstance(); MyAvatar* myAvatar = application->getAvatar(); const glm::quat& orientation = myAvatar->getOrientation(); - const glm::vec3& position = myAvatar->getHead()->getEyePosition(); + const glm::vec3& position = myAvatar->getDefaultEyePosition(); glm::mat4 rotation = glm::toMat4(orientation); From 170e328f5a496145afecba3ba0d0f0e50ac3c02a Mon Sep 17 00:00:00 2001 From: David Rowe Date: Fri, 31 Oct 2014 12:40:16 -0700 Subject: [PATCH 2/6] Fix similar problem for HMD third person view getUprightHeadPosition() changes with avatar lean. --- interface/src/Application.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 0752f9fa9e..1ec8078f53 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -620,8 +620,8 @@ void Application::paintGL() { } else if (_myCamera.getMode() == CAMERA_MODE_THIRD_PERSON) { static const float THIRD_PERSON_CAMERA_DISTANCE = 1.5f; - _myCamera.setPosition(_myAvatar->getUprightHeadPosition() + - _myAvatar->getOrientation() * glm::vec3(0.0f, 0.0f, 1.0f) * THIRD_PERSON_CAMERA_DISTANCE * _myAvatar->getScale()); + _myCamera.setPosition(_myAvatar->getDefaultEyePosition() + + _myAvatar->getOrientation() * glm::vec3(0.0f, 0.0f, 1.0f) * THIRD_PERSON_CAMERA_DISTANCE * _myAvatar->getScale()); if (OculusManager::isConnected()) { _myCamera.setRotation(_myAvatar->getWorldAlignedOrientation()); } else { From 8e58e6e3b00321a59ce2ecd56830d63f1aff9e1d Mon Sep 17 00:00:00 2001 From: David Rowe Date: Fri, 31 Oct 2014 12:48:30 -0700 Subject: [PATCH 3/6] Remove unused methods --- interface/src/avatar/Avatar.cpp | 4 ---- interface/src/avatar/Avatar.h | 1 - interface/src/avatar/MyAvatar.cpp | 4 ---- interface/src/avatar/MyAvatar.h | 1 - 4 files changed, 10 deletions(-) diff --git a/interface/src/avatar/Avatar.cpp b/interface/src/avatar/Avatar.cpp index 59c8c90d1c..e29f68e585 100644 --- a/interface/src/avatar/Avatar.cpp +++ b/interface/src/avatar/Avatar.cpp @@ -1057,10 +1057,6 @@ float Avatar::getPelvisFloatingHeight() const { return -_skeletonModel.getBindExtents().minimum.y; } -float Avatar::getPelvisToHeadLength() const { - return glm::distance(_position, getHead()->getPosition()); -} - void Avatar::setShowDisplayName(bool showDisplayName) { if (!Menu::getInstance()->isOptionChecked(MenuOption::NamesAboveHeads)) { _displayNameAlpha = 0.0f; diff --git a/interface/src/avatar/Avatar.h b/interface/src/avatar/Avatar.h index 29fb4cf241..376e229d0c 100644 --- a/interface/src/avatar/Avatar.h +++ b/interface/src/avatar/Avatar.h @@ -230,7 +230,6 @@ protected: float getSkeletonHeight() const; float getHeadHeight() const; float getPelvisFloatingHeight() const; - float getPelvisToHeadLength() const; glm::vec3 getDisplayNamePosition(); void renderDisplayName(); diff --git a/interface/src/avatar/MyAvatar.cpp b/interface/src/avatar/MyAvatar.cpp index 623631d5e5..2f7a123e4b 100644 --- a/interface/src/avatar/MyAvatar.cpp +++ b/interface/src/avatar/MyAvatar.cpp @@ -1004,10 +1004,6 @@ bool MyAvatar::isLookingAtLeftEye() { return _isLookingAtLeftEye; } -glm::vec3 MyAvatar::getUprightHeadPosition() const { - return _position + getWorldAlignedOrientation() * glm::vec3(0.0f, getPelvisToHeadLength(), 0.0f); -} - glm::vec3 MyAvatar::getDefaultEyePosition() const { return _position + getWorldAlignedOrientation() * _skeletonModel.getDefaultEyeModelPosition(); } diff --git a/interface/src/avatar/MyAvatar.h b/interface/src/avatar/MyAvatar.h index aa3d569e2f..326e0e2665 100644 --- a/interface/src/avatar/MyAvatar.h +++ b/interface/src/avatar/MyAvatar.h @@ -66,7 +66,6 @@ public: const glm::vec3& getMouseRayOrigin() const { return _mouseRayOrigin; } const glm::vec3& getMouseRayDirection() const { return _mouseRayDirection; } glm::vec3 getGravity() const { return _gravity; } - glm::vec3 getUprightHeadPosition() const; glm::vec3 getDefaultEyePosition() const; bool getShouldRenderLocally() const { return _shouldRender; } From 02f9bb489f47e54e15c8d76e63aaf553a2492b0c Mon Sep 17 00:00:00 2001 From: David Rowe Date: Fri, 31 Oct 2014 12:49:21 -0700 Subject: [PATCH 4/6] Fix some build warnings while in the vicinity --- interface/src/avatar/MyAvatar.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/interface/src/avatar/MyAvatar.cpp b/interface/src/avatar/MyAvatar.cpp index 2f7a123e4b..79ab9eda81 100644 --- a/interface/src/avatar/MyAvatar.cpp +++ b/interface/src/avatar/MyAvatar.cpp @@ -416,7 +416,7 @@ void MyAvatar::renderDebugBodyPoints() { glPushMatrix(); glColor4f(0, 1, 0, .5f); glTranslatef(position.x, position.y, position.z); - Application::getInstance()->getGeometryCache()->renderSphere(0.2, 10, 10); + Application::getInstance()->getGeometryCache()->renderSphere(0.2f, 10.0f, 10.0f); glPopMatrix(); // Head Sphere @@ -424,7 +424,7 @@ void MyAvatar::renderDebugBodyPoints() { glPushMatrix(); glColor4f(0, 1, 0, .5f); glTranslatef(position.x, position.y, position.z); - Application::getInstance()->getGeometryCache()->renderSphere(0.15, 10, 10); + Application::getInstance()->getGeometryCache()->renderSphere(0.15f, 10.0f, 10.0f); glPopMatrix(); } From a9040c1a53170b580dccb6f3aedc84eb811a6582 Mon Sep 17 00:00:00 2001 From: David Rowe Date: Fri, 31 Oct 2014 15:15:44 -0700 Subject: [PATCH 5/6] Minor adjustment to Oculus pick ray calc --- interface/src/ui/ApplicationOverlay.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/interface/src/ui/ApplicationOverlay.cpp b/interface/src/ui/ApplicationOverlay.cpp index 37bba98ecc..4d2c710be7 100644 --- a/interface/src/ui/ApplicationOverlay.cpp +++ b/interface/src/ui/ApplicationOverlay.cpp @@ -183,7 +183,7 @@ void ApplicationOverlay::computeOculusPickRay(float x, float y, glm::vec3& direc float dist = sqrt(x * x + y * y); float z = -sqrt(1.0f - dist * dist); - glm::vec3 relativePosition = myAvatar->getHead()->getEyePosition() + + glm::vec3 relativePosition = myAvatar->getDefaultEyePosition() + glm::normalize(myAvatar->getOrientation() * glm::vec3(x, y, z)); //Rotate the UI pick ray by the avatar orientation From af74fc09b946a8c449fcb1a53b9ba9884813d96b Mon Sep 17 00:00:00 2001 From: Thijs Wenker Date: Sat, 1 Nov 2014 02:42:22 +0100 Subject: [PATCH 6/6] Adds AudioDevice mute functionality to ScriptEngine --- examples/audioMuteExample.js | 50 +++++++++++++++++++ interface/src/Application.cpp | 3 ++ .../AudioDeviceScriptingInterface.cpp | 8 +++ .../scripting/AudioDeviceScriptingInterface.h | 6 +++ 4 files changed, 67 insertions(+) create mode 100644 examples/audioMuteExample.js diff --git a/examples/audioMuteExample.js b/examples/audioMuteExample.js new file mode 100644 index 0000000000..efdd39e5aa --- /dev/null +++ b/examples/audioMuteExample.js @@ -0,0 +1,50 @@ +// +// audioMuteExample.js +// examples +// +// Created by Thijs Wenker on 10/31/14. +// Copyright 2014 High Fidelity, Inc. +// +// This example shows how to use the AudioDevice mute functions. +// Press the MUTE/UNMUTE button to see it function. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html +// + +var toggleMuteButton = Overlays.addOverlay("text", { + x: 50, + y: 50, + width: 190, + height: 50, + backgroundColor: { red: 255, green: 255, blue: 255}, + color: { red: 255, green: 0, blue: 0}, + font: {size: 30}, + topMargin: 10 +}); + +function muteButtonText() { + print("Audio Muted: " + AudioDevice.getMuted()); +} + +function onMuteStateChanged() { + Overlays.editOverlay(toggleMuteButton, + AudioDevice.getMuted() ? {text: "UNMUTE", leftMargin: 10} : {text: "MUTE", leftMargin: 38}); + print("Audio Muted: " + AudioDevice.getMuted()); +} + +function mousePressEvent(event) { + if (Overlays.getOverlayAtPoint({x: event.x, y: event.y}) == toggleMuteButton) { + AudioDevice.toggleMute() + } +} + +function scriptEnding() { + Overlays.deleteOverlay(toggleMuteButton); +} + +onMuteStateChanged(); + +AudioDevice.muteToggled.connect(onMuteStateChanged); +Controller.mousePressEvent.connect(mousePressEvent); +Script.scriptEnding.connect(scriptEnding); \ No newline at end of file diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 0752f9fa9e..1a293628b7 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -1966,6 +1966,9 @@ void Application::init() { connect(getAudio(), &Audio::preProcessOriginalInboundAudio, &_audioReflector, &AudioReflector::preProcessOriginalInboundAudio,Qt::DirectConnection); + connect(getAudio(), &Audio::muteToggled, AudioDeviceScriptingInterface::getInstance(), + &AudioDeviceScriptingInterface::muteToggled, Qt::DirectConnection); + // save settings when avatar changes connect(_myAvatar, &MyAvatar::transformChanged, this, &Application::bumpSettings); } diff --git a/interface/src/scripting/AudioDeviceScriptingInterface.cpp b/interface/src/scripting/AudioDeviceScriptingInterface.cpp index bcb5fc308d..e3826a24ea 100644 --- a/interface/src/scripting/AudioDeviceScriptingInterface.cpp +++ b/interface/src/scripting/AudioDeviceScriptingInterface.cpp @@ -78,3 +78,11 @@ void AudioDeviceScriptingInterface::setReverb(bool reverb) { void AudioDeviceScriptingInterface::setReverbOptions(const AudioEffectOptions* options) { Application::getInstance()->getAudio()->setReverbOptions(options); } + +void AudioDeviceScriptingInterface::toggleMute() { + Application::getInstance()->getAudio()->toggleMute(); +} + +bool AudioDeviceScriptingInterface::getMuted() { + return Application::getInstance()->getAudio()->getMuted(); +} diff --git a/interface/src/scripting/AudioDeviceScriptingInterface.h b/interface/src/scripting/AudioDeviceScriptingInterface.h index 45bdbc92e2..b7febaea07 100644 --- a/interface/src/scripting/AudioDeviceScriptingInterface.h +++ b/interface/src/scripting/AudioDeviceScriptingInterface.h @@ -41,6 +41,12 @@ public slots: void setInputVolume(float volume); void setReverb(bool reverb); void setReverbOptions(const AudioEffectOptions* options); + + bool getMuted(); + void toggleMute(); + +signals: + void muteToggled(); }; #endif // hifi_AudioDeviceScriptingInterface_h