mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 18:13:05 +02:00
Merge branch 'master' of github.com:highfidelity/hifi into parents
This commit is contained in:
commit
3944d7be0f
7 changed files with 196 additions and 23 deletions
146
examples/toys/AC_scripts/toybox_sounds.js
Normal file
146
examples/toys/AC_scripts/toybox_sounds.js
Normal file
|
@ -0,0 +1,146 @@
|
||||||
|
//
|
||||||
|
// toys/AC_scripts/toybox_sounds.js
|
||||||
|
//
|
||||||
|
// This script adds several sounds to the correct locations for toybox.
|
||||||
|
// By James B. Pollack @imgntn 10/21/2015
|
||||||
|
//
|
||||||
|
// Distributed under the Apache License, Version 2.0.
|
||||||
|
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||||
|
//
|
||||||
|
|
||||||
|
var soundMap = [{
|
||||||
|
name: 'river water',
|
||||||
|
url: "http://hifi-public.s3.amazonaws.com/ryan/Water_Lap_River_Edge_Gentle.L.wav",
|
||||||
|
audioOptions: {
|
||||||
|
position: {
|
||||||
|
x: 580,
|
||||||
|
y: 493,
|
||||||
|
z: 528
|
||||||
|
},
|
||||||
|
volume: 0.4,
|
||||||
|
loop: true
|
||||||
|
}
|
||||||
|
}, {
|
||||||
|
name: 'windmill',
|
||||||
|
url: "http://hifi-public.s3.amazonaws.com/ryan/WINDMILL_Mono.wav",
|
||||||
|
audioOptions: {
|
||||||
|
position: {
|
||||||
|
x: 530,
|
||||||
|
y: 516,
|
||||||
|
z: 518
|
||||||
|
},
|
||||||
|
volume: 0.08,
|
||||||
|
loop: true
|
||||||
|
}
|
||||||
|
}, {
|
||||||
|
name: 'insects',
|
||||||
|
url: "http://hifi-public.s3.amazonaws.com/ryan/insects3.wav",
|
||||||
|
audioOptions: {
|
||||||
|
position: {
|
||||||
|
x: 560,
|
||||||
|
y: 495,
|
||||||
|
z: 474
|
||||||
|
},
|
||||||
|
volume: 0.25,
|
||||||
|
loop: true
|
||||||
|
}
|
||||||
|
}, {
|
||||||
|
name: 'fireplace',
|
||||||
|
url: "http://hifi-public.s3.amazonaws.com/ryan/demo/0619_Fireplace__Tree_B.L.wav",
|
||||||
|
audioOptions: {
|
||||||
|
position: {
|
||||||
|
x: 551.61,
|
||||||
|
y: 494.88,
|
||||||
|
z: 502.00
|
||||||
|
},
|
||||||
|
volume: 0.25,
|
||||||
|
loop: true
|
||||||
|
}
|
||||||
|
}, {
|
||||||
|
name: 'cat purring',
|
||||||
|
url: "http://hifi-public.s3.amazonaws.com/ryan/Cat_Purring_Deep_Low_Snor.wav",
|
||||||
|
audioOptions: {
|
||||||
|
position: {
|
||||||
|
x: 551.48,
|
||||||
|
y: 495.60,
|
||||||
|
z: 502.08
|
||||||
|
},
|
||||||
|
volume: 0.25,
|
||||||
|
loop: true
|
||||||
|
}
|
||||||
|
}, {
|
||||||
|
name: 'dogs barking',
|
||||||
|
url: "http://hifi-public.s3.amazonaws.com/ryan/dogs_barking_1.L.wav",
|
||||||
|
audioOptions: {
|
||||||
|
position: {
|
||||||
|
x: 551.61,
|
||||||
|
y: 494.88,
|
||||||
|
z: 502.00
|
||||||
|
},
|
||||||
|
volume: 0.15,
|
||||||
|
loop: false
|
||||||
|
},
|
||||||
|
playAtInterval: 60 * 1000
|
||||||
|
}];
|
||||||
|
|
||||||
|
function loadSounds() {
|
||||||
|
soundMap.forEach(function(soundData) {
|
||||||
|
soundData.sound = SoundCache.getSound(soundData.url);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function playSound(soundData) {
|
||||||
|
if (soundData.injector) {
|
||||||
|
// try/catch in case the injector QObject has been deleted already
|
||||||
|
try {
|
||||||
|
soundData.injector.stop();
|
||||||
|
} catch (e) {}
|
||||||
|
}
|
||||||
|
soundData.injector = Audio.playSound(soundData.sound, soundData.audioOptions);
|
||||||
|
}
|
||||||
|
|
||||||
|
function checkDownloaded(soundData) {
|
||||||
|
if (soundData.sound.downloaded) {
|
||||||
|
|
||||||
|
Script.clearInterval(soundData.downloadTimer);
|
||||||
|
|
||||||
|
if (soundData.hasOwnProperty('playAtInterval')) {
|
||||||
|
soundData.playingInterval = Script.setInterval(function() {
|
||||||
|
playSound(soundData)
|
||||||
|
}, soundData.playAtInterval);
|
||||||
|
} else {
|
||||||
|
playSound(soundData);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function startCheckDownloadedTimers() {
|
||||||
|
soundMap.forEach(function(soundData) {
|
||||||
|
soundData.downloadTimer = Script.setInterval(function() {
|
||||||
|
checkDownloaded(soundData);
|
||||||
|
}, 1000);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
Script.scriptEnding.connect(function() {
|
||||||
|
soundMap.forEach(function(soundData) {
|
||||||
|
|
||||||
|
if (soundData.hasOwnProperty("injector")) {
|
||||||
|
soundData.injector.stop();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (soundData.hasOwnProperty("downloadTimer")) {
|
||||||
|
Script.clearInterval(soundData.downloadTimer);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (soundData.hasOwnProperty("playingInterval")) {
|
||||||
|
Script.clearInterval(soundData.playingInterval);
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
loadSounds();
|
||||||
|
startCheckDownloadedTimers();
|
|
@ -245,6 +245,8 @@ QByteArray AvatarActionHold::serialize() const {
|
||||||
|
|
||||||
dataStream << _expires + getEntityServerClockSkew();
|
dataStream << _expires + getEntityServerClockSkew();
|
||||||
dataStream << _tag;
|
dataStream << _tag;
|
||||||
|
dataStream << _kinematic;
|
||||||
|
dataStream << _kinematicSetVelocity;
|
||||||
});
|
});
|
||||||
|
|
||||||
return serializedActionArguments;
|
return serializedActionArguments;
|
||||||
|
@ -278,6 +280,8 @@ void AvatarActionHold::deserialize(QByteArray serializedArguments) {
|
||||||
dataStream >> _expires;
|
dataStream >> _expires;
|
||||||
_expires -= getEntityServerClockSkew();
|
_expires -= getEntityServerClockSkew();
|
||||||
dataStream >> _tag;
|
dataStream >> _tag;
|
||||||
|
dataStream >> _kinematic;
|
||||||
|
dataStream >> _kinematicSetVelocity;
|
||||||
|
|
||||||
#if WANT_DEBUG
|
#if WANT_DEBUG
|
||||||
qDebug() << "deserialize AvatarActionHold: " << _holderID
|
qDebug() << "deserialize AvatarActionHold: " << _holderID
|
||||||
|
|
|
@ -21,8 +21,8 @@
|
||||||
// There is a minor performance gain when comparing/copying an existing glm::vec3 rather than
|
// There is a minor performance gain when comparing/copying an existing glm::vec3 rather than
|
||||||
// creating a new one on the stack so we declare the ZERO_VEC3 constant as an optimization.
|
// creating a new one on the stack so we declare the ZERO_VEC3 constant as an optimization.
|
||||||
const glm::vec3 ENTITY_ITEM_ZERO_VEC3 = glm::vec3(0.0f);
|
const glm::vec3 ENTITY_ITEM_ZERO_VEC3 = glm::vec3(0.0f);
|
||||||
const glm::vec3 ENTITY_ITEM_ONE_VEC3 = glm::vec3(1.0f, 1.0f, 1.0f);
|
const glm::vec3 ENTITY_ITEM_ONE_VEC3 = glm::vec3(1.0f);
|
||||||
const glm::vec3 ENTITY_ITEM_HALF_VEC3 = ENTITY_ITEM_ONE_VEC3 / 2.0f;
|
const glm::vec3 ENTITY_ITEM_HALF_VEC3 = glm::vec3(0.5f);
|
||||||
|
|
||||||
const bool ENTITY_ITEM_DEFAULT_LOCKED = false;
|
const bool ENTITY_ITEM_DEFAULT_LOCKED = false;
|
||||||
const QString ENTITY_ITEM_DEFAULT_USER_DATA = QString("");
|
const QString ENTITY_ITEM_DEFAULT_USER_DATA = QString("");
|
||||||
|
|
|
@ -648,7 +648,6 @@ EntityItemPointer EntityTreeElement::getClosestEntity(glm::vec3 position) const
|
||||||
|
|
||||||
// TODO: change this to use better bounding shape for entity than sphere
|
// TODO: change this to use better bounding shape for entity than sphere
|
||||||
void EntityTreeElement::getEntities(const glm::vec3& searchPosition, float searchRadius, QVector<EntityItemPointer>& foundEntities) const {
|
void EntityTreeElement::getEntities(const glm::vec3& searchPosition, float searchRadius, QVector<EntityItemPointer>& foundEntities) const {
|
||||||
float compareRadius = searchRadius * searchRadius;
|
|
||||||
forEachEntity([&](EntityItemPointer entity) {
|
forEachEntity([&](EntityItemPointer entity) {
|
||||||
|
|
||||||
AABox entityBox = entity->getAABox();
|
AABox entityBox = entity->getAABox();
|
||||||
|
@ -657,10 +656,25 @@ void EntityTreeElement::getEntities(const glm::vec3& searchPosition, float searc
|
||||||
glm::vec3 penetration;
|
glm::vec3 penetration;
|
||||||
if (entityBox.findSpherePenetration(searchPosition, searchRadius, penetration)) {
|
if (entityBox.findSpherePenetration(searchPosition, searchRadius, penetration)) {
|
||||||
|
|
||||||
// FIXME - handle entity->getShapeType() == SHAPE_TYPE_SPHERE case better
|
glm::vec3 dimensions = entity->getDimensions();
|
||||||
|
|
||||||
// FIXME - consider allowing the entity to determine penetration so that
|
// FIXME - consider allowing the entity to determine penetration so that
|
||||||
// entities could presumably dull actuall hull testing if they wanted to
|
// entities could presumably dull actuall hull testing if they wanted to
|
||||||
|
// FIXME - handle entity->getShapeType() == SHAPE_TYPE_SPHERE case better in particular
|
||||||
|
// can we handle the ellipsoid case better? We only currently handle perfect spheres
|
||||||
|
// with centered registration points
|
||||||
|
if (entity->getShapeType() == SHAPE_TYPE_SPHERE &&
|
||||||
|
(dimensions.x == dimensions.y && dimensions.y == dimensions.z)) {
|
||||||
|
|
||||||
|
// NOTE: entity->getRadius() doesn't return the true radius, it returns the radius of the
|
||||||
|
// maximum bounding sphere, which is actually larger than our actual radius
|
||||||
|
float entityTrueRadius = dimensions.x / 2.0f;
|
||||||
|
|
||||||
|
if (findSphereSpherePenetration(searchPosition, searchRadius,
|
||||||
|
entity->getCenterPosition(), entityTrueRadius, penetration)) {
|
||||||
|
foundEntities.push_back(entity);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
// determine the worldToEntityMatrix that doesn't include scale because
|
// determine the worldToEntityMatrix that doesn't include scale because
|
||||||
// we're going to use the registration aware aa box in the entity frame
|
// we're going to use the registration aware aa box in the entity frame
|
||||||
glm::mat4 rotation = glm::mat4_cast(entity->getRotation());
|
glm::mat4 rotation = glm::mat4_cast(entity->getRotation());
|
||||||
|
@ -668,7 +682,6 @@ void EntityTreeElement::getEntities(const glm::vec3& searchPosition, float searc
|
||||||
glm::mat4 entityToWorldMatrix = translation * rotation;
|
glm::mat4 entityToWorldMatrix = translation * rotation;
|
||||||
glm::mat4 worldToEntityMatrix = glm::inverse(entityToWorldMatrix);
|
glm::mat4 worldToEntityMatrix = glm::inverse(entityToWorldMatrix);
|
||||||
|
|
||||||
glm::vec3 dimensions = entity->getDimensions();
|
|
||||||
glm::vec3 registrationPoint = entity->getRegistrationPoint();
|
glm::vec3 registrationPoint = entity->getRegistrationPoint();
|
||||||
glm::vec3 corner = -(dimensions * registrationPoint);
|
glm::vec3 corner = -(dimensions * registrationPoint);
|
||||||
|
|
||||||
|
@ -679,6 +692,7 @@ void EntityTreeElement::getEntities(const glm::vec3& searchPosition, float searc
|
||||||
foundEntities.push_back(entity);
|
foundEntities.push_back(entity);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -54,7 +54,6 @@
|
||||||
|
|
||||||
MasterReset = function() {
|
MasterReset = function() {
|
||||||
var resetKey = "resetMe";
|
var resetKey = "resetMe";
|
||||||
var GRABBABLE_DATA_KEY = "grabbableKey";
|
|
||||||
|
|
||||||
var HIFI_PUBLIC_BUCKET = "http://s3.amazonaws.com/hifi-public/";
|
var HIFI_PUBLIC_BUCKET = "http://s3.amazonaws.com/hifi-public/";
|
||||||
|
|
||||||
|
@ -97,8 +96,6 @@
|
||||||
z: 505.78
|
z: 505.78
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
createCombinedArmChair({
|
createCombinedArmChair({
|
||||||
x: 549.29,
|
x: 549.29,
|
||||||
y: 494.9,
|
y: 494.9,
|
||||||
|
@ -487,7 +484,6 @@
|
||||||
grabbableKey: {
|
grabbableKey: {
|
||||||
invertSolidWhileHeld: true
|
invertSolidWhileHeld: true
|
||||||
}
|
}
|
||||||
|
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -533,6 +529,9 @@
|
||||||
resetMe: true,
|
resetMe: true,
|
||||||
on: true,
|
on: true,
|
||||||
type: "Hall Light"
|
type: "Hall Light"
|
||||||
|
},
|
||||||
|
grabbableKey: {
|
||||||
|
wantsTrigger: true
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
|
@ -628,6 +627,9 @@
|
||||||
resetMe: true,
|
resetMe: true,
|
||||||
on: true,
|
on: true,
|
||||||
type: "Garage Light"
|
type: "Garage Light"
|
||||||
|
},
|
||||||
|
grabbableKey: {
|
||||||
|
wantsTrigger: true
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
|
@ -759,6 +761,7 @@
|
||||||
grabbableKey: {
|
grabbableKey: {
|
||||||
invertSolidWhileHeld: true
|
invertSolidWhileHeld: true
|
||||||
}
|
}
|
||||||
|
|
||||||
})
|
})
|
||||||
};
|
};
|
||||||
var dice1 = Entities.addEntity(diceProps);
|
var dice1 = Entities.addEntity(diceProps);
|
||||||
|
@ -851,6 +854,7 @@
|
||||||
grabbableKey: {
|
grabbableKey: {
|
||||||
invertSolidWhileHeld: true
|
invertSolidWhileHeld: true
|
||||||
}
|
}
|
||||||
|
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -1176,7 +1180,7 @@
|
||||||
y: 0.05,
|
y: 0.05,
|
||||||
z: 0.25
|
z: 0.25
|
||||||
}
|
}
|
||||||
} ];
|
}];
|
||||||
|
|
||||||
var modelURL, entity;
|
var modelURL, entity;
|
||||||
for (i = 0; i < blockTypes.length; i++) {
|
for (i = 0; i < blockTypes.length; i++) {
|
||||||
|
|
|
@ -27,7 +27,6 @@ var targetsScriptURL = Script.resolvePath('../examples/toys/ping_pong_gun/wallTa
|
||||||
|
|
||||||
MasterReset = function() {
|
MasterReset = function() {
|
||||||
var resetKey = "resetMe";
|
var resetKey = "resetMe";
|
||||||
var GRABBABLE_DATA_KEY = "grabbableKey";
|
|
||||||
|
|
||||||
var HIFI_PUBLIC_BUCKET = "http://s3.amazonaws.com/hifi-public/";
|
var HIFI_PUBLIC_BUCKET = "http://s3.amazonaws.com/hifi-public/";
|
||||||
|
|
||||||
|
@ -505,6 +504,9 @@ MasterReset = function() {
|
||||||
resetMe: true,
|
resetMe: true,
|
||||||
on: true,
|
on: true,
|
||||||
type: "Hall Light"
|
type: "Hall Light"
|
||||||
|
},
|
||||||
|
grabbableKey: {
|
||||||
|
wantsTrigger: true
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
|
@ -600,6 +602,9 @@ MasterReset = function() {
|
||||||
resetMe: true,
|
resetMe: true,
|
||||||
on: true,
|
on: true,
|
||||||
type: "Garage Light"
|
type: "Garage Light"
|
||||||
|
},
|
||||||
|
grabbableKey: {
|
||||||
|
wantsTrigger: true
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue