diff --git a/examples/quick3d/blendmodes/BackgroundView.qml b/examples/quick3d/blendmodes/BackgroundView.qml index 38da1332028aa583bb271cac1dcf2c8b6494d1b5..1ebb34d4b69ace1f69fa3814aa4e51e7127c38cd 100644 --- a/examples/quick3d/blendmodes/BackgroundView.qml +++ b/examples/quick3d/blendmodes/BackgroundView.qml @@ -48,19 +48,19 @@ ** ****************************************************************************/ -import QtQuick 2.0 +import QtQuick 2.14 import QtQuick3D 1.0 View3D { - + //! [background] environment: SceneEnvironment { - clearColor: "tan" + clearColor: "#848895" backgroundMode: SceneEnvironment.Color } - + //! [background] DirectionalLight { - + brightness: 200 } PerspectiveCamera { @@ -68,29 +68,26 @@ View3D { } Model { - id: cube1 source: "#Cube" + rotation: Qt.vector3d(45, 45, 22.5) materials: DefaultMaterial { - diffuseColor: "blue" + diffuseColor: "#a8171a" } } Model { - id: cone1 y: 100 source: "#Cone" materials: DefaultMaterial { - diffuseColor: "salmon" + diffuseColor: "#17a81a" } } Model { - id: cylinder1 - x: -300 - source: "#Cylinder" + x: -200 + source: "#Sphere" materials: DefaultMaterial { - diffuseColor: "green" + diffuseColor: "#09102b" } } - } diff --git a/examples/quick3d/blendmodes/ForegroundView.qml b/examples/quick3d/blendmodes/ForegroundView.qml index 5842af06d8f306ba47d2cb6aebbf02df1692c678..7cbec879dc045bfd33534004835e3b9f076c1038 100644 --- a/examples/quick3d/blendmodes/ForegroundView.qml +++ b/examples/quick3d/blendmodes/ForegroundView.qml @@ -48,51 +48,53 @@ ** ****************************************************************************/ -import QtQuick 2.0 +import QtQuick 2.14 import QtQuick3D 1.0 +import QtQuick3D.Materials 1.0 View3D { - + //! [foreground] + environment: SceneEnvironment { + backgroundMode: SceneEnvironment.Transparent + } + //! [foreground] Node { id: orbiter + NumberAnimation { target: orbiter property: "rotation.y" duration: 5000 from: 0 to: 360 - loops: -1 + loops: Animation.Infinite running: true } DirectionalLight { - } + PerspectiveCamera { - z: -350 + z: -500 } } - - Model { id: cube1 source: "#Cube" x: -200 - materials: DefaultMaterial { - diffuseColor: "yellow" + materials: AluminumMaterial { + bump_amount: 5.0 } } Model { id: cone1 y: -100 + rotation.x: 45 source: "#Cone" - materials: DefaultMaterial { - diffuseColor: "pink" - } - + materials: CopperMaterial {} SequentialAnimation { NumberAnimation { @@ -114,17 +116,12 @@ View3D { running: true loops: -1 } - - } Model { id: cylinder1 x: 200 - source: "#Cylinder" - materials: DefaultMaterial { - diffuseColor: "grey" - } + source: "#Sphere" + materials: SteelMilledConcentricMaterial {} } - } diff --git a/examples/quick3d/blendmodes/blendmodes.pro b/examples/quick3d/blendmodes/blendmodes.pro index 1604047d95f5810c287f27730bbd26ce77dbd5d6..dc6000f48d57896af5d8bd36315d8cd8d9df446b 100644 --- a/examples/quick3d/blendmodes/blendmodes.pro +++ b/examples/quick3d/blendmodes/blendmodes.pro @@ -4,6 +4,10 @@ target.path = $$[QT_INSTALL_EXAMPLES]/quick3d/blendmodes INSTALLS += target SOURCES += \ - main.cpp + main.cpp -RESOURCES += qml.qrc +RESOURCES += \ + qml.qrc + +OTHER_FILES += \ + doc/src/*.* diff --git a/examples/quick3d/blendmodes/doc/images/blendmodes-example.png b/examples/quick3d/blendmodes/doc/images/blendmodes-example.png new file mode 100644 index 0000000000000000000000000000000000000000..34052265374954f078a67f3125e3d8c3a8408e48 Binary files /dev/null and b/examples/quick3d/blendmodes/doc/images/blendmodes-example.png differ diff --git a/examples/quick3d/blendmodes/doc/src/qtquick3d-examples-blendmodes.qdoc b/examples/quick3d/blendmodes/doc/src/qtquick3d-examples-blendmodes.qdoc new file mode 100644 index 0000000000000000000000000000000000000000..5c07ac3f5f7c5c34a75295901cefbe1dfa3dbc77 --- /dev/null +++ b/examples/quick3d/blendmodes/doc/src/qtquick3d-examples-blendmodes.qdoc @@ -0,0 +1,62 @@ +/**************************************************************************** +** +** Copyright (C) 2019 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:FDL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Free Documentation License Usage +** Alternatively, this file may be used under the terms of the GNU Free +** Documentation License version 1.3 as published by the Free Software +** Foundation and appearing in the file included in the packaging of +** this file. Please review the following information to ensure +** the GNU Free Documentation License version 1.3 requirements +** will be met: https://www.gnu.org/licenses/fdl-1.3.html. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +/*! + \example blendmodes + \ingroup quick3d-examples + \title Qt Quick 3D - Blend Modes Example + \brief Demonstrates the use of different blend modes. + \image blendmodes-example.png + + This example demonstrates a number of blend modes that can be used in a Qt Quick 3D application. + Blending is done between two \l {View3D}s using \l {QtGraphicalEffects}. + + \section1 Creating Views + + We create two views. The first view is the background view, and may have a + non-transparent \l {SceneEnvironment::backgroundMode}{background mode} and + \l {SceneEnvironment::clearColor}{clear color} set. + + \snippet blendmodes/BackgroundView.qml background + + The second view is the foreground view, and it must have transparent + \l {SceneEnvironment::backgroundMode}{background mode}. + + \snippet blendmodes/ForegroundView.qml foreground + + \section1 Blending + + As the blending is done with \l {QtGraphicalEffects}, we need to import it into our + \c {main.qml}. + + \snippet blendmodes/main.qml extra import + + The foreground view is blended on top of the background view using the + \l {QtGraphicalEffects::Blend}{Blend} type. + + \snippet blendmodes/main.qml blending +*/ diff --git a/examples/quick3d/blendmodes/main.qml b/examples/quick3d/blendmodes/main.qml index 59a08e762c63588645828014551356289cc2d3b5..ba4f9f47264341ba94ff1202c6f9d87fc18e59b6 100644 --- a/examples/quick3d/blendmodes/main.qml +++ b/examples/quick3d/blendmodes/main.qml @@ -48,41 +48,49 @@ ** ****************************************************************************/ -import QtQuick 2.11 -import QtQuick.Window 2.11 -import QtGraphicalEffects 1.0 +import QtQuick 2.14 +import QtQuick.Window 2.14 +//! [extra import] +import QtGraphicalEffects 1.14 +//! [extra import] Window { visible: true - width: 640 - height: 480 + width: 1280 + height: 720 title: qsTr("Blend Modes Example") + color: "#6b7080" Item { id: controlArea anchors.top: parent.top anchors.bottom: parent.bottom anchors.left: parent.left - - width: 100 + anchors.margins: 20 + width: 160 ListView { id: modeList anchors.fill: parent model: modeModel delegate: Item { - height: 20 - width: 100 + height: 26 + width: 140 Text { + anchors.fill: parent + anchors.leftMargin: 10 + anchors.rightMargin: 10 text: mode + font.pixelSize: 20 } MouseArea { anchors.fill: parent - onClicked: modeList.currentIndex = index + onClicked: modeList.currentIndex = index; } } highlight: Rectangle { - color: "lightgreen" + color: "#53586b" + radius: 4 } focus: true } @@ -165,6 +173,7 @@ Window { anchors.right: parent.right anchors.left: controlArea.right + //! [blending] BackgroundView { id: background anchors.fill: parent @@ -185,9 +194,9 @@ Window { sourceItem: foreground hideSource: true } + // Take the blend mode from the selection in the list mode: modeModel.get(modeList.currentIndex).mode } + //! [blending] } - - } diff --git a/src/imports/quick3d/doc/qtquick3d.qdocconf b/src/imports/quick3d/doc/qtquick3d.qdocconf index e3e37ed847146c4bdd56096b7dca15b2ff9a0183..96a93c4923484d7bac0ce9af93c7784013719a07 100644 --- a/src/imports/quick3d/doc/qtquick3d.qdocconf +++ b/src/imports/quick3d/doc/qtquick3d.qdocconf @@ -30,7 +30,7 @@ qhp.QtQuick3D.subprojects.examples.selectors = doc:example # This module has no documented C++ types, clear the module header moduleheader = -depends += qtcore qtgui qtdoc qtqml qtqmlmodels qtquick +depends += qtcore qtgui qtdoc qtqml qtqmlmodels qtquick qtgraphicaleffects headerdirs += .. \ ../../../quick3d/ \