Beispiel #1
0
void TextureImage::sceneChangeEvent(const Qt3DCore::QSceneChangePtr &e)
{
    QScenePropertyChangePtr propertyChange = qSharedPointerCast<QScenePropertyChange>(e);

    if (e->type() == NodeUpdated) {
        if (propertyChange->propertyName() == QByteArrayLiteral("layer")) {
            m_layer = propertyChange->value().toInt();
            m_dirty = true;
        } else if (propertyChange->propertyName() == QByteArrayLiteral("mipmapLevel")) {
            m_mipmapLevel = propertyChange->value().toInt();
            m_dirty = true;
        } else if (propertyChange->propertyName() == QByteArrayLiteral("cubeMapFace")) {
            m_face = static_cast<QAbstractTextureProvider::CubeMapFace>(propertyChange->value().toInt());
            m_dirty = true;
        } else if (propertyChange->propertyName() == QByteArrayLiteral("dataFunctor")) {
            m_functor = propertyChange->value().value<QTextureDataFunctorPtr>();
            m_dirty = true;
        }
    }
    if (m_dirty) {// Notify the Texture that we were updated and request it to schedule an update job
        Texture *txt = m_textureManager->data(m_textureProvider);
        if (txt != Q_NULLPTR)
            txt->addToPendingTextureJobs();
    }
}
void RenderMaterial::sceneChangeEvent(const QSceneChangePtr &e)
{
    QScenePropertyChangePtr propertyChange = qSharedPointerCast<QScenePropertyChange>(e);

    switch (e->type()) {
    case NodeUpdated: {
        if (propertyChange->propertyName() == QByteArrayLiteral("enabled"))
            m_enabled = propertyChange->value().toBool();
        break;
    }
        // Check for shader parameter
    case NodeAdded: {
        if (propertyChange->propertyName() == QByteArrayLiteral("parameter"))
            m_parameterPack.appendParameter(propertyChange->value().value<QNodeId>());
        else if (propertyChange->propertyName() == QByteArrayLiteral("effect"))
            m_effectUuid = propertyChange->value().value<QNodeId>();
        break;
    }
    case NodeRemoved: {
        if (propertyChange->propertyName() == QByteArrayLiteral("parameter"))
            m_parameterPack.removeParameter(propertyChange->value().value<QNodeId>());
        else if (propertyChange->propertyName() == QByteArrayLiteral("effect"))
            m_effectUuid = QNodeId();
        break;
    }

    default:
        break;
    }
}
Beispiel #3
0
void ClearBuffer::sceneChangeEvent(const QSceneChangePtr &e)
{
    if (e->type() == NodeUpdated) {
        QScenePropertyChangePtr propertyChange = qSharedPointerCast<QScenePropertyChange>(e);
        if (propertyChange->propertyName() == QByteArrayLiteral("buffers"))
            m_type = static_cast<QClearBuffer::BufferType>(propertyChange->value().toInt());
        else if (propertyChange->propertyName() == QByteArrayLiteral("enabled"))
            setEnabled(propertyChange->value().toBool());
    }
}
Beispiel #4
0
void Parameter::sceneChangeEvent(const Qt3DCore::QSceneChangePtr &e)
{
    QScenePropertyChangePtr propertyChange = qSharedPointerCast<QScenePropertyChange>(e);

    if (e->type() == NodeUpdated) {
        if (propertyChange->propertyName() == QByteArrayLiteral("name"))
            m_name = propertyChange->value().toString();
        else if (propertyChange->propertyName() == QByteArrayLiteral("value"))
            m_value = toBackendValue(propertyChange->value());
    }
}
Beispiel #5
0
void SortMethod::sceneChangeEvent(const QSceneChangePtr &e)
{
    QScenePropertyChangePtr propertyChange = qSharedPointerCast<QScenePropertyChange>(e);
    if (propertyChange->propertyName() == QByteArrayLiteral("sortCriterion")) {
        QSortCriterion *c = propertyChange->value().value<QSortCriterion *>();
        if (c != Q_NULLPTR) {
            if (e->type() == NodeAdded)
                m_criteria.append(c->id());
            else if (e->type() == NodeRemoved)
                m_criteria.removeAll(c->id());
        }
    } else if (propertyChange->propertyName() == QByteArrayLiteral("enabled") && e->type() == NodeUpdated) {
        setEnabled(propertyChange->value().toBool());
    }
}
Beispiel #6
0
void RenderScene::sceneChangeEvent(const QSceneChangePtr &e)
{
    QScenePropertyChangePtr propertyChange = qSharedPointerCast<QScenePropertyChange>(e);
    if (propertyChange->propertyName() == QByteArrayLiteral("source")) {
        m_source = propertyChange->value().toUrl();
        m_sceneManager->addSceneData(m_source, peerUuid());
    }
}
Beispiel #7
0
void RenderCameraLens::sceneChangeEvent(const QSceneChangePtr &e)
{
    switch (e->type()) {
    case NodeUpdated: {
        QScenePropertyChangePtr propertyChange = qSharedPointerCast<QScenePropertyChange>(e);

        if (propertyChange->propertyName() == QByteArrayLiteral("projectionMatrix")) {
            QMatrix4x4 projectionMatrix = propertyChange->value().value<QMatrix4x4>();
            m_projection = projectionMatrix;
        } else if (propertyChange->propertyName() == QByteArrayLiteral("enabled")) {
            m_enabled = propertyChange->value().toBool();
        }
    }
        break;

    default:
        break;
    }
}
Beispiel #8
0
void MouseInput::sceneChangeEvent(const Qt3DCore::QSceneChangePtr &e)
{
    if (e->type() == NodeUpdated) {
        QScenePropertyChangePtr propertyChange = qSharedPointerCast<QScenePropertyChange>(e);
        if (propertyChange->propertyName() == QByteArrayLiteral("controller")) {
            const QNodeId newId = propertyChange->value().value<QNodeId>();
            if (m_mouseController != newId) {
                setController(newId);
            }
        }
    }
}
Beispiel #9
0
void StateSetNode::sceneChangeEvent(const QSceneChangePtr &e)
{
    QScenePropertyChangePtr propertyChange = qSharedPointerCast<QScenePropertyChange>(e);
    switch (e->type()) {
    case NodeAdded: {
        if (propertyChange->propertyName() == QByteArrayLiteral("renderState")) {
            QNodePtr nodePtr = propertyChange->value().value<QNodePtr>();
            QRenderState *renderState = static_cast<QRenderState *>(nodePtr.data());
            appendRenderState(renderState->id(), RenderState::getOrCreateBackendState(renderState));
        }
    }
        break;

    case NodeRemoved: {
        if (propertyChange->propertyName() == QByteArrayLiteral("renderState"))
            removeRenderState(propertyChange->value().value<QNodeId>());
    }
        break;

    default:
        break;
    }
}
Beispiel #10
0
void Geometry::sceneChangeEvent(const Qt3DCore::QSceneChangePtr &e)
{
    QScenePropertyChangePtr propertyChange = qSharedPointerCast<QScenePropertyChange>(e);
    QByteArray propertyName = propertyChange->propertyName();

    switch (e->type()) {
    case NodeAdded: {
        if (propertyName == QByteArrayLiteral("attribute")) {
            m_attributes.push_back(propertyChange->value().value<QNodeId>());
            m_geometryDirty = true;
        }
        break;
    }

    case NodeRemoved: {
        if (propertyName == QByteArrayLiteral("attribute")) {
            m_attributes.removeOne(propertyChange->value().value<QNodeId>());
            m_geometryDirty = true;
        }
        break;
    }

    case NodeUpdated:
        if (propertyName == QByteArrayLiteral("verticesPerPatch")) {
            m_verticesPerPatch = propertyChange->value().value<int>();
            break;

            // Note: doesn't set dirtyness as this parameter changing doesn't need
            // a new VAO update.
        } else if (propertyName == QByteArrayLiteral("boundingVolumeSpecifierPositionAttribute")) {
            m_boundingPositionAttribute = propertyChange->value().value<Qt3DCore::QNodeId>();
            break;
        }

    default:
        break;
    }
}