diff options
author | Mike Krus <mike.krus@kdab.com> | 2018-01-15 21:00:25 +0000 |
---|---|---|
committer | Mike Krus <mike.krus@kdab.com> | 2018-02-01 21:26:34 +0000 |
commit | 2161118a82d0ddb91cbe78cdf530970409a9d204 (patch) | |
tree | 23bccea849edbbbeaf85c7cab5bc96e521b98aae | |
parent | 227733c5305874a3620dfed1d4b4c0465dda5145 (diff) |
Manual unit test for ray casting
Change-Id: Icdd27b5ef6b50512e4af40d68d1ba7525f56b991
Reviewed-by: Paul Lemire <paul.lemire@kdab.com>
Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
-rw-r--r-- | tests/manual/manual.pro | 3 | ||||
-rw-r--r-- | tests/manual/raycasting-qml/CylinderEntity.qml | 81 | ||||
-rw-r--r-- | tests/manual/raycasting-qml/LineEntity.qml | 114 | ||||
-rw-r--r-- | tests/manual/raycasting-qml/LineMaterial.qml | 143 | ||||
-rw-r--r-- | tests/manual/raycasting-qml/main.cpp | 63 | ||||
-rw-r--r-- | tests/manual/raycasting-qml/main.qml | 163 | ||||
-rw-r--r-- | tests/manual/raycasting-qml/main.qrc | 14 | ||||
-rw-r--r-- | tests/manual/raycasting-qml/raycasting-qml.pro | 10 | ||||
-rw-r--r-- | tests/manual/raycasting-qml/shaders/es2/simpleColor.frag | 10 | ||||
-rw-r--r-- | tests/manual/raycasting-qml/shaders/es2/simpleColor.vert | 15 | ||||
-rw-r--r-- | tests/manual/raycasting-qml/shaders/gl3/simpleColor.frag | 11 | ||||
-rw-r--r-- | tests/manual/raycasting-qml/shaders/gl3/simpleColor.vert | 11 |
12 files changed, 637 insertions, 1 deletions
diff --git a/tests/manual/manual.pro b/tests/manual/manual.pro index 724cc0fb3..b1e16fc0b 100644 --- a/tests/manual/manual.pro +++ b/tests/manual/manual.pro @@ -55,7 +55,8 @@ SUBDIRS += \ skinned-mesh \ proximityfilter \ rendercapture-qml-fbo \ - blitframebuffer-qml + blitframebuffer-qml \ + raycasting-qml qtHaveModule(widgets): { SUBDIRS += \ diff --git a/tests/manual/raycasting-qml/CylinderEntity.qml b/tests/manual/raycasting-qml/CylinderEntity.qml new file mode 100644 index 000000000..4bae3c207 --- /dev/null +++ b/tests/manual/raycasting-qml/CylinderEntity.qml @@ -0,0 +1,81 @@ +/**************************************************************************** +** +** Copyright (C) 2018 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 +import Qt3D.Input 2.0 +import Qt3D.Extras 2.0 + +Entity { + id: root + + property alias translation: transform.translation + property alias color: material.diffuse + + components: [ mesh, material, transform ] + + CylinderMesh { + id: mesh + radius: 1 + length: 3 + rings: 100 + slices: 20 + } + + Transform { + id: transform + rotation: fromAxisAndAngle(Qt.vector3d(1, 0, 0), 45) + } + + PhongMaterial { + id: material + diffuse: "green" + } +} diff --git a/tests/manual/raycasting-qml/LineEntity.qml b/tests/manual/raycasting-qml/LineEntity.qml new file mode 100644 index 000000000..6071881f3 --- /dev/null +++ b/tests/manual/raycasting-qml/LineEntity.qml @@ -0,0 +1,114 @@ +/**************************************************************************** +** +** Copyright (C) 2018 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 +import Qt3D.Input 2.0 +import Qt3D.Extras 2.0 + +Entity { + id: root + + property vector3d origin + property vector3d direction + property real length: 1 + + components: [ mesh, material ] + + function buildVertexBufferData(o, d, l) { + // Vertices + var v0 = o + var v1 = o.plus(d.times(l)) + + var vertices = [ v1, v0 ] + + var vertexArray = new Float32Array(vertices.length * 3); + var i = 0; + + vertices.forEach(function(vec3) { + vertexArray[i++] = vec3.x; + vertexArray[i++] = vec3.y; + vertexArray[i++] = vec3.z; + }); + + return vertexArray; + } + + Buffer { + id: vertexBuffer + type: Buffer.VertexBuffer + data: buildVertexBufferData(root.origin, root.direction, root.length) + } + + GeometryRenderer { + id: mesh + instanceCount: 1 + indexOffset: 0 + firstInstance: 0 + primitiveType: GeometryRenderer.Lines + + geometry: Geometry { + Attribute { + attributeType: Attribute.VertexAttribute + vertexBaseType: Attribute.Float + vertexSize: 3 + byteOffset: 0 + count: 2 + name: defaultPositionAttributeName + buffer: vertexBuffer + } + } + } + + LineMaterial { + id: material + maincolor: "white" + } +} diff --git a/tests/manual/raycasting-qml/LineMaterial.qml b/tests/manual/raycasting-qml/LineMaterial.qml new file mode 100644 index 000000000..147f47357 --- /dev/null +++ b/tests/manual/raycasting-qml/LineMaterial.qml @@ -0,0 +1,143 @@ +/**************************************************************************** +** +** Copyright (C) 2018 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 + + //! [0] + property color maincolor: Qt.rgba(0.0, 0.0, 0.0, 1.0) + + parameters: [ + Parameter { + name: "maincolor" + value: Qt.vector3d(root.maincolor.r, root.maincolor.g, root.maincolor.b) + } + ] + + //! [0] + + effect: Effect { + + //! [1] + property string vertex: "qrc:/shaders/gl3/simpleColor.vert" + property string fragment: "qrc:/shaders/gl3/simpleColor.frag" + property string vertexES: "qrc:/shaders/es2/simpleColor.vert" + property string fragmentES: "qrc:/shaders/es2/simpleColor.frag" + //! [1] + + FilterKey { + id: forward + name: "renderingStyle" + value: "forward" + } + + //! [2] + ShaderProgram { + id: gl3Shader + vertexShaderCode: loadSource(parent.vertex) + fragmentShaderCode: loadSource(parent.fragment) + } + ShaderProgram { + id: es2Shader + vertexShaderCode: loadSource(parent.vertexES) + fragmentShaderCode: loadSource(parent.fragmentES) + } + //! [2] + + techniques: [ + //! [3] + // OpenGL 3.1 + Technique { + filterKeys: [forward] + graphicsApiFilter { + api: GraphicsApiFilter.OpenGL + profile: GraphicsApiFilter.CoreProfile + majorVersion: 3 + minorVersion: 1 + } + renderPasses: RenderPass { + shaderProgram: gl3Shader + } + }, + //! [3] + // OpenGL 2.0 + Technique { + filterKeys: [forward] + graphicsApiFilter { + api: GraphicsApiFilter.OpenGL + profile: GraphicsApiFilter.NoProfile + majorVersion: 2 + minorVersion: 0 + } + renderPasses: RenderPass { + shaderProgram: es2Shader + } + }, + // ES 2.0 + Technique { + filterKeys: [forward] + graphicsApiFilter { + api: GraphicsApiFilter.OpenGLES + profile: GraphicsApiFilter.CoreProfile + majorVersion: 2 + minorVersion: 0 + } + renderPasses: RenderPass { + shaderProgram: es2Shader + } + } + ] + } +} + + diff --git a/tests/manual/raycasting-qml/main.cpp b/tests/manual/raycasting-qml/main.cpp new file mode 100644 index 000000000..3741265c7 --- /dev/null +++ b/tests/manual/raycasting-qml/main.cpp @@ -0,0 +1,63 @@ +/**************************************************************************** +** +** Copyright (C) 2018 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 <Qt3DQuickExtras/qt3dquickwindow.h> +#include <QGuiApplication> + +int main(int argc, char* argv[]) +{ + QGuiApplication app(argc, argv); + Qt3DExtras::Quick::Qt3DQuickWindow view; + + view.setSource(QUrl("qrc:/main.qml")); + view.show(); + + return app.exec(); +} diff --git a/tests/manual/raycasting-qml/main.qml b/tests/manual/raycasting-qml/main.qml new file mode 100644 index 000000000..c6cc8445f --- /dev/null +++ b/tests/manual/raycasting-qml/main.qml @@ -0,0 +1,163 @@ +/**************************************************************************** +** +** Copyright (C) 2018 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.11 +import Qt3D.Input 2.0 +import Qt3D.Extras 2.0 +import QtQuick 2.0 + +Entity { + id: sceneRoot + + Camera { + id: camera + projectionType: CameraLens.PerspectiveProjection + fieldOfView: 45 + aspectRatio: 16/9 + nearPlane : 0.1 + farPlane : 1000.0 + position: Qt.vector3d( 0.0, 2.0, 20.0 ) + upVector: Qt.vector3d( 0.0, 1.0, 0.0 ) + viewCenter: Qt.vector3d( 0.0, 0.0, 0.0 ) + } + + OrbitCameraController { camera: camera } + + RenderSettings { + id : external_forward_renderer + activeFrameGraph : ForwardRenderer { + camera: camera + clearColor: "black" + } + pickingSettings.pickMethod: PickingSettings.TrianglePicking + } + + // Event Source will be set by the Qt3DQuickWindow + InputSettings { id: inputSettings } + + DirectionalLight { + id: headLight + worldDirection: camera.viewVector + } + + RayCaster { + id: raycaster + origin: Qt.vector3d(0, 0, 4) + direction: Qt.vector3d(0., 0., -1.) + length: 5 + + onHitsChanged: printHits("Model hits", hits) + } + + ScreenRayCaster { + id: screenRayCaster + position: Qt.point(200, 200) + + onHitsChanged: printHits("Screen hits", hits) + } + + MouseHandler { + id: mouseHandler + sourceDevice: MouseDevice {} + onReleased: { screenRayCaster.trigger(Qt.point(mouse.x, mouse.y)) } + } + + KeyboardDevice { id: kbDevice } + KeyboardHandler { + id: kbHandler + focus: true + sourceDevice: kbDevice + onPressed: { + if (event.text.toLowerCase() == "a") { raycaster.origin.x -= .1; raycaster.trigger() } + if (event.text.toLowerCase() == "f") { raycaster.origin.x += .1; raycaster.trigger() } + if (event.text.toLowerCase() == "s") { raycaster.origin.y += .1; raycaster.trigger() } + if (event.text.toLowerCase() == "d") { raycaster.origin.y -= .1; raycaster.trigger() } + } + } + + components: [ external_forward_renderer, inputSettings, headLight, raycaster, screenRayCaster, mouseHandler, kbHandler ] + + function printHits(desc, hits) { + console.log(desc, hits.length) + for (var i=0; i<hits.length; i++) { + console.log(" " + hits[i].entity.objectName, hits[i].distance, + hits[i].worldIntersection.x, hits[i].worldIntersection.y, hits[i].worldIntersection.z) + } + } + + CylinderEntity { + objectName: "CRed" + id: leftEntity + translation: Qt.vector3d(-5, 0, 0) + color: "red" + } + + CylinderEntity { + objectName: "CGreen" + id: mainEntity + translation: Qt.vector3d(0, 0, 0) + color: "green" + } + + CylinderEntity { + objectName: "CBlue" + id: rightEntity + translation: Qt.vector3d(5, 0, 0) + color: "blue" + } + + LineEntity { + id: raydisplay + origin: raycaster.origin + direction: raycaster.direction + length: raycaster.length + } +} diff --git a/tests/manual/raycasting-qml/main.qrc b/tests/manual/raycasting-qml/main.qrc new file mode 100644 index 000000000..48ba3f500 --- /dev/null +++ b/tests/manual/raycasting-qml/main.qrc @@ -0,0 +1,14 @@ +<RCC> + <qresource prefix="/"> + <file>main.qml</file> + <file>CylinderEntity.qml</file> + <file>LineEntity.qml</file> + <file>LineMaterial.qml</file> + <file>shaders/es2/simpleColor.frag</file> + <file>shaders/es2/simpleColor.vert</file> + <file>shaders/gl3/simpleColor.frag</file> + <file>shaders/gl3/simpleColor.vert</file> + </qresource> + <qresource prefix="/shaders/es2"/> + <qresource prefix="/shaders/gl3"/> +</RCC> diff --git a/tests/manual/raycasting-qml/raycasting-qml.pro b/tests/manual/raycasting-qml/raycasting-qml.pro new file mode 100644 index 000000000..b3ff6d6a8 --- /dev/null +++ b/tests/manual/raycasting-qml/raycasting-qml.pro @@ -0,0 +1,10 @@ +QT += 3dcore 3drender 3dinput 3dquick qml quick 3dquickextras + +SOURCES += \ + main.cpp + +OTHER_FILES += \ + main.qml + +RESOURCES += \ + main.qrc diff --git a/tests/manual/raycasting-qml/shaders/es2/simpleColor.frag b/tests/manual/raycasting-qml/shaders/es2/simpleColor.frag new file mode 100644 index 000000000..d18c01699 --- /dev/null +++ b/tests/manual/raycasting-qml/shaders/es2/simpleColor.frag @@ -0,0 +1,10 @@ +#define FP highp + +uniform FP vec3 maincolor; + +void main() +{ + //output color from material + gl_FragColor = vec4(maincolor,1.0); +} + diff --git a/tests/manual/raycasting-qml/shaders/es2/simpleColor.vert b/tests/manual/raycasting-qml/shaders/es2/simpleColor.vert new file mode 100644 index 000000000..24934948c --- /dev/null +++ b/tests/manual/raycasting-qml/shaders/es2/simpleColor.vert @@ -0,0 +1,15 @@ +#define FP highp + +attribute FP vec3 vertexPosition; +varying FP vec3 worldPosition; +uniform FP mat4 modelMatrix; +uniform FP mat4 mvp; + +void main() +{ + // Transform position, normal, and tangent to world coords + worldPosition = vec3(modelMatrix * vec4(vertexPosition, 1.0)); + + // Calculate vertex position in clip coordinates + gl_Position = mvp * vec4(worldPosition, 1.0); +} diff --git a/tests/manual/raycasting-qml/shaders/gl3/simpleColor.frag b/tests/manual/raycasting-qml/shaders/gl3/simpleColor.frag new file mode 100644 index 000000000..c899052d9 --- /dev/null +++ b/tests/manual/raycasting-qml/shaders/gl3/simpleColor.frag @@ -0,0 +1,11 @@ +#version 150 core + +uniform vec3 maincolor; +out vec4 fragColor; + +void main() +{ + //output color from material + fragColor = vec4(maincolor,1.0); +} + diff --git a/tests/manual/raycasting-qml/shaders/gl3/simpleColor.vert b/tests/manual/raycasting-qml/shaders/gl3/simpleColor.vert new file mode 100644 index 000000000..2912a1837 --- /dev/null +++ b/tests/manual/raycasting-qml/shaders/gl3/simpleColor.vert @@ -0,0 +1,11 @@ +#version 150 core + +in vec3 vertexPosition; +uniform mat4 modelMatrix; +uniform mat4 mvp; + +void main() +{ + // Calculate vertex position in clip coordinates + gl_Position = mvp * vec4(vertexPosition, 1.0); +} |