diff --git a/examples/lobby.js b/examples/lobby.js index e34d119502..15a8aca328 100644 --- a/examples/lobby.js +++ b/examples/lobby.js @@ -138,11 +138,13 @@ function drawLobby() { // add an attachment on this avatar so other people see them in the lobby MyAvatar.attach(HELMET_ATTACHMENT_URL, "Neck", {x: 0, y: 0, z: 0}, Quat.fromPitchYawRollDegrees(0, 0, 0), 1.15); - // start the drone sound - // currentDrone = Audio.playSound(droneSound, { stereo: true, loop: true, localOnly: true, volume: DRONE_VOLUME }); + if (droneSound.downloaded) { + // start the drone sound + currentDrone = Audio.playSound(droneSound, { stereo: true, loop: true, localOnly: true, volume: DRONE_VOLUME }); + } // start one of our muzak sounds - // playRandomMuzak(); + playRandomMuzak(); } } @@ -353,9 +355,9 @@ function update(deltaTime) { Overlays.editOverlay(descriptionText, { position: textOverlayPosition() }); // if the reticle is up then we may need to play the next muzak - // if (!Audio.isInjectorPlaying(currentMuzakInjector)) { -// playNextMuzak(); -// } + if (currentMuzakInjector && !Audio.isInjectorPlaying(currentMuzakInjector)) { + playNextMuzak(); + } } } diff --git a/interface/src/Audio.cpp b/interface/src/Audio.cpp index bd106d9bc6..844386c9e5 100644 --- a/interface/src/Audio.cpp +++ b/interface/src/Audio.cpp @@ -880,7 +880,7 @@ bool Audio::outputLocalInjector(bool isStereo, qreal volume, AudioInjector* inje localFormat.setChannelCount(isStereo ? 2 : 1); QAudioOutput* localOutput = new QAudioOutput(getNamedAudioDeviceForMode(QAudio::AudioOutput, _outputAudioDeviceName), - localFormat, this); + localFormat); localOutput->setVolume(volume); // move the localOutput to the same thread as the local injector buffer diff --git a/interface/src/ui/ApplicationOverlay.cpp b/interface/src/ui/ApplicationOverlay.cpp index 1d710f29d4..106c74cdeb 100644 --- a/interface/src/ui/ApplicationOverlay.cpp +++ b/interface/src/ui/ApplicationOverlay.cpp @@ -197,19 +197,23 @@ void ApplicationOverlay::renderOverlay(bool renderToTexture) { const float FAR_CLIP = 10000; glLoadIdentity(); glOrtho(0, glCanvas->width(), glCanvas->height(), 0, NEAR_CLIP, FAR_CLIP); - + + glMatrixMode(GL_MODELVIEW); + renderAudioMeter(); - + renderStatsAndLogs(); - + // give external parties a change to hook in emit application->renderingOverlay(); - + overlays.renderHUD(); - + renderPointers(); - + renderDomainConnectionStatusBorder(); + + glMatrixMode(GL_PROJECTION); } glPopMatrix(); glMatrixMode(GL_MODELVIEW); diff --git a/libraries/audio/src/AudioScriptingInterface.cpp b/libraries/audio/src/AudioScriptingInterface.cpp index 8cd133ad40..120c7a6b5a 100644 --- a/libraries/audio/src/AudioScriptingInterface.cpp +++ b/libraries/audio/src/AudioScriptingInterface.cpp @@ -13,7 +13,8 @@ void registerAudioMetaTypes(QScriptEngine* engine) { qScriptRegisterMetaType(engine, injectorOptionsToScriptValue, injectorOptionsFromScriptValue); - qScriptRegisterMetaType(engine, soundToScriptValue, soundFromScriptValue); + qScriptRegisterMetaType(engine, soundSharedPointerToScriptValue, soundSharedPointerFromScriptValue); + qScriptRegisterMetaType(engine, soundPointerToScriptValue, soundPointerFromScriptValue); } AudioScriptingInterface& AudioScriptingInterface::getInstance() { diff --git a/libraries/audio/src/Sound.cpp b/libraries/audio/src/Sound.cpp index 54ff61d66a..cc41a849e7 100644 --- a/libraries/audio/src/Sound.cpp +++ b/libraries/audio/src/Sound.cpp @@ -29,13 +29,22 @@ #include "AudioEditBuffer.h" #include "Sound.h" -QScriptValue soundToScriptValue(QScriptEngine* engine, SharedSoundPointer const& in) { +static int soundMetaTypeId = qRegisterMetaType(); + +QScriptValue soundSharedPointerToScriptValue(QScriptEngine* engine, SharedSoundPointer const& in) { return engine->newQObject(in.data()); } -void soundFromScriptValue(const QScriptValue &object, SharedSoundPointer &out) { +void soundSharedPointerFromScriptValue(const QScriptValue& object, SharedSoundPointer &out) { out = SharedSoundPointer(qobject_cast(object.toQObject())); - qDebug() << "Sound from script value" << out.data(); +} + +QScriptValue soundPointerToScriptValue(QScriptEngine* engine, Sound* const& in) { + return engine->newQObject(in); +} + +void soundPointerFromScriptValue(const QScriptValue &object, Sound* &out) { + out = qobject_cast(object.toQObject()); } Sound::Sound(const QUrl& url, bool isStereo) : diff --git a/libraries/audio/src/Sound.h b/libraries/audio/src/Sound.h index 02b75417e8..9aa92feea1 100644 --- a/libraries/audio/src/Sound.h +++ b/libraries/audio/src/Sound.h @@ -45,8 +45,12 @@ private: typedef QSharedPointer SharedSoundPointer; Q_DECLARE_METATYPE(SharedSoundPointer) +QScriptValue soundSharedPointerToScriptValue(QScriptEngine* engine, SharedSoundPointer const& in); +void soundSharedPointerFromScriptValue(const QScriptValue& object, SharedSoundPointer &out); + +Q_DECLARE_METATYPE(Sound*) +QScriptValue soundPointerToScriptValue(QScriptEngine* engine, Sound* const& in); +void soundPointerFromScriptValue(const QScriptValue& object, Sound* &out); -QScriptValue soundToScriptValue(QScriptEngine* engine, SharedSoundPointer const& in); -void soundFromScriptValue(const QScriptValue& object, SharedSoundPointer& out); #endif // hifi_Sound_h diff --git a/libraries/entities/src/EntityTreeElement.cpp b/libraries/entities/src/EntityTreeElement.cpp index 4ced5fe844..aff6e64f57 100644 --- a/libraries/entities/src/EntityTreeElement.cpp +++ b/libraries/entities/src/EntityTreeElement.cpp @@ -665,7 +665,7 @@ const EntityItem* EntityTreeElement::getEntityWithEntityItemID(const EntityItemI } return foundEntity; } - + EntityItem* EntityTreeElement::getEntityWithEntityItemID(const EntityItemID& id) { EntityItem* foundEntity = NULL; uint16_t numberOfEntities = _entityItems->size(); diff --git a/libraries/fbx/src/FBXReader.cpp b/libraries/fbx/src/FBXReader.cpp index 9532f44acf..8363084d37 100644 --- a/libraries/fbx/src/FBXReader.cpp +++ b/libraries/fbx/src/FBXReader.cpp @@ -38,7 +38,7 @@ struct TextureParam { glm::vec2 UVTranslation; glm::vec2 UVScaling; glm::vec4 cropping; - std::string UVSet; + QString UVSet; glm::vec3 translation; glm::vec3 rotation; @@ -802,14 +802,14 @@ public: QVector > blendshapeIndexMaps; QVector > partMaterialTextures; QHash texcoordSetMap; - std::map texcoordSetMap2; + std::map texcoordSetMap2; }; class AttributeData { public: QVector texCoords; QVector texCoordIndices; - std::string name; + QString name; int index; }; @@ -945,12 +945,12 @@ ExtractedMesh extractMesh(const FBXNode& object) { data.texCoordIndices = getIntVector(subdata); attrib.texCoordIndices = getIntVector(subdata); } else if (subdata.name == "Name") { - attrib.name = subdata.properties.at(0).toString().toStdString(); + attrib.name = subdata.properties.at(0).toString(); } #if defined(DEBUG_FBXREADER) else { int unknown = 0; - std::string subname = subdata.name.data(); + QString subname = subdata.name.data(); if ( (subdata.name == "Version") || (subdata.name == "MappingInformationType") || (subdata.name == "ReferenceInformationType") ) { @@ -960,7 +960,7 @@ ExtractedMesh extractMesh(const FBXNode& object) { } #endif } - data.extracted.texcoordSetMap.insert(QString(attrib.name.c_str()), data.attributes.size()); + data.extracted.texcoordSetMap.insert(attrib.name, data.attributes.size()); data.attributes.push_back(attrib); } else { AttributeData attrib; @@ -971,12 +971,12 @@ ExtractedMesh extractMesh(const FBXNode& object) { } else if (subdata.name == "UVIndex") { attrib.texCoordIndices = getIntVector(subdata); } else if (subdata.name == "Name") { - attrib.name = subdata.properties.at(0).toString().toStdString(); + attrib.name = subdata.properties.at(0).toString(); } #if defined(DEBUG_FBXREADER) else { int unknown = 0; - std::string subname = subdata.name.data(); + QString subname = subdata.name.data(); if ( (subdata.name == "Version") || (subdata.name == "MappingInformationType") || (subdata.name == "ReferenceInformationType") ) { @@ -987,9 +987,9 @@ ExtractedMesh extractMesh(const FBXNode& object) { #endif } - QHash::iterator it = data.extracted.texcoordSetMap.find(QString(attrib.name.c_str())); + QHash::iterator it = data.extracted.texcoordSetMap.find(attrib.name); if (it == data.extracted.texcoordSetMap.end()) { - data.extracted.texcoordSetMap.insert(QString(attrib.name.c_str()), data.attributes.size()); + data.extracted.texcoordSetMap.insert(attrib.name, data.attributes.size()); data.attributes.push_back(attrib); } else { // WTF same names for different UVs? @@ -1198,11 +1198,11 @@ bool checkMaterialsHaveTextures(const QHash& materials, return false; } -int matchTextureUVSetToAttributeChannel(const std::string& texUVSetName, const QHash& texcoordChannels) { - if (texUVSetName.empty()) { +int matchTextureUVSetToAttributeChannel(const QString& texUVSetName, const QHash& texcoordChannels) { + if (texUVSetName.isEmpty()) { return 0; } else { - QHash::const_iterator tcUnit = texcoordChannels.find(QString(texUVSetName.c_str())); + QHash::const_iterator tcUnit = texcoordChannels.find(texUVSetName); if (tcUnit != texcoordChannels.end()) { int channel = (*tcUnit); if (channel >= 2) { @@ -1220,13 +1220,13 @@ FBXLight extractLight(const FBXNode& object) { FBXLight light; foreach (const FBXNode& subobject, object.children) { - std::string childname = QString(subobject.name).toStdString(); + QString childname = QString(subobject.name); if (subobject.name == "Properties70") { foreach (const FBXNode& property, subobject.children) { int valIndex = 4; - std::string propName = QString(property.name).toStdString(); + QString propName = QString(property.name); if (property.name == "P") { - std::string propname = property.properties.at(0).toString().toStdString(); + QString propname = property.properties.at(0).toString(); if (propname == "Intensity") { light.intensity = 0.01f * property.properties.at(valIndex).value(); } @@ -1238,13 +1238,13 @@ FBXLight extractLight(const FBXNode& object) { } #if defined(DEBUG_FBXREADER) - std::string type = object.properties.at(0).toString().toStdString(); - type = object.properties.at(1).toString().toStdString(); - type = object.properties.at(2).toString().toStdString(); + QString type = object.properties.at(0).toString(); + type = object.properties.at(1).toString(); + type = object.properties.at(2).toString(); foreach (const QVariant& prop, object.properties) { - std::string proptype = prop.typeName(); - std::string propval = prop.toString().toStdString(); + QString proptype = prop.typeName(); + QString propval = prop.toString(); if (proptype == "Properties70") { } } @@ -1281,7 +1281,7 @@ FBXGeometry extractFBXGeometry(const FBXNode& node, const QVariantHash& mapping, QHash yComponents; QHash zComponents; - std::map lights; + std::map lights; QVariantHash joints = mapping.value("joint").toHash(); QString jointEyeLeftName = processID(getString(joints.value("jointEyeLeft", "jointEyeLeft"))); @@ -1369,7 +1369,7 @@ FBXGeometry extractFBXGeometry(const FBXNode& node, const QVariantHash& mapping, int index = 4; foreach (const FBXNode& subobject, object.children) { if (subobject.name == propertyName) { - std::string subpropName = subobject.properties.at(0).toString().toStdString(); + QString subpropName = subobject.properties.at(0).toString(); if (subpropName == "UnitScaleFactor") { unitScaleFactor = subobject.properties.at(index).toFloat(); } else if (subpropName == "AmbientColor") { @@ -1393,8 +1393,8 @@ FBXGeometry extractFBXGeometry(const FBXNode& node, const QVariantHash& mapping, QString id = getID(object.properties); modelIDsToNames.insert(id, name); - std::string modelname = name.toLower().toStdString(); - if (modelname.find("hifi") == 0) { + QString modelname = name.toLower(); + if (modelname.startsWith("hifi")) { hifiGlobalNodeID = id; } @@ -1527,19 +1527,19 @@ FBXGeometry extractFBXGeometry(const FBXNode& node, const QVariantHash& mapping, } #if defined(DEBUG_FBXREADER) else if (subobject.name == "TypeFlags") { - std::string attributetype = subobject.properties.at(0).toString().toStdString(); + QString attributetype = subobject.properties.at(0).toString(); if (!attributetype.empty()) { if (attributetype == "Light") { - std::string lightprop; + QString lightprop; foreach (const QVariant& vprop, subobject.properties) { - lightprop = vprop.toString().toStdString(); + lightprop = vprop.toString(); } FBXLight light = extractLight(object); } } } else { - std::string whatisthat = subobject.name; + QString whatisthat = subobject.name; if (whatisthat == "Shape") { } } @@ -1604,7 +1604,7 @@ FBXGeometry extractFBXGeometry(const FBXNode& node, const QVariantHash& mapping, if (property.name == propertyName) { QString v = property.properties.at(0).toString(); if (property.properties.at(0) == "UVSet") { - tex.assign(tex.UVSet, property.properties.at(index).toString().toStdString()); + tex.assign(tex.UVSet, property.properties.at(index).toString()); } else if (property.properties.at(0) == "CurrentTextureBlendMode") { tex.assign(tex.currentTextureBlendMode, property.properties.at(index).value()); } else if (property.properties.at(0) == "UseMaterial") { @@ -1618,7 +1618,7 @@ FBXGeometry extractFBXGeometry(const FBXNode& node, const QVariantHash& mapping, } #if defined(DEBUG_FBXREADER) else { - std::string propName = v.toStdString(); + QString propName = v; unknown++; } #endif @@ -1632,7 +1632,7 @@ FBXGeometry extractFBXGeometry(const FBXNode& node, const QVariantHash& mapping, } else if (subobject.name == "FileName") { } else if (subobject.name == "Media") { } else { - std::string subname = subobject.name.data(); + QString subname = subobject.name.data(); unknown++; } } @@ -1693,7 +1693,7 @@ FBXGeometry extractFBXGeometry(const FBXNode& node, const QVariantHash& mapping, } #if defined(DEBUG_FBXREADER) else { - const std::string propname = property.properties.at(0).toString().toStdString(); + const QString propname = property.properties.at(0).toString(); if (propname == "EmissiveFactor") { } } @@ -1703,7 +1703,7 @@ FBXGeometry extractFBXGeometry(const FBXNode& node, const QVariantHash& mapping, } #if defined(DEBUG_FBXREADER) else { - std::string propname = subobject.name.data(); + QString propname = subobject.name.data(); int unknown = 0; if ( (propname == "Version") ||(propname == "ShadingModel") @@ -1719,21 +1719,21 @@ FBXGeometry extractFBXGeometry(const FBXNode& node, const QVariantHash& mapping, } else if (object.name == "NodeAttribute") { #if defined(DEBUG_FBXREADER) - std::vector properties; + std::vector properties; foreach(const QVariant& v, object.properties) { - properties.push_back(v.toString().toStdString()); + properties.push_back(v.toString()); } #endif - std::string attribID = getID(object.properties).toStdString(); - std::string attributetype; + QString attribID = getID(object.properties); + QString attributetype; foreach (const FBXNode& subobject, object.children) { if (subobject.name == "TypeFlags") { typeFlags.insert(getID(object.properties), subobject.properties.at(0).toString()); - attributetype = subobject.properties.at(0).toString().toStdString(); + attributetype = subobject.properties.at(0).toString(); } } - if (!attributetype.empty()) { + if (!attributetype.isEmpty()) { if (attributetype == "Light") { FBXLight light = extractLight(object); lights[attribID] = light; @@ -1781,7 +1781,7 @@ FBXGeometry extractFBXGeometry(const FBXNode& node, const QVariantHash& mapping, } #if defined(DEBUG_FBXREADER) else { - std::string objectname = object.name.data(); + QString objectname = object.name.data(); if ( objectname == "Pose" || objectname == "AnimationStack" || objectname == "AnimationLayer" @@ -1800,7 +1800,7 @@ FBXGeometry extractFBXGeometry(const FBXNode& node, const QVariantHash& mapping, QString parentID = getID(connection.properties, 2); ooChildToParent.insert(childID, parentID); if (!hifiGlobalNodeID.isEmpty() && (parentID == hifiGlobalNodeID)) { - std::map< std::string, FBXLight >::iterator lit = lights.find(childID.toStdString()); + std::map< QString, FBXLight >::iterator lit = lights.find(childID); if (lit != lights.end()) { lightmapLevel = (*lit).second.intensity; if (lightmapLevel <= 0.0f) { @@ -1842,7 +1842,7 @@ FBXGeometry extractFBXGeometry(const FBXNode& node, const QVariantHash& mapping, } else if (loadLightmaps && type.contains("ambient")) { ambientTextures.insert(getID(connection.properties, 2), getID(connection.properties, 1)); } else { - std::string typenam = type.data(); + QString typenam = type.data(); counter++; } } @@ -1853,7 +1853,7 @@ FBXGeometry extractFBXGeometry(const FBXNode& node, const QVariantHash& mapping, } #if defined(DEBUG_FBXREADER) else { - std::string objectname = child.name.data(); + QString objectname = child.name.data(); if ( objectname == "Pose" || objectname == "CreationTime" || objectname == "FileId" @@ -1875,7 +1875,7 @@ FBXGeometry extractFBXGeometry(const FBXNode& node, const QVariantHash& mapping, // TODO: check if is code is needed if (!lights.empty()) { if (hifiGlobalNodeID.isEmpty()) { - std::map< std::string, FBXLight >::iterator l = lights.begin(); + std::map< QString, FBXLight >::iterator l = lights.begin(); lightmapLevel = (*l).second.intensity; } } diff --git a/libraries/fbx/src/FBXReader.h b/libraries/fbx/src/FBXReader.h index 44b2bfe4a5..98e4d60826 100644 --- a/libraries/fbx/src/FBXReader.h +++ b/libraries/fbx/src/FBXReader.h @@ -110,7 +110,7 @@ public: Transform transform; int texcoordSet; - std::string texcoordSetName; + QString texcoordSetName; }; /// A single part of a mesh (with the same material). diff --git a/libraries/render-utils/src/GeometryCache.cpp b/libraries/render-utils/src/GeometryCache.cpp index 25f988472f..cfb11fd9f0 100644 --- a/libraries/render-utils/src/GeometryCache.cpp +++ b/libraries/render-utils/src/GeometryCache.cpp @@ -1873,9 +1873,9 @@ void GeometryReader::run() { if (!_reply) { throw QString("Reply is NULL ?!"); } - std::string urlname = _url.path().toLower().toStdString(); + QString urlname = _url.path().toLower(); bool urlValid = true; - urlValid &= !urlname.empty(); + urlValid &= !urlname.isEmpty(); urlValid &= !_url.path().isEmpty(); urlValid &= _url.path().toLower().endsWith(".fbx") || _url.path().toLower().endsWith(".svo");