diff options
Diffstat (limited to 'src/quick3d')
-rw-r--r-- | src/quick3d/imports/extras/defaults/defaults.pri (renamed from src/quick3d/imports/render/defaults/defaults.pri) | 1 | ||||
-rw-r--r-- | src/quick3d/imports/extras/defaults/qml/DiffuseMapMaterial.qml (renamed from src/quick3d/imports/render/defaults/qml/DiffuseMapMaterial.qml) | 0 | ||||
-rw-r--r-- | src/quick3d/imports/extras/defaults/qml/DiffuseSpecularMapMaterial.qml (renamed from src/quick3d/imports/render/defaults/qml/DiffuseSpecularMapMaterial.qml) | 0 | ||||
-rw-r--r-- | src/quick3d/imports/extras/defaults/qml/FirstPersonCameraController.qml | 176 | ||||
-rw-r--r-- | src/quick3d/imports/extras/defaults/qml/ForwardRenderer.qml (renamed from src/quick3d/imports/render/defaults/qml/ForwardRenderer.qml) | 6 | ||||
-rw-r--r-- | src/quick3d/imports/extras/defaults/qml/GoochMaterial.qml (renamed from src/quick3d/imports/render/defaults/qml/GoochMaterial.qml) | 0 | ||||
-rw-r--r-- | src/quick3d/imports/extras/defaults/qml/NormalDiffuseMapAlphaMaterial.qml (renamed from src/quick3d/imports/render/defaults/qml/NormalDiffuseMapAlphaMaterial.qml) | 0 | ||||
-rw-r--r-- | src/quick3d/imports/extras/defaults/qml/NormalDiffuseMapMaterial.qml (renamed from src/quick3d/imports/render/defaults/qml/NormalDiffuseMapMaterial.qml) | 0 | ||||
-rw-r--r-- | src/quick3d/imports/extras/defaults/qml/NormalDiffuseSpecularMapMaterial.qml (renamed from src/quick3d/imports/render/defaults/qml/NormalDiffuseSpecularMapMaterial.qml) | 0 | ||||
-rw-r--r-- | src/quick3d/imports/extras/defaults/qml/PerVertexColorMaterial.qml (renamed from src/quick3d/imports/render/defaults/qml/PerVertexColorMaterial.qml) | 0 | ||||
-rw-r--r-- | src/quick3d/imports/extras/defaults/qml/PhongAlphaMaterial.qml (renamed from src/quick3d/imports/render/defaults/qml/PhongAlphaMaterial.qml) | 0 | ||||
-rw-r--r-- | src/quick3d/imports/extras/defaults/qml/PhongMaterial.qml (renamed from src/quick3d/imports/render/defaults/qml/PhongMaterial.qml) | 0 | ||||
-rw-r--r-- | src/quick3d/imports/extras/defaults/qml/SkyboxEntity.qml (renamed from src/quick3d/imports/render/defaults/qml/SkyboxEntity.qml) | 1 | ||||
-rw-r--r-- | src/quick3d/imports/extras/defaults/qml/TextureMaterial.qml (renamed from src/quick3d/imports/render/defaults/qml/TextureMaterial.qml) | 6 | ||||
-rw-r--r-- | src/quick3d/imports/extras/importsextras.pro | 41 | ||||
-rw-r--r-- | src/quick3d/imports/extras/qmldir | 3 | ||||
-rw-r--r-- | src/quick3d/imports/extras/qt3dquick3dextrasplugin.cpp | 106 | ||||
-rw-r--r-- | src/quick3d/imports/extras/qt3dquick3dextrasplugin.h | 65 | ||||
-rw-r--r-- | src/quick3d/imports/render/importsrender.pro | 29 | ||||
-rw-r--r-- | src/quick3d/imports/render/qt3dquick3drenderplugin.cpp | 64 |
20 files changed, 404 insertions, 94 deletions
diff --git a/src/quick3d/imports/render/defaults/defaults.pri b/src/quick3d/imports/extras/defaults/defaults.pri index 5487dac49..eee644925 100644 --- a/src/quick3d/imports/render/defaults/defaults.pri +++ b/src/quick3d/imports/extras/defaults/defaults.pri @@ -1,3 +1,4 @@ + # When adding new QML files that should be built into the plugin, # add them to this variable and they will be listed into a generated # resource file. diff --git a/src/quick3d/imports/render/defaults/qml/DiffuseMapMaterial.qml b/src/quick3d/imports/extras/defaults/qml/DiffuseMapMaterial.qml index 6e5a843b0..6e5a843b0 100644 --- a/src/quick3d/imports/render/defaults/qml/DiffuseMapMaterial.qml +++ b/src/quick3d/imports/extras/defaults/qml/DiffuseMapMaterial.qml diff --git a/src/quick3d/imports/render/defaults/qml/DiffuseSpecularMapMaterial.qml b/src/quick3d/imports/extras/defaults/qml/DiffuseSpecularMapMaterial.qml index e5ec0562a..e5ec0562a 100644 --- a/src/quick3d/imports/render/defaults/qml/DiffuseSpecularMapMaterial.qml +++ b/src/quick3d/imports/extras/defaults/qml/DiffuseSpecularMapMaterial.qml diff --git a/src/quick3d/imports/extras/defaults/qml/FirstPersonCameraController.qml b/src/quick3d/imports/extras/defaults/qml/FirstPersonCameraController.qml new file mode 100644 index 000000000..e6950140d --- /dev/null +++ b/src/quick3d/imports/extras/defaults/qml/FirstPersonCameraController.qml @@ -0,0 +1,176 @@ +/**************************************************************************** +** +** Copyright (C) 2015 Paul Lemire <paul.lemire350@gmail.com> +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the Qt3D module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** 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. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of The Qt Company Ltd nor the names of its +** contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import Qt3D.Core 2.0 +import Qt3D.Render 2.0 +import Qt3D.Input 2.0 +import Qt3D.Logic 2.0 +import QtQml 2.2 + +Entity { + id: root + property Camera camera + property real linearSpeed: 10.0 + property real lookSpeed: 180.0 + + QtObject { + id: d + readonly property vector3d firstPersonUp: Qt.vector3d(0, 1, 0) + readonly property bool leftMouseButtonPressed: leftMouseButtonAction.active + readonly property real vx: txAxis.value * linearSpeed; + readonly property real vy: tyAxis.value * linearSpeed; + readonly property real vz: tzAxis.value * linearSpeed; + readonly property real dx: rxAxis.value * lookSpeed + readonly property real dy: ryAxis.value * lookSpeed + readonly property bool fineMotion: fineMotionAction.active + } + + KeyboardDevice { + id: keyboardSourceDevice + } + + MouseDevice { + id: mouseSourceDevice + sensitivity: d.fineMotion ? 0.01 : 0.1 + } + + components: [ + + LogicalDevice { + actions: [ + Action { + id: leftMouseButtonAction + ActionInput { + sourceDevice: mouseSourceDevice + buttons: [MouseEvent.LeftButton] + } + }, + Action { + id: fineMotionAction + ActionInput { + sourceDevice: keyboardSourceDevice + buttons: [Qt.Key_Shift] + } + } + ] // actions + + axes: [ + // Rotation + Axis { + id: rxAxis + AxisInput { + sourceDevice: mouseSourceDevice + axis: MouseDevice.X + } + }, + Axis { + id: ryAxis + AxisInput { + sourceDevice: mouseSourceDevice + axis: MouseDevice.Y + } + }, + // Translation + Axis { + id: txAxis + AxisInput { + sourceDevice: keyboardSourceDevice + buttons: [Qt.Key_Left] + scale: -1.0 + } + AxisInput { + sourceDevice: keyboardSourceDevice + buttons: [Qt.Key_Right] + scale: 1.0 + } + }, + Axis { + id: tzAxis + AxisInput { + sourceDevice: keyboardSourceDevice + buttons: [Qt.Key_Up] + scale: 1.0 + } + AxisInput { + sourceDevice: keyboardSourceDevice + buttons: [Qt.Key_Down] + scale: -1.0 + } + }, + Axis { + id: tyAxis + AxisInput { + sourceDevice: keyboardSourceDevice + buttons: [Qt.Key_PageUp] + scale: 1.0 + } + AxisInput { + sourceDevice: keyboardSourceDevice + buttons: [Qt.Key_PageDown] + scale: -1.0 + } + } + ] // axes + }, + + FrameAction { + onTriggered: { + // The time difference since the last frame is passed in as the + // argument dt. It is a floating point value in units of seconds. + root.camera.translate(Qt.vector3d(d.vx, d.vy, d.vz).times(dt)) + + if (d.leftMouseButtonPressed) { + root.camera.pan(d.dx * dt, d.firstPersonUp) + root.camera.tilt(d.dy * dt) + } + } + } + ] // components +} diff --git a/src/quick3d/imports/render/defaults/qml/ForwardRenderer.qml b/src/quick3d/imports/extras/defaults/qml/ForwardRenderer.qml index be30e7fb9..0cd5bcaa6 100644 --- a/src/quick3d/imports/render/defaults/qml/ForwardRenderer.qml +++ b/src/quick3d/imports/extras/defaults/qml/ForwardRenderer.qml @@ -43,7 +43,7 @@ import Qt3D.Render 2.0 TechniqueFilter { // Expose camera to allow user to choose which camera to use for rendering property alias camera: cameraSelector.camera - property alias clearColor: clearBuffers.clearColor + property alias clearColor: clearBuffer.clearColor property alias viewportRect: viewport.normalizedRect property alias window: surfaceSelector.surface @@ -63,9 +63,9 @@ TechniqueFilter { id : cameraSelector FrustumCulling { ClearBuffers { - id: clearBuffers - buffers : ClearBuffers.ColorDepthBuffer + id: clearBuffer clearColor: "white" + buffers : ClearBuffers.ColorDepthBuffer } } } diff --git a/src/quick3d/imports/render/defaults/qml/GoochMaterial.qml b/src/quick3d/imports/extras/defaults/qml/GoochMaterial.qml index 51c656ae0..51c656ae0 100644 --- a/src/quick3d/imports/render/defaults/qml/GoochMaterial.qml +++ b/src/quick3d/imports/extras/defaults/qml/GoochMaterial.qml diff --git a/src/quick3d/imports/render/defaults/qml/NormalDiffuseMapAlphaMaterial.qml b/src/quick3d/imports/extras/defaults/qml/NormalDiffuseMapAlphaMaterial.qml index 6dfbf98c1..6dfbf98c1 100644 --- a/src/quick3d/imports/render/defaults/qml/NormalDiffuseMapAlphaMaterial.qml +++ b/src/quick3d/imports/extras/defaults/qml/NormalDiffuseMapAlphaMaterial.qml diff --git a/src/quick3d/imports/render/defaults/qml/NormalDiffuseMapMaterial.qml b/src/quick3d/imports/extras/defaults/qml/NormalDiffuseMapMaterial.qml index eeb1d33d4..eeb1d33d4 100644 --- a/src/quick3d/imports/render/defaults/qml/NormalDiffuseMapMaterial.qml +++ b/src/quick3d/imports/extras/defaults/qml/NormalDiffuseMapMaterial.qml diff --git a/src/quick3d/imports/render/defaults/qml/NormalDiffuseSpecularMapMaterial.qml b/src/quick3d/imports/extras/defaults/qml/NormalDiffuseSpecularMapMaterial.qml index d2c0efda0..d2c0efda0 100644 --- a/src/quick3d/imports/render/defaults/qml/NormalDiffuseSpecularMapMaterial.qml +++ b/src/quick3d/imports/extras/defaults/qml/NormalDiffuseSpecularMapMaterial.qml diff --git a/src/quick3d/imports/render/defaults/qml/PerVertexColorMaterial.qml b/src/quick3d/imports/extras/defaults/qml/PerVertexColorMaterial.qml index 9e286f459..9e286f459 100644 --- a/src/quick3d/imports/render/defaults/qml/PerVertexColorMaterial.qml +++ b/src/quick3d/imports/extras/defaults/qml/PerVertexColorMaterial.qml diff --git a/src/quick3d/imports/render/defaults/qml/PhongAlphaMaterial.qml b/src/quick3d/imports/extras/defaults/qml/PhongAlphaMaterial.qml index 295d8abd1..295d8abd1 100644 --- a/src/quick3d/imports/render/defaults/qml/PhongAlphaMaterial.qml +++ b/src/quick3d/imports/extras/defaults/qml/PhongAlphaMaterial.qml diff --git a/src/quick3d/imports/render/defaults/qml/PhongMaterial.qml b/src/quick3d/imports/extras/defaults/qml/PhongMaterial.qml index e60bcefc8..e60bcefc8 100644 --- a/src/quick3d/imports/render/defaults/qml/PhongMaterial.qml +++ b/src/quick3d/imports/extras/defaults/qml/PhongMaterial.qml diff --git a/src/quick3d/imports/render/defaults/qml/SkyboxEntity.qml b/src/quick3d/imports/extras/defaults/qml/SkyboxEntity.qml index f3cb1f3bf..9fcf8559f 100644 --- a/src/quick3d/imports/render/defaults/qml/SkyboxEntity.qml +++ b/src/quick3d/imports/extras/defaults/qml/SkyboxEntity.qml @@ -39,6 +39,7 @@ import Qt3D.Core 2.0 import Qt3D.Render 2.0 +import Qt3D.Extras 2.0 Entity { diff --git a/src/quick3d/imports/render/defaults/qml/TextureMaterial.qml b/src/quick3d/imports/extras/defaults/qml/TextureMaterial.qml index 28d3a1713..d5f99445b 100644 --- a/src/quick3d/imports/render/defaults/qml/TextureMaterial.qml +++ b/src/quick3d/imports/extras/defaults/qml/TextureMaterial.qml @@ -82,7 +82,7 @@ Material { techniques: [ // OpenGL 3.1 Technique { - filterKeys: [ forward ] + annotations: [ forward ] graphicsApiFilter { api: GraphicsApiFilter.OpenGL profile: GraphicsApiFilter.CoreProfile @@ -96,7 +96,7 @@ Material { // GL 2 Technique Technique { - filterKeys: [ forward ] + annotations: [ forward ] graphicsApiFilter { api: GraphicsApiFilter.OpenGL majorVersion: 2 @@ -109,7 +109,7 @@ Material { // ES 2 Technique Technique { - filterKeys: [ forward ] + annotations: [ forward ] graphicsApiFilter { api: GraphicsApiFilter.OpenGLES profile: GraphicsApiFilter.NoProfile diff --git a/src/quick3d/imports/extras/importsextras.pro b/src/quick3d/imports/extras/importsextras.pro new file mode 100644 index 000000000..bc87843bf --- /dev/null +++ b/src/quick3d/imports/extras/importsextras.pro @@ -0,0 +1,41 @@ +CXX_MODULE = qml +TARGET = quick3dextrasplugin +TARGETPATH = Qt3D/Extras + +QT += core-private qml qml-private quick quick-private 3dcore 3dcore-private 3dquick 3dquick-private 3dextras + +HEADERS += \ + qt3dquick3dextrasplugin.h + +SOURCES += \ + qt3dquick3dextrasplugin.cpp + +load(qml_plugin) + +include(./defaults/defaults.pri) + +OTHER_FILES += \ + qmldir \ + $$QML_FILES + +# Create a resource file for qml files that need to be registered by the plugin +GENERATED_RESOURCE_FILE = $$OUT_PWD/defaults.qrc +INCLUDED_RESOURCE_FILES = $$QML_FILES +RESOURCE_CONTENT = \ + "<RCC>" \ + "<qresource prefix=\"/qt-project.org/imports/Qt3D/Extras/\">" + +for(resourcefile, INCLUDED_RESOURCE_FILES) { + resourcefileabsolutepath = $$absolute_path($$resourcefile) + relativepath_in = $$relative_path($$resourcefileabsolutepath, $$_PRO_FILE_PWD_) + relativepath_out = $$relative_path($$resourcefileabsolutepath, $$OUT_PWD) + RESOURCE_CONTENT += "<file alias=\"$$relativepath_in\">$$relativepath_out</file>" +} + +RESOURCE_CONTENT += \ + "</qresource>" \ + "</RCC>" + +write_file($$GENERATED_RESOURCE_FILE, RESOURCE_CONTENT)|error("Aborting.") + +RESOURCES += $$GENERATED_RESOURCE_FILE diff --git a/src/quick3d/imports/extras/qmldir b/src/quick3d/imports/extras/qmldir new file mode 100644 index 000000000..4f7215ae0 --- /dev/null +++ b/src/quick3d/imports/extras/qmldir @@ -0,0 +1,3 @@ +module Qt3D.Extras +plugin quick3dextrasplugin +classname Qt3DQuick3DExtrasPlugin diff --git a/src/quick3d/imports/extras/qt3dquick3dextrasplugin.cpp b/src/quick3d/imports/extras/qt3dquick3dextrasplugin.cpp new file mode 100644 index 000000000..cd7743915 --- /dev/null +++ b/src/quick3d/imports/extras/qt3dquick3dextrasplugin.cpp @@ -0,0 +1,106 @@ +/**************************************************************************** +** +** Copyright (C) 2016 Klaralvdalens Datakonsult AB (KDAB). +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the Qt3D module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** 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 Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qt3dquick3dextrasplugin.h" +#include <Qt3DExtras/qcuboidmesh.h> +#include <Qt3DExtras/qconemesh.h> +#include <Qt3DExtras/qcylindermesh.h> +#include <Qt3DExtras/qplanemesh.h> +#include <Qt3DExtras/qspheremesh.h> +#include <Qt3DExtras/qtorusmesh.h> +#include <Qt3DExtras/qtorusgeometry.h> +#include <Qt3DExtras/qspheregeometry.h> +#include <Qt3DExtras/qcuboidgeometry.h> +#include <Qt3DExtras/qplanegeometry.h> +#include <Qt3DExtras/qconegeometry.h> +#include <Qt3DExtras/qcylindergeometry.h> +#include <QtQml/qqml.h> + +QT_BEGIN_NAMESPACE + +static const struct { + const char *type; + int major, minor; +} qmldir [] = { + // Materials + { "PhongMaterial", 2, 0 }, + { "PhongAlphaMaterial", 2, 0 }, + { "DiffuseMapMaterial", 2, 0 }, + { "DiffuseSpecularMapMaterial", 2, 0 }, + { "NormalDiffuseMapAlphaMaterial", 2, 0 }, + { "NormalDiffuseMapMaterial", 2, 0 }, + { "NormalDiffuseSpecularMapMaterial", 2, 0 }, + { "PerVertexColorMaterial", 2, 0 }, + { "GoochMaterial", 2, 0 }, + { "TextureMaterial", 2, 0 }, + // FrameGraphs + { "ForwardRenderer", 2, 0 }, + // Entities + { "SkyboxEntity", 2, 0 } +}; + +void Qt3DQuick3DExtrasPlugin::registerTypes(const char *uri) +{ + // Meshes + qmlRegisterType<Qt3DExtras::QConeMesh>(uri, 2, 0, "ConeMesh"); + qmlRegisterType<Qt3DExtras::QConeGeometry>(uri, 2, 0, "ConeGeometry"); + qmlRegisterType<Qt3DExtras::QCuboidMesh>(uri, 2, 0, "CuboidMesh"); + qmlRegisterType<Qt3DExtras::QCuboidGeometry>(uri, 2, 0, "CuboidGeometry"); + qmlRegisterType<Qt3DExtras::QCylinderMesh>(uri, 2, 0, "CylinderMesh"); + qmlRegisterType<Qt3DExtras::QCylinderGeometry>(uri, 2, 0, "CylinderGeometry"); + qmlRegisterType<Qt3DExtras::QPlaneMesh>(uri, 2, 0, "PlaneMesh"); + qmlRegisterType<Qt3DExtras::QPlaneGeometry>(uri, 2, 0, "PlaneGeometry"); + qmlRegisterType<Qt3DExtras::QTorusMesh>(uri, 2, 0, "TorusMesh"); + qmlRegisterType<Qt3DExtras::QTorusGeometry>(uri, 2, 0, "TorusGeometry"); + qmlRegisterType<Qt3DExtras::QSphereMesh>(uri, 2, 0, "SphereMesh"); + qmlRegisterType<Qt3DExtras::QSphereGeometry>(uri, 2, 0, "SphereGeometry"); + + + // Register types provided as QML files compiled into the plugin + for (int i = 0; i < int(sizeof(qmldir) / sizeof(qmldir[0])); i++) { + QString path = QStringLiteral("qrc:/qt-project.org/imports/Qt3D/Extras/defaults/qml/"); + qmlRegisterType(QUrl(path + qmldir[i].type + QStringLiteral(".qml")), + uri, + qmldir[i].major, qmldir[i].minor, + qmldir[i].type); + } +} + + +QT_END_NAMESPACE diff --git a/src/quick3d/imports/extras/qt3dquick3dextrasplugin.h b/src/quick3d/imports/extras/qt3dquick3dextrasplugin.h new file mode 100644 index 000000000..147d7eca6 --- /dev/null +++ b/src/quick3d/imports/extras/qt3dquick3dextrasplugin.h @@ -0,0 +1,65 @@ +/**************************************************************************** +** +** Copyright (C) 2016 Klaralvdalens Datakonsult AB (KDAB). +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the Qt3D module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** 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 Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QT3DQUICK3DEXTRASPLUGIN_H +#define QT3DQUICK3DEXTRASPLUGIN_H + +#include <QtQml/QQmlExtensionPlugin> + +static void initResources() +{ +#ifdef QT_STATIC + Q_INIT_RESOURCE(qmake_Qt3D_Core); +#endif +} + +QT_BEGIN_NAMESPACE + +class Qt3DQuick3DExtrasPlugin : public QQmlExtensionPlugin +{ + Q_OBJECT + Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface/1.0") +public: + Qt3DQuick3DExtrasPlugin(QObject *parent = nullptr) : QQmlExtensionPlugin(parent) { initResources(); } + void registerTypes(const char *uri) Q_DECL_OVERRIDE; +}; + +QT_END_NAMESPACE + +#endif // QT3DQUICK3DEXTRASPLUGIN_H diff --git a/src/quick3d/imports/render/importsrender.pro b/src/quick3d/imports/render/importsrender.pro index 571092e03..36d9080c1 100644 --- a/src/quick3d/imports/render/importsrender.pro +++ b/src/quick3d/imports/render/importsrender.pro @@ -10,35 +10,6 @@ HEADERS += \ SOURCES += \ qt3dquick3drenderplugin.cpp -include(./defaults/defaults.pri) - OTHER_FILES += qmldir -include(./defaults/defaults.pri) - -OTHER_FILES += \ - $$QML_FILES - -# Create a resource file for qml files that need to be registered by the plugin -GENERATED_RESOURCE_FILE = $$OUT_PWD/defaults.qrc -INCLUDED_RESOURCE_FILES = $$QML_FILES -RESOURCE_CONTENT = \ - "<RCC>" \ - "<qresource prefix=\"/qt-project.org/imports/Qt3D/Render/\">" - -for(resourcefile, INCLUDED_RESOURCE_FILES) { - resourcefileabsolutepath = $$absolute_path($$resourcefile) - relativepath_in = $$relative_path($$resourcefileabsolutepath, $$_PRO_FILE_PWD_) - relativepath_out = $$relative_path($$resourcefileabsolutepath, $$OUT_PWD) - RESOURCE_CONTENT += "<file alias=\"$$relativepath_in\">$$relativepath_out</file>" -} - -RESOURCE_CONTENT += \ - "</qresource>" \ - "</RCC>" - -write_file($$GENERATED_RESOURCE_FILE, RESOURCE_CONTENT)|error("Aborting.") - -RESOURCES += $$GENERATED_RESOURCE_FILE - load(qml_plugin) diff --git a/src/quick3d/imports/render/qt3dquick3drenderplugin.cpp b/src/quick3d/imports/render/qt3dquick3drenderplugin.cpp index 62111535c..1e8ace1ec 100644 --- a/src/quick3d/imports/render/qt3dquick3drenderplugin.cpp +++ b/src/quick3d/imports/render/qt3dquick3drenderplugin.cpp @@ -54,12 +54,6 @@ #include <Qt3DRender/qeffect.h> #include <Qt3DRender/qparameter.h> #include <Qt3DRender/qfilterkey.h> -#include <Qt3DRender/qcuboidmesh.h> -#include <Qt3DRender/qconemesh.h> -#include <Qt3DRender/qcylindermesh.h> -#include <Qt3DRender/qplanemesh.h> -#include <Qt3DRender/qspheremesh.h> -#include <Qt3DRender/qtorusmesh.h> #include <Qt3DRender/qlayer.h> #include <Qt3DRender/qlayerfilter.h> #include <Qt3DRender/qlight.h> @@ -97,13 +91,7 @@ #include <Qt3DRender/qattribute.h> #include <Qt3DRender/qbuffer.h> #include <Qt3DRender/qgeometry.h> -#include <Qt3DRender/qtorusgeometry.h> -#include <Qt3DRender/qspheregeometry.h> -#include <Qt3DRender/qcuboidgeometry.h> -#include <Qt3DRender/qplanegeometry.h> #include <Qt3DRender/qgeometryrenderer.h> -#include <Qt3DRender/qconegeometry.h> -#include <Qt3DRender/qcylindergeometry.h> #include <Qt3DRender/qobjectpicker.h> #include <Qt3DRender/qpickevent.h> #include <Qt3DRender/qfrustumculling.h> @@ -138,27 +126,6 @@ QT_BEGIN_NAMESPACE -static const struct { - const char *type; - int major, minor; -} qmldir [] = { - // Materials - { "PhongMaterial", 2, 0 }, - { "PhongAlphaMaterial", 2, 0 }, - { "DiffuseMapMaterial", 2, 0 }, - { "DiffuseSpecularMapMaterial", 2, 0 }, - { "NormalDiffuseMapAlphaMaterial", 2, 0 }, - { "NormalDiffuseMapMaterial", 2, 0 }, - { "NormalDiffuseSpecularMapMaterial", 2, 0 }, - { "PerVertexColorMaterial", 2, 0 }, - { "GoochMaterial", 2, 0 }, - { "TextureMaterial", 2, 0 }, - // FrameGraphs - { "ForwardRenderer", 2, 0 }, - // Entities - { "SkyboxEntity", 2, 0 } -}; - QVariantList Quick3DShaderDataArrayToVariantListConverter(Qt3DRender::Render::Quick::Quick3DShaderDataArray *array) { QVector<Qt3DRender::QShaderData *> arrayValues = array->values(); @@ -226,28 +193,16 @@ void Qt3DQuick3DRenderPlugin::registerTypes(const char *uri) qmlRegisterType<Qt3DRender::QGeometryRenderer>(uri, 2, 0, "GeometryRenderer"); // Debug components - qmlRegisterType<Qt3DRender::QBoundingVolumeDebug>(uri, 2, 0, "BoundingVolumeDebug"); +// qmlRegisterType<Qt3DRender::QBoundingVolumeDebug>(uri, 2, 0, "BoundingVolumeDebug"); + + // Mesh + qmlRegisterType<Qt3DRender::QMesh>(uri, 2, 0, "Mesh"); // Picking qmlRegisterType<Qt3DRender::QObjectPicker>(uri, 2, 0, "ObjectPicker"); qmlRegisterUncreatableType<Qt3DRender::QPickEvent>(uri, 2, 0, "PickEvent", QStringLiteral("Events cannot be created")); - // Meshes - qmlRegisterType<Qt3DRender::QMesh>(uri, 2, 0, "Mesh"); - qmlRegisterType<Qt3DRender::QConeMesh>(uri, 2, 0, "ConeMesh"); - qmlRegisterType<Qt3DRender::QConeGeometry>(uri, 2, 0, "ConeGeometry"); - qmlRegisterType<Qt3DRender::QCuboidMesh>(uri, 2, 0, "CuboidMesh"); - qmlRegisterType<Qt3DRender::QCuboidGeometry>(uri, 2, 0, "CuboidGeometry"); - qmlRegisterType<Qt3DRender::QCylinderMesh>(uri, 2, 0, "CylinderMesh"); - qmlRegisterType<Qt3DRender::QCylinderGeometry>(uri, 2, 0, "CylinderGeometry"); - qmlRegisterType<Qt3DRender::QPlaneMesh>(uri, 2, 0, "PlaneMesh"); - qmlRegisterType<Qt3DRender::QPlaneGeometry>(uri, 2, 0, "PlaneGeometry"); - qmlRegisterType<Qt3DRender::QTorusMesh>(uri, 2, 0, "TorusMesh"); - qmlRegisterType<Qt3DRender::QTorusGeometry>(uri, 2, 0, "TorusGeometry"); - qmlRegisterType<Qt3DRender::QSphereMesh>(uri, 2, 0, "SphereMesh"); - qmlRegisterType<Qt3DRender::QSphereGeometry>(uri, 2, 0, "SphereGeometry"); - - // Compute Job + // Compute Job qmlRegisterType<Qt3DRender::QComputeCommand>(uri, 2, 0, "ComputeCommand"); // Layers @@ -307,15 +262,6 @@ void Qt3DQuick3DRenderPlugin::registerTypes(const char *uri) qmlRegisterType<Qt3DRender::QSeamlessCubemap>(uri, 2, 0, "SeamlessCubemap"); qmlRegisterType<Qt3DRender::QStencilOperation>(uri, 2, 0, "StencilOperation"); qmlRegisterType<Qt3DRender::QStencilMask>(uri, 2, 0, "StencilMask"); - - // Register types provided as QML files compiled into the plugin - for (int i = 0; i < int(sizeof(qmldir) / sizeof(qmldir[0])); i++) { - QString path = QStringLiteral("qrc:/qt-project.org/imports/Qt3D/Render/defaults/qml/"); - qmlRegisterType(QUrl(path + qmldir[i].type + QStringLiteral(".qml")), - uri, - qmldir[i].major, qmldir[i].minor, - qmldir[i].type); - } } QT_END_NAMESPACE |