diff options
author | Kevin Ottens <kevin.ottens@kdab.com> | 2017-01-25 12:10:33 +0100 |
---|---|---|
committer | Kevin Ottens <kevin.ottens@kdab.com> | 2017-01-27 14:58:39 +0000 |
commit | f5b66ed6706c129754a8fc0c0541eab1f9ed4181 (patch) | |
tree | 7cf7903abe9b817c24f34f3074c04e4e0c1f4da1 | |
parent | 946e78eada359f651d337309b25d51d4204289b0 (diff) |
Consolidate QML/C++ materials in extras
We remove the qml implementation of materials in extras that were also
implemented in C++. Note this is an API change for the materials having
texture properties. The QML ones had mistakenly a string property
instead of a texture one. This move also fixes this API issue on the QML
end.
Change-Id: Ibed14288cd7b8c5ab9615b74b949c6a73ac29329
Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
17 files changed, 41 insertions, 765 deletions
diff --git a/examples/qt3d/audio-visualizer-qml/Visualizer.qml b/examples/qt3d/audio-visualizer-qml/Visualizer.qml index 562d8c184..ce32dd3ee 100644 --- a/examples/qt3d/audio-visualizer-qml/Visualizer.qml +++ b/examples/qt3d/audio-visualizer-qml/Visualizer.qml @@ -189,8 +189,8 @@ Entity { NormalDiffuseMapAlphaMaterial { id: titlePlaneMaterial - diffuse: "qrc:/images/demotitle.png" - normal: "qrc:/images/normalmap.png" + diffuse: TextureLoader { source: "qrc:/images/demotitle.png" } + normal: TextureLoader { source: "qrc:/images/normalmap.png" } shininess: 1.0 } @@ -215,8 +215,8 @@ Entity { } property Material songPlaneMaterial: NormalDiffuseMapAlphaMaterial { - diffuse: "qrc:/images/songtitle.png" - normal: "qrc:/images/normalmap.png" + diffuse: TextureLoader { source: "qrc:/images/songtitle.png" } + normal: TextureLoader { source: "qrc:/images/normalmap.png" } shininess: 1.0 } diff --git a/examples/qt3d/lights/main.qml b/examples/qt3d/lights/main.qml index 8f1c603cf..69250da13 100644 --- a/examples/qt3d/lights/main.qml +++ b/examples/qt3d/lights/main.qml @@ -183,8 +183,8 @@ Entity material: NormalDiffuseMapMaterial { ambient: Qt.rgba( 0.2, 0.2, 0.2, 1.0 ) - diffuse: "assets/textures/pattern_09/diffuse.webp" - normal: "assets/textures/pattern_09/normal.webp" + diffuse: TextureLoader { source: "assets/textures/pattern_09/diffuse.webp" } + normal: TextureLoader { source: "assets/textures/pattern_09/normal.webp" } textureScale: 10 shininess: 10 } diff --git a/examples/qt3d/materials/Barrel.qml b/examples/qt3d/materials/Barrel.qml index c68cab657..31abd329f 100644 --- a/examples/qt3d/materials/Barrel.qml +++ b/examples/qt3d/materials/Barrel.qml @@ -74,13 +74,11 @@ Entity { material: NormalDiffuseSpecularMapMaterial { id: material ambient: "black" - diffuse: "assets/metalbarrel/diffus_" + root.diffuseColor + ".webp" - normal: "assets/metalbarrel/normal_" + root.bump + ".webp" - specular: { - if (root.specular !== "" ) - return "assets/metalbarrel/specular_" + root.specular + ".webp" - else - return "assets/metalbarrel/specular.webp" + diffuse: TextureLoader { source: "assets/metalbarrel/diffus_" + root.diffuseColor + ".webp" } //TextureLoader { source: ("assets/metalbarrel/diffus_" + root.diffuseColor + ".webp") } + normal: TextureLoader { source: "assets/metalbarrel/normal_" + root.bump + ".webp" } + specular: TextureLoader { + source: root.specular !== "" ? "assets/metalbarrel/specular_" + root.specular + ".webp" + : "assets/metalbarrel/specular.webp" } shininess: 5.0 diff --git a/examples/qt3d/materials/Chest.qml b/examples/qt3d/materials/Chest.qml index 879ebb26f..227e32864 100644 --- a/examples/qt3d/materials/Chest.qml +++ b/examples/qt3d/materials/Chest.qml @@ -68,7 +68,7 @@ Entity { material: DiffuseMapMaterial { id: material - diffuse: "assets/chest/diffuse.webp" + diffuse: TextureLoader { source: "assets/chest/diffuse.webp" } specular: Qt.rgba( 0.2, 0.2, 0.2, 1.0 ) shininess: 2.0 } diff --git a/examples/qt3d/materials/HousePlant.qml b/examples/qt3d/materials/HousePlant.qml index 6505ab171..7ee810d7f 100644 --- a/examples/qt3d/materials/HousePlant.qml +++ b/examples/qt3d/materials/HousePlant.qml @@ -70,8 +70,8 @@ Entity { position: Qt.vector3d(root.x, root.y, root.z) material: NormalDiffuseMapMaterial { - diffuse: "assets/houseplants/pot.webp" - normal: "assets/houseplants/pot_normal.webp" + diffuse: TextureLoader { source: "assets/houseplants/pot.webp" } + normal: TextureLoader { source: "assets/houseplants/pot_normal.webp" } specular: Qt.rgba( 0.75, 0.75, 0.75, 1.0 ) shininess: 5.0 } @@ -79,8 +79,8 @@ Entity { RenderableEntity { source: "assets/houseplants/" + root.potShape + "-" + root.plantType + ".obj" material: NormalDiffuseMapAlphaMaterial { - diffuse: "assets/houseplants/" + root.plantType + ".webp" - normal: "assets/houseplants/" + root.plantType + "_normal.webp" + diffuse: TextureLoader { source: "assets/houseplants/" + root.plantType + ".webp" } + normal: TextureLoader { source: "assets/houseplants/" + root.plantType + "_normal.webp" } shininess: 10.0 } } @@ -88,8 +88,8 @@ Entity { RenderableEntity { source: "assets/houseplants/" + root.potShape + "-pot-cover.obj" material: NormalDiffuseMapMaterial { - diffuse: "assets/houseplants/cover.webp" - normal: "assets/houseplants/cover_normal.webp" + diffuse: TextureLoader { source: "assets/houseplants/cover.webp" } + normal: TextureLoader { source: "assets/houseplants/cover_normal.webp" } specular: Qt.rgba( 0.05, 0.05, 0.05, 1.0 ) shininess: 5.0 } diff --git a/examples/qt3d/materials/main.qml b/examples/qt3d/materials/main.qml index 9ed9bd219..c09454065 100644 --- a/examples/qt3d/materials/main.qml +++ b/examples/qt3d/materials/main.qml @@ -96,9 +96,9 @@ Entity { material: NormalDiffuseSpecularMapMaterial { ambient: Qt.rgba( 0.05, 0.05, 0.05, 1.0 ) - diffuse: "assets/textures/pattern_09/diffuse.webp" - specular: "assets/textures/pattern_09/specular.webp" - normal: "assets/textures/pattern_09/normal.webp" + diffuse: TextureLoader { source: "assets/textures/pattern_09/diffuse.webp" } + specular: TextureLoader { source: "assets/textures/pattern_09/specular.webp" } + normal: TextureLoader { source: "assets/textures/pattern_09/normal.webp" } textureScale: 10.0 shininess: 10.0 } diff --git a/src/quick3d/imports/extras/defaults/defaults.pri b/src/quick3d/imports/extras/defaults/defaults.pri index 98f542fd6..7872837a7 100644 --- a/src/quick3d/imports/extras/defaults/defaults.pri +++ b/src/quick3d/imports/extras/defaults/defaults.pri @@ -8,17 +8,8 @@ QML_FILES = \ $$PWD/qml/DefaultEffect.qml \ $$PWD/qml/DefaultAlphaEffect.qml \ - $$PWD/qml/PhongMaterial.qml \ - $$PWD/qml/DiffuseMapMaterial.qml \ - $$PWD/qml/DiffuseSpecularMapMaterial.qml \ - $$PWD/qml/NormalDiffuseMapMaterial.qml \ - $$PWD/qml/NormalDiffuseMapAlphaMaterial.qml \ - $$PWD/qml/NormalDiffuseSpecularMapMaterial.qml \ $$PWD/qml/ForwardRenderer.qml \ - $$PWD/qml/PerVertexColorMaterial.qml \ $$PWD/qml/SkyboxEntity.qml \ - $$PWD/qml/GoochMaterial.qml \ - $$PWD/qml/PhongAlphaMaterial.qml \ $$PWD/qml/TextureMaterial.qml \ $$PWD/qml/OrbitCameraController.qml \ $$PWD/qml/FirstPersonCameraController.qml \ diff --git a/src/quick3d/imports/extras/defaults/qml/DiffuseMapMaterial.qml b/src/quick3d/imports/extras/defaults/qml/DiffuseMapMaterial.qml deleted file mode 100644 index 4b49d76de..000000000 --- a/src/quick3d/imports/extras/defaults/qml/DiffuseMapMaterial.qml +++ /dev/null @@ -1,81 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2014 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$ -** -****************************************************************************/ - -import Qt3D.Core 2.0 -import Qt3D.Render 2.0 - -Material { - id: root - - property color ambient: Qt.rgba( 0.05, 0.05, 0.05, 1.0 ) - property alias diffuse: diffuseTextureImage.source - property color specular: Qt.rgba( 0.01, 0.01, 0.01, 1.0 ) - property real shininess: 150.0 - property real textureScale: 1.0 - - parameters: [ - Parameter { name: "ka"; value: Qt.vector3d(root.ambient.r, root.ambient.g, root.ambient.b) }, - Parameter { - name: "diffuseTexture" - value: Texture2D { - id: diffuseTexture - minificationFilter: Texture.LinearMipMapLinear - magnificationFilter: Texture.Linear - wrapMode { - x: WrapMode.Repeat - y: WrapMode.Repeat - } - generateMipMaps: true - maximumAnisotropy: 16.0 - TextureImage { id: diffuseTextureImage; } - } - }, - Parameter { name: "ks"; value: Qt.vector3d(root.specular.r, root.specular.g, root.specular.b) }, - Parameter { name: "shininess"; value: root.shininess }, - Parameter { name: "texCoordScale"; value: textureScale } - ] - - effect: DefaultEffect { - vertexES: "qrc:/shaders/es2/diffusemap.vert" - fragmentES: "qrc:/shaders/es2/diffusemap.frag" - vertex: "qrc:/shaders/gl3/diffusemap.vert" - fragment: "qrc:/shaders/gl3/diffusemap.frag" - } -} - diff --git a/src/quick3d/imports/extras/defaults/qml/DiffuseSpecularMapMaterial.qml b/src/quick3d/imports/extras/defaults/qml/DiffuseSpecularMapMaterial.qml deleted file mode 100644 index 629cb6d11..000000000 --- a/src/quick3d/imports/extras/defaults/qml/DiffuseSpecularMapMaterial.qml +++ /dev/null @@ -1,93 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2014 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$ -** -****************************************************************************/ - -import Qt3D.Core 2.0 -import Qt3D.Render 2.0 - -Material { - id: root - - property color ambient: Qt.rgba( 0.05, 0.05, 0.05, 1.0 ) - property alias diffuse: diffuseTextureImage.source - property alias specular: specularTextureImage.source - property real shininess: 150.0 - property real textureScale: 1.0 - - parameters: [ - Parameter { name: "ka"; value: Qt.vector3d(root.ambient.r, root.ambient.g, root.ambient.b) }, - Parameter { - name: "diffuseTexture" - value: Texture2D { - id: diffuseTexture - minificationFilter: Texture.LinearMipMapLinear - magnificationFilter: Texture.Linear - wrapMode { - x: WrapMode.Repeat - y: WrapMode.Repeat - } - generateMipMaps: true - maximumAnisotropy: 16.0 - TextureImage { id: diffuseTextureImage; } - } - }, - Parameter { name: "specularTexture"; - value: Texture2D { - id: specularTexture - minificationFilter: Texture.LinearMipMapLinear - magnificationFilter: Texture.Linear - wrapMode { - x: WrapMode.Repeat - y: WrapMode.Repeat - } - generateMipMaps: true - maximumAnisotropy: 16.0 - TextureImage { id: specularTextureImage; } - } - }, - Parameter { name: "shininess"; value: root.shininess }, - Parameter { name: "texCoordScale"; value: textureScale } - ] - - effect: DefaultEffect { - vertexES: "qrc:/shaders/es2/diffusemap.vert" - fragmentES: "qrc:/shaders/es2/diffusespecularmap.frag" - vertex: "qrc:/shaders/gl3/diffusemap.vert" - fragment: "qrc:/shaders/gl3/diffusespecularmap.frag" - } -} diff --git a/src/quick3d/imports/extras/defaults/qml/GoochMaterial.qml b/src/quick3d/imports/extras/defaults/qml/GoochMaterial.qml deleted file mode 100644 index fffa2284d..000000000 --- a/src/quick3d/imports/extras/defaults/qml/GoochMaterial.qml +++ /dev/null @@ -1,71 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2015 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$ -** -****************************************************************************/ - -import Qt3D.Core 2.0 -import Qt3D.Render 2.0 - -Material { - id: root - - property color diffuse: Qt.rgba( 0.0, 0.0, 0.0, 1.0 ) - property color specular: Qt.rgba( 0.0, 0.0, 0.0, 1.0 ) - property color coolColor: Qt.rgba( 0.0, 0.0, 0.4, 1.0 ) - property color warmColor: Qt.rgba( 0.4, 0.4, 0.0, 1.0 ) - property real alpha: 0.25 - property real beta: 0.5 - property real shininess: 100.0 - - parameters: [ - Parameter { name: "kd"; value: root.diffuse }, - Parameter { name: "ks"; value: root.specular }, - Parameter { name: "kblue"; value: root.coolColor }, - Parameter { name: "kyellow"; value: root.warmColor }, - Parameter { name: "alpha"; value: root.alpha }, - Parameter { name: "beta"; value: root.beta }, - Parameter { name: "shininess"; value: root.shininess } - ] - - effect: DefaultEffect { - vertexES: "qrc:/shaders/es2/gooch.vert" - fragmentES: "qrc:/shaders/es2/gooch.frag" - vertex: "qrc:/shaders/gl3/gooch.vert" - fragment: "qrc:/shaders/gl3/gooch.frag" - } -} - diff --git a/src/quick3d/imports/extras/defaults/qml/NormalDiffuseMapAlphaMaterial.qml b/src/quick3d/imports/extras/defaults/qml/NormalDiffuseMapAlphaMaterial.qml deleted file mode 100644 index 421cc3aa9..000000000 --- a/src/quick3d/imports/extras/defaults/qml/NormalDiffuseMapAlphaMaterial.qml +++ /dev/null @@ -1,92 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2014 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$ -** -****************************************************************************/ - -import Qt3D.Core 2.0 -import Qt3D.Render 2.0 - -Material { - id: root - - property color ambient: Qt.rgba( 0.05, 0.05, 0.05, 1.0 ) - property alias diffuse: diffuseTextureImage.source - property color specular: Qt.rgba( 0.01, 0.01, 0.01, 1.0 ) - property alias normal: normalTextureImage.source - property real shininess: 150.0 - property real textureScale: 1.0 - - parameters: [ - Parameter { name: "ka"; value: Qt.vector3d(root.ambient.r, root.ambient.g, root.ambient.b) }, - Parameter { - name: "diffuseTexture" - value: Texture2D { - id: diffuseTexture - minificationFilter: Texture.LinearMipMapLinear - magnificationFilter: Texture.Linear - wrapMode { - x: WrapMode.Repeat - y: WrapMode.Repeat - } - generateMipMaps: true - maximumAnisotropy: 16.0 - TextureImage { id: diffuseTextureImage; } - } - }, - Parameter { - name: "normalTexture" - value: Texture2D { - id: normalTexture - minificationFilter: Texture.LinearMipMapLinear - magnificationFilter: Texture.Linear - wrapMode { - x: WrapMode.Repeat - y: WrapMode.Repeat - } - generateMipMaps: true - maximumAnisotropy: 16.0 - TextureImage { id: normalTextureImage; } - } - }, - Parameter { name: "ks"; value: Qt.vector3d(root.specular.r, root.specular.g, root.specular.b) }, - Parameter { name: "shininess"; value: root.shininess }, - Parameter { name: "texCoordScale"; value: textureScale } - ] - - effect: NormalDiffuseMapAlphaEffect { } -} - diff --git a/src/quick3d/imports/extras/defaults/qml/NormalDiffuseMapMaterial.qml b/src/quick3d/imports/extras/defaults/qml/NormalDiffuseMapMaterial.qml deleted file mode 100644 index 0724cf597..000000000 --- a/src/quick3d/imports/extras/defaults/qml/NormalDiffuseMapMaterial.qml +++ /dev/null @@ -1,97 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2014 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$ -** -****************************************************************************/ - -import Qt3D.Core 2.0 -import Qt3D.Render 2.0 - -Material { - id: root - - property color ambient: Qt.rgba( 0.05, 0.05, 0.05, 1.0 ) - property alias diffuse: diffuseTextureImage.source - property color specular: Qt.rgba( 0.01, 0.01, 0.01, 1.0 ) - property alias normal: normalTextureImage.source - property real shininess: 150.0 - property real textureScale: 1.0 - - parameters: [ - Parameter { name: "ka"; value: Qt.vector3d(root.ambient.r, root.ambient.g, root.ambient.b) }, - Parameter { - name: "diffuseTexture" - value: Texture2D { - id: diffuseTexture - minificationFilter: Texture.LinearMipMapLinear - magnificationFilter: Texture.Linear - wrapMode { - x: WrapMode.Repeat - y: WrapMode.Repeat - } - generateMipMaps: true - maximumAnisotropy: 16.0 - TextureImage { id: diffuseTextureImage; } - } - }, - Parameter { - name: "normalTexture" - value: Texture2D { - id: normalTexture - minificationFilter: Texture.LinearMipMapLinear - magnificationFilter: Texture.Linear - wrapMode { - x: WrapMode.Repeat - y: WrapMode.Repeat - } - generateMipMaps: true - maximumAnisotropy: 16.0 - TextureImage { id: normalTextureImage; } - } - }, - Parameter { name: "ks"; value: Qt.vector3d(root.specular.r, root.specular.g, root.specular.b) }, - Parameter { name: "shininess"; value: root.shininess }, - Parameter { name: "texCoordScale"; value: textureScale } - ] - - effect: DefaultEffect { - vertexES: "qrc:/shaders/es2/normaldiffusemap.vert" - fragmentES: "qrc:/shaders/es2/normaldiffusemap.frag" - vertex: "qrc:/shaders/gl3/normaldiffusemap.vert" - fragment: "qrc:/shaders/gl3/normaldiffusemap.frag" - } -} - diff --git a/src/quick3d/imports/extras/defaults/qml/NormalDiffuseSpecularMapMaterial.qml b/src/quick3d/imports/extras/defaults/qml/NormalDiffuseSpecularMapMaterial.qml deleted file mode 100644 index 497209c32..000000000 --- a/src/quick3d/imports/extras/defaults/qml/NormalDiffuseSpecularMapMaterial.qml +++ /dev/null @@ -1,110 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2014 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$ -** -****************************************************************************/ - -import Qt3D.Core 2.0 -import Qt3D.Render 2.0 - -Material { - id: root - - property color ambient: Qt.rgba( 0.05, 0.05, 0.05, 1.0 ) - property alias diffuse: diffuseTextureImage.source - property alias specular: specularTextureImage.source - property alias normal: normalTextureImage.source - property real shininess: 150.0 - property real textureScale: 1.0 - - parameters: [ - Parameter { name: "ka"; value: Qt.vector3d(root.ambient.r, root.ambient.g, root.ambient.b) }, - Parameter { - name: "diffuseTexture" - value: Texture2D { - id: diffuseTexture - minificationFilter: Texture.LinearMipMapLinear - magnificationFilter: Texture.Linear - wrapMode { - x: WrapMode.Repeat - y: WrapMode.Repeat - } - generateMipMaps: true - maximumAnisotropy: 16.0 - TextureImage { id: diffuseTextureImage; } - } - }, - Parameter { name: "specularTexture"; - value: Texture2D { - id: specularTexture - minificationFilter: Texture.LinearMipMapLinear - magnificationFilter: Texture.Linear - wrapMode { - x: WrapMode.Repeat - y: WrapMode.Repeat - } - generateMipMaps: true - maximumAnisotropy: 16.0 - TextureImage { id: specularTextureImage; } - } - }, - Parameter { - name: "normalTexture" - value: Texture2D { - id: normalTexture - minificationFilter: Texture.LinearMipMapLinear - magnificationFilter: Texture.Linear - wrapMode { - x: WrapMode.Repeat - y: WrapMode.Repeat - } - generateMipMaps: true - maximumAnisotropy: 16.0 - TextureImage { id: normalTextureImage; } - } - }, - Parameter { name: "shininess"; value: root.shininess }, - Parameter { name: "texCoordScale"; value: textureScale } - ] - - effect: DefaultEffect { - vertexES: "qrc:/shaders/es2/normaldiffusemap.vert" - fragmentES: "qrc:/shaders/es2/normaldiffusespecularmap.frag" - vertex: "qrc:/shaders/gl3/normaldiffusemap.vert" - fragment: "qrc:/shaders/gl3/normaldiffusespecularmap.frag" - } -} - diff --git a/src/quick3d/imports/extras/defaults/qml/PerVertexColorMaterial.qml b/src/quick3d/imports/extras/defaults/qml/PerVertexColorMaterial.qml deleted file mode 100644 index 70c461edd..000000000 --- a/src/quick3d/imports/extras/defaults/qml/PerVertexColorMaterial.qml +++ /dev/null @@ -1,53 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2015 Lorenz Esch (TU Ilmenau). -** 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$ -** -****************************************************************************/ - -import Qt3D.Core 2.0 -import Qt3D.Render 2.0 - -Material { - id: root - - effect: DefaultEffect { - vertexES: "qrc:/shaders/es2/pervertexcolor.vert" - fragmentES: "qrc:/shaders/es2/pervertexcolor.frag" - vertex: "qrc:/shaders/gl3/pervertexcolor.vert" - fragment: "qrc:/shaders/gl3/pervertexcolor.frag" - } -} - diff --git a/src/quick3d/imports/extras/defaults/qml/PhongAlphaMaterial.qml b/src/quick3d/imports/extras/defaults/qml/PhongAlphaMaterial.qml deleted file mode 100644 index 87373242d..000000000 --- a/src/quick3d/imports/extras/defaults/qml/PhongAlphaMaterial.qml +++ /dev/null @@ -1,68 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2015 Paul Lemire -** 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$ -** -****************************************************************************/ - -import Qt3D.Core 2.0 -import Qt3D.Render 2.0 - -Material { - id: root - - property color ambient: Qt.rgba( 0.05, 0.05, 0.05, 1.0 ) - property color diffuse: Qt.rgba( 0.7, 0.7, 0.7, 1.0 ) - property color specular: Qt.rgba( 0.01, 0.01, 0.01, 1.0 ) - property real shininess: 150.0 - property real alpha: 0.5 - - property alias sourceRgbArg: alphaEffect.sourceRgbArg - property alias destinationRgbArg: alphaEffect.destinationRgbArg - property alias sourceAlphaArg: alphaEffect.sourceAlphaArg - property alias destinationAlphaArg: alphaEffect.destinationAlphaArg - property alias blendFunctionArg: alphaEffect.blendFunctionArg - - parameters: [ - Parameter { name: "alpha"; value: root.alpha }, - Parameter { name: "ka"; value: Qt.vector3d(root.ambient.r, root.ambient.g, root.ambient.b) }, - Parameter { name: "kd"; value: Qt.vector3d(root.diffuse.r, root.diffuse.g, root.diffuse.b) }, - Parameter { name: "ks"; value: Qt.vector3d(root.specular.r, root.specular.g, root.specular.b) }, - Parameter { name: "shininess"; value: root.shininess } - ] - - effect: DefaultAlphaEffect { id: alphaEffect } -} - diff --git a/src/quick3d/imports/extras/defaults/qml/PhongMaterial.qml b/src/quick3d/imports/extras/defaults/qml/PhongMaterial.qml deleted file mode 100644 index 5b770a56d..000000000 --- a/src/quick3d/imports/extras/defaults/qml/PhongMaterial.qml +++ /dev/null @@ -1,59 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2014 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$ -** -****************************************************************************/ - -import Qt3D.Core 2.0 -import Qt3D.Render 2.0 - -Material { - id:root - property color ambient: Qt.rgba( 0.05, 0.05, 0.05, 1.0 ) - property color diffuse: Qt.rgba( 0.7, 0.7, 0.7, 1.0 ) - property color specular: Qt.rgba( 0.01, 0.01, 0.01, 1.0 ) - property real shininess: 150.0 - - parameters: [ - Parameter { name: "ka"; value: Qt.vector3d(root.ambient.r, root.ambient.g, root.ambient.b) }, - Parameter { name: "kd"; value: Qt.vector3d(root.diffuse.r, root.diffuse.g, root.diffuse.b) }, - Parameter { name: "ks"; value: Qt.vector3d(root.specular.r, root.specular.g, root.specular.b) }, - Parameter { name: "shininess"; value: root.shininess } - ] - - effect: DefaultEffect {} -} - diff --git a/src/quick3d/imports/extras/qt3dquick3dextrasplugin.cpp b/src/quick3d/imports/extras/qt3dquick3dextrasplugin.cpp index 7d695ea5b..38cc77503 100644 --- a/src/quick3d/imports/extras/qt3dquick3dextrasplugin.cpp +++ b/src/quick3d/imports/extras/qt3dquick3dextrasplugin.cpp @@ -41,6 +41,15 @@ #include <Qt3DExtras/qcuboidmesh.h> #include <Qt3DExtras/qconemesh.h> #include <Qt3DExtras/qcylindermesh.h> +#include <Qt3DExtras/qdiffusemapmaterial.h> +#include <Qt3DExtras/qdiffusespecularmapmaterial.h> +#include <Qt3DExtras/qgoochmaterial.h> +#include <Qt3DExtras/qnormaldiffusemapalphamaterial.h> +#include <Qt3DExtras/qnormaldiffusemapmaterial.h> +#include <Qt3DExtras/qnormaldiffusespecularmapmaterial.h> +#include <Qt3DExtras/qpervertexcolormaterial.h> +#include <Qt3DExtras/qphongalphamaterial.h> +#include <Qt3DExtras/qphongmaterial.h> #include <Qt3DExtras/qplanemesh.h> #include <Qt3DExtras/qspheremesh.h> #include <Qt3DExtras/qtorusmesh.h> @@ -61,15 +70,6 @@ static const struct { 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 }, // Effects { "DefaultEffect", 2, 0 }, @@ -88,6 +88,17 @@ static const struct { void Qt3DQuick3DExtrasPlugin::registerTypes(const char *uri) { + // Materials + qmlRegisterType<Qt3DExtras::QPhongMaterial>(uri, 2, 0, "PhongMaterial"); + qmlRegisterType<Qt3DExtras::QPhongAlphaMaterial>(uri, 2, 0, "PhongAlphaMaterial"); + qmlRegisterType<Qt3DExtras::QDiffuseMapMaterial>(uri, 2, 0, "DiffuseMapMaterial"); + qmlRegisterType<Qt3DExtras::QDiffuseSpecularMapMaterial>(uri, 2, 0, "DiffuseSpecularMapMaterial"); + qmlRegisterType<Qt3DExtras::QNormalDiffuseMapAlphaMaterial>(uri, 2, 0, "NormalDiffuseMapAlphaMaterial"); + qmlRegisterType<Qt3DExtras::QNormalDiffuseMapMaterial>(uri, 2, 0, "NormalDiffuseMapMaterial"); + qmlRegisterType<Qt3DExtras::QNormalDiffuseSpecularMapMaterial>(uri, 2, 0, "NormalDiffuseSpecularMapMaterial"); + qmlRegisterType<Qt3DExtras::QPerVertexColorMaterial>(uri, 2, 0, "PerVertexColorMaterial"); + qmlRegisterType<Qt3DExtras::QGoochMaterial>(uri, 2, 0, "GoochMaterial"); + // Meshes qmlRegisterType<Qt3DExtras::QConeMesh>(uri, 2, 0, "ConeMesh"); qmlRegisterType<Qt3DExtras::QConeGeometry>(uri, 2, 0, "ConeGeometry"); |