mirror of
https://github.com/overte-org/overte.git
synced 2025-08-08 04:57:23 +02:00
Provide the option to avoid making duplicate attachments.
This commit is contained in:
parent
f866828db2
commit
c02b708ee5
4 changed files with 35 additions and 6 deletions
|
@ -39,6 +39,8 @@ var impactSound = new Sound("https://s3-us-west-1.amazonaws.com/highfidelity-pub
|
||||||
var targetHitSound = new Sound("http://highfidelity-public.s3-us-west-1.amazonaws.com/sounds/Space%20Invaders/hit.raw");
|
var targetHitSound = new Sound("http://highfidelity-public.s3-us-west-1.amazonaws.com/sounds/Space%20Invaders/hit.raw");
|
||||||
var targetLaunchSound = new Sound("http://highfidelity-public.s3-us-west-1.amazonaws.com/sounds/Space%20Invaders/shoot.raw");
|
var targetLaunchSound = new Sound("http://highfidelity-public.s3-us-west-1.amazonaws.com/sounds/Space%20Invaders/shoot.raw");
|
||||||
|
|
||||||
|
var gunModel = "http://highfidelity-public.s3-us-west-1.amazonaws.com/models/attachments/Raygun2.fst";
|
||||||
|
|
||||||
var audioOptions = new AudioInjectionOptions();
|
var audioOptions = new AudioInjectionOptions();
|
||||||
audioOptions.volume = 0.9;
|
audioOptions.volume = 0.9;
|
||||||
|
|
||||||
|
@ -190,6 +192,8 @@ function keyPressEvent(event) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MyAvatar.attach(gunModel, "RightHand", {x: -0.10, y: 0.0, z: 0.0}, Quat.fromPitchYawRollDegrees(-90, 180, 0), 0.14);
|
||||||
|
|
||||||
function update(deltaTime) {
|
function update(deltaTime) {
|
||||||
// Check for mouseLook movement, update rotation
|
// Check for mouseLook movement, update rotation
|
||||||
// rotate body yaw for yaw received from mouse
|
// rotate body yaw for yaw received from mouse
|
||||||
|
@ -304,6 +308,7 @@ function mouseMoveEvent(event) {
|
||||||
function scriptEnding() {
|
function scriptEnding() {
|
||||||
Overlays.deleteOverlay(reticle);
|
Overlays.deleteOverlay(reticle);
|
||||||
Overlays.deleteOverlay(text);
|
Overlays.deleteOverlay(text);
|
||||||
|
MyAvatar.detachOne(gunModel);
|
||||||
}
|
}
|
||||||
|
|
||||||
Particles.particleCollisionWithVoxel.connect(particleCollisionWithVoxel);
|
Particles.particleCollisionWithVoxel.connect(particleCollisionWithVoxel);
|
||||||
|
|
|
@ -709,7 +709,9 @@ void Avatar::setSkeletonModelURL(const QUrl& skeletonModelURL) {
|
||||||
|
|
||||||
void Avatar::setAttachmentData(const QVector<AttachmentData>& attachmentData) {
|
void Avatar::setAttachmentData(const QVector<AttachmentData>& attachmentData) {
|
||||||
AvatarData::setAttachmentData(attachmentData);
|
AvatarData::setAttachmentData(attachmentData);
|
||||||
|
if (QThread::currentThread() != thread()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
// make sure we have as many models as attachments
|
// make sure we have as many models as attachments
|
||||||
while (_attachmentModels.size() < attachmentData.size()) {
|
while (_attachmentModels.size() < attachmentData.size()) {
|
||||||
Model* model = new Model(this);
|
Model* model = new Model(this);
|
||||||
|
|
|
@ -685,9 +685,22 @@ void AvatarData::setAttachmentData(const QVector<AttachmentData>& attachmentData
|
||||||
_attachmentData = attachmentData;
|
_attachmentData = attachmentData;
|
||||||
}
|
}
|
||||||
|
|
||||||
void AvatarData::attach(const QString& modelURL, const QString& jointName,
|
void AvatarData::attach(const QString& modelURL, const QString& jointName, const glm::vec3& translation,
|
||||||
const glm::vec3& translation, const glm::quat& rotation, float scale) {
|
const glm::quat& rotation, float scale, bool allowDuplicates) {
|
||||||
|
if (QThread::currentThread() != thread()) {
|
||||||
|
QMetaObject::invokeMethod(this, "attach", Q_ARG(const QString&, modelURL), Q_ARG(const QString&, jointName),
|
||||||
|
Q_ARG(const glm::vec3&, translation), Q_ARG(const glm::quat&, rotation),
|
||||||
|
Q_ARG(float, scale), Q_ARG(bool, allowDuplicates));
|
||||||
|
return;
|
||||||
|
}
|
||||||
QVector<AttachmentData> attachmentData = getAttachmentData();
|
QVector<AttachmentData> attachmentData = getAttachmentData();
|
||||||
|
if (!allowDuplicates) {
|
||||||
|
foreach (const AttachmentData& data, attachmentData) {
|
||||||
|
if (data.modelURL == modelURL && (jointName.isEmpty() || data.jointName == jointName)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
AttachmentData data;
|
AttachmentData data;
|
||||||
data.modelURL = modelURL;
|
data.modelURL = modelURL;
|
||||||
data.jointName = jointName;
|
data.jointName = jointName;
|
||||||
|
@ -699,17 +712,25 @@ void AvatarData::attach(const QString& modelURL, const QString& jointName,
|
||||||
}
|
}
|
||||||
|
|
||||||
void AvatarData::detachOne(const QString& modelURL, const QString& jointName) {
|
void AvatarData::detachOne(const QString& modelURL, const QString& jointName) {
|
||||||
|
if (QThread::currentThread() != thread()) {
|
||||||
|
QMetaObject::invokeMethod(this, "detachOne", Q_ARG(const QString&, modelURL), Q_ARG(const QString&, jointName));
|
||||||
|
return;
|
||||||
|
}
|
||||||
QVector<AttachmentData> attachmentData = getAttachmentData();
|
QVector<AttachmentData> attachmentData = getAttachmentData();
|
||||||
for (QVector<AttachmentData>::iterator it = attachmentData.begin(); it != attachmentData.end(); it++) {
|
for (QVector<AttachmentData>::iterator it = attachmentData.begin(); it != attachmentData.end(); it++) {
|
||||||
if (it->modelURL == modelURL && (jointName.isEmpty() || it->jointName == jointName)) {
|
if (it->modelURL == modelURL && (jointName.isEmpty() || it->jointName == jointName)) {
|
||||||
attachmentData.erase(it);
|
attachmentData.erase(it);
|
||||||
|
setAttachmentData(attachmentData);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
setAttachmentData(attachmentData);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void AvatarData::detachAll(const QString& modelURL, const QString& jointName) {
|
void AvatarData::detachAll(const QString& modelURL, const QString& jointName) {
|
||||||
|
if (QThread::currentThread() != thread()) {
|
||||||
|
QMetaObject::invokeMethod(this, "detachAll", Q_ARG(const QString&, modelURL), Q_ARG(const QString&, jointName));
|
||||||
|
return;
|
||||||
|
}
|
||||||
QVector<AttachmentData> attachmentData = getAttachmentData();
|
QVector<AttachmentData> attachmentData = getAttachmentData();
|
||||||
for (QVector<AttachmentData>::iterator it = attachmentData.begin(); it != attachmentData.end(); ) {
|
for (QVector<AttachmentData>::iterator it = attachmentData.begin(); it != attachmentData.end(); ) {
|
||||||
if (it->modelURL == modelURL && (jointName.isEmpty() || it->jointName == jointName)) {
|
if (it->modelURL == modelURL && (jointName.isEmpty() || it->jointName == jointName)) {
|
||||||
|
|
|
@ -241,7 +241,8 @@ public:
|
||||||
Q_INVOKABLE virtual void setAttachmentData(const QVector<AttachmentData>& attachmentData);
|
Q_INVOKABLE virtual void setAttachmentData(const QVector<AttachmentData>& attachmentData);
|
||||||
|
|
||||||
Q_INVOKABLE virtual void attach(const QString& modelURL, const QString& jointName = QString(),
|
Q_INVOKABLE virtual void attach(const QString& modelURL, const QString& jointName = QString(),
|
||||||
const glm::vec3& translation = glm::vec3(), const glm::quat& rotation = glm::quat(), float scale = 1.0f);
|
const glm::vec3& translation = glm::vec3(), const glm::quat& rotation = glm::quat(), float scale = 1.0f,
|
||||||
|
bool allowDuplicates = false);
|
||||||
|
|
||||||
Q_INVOKABLE void detachOne(const QString& modelURL, const QString& jointName = QString());
|
Q_INVOKABLE void detachOne(const QString& modelURL, const QString& jointName = QString());
|
||||||
Q_INVOKABLE void detachAll(const QString& modelURL, const QString& jointName = QString());
|
Q_INVOKABLE void detachAll(const QString& modelURL, const QString& jointName = QString());
|
||||||
|
|
Loading…
Reference in a new issue