diff options
author | Robert Brock <robert.brock@kdab.com> | 2016-05-09 12:18:03 +0100 |
---|---|---|
committer | Sean Harmer <sean.harmer@kdab.com> | 2016-05-15 13:45:17 +0000 |
commit | a8cad56f61c94b0bb8dc6883e697b6619e922642 (patch) | |
tree | 4608933d60acf8222e6cacfc84a753c41e1afba9 /examples | |
parent | b24a2479914004d897048ab096d946677b73ff1e (diff) |
Moved tessellation-modes example to manual test
Part of an examples cleanup
Change-Id: I80f5927b91a31f86ac92cf357604783948c34a30
Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
Diffstat (limited to 'examples')
22 files changed, 0 insertions, 1237 deletions
diff --git a/examples/qt3d/qt3d.pro b/examples/qt3d/qt3d.pro index 1b359a4e8..961c3b183 100644 --- a/examples/qt3d/qt3d.pro +++ b/examples/qt3d/qt3d.pro @@ -5,7 +5,6 @@ SUBDIRS += \ simple-cpp \ multiviewport \ wireframe \ - tessellation-modes \ shadow-map-qml \ materials \ wave \ diff --git a/examples/qt3d/tessellation-modes/BasicCamera.qml b/examples/qt3d/tessellation-modes/BasicCamera.qml deleted file mode 100644 index 213054ec3..000000000 --- a/examples/qt3d/tessellation-modes/BasicCamera.qml +++ /dev/null @@ -1,65 +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: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 - -Camera { - id: mainCamera - objectName: "mainCamera" - projectionType: CameraLens.PerspectiveProjection - fieldOfView: 22.5 - aspectRatio: _window.width / _window.height - onAspectRatioChanged: console.log( "aspectRatio = " + aspectRatio ) - nearPlane: 0.01 - farPlane: 1000.0 - viewCenter: Qt.vector3d( 0.0, 0.0, 0.0 ) - upVector: Qt.vector3d( 0.0, 1.0, 0.0 ) -} diff --git a/examples/qt3d/tessellation-modes/TessellatedQuad.qml b/examples/qt3d/tessellation-modes/TessellatedQuad.qml deleted file mode 100644 index bc599bcd8..000000000 --- a/examples/qt3d/tessellation-modes/TessellatedQuad.qml +++ /dev/null @@ -1,78 +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: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 QtQuick 2.1 as QQ2 -import Qt3D.Core 2.0 -import Qt3D.Render 2.0 -import Qt3D.Examples 1.0 - -Entity { - id: root - - property real x: 0.0 - property real y: 0.0 - property real z: 0.0 - property real scale: 1.0 - property real theta: 0.0 - property Material material - - components: [ transform, mesh, root.material ] - - Transform { - id: transform - translation: Qt.vector3d(root.x, root.y, root.z) - rotation: fromAxisAndAngle(Qt.vector3d(0, 1, 0), root.theta) - scale: root.scale - } - - TessellatedQuadMesh { - id: mesh - } -} diff --git a/examples/qt3d/tessellation-modes/TessellatedWireframeEffect.qml b/examples/qt3d/tessellation-modes/TessellatedWireframeEffect.qml deleted file mode 100644 index 936ad5536..000000000 --- a/examples/qt3d/tessellation-modes/TessellatedWireframeEffect.qml +++ /dev/null @@ -1,103 +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: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 - -Effect { - id: root - - // It's expected that users of this will specify the tessellation control and evaluation - // shaders and if necessary suitable replacements for the other stages - property alias vertexShaderCode: program.vertexShaderCode - property alias tessellationControlShaderCode: program.tessellationControlShaderCode - property alias tessellationEvaluationShaderCode: program.tessellationEvaluationShaderCode - property alias geometryShaderCode: program.geometryShaderCode - property alias fragmentShaderCode: program.fragmentShaderCode - property alias shaderProgram: program - - parameters: [ - Parameter { name: "ka"; value: Qt.vector3d( 0.1, 0.1, 0.1 ) }, - Parameter { name: "kd"; value: Qt.vector3d( 0.7, 0.7, 0.7 ) }, - Parameter { name: "ks"; value: Qt.vector3d( 0.95, 0.95, 0.95 ) }, - Parameter { name: "shininess"; value: 150.0 } - ] - - techniques: [ - Technique { - graphicsApiFilter { - api: GraphicsApiFilter.OpenGL - profile: GraphicsApiFilter.CoreProfile - majorVersion: 4 - minorVersion: 0 - } - - filterKeys: [ FilterKey { name: "renderingStyle"; value: "forward" } ] - - parameters: [ - Parameter { name: "light.position"; value: Qt.vector4d(0.0, 0.0, 0.0, 1.0) }, - Parameter { name: "light.intensity"; value: Qt.vector3d(1.0, 1.0, 1.0) }, - Parameter { name: "line.width"; value: 0.8 }, - Parameter { name: "line.color"; value: Qt.vector4d(1.0, 1.0, 1.0, 1.0) } - ] - - renderPasses: [ - RenderPass { - shaderProgram: ShaderProgram { - id: program - vertexShaderCode: loadSource("qrc:/shaders/passthru.vert") - geometryShaderCode: loadSource("qrc:/shaders/robustwireframe.geom") - fragmentShaderCode: loadSource("qrc:/shaders/phongwireframe.frag") - } - } - ] - } - ] -} diff --git a/examples/qt3d/tessellation-modes/TessellatedWireframeMaterial.qml b/examples/qt3d/tessellation-modes/TessellatedWireframeMaterial.qml deleted file mode 100644 index af992b170..000000000 --- a/examples/qt3d/tessellation-modes/TessellatedWireframeMaterial.qml +++ /dev/null @@ -1,76 +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: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 - -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.95, 0.95, 0.95, 1.0 ) - property real shininess: 150.0 - property real lineWidth: 1.0 - property color lineColor: Qt.rgba( 1.0, 1.0, 1.0, 1.0 ) - property var innerTessLevel: [1.0, 1.0 ] - property var outerTessLevel: [1.0, 1.0, 1.0, 1.0] - - parameters: [ - Parameter { name: "ambient"; value: Qt.vector3d(root.ambient.r, root.ambient.g, root.ambient.b) }, - Parameter { name: "diffuse"; value: Qt.vector3d(root.diffuse.r, root.diffuse.g, root.diffuse.b) }, - Parameter { name: "specular"; value: Qt.vector3d(root.specular.r, root.specular.g, root.specular.b) }, - Parameter { name: "shininess"; value: root.shininess }, - Parameter { name: "line.width"; value: root.lineWidth }, - Parameter { name: "line.color"; value: root.lineColor }, - Parameter { name: "inner[0]"; value: root.innerTessLevel }, - Parameter { name: "outer[0]"; value: root.outerTessLevel } - ] -} diff --git a/examples/qt3d/tessellation-modes/doc/src/tessellation-modes.qdoc b/examples/qt3d/tessellation-modes/doc/src/tessellation-modes.qdoc deleted file mode 100644 index c485c5f0e..000000000 --- a/examples/qt3d/tessellation-modes/doc/src/tessellation-modes.qdoc +++ /dev/null @@ -1,32 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 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 tessellation-modes - \title Qt 3D: Tessellation Modes QML Example - \ingroup qt3d-examples-qml -*/ diff --git a/examples/qt3d/tessellation-modes/main.cpp b/examples/qt3d/tessellation-modes/main.cpp deleted file mode 100644 index a0eae5175..000000000 --- a/examples/qt3d/tessellation-modes/main.cpp +++ /dev/null @@ -1,78 +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: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$ -** -****************************************************************************/ - -#include "tessellatedquadmesh.h" -#include <Qt3DQuickExtras/qt3dquickwindow.h> -#include <Qt3DQuick/QQmlAspectEngine> -#include <QGuiApplication> -#include <qqml.h> -#include <QQmlContext> -#include <QQmlEngine> - -int main(int argc, char* argv[]) -{ - QGuiApplication app(argc, argv); - - Qt3DExtras::Quick::Qt3DQuickWindow view; - // Register our custom types - qmlRegisterType<TessellatedQuadMesh>("Qt3D.Examples", 1, 0, "TessellatedQuadMesh"); - - // Expose the window as a context property so we can set the aspect ratio - view.engine()->qmlEngine()->rootContext()->setContextProperty("_window", &view); - - // There should be some synchronising mechanism to make sure - // the source is set after all aspects have been completely initialized - // Otherwise we might encounter cases where an Aspect's QML elements have - // not yet been registered - view.setSource(QUrl("qrc:/main.qml")); - view.show(); - - return app.exec(); -} diff --git a/examples/qt3d/tessellation-modes/main.qml b/examples/qt3d/tessellation-modes/main.qml deleted file mode 100644 index e37150078..000000000 --- a/examples/qt3d/tessellation-modes/main.qml +++ /dev/null @@ -1,126 +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: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 QtQuick 2.1 as QQ2 -import Qt3D.Core 2.0 -import Qt3D.Render 2.0 -import Qt3D.Input 2.0 -import Qt3D.Extras 2.0 - -Entity { - id: root - objectName: "root" - - // Use the renderer configuration specified in ForwardRenderer.qml - // and render from the mainCamera - components: [ - RenderSettings { - activeFrameGraph: ForwardRenderer { - id: renderer - camera: mainCamera - clearColor: "black" - } - }, - // Event Source will be set by the Qt3DQuickWindow - InputSettings { } - ] - - BasicCamera { - id: mainCamera - position: Qt.vector3d( 0.0, 0.0, 10.0 ) - } - - OrbitCameraController { camera: mainCamera } - - TessellatedWireframeMaterial { - id: quadMaterial - ambient: Qt.rgba( 0.2, 0.0, 0.0, 1.0 ) - diffuse: Qt.rgba( 0.8, 0.0, 0.0, 1.0 ) - - property real innerLevel : 1.0 - property real outerLevel : 1.0 - - innerTessLevel : [innerLevel, innerLevel] - outerTessLevel : [outerLevel, outerLevel, outerLevel, outerLevel] - - effect: TessellatedWireframeEffect { - tessellationControlShaderCode: shaderProgram.loadSource("qrc:/shaders/quads.tcs") - tessellationEvaluationShaderCode: shaderProgram.loadSource("qrc:/shaders/quads.tes") - } - - QQ2.SequentialAnimation { - loops: QQ2.Animation.Infinite - running: true - - QQ2.NumberAnimation { - target: quadMaterial; - properties: "innerLevel,outerLevel"; - duration: 1000; - from: 1.0 - to: 20.0 - } - - QQ2.NumberAnimation { - target: quadMaterial; - properties: "innerLevel,outerLevel"; - duration: 1000; - from: 20.0 - to: 1.0 - } - } - } - - TessellatedQuad { - id: quad - material: quadMaterial - } - - // TODO: Add examples for triangle and isoline tessellation modes -} diff --git a/examples/qt3d/tessellation-modes/shaders/flat.frag b/examples/qt3d/tessellation-modes/shaders/flat.frag deleted file mode 100644 index 6e596d4d6..000000000 --- a/examples/qt3d/tessellation-modes/shaders/flat.frag +++ /dev/null @@ -1,12 +0,0 @@ -#version 400 core - -in Vertex { - vec3 color; -} fs_in; - -out vec4 fragColor; - -void main() -{ - fragColor = vec4( fs_in.color, 1.0 ); -} diff --git a/examples/qt3d/tessellation-modes/shaders/isolines.tcs b/examples/qt3d/tessellation-modes/shaders/isolines.tcs deleted file mode 100644 index 624af51cc..000000000 --- a/examples/qt3d/tessellation-modes/shaders/isolines.tcs +++ /dev/null @@ -1,15 +0,0 @@ -#version 400 core - -layout( vertices = 4 ) out; - -uniform float outer[4] = float[]( 1.0, 1.0, 1.0, 1.0 ); - -void main() -{ - // Pass along the vertex position unmodified - gl_out[gl_InvocationID].gl_Position = gl_in[gl_InvocationID].gl_Position; - - // Set the tessellation levels - gl_TessLevelOuter[0] = outer[0]; // number of isolines - gl_TessLevelOuter[1] = outer[1]; // divisions along isoline -} diff --git a/examples/qt3d/tessellation-modes/shaders/isolines.tes b/examples/qt3d/tessellation-modes/shaders/isolines.tes deleted file mode 100644 index f6b984bc8..000000000 --- a/examples/qt3d/tessellation-modes/shaders/isolines.tes +++ /dev/null @@ -1,74 +0,0 @@ -#version 400 core - -layout( isolines, fractional_even_spacing, ccw ) in; - -out Vertex { - vec3 color; -} te_out; - -uniform mat4 modelViewMatrix; -uniform mat3 normalMatrix; -uniform mat4 projectionMatrix; -uniform mat4 mvp; - -// Calculate RGB triplet from HSV -vec3 hsvToRGB( float h, float s, float v ) -{ - if ( s <= 0.0 ) - return vec3( v ); - - h = h * 6.0; - float c = v * s; - float x = ( 1.0 - abs( ( mod( h, 2 ) - 1 ) ) ) * c; - float m = v - c; - float r = 0.0; - float g = 0.0; - float b = 0.0; - - if ( h < 1.0 ) { r = c; g = x; b = 0.0;} - else if ( h < 2.0 ) { r = x; g = c; b = 0.0; } - else if ( h < 3.0 ) { r = 0.0; g = c; b = x; } - else if ( h < 4.0 ) { r = 0.0; g = x; b = c; } - else if ( h < 5.0 ) { r = x; g = 0.0; b = c; } - else { r = c; g = 0.0; b = x; } - - return vec3( r + m, g + m, b + m ); -} - -void main() -{ - float u = gl_TessCoord.x; - float v = gl_TessCoord.y; - - vec4 a = gl_in[0].gl_Position; - vec4 b = gl_in[1].gl_Position; - vec4 c = gl_in[2].gl_Position; - vec4 d = gl_in[3].gl_Position; - - // Use the (u,v) parametric coords to calculate the vertex. - // u is the position along an isoline - // v is isoline number - - // Let's make a sinusoidal curve as a function of u that varies - // in the v direction which we will define as orthogonal to u - - // Interpolate in u along top and bottom edges of the patch - vec4 q0 = mix( a, b, u ); - vec4 q1 = mix( d, c, u ); - - // Interpolate in v between the above positions. This gives the - // nominal position for our vertex - vec4 p = mix( q0, q1, v ); - - // Find "vertical" direction - vec4 vBasis = normalize( q1 - q0 ); - - // Offset vertex in this direction using sinusoid - vec4 pos = p + 0.2 * vBasis * sin( 20.0 * u ); - - // Use a hue value based on v - te_out.color = hsvToRGB( v, 1.0, 1.0 ); - - // Transform to clip-space - gl_Position = mvp * pos; -} diff --git a/examples/qt3d/tessellation-modes/shaders/passthru.vert b/examples/qt3d/tessellation-modes/shaders/passthru.vert deleted file mode 100644 index 71875a55f..000000000 --- a/examples/qt3d/tessellation-modes/shaders/passthru.vert +++ /dev/null @@ -1,10 +0,0 @@ -#version 400 core - -in vec3 vertexPosition; - -void main() -{ - // We do the transformations later in the - // tessellation evaluation shader - gl_Position = vec4( vertexPosition, 1.0 ); -} diff --git a/examples/qt3d/tessellation-modes/shaders/phongwireframe.frag b/examples/qt3d/tessellation-modes/shaders/phongwireframe.frag deleted file mode 100644 index 4fd62007d..000000000 --- a/examples/qt3d/tessellation-modes/shaders/phongwireframe.frag +++ /dev/null @@ -1,108 +0,0 @@ -#version 400 core - -uniform struct LightInfo { - vec4 position; - vec3 intensity; -} light; - -uniform struct LineInfo { - float width; - vec4 color; -} line; - -uniform vec3 ka; // Ambient reflectivity -uniform vec3 kd; // Diffuse reflectivity -uniform vec3 ks; // Specular reflectivity -uniform float shininess; // Specular shininess factor - -in WireframeVertex { - vec3 position; - vec3 normal; - noperspective vec4 edgeA; - noperspective vec4 edgeB; - flat int configuration; -} fs_in; - -out vec4 fragColor; - -vec3 adsModel( const in vec3 pos, const in vec3 n ) -{ - // Calculate the vector from the light to the fragment - vec3 s = normalize( vec3( light.position ) - pos ); - - // Calculate the vector from the fragment to the eye position (the - // origin since this is in "eye" or "camera" space - vec3 v = normalize( -pos ); - - // Refleft the light beam using the normal at this fragment - vec3 r = reflect( -s, n ); - - // Calculate the diffus component - vec3 diffuse = vec3( max( dot( s, n ), 0.0 ) ); - - // Calculate the specular component - vec3 specular = vec3( pow( max( dot( r, v ), 0.0 ), shininess ) ); - - // Combine the ambient, diffuse and specular contributions - return light.intensity * ( ka + kd * diffuse + ks * specular ); -} - -vec4 shadeLine( const in vec4 color ) -{ - // Find the smallest distance between the fragment and a triangle edge - float d; - if ( fs_in.configuration == 0 ) - { - // Common configuration - d = min( fs_in.edgeA.x, fs_in.edgeA.y ); - d = min( d, fs_in.edgeA.z ); - } - else - { - // Handle configuration where screen space projection breaks down - // Compute and compare the squared distances - vec2 AF = gl_FragCoord.xy - fs_in.edgeA.xy; - float sqAF = dot( AF, AF ); - float AFcosA = dot( AF, fs_in.edgeA.zw ); - d = abs( sqAF - AFcosA * AFcosA ); - - vec2 BF = gl_FragCoord.xy - fs_in.edgeB.xy; - float sqBF = dot( BF, BF ); - float BFcosB = dot( BF, fs_in.edgeB.zw ); - d = min( d, abs( sqBF - BFcosB * BFcosB ) ); - - // Only need to care about the 3rd edge for some configurations. - if ( fs_in.configuration == 1 || fs_in.configuration == 2 || fs_in.configuration == 4 ) - { - float AFcosA0 = dot( AF, normalize( fs_in.edgeB.xy - fs_in.edgeA.xy ) ); - d = min( d, abs( sqAF - AFcosA0 * AFcosA0 ) ); - } - - d = sqrt( d ); - } - - // Blend between line color and phong color - float mixVal; - if ( d < line.width - 1.0 ) - { - mixVal = 1.0; - } - else if ( d > line.width + 1.0 ) - { - mixVal = 0.0; - } - else - { - float x = d - ( line.width - 1.0 ); - mixVal = exp2( -2.0 * ( x * x ) ); - } - - return mix( color, line.color, mixVal ); -} - -void main() -{ - // Calculate the color from the phong model - vec4 color = vec4( adsModel( fs_in.position, normalize( fs_in.normal ) ), 1.0 ); - fragColor = shadeLine( color ); -} diff --git a/examples/qt3d/tessellation-modes/shaders/quads.tcs b/examples/qt3d/tessellation-modes/shaders/quads.tcs deleted file mode 100644 index 367195522..000000000 --- a/examples/qt3d/tessellation-modes/shaders/quads.tcs +++ /dev/null @@ -1,21 +0,0 @@ -#version 400 core - -layout( vertices = 4 ) out; - -uniform float inner[2] = float[]( 10.0, 10.0 ); -uniform float outer[4] = float[]( 1.0, 1.0, 1.0, 1.0 ); - -void main() -{ - // Pass along the vertex position unmodified - gl_out[gl_InvocationID].gl_Position = gl_in[gl_InvocationID].gl_Position; - - // Set the tessellation levels from the uniforms - gl_TessLevelOuter[0] = outer[0]; - gl_TessLevelOuter[1] = outer[1]; - gl_TessLevelOuter[2] = outer[2]; - gl_TessLevelOuter[3] = outer[3]; - - gl_TessLevelInner[0] = inner[0]; - gl_TessLevelInner[1] = inner[1]; -} diff --git a/examples/qt3d/tessellation-modes/shaders/quads.tes b/examples/qt3d/tessellation-modes/shaders/quads.tes deleted file mode 100644 index a3fd48441..000000000 --- a/examples/qt3d/tessellation-modes/shaders/quads.tes +++ /dev/null @@ -1,40 +0,0 @@ -#version 400 core - -layout( quads, fractional_even_spacing, ccw ) in; - -out EyeSpaceVertex { - vec3 position; - vec3 normal; -} te_out; - -uniform mat4 modelView; -uniform mat3 modelViewNormal; -uniform mat4 projectionMatrix; -uniform mat4 mvp; - -void main() -{ - float u = gl_TessCoord.x; - float v = gl_TessCoord.y; - - vec4 p00 = gl_in[0].gl_Position; - vec4 p10 = gl_in[1].gl_Position; - vec4 p11 = gl_in[2].gl_Position; - vec4 p01 = gl_in[3].gl_Position; - - // Linearly interpolate to the vertex position using the - // (u,v) barycentric coords - vec4 pos = p00 * ( 1.0 - u ) * ( 1.0 - v ) - + p10 * u * ( 1.0 - v ) - + p01 * v * ( 1.0 - u ) - + p11 * u * v; - - // Transform to eye space (for lighting calcs) - te_out.position = vec3( modelView * pos ); - - // Assume normal points along z - te_out.normal = normalize( modelViewNormal * vec3( 0.0, 0.0, 1.0 ) ); - - // Transform to clip-space - gl_Position = mvp * pos; -} diff --git a/examples/qt3d/tessellation-modes/shaders/robustwireframe.geom b/examples/qt3d/tessellation-modes/shaders/robustwireframe.geom deleted file mode 100644 index 02eaaf398..000000000 --- a/examples/qt3d/tessellation-modes/shaders/robustwireframe.geom +++ /dev/null @@ -1,131 +0,0 @@ -#version 400 core - -layout( triangles ) in; -layout( triangle_strip, max_vertices = 3 ) out; - -in EyeSpaceVertex { - vec3 position; - vec3 normal; -} gs_in[]; - -out WireframeVertex { - vec3 position; - vec3 normal; - noperspective vec4 edgeA; - noperspective vec4 edgeB; - flat int configuration; -} gs_out; - -uniform mat4 viewportMatrix; - -const int infoA[] = int[]( 0, 0, 0, 0, 1, 1, 2 ); -const int infoB[] = int[]( 1, 1, 2, 0, 2, 1, 2 ); -const int infoAd[] = int[]( 2, 2, 1, 1, 0, 0, 0 ); -const int infoBd[] = int[]( 2, 2, 1, 2, 0, 2, 1 ); - -vec2 transformToViewport( const in vec4 p ) -{ - return vec2( viewportMatrix * ( p / p.w ) ); -} - -void main() -{ - gs_out.configuration = int(gl_in[0].gl_Position.z < 0) * int(4) - + int(gl_in[1].gl_Position.z < 0) * int(2) - + int(gl_in[2].gl_Position.z < 0); - - // If all vertices are behind us, cull the primitive - if (gs_out.configuration == 7) - return; - - // Transform each vertex into viewport space - vec2 p[3]; - p[0] = transformToViewport( gl_in[0].gl_Position ); - p[1] = transformToViewport( gl_in[1].gl_Position ); - p[2] = transformToViewport( gl_in[2].gl_Position ); - - if (gs_out.configuration == 0) - { - // Common configuration where all vertices are within the viewport - gs_out.edgeA = vec4(0.0); - gs_out.edgeB = vec4(0.0); - - // Calculate lengths of 3 edges of triangle - float a = length( p[1] - p[2] ); - float b = length( p[2] - p[0] ); - float c = length( p[1] - p[0] ); - - // Calculate internal angles using the cosine rule - float alpha = acos( ( b * b + c * c - a * a ) / ( 2.0 * b * c ) ); - float beta = acos( ( a * a + c * c - b * b ) / ( 2.0 * a * c ) ); - - // Calculate the perpendicular distance of each vertex from the opposing edge - float ha = abs( c * sin( beta ) ); - float hb = abs( c * sin( alpha ) ); - float hc = abs( b * sin( alpha ) ); - - // Now add this perpendicular distance as a per-vertex property in addition to - // the position and normal calculated in the vertex shader. - - // Vertex 0 (a) - gs_out.edgeA = vec4( ha, 0.0, 0.0, 0.0 ); - gs_out.normal = gs_in[0].normal; - gs_out.position = gs_in[0].position; - gl_Position = gl_in[0].gl_Position; - EmitVertex(); - - // Vertex 1 (b) - gs_out.edgeA = vec4( 0.0, hb, 0.0, 0.0 ); - gs_out.normal = gs_in[1].normal; - gs_out.position = gs_in[1].position; - gl_Position = gl_in[1].gl_Position; - EmitVertex(); - - // Vertex 2 (c) - gs_out.edgeA = vec4( 0.0, 0.0, hc, 0.0 ); - gs_out.normal = gs_in[2].normal; - gs_out.position = gs_in[2].position; - gl_Position = gl_in[2].gl_Position; - EmitVertex(); - - // Finish the primitive off - EndPrimitive(); - } - else - { - // Viewport projection breaks down for one or two vertices. - // Caclulate what we can here and defer rest to fragment shader. - // Since this is coherent for the entire primitive the conditional - // in the fragment shader is still cheap as all concurrent - // fragment shader invocations will take the same code path. - - // Copy across the viewport-space points for the (up to) two vertices - // in the viewport - gs_out.edgeA.xy = p[infoA[gs_out.configuration]]; - gs_out.edgeB.xy = p[infoB[gs_out.configuration]]; - - // Copy across the viewport-space edge vectors for the (up to) two vertices - // in the viewport - gs_out.edgeA.zw = normalize( gs_out.edgeA.xy - p[ infoAd[gs_out.configuration] ] ); - gs_out.edgeB.zw = normalize( gs_out.edgeB.xy - p[ infoBd[gs_out.configuration] ] ); - - // Pass through the other vertex attributes - gs_out.normal = gs_in[0].normal; - gs_out.position = gs_in[0].position; - gl_Position = gl_in[0].gl_Position; - EmitVertex(); - - gs_out.normal = gs_in[1].normal; - gs_out.position = gs_in[1].position; - gl_Position = gl_in[1].gl_Position; - EmitVertex(); - - gs_out.normal = gs_in[2].normal; - gs_out.position = gs_in[2].position; - gl_Position = gl_in[2].gl_Position; - EmitVertex(); - - // Finish the primitive off - EndPrimitive(); - } -} diff --git a/examples/qt3d/tessellation-modes/shaders/triangles.tcs b/examples/qt3d/tessellation-modes/shaders/triangles.tcs deleted file mode 100644 index c311796fd..000000000 --- a/examples/qt3d/tessellation-modes/shaders/triangles.tcs +++ /dev/null @@ -1,19 +0,0 @@ -#version 400 core - -layout( vertices = 3 ) out; - -uniform float inner[2] = float[]( 1.0, 1.0 ); -uniform float outer[4] = float[]( 1.0, 1.0, 1.0, 1.0 ); - -void main() -{ - // Pass along the vertex position unmodified - gl_out[gl_InvocationID].gl_Position = gl_in[gl_InvocationID].gl_Position; - - // Set the tessellation levels from the uniforms - gl_TessLevelOuter[0] = outer[0]; - gl_TessLevelOuter[1] = outer[1]; - gl_TessLevelOuter[2] = outer[2]; - - gl_TessLevelInner[0] = inner[0]; -} diff --git a/examples/qt3d/tessellation-modes/shaders/triangles.tes b/examples/qt3d/tessellation-modes/shaders/triangles.tes deleted file mode 100644 index c833e9587..000000000 --- a/examples/qt3d/tessellation-modes/shaders/triangles.tes +++ /dev/null @@ -1,39 +0,0 @@ -#version 400 core - -layout( triangles, fractional_even_spacing, ccw ) in; - -out EyeSpaceVertex { - vec3 position; - vec3 normal; -} te_out; - -uniform mat4 modelViewMatrix; -uniform mat3 normalMatrix; -uniform mat4 projectionMatrix; -uniform mat4 mvp; - -void main() -{ - float u = gl_TessCoord.x; - float v = gl_TessCoord.y; - float w = gl_TessCoord.z; - - vec4 p0 = gl_in[0].gl_Position; - vec4 p1 = gl_in[1].gl_Position; - vec4 p2 = gl_in[2].gl_Position; - - // Linearly interpolate to the vertex position using the - // (u,v) barycentric coords - vec4 pos = (u * p0) - + (v * p1) - + (w * p2); - - // Transform to eye space (for lighting calcs) - te_out.position = vec3( modelViewMatrix * pos ); - - // Assume normal points along z - te_out.normal = normalize( normalMatrix * vec3( 0.0, 0.0, 1.0 ) ); - - // Transform to clip-space - gl_Position = mvp * pos; -} diff --git a/examples/qt3d/tessellation-modes/tessellatedquadmesh.cpp b/examples/qt3d/tessellation-modes/tessellatedquadmesh.cpp deleted file mode 100644 index e98ee8936..000000000 --- a/examples/qt3d/tessellation-modes/tessellatedquadmesh.cpp +++ /dev/null @@ -1,104 +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: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$ -** -****************************************************************************/ - -#include "tessellatedquadmesh.h" - -#include <Qt3DRender/qattribute.h> -#include <Qt3DRender/qbuffer.h> -#include <Qt3DRender/qgeometry.h> - -class TessellatedGeometry : public Qt3DRender::QGeometry -{ - Q_OBJECT -public: - TessellatedGeometry(Qt3DCore::QNode *parent = nullptr) - : Qt3DRender::QGeometry(parent) - , m_positionAttribute(new Qt3DRender::QAttribute(this)) - , m_vertexBuffer(new Qt3DRender::QBuffer(Qt3DRender::QBuffer::VertexBuffer, this)) - { - const float positionData[] = { - -0.8f, -0.8f, 0.0f, - 0.8f, -0.8f, 0.0f, - 0.8f, 0.8f, 0.0f, - -0.8f, 0.8f, 0.0f - }; - - const int nVerts = 4; - const int size = nVerts * 3 * sizeof(float); - QByteArray positionBytes; - positionBytes.resize(size); - memcpy(positionBytes.data(), positionData, size); - - m_vertexBuffer->setData(positionBytes); - - m_positionAttribute->setName(Qt3DRender::QAttribute::defaultPositionAttributeName()); - m_positionAttribute->setDataType(Qt3DRender::QAttribute::Float); - m_positionAttribute->setDataSize(3); - m_positionAttribute->setCount(nVerts); - m_positionAttribute->setByteStride(3 * sizeof(float)); - m_positionAttribute->setBuffer(m_vertexBuffer); - - addAttribute(m_positionAttribute); - } - -private: - Qt3DRender::QAttribute *m_positionAttribute; - Qt3DRender::QBuffer *m_vertexBuffer; -}; - -TessellatedQuadMesh::TessellatedQuadMesh(Qt3DCore::QNode *parent) - : Qt3DRender::QGeometryRenderer(parent) -{ - setPrimitiveType(Qt3DRender::QGeometryRenderer::Patches); - setVerticesPerPatch(4); - setGeometry(new TessellatedGeometry(this)); -} - -#include "tessellatedquadmesh.moc" diff --git a/examples/qt3d/tessellation-modes/tessellatedquadmesh.h b/examples/qt3d/tessellation-modes/tessellatedquadmesh.h deleted file mode 100644 index e60c54e86..000000000 --- a/examples/qt3d/tessellation-modes/tessellatedquadmesh.h +++ /dev/null @@ -1,63 +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: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$ -** -****************************************************************************/ - -#ifndef TESSELLATEDQUAD_H -#define TESSELLATEDQUAD_H - -#include <Qt3DRender/qgeometryrenderer.h> - -class TessellatedQuadMesh : public Qt3DRender::QGeometryRenderer -{ - Q_OBJECT -public: - explicit TessellatedQuadMesh(Qt3DCore::QNode *parent = 0); -}; - -#endif // TESSELLATEDQUAD_H diff --git a/examples/qt3d/tessellation-modes/tessellation-modes.pro b/examples/qt3d/tessellation-modes/tessellation-modes.pro deleted file mode 100644 index c1691e607..000000000 --- a/examples/qt3d/tessellation-modes/tessellation-modes.pro +++ /dev/null @@ -1,23 +0,0 @@ -!include( ../examples.pri ) { - error( "Couldn't find the examples.pri file!" ) -} - -QT += 3dcore 3drender 3dinput 3dquick qml quick 3dquickextras - -HEADERS += \ - tessellatedquadmesh.h - -SOURCES += \ - main.cpp \ - tessellatedquadmesh.cpp - -OTHER_FILES += \ - main.qml \ - BasicCamera.qml \ - TessellatedWireframeEffect.qml \ - TessellatedWireframeMaterial.qml \ - TessellatedQuad.qml \ - shaders/* - -RESOURCES += \ - tessellation-modes.qrc diff --git a/examples/qt3d/tessellation-modes/tessellation-modes.qrc b/examples/qt3d/tessellation-modes/tessellation-modes.qrc deleted file mode 100644 index 466c9307a..000000000 --- a/examples/qt3d/tessellation-modes/tessellation-modes.qrc +++ /dev/null @@ -1,19 +0,0 @@ -<RCC> - <qresource prefix="/"> - <file>main.qml</file> - <file>BasicCamera.qml</file> - <file>TessellatedWireframeEffect.qml</file> - <file>TessellatedWireframeMaterial.qml</file> - <file>shaders/flat.frag</file> - <file>shaders/isolines.tcs</file> - <file>shaders/isolines.tes</file> - <file>shaders/passthru.vert</file> - <file>shaders/phongwireframe.frag</file> - <file>shaders/quads.tcs</file> - <file>shaders/quads.tes</file> - <file>shaders/triangles.tcs</file> - <file>shaders/triangles.tes</file> - <file>shaders/robustwireframe.geom</file> - <file>TessellatedQuad.qml</file> - </qresource> -</RCC> |