void RayToEntityIntersectionResultFromScriptValue(const QScriptValue& object, RayToEntityIntersectionResult& value) {
    value.intersects = object.property("intersects").toVariant().toBool();
    value.accurate = object.property("accurate").toVariant().toBool();
    QScriptValue entityIDValue = object.property("entityID");
    // EntityItemIDfromScriptValue(entityIDValue, value.entityID);
    quuidFromScriptValue(entityIDValue, value.entityID);
    QScriptValue entityPropertiesValue = object.property("properties");
    if (entityPropertiesValue.isValid()) {
        EntityItemPropertiesFromScriptValueHonorReadOnly(entityPropertiesValue, value.properties);
    }
    value.distance = object.property("distance").toVariant().toFloat();

    QString faceName = object.property("face").toVariant().toString();
    if (faceName == "MIN_X_FACE") {
        value.face = MIN_X_FACE;
    } else if (faceName == "MAX_X_FACE") {
        value.face = MAX_X_FACE;
    } else if (faceName == "MIN_Y_FACE") {
        value.face = MIN_Y_FACE;
    } else if (faceName == "MAX_Y_FACE") {
        value.face = MAX_Y_FACE;
    } else if (faceName == "MIN_Z_FACE") {
        value.face = MIN_Z_FACE;
    } else {
        value.face = MAX_Z_FACE;
    };
    QScriptValue intersection = object.property("intersection");
    if (intersection.isValid()) {
        vec3FromScriptValue(intersection, value.intersection);
    }
    QScriptValue surfaceNormal = object.property("surfaceNormal");
    if (surfaceNormal.isValid()) {
        vec3FromScriptValue(surfaceNormal, value.surfaceNormal);
    }
}
Beispiel #2
0
void PointerEvent::fromScriptValue(const QScriptValue& object, PointerEvent& event) {
    if (object.isObject()) {
        QScriptValue type = object.property("type");
        QString typeStr = type.isString() ? type.toString() : "Move";
        if (typeStr == "Press") {
            event._type = Press;
        } else if (typeStr == "DoublePress") {
            event._type = DoublePress;
        } else if (typeStr == "Release") {
            event._type = Release;
        } else {
            event._type = Move;
        }

        QScriptValue id = object.property("id");
        event._id = id.isNumber() ? (uint32_t)id.toNumber() : 0;

        glm::vec2 pos2D;
        vec2FromScriptValue(object.property("pos2D"), event._pos2D);

        glm::vec3 pos3D;
        vec3FromScriptValue(object.property("pos3D"), event._pos3D);

        glm::vec3 normal;
        vec3FromScriptValue(object.property("normal"), event._normal);

        glm::vec3 direction;
        vec3FromScriptValue(object.property("direction"), event._direction);

        QScriptValue button = object.property("button");
        QString buttonStr = type.isString() ? button.toString() : "NoButtons";

        if (buttonStr == "Primary") {
            event._button = PrimaryButton;
        } else if (buttonStr == "Secondary") {
            event._button = SecondaryButton;
        } else if (buttonStr == "Tertiary") {
            event._button = TertiaryButton;
        } else {
            event._button = NoButtons;
        }

        bool primary = object.property("isPrimaryHeld").toBool();
        bool secondary = object.property("isSecondaryHeld").toBool();
        bool tertiary = object.property("isTertiaryHeld").toBool();
        event._buttons = 0;
        if (primary) {
            event._buttons |= PrimaryButton;
        }
        if (secondary) {
            event._buttons |= SecondaryButton;
        }
        if (tertiary) {
            event._buttons |= TertiaryButton;
        }

        event._keyboardModifiers = (Qt::KeyboardModifiers)(object.property("keyboardModifiers").toUInt32());
    }
}
Beispiel #3
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 #4
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 #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;
     }
 }
Beispiel #6
0
void qVectorVec3FromScriptValue(const QScriptValue& array, QVector<glm::vec3>& vector ) {
    int length = array.property("length").toInteger();

    for (int i = 0; i < length; i++) {
        glm::vec3 newVec3 = glm::vec3();
        vec3FromScriptValue(array.property(i), newVec3);
        vector << newVec3;
    }
}
Beispiel #7
0
QVector<glm::vec3> qVectorVec3FromScriptValue(const QScriptValue& array) {
    QVector<glm::vec3> newVector;
    int length = array.property("length").toInteger();

    for (int i = 0; i < length; i++) {
        glm::vec3 newVec3 = glm::vec3();
        vec3FromScriptValue(array.property(i), newVec3);
        newVector << newVec3;
    }
    return newVector;
}
Beispiel #8
0
static void localLightFromScriptValue(const QScriptValue& value, AvatarManager::LocalLight& light) {
    vec3FromScriptValue(value.property("direction"), light.direction);
    vec3FromScriptValue(value.property("color"), light.color);
}