Beispiel #1
0
void injectorOptionsFromScriptValue(const QScriptValue& object, AudioInjectorOptions& injectorOptions) {
    if (object.property("position").isValid()) {
        vec3FromScriptValue(object.property("position"), injectorOptions.position);
    }

    if (object.property("volume").isValid()) {
        injectorOptions.volume = object.property("volume").toNumber();
    }

    if (object.property("loop").isValid()) {
        injectorOptions.loop = object.property("loop").toBool();
    }

    if (object.property("orientation").isValid()) {
        quatFromScriptValue(object.property("orientation"), injectorOptions.orientation);
    }

    if (object.property("ignorePenumbra").isValid()) {
        injectorOptions.ignorePenumbra = object.property("ignorePenumbra").toBool();
    }

    if (object.property("localOnly").isValid()) {
        injectorOptions.localOnly = object.property("localOnly").toBool();
    }

    if (object.property("secondOffset").isValid()) {
        injectorOptions.secondOffset = object.property("secondOffset").toNumber();
    }
}
Beispiel #2
0
void OverlayPanel::setProperties(const QScriptValue &properties) {
    PanelAttachable::setProperties(properties);
    Billboardable::setProperties(properties);

    QScriptValue anchorPosition = properties.property("anchorPosition");
    if (anchorPosition.isValid() &&
        anchorPosition.property("x").isValid() &&
        anchorPosition.property("y").isValid() &&
        anchorPosition.property("z").isValid()) {
        glm::vec3 newPosition;
        vec3FromScriptValue(anchorPosition, newPosition);
        setAnchorPosition(newPosition);
    }

    QScriptValue anchorPositionBinding = properties.property("anchorPositionBinding");
    if (anchorPositionBinding.isValid()) {
        PropertyBinding binding = {};
        propertyBindingFromScriptValue(anchorPositionBinding, binding);
        _anchorPositionBindMyAvatar = binding.avatar == "MyAvatar";
        _anchorPositionBindEntity = binding.entity;
    }

    QScriptValue anchorRotation = properties.property("anchorRotation");
    if (anchorRotation.isValid() &&
        anchorRotation.property("x").isValid() &&
        anchorRotation.property("y").isValid() &&
        anchorRotation.property("z").isValid() &&
        anchorRotation.property("w").isValid()) {
        glm::quat newRotation;
        quatFromScriptValue(anchorRotation, newRotation);
        setAnchorRotation(newRotation);
    }

    QScriptValue anchorRotationBinding = properties.property("anchorRotationBinding");
    if (anchorRotationBinding.isValid()) {
        PropertyBinding binding = {};
        propertyBindingFromScriptValue(anchorPositionBinding, binding);
        _anchorRotationBindMyAvatar = binding.avatar == "MyAvatar";
        _anchorRotationBindEntity = binding.entity;
    }

    QScriptValue anchorScale = properties.property("anchorScale");
    if (anchorScale.isValid()) {
        if (anchorScale.property("x").isValid() &&
            anchorScale.property("y").isValid() &&
            anchorScale.property("z").isValid()) {
            glm::vec3 newScale;
            vec3FromScriptValue(anchorScale, newScale);
            setAnchorScale(newScale);
        } else {
            setAnchorScale(anchorScale.toVariant().toFloat());
        }
    }

    QScriptValue visible = properties.property("visible");
    if (visible.isValid()) {
        setVisible(visible.toVariant().toBool());
    }
}
Beispiel #3
0
void qVectorQuatFromScriptValue(const QScriptValue& array, QVector<glm::quat>& vector ) {
    int length = array.property("length").toInteger();

    for (int i = 0; i < length; i++) {
        glm::quat newQuat = glm::quat();
        quatFromScriptValue(array.property(i), newQuat);
        vector << newQuat;
    }
}
Beispiel #4
0
QVector<glm::quat> qVectorQuatFromScriptValue(const QScriptValue& array) {
    QVector<glm::quat> newVector;
    int length = array.property("length").toInteger();

    for (int i = 0; i < length; i++) {
        glm::quat newQuat = glm::quat();
        quatFromScriptValue(array.property(i), newQuat);
        newVector << newQuat;
    }
    return newVector;
}
Beispiel #5
0
 void Pose::fromScriptValue(const QScriptValue& object, Pose& pose) {
     auto translation = object.property("translation");
     auto rotation = object.property("rotation");
     auto velocity = object.property("velocity");
     auto angularVelocity = object.property("angularVelocity");
     if (translation.isValid() &&
             rotation.isValid() &&
             velocity.isValid() &&
             angularVelocity.isValid()) {
         vec3FromScriptValue(translation, pose.translation);
         quatFromScriptValue(rotation, pose.rotation);
         vec3FromScriptValue(velocity, pose.velocity);
         vec3FromScriptValue(angularVelocity, pose.angularVelocity);
         pose.valid = true;
     } else {
         pose.valid = false;
     }
 }