mirror of
https://github.com/overte-org/overte.git
synced 2025-06-24 03:39:41 +02:00
Merge branch 'master' of https://github.com/highfidelity/hifi
This commit is contained in:
commit
52d0b15979
9 changed files with 75 additions and 18 deletions
50
examples/audioMuteExample.js
Normal file
50
examples/audioMuteExample.js
Normal file
|
@ -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);
|
|
@ -620,8 +620,8 @@ void Application::paintGL() {
|
||||||
|
|
||||||
} else if (_myCamera.getMode() == CAMERA_MODE_THIRD_PERSON) {
|
} else if (_myCamera.getMode() == CAMERA_MODE_THIRD_PERSON) {
|
||||||
static const float THIRD_PERSON_CAMERA_DISTANCE = 1.5f;
|
static const float THIRD_PERSON_CAMERA_DISTANCE = 1.5f;
|
||||||
_myCamera.setPosition(_myAvatar->getUprightHeadPosition() +
|
_myCamera.setPosition(_myAvatar->getDefaultEyePosition() +
|
||||||
_myAvatar->getOrientation() * glm::vec3(0.0f, 0.0f, 1.0f) * THIRD_PERSON_CAMERA_DISTANCE * _myAvatar->getScale());
|
_myAvatar->getOrientation() * glm::vec3(0.0f, 0.0f, 1.0f) * THIRD_PERSON_CAMERA_DISTANCE * _myAvatar->getScale());
|
||||||
if (OculusManager::isConnected()) {
|
if (OculusManager::isConnected()) {
|
||||||
_myCamera.setRotation(_myAvatar->getWorldAlignedOrientation());
|
_myCamera.setRotation(_myAvatar->getWorldAlignedOrientation());
|
||||||
} else {
|
} else {
|
||||||
|
@ -1980,6 +1980,9 @@ void Application::init() {
|
||||||
connect(getAudio(), &Audio::preProcessOriginalInboundAudio, &_audioReflector,
|
connect(getAudio(), &Audio::preProcessOriginalInboundAudio, &_audioReflector,
|
||||||
&AudioReflector::preProcessOriginalInboundAudio,Qt::DirectConnection);
|
&AudioReflector::preProcessOriginalInboundAudio,Qt::DirectConnection);
|
||||||
|
|
||||||
|
connect(getAudio(), &Audio::muteToggled, AudioDeviceScriptingInterface::getInstance(),
|
||||||
|
&AudioDeviceScriptingInterface::muteToggled, Qt::DirectConnection);
|
||||||
|
|
||||||
// save settings when avatar changes
|
// save settings when avatar changes
|
||||||
connect(_myAvatar, &MyAvatar::transformChanged, this, &Application::bumpSettings);
|
connect(_myAvatar, &MyAvatar::transformChanged, this, &Application::bumpSettings);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1057,10 +1057,6 @@ float Avatar::getPelvisFloatingHeight() const {
|
||||||
return -_skeletonModel.getBindExtents().minimum.y;
|
return -_skeletonModel.getBindExtents().minimum.y;
|
||||||
}
|
}
|
||||||
|
|
||||||
float Avatar::getPelvisToHeadLength() const {
|
|
||||||
return glm::distance(_position, getHead()->getPosition());
|
|
||||||
}
|
|
||||||
|
|
||||||
void Avatar::setShowDisplayName(bool showDisplayName) {
|
void Avatar::setShowDisplayName(bool showDisplayName) {
|
||||||
if (!Menu::getInstance()->isOptionChecked(MenuOption::NamesAboveHeads)) {
|
if (!Menu::getInstance()->isOptionChecked(MenuOption::NamesAboveHeads)) {
|
||||||
_displayNameAlpha = 0.0f;
|
_displayNameAlpha = 0.0f;
|
||||||
|
|
|
@ -230,7 +230,6 @@ protected:
|
||||||
float getSkeletonHeight() const;
|
float getSkeletonHeight() const;
|
||||||
float getHeadHeight() const;
|
float getHeadHeight() const;
|
||||||
float getPelvisFloatingHeight() const;
|
float getPelvisFloatingHeight() const;
|
||||||
float getPelvisToHeadLength() const;
|
|
||||||
glm::vec3 getDisplayNamePosition();
|
glm::vec3 getDisplayNamePosition();
|
||||||
|
|
||||||
void renderDisplayName();
|
void renderDisplayName();
|
||||||
|
|
|
@ -416,7 +416,7 @@ void MyAvatar::renderDebugBodyPoints() {
|
||||||
glPushMatrix();
|
glPushMatrix();
|
||||||
glColor4f(0, 1, 0, .5f);
|
glColor4f(0, 1, 0, .5f);
|
||||||
glTranslatef(position.x, position.y, position.z);
|
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();
|
glPopMatrix();
|
||||||
|
|
||||||
// Head Sphere
|
// Head Sphere
|
||||||
|
@ -424,7 +424,7 @@ void MyAvatar::renderDebugBodyPoints() {
|
||||||
glPushMatrix();
|
glPushMatrix();
|
||||||
glColor4f(0, 1, 0, .5f);
|
glColor4f(0, 1, 0, .5f);
|
||||||
glTranslatef(position.x, position.y, position.z);
|
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();
|
glPopMatrix();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1004,10 +1004,6 @@ bool MyAvatar::isLookingAtLeftEye() {
|
||||||
return _isLookingAtLeftEye;
|
return _isLookingAtLeftEye;
|
||||||
}
|
}
|
||||||
|
|
||||||
glm::vec3 MyAvatar::getUprightHeadPosition() const {
|
|
||||||
return _position + getWorldAlignedOrientation() * glm::vec3(0.0f, getPelvisToHeadLength(), 0.0f);
|
|
||||||
}
|
|
||||||
|
|
||||||
glm::vec3 MyAvatar::getDefaultEyePosition() const {
|
glm::vec3 MyAvatar::getDefaultEyePosition() const {
|
||||||
return _position + getWorldAlignedOrientation() * _skeletonModel.getDefaultEyeModelPosition();
|
return _position + getWorldAlignedOrientation() * _skeletonModel.getDefaultEyeModelPosition();
|
||||||
}
|
}
|
||||||
|
|
|
@ -66,7 +66,6 @@ public:
|
||||||
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; }
|
||||||
glm::vec3 getGravity() const { return _gravity; }
|
glm::vec3 getGravity() const { return _gravity; }
|
||||||
glm::vec3 getUprightHeadPosition() const;
|
|
||||||
glm::vec3 getDefaultEyePosition() const;
|
glm::vec3 getDefaultEyePosition() const;
|
||||||
bool getShouldRenderLocally() const { return _shouldRender; }
|
bool getShouldRenderLocally() const { return _shouldRender; }
|
||||||
|
|
||||||
|
|
|
@ -78,3 +78,11 @@ void AudioDeviceScriptingInterface::setReverb(bool reverb) {
|
||||||
void AudioDeviceScriptingInterface::setReverbOptions(const AudioEffectOptions* options) {
|
void AudioDeviceScriptingInterface::setReverbOptions(const AudioEffectOptions* options) {
|
||||||
Application::getInstance()->getAudio()->setReverbOptions(options);
|
Application::getInstance()->getAudio()->setReverbOptions(options);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AudioDeviceScriptingInterface::toggleMute() {
|
||||||
|
Application::getInstance()->getAudio()->toggleMute();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool AudioDeviceScriptingInterface::getMuted() {
|
||||||
|
return Application::getInstance()->getAudio()->getMuted();
|
||||||
|
}
|
||||||
|
|
|
@ -41,6 +41,12 @@ public slots:
|
||||||
void setInputVolume(float volume);
|
void setInputVolume(float volume);
|
||||||
void setReverb(bool reverb);
|
void setReverb(bool reverb);
|
||||||
void setReverbOptions(const AudioEffectOptions* options);
|
void setReverbOptions(const AudioEffectOptions* options);
|
||||||
|
|
||||||
|
bool getMuted();
|
||||||
|
void toggleMute();
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void muteToggled();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // hifi_AudioDeviceScriptingInterface_h
|
#endif // hifi_AudioDeviceScriptingInterface_h
|
||||||
|
|
|
@ -183,7 +183,7 @@ void ApplicationOverlay::computeOculusPickRay(float x, float y, glm::vec3& direc
|
||||||
float dist = sqrt(x * x + y * y);
|
float dist = sqrt(x * x + y * y);
|
||||||
float z = -sqrt(1.0f - dist * dist);
|
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));
|
glm::normalize(myAvatar->getOrientation() * glm::vec3(x, y, z));
|
||||||
|
|
||||||
//Rotate the UI pick ray by the avatar orientation
|
//Rotate the UI pick ray by the avatar orientation
|
||||||
|
@ -380,7 +380,7 @@ void ApplicationOverlay::displayOverlayTextureOculus(Camera& whichCamera) {
|
||||||
|
|
||||||
glPushMatrix();
|
glPushMatrix();
|
||||||
const glm::quat& orientation = myAvatar->getOrientation();
|
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);
|
glm::mat4 rotation = glm::toMat4(orientation);
|
||||||
|
|
||||||
|
@ -414,7 +414,7 @@ void ApplicationOverlay::displayOverlayTextureOculus(Camera& whichCamera) {
|
||||||
|
|
||||||
renderTexturedHemisphere();
|
renderTexturedHemisphere();
|
||||||
|
|
||||||
renderPointersOculus(myAvatar->getHead()->getEyePosition());
|
renderPointersOculus(myAvatar->getDefaultEyePosition());
|
||||||
|
|
||||||
glDepthMask(GL_TRUE);
|
glDepthMask(GL_TRUE);
|
||||||
glBindTexture(GL_TEXTURE_2D, 0);
|
glBindTexture(GL_TEXTURE_2D, 0);
|
||||||
|
@ -1220,7 +1220,7 @@ void ApplicationOverlay::renderTexturedHemisphere() {
|
||||||
Application* application = Application::getInstance();
|
Application* application = Application::getInstance();
|
||||||
MyAvatar* myAvatar = application->getAvatar();
|
MyAvatar* myAvatar = application->getAvatar();
|
||||||
const glm::quat& orientation = myAvatar->getOrientation();
|
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);
|
glm::mat4 rotation = glm::toMat4(orientation);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue