diff options
Diffstat (limited to 'tests/manual')
74 files changed, 4742 insertions, 220 deletions
diff --git a/tests/manual/anim-viewer/main.qml b/tests/manual/anim-viewer/main.qml index 95a4900e3..15e9cd3f9 100644 --- a/tests/manual/anim-viewer/main.qml +++ b/tests/manual/anim-viewer/main.qml @@ -42,7 +42,8 @@ import QtQuick.Controls.Styles 1.4 import Qt3D.Core 2.0 import Qt3D.Render 2.0 import Qt3D.Input 2.0 -import Qt3D.Extras 2.2 +import Qt3D.Extras 2.9 +import Qt3D.Animation 2.9 import QtQuick.Scene3D 2.0 diff --git a/tests/manual/animation-keyframe-blendtree/DefaultSceneEntity.qml b/tests/manual/animation-keyframe-blendtree/DefaultSceneEntity.qml new file mode 100644 index 000000000..f1c6110d6 --- /dev/null +++ b/tests/manual/animation-keyframe-blendtree/DefaultSceneEntity.qml @@ -0,0 +1,76 @@ +/**************************************************************************** +** +** Copyright (C) 2017 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 Camera camera + + components: [ + RenderSettings { + activeFrameGraph: ForwardRenderer { + camera: root.camera + } + }, + // Event Source will be set by the Qt3DQuickWindow + InputSettings { } + ] + + Entity { + components: [ + PointLight { intensity: 0.5 }, + Transform { translation: camera.position } + ] + } +} diff --git a/tests/manual/animation-keyframe-blendtree/animation-keyframe-blendtree.pro b/tests/manual/animation-keyframe-blendtree/animation-keyframe-blendtree.pro new file mode 100644 index 000000000..04db4207e --- /dev/null +++ b/tests/manual/animation-keyframe-blendtree/animation-keyframe-blendtree.pro @@ -0,0 +1,5 @@ +TEMPLATE = app +QT += 3dquickextras 3dquickanimation +SOURCES += main.cpp +RESOURCES += main.qrc +OTHER_FILES += main.qml DefaultSceneEntity.qml diff --git a/tests/manual/animation-keyframe-blendtree/main.cpp b/tests/manual/animation-keyframe-blendtree/main.cpp new file mode 100644 index 000000000..fce9ecc5f --- /dev/null +++ b/tests/manual/animation-keyframe-blendtree/main.cpp @@ -0,0 +1,66 @@ +/**************************************************************************** +** +** Copyright (C) 2017 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 <QGuiApplication> +#include <Qt3DAnimation/QAnimationAspect> +#include <Qt3DQuickExtras/Qt3DQuickWindow> +#include <Qt3DQuick/QQmlAspectEngine> +#include <QQmlEngine> +#include <QQmlContext> + +int main(int argc, char **argv) +{ + QGuiApplication app(argc, argv); + Qt3DExtras::Quick::Qt3DQuickWindow view; + view.registerAspect(new Qt3DAnimation::QAnimationAspect()); + view.setSource(QUrl("qrc:/main.qml")); + view.show(); + return app.exec(); +} diff --git a/tests/manual/animation-keyframe-blendtree/main.qml b/tests/manual/animation-keyframe-blendtree/main.qml new file mode 100644 index 000000000..23aba4b79 --- /dev/null +++ b/tests/manual/animation-keyframe-blendtree/main.qml @@ -0,0 +1,116 @@ +/**************************************************************************** +** +** Copyright (C) 2017 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.Animation 2.9 +import Qt3D.Extras 2.0 + +DefaultSceneEntity { + id: scene + + Entity { + id: cube + + components: [ + Transform { + id: cubeTransform + translation: Qt.vector3d(5, 0, 0) + onTranslationChanged: console.log("t = " + translation) + }, + CuboidMesh { + }, + PhongMaterial { + id: cubeMaterial + ambient: Qt.rgba(0.02, 0.02, 0.02, 1.0) + diffuse: "red" + shininess: 50 + }, + ObjectPicker { + onClicked: blendedAnimator.running = true + }, + BlendedClipAnimator { + id: blendedAnimator + loops: 2 + + onRunningChanged: console.log("running = " + running) + + blendTree: LerpClipBlend { + blendFactor: 0.2 + startClip: ClipBlendValue { + clip: AnimationClipLoader { source: "sliding-cube.json" } + } + endClip: ClipBlendValue { + clip: AnimationClipLoader { source: "sliding-pulsing-cube.json" } + } + } + + channelMapper: ChannelMapper { + mappings: [ + ChannelMapping { channelName: "Location"; target: cubeTransform; property: "translation" }, + ChannelMapping { channelName: "Scale"; target: cubeTransform; property: "scale3D" } + ] + } + } + ] + } + + camera: Camera { + position: Qt.vector3d(10, 3, 15) + viewCenter: Qt.vector3d(2.5, 1, 0) + } + + OrbitCameraController { + camera: scene.camera + linearSpeed: 8 + lookSpeed: 180 + } +} diff --git a/tests/manual/animation-keyframe-blendtree/main.qrc b/tests/manual/animation-keyframe-blendtree/main.qrc new file mode 100644 index 000000000..4422a677e --- /dev/null +++ b/tests/manual/animation-keyframe-blendtree/main.qrc @@ -0,0 +1,8 @@ +<RCC> + <qresource prefix="/"> + <file>main.qml</file> + <file>DefaultSceneEntity.qml</file> + <file>sliding-cube.json</file> + <file>sliding-pulsing-cube.json</file> + </qresource> +</RCC> diff --git a/tests/manual/animation-keyframe-blendtree/sliding-cube.json b/tests/manual/animation-keyframe-blendtree/sliding-cube.json new file mode 100644 index 000000000..2404ea325 --- /dev/null +++ b/tests/manual/animation-keyframe-blendtree/sliding-cube.json @@ -0,0 +1,469 @@ +{ + "animations": [ + { + "animationName": "PulsingSlidingCube", + "channels": [ + { + "channelComponents": [ + { + "channelComponentName": "Location X", + "keyFrames": [ + { + "coords": [ + 0.0, + 0.0 + ], + "leftHandle": [ + -0.22774004936218262, + 0.0 + ], + "rightHandle": [ + 0.22774004936218262, + 0.0 + ] + }, + { + "coords": [ + 0.5833333333333334, + 0.6238380670547485 + ], + "leftHandle": [ + 0.3555932839711507, + 0.20872697234153748 + ], + "rightHandle": [ + 0.8273405234018961, + 1.0685999393463135 + ] + }, + { + "coords": [ + 1.2083333333333333, + 2.2338662147521973 + ], + "leftHandle": [ + 0.9643261432647705, + 1.5640573501586914 + ], + "rightHandle": [ + 1.4523404439290364, + 2.903675079345703 + ] + }, + { + "coords": [ + 1.8333333333333333, + 4.0551347732543945 + ], + "leftHandle": [ + 1.5893262227376301, + 3.515169620513916 + ], + "rightHandle": [ + 2.0773404439290366, + 4.595099925994873 + ] + }, + { + "coords": [ + 2.4583333333333335, + 5.0 + ], + "leftHandle": [ + 2.2143262227376304, + 5.0 + ], + "rightHandle": [ + 2.7023404439290366, + 5.0 + ] + } + ] + }, + { + "channelComponentName": "Location Z", + "keyFrames": [ + { + "coords": [ + 0.0, + 0.0 + ], + "leftHandle": [ + -0.22774004936218262, + 0.0 + ], + "rightHandle": [ + 0.22774004936218262, + 0.0 + ] + }, + { + "coords": [ + 0.5833333333333334, + 0.0 + ], + "leftHandle": [ + 0.3555932839711507, + 0.0 + ], + "rightHandle": [ + 0.8273405234018961, + 0.0 + ] + }, + { + "coords": [ + 1.2083333333333333, + 0.0 + ], + "leftHandle": [ + 0.9643261432647705, + 0.0 + ], + "rightHandle": [ + 1.4523404439290364, + 0.0 + ] + }, + { + "coords": [ + 1.8333333333333333, + 0.0 + ], + "leftHandle": [ + 1.5893262227376301, + 0.0 + ], + "rightHandle": [ + 2.0773404439290366, + 0.0 + ] + }, + { + "coords": [ + 2.4583333333333335, + 0.0 + ], + "leftHandle": [ + 2.2143262227376304, + 0.0 + ], + "rightHandle": [ + 2.7023404439290366, + 0.0 + ] + } + ] + }, + { + "channelComponentName": "Location Y", + "keyFrames": [ + { + "coords": [ + 0.0, + 0.0 + ], + "leftHandle": [ + -0.22774004936218262, + 0.0 + ], + "rightHandle": [ + 0.22774004936218262, + 0.0 + ] + }, + { + "coords": [ + 0.5833333333333334, + 0.0 + ], + "leftHandle": [ + 0.3555932839711507, + 0.0 + ], + "rightHandle": [ + 0.8273405234018961, + 0.0 + ] + }, + { + "coords": [ + 1.2083333333333333, + 0.0 + ], + "leftHandle": [ + 0.9643261432647705, + 0.0 + ], + "rightHandle": [ + 1.4523404439290364, + 0.0 + ] + }, + { + "coords": [ + 1.8333333333333333, + 0.0 + ], + "leftHandle": [ + 1.5893262227376301, + 0.0 + ], + "rightHandle": [ + 2.0773404439290366, + 0.0 + ] + }, + { + "coords": [ + 2.4583333333333335, + 0.0 + ], + "leftHandle": [ + 2.2143262227376304, + 0.0 + ], + "rightHandle": [ + 2.7023404439290366, + 0.0 + ] + } + ] + } + ], + "channelName": "Location" + }, + { + "channelComponents": [ + { + "channelComponentName": "Scale X", + "keyFrames": [ + { + "coords": [ + 0.0, + 1.0 + ], + "leftHandle": [ + -0.22774004936218262, + 1.0 + ], + "rightHandle": [ + 0.22774004936218262, + 1.0 + ] + }, + { + "coords": [ + 0.5833333333333334, + 1.0 + ], + "leftHandle": [ + 0.3555932839711507, + 1.0 + ], + "rightHandle": [ + 0.8273405234018961, + 1.0 + ] + }, + { + "coords": [ + 1.2083333333333333, + 1.0 + ], + "leftHandle": [ + 0.9643261432647705, + 1.0 + ], + "rightHandle": [ + 1.4523404439290364, + 1.0 + ] + }, + { + "coords": [ + 1.8333333333333333, + 1.0 + ], + "leftHandle": [ + 1.5893262227376301, + 1.0 + ], + "rightHandle": [ + 2.0773404439290366, + 1.0 + ] + }, + { + "coords": [ + 2.4583333333333335, + 1.0 + ], + "leftHandle": [ + 2.2143262227376304, + 1.0 + ], + "rightHandle": [ + 2.7023404439290366, + 1.0 + ] + } + ] + }, + { + "channelComponentName": "Scale Y", + "keyFrames": [ + { + "coords": [ + 0.0, + 1.0 + ], + "leftHandle": [ + -0.22774004936218262, + 1.0 + ], + "rightHandle": [ + 0.22774004936218262, + 1.0 + ] + }, + { + "coords": [ + 0.5833333333333334, + 1.0 + ], + "leftHandle": [ + 0.3555932839711507, + 1.0 + ], + "rightHandle": [ + 0.8273405234018961, + 1.0 + ] + }, + { + "coords": [ + 1.2083333333333333, + 1.0 + ], + "leftHandle": [ + 0.9643261432647705, + 1.0 + ], + "rightHandle": [ + 1.4523404439290364, + 1.0 + ] + }, + { + "coords": [ + 1.8333333333333333, + 1.0 + ], + "leftHandle": [ + 1.5893262227376301, + 1.0 + ], + "rightHandle": [ + 2.0773404439290366, + 1.0 + ] + }, + { + "coords": [ + 2.4583333333333335, + 1.0 + ], + "leftHandle": [ + 2.2143262227376304, + 1.0 + ], + "rightHandle": [ + 2.7023404439290366, + 1.0 + ] + } + ] + }, + { + "channelComponentName": "Scale Z", + "keyFrames": [ + { + "coords": [ + 0.0, + 1.0 + ], + "leftHandle": [ + -0.22774004936218262, + 1.0 + ], + "rightHandle": [ + 0.22774004936218262, + 1.0 + ] + }, + { + "coords": [ + 0.5833333333333334, + 1.0 + ], + "leftHandle": [ + 0.3555932839711507, + 1.0 + ], + "rightHandle": [ + 0.8273405234018961, + 1.0 + ] + }, + { + "coords": [ + 1.2083333333333333, + 1.0 + ], + "leftHandle": [ + 0.9643261432647705, + 1.0 + ], + "rightHandle": [ + 1.4523404439290364, + 1.0 + ] + }, + { + "coords": [ + 1.8333333333333333, + 1.0 + ], + "leftHandle": [ + 1.5893262227376301, + 1.0 + ], + "rightHandle": [ + 2.0773404439290366, + 1.0 + ] + }, + { + "coords": [ + 2.4583333333333335, + 1.0 + ], + "leftHandle": [ + 2.2143262227376304, + 1.0 + ], + "rightHandle": [ + 2.7023404439290366, + 1.0 + ] + } + ] + } + ], + "channelName": "Scale" + } + ] + } + ] +}
\ No newline at end of file diff --git a/tests/manual/animation-keyframe-blendtree/sliding-pulsing-cube.json b/tests/manual/animation-keyframe-blendtree/sliding-pulsing-cube.json new file mode 100644 index 000000000..9d6a8c7b8 --- /dev/null +++ b/tests/manual/animation-keyframe-blendtree/sliding-pulsing-cube.json @@ -0,0 +1,469 @@ +{ + "animations": [ + { + "animationName": "PulsingSlidingCube", + "channels": [ + { + "channelComponents": [ + { + "channelComponentName": "Location X", + "keyFrames": [ + { + "coords": [ + 0.0, + 0.0 + ], + "leftHandle": [ + -0.22774004936218262, + 0.0 + ], + "rightHandle": [ + 0.22774004936218262, + 0.0 + ] + }, + { + "coords": [ + 0.5833333333333334, + 0.6238380670547485 + ], + "leftHandle": [ + 0.3555932839711507, + 0.20872697234153748 + ], + "rightHandle": [ + 0.8273405234018961, + 1.0685999393463135 + ] + }, + { + "coords": [ + 1.2083333333333333, + 2.2338662147521973 + ], + "leftHandle": [ + 0.9643261432647705, + 1.5640573501586914 + ], + "rightHandle": [ + 1.4523404439290364, + 2.903675079345703 + ] + }, + { + "coords": [ + 1.8333333333333333, + 4.0551347732543945 + ], + "leftHandle": [ + 1.5893262227376301, + 3.515169620513916 + ], + "rightHandle": [ + 2.0773404439290366, + 4.595099925994873 + ] + }, + { + "coords": [ + 2.4583333333333335, + 5.0 + ], + "leftHandle": [ + 2.2143262227376304, + 5.0 + ], + "rightHandle": [ + 2.7023404439290366, + 5.0 + ] + } + ] + }, + { + "channelComponentName": "Location Z", + "keyFrames": [ + { + "coords": [ + 0.0, + 0.0 + ], + "leftHandle": [ + -0.22774004936218262, + 0.0 + ], + "rightHandle": [ + 0.22774004936218262, + 0.0 + ] + }, + { + "coords": [ + 0.5833333333333334, + 0.0 + ], + "leftHandle": [ + 0.3555932839711507, + 0.0 + ], + "rightHandle": [ + 0.8273405234018961, + 0.0 + ] + }, + { + "coords": [ + 1.2083333333333333, + 0.0 + ], + "leftHandle": [ + 0.9643261432647705, + 0.0 + ], + "rightHandle": [ + 1.4523404439290364, + 0.0 + ] + }, + { + "coords": [ + 1.8333333333333333, + 0.0 + ], + "leftHandle": [ + 1.5893262227376301, + 0.0 + ], + "rightHandle": [ + 2.0773404439290366, + 0.0 + ] + }, + { + "coords": [ + 2.4583333333333335, + 0.0 + ], + "leftHandle": [ + 2.2143262227376304, + 0.0 + ], + "rightHandle": [ + 2.7023404439290366, + 0.0 + ] + } + ] + }, + { + "channelComponentName": "Location Y", + "keyFrames": [ + { + "coords": [ + 0.0, + 0.0 + ], + "leftHandle": [ + -0.22774004936218262, + 0.0 + ], + "rightHandle": [ + 0.22774004936218262, + 0.0 + ] + }, + { + "coords": [ + 0.5833333333333334, + 0.0 + ], + "leftHandle": [ + 0.3555932839711507, + 0.0 + ], + "rightHandle": [ + 0.8273405234018961, + 0.0 + ] + }, + { + "coords": [ + 1.2083333333333333, + 0.0 + ], + "leftHandle": [ + 0.9643261432647705, + 0.0 + ], + "rightHandle": [ + 1.4523404439290364, + 0.0 + ] + }, + { + "coords": [ + 1.8333333333333333, + 0.0 + ], + "leftHandle": [ + 1.5893262227376301, + 0.0 + ], + "rightHandle": [ + 2.0773404439290366, + 0.0 + ] + }, + { + "coords": [ + 2.4583333333333335, + 0.0 + ], + "leftHandle": [ + 2.2143262227376304, + 0.0 + ], + "rightHandle": [ + 2.7023404439290366, + 0.0 + ] + } + ] + } + ], + "channelName": "Location" + }, + { + "channelComponents": [ + { + "channelComponentName": "Scale X", + "keyFrames": [ + { + "coords": [ + 0.0, + 1.0 + ], + "leftHandle": [ + -0.22774004936218262, + 1.0 + ], + "rightHandle": [ + 0.22774004936218262, + 1.0 + ] + }, + { + "coords": [ + 0.5833333333333334, + 0.5 + ], + "leftHandle": [ + 0.3555932839711507, + 0.5 + ], + "rightHandle": [ + 0.8273405234018961, + 0.5 + ] + }, + { + "coords": [ + 1.2083333333333333, + 1.0 + ], + "leftHandle": [ + 0.9643261432647705, + 1.0 + ], + "rightHandle": [ + 1.4523404439290364, + 1.0 + ] + }, + { + "coords": [ + 1.8333333333333333, + 0.5 + ], + "leftHandle": [ + 1.5893262227376301, + 0.5 + ], + "rightHandle": [ + 2.0773404439290366, + 0.5 + ] + }, + { + "coords": [ + 2.4583333333333335, + 1.0 + ], + "leftHandle": [ + 2.2143262227376304, + 1.0 + ], + "rightHandle": [ + 2.7023404439290366, + 1.0 + ] + } + ] + }, + { + "channelComponentName": "Scale Y", + "keyFrames": [ + { + "coords": [ + 0.0, + 1.0 + ], + "leftHandle": [ + -0.22774004936218262, + 1.0 + ], + "rightHandle": [ + 0.22774004936218262, + 1.0 + ] + }, + { + "coords": [ + 0.5833333333333334, + 0.5 + ], + "leftHandle": [ + 0.3555932839711507, + 0.5 + ], + "rightHandle": [ + 0.8273405234018961, + 0.5 + ] + }, + { + "coords": [ + 1.2083333333333333, + 1.0 + ], + "leftHandle": [ + 0.9643261432647705, + 1.0 + ], + "rightHandle": [ + 1.4523404439290364, + 1.0 + ] + }, + { + "coords": [ + 1.8333333333333333, + 0.5 + ], + "leftHandle": [ + 1.5893262227376301, + 0.5 + ], + "rightHandle": [ + 2.0773404439290366, + 0.5 + ] + }, + { + "coords": [ + 2.4583333333333335, + 1.0 + ], + "leftHandle": [ + 2.2143262227376304, + 1.0 + ], + "rightHandle": [ + 2.7023404439290366, + 1.0 + ] + } + ] + }, + { + "channelComponentName": "Scale Z", + "keyFrames": [ + { + "coords": [ + 0.0, + 1.0 + ], + "leftHandle": [ + -0.22774004936218262, + 1.0 + ], + "rightHandle": [ + 0.22774004936218262, + 1.0 + ] + }, + { + "coords": [ + 0.5833333333333334, + 0.5 + ], + "leftHandle": [ + 0.3555932839711507, + 0.5 + ], + "rightHandle": [ + 0.8273405234018961, + 0.5 + ] + }, + { + "coords": [ + 1.2083333333333333, + 1.0 + ], + "leftHandle": [ + 0.9643261432647705, + 1.0 + ], + "rightHandle": [ + 1.4523404439290364, + 1.0 + ] + }, + { + "coords": [ + 1.8333333333333333, + 0.5 + ], + "leftHandle": [ + 1.5893262227376301, + 0.5 + ], + "rightHandle": [ + 2.0773404439290366, + 0.5 + ] + }, + { + "coords": [ + 2.4583333333333335, + 1.0 + ], + "leftHandle": [ + 2.2143262227376304, + 1.0 + ], + "rightHandle": [ + 2.7023404439290366, + 1.0 + ] + } + ] + } + ], + "channelName": "Scale" + } + ] + } + ] +}
\ No newline at end of file diff --git a/tests/manual/animation-keyframe-programmatic/DefaultSceneEntity.qml b/tests/manual/animation-keyframe-programmatic/DefaultSceneEntity.qml new file mode 100644 index 000000000..f1c6110d6 --- /dev/null +++ b/tests/manual/animation-keyframe-programmatic/DefaultSceneEntity.qml @@ -0,0 +1,76 @@ +/**************************************************************************** +** +** Copyright (C) 2017 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 Camera camera + + components: [ + RenderSettings { + activeFrameGraph: ForwardRenderer { + camera: root.camera + } + }, + // Event Source will be set by the Qt3DQuickWindow + InputSettings { } + ] + + Entity { + components: [ + PointLight { intensity: 0.5 }, + Transform { translation: camera.position } + ] + } +} diff --git a/tests/manual/animation-keyframe-programmatic/animation-keyframe-programmatic.pro b/tests/manual/animation-keyframe-programmatic/animation-keyframe-programmatic.pro new file mode 100644 index 000000000..e38990808 --- /dev/null +++ b/tests/manual/animation-keyframe-programmatic/animation-keyframe-programmatic.pro @@ -0,0 +1,12 @@ +TEMPLATE = app +QT += 3dquickextras 3dquickanimation + +SOURCES += \ + main.cpp \ + animationfactory.cpp + +HEADERS += \ + animationfactory.h + +RESOURCES += main.qrc +OTHER_FILES += main.qml DefaultSceneEntity.qml diff --git a/tests/manual/animation-keyframe-programmatic/animationfactory.cpp b/tests/manual/animation-keyframe-programmatic/animationfactory.cpp new file mode 100644 index 000000000..e3b1c6165 --- /dev/null +++ b/tests/manual/animation-keyframe-programmatic/animationfactory.cpp @@ -0,0 +1,85 @@ +/**************************************************************************** +** +** Copyright (C) 2017 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 "animationfactory.h" + +using namespace Qt3DAnimation; + +AnimationFactory::AnimationFactory(QObject *parent) + : QObject(parent) +{ + updateClipData(); +} + +void AnimationFactory::updateClipData() +{ + m_clipData.clearChannels(); + + // Add a channel for a Location animation + QChannel location(QLatin1String("Location")); + + QChannelComponent locationX(QLatin1String("Location X")); + locationX.appendKeyFrame(QKeyFrame({0.0f, 0.0f}, {-1.0f, 0.0f}, {1.0f, 0.0f})); + locationX.appendKeyFrame(QKeyFrame({2.45f, 5.0f}, {1.45f, 5.0f}, {3.45f, 5.0f})); + + QChannelComponent locationY(QLatin1String("Location Y")); + locationY.appendKeyFrame(QKeyFrame({0.0f, 0.0f}, {-1.0f, 0.0f}, {1.0f, 0.0f})); + locationY.appendKeyFrame(QKeyFrame({2.45f, 0.0f}, {1.45f, 0.0f}, {3.45f, 0.0f})); + + QChannelComponent locationZ(QLatin1String("Location Z")); + locationZ.appendKeyFrame(QKeyFrame({0.0f, 0.0f}, {-1.0f, 0.0f}, {1.0f, 0.0f})); + locationZ.appendKeyFrame(QKeyFrame({2.45f, 0.0f}, {1.45f, 0.0f}, {3.45f, 0.0f})); + + location.appendChannelComponent(locationX); + location.appendChannelComponent(locationY); + location.appendChannelComponent(locationZ); + + m_clipData.appendChannel(location); +} diff --git a/tests/manual/animation-keyframe-programmatic/animationfactory.h b/tests/manual/animation-keyframe-programmatic/animationfactory.h new file mode 100644 index 000000000..b73db0b68 --- /dev/null +++ b/tests/manual/animation-keyframe-programmatic/animationfactory.h @@ -0,0 +1,79 @@ +/**************************************************************************** +** +** Copyright (C) 2017 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 ANIMATIONFACTORY_H +#define ANIMATIONFACTORY_H + +#include <QObject> +#include <Qt3DAnimation/qanimationclipdata.h> + +class AnimationFactory : public QObject +{ + Q_OBJECT + Q_PROPERTY(Qt3DAnimation::QAnimationClipData clipData READ clipData NOTIFY clipDataChanged) + +public: + explicit AnimationFactory(QObject *parent = 0); + + Qt3DAnimation::QAnimationClipData clipData() const + { + return m_clipData; + } + +signals: + void clipDataChanged(Qt3DAnimation::QAnimationClipData clipData); + +private: + void updateClipData(); + + Qt3DAnimation::QAnimationClipData m_clipData; +}; + +#endif // ANIMATIONFACTORY_H diff --git a/tests/manual/animation-keyframe-programmatic/main.cpp b/tests/manual/animation-keyframe-programmatic/main.cpp new file mode 100644 index 000000000..eb3a22df1 --- /dev/null +++ b/tests/manual/animation-keyframe-programmatic/main.cpp @@ -0,0 +1,72 @@ +/**************************************************************************** +** +** Copyright (C) 2017 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 <QGuiApplication> +#include <Qt3DAnimation/QAnimationAspect> +#include <Qt3DQuickExtras/Qt3DQuickWindow> +#include <Qt3DQuick/QQmlAspectEngine> +#include <QQmlEngine> +#include <QQmlContext> + +#include "animationfactory.h" + +int main(int argc, char **argv) +{ + QGuiApplication app(argc, argv); + + AnimationFactory animationFactory; + + Qt3DExtras::Quick::Qt3DQuickWindow view; + view.registerAspect(new Qt3DAnimation::QAnimationAspect()); + view.engine()->qmlEngine()->rootContext()->setContextProperty("_animationFactory", &animationFactory); + view.setSource(QUrl("qrc:/main.qml")); + view.show(); + return app.exec(); +} diff --git a/tests/manual/animation-keyframe-programmatic/main.qml b/tests/manual/animation-keyframe-programmatic/main.qml new file mode 100644 index 000000000..c34e44d51 --- /dev/null +++ b/tests/manual/animation-keyframe-programmatic/main.qml @@ -0,0 +1,116 @@ +/**************************************************************************** +** +** Copyright (C) 2017 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.Animation 2.9 +import Qt3D.Extras 2.0 + +DefaultSceneEntity { + id: scene + + Entity { + id: cube + + components: [ + Transform { + id: cubeTransform + + onTranslationChanged: console.log("t = " + translation) + }, + CuboidMesh { + }, + PhongMaterial { + id: cubeMaterial + ambient: Qt.rgba(0.02, 0.02, 0.02, 1.0) + diffuse: "blue" + shininess: 50 + }, + ObjectPicker { + onClicked: animator.running = true + }, + ClipAnimator { + id: animator + loops: 3 + onRunningChanged: console.log("running = " + running) + + clip: AnimationClip { + clipData: _animationFactory.clipData + onDurationChanged: console.log("duration = " + duration) + } + + // By default introspect parent Entity and try + // to map fcurve groups to properties of QTransform + // mapping: AutomaticAnimationMapping {} + + // To do more, we can be explicit + channelMapper: ChannelMapper { + mappings: [ + ChannelMapping { channelName: "Location"; target: cubeTransform; property: "translation" }, + ChannelMapping { channelName: "Rotation"; target: cubeTransform; property: "rotation" }, + ChannelMapping { channelName: "Diffuse Color"; target: cubeMaterial; property: "diffuse" } + ] + } + } + ] + } + + camera: Camera { + position: Qt.vector3d(10, 3, 15) + viewCenter: Qt.vector3d(2.5, 1, 0) + } + + OrbitCameraController { + camera: scene.camera + linearSpeed: 8 + lookSpeed: 180 + } +} diff --git a/tests/manual/animation-keyframe-programmatic/main.qrc b/tests/manual/animation-keyframe-programmatic/main.qrc new file mode 100644 index 000000000..8bcf0c762 --- /dev/null +++ b/tests/manual/animation-keyframe-programmatic/main.qrc @@ -0,0 +1,6 @@ +<RCC> + <qresource prefix="/"> + <file>main.qml</file> + <file>DefaultSceneEntity.qml</file> + </qresource> +</RCC> diff --git a/tests/manual/animation-keyframe-simple/DefaultSceneEntity.qml b/tests/manual/animation-keyframe-simple/DefaultSceneEntity.qml index efffd44c9..f1c6110d6 100644 --- a/tests/manual/animation-keyframe-simple/DefaultSceneEntity.qml +++ b/tests/manual/animation-keyframe-simple/DefaultSceneEntity.qml @@ -1,11 +1,52 @@ -/************************************************************************* - * - * Copyright (c) 2016, Klaralvdalens Datakonsult AB (KDAB) - * All rights reserved. - * - * See the LICENSE.txt file shipped along with this file for the license. - * - *************************************************************************/ +/**************************************************************************** +** +** Copyright (C) 2017 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 diff --git a/tests/manual/animation-keyframe-simple/cubeanimation.json b/tests/manual/animation-keyframe-simple/cubeanimation.json index addf92907..3faff409c 100644 --- a/tests/manual/animation-keyframe-simple/cubeanimation.json +++ b/tests/manual/animation-keyframe-simple/cubeanimation.json @@ -1,87 +1,250 @@ { "animations": [ - { "object": "Cube", - "action": "CubeAction", - "range": [0.0, 60.0], - "groups": [ - { "group": "Location", - "channels": [ - { "name": "x", - "keyframes": [ - { "co": [0.0, 0.0], - "handle_left": [-0.4717472394307454, 0.0], - "handle_right": [0.4717472394307454, 0.0]} - ,{ "co": [1.2083333333333333, 2.430499792098999], - "handle_left": [0.7365860939025879, 1.4711904525756836], - "handle_right": [1.696347713470459, 3.42288875579834]} - ,{ "co": [2.4583333333333335, 5.0], - "handle_left": [1.9703189531962078, 5.0], - "handle_right": [2.9463475545247397, 5.0]} - ]} - ,{ "name": "z", - "keyframes": [ - { "co": [0.0, 0.0], - "handle_left": [-0.4717472394307454, 0.0], - "handle_right": [0.4717472394307454, 0.0]} - ,{ "co": [1.2083333333333333, 0.0], - "handle_left": [0.7365860939025879, 0.0], - "handle_right": [1.696347713470459, 0.0]} - ,{ "co": [2.4583333333333335, 0.0], - "handle_left": [1.9703189531962078, 0.0], - "handle_right": [2.9463475545247397, 0.0]} - ]} - ,{ "name": "y", - "keyframes": [ - { "co": [0.0, 0.0], - "handle_left": [-0.4717472394307454, 0.0], - "handle_right": [0.4717472394307454, 0.0]} - ,{ "co": [1.2083333333333333, 3.0], - "handle_left": [0.7365860939025879, 3.0], - "handle_right": [1.696347713470459, 3.0]} - ,{ "co": [2.4583333333333335, 0.0], - "handle_left": [1.9703189531962078, 0.0], - "handle_right": [2.9463475545247397, 0.0]} - ]} - ]} - ,{ "group": "Rotation", - "channels": [ - { "name": "w", - "keyframes": [ - { "co": [0.0, 1.0], - "handle_left": [-0.9597616195678711, 1.0], - "handle_right": [0.9597616195678711, 1.0]} - ,{ "co": [2.4583333333333335, -4.371138828673793e-08], - "handle_left": [1.4985717137654622, -4.371138828673793e-08], - "handle_right": [3.4180949529012046, -4.371138828673793e-08]} - ]} - ,{ "name": "x", - "keyframes": [ - { "co": [0.0, 0.0], - "handle_left": [-0.9597616195678711, 0.0], - "handle_right": [0.9597616195678711, 0.0]} - ,{ "co": [2.4583333333333335, 0.0], - "handle_left": [1.4985717137654622, 0.0], - "handle_right": [3.4180949529012046, 0.0]} - ]} - ,{ "name": "z", - "keyframes": [ - { "co": [0.0, -0.0], - "handle_left": [-0.9597616195678711, -0.0], - "handle_right": [0.9597616195678711, -0.0]} - ,{ "co": [2.4583333333333335, -1.0], - "handle_left": [1.4985717137654622, -1.0], - "handle_right": [3.4180949529012046, -1.0]} - ]} - ,{ "name": "y", - "keyframes": [ - { "co": [0.0, 0.0], - "handle_left": [-0.9597616195678711, 0.0], - "handle_right": [0.9597616195678711, 0.0]} - ,{ "co": [2.4583333333333335, 0.0], - "handle_left": [1.4985717137654622, 0.0], - "handle_right": [3.4180949529012046, 0.0]} - ]} - ]} - ]} - ] -} + { + "animationName": "CubeAction", + "channels": [ + { + "channelComponents": [ + { + "channelComponentName": "Location X", + "keyFrames": [ + { + "coords": [ + 0.0, + 0.0 + ], + "leftHandle": [ + -0.9597616195678711, + 0.0 + ], + "rightHandle": [ + 0.9597616195678711, + 0.0 + ] + }, + { + "coords": [ + 2.4583333333333335, + 5.0 + ], + "leftHandle": [ + 1.4985717137654622, + 5.0 + ], + "rightHandle": [ + 3.4180949529012046, + 5.0 + ] + } + ] + }, + { + "channelComponentName": "Location Z", + "keyFrames": [ + { + "coords": [ + 0.0, + 0.0 + ], + "leftHandle": [ + -0.9597616195678711, + 0.0 + ], + "rightHandle": [ + 0.9597616195678711, + 0.0 + ] + }, + { + "coords": [ + 2.4583333333333335, + 0.0 + ], + "leftHandle": [ + 1.4985717137654622, + 0.0 + ], + "rightHandle": [ + 3.4180949529012046, + 0.0 + ] + } + ] + }, + { + "channelComponentName": "Location Y", + "keyFrames": [ + { + "coords": [ + 0.0, + 0.0 + ], + "leftHandle": [ + -0.9597616195678711, + 0.0 + ], + "rightHandle": [ + 0.9597616195678711, + 0.0 + ] + }, + { + "coords": [ + 2.4583333333333335, + 0.0 + ], + "leftHandle": [ + 1.4985717137654622, + 0.0 + ], + "rightHandle": [ + 3.4180949529012046, + 0.0 + ] + } + ] + } + ], + "channelName": "Location" + }, + { + "channelComponents": [ + { + "channelComponentName": "Rotation W", + "keyFrames": [ + { + "coords": [ + 0.0, + 1.0 + ], + "leftHandle": [ + -0.9597616195678711, + 1.0 + ], + "rightHandle": [ + 0.9597616195678711, + 1.0 + ] + }, + { + "coords": [ + 2.4583333333333335, + -4.371138828673793e-08 + ], + "leftHandle": [ + 1.4985717137654622, + -4.371138828673793e-08 + ], + "rightHandle": [ + 3.4180949529012046, + -4.371138828673793e-08 + ] + } + ] + }, + { + "channelComponentName": "Rotation X", + "keyFrames": [ + { + "coords": [ + 0.0, + 0.0 + ], + "leftHandle": [ + -0.9597616195678711, + 0.0 + ], + "rightHandle": [ + 0.9597616195678711, + 0.0 + ] + }, + { + "coords": [ + 2.4583333333333335, + 0.0 + ], + "leftHandle": [ + 1.4985717137654622, + 0.0 + ], + "rightHandle": [ + 3.4180949529012046, + 0.0 + ] + } + ] + }, + { + "channelComponentName": "Rotation Z", + "keyFrames": [ + { + "coords": [ + 0.0, + -0.0 + ], + "leftHandle": [ + -0.9597616195678711, + -0.0 + ], + "rightHandle": [ + 0.9597616195678711, + -0.0 + ] + }, + { + "coords": [ + 2.4583333333333335, + -1.0 + ], + "leftHandle": [ + 1.4985717137654622, + -1.0 + ], + "rightHandle": [ + 3.4180949529012046, + -1.0 + ] + } + ] + }, + { + "channelComponentName": "Rotation Y", + "keyFrames": [ + { + "coords": [ + 0.0, + 0.0 + ], + "leftHandle": [ + -0.9597616195678711, + 0.0 + ], + "rightHandle": [ + 0.9597616195678711, + 0.0 + ] + }, + { + "coords": [ + 2.4583333333333335, + 0.0 + ], + "leftHandle": [ + 1.4985717137654622, + 0.0 + ], + "rightHandle": [ + 3.4180949529012046, + 0.0 + ] + } + ] + } + ], + "channelName": "Rotation" + } + ] + } + ] +}
\ No newline at end of file diff --git a/tests/manual/animation-keyframe-simple/main.cpp b/tests/manual/animation-keyframe-simple/main.cpp index fc48fc702..fce9ecc5f 100644 --- a/tests/manual/animation-keyframe-simple/main.cpp +++ b/tests/manual/animation-keyframe-simple/main.cpp @@ -1,11 +1,52 @@ -/************************************************************************* - * - * Copyright (c) 2016, Klaralvdalens Datakonsult AB (KDAB) - * All rights reserved. - * - * See the LICENSE.txt file shipped along with this file for the license. - * - *************************************************************************/ +/**************************************************************************** +** +** Copyright (C) 2017 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 <QGuiApplication> #include <Qt3DAnimation/QAnimationAspect> diff --git a/tests/manual/animation-keyframe-simple/main.qml b/tests/manual/animation-keyframe-simple/main.qml index 8546d8b34..79fb75fbd 100644 --- a/tests/manual/animation-keyframe-simple/main.qml +++ b/tests/manual/animation-keyframe-simple/main.qml @@ -1,16 +1,57 @@ -/************************************************************************* - * - * Copyright (c) 2016, Klaralvdalens Datakonsult AB (KDAB) - * All rights reserved. - * - * See the LICENSE.txt file shipped along with this file for the license. - * - *************************************************************************/ +/**************************************************************************** +** +** Copyright (C) 2017 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.Animation 2.2 +import Qt3D.Animation 2.9 import Qt3D.Extras 2.0 DefaultSceneEntity { @@ -41,7 +82,7 @@ DefaultSceneEntity { loops: 3 onRunningChanged: console.log("running = " + running) - clip: AnimationClip { + clip: AnimationClipLoader { source: "cubeanimation.json" onDurationChanged: console.log("duration = " + duration) } @@ -62,64 +103,6 @@ DefaultSceneEntity { ] } - Entity { - id: sphere - - components: [ - Transform { - id: sphereTransform - translation: Qt.vector3d(5, 0, 0) - onTranslationChanged: console.log("t = " + translation) - }, - SphereMesh { - }, - PhongMaterial { - id: sphereMaterial - ambient: Qt.rgba(0.02, 0.02, 0.02, 1.0) - diffuse: "red" - shininess: 50 - }, - ObjectPicker { - onClicked: blendedAnimator.running = true - }, - BlendedClipAnimator { - id: blendedAnimator - loops: 2 - - onRunningChanged: console.log("running = " + running) - - blendTree: LerpBlend { - blendFactor: 0.5 - clips: [ - AnimationClip { - source: "cubeanimation.json" - onDurationChanged: console.log("duration = " + duration) - }, - AnimationClip { - source: "pulsing-moving-cube.json" - onDurationChanged: console.log("duration = " + duration) - }] - } - - - // By default introspect parent Entity and try - // to map fcurve groups to properties of QTransform - // mapping: AutomaticAnimationMapping {} - - // To do more, we can be explicit - channelMapper: ChannelMapper { - mappings: [ - ChannelMapping { channelName: "Location"; target: sphereTransform; property: "translation" }, - ChannelMapping { channelName: "Rotation"; target: sphereTransform; property: "rotation" }, - ChannelMapping { channelName: "Scaling"; target: sphereTransform; property: "scale3D" }, - ChannelMapping { channelName: "Diffuse Color"; target: sphereMaterial; property: "diffuse" } - ] - } - } - ] - } - - camera: Camera { position: Qt.vector3d(10, 3, 15) viewCenter: Qt.vector3d(2.5, 1, 0) diff --git a/tests/manual/animation-keyframe-simple/main.qrc b/tests/manual/animation-keyframe-simple/main.qrc index 323756a88..b59429895 100644 --- a/tests/manual/animation-keyframe-simple/main.qrc +++ b/tests/manual/animation-keyframe-simple/main.qrc @@ -4,5 +4,6 @@ <file>DefaultSceneEntity.qml</file> <file>cubeanimation.json</file> <file>pulsing-moving-cube.json</file> + <file>pulsing-cube-additive.json</file> </qresource> </RCC> diff --git a/tests/manual/animation-keyframe-simple/pulsing-cube-additive.json b/tests/manual/animation-keyframe-simple/pulsing-cube-additive.json new file mode 100644 index 000000000..1373a5002 --- /dev/null +++ b/tests/manual/animation-keyframe-simple/pulsing-cube-additive.json @@ -0,0 +1,84 @@ +{ + "animations": [ + { "object": "Cube", + "action": "CubeAction", + "range": [0.0, 60.0], + "groups": [ + { "group": "Scaling", + "channels": [ + { "name": "x", + "keyframes": [ + { "co": [0.0, 1.0], + "handle_left": [-0.1464043160279592, 1.0], + "handle_right": [0.14640430609385172, 1.0]} + ,{ "co": [0.375, 0.5], + "handle_left": [0.22859569390614828, 0.5], + "handle_right": [0.5376714468002319, 0.5]} + ,{ "co": [0.7916666666666666, 1.0], + "handle_left": [0.6289951801300049, 1.0], + "handle_right": [0.9543381532033285, 1.0]} + ,{ "co": [1.2083333333333333, 0.5], + "handle_left": [1.0456619262695312, 0.5], + "handle_right": [1.371035893758138, 0.5]} + ,{ "co": [1.625, 1.0], + "handle_left": [1.462328592936198, 1.0], + "handle_right": [1.787671407063802, 1.0]} + ,{ "co": [2.0416666666666665, 0.5], + "handle_left": [1.8789952596028645, 0.5], + "handle_right": [2.2043380737304688, 0.5]} + ,{ "co": [2.4583333333333335, 1.0], + "handle_left": [2.2956619262695312, 1.0], + "handle_right": [2.6210047403971353, 1.0]} + ]} + ,{ "name": "z", + "keyframes": [ + { "co": [0.0, 1.0], + "handle_left": [-0.1464043160279592, 1.0], + "handle_right": [0.14640430609385172, 1.0]} + ,{ "co": [0.375, 0.5], + "handle_left": [0.22859569390614828, 0.5], + "handle_right": [0.5376714468002319, 0.5]} + ,{ "co": [0.7916666666666666, 1.0], + "handle_left": [0.6289951801300049, 1.0], + "handle_right": [0.9543381532033285, 1.0]} + ,{ "co": [1.2083333333333333, 0.5], + "handle_left": [1.0456618467966716, 0.5], + "handle_right": [1.3710047403971355, 0.5]} + ,{ "co": [1.625, 1.0], + "handle_left": [1.462328592936198, 1.0], + "handle_right": [1.787671407063802, 1.0]} + ,{ "co": [2.0416666666666665, 0.5], + "handle_left": [1.8789952596028645, 0.5], + "handle_right": [2.2043380737304688, 0.5]} + ,{ "co": [2.4583333333333335, 1.0], + "handle_left": [2.2956619262695312, 1.0], + "handle_right": [2.6210047403971353, 1.0]} + ]} + ,{ "name": "y", + "keyframes": [ + { "co": [0.0, 1.0], + "handle_left": [-0.1464043160279592, 1.0], + "handle_right": [0.14640430609385172, 1.0]} + ,{ "co": [0.375, 0.5], + "handle_left": [0.22859569390614828, 0.5], + "handle_right": [0.5376714468002319, 0.5]} + ,{ "co": [0.7916666666666666, 1.0], + "handle_left": [0.6289951801300049, 1.0], + "handle_right": [0.9543381532033285, 1.0]} + ,{ "co": [1.2083333333333333, 0.5441937446594238], + "handle_left": [1.0456618467966716, 0.5441937446594238], + "handle_right": [1.3710047403971355, 0.5441937446594238]} + ,{ "co": [1.625, 1.0], + "handle_left": [1.462328592936198, 1.0], + "handle_right": [1.787671407063802, 1.0]} + ,{ "co": [2.0416666666666665, 0.5771476030349731], + "handle_left": [1.8789952596028645, 0.5771476030349731], + "handle_right": [2.2043380737304688, 0.5771476030349731]} + ,{ "co": [2.4583333333333335, 1.0], + "handle_left": [2.2956619262695312, 1.0], + "handle_right": [2.6210047403971353, 1.0]} + ]} + ]} + ]} + ] +} diff --git a/tests/manual/buffercapture-qml/BufferSetterScene.qml b/tests/manual/buffercapture-qml/BufferSetterScene.qml new file mode 100644 index 000000000..2b2b2a85a --- /dev/null +++ b/tests/manual/buffercapture-qml/BufferSetterScene.qml @@ -0,0 +1,114 @@ +/**************************************************************************** +** +** Copyright (C) 2017 Juan José Casafranca. +** 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.2 as QQ2 +import Qt3D.Core 2.0 +import Qt3D.Render 2.9 +import Qt3D.Input 2.0 +import Qt3D.Extras 2.0 + +Entity { + id: sceneRoot + + Camera { + id: sceneCamera + projectionType: CameraLens.PerspectiveProjection + upVector: Qt.vector3d(0, 1, 0) + position: Qt.vector3d(0, 0, -800) + viewCenter: Qt.vector3d(0, 0, 0) + nearPlane: 0.1 + farPlane: 1000 + fieldOfView: 25 + aspectRatio: 1.33 + } + + components: [ + RenderSettings { + ComputeFrameGraph { + } + // explicitly set RenderingPolicy to AlwaysRender, as changes in the + // scene won't be reflected in actual Qt scene-graph changes (due to + // GPU compute calls) + renderPolicy: RenderSettings.Always + } + ] + + function initGraphBuffer() { + var bufferData = new Uint32Array(1024); + for (var i = 0; i < 1024; ++i) { + bufferData[i] = 1; + } + return bufferData + } + + + Buffer { + id: graphBuffer + objectName: "buffer" + type: Buffer.VertexBuffer + data: initGraphBuffer() + accessType: Buffer.ReadWrite + } + + ComputeMaterial { + id: computeMaterial + dataBuffer: graphBuffer + inputSize: 1024 + } + + Entity { + id: particleComputeEntity + readonly property ComputeCommand particlesComputeJob: ComputeCommand {} + components: [ + particlesComputeJob, + computeMaterial + ] + } +} diff --git a/tests/manual/buffercapture-qml/ComputeFrameGraph.qml b/tests/manual/buffercapture-qml/ComputeFrameGraph.qml new file mode 100644 index 000000000..bc2061e1a --- /dev/null +++ b/tests/manual/buffercapture-qml/ComputeFrameGraph.qml @@ -0,0 +1,74 @@ +/**************************************************************************** +** +** Copyright (C) 2017 Juan José Casafranca. +** 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.9 + +Viewport { + RenderSurfaceSelector { + id: surfaceSelector + + // Compute Pass + DispatchCompute { + workGroupX: 50; workGroupY: 1; workGroupZ: 1 + BufferCapture { + TechniqueFilter { + matchAll: [ + FilterKey { name: "type"; value: "compute"} + ] + } + } + } + + NoDraw { } + } +} + + diff --git a/tests/manual/buffercapture-qml/ComputeMaterial.qml b/tests/manual/buffercapture-qml/ComputeMaterial.qml new file mode 100644 index 000000000..05c56901c --- /dev/null +++ b/tests/manual/buffercapture-qml/ComputeMaterial.qml @@ -0,0 +1,91 @@ +/**************************************************************************** +** +** Copyright (C) 2017 Juan José Casafranca. +** 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 { + property Buffer dataBuffer; + property int inputSize; + + parameters: [ + Parameter { name: "inputSize"; value: inputSize} + ] + + ShaderProgram { + id: computeShader + computeShaderCode: loadSource("qrc:/bufferSetter.comp") + } + + effect: Effect { + techniques: [ + Technique { + renderPasses: [ + RenderPass { + shaderProgram: computeShader + // We set the buffer as the parameter data + parameters: [ + Parameter { name: "input"; value: dataBuffer } + ] + } + ] + filterKeys: [ + FilterKey { name: "type"; value: "compute" } + ] + graphicsApiFilter { + api: GraphicsApiFilter.OpenGL + profile: GraphicsApiFilter.CoreProfile + majorVersion: 4 + minorVersion: 3 + } + } + ] // techniques + } +} diff --git a/tests/manual/buffercapture-qml/bufferSetter.comp b/tests/manual/buffercapture-qml/bufferSetter.comp new file mode 100755 index 000000000..d7c383669 --- /dev/null +++ b/tests/manual/buffercapture-qml/bufferSetter.comp @@ -0,0 +1,66 @@ +/**************************************************************************** +** +** Copyright (C) 2017 Juan José Casafranca. +** 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$ +** +****************************************************************************/ + +#version 430 core + +layout (local_size_x=32) in; + +layout (std430, binding = 1) buffer input +{ + uint d[]; +}; + +layout (location=1) uniform int inputSize; + +void main() +{ + if (gl_GlobalInvocationID.x < inputSize) + d[gl_GlobalInvocationID.x] = d[gl_GlobalInvocationID.x] + gl_GlobalInvocationID.x * 2; +} diff --git a/tests/manual/buffercapture-qml/buffercapture-qml.pro b/tests/manual/buffercapture-qml/buffercapture-qml.pro new file mode 100644 index 000000000..32b79a36e --- /dev/null +++ b/tests/manual/buffercapture-qml/buffercapture-qml.pro @@ -0,0 +1,16 @@ +!include( ../manual.pri ) { + error( "Couldn't find the manual.pri file!" ) +} + +QT += 3dcore 3drender 3dinput 3dextras 3dquick 3dlogic qml quick 3dquickextras + +SOURCES += \ + main.cpp + +DISTFILES += \ + main.qml \ + main.qml + +RESOURCES += \ + resources.qrc + diff --git a/tests/manual/buffercapture-qml/main.cpp b/tests/manual/buffercapture-qml/main.cpp new file mode 100644 index 000000000..6928c5724 --- /dev/null +++ b/tests/manual/buffercapture-qml/main.cpp @@ -0,0 +1,85 @@ +/**************************************************************************** +** +** Copyright (C) 2017 Juan José Casafranca. +** 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 <QQuickItem> +#include <QQuickView> +#include <Qt3DQuick/QQmlAspectEngine> +#include <QGuiApplication> +#include <QQmlEngine> +#include <QQmlContext> + +#include <Qt3DRender> +#include <iostream> + + +int main(int argc, char* argv[]) +{ + QGuiApplication app(argc, argv); + QQuickView view; + + view.setSource(QUrl("qrc:/main.qml")); + + QObject *rootObject = view.rootObject(); + Qt3DRender::QBuffer *buffer = rootObject->findChild<Qt3DRender::QBuffer*>("buffer"); + + QObject::connect(buffer, &Qt3DRender::QBuffer::dataChanged, + [=](const QByteArray &bytes) { + //I know I'm receiving int data + const uint *data = reinterpret_cast<const uint*>(bytes.data()); + qDebug() << "Data received"; + for (uint i = 0; i < 1024; ++i) + qDebug() << data[i]; + } + ); + + view.show(); + + return app.exec(); +} diff --git a/tests/manual/buffercapture-qml/main.qml b/tests/manual/buffercapture-qml/main.qml new file mode 100644 index 000000000..a2680e921 --- /dev/null +++ b/tests/manual/buffercapture-qml/main.qml @@ -0,0 +1,65 @@ +/**************************************************************************** +** +** Copyright (C) 2017 Juan José Casafranca. +** 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.0 +import Qt3D.Core 2.0 +import Qt3D.Render 2.0 +import QtQuick.Scene3D 2.0 + +Item { + width: 128 + height: width + Scene3D { + anchors.fill: parent + BufferSetterScene { + id: scene + } + } +} diff --git a/tests/manual/buffercapture-qml/resources.qrc b/tests/manual/buffercapture-qml/resources.qrc new file mode 100644 index 000000000..167957feb --- /dev/null +++ b/tests/manual/buffercapture-qml/resources.qrc @@ -0,0 +1,9 @@ +<RCC> + <qresource prefix="/"> + <file>BufferSetterScene.qml</file> + <file>bufferSetter.comp</file> + <file>main.qml</file> + <file>ComputeFrameGraph.qml</file> + <file>ComputeMaterial.qml</file> + </qresource> +</RCC> diff --git a/tests/manual/custom-mesh-update-data-cpp/main.cpp b/tests/manual/custom-mesh-update-data-cpp/main.cpp index 7485dbec5..80ee2088d 100644 --- a/tests/manual/custom-mesh-update-data-cpp/main.cpp +++ b/tests/manual/custom-mesh-update-data-cpp/main.cpp @@ -277,7 +277,7 @@ int main(int argc, char* argv[]) void TimerObject::timeout() { - angle += M_PI / 360.0f; + angle += qDegreesToRadians(0.5f); QByteArray updateData; updateData.resize(3*sizeof(float)); diff --git a/tests/manual/custom-mesh-update-data-qml/main.qml b/tests/manual/custom-mesh-update-data-qml/main.qml index e95c05a26..909dbf9ca 100644 --- a/tests/manual/custom-mesh-update-data-qml/main.qml +++ b/tests/manual/custom-mesh-update-data-qml/main.qml @@ -224,7 +224,7 @@ Entity { byteOffset: 0 byteStride: 9 * 4 count: 4 - name: defaultPositionAttributeName() + name: defaultPositionAttributeName buffer: vertexBuffer } @@ -235,7 +235,7 @@ Entity { byteOffset: 3 * 4 byteStride: 9 * 4 count: 4 - name: defaultNormalAttributeName() + name: defaultNormalAttributeName buffer: vertexBuffer } @@ -246,7 +246,7 @@ Entity { byteOffset: 6 * 4 byteStride: 9 * 4 count: 4 - name: defaultColorAttributeName() + name: defaultColorAttributeName buffer: vertexBuffer } diff --git a/tests/manual/deferred-renderer-cpp/gbuffer.h b/tests/manual/deferred-renderer-cpp/gbuffer.h index dab8b6752..7ffaffe2a 100644 --- a/tests/manual/deferred-renderer-cpp/gbuffer.h +++ b/tests/manual/deferred-renderer-cpp/gbuffer.h @@ -75,7 +75,6 @@ public: private: Qt3DRender::QAbstractTexture *m_textures[AttachmentsCount]; - Qt3DRender::QRenderTargetOutput *m_attachments[AttachmentsCount]; }; #endif // GBUFFER_H diff --git a/tests/manual/distancefieldtext/TextScene.qml b/tests/manual/distancefieldtext/TextScene.qml new file mode 100644 index 000000000..5e94a9aaf --- /dev/null +++ b/tests/manual/distancefieldtext/TextScene.qml @@ -0,0 +1,151 @@ +/**************************************************************************** +** +** Copyright (C) 2016 Klaralvdalens Datakonsult AB (KDAB). +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the Qt3D module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE: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.9 +import QtQuick 2.0 as QQ2; + +Entity { + id: sceneRoot + + property alias fontFamily : text.font.family + property alias fontBold : text.font.bold + property alias fontItalic : text.font.italic + + signal clicked() + + Camera { + id: camera + projectionType: CameraLens.PerspectiveProjection + fieldOfView: 45 + aspectRatio: 16/9 + nearPlane : 0.1 + farPlane : 1000.0 + position: Qt.vector3d( 0.0, 0.0, 20.0 ) + upVector: Qt.vector3d( 0.0, 1.0, 0.0 ) + viewCenter: Qt.vector3d( 0.0, 0.0, 0.0 ) + } + + FirstPersonCameraController { + camera: camera + linearSpeed: 0.1 + camera.position.z + } + + components: [ + RenderSettings { + activeFrameGraph : ForwardRenderer { + camera: camera + clearColor: "black" + } + }, + InputSettings { + } + ] + + function getChars(n) { + var s = ""; + for (var i = 0; i < n; i++) { + s += String.fromCharCode(32+i); + if (i % 16 == 15) + s += "\n"; + } + return s; + } + + property int strLen : 28 + + onClicked: { + strLen += 1 + if (strLen > 96) + strLen = 10 + } + + Entity { + components: [ + Transform { + id: rot + translation: Qt.vector3d(-5, -5, 0) + } + ] + + QQ2.SequentialAnimation { + loops: QQ2.Animation.Infinite + running: true + QQ2.NumberAnimation { + target: rot + property: "rotationY" + from: 0; to: -80; + duration: 2000 + } + QQ2.NumberAnimation { + target: rot + property: "rotationY" + from: -80; to: 80; + duration: 4000 + } + QQ2.NumberAnimation { + target: rot + property: "rotationY" + from: 80; to: 0; + duration: 2000 + } + } + + Text2DEntity { + id: text + font.pointSize: 1 + text: getChars(strLen) + width: 20 + height: 10 + } + } +} diff --git a/tests/manual/distancefieldtext/distancefieldtext.pro b/tests/manual/distancefieldtext/distancefieldtext.pro new file mode 100644 index 000000000..01f080917 --- /dev/null +++ b/tests/manual/distancefieldtext/distancefieldtext.pro @@ -0,0 +1,15 @@ +!include( ../manual.pri ) { + error( "Couldn't find the manual.pri file!" ) +} + +QT += 3dcore 3drender 3dinput 3dquick qml quick 3dquickextras + +SOURCES += \ + main.cpp + +OTHER_FILES += \ + TextScene.qml \ + main.qml + +RESOURCES += \ + distancefieldtext.qrc diff --git a/tests/manual/distancefieldtext/distancefieldtext.qrc b/tests/manual/distancefieldtext/distancefieldtext.qrc new file mode 100644 index 000000000..5a60978c0 --- /dev/null +++ b/tests/manual/distancefieldtext/distancefieldtext.qrc @@ -0,0 +1,6 @@ +<RCC> + <qresource prefix="/"> + <file>main.qml</file> + <file>TextScene.qml</file> + </qresource> +</RCC> diff --git a/tests/manual/distancefieldtext/main.cpp b/tests/manual/distancefieldtext/main.cpp new file mode 100644 index 000000000..28ba977d8 --- /dev/null +++ b/tests/manual/distancefieldtext/main.cpp @@ -0,0 +1,75 @@ +/**************************************************************************** +** +** Copyright (C) 2016 Klaralvdalens Datakonsult AB (KDAB). +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the Qt3D module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE: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 <QGuiApplication> +#include <QQuickView> +#include <QOpenGLContext> + +int main(int argc, char **argv) +{ + QGuiApplication app(argc, argv); + + QSurfaceFormat format; + if (QOpenGLContext::openGLModuleType() == QOpenGLContext::LibGL) { + format.setVersion(3, 2); + format.setProfile(QSurfaceFormat::CoreProfile); + format.setDepthBufferSize(24); + format.setStencilBufferSize(8); + } + + QQuickView view; + view.setFormat(format); + view.resize(1200, 600); + view.setResizeMode(QQuickView::SizeRootObjectToView); + view.setSource(QUrl("qrc:/main.qml")); + view.show(); + + return app.exec(); +} diff --git a/tests/manual/distancefieldtext/main.qml b/tests/manual/distancefieldtext/main.qml new file mode 100644 index 000000000..69c76bb8f --- /dev/null +++ b/tests/manual/distancefieldtext/main.qml @@ -0,0 +1,155 @@ +/**************************************************************************** +** +** Copyright (C) 2016 Klaralvdalens Datakonsult AB (KDAB). +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the Qt3D module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE: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.0 +import QtQuick.Scene3D 2.0 + +Item { + id: root + property string currentFont + property bool bold : false + property bool italic : false + + Scene3D { + id: scene3d + anchors.left: parent.left + anchors.top: parent.top + anchors.bottom: parent.bottom + anchors.right: settingsPane.left + focus: true + aspects: ["input", "logic", "render"] + cameraAspectRatioMode: Scene3D.AutomaticAspectRatio + + TextScene { + id: textScene + fontFamily: root.currentFont + fontBold: bold + fontItalic: italic + } + } + + MouseArea { + anchors.fill: parent + onClicked: { + textScene.clicked() + } + } + + Item { + id: settingsPane + + anchors.right: parent.right + anchors.top: parent.top + anchors.bottom: parent.bottom + width: 400 + + Rectangle { + width: parent.width/2 + height:50 + color: root.bold ? "#000066" : "#222222" + Text { + anchors.centerIn: parent + text: "Bold" + font.pointSize: 20 + color: "#ffffff" + } + MouseArea { + anchors.fill: parent + onClicked: root.bold = !root.bold + } + } + + Rectangle { + x: parent.width/2 + width: parent.width/2 + height:50 + color: root.italic ? "#000066" : "#222222" + Text { + anchors.centerIn: parent + text: "Italic" + font.pointSize: 20 + color: "#ffffff" + } + MouseArea { + anchors.fill: parent + onClicked: root.italic = !root.italic + } + } + + ListView { + anchors.fill: parent + anchors.topMargin: 50 + model: Qt.fontFamilies() + + delegate: Rectangle { + height: fontFamilyText.height + 10 + width: parent.width + color: (modelData == root.currentFont) ? "#000066" : "#222222" + + Text { + id: fontFamilyText + anchors.centerIn: parent + font.pointSize: 14 + font.family: modelData + text: modelData + color: "#ffffff" + } + + MouseArea { + anchors.fill: parent + onClicked: { + root.currentFont = modelData; + + } + } + } + } + } +} diff --git a/tests/manual/downloading/downloading.pro b/tests/manual/downloading/downloading.pro new file mode 100644 index 000000000..6f1b6e3d5 --- /dev/null +++ b/tests/manual/downloading/downloading.pro @@ -0,0 +1,14 @@ +!include( ../manual.pri ) { + error( "Couldn't find the manual.pri file!" ) +} + +QT += 3dcore 3drender 3dinput 3dquick qml quick 3dquickextras + +SOURCES += \ + main.cpp + +OTHER_FILES += \ + main.qml + +RESOURCES += \ + downloading.qrc diff --git a/tests/manual/downloading/downloading.qrc b/tests/manual/downloading/downloading.qrc new file mode 100644 index 000000000..5f6483ac3 --- /dev/null +++ b/tests/manual/downloading/downloading.qrc @@ -0,0 +1,5 @@ +<RCC> + <qresource prefix="/"> + <file>main.qml</file> + </qresource> +</RCC> diff --git a/tests/manual/downloading/main.cpp b/tests/manual/downloading/main.cpp new file mode 100644 index 000000000..dba6e0bff --- /dev/null +++ b/tests/manual/downloading/main.cpp @@ -0,0 +1,63 @@ +/**************************************************************************** +** +** Copyright (C) 2017 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/downloading/main.qml b/tests/manual/downloading/main.qml new file mode 100644 index 000000000..e2f42284d --- /dev/null +++ b/tests/manual/downloading/main.qml @@ -0,0 +1,105 @@ +/**************************************************************************** +** +** Copyright (C) 2017 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: sceneRoot + + Camera { + id: camera + position: Qt.vector3d( 0.0, 0.5, 15.0 ) + viewCenter: Qt.vector3d( 0.0, 0.5, 0.0 ) + } + + OrbitCameraController { camera: camera } + + RenderSettings { + id : external_forward_renderer + activeFrameGraph : ForwardRenderer { + camera: camera + clearColor: "white" + } + } + + // Event Source will be set by the Qt3DQuickWindow + InputSettings { id: inputSettings } + + DirectionalLight { id: light; worldDirection: camera.viewVector } + + components: [external_forward_renderer, inputSettings, light] + + Mesh { + id: mesh + source: "https://codereview.qt-project.org/gitweb?p=qt/qt3d.git;a=blob_plain;hb=refs/heads/dev;f=examples/qt3d/exampleresources/assets/chest/Chest.obj" + } + + Transform { + id: transform + scale: 0.03 + rotation: fromAxisAndAngle(Qt.vector3d(1, 0, 0), 30) + } + + DiffuseMapMaterial { + id: material + diffuse: TextureLoader { source: "https://codereview.qt-project.org/gitweb?p=qt/qt3d.git;a=blob_plain;hb=refs/heads/dev;f=examples/qt3d/planets-qml/images/earthmap1k.jpg" } + specular: Qt.rgba( 0.2, 0.2, 0.2, 1.0 ) + shininess: 2.0 + } + + Entity { + id: mainEntity + objectName: "mainEntity" + components: [ mesh, material, transform ] + } +} diff --git a/tests/manual/dynamic-model-loader-qml/CuboidEntity.qml b/tests/manual/dynamic-model-loader-qml/CuboidEntity.qml index 8555b6903..d9b33c511 100644 --- a/tests/manual/dynamic-model-loader-qml/CuboidEntity.qml +++ b/tests/manual/dynamic-model-loader-qml/CuboidEntity.qml @@ -76,7 +76,7 @@ Entity { QQ2.ColorAnimation { target: phongMaterial - property: "warmColor" + property: "warm" from: "red" to: "blue" duration: 2500 diff --git a/tests/manual/gltf/main.qml b/tests/manual/gltf/main.qml index 1afb8c48e..39fbb9acf 100644 --- a/tests/manual/gltf/main.qml +++ b/tests/manual/gltf/main.qml @@ -79,7 +79,7 @@ Entity { buffers : ClearBuffers.ColorDepthBuffer clearColor: "black" SortPolicy { - sortTypes: [ SortType.BackToFront ] + sortTypes: [ SortPolicy.BackToFront ] } } } diff --git a/tests/manual/loader-qml/CuboidEntity.qml b/tests/manual/loader-qml/CuboidEntity.qml index 8555b6903..d9b33c511 100644 --- a/tests/manual/loader-qml/CuboidEntity.qml +++ b/tests/manual/loader-qml/CuboidEntity.qml @@ -76,7 +76,7 @@ Entity { QQ2.ColorAnimation { target: phongMaterial - property: "warmColor" + property: "warm" from: "red" to: "blue" duration: 2500 diff --git a/tests/manual/lod/main.qml b/tests/manual/lod/main.qml index 8d9c8722a..80547dcff 100644 --- a/tests/manual/lod/main.qml +++ b/tests/manual/lod/main.qml @@ -49,9 +49,9 @@ ****************************************************************************/ import Qt3D.Core 2.0 -import Qt3D.Render 2.2 +import Qt3D.Render 2.9 import Qt3D.Input 2.0 -import Qt3D.Extras 2.2 +import Qt3D.Extras 2.9 import QtQuick 2.0 as QQ2 @@ -126,10 +126,8 @@ Entity { id: lod camera: camera thresholds: [1000, 600, 300, 180] - thresholdType: LevelOfDetail.ProjectedScreenPixelSize - volumeOverride: BoundingSphere { - radius: 2. - } + thresholdType: LevelOfDetail.ProjectedScreenPixelSizeThreshold + volumeOverride: lod.createBoundingSphere(Qt.vector3d(0, 0, 0), 2.0) } ] } @@ -143,6 +141,7 @@ Entity { ] LevelOfDetailLoader { + id: lodLoader components: [ Transform { scale: .5 translation: Qt.vector3d(-8, 0, 0) @@ -150,8 +149,8 @@ Entity { camera: camera thresholds: [20, 35, 50, 65] - thresholdType: LevelOfDetail.DistanceToCamera - volumeOverride: null + thresholdType: LevelOfDetail.DistanceToCameraThreshold + volumeOverride: lodLoader.createBoundingSphere(Qt.vector3d(0, 0, 0), -1) sources: ["qrc:/SphereEntity.qml", "qrc:/CylinderEntity.qml", "qrc:/ConeEntity.qml", "qrc:/CuboidEntity.qml"] } } @@ -172,7 +171,7 @@ Entity { LevelOfDetailSwitch { camera: camera thresholds: [20, 35, 50, 65] - thresholdType: LevelOfDetail.DistanceToCamera + thresholdType: LevelOfDetail.DistanceToCameraThreshold } ] diff --git a/tests/manual/manual.pro b/tests/manual/manual.pro index 0c42b72f0..1dd418500 100644 --- a/tests/manual/manual.pro +++ b/tests/manual/manual.pro @@ -16,6 +16,7 @@ SUBDIRS += \ cylinder-qml \ deferred-renderer-cpp \ deferred-renderer-qml \ + downloading \ dragging \ dynamicscene-cpp \ enabled-qml \ @@ -38,9 +39,16 @@ SUBDIRS += \ rendercapture-qml \ additional-attributes-qml \ dynamic-model-loader-qml \ + buffercapture-qml \ + render-qml-to-texture \ + render-qml-to-texture-qml \ + video-texture-qml \ animation-keyframe-simple \ + animation-keyframe-blendtree \ + distancefieldtext \ mesh-morphing \ - anim-viewer + anim-viewer \ + animation-keyframe-programmatic qtHaveModule(widgets): { SUBDIRS += \ diff --git a/tests/manual/mesh-morphing/main.cpp b/tests/manual/mesh-morphing/main.cpp index 4ae791181..641722a4c 100644 --- a/tests/manual/mesh-morphing/main.cpp +++ b/tests/manual/mesh-morphing/main.cpp @@ -43,8 +43,8 @@ #include <Qt3DExtras/qcylindermesh.h> #include <Qt3DExtras/QPhongMaterial> #include <Qt3DExtras/QMorphPhongMaterial> -#include <Qt3DExtras/QVertexBlendAnimation> -#include <Qt3DExtras/QMorphTarget> +#include <Qt3DAnimation/QVertexBlendAnimation> +#include <Qt3DAnimation/QMorphTarget> #include <Qt3DExtras/QCylinderGeometry> #include <Qt3DCore/qentity.h> @@ -111,13 +111,13 @@ int main(int argc, char **argv) attributes.push_back(Qt3DRender::QAttribute::defaultPositionAttributeName()); attributes.push_back(Qt3DRender::QAttribute::defaultNormalAttributeName()); - QVector<Qt3DExtras::QMorphTarget*> morphTargets; - morphTargets.push_back(Qt3DExtras::QMorphTarget::fromGeometry(cylinder1, attributes)); - morphTargets.push_back(Qt3DExtras::QMorphTarget::fromGeometry(cylinder2, attributes)); - morphTargets.push_back(Qt3DExtras::QMorphTarget::fromGeometry(cylinder3, attributes)); + QVector<Qt3DAnimation::QMorphTarget*> morphTargets; + morphTargets.push_back(Qt3DAnimation::QMorphTarget::fromGeometry(cylinder1, attributes)); + morphTargets.push_back(Qt3DAnimation::QMorphTarget::fromGeometry(cylinder2, attributes)); + morphTargets.push_back(Qt3DAnimation::QMorphTarget::fromGeometry(cylinder3, attributes)); morphTargets.push_back(morphTargets.first()); - Qt3DExtras::QVertexBlendAnimation *animation = new Qt3DExtras::QVertexBlendAnimation; + Qt3DAnimation::QVertexBlendAnimation *animation = new Qt3DAnimation::QVertexBlendAnimation; QVector<float> times; times.push_back(0.0f); times.push_back(5.0f); @@ -132,7 +132,7 @@ int main(int argc, char **argv) Qt3DExtras::QMorphPhongMaterial *material = new Qt3DExtras::QMorphPhongMaterial(rootEntity); material->setDiffuse(Qt::red); - QObject::connect(animation, &Qt3DExtras::QVertexBlendAnimation::interpolatorChanged, + QObject::connect(animation, &Qt3DAnimation::QVertexBlendAnimation::interpolatorChanged, material, &Qt3DExtras::QMorphPhongMaterial::setInterpolator); // Cylinder diff --git a/tests/manual/mesh-morphing/mesh-morphing.pro b/tests/manual/mesh-morphing/mesh-morphing.pro index ad2a31b8b..27419655f 100644 --- a/tests/manual/mesh-morphing/mesh-morphing.pro +++ b/tests/manual/mesh-morphing/mesh-morphing.pro @@ -2,7 +2,7 @@ error( "Couldn't find the manual.pri file!" ) } -QT += 3dcore 3drender 3dquick 3dinput quick qml 3dextras 3dquickextras +QT += 3dcore 3drender 3dquick 3dinput quick qml 3dextras 3dquickextras 3danimation 3dquickanimation SOURCES += \ main.cpp diff --git a/tests/manual/render-qml-to-texture-qml/InteractiveGui.qml b/tests/manual/render-qml-to-texture-qml/InteractiveGui.qml new file mode 100644 index 000000000..65e5f27de --- /dev/null +++ b/tests/manual/render-qml-to-texture-qml/InteractiveGui.qml @@ -0,0 +1,97 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt3D module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** 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 http://www.qt.io/terms-conditions. For further +** information use the contact form at http://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.LGPLv3 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.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 later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import QtQuick.Controls 1.2 +import QtQuick.Controls.Styles 1.3 + +Rectangle { + width: 1024 + height: 1024 + color: "white" + focus: true + + Rectangle { + id: rect + x: 0 + y: 0 + width: 200 + height: 200 + color: "red" + } + + Rectangle { + id: rect2 + width: 300 + height: 100 + anchors.right: parent.right + anchors.bottom: parent.bottom + color: "blue" + } + + Button { + id: button + width: 100 + height: 80 + anchors.top: rect.bottom + anchors.left: parent.left + text: "button" + scale: 2.0 + } + CheckBox { + id: checkbox + width: 200 + height: 180 + scale: 2.0 + text: "checkbox" + checked: true + anchors.top: parent.top + anchors.right: parent.right + } + Slider { + anchors.bottom: parent.bottom + anchors.left: parent.left + width: 400 + value: 1 + minimumValue: 0 + maximumValue: 1 + + onValueChanged: { + rect.color = Qt.rgba(value, 0, 0, 1) + rect2.color = Qt.rgba(0, 0, value, 1) + } + } +} diff --git a/tests/manual/render-qml-to-texture-qml/PlaneMaterial.qml b/tests/manual/render-qml-to-texture-qml/PlaneMaterial.qml new file mode 100644 index 000000000..6c65de9b3 --- /dev/null +++ b/tests/manual/render-qml-to-texture-qml/PlaneMaterial.qml @@ -0,0 +1,117 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt3D module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** 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 http://www.qt.io/terms-conditions. For further +** information use the contact form at http://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.LGPLv3 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.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 later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import Qt3D.Core 2.0 +import Qt3D.Render 2.0 + +Material { + + property Texture2D texture + property vector2d textureScale: Qt.vector2d(1,-1) + property vector2d textureBias: Qt.vector2d(0, 1) + + parameters: [ + Parameter { name: "surfaceTexture"; value: texture }, + Parameter { name: "texCoordScale"; value: textureScale }, + Parameter { name: "texCoordBias"; value: textureBias } + ] + + effect: Effect { + FilterKey { + id: forward + name: "renderingStyle" + value: "forward" + } + + ShaderProgram { + id: gl2Es2Shader + vertexShaderCode: loadSource("qrc:/shaders/es2/texturing.vert") + fragmentShaderCode: loadSource("qrc:/shaders/es2/texturing.frag") + } + + ShaderProgram { + id: gl3Shader + vertexShaderCode: loadSource("qrc:/shaders/gl3/texturing.vert") + fragmentShaderCode: loadSource("qrc:/shaders/gl3/texturing.frag") + } + techniques: [ + // OpenGL 3.1 + Technique { + filterKeys: [ forward ] + graphicsApiFilter { + api: GraphicsApiFilter.OpenGL + profile: GraphicsApiFilter.CoreProfile + majorVersion: 3 + minorVersion: 1 + } + + renderPasses: RenderPass { + shaderProgram: gl3Shader + } + }, + + // OpenGL 2.1 + Technique { + filterKeys: [ forward ] + graphicsApiFilter { + api: GraphicsApiFilter.OpenGL + profile: GraphicsApiFilter.NoProfile + majorVersion: 2 + minorVersion: 0 + } + + renderPasses: RenderPass { + shaderProgram: gl2Es2Shader + } + }, + + // OpenGL ES 2 + Technique { + filterKeys: [ forward ] + graphicsApiFilter { + api: GraphicsApiFilter.OpenGLES + profile: GraphicsApiFilter.NoProfile + majorVersion: 2 + minorVersion: 0 + } + renderPasses: RenderPass { + shaderProgram: gl2Es2Shader + } + } + ] + } +} diff --git a/tests/manual/render-qml-to-texture-qml/main.cpp b/tests/manual/render-qml-to-texture-qml/main.cpp new file mode 100644 index 000000000..ac85cbe46 --- /dev/null +++ b/tests/manual/render-qml-to-texture-qml/main.cpp @@ -0,0 +1,65 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt3D module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** 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 http://www.qt.io/terms-conditions. For further +** information use the contact form at http://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.LGPLv3 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.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 later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include <QGuiApplication> + +#include <QtQuick/QQuickView> +#include <Qt3DQuick/QQmlAspectEngine> +#include <QQmlContext> +#include <QOpenGLContext> + +int main(int argc, char *argv[]) +{ + QGuiApplication app(argc, argv); + + QSurfaceFormat format; + if (QOpenGLContext::openGLModuleType() == QOpenGLContext::LibGL) { + format.setVersion(3, 2); + format.setProfile(QSurfaceFormat::CoreProfile); + } + format.setDepthBufferSize(24); + format.setStencilBufferSize(8); + format.setSamples(4); + + QQuickView view; + view.setFormat(format); + view.setResizeMode(QQuickView::SizeRootObjectToView); + view.setSource(QUrl("qrc:/main.qml")); + view.setColor("#000000"); + view.show(); + + return app.exec(); +} diff --git a/tests/manual/render-qml-to-texture-qml/main.qml b/tests/manual/render-qml-to-texture-qml/main.qml new file mode 100644 index 000000000..65a0a8783 --- /dev/null +++ b/tests/manual/render-qml-to-texture-qml/main.qml @@ -0,0 +1,147 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt3D module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** 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 http://www.qt.io/terms-conditions. For further +** information use the contact form at http://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.LGPLv3 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.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 later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import Qt3D.Core 2.0 +import Qt3D.Render 2.9 +import Qt3D.Input 2.0 +import QtQuick 2.0 as QQ2 +import QtQuick.Scene3D 2.0 +import QtQuick.Scene2D 2.9 +import QtQuick.Window 2.0 as QW2 +import Qt3D.Extras 2.0 + + +QQ2.Item { + width: 1024 + height: 768 + + Scene3D { + id: scene + focus: true + anchors.fill: parent + + aspects: ["input", "logic"] + + Entity { + id: sceneRoot + + Camera { + id: camera + projectionType: CameraLens.PerspectiveProjection + fieldOfView: 45 + aspectRatio: scene.width / scene.height + nearPlane : 0.1 + farPlane : 1000.0 + position: Qt.vector3d( 0.0, 0.0, 6.0 ) + upVector: Qt.vector3d( 0.0, 1.0, 0.0 ) + viewCenter: Qt.vector3d( 0.0, 0.0, 0.0 ) + } + + Scene2D { + id: qmlTexture + output: RenderTargetOutput { + attachmentPoint: RenderTargetOutput.Color0 + texture: Texture2D { + id: offscreenTexture + width: 1024 + height: 1024 + format: Texture.RGBA8_UNorm + generateMipMaps: true + magnificationFilter: Texture.Linear + minificationFilter: Texture.LinearMipMapLinear + wrapMode { + x: WrapMode.ClampToEdge + y: WrapMode.ClampToEdge + } + } + + } + + entities: [plane1] + + mouseEnabled: plane1.picker.pressed + + InteractiveGui { + + } + } + + FirstPersonCameraController { + id: controller + camera: camera + enabled: !plane1.picker.pressed + } + + components: [ + RenderSettings { + pickingSettings.pickMethod: PickingSettings.TrianglePicking + activeFrameGraph: + ForwardRenderer { + camera: camera + } + }, + InputSettings {} + ] + + PlaneMesh { + id: planeMesh + width: 4 + height: 4 + } + + Entity { + id: plane1 + + property Transform transform: Transform { + scale: 1 + translation: Qt.vector3d(0,0,0) + rotation: fromAxisAndAngle(Qt.vector3d(1,0,0), 90) + } + + property Material material: PlaneMaterial { + texture: offscreenTexture + } + + property ObjectPicker picker: ObjectPicker { + hoverEnabled: true + dragEnabled: true + } + + components: [planeMesh, material, transform, picker] + } + } + } +} diff --git a/tests/manual/render-qml-to-texture-qml/render-qml-to-texture-qml.pro b/tests/manual/render-qml-to-texture-qml/render-qml-to-texture-qml.pro new file mode 100644 index 000000000..23729957c --- /dev/null +++ b/tests/manual/render-qml-to-texture-qml/render-qml-to-texture-qml.pro @@ -0,0 +1,21 @@ +!include( ../manual.pri ) { + error( "Couldn't find the manual.pri file!" ) +} + +!include ( ../render-qml-to-texture/render-qml-to-texture.pri ) { + error( "Couldn't find the render-qml-to-texture.pri file!") +} + +QT += 3dextras 3dcore 3drender 3dinput 3dquick qml quick + +SOURCES += main.cpp + +RESOURCES += \ + render-qml-to-texture-qml.qrc + +OTHER_FILES += \ + main.qml + +HEADERS += + + diff --git a/tests/manual/render-qml-to-texture-qml/render-qml-to-texture-qml.qrc b/tests/manual/render-qml-to-texture-qml/render-qml-to-texture-qml.qrc new file mode 100644 index 000000000..51ec4790c --- /dev/null +++ b/tests/manual/render-qml-to-texture-qml/render-qml-to-texture-qml.qrc @@ -0,0 +1,7 @@ +<RCC> + <qresource prefix="/"> + <file>main.qml</file> + <file>PlaneMaterial.qml</file> + <file>InteractiveGui.qml</file> + </qresource> +</RCC> diff --git a/tests/manual/render-qml-to-texture/OffscreenGui.qml b/tests/manual/render-qml-to-texture/OffscreenGui.qml new file mode 100644 index 000000000..20fb0937d --- /dev/null +++ b/tests/manual/render-qml-to-texture/OffscreenGui.qml @@ -0,0 +1,132 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt3D module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** 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 http://www.qt.io/terms-conditions. For further +** information use the contact form at http://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.LGPLv3 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.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 later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import QtQuick.Controls 1.2 +import QtQuick.Controls.Styles 1.3 + +Rectangle { + width: 1024 + height: 1024 + color: "white" + + TextRectangle { + id: textRect + } + + Rectangle { + id: rect + x: 0 + y: 0 + width: 200 + height: 200 + color: "red" + + ColorAnimation { + target: rect + loops: Animation.Infinite + property: "color" + from: "blue" + to: "green" + duration: 2000 + running: true + } + } + + Rectangle { + id: rect2 + width: 300 + height: 100 + anchors.right: parent.right + anchors.bottom: parent.bottom + color: "red" + + ColorAnimation { + target: rect2 + loops: Animation.Infinite + property: "color" + from: "red" + to: "white" + duration: 2000 + running: true + } + } + + Button { + id: button + width: 100 + height: 80 + anchors.top: rect.bottom + anchors.left: parent.left + text: "button" + scale: 2.0 + } + CheckBox { + id: checkbox + width: 200 + height: 180 + scale: 2.0 + text: "checkbox" + checked: true + anchors.top: parent.top + anchors.right: parent.right + + Timer { + interval: 1000 + repeat: true + running: true + onTriggered: { + checkbox.checked = !checkbox.checked; + } + } + } + Slider { + anchors.bottom: parent.bottom + anchors.left: parent.left + width: 400 + value: 0.0 + minimumValue: 0 + maximumValue: 1 + + PropertyAnimation on value { + loops: Animation.Infinite + duration: 3000 + from: 0.0 + to: 1.0 + running: true + } + } +} diff --git a/tests/manual/render-qml-to-texture/TextRectangle.qml b/tests/manual/render-qml-to-texture/TextRectangle.qml new file mode 100644 index 000000000..b47fa965b --- /dev/null +++ b/tests/manual/render-qml-to-texture/TextRectangle.qml @@ -0,0 +1,86 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt3D module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** 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 http://www.qt.io/terms-conditions. For further +** information use the contact form at http://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.LGPLv3 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.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 later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Rectangle { + id: rectangle + property string myText: "The quick brown fox jumps over the lazy dog." + x: 352 + y: 272 + width: 320 + height: 480 + color: "steelblue" + + FontLoader { id: fixedFont; name: "Courier" } + + Column { + anchors { fill: parent; leftMargin: 10; rightMargin: 10; topMargin: 10 } + spacing: 15 + + Text { + text: rectangle.myText + color: "lightsteelblue" + width: parent.width + wrapMode: Text.WordWrap + font.family: "Times" + font.pixelSize: 20 + } + Text { + text: rectangle.myText + color: "lightsteelblue" + width: parent.width + wrapMode: Text.WordWrap + horizontalAlignment: Text.AlignHCenter + font { family: "Times"; pixelSize: 20; capitalization: Font.AllUppercase } + } + Text { + text: rectangle.myText + color: "lightsteelblue" + width: parent.width + horizontalAlignment: Text.AlignRight + wrapMode: Text.WordWrap + font { family: fixedFont.name; pixelSize: 20; weight: Font.Bold; capitalization: Font.AllLowercase } + } + Text { + text: rectangle.myText + color: "lightsteelblue" + width: parent.width + wrapMode: Text.WordWrap + font { family: fixedFont.name; pixelSize: 20; italic: true; capitalization: Font.SmallCaps } + } + } +} diff --git a/tests/manual/render-qml-to-texture/main.cpp b/tests/manual/render-qml-to-texture/main.cpp new file mode 100644 index 000000000..2420c8560 --- /dev/null +++ b/tests/manual/render-qml-to-texture/main.cpp @@ -0,0 +1,128 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt3D module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** 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 http://www.qt.io/terms-conditions. For further +** information use the contact form at http://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.LGPLv3 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.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 later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include <QGuiApplication> +#include <QAnimationDriver> +#include <QPropertyAnimation> +#include <QQmlComponent> +#include <QQmlEngine> + +#include <Qt3DCore/QEntity> +#include <Qt3DCore/QAspectEngine> +#include <Qt3DCore/QTransform> +#include <Qt3DRender/QCamera> + +#include <Qt3DInput/QInputAspect> + +#include <Qt3DRender/QRenderAspect> +#include <Qt3DRender/QEffect> +#include <Qt3DRender/QMaterial> +#include <Qt3DExtras/QForwardRenderer> +#include <Qt3DQuickScene2D/QScene2D> +#include <Qt3DExtras/QPlaneMesh> +#include <Qt3DRender/QTextureWrapMode> +#include <Qt3DRender/QClearBuffers> +#include <Qt3DRender/QTexture> + +#include "qt3dwindow.h" +#include "qfirstpersoncameracontroller.h" +#include "planematerial.h" + +int main(int argc, char *argv[]) +{ + QGuiApplication app(argc, argv); + + Qt3DExtras::Qt3DWindow view; + + // Scene Root + Qt3DCore::QEntity *sceneRoot = new Qt3DCore::QEntity(); + + // Scene Camera + Qt3DRender::QCamera *basicCamera = view.camera(); + basicCamera->setProjectionType(Qt3DRender::QCameraLens::PerspectiveProjection); + basicCamera->setAspectRatio(view.width() / view.height()); + basicCamera->setUpVector(QVector3D(0.0f, 1.0f, 0.0f)); + basicCamera->setPosition(QVector3D(0.0f, 0.0f, 6.0f)); + basicCamera->setViewCenter(QVector3D(0.0f, 0.0f, 0.0f)); + basicCamera->setNearPlane(0.1f); + basicCamera->setFarPlane(1000.0f); + basicCamera->setFieldOfView(45.0f); + + // For camera controls + Qt3DExtras::QFirstPersonCameraController *camController = new Qt3DExtras::QFirstPersonCameraController(sceneRoot); + camController->setCamera(basicCamera); + + Qt3DRender::QFrameGraphNode* frameGraphNode = view.activeFrameGraph(); + while (frameGraphNode->childNodes().size() > 0) + frameGraphNode = (Qt3DRender::QFrameGraphNode*)frameGraphNode->childNodes().at(0); + view.defaultFrameGraph()->setClearColor(QColor::fromRgbF(1.0f, 1.0f, 1.0f)); + Qt3DRender::Quick::QScene2D *qmlTextureRenderer = new Qt3DRender::Quick::QScene2D(frameGraphNode); + + Qt3DRender::QTexture2D* offscreenTexture = new Qt3DRender::QTexture2D(qmlTextureRenderer); + offscreenTexture->setSize(1024, 1024); + offscreenTexture->setFormat(Qt3DRender::QAbstractTexture::RGBA8_UNorm); + offscreenTexture->setGenerateMipMaps(true); + offscreenTexture->setMagnificationFilter(Qt3DRender::QAbstractTexture::Linear); + offscreenTexture->setMinificationFilter(Qt3DRender::QAbstractTexture::Linear); + offscreenTexture->setWrapMode(Qt3DRender::QTextureWrapMode(Qt3DRender::QTextureWrapMode::ClampToEdge, offscreenTexture)); + + Qt3DRender::QRenderTargetOutput *output = new Qt3DRender::QRenderTargetOutput(qmlTextureRenderer); + output->setAttachmentPoint(Qt3DRender::QRenderTargetOutput::Color0); + output->setTexture(offscreenTexture); + + qmlTextureRenderer->setOutput(output); + QQmlEngine engine; + QQmlComponent component(&engine, QUrl(QStringLiteral("qrc:/OffscreenGui.qml"))); + qmlTextureRenderer->setItem(static_cast<QQuickItem *>(component.create())); + + Qt3DCore::QEntity* planeEntity = new Qt3DCore::QEntity(sceneRoot); + Qt3DExtras::QPlaneMesh* planeMesh = new Qt3DExtras::QPlaneMesh(planeEntity); + planeMesh->setWidth(4); + planeMesh->setHeight(4); + planeEntity->addComponent(planeMesh); + + PlaneMaterial* material = new PlaneMaterial(offscreenTexture, planeEntity); + planeEntity->addComponent(material); + + Qt3DCore::QTransform* transform = new Qt3DCore::QTransform(planeEntity); + transform->setRotation(QQuaternion::fromAxisAndAngle(1,0,0,90)); + planeEntity->addComponent(transform); + + view.setRootEntity(sceneRoot); + view.show(); + + return app.exec(); +} diff --git a/tests/manual/render-qml-to-texture/planematerial.cpp b/tests/manual/render-qml-to-texture/planematerial.cpp new file mode 100644 index 000000000..4435766bb --- /dev/null +++ b/tests/manual/render-qml-to-texture/planematerial.cpp @@ -0,0 +1,119 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt3D module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** 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 http://www.qt.io/terms-conditions. For further +** information use the contact form at http://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.LGPLv3 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.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 later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include <Qt3DRender/QParameter> +#include <Qt3DRender/QEffect> +#include <Qt3DRender/QTechnique> +#include <Qt3DRender/QAbstractTexture> +#include <Qt3DRender/QShaderProgram> +#include <Qt3DRender/QRenderPass> +#include <Qt3DRender/QBlendEquation> +#include <Qt3DRender/QBlendEquationArguments> +#include <Qt3DRender/QFilterKey> +#include <Qt3DRender/QGraphicsApiFilter> +#include <QColor> +#include <QVector2D> +#include <QUrl> + +#include "planematerial.h" + +PlaneMaterial::PlaneMaterial(Qt3DRender::QAbstractTexture *texture, Qt3DCore::QNode *parent) + : QMaterial(parent) + , m_effect(new Qt3DRender::QEffect(this)) + , m_texture(texture) +{ + setEffect(m_effect); + + m_texCoordScaleParam = new Qt3DRender::QParameter(QStringLiteral("texCoordScale"), QVector2D(1.0f, -1.0f)); + m_texCoordBiasParam = new Qt3DRender::QParameter(QStringLiteral("texCoordBias"), QVector2D(0.0f, 1.0f)); + m_textureParam = new Qt3DRender::QParameter(QStringLiteral("surfaceTexture"), m_texture); + + m_effect->addParameter(m_texCoordScaleParam); + m_effect->addParameter(m_texCoordBiasParam); + m_effect->addParameter(m_textureParam); + + m_filter = new Qt3DRender::QFilterKey(this); + m_filter->setName(QStringLiteral("renderingStyle")); + m_filter->setValue(QStringLiteral("forward")); + + m_techniqueGLES = new Qt3DRender::QTechnique(m_effect); + m_techniqueGL3 = new Qt3DRender::QTechnique(m_effect); + m_techniqueGL2 = new Qt3DRender::QTechnique(m_effect); + + m_techniqueGLES->addFilterKey(m_filter); + m_techniqueGL3->addFilterKey(m_filter); + m_techniqueGL2->addFilterKey(m_filter); + + m_effect->addTechnique(m_techniqueGLES); + m_effect->addTechnique(m_techniqueGL3); + m_effect->addTechnique(m_techniqueGL2); + + m_programGLES = new Qt3DRender::QShaderProgram(m_effect); + m_programGLES->setVertexShaderCode(Qt3DRender::QShaderProgram::loadSource(QUrl(QStringLiteral("qrc:/shaders/es2/texturing.vert")))); + m_programGLES->setFragmentShaderCode(Qt3DRender::QShaderProgram::loadSource(QUrl(QStringLiteral("qrc:/shaders/es2/texturing.frag")))); + + m_programGL3 = new Qt3DRender::QShaderProgram(m_effect); + m_programGL3->setVertexShaderCode(Qt3DRender::QShaderProgram::loadSource(QUrl(QStringLiteral("qrc:/shaders/gl3/texturing.vert")))); + m_programGL3->setFragmentShaderCode(Qt3DRender::QShaderProgram::loadSource(QUrl(QStringLiteral("qrc:/shaders/gl3/texturing.frag")))); + + m_renderPassGLES = new Qt3DRender::QRenderPass(m_effect); + m_renderPassGL3 = new Qt3DRender::QRenderPass(m_effect); + m_renderPassGL2 = new Qt3DRender::QRenderPass(m_effect); + + m_renderPassGLES->setShaderProgram(m_programGLES); + m_renderPassGL3->setShaderProgram(m_programGL3); + m_renderPassGL2->setShaderProgram(m_programGL3); + + m_techniqueGL2->addRenderPass(m_renderPassGL2); + m_techniqueGLES->addRenderPass(m_renderPassGLES); + m_techniqueGL3->addRenderPass(m_renderPassGL3); + + m_techniqueGLES->graphicsApiFilter()->setApi(Qt3DRender::QGraphicsApiFilter::OpenGLES); + m_techniqueGLES->graphicsApiFilter()->setMajorVersion(2); + m_techniqueGLES->graphicsApiFilter()->setMinorVersion(0); + m_techniqueGLES->graphicsApiFilter()->setProfile(Qt3DRender::QGraphicsApiFilter::NoProfile); + + m_techniqueGL2->graphicsApiFilter()->setApi(Qt3DRender::QGraphicsApiFilter::OpenGL); + m_techniqueGL2->graphicsApiFilter()->setMajorVersion(2); + m_techniqueGL2->graphicsApiFilter()->setMinorVersion(0); + m_techniqueGL2->graphicsApiFilter()->setProfile(Qt3DRender::QGraphicsApiFilter::NoProfile); + + m_techniqueGL3->graphicsApiFilter()->setApi(Qt3DRender::QGraphicsApiFilter::OpenGL); + m_techniqueGL3->graphicsApiFilter()->setMajorVersion(3); + m_techniqueGL3->graphicsApiFilter()->setMinorVersion(1); + m_techniqueGL3->graphicsApiFilter()->setProfile(Qt3DRender::QGraphicsApiFilter::CoreProfile); +} + diff --git a/tests/manual/render-qml-to-texture/planematerial.h b/tests/manual/render-qml-to-texture/planematerial.h new file mode 100644 index 000000000..8de7a19c9 --- /dev/null +++ b/tests/manual/render-qml-to-texture/planematerial.h @@ -0,0 +1,59 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt3D module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** 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 http://www.qt.io/terms-conditions. For further +** information use the contact form at http://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.LGPLv3 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.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 later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef PLANEMATERIAL_H +#define PLANEMATERIAL_H + +#include <Qt3DRender/QMaterial> +#include <Qt3DRender/QFilterKey> +#include <Qt3DRender/QTechnique> +#include <Qt3DRender/QMaterial> + +class PlaneMaterial : public Qt3DRender::QMaterial +{ +public: + explicit PlaneMaterial(Qt3DRender::QAbstractTexture *texture, Qt3DCore::QNode *parent = nullptr); +private: + Qt3DRender::QEffect *m_effect; + Qt3DRender::QAbstractTexture *m_texture; + Qt3DRender::QParameter *m_textureParam, *m_texCoordScaleParam, *m_texCoordBiasParam; + Qt3DRender::QFilterKey *m_filter; + Qt3DRender::QTechnique *m_techniqueGLES, *m_techniqueGL3, *m_techniqueGL2; + Qt3DRender::QShaderProgram *m_programGLES, *m_programGL3; + Qt3DRender::QRenderPass *m_renderPassGLES, *m_renderPassGL3, *m_renderPassGL2; +}; + +#endif // PLANEMATERIAL_H diff --git a/tests/manual/render-qml-to-texture/render-qml-to-texture.pri b/tests/manual/render-qml-to-texture/render-qml-to-texture.pri new file mode 100644 index 000000000..b02c23840 --- /dev/null +++ b/tests/manual/render-qml-to-texture/render-qml-to-texture.pri @@ -0,0 +1,6 @@ +SOURCES += + +RESOURCES += \ + ../render-qml-to-texture/render-qml-to-texture.qrc + +HEADERS += diff --git a/tests/manual/render-qml-to-texture/render-qml-to-texture.pro b/tests/manual/render-qml-to-texture/render-qml-to-texture.pro new file mode 100644 index 000000000..45c213803 --- /dev/null +++ b/tests/manual/render-qml-to-texture/render-qml-to-texture.pro @@ -0,0 +1,21 @@ +!include( ../manual.pri ) { + error( "Couldn't find the manual.pri file!" ) +} + +QT += 3dextras 3dcore 3drender 3dinput 3dquick qml quick 3dquickrender 3dquickscene2d + +SOURCES += main.cpp \ + planematerial.cpp + +RESOURCES += \ + render-qml-to-texture.qrc + +OTHER_FILES += \ + main.qml + +DISTFILES += \ + OffscreenGui.qml \ + TextRectangle.qml + +HEADERS += \ + planematerial.h diff --git a/tests/manual/render-qml-to-texture/render-qml-to-texture.qrc b/tests/manual/render-qml-to-texture/render-qml-to-texture.qrc new file mode 100644 index 000000000..792a74b70 --- /dev/null +++ b/tests/manual/render-qml-to-texture/render-qml-to-texture.qrc @@ -0,0 +1,10 @@ +<RCC> + <qresource prefix="/"> + <file>shaders/es2/texturing.frag</file> + <file>shaders/es2/texturing.vert</file> + <file>shaders/gl3/texturing.frag</file> + <file>shaders/gl3/texturing.vert</file> + <file>OffscreenGui.qml</file> + <file>TextRectangle.qml</file> + </qresource> +</RCC> diff --git a/tests/manual/render-qml-to-texture/shaders/es2/texturing.frag b/tests/manual/render-qml-to-texture/shaders/es2/texturing.frag new file mode 100644 index 000000000..b651bd5ed --- /dev/null +++ b/tests/manual/render-qml-to-texture/shaders/es2/texturing.frag @@ -0,0 +1,16 @@ +#define FP highp + +uniform FP vec3 eyePosition; + +uniform sampler2D surfaceTexture; + +varying FP vec3 worldPosition; +varying FP vec3 worldNormal; +varying FP vec2 texCoord; + + + +void main() +{ + gl_FragColor = texture2D(surfaceTexture, texCoord); +} diff --git a/tests/manual/render-qml-to-texture/shaders/es2/texturing.vert b/tests/manual/render-qml-to-texture/shaders/es2/texturing.vert new file mode 100644 index 000000000..cfbd338d2 --- /dev/null +++ b/tests/manual/render-qml-to-texture/shaders/es2/texturing.vert @@ -0,0 +1,26 @@ + + +attribute vec3 vertexPosition; +attribute vec3 vertexNormal; +attribute vec2 vertexTexCoord; + +varying vec3 worldPosition; +varying vec3 worldNormal; +varying vec2 texCoord; + +uniform mat4 modelMatrix; +uniform mat3 modelNormalMatrix; +uniform mat4 mvp; + +uniform vec2 texCoordScale; +uniform vec2 texCoordBias; + +void main() +{ + texCoord = vertexTexCoord * texCoordScale + texCoordBias; + worldNormal = normalize(modelNormalMatrix * vertexNormal); + worldPosition = vec3(modelMatrix * vec4(vertexPosition, 1.0)); + + gl_Position = mvp * vec4(vertexPosition, 1.0); +} + diff --git a/tests/manual/render-qml-to-texture/shaders/gl3/texturing.frag b/tests/manual/render-qml-to-texture/shaders/gl3/texturing.frag new file mode 100644 index 000000000..b051dc254 --- /dev/null +++ b/tests/manual/render-qml-to-texture/shaders/gl3/texturing.frag @@ -0,0 +1,16 @@ +#version 150 core + +uniform vec3 eyePosition; + +uniform sampler2D surfaceTexture; + +in vec3 worldPosition; +in vec3 worldNormal; +in vec2 texCoord; + +out vec4 fragColor; + +void main() +{ + fragColor = texture(surfaceTexture, texCoord); +} diff --git a/tests/manual/render-qml-to-texture/shaders/gl3/texturing.vert b/tests/manual/render-qml-to-texture/shaders/gl3/texturing.vert new file mode 100644 index 000000000..2b8a08b0a --- /dev/null +++ b/tests/manual/render-qml-to-texture/shaders/gl3/texturing.vert @@ -0,0 +1,25 @@ +#version 150 core + +in vec3 vertexPosition; +in vec3 vertexNormal; +in vec2 vertexTexCoord; + +out vec3 worldPosition; +out vec3 worldNormal; +out vec2 texCoord; + +uniform mat4 modelMatrix; +uniform mat3 modelNormalMatrix; +uniform mat4 mvp; + +uniform vec2 texCoordScale; +uniform vec2 texCoordBias; + +void main() +{ + texCoord = vertexTexCoord * texCoordScale + texCoordBias; + worldNormal = normalize(modelNormalMatrix * vertexNormal); + worldPosition = vec3(modelMatrix * vec4(vertexPosition, 1.0)); + + gl_Position = mvp * vec4(vertexPosition, 1.0); +} diff --git a/tests/manual/rendercapture-cpp/mycapture.h b/tests/manual/rendercapture-cpp/mycapture.h index 803ef7336..fea1abe46 100644 --- a/tests/manual/rendercapture-cpp/mycapture.h +++ b/tests/manual/rendercapture-cpp/mycapture.h @@ -60,31 +60,26 @@ class MyCapture : public QObject public: MyCapture(Qt3DRender::QRenderCapture* capture, QLabel *imageLabel) : m_capture(capture) - , m_cid(1) - , m_imageLabel(imageLabel) , m_reply(nullptr) + , m_imageLabel(imageLabel) , m_continuous(false) { } public slots: - void onCompleted(bool isComplete) + void onCompleted() { - if (isComplete) { - QObject::disconnect(connection); - - m_imageLabel->setPixmap(QPixmap::fromImage(m_reply->image())); + QObject::disconnect(connection); - ++m_cid; + m_imageLabel->setPixmap(QPixmap::fromImage(m_reply->image())); - m_reply->saveToFile("capture.bmp"); + m_reply->saveImage("capture.bmp"); - delete m_reply; - m_reply = nullptr; + delete m_reply; + m_reply = nullptr; - if (m_continuous) - capture(); - } + if (m_continuous) + capture(); } void setContinuous(bool continuos) @@ -94,9 +89,11 @@ public slots: void capture() { - m_reply = m_capture->requestCapture(m_cid); - connection = QObject::connect(m_reply, &Qt3DRender::QRenderCaptureReply::completeChanged, - this, &MyCapture::onCompleted); + if (!m_reply) { + m_reply = m_capture->requestCapture(); + connection = QObject::connect(m_reply, &Qt3DRender::QRenderCaptureReply::completed, + this, &MyCapture::onCompleted); + } } private: @@ -105,7 +102,6 @@ private: QMetaObject::Connection connection; QLabel *m_imageLabel; bool m_continuous; - int m_cid; }; #endif diff --git a/tests/manual/rendercapture-qml/CaptureScene.qml b/tests/manual/rendercapture-qml/CaptureScene.qml index 2329e4730..ea355042a 100644 --- a/tests/manual/rendercapture-qml/CaptureScene.qml +++ b/tests/manual/rendercapture-qml/CaptureScene.qml @@ -57,9 +57,9 @@ import Qt3D.Extras 2.0 Entity { id: sceneRoot - function requestRenderCapture(cid) + function requestRenderCapture() { - return renderCapture.requestCapture(cid) + return renderCapture.requestCapture() } Camera { diff --git a/tests/manual/rendercapture-qml/main.qml b/tests/manual/rendercapture-qml/main.qml index 77e96d739..9aff1fefe 100644 --- a/tests/manual/rendercapture-qml/main.qml +++ b/tests/manual/rendercapture-qml/main.qml @@ -51,7 +51,7 @@ import QtQuick 2.2 import QtQuick.Layouts 1.3 import QtQuick.Controls 1.4 -import Qt3D.Render 2.1 +import Qt3D.Render 2.9 import QtQuick.Scene3D 2.0 Item { @@ -96,7 +96,7 @@ Item { function doRenderCapture() { - reply = scene.requestRenderCapture(cid) + reply = scene.requestRenderCapture() reply.completeChanged.connect(onRenderCaptureComplete) } @@ -104,7 +104,7 @@ Item { { _renderCaptureProvider.updateImage(reply) image.source = "image://rendercapture/" + cid - reply.saveToFile("capture" + cid + ".png") + reply.saveImage("capture" + cid + ".png") cid++ if (continuous === true) doRenderCapture() diff --git a/tests/manual/video-texture-qml/PlaneMaterial.qml b/tests/manual/video-texture-qml/PlaneMaterial.qml new file mode 100644 index 000000000..6c65de9b3 --- /dev/null +++ b/tests/manual/video-texture-qml/PlaneMaterial.qml @@ -0,0 +1,117 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt3D module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** 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 http://www.qt.io/terms-conditions. For further +** information use the contact form at http://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.LGPLv3 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.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 later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import Qt3D.Core 2.0 +import Qt3D.Render 2.0 + +Material { + + property Texture2D texture + property vector2d textureScale: Qt.vector2d(1,-1) + property vector2d textureBias: Qt.vector2d(0, 1) + + parameters: [ + Parameter { name: "surfaceTexture"; value: texture }, + Parameter { name: "texCoordScale"; value: textureScale }, + Parameter { name: "texCoordBias"; value: textureBias } + ] + + effect: Effect { + FilterKey { + id: forward + name: "renderingStyle" + value: "forward" + } + + ShaderProgram { + id: gl2Es2Shader + vertexShaderCode: loadSource("qrc:/shaders/es2/texturing.vert") + fragmentShaderCode: loadSource("qrc:/shaders/es2/texturing.frag") + } + + ShaderProgram { + id: gl3Shader + vertexShaderCode: loadSource("qrc:/shaders/gl3/texturing.vert") + fragmentShaderCode: loadSource("qrc:/shaders/gl3/texturing.frag") + } + techniques: [ + // OpenGL 3.1 + Technique { + filterKeys: [ forward ] + graphicsApiFilter { + api: GraphicsApiFilter.OpenGL + profile: GraphicsApiFilter.CoreProfile + majorVersion: 3 + minorVersion: 1 + } + + renderPasses: RenderPass { + shaderProgram: gl3Shader + } + }, + + // OpenGL 2.1 + Technique { + filterKeys: [ forward ] + graphicsApiFilter { + api: GraphicsApiFilter.OpenGL + profile: GraphicsApiFilter.NoProfile + majorVersion: 2 + minorVersion: 0 + } + + renderPasses: RenderPass { + shaderProgram: gl2Es2Shader + } + }, + + // OpenGL ES 2 + Technique { + filterKeys: [ forward ] + graphicsApiFilter { + api: GraphicsApiFilter.OpenGLES + profile: GraphicsApiFilter.NoProfile + majorVersion: 2 + minorVersion: 0 + } + renderPasses: RenderPass { + shaderProgram: gl2Es2Shader + } + } + ] + } +} diff --git a/tests/manual/video-texture-qml/main.cpp b/tests/manual/video-texture-qml/main.cpp new file mode 100644 index 000000000..5146d5939 --- /dev/null +++ b/tests/manual/video-texture-qml/main.cpp @@ -0,0 +1,53 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt3D module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** 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 http://www.qt.io/terms-conditions. For further +** information use the contact form at http://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.LGPLv3 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.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 later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include <Qt3DQuick/QQmlAspectEngine> +#include <QGuiApplication> +#include <QQmlEngine> +#include <QQmlContext> +#include <Qt3DQuickExtras/Qt3DQuickWindow> + +int main(int argc, char* argv[]) +{ + QGuiApplication app(argc, argv); + Qt3DExtras::Quick::Qt3DQuickWindow view; + + view.engine()->qmlEngine()->rootContext()->setContextProperty("_window", &view); + view.setSource(QUrl("qrc:/main.qml")); + view.show(); + + return app.exec(); +} diff --git a/tests/manual/video-texture-qml/main.qml b/tests/manual/video-texture-qml/main.qml new file mode 100644 index 000000000..6a8dff3d5 --- /dev/null +++ b/tests/manual/video-texture-qml/main.qml @@ -0,0 +1,147 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt3D module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** 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 http://www.qt.io/terms-conditions. For further +** information use the contact form at http://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.LGPLv3 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.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 later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import Qt3D.Core 2.0 +import Qt3D.Render 2.9 +import Qt3D.Input 2.0 +import QtQuick 2.2 as QQ2 +import QtQuick.Scene2D 2.9 +import QtQuick.Window 2.0 as QW2 +import Qt3D.Extras 2.0 +import QtMultimedia 5.6 as QMM +import QtQuick.Dialogs 1.0 + +Entity { + id: sceneRoot + + Camera { + id: camera + projectionType: CameraLens.PerspectiveProjection + fieldOfView: 45 + aspectRatio: _window.width / _window.height + nearPlane : 0.1 + farPlane : 1000.0 + position: Qt.vector3d( 0.0, 0.0, 3.0 ) + upVector: Qt.vector3d( 0.0, 1.0, 0.0 ) + viewCenter: Qt.vector3d( 0.0, 0.0, 0.0 ) + } + + Scene2D { + output: RenderTargetOutput { + attachmentPoint: RenderTargetOutput.Color0 + texture: Texture2D { + id: offscreenTexture + width: 1024 + height: 1024 + format: Texture.RGBA8_UNorm + generateMipMaps: false + magnificationFilter: Texture.Linear + minificationFilter: Texture.Linear + wrapMode { + x: WrapMode.ClampToEdge + y: WrapMode.ClampToEdge + } + } + } + QQ2.Rectangle { + width: 400 + height: 300 + color: "green" + + QMM.MediaPlayer { + id: player + autoPlay: false + loops: QMM.MediaPlayer.Infinite + } + + QMM.VideoOutput { + id: videoOutput + source: player + anchors.fill: parent + } + } + } + + FirstPersonCameraController { + camera: camera + } + + components: [ + RenderSettings { + activeFrameGraph: + ForwardRenderer { + camera: camera + } + }, + InputSettings {} + ] + + CuboidMesh { + id: mesh + } + + Entity { + id: entity + + property Transform transform: Transform { + scale: 1 + translation: Qt.vector3d(0,0,0) + } + + property Material material: PlaneMaterial { + texture: offscreenTexture + } + + components: [mesh, material, transform] + } + + FileDialog { + id: fileDialog + title: "Please choose a video" + folder: shortcuts.home + onAccepted: { + visible = false + player.source = fileDialog.fileUrl + player.play() + } + onRejected: { + Qt.quit() + } + QQ2.Component.onCompleted: { + visible = true + } + } +} diff --git a/tests/manual/video-texture-qml/video-texture-qml.pro b/tests/manual/video-texture-qml/video-texture-qml.pro new file mode 100644 index 000000000..713ef8cfe --- /dev/null +++ b/tests/manual/video-texture-qml/video-texture-qml.pro @@ -0,0 +1,21 @@ +!include( ../manual.pri ) { + error( "Couldn't find the manual.pri file!" ) +} + +!include ( ../render-qml-to-texture/render-qml-to-texture.pri ) { + error( "Couldn't find the render-qml-to-texture.pri file!") +} + +QT += 3dquickextras 3dcore 3drender 3dinput 3dquick qml quick 3dquickrender + +SOURCES += main.cpp + +RESOURCES += \ + video-texture-qml.qrc + +OTHER_FILES += \ + main.qml + +DISTFILES += \ + PlaneMaterial.qml + diff --git a/tests/manual/video-texture-qml/video-texture-qml.qrc b/tests/manual/video-texture-qml/video-texture-qml.qrc new file mode 100644 index 000000000..6b2a1aef6 --- /dev/null +++ b/tests/manual/video-texture-qml/video-texture-qml.qrc @@ -0,0 +1,6 @@ +<RCC> + <qresource prefix="/"> + <file>main.qml</file> + <file>PlaneMaterial.qml</file> + </qresource> +</RCC> |