diff options
Diffstat (limited to 'examples')
-rw-r--r-- | examples/qt3d/lights/lights.pro | 16 | ||||
-rw-r--r-- | examples/qt3d/lights/lights.qrc | 5 | ||||
-rw-r--r-- | examples/qt3d/lights/main.cpp | 61 | ||||
-rw-r--r-- | examples/qt3d/lights/main.qml | 91 | ||||
-rw-r--r-- | examples/qt3d/qt3d.pro | 3 |
5 files changed, 175 insertions, 1 deletions
diff --git a/examples/qt3d/lights/lights.pro b/examples/qt3d/lights/lights.pro new file mode 100644 index 000000000..d1a2c4fea --- /dev/null +++ b/examples/qt3d/lights/lights.pro @@ -0,0 +1,16 @@ +!include( ../examples.pri ) { + error( "Couldn't find the examples.pri file!" ) +} + +SOURCE += main.cpp + +QT += qml quick 3dcore 3drender 3dinput 3dquick + +OTHER_FILES += main.qml + +SOURCES += \ + main.cpp + +RESOURCES += \ + lights.qrc \ + ../exampleresources/obj.qrc diff --git a/examples/qt3d/lights/lights.qrc b/examples/qt3d/lights/lights.qrc new file mode 100644 index 000000000..5f6483ac3 --- /dev/null +++ b/examples/qt3d/lights/lights.qrc @@ -0,0 +1,5 @@ +<RCC> + <qresource prefix="/"> + <file>main.qml</file> + </qresource> +</RCC> diff --git a/examples/qt3d/lights/main.cpp b/examples/qt3d/lights/main.cpp new file mode 100644 index 000000000..51857b171 --- /dev/null +++ b/examples/qt3d/lights/main.cpp @@ -0,0 +1,61 @@ +/**************************************************************************** +** +** Copyright (C) 2015 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 <window.h> +#include <Qt3DRender/QRenderAspect> +#include <Qt3DInput/QInputAspect> +#include <Qt3DQuick/QQmlAspectEngine> +#include <QGuiApplication> + +int main(int argc, char* argv[]) +{ + QGuiApplication app(argc, argv); + + Window view; + Qt3DCore::Quick::QQmlAspectEngine engine; + + engine.aspectEngine()->registerAspect(new Qt3DRender::QRenderAspect()); + engine.aspectEngine()->registerAspect(new Qt3DInput::QInputAspect()); + QVariantMap data; + data.insert(QStringLiteral("surface"), QVariant::fromValue(static_cast<QSurface *>(&view))); + data.insert(QStringLiteral("eventSource"), QVariant::fromValue(&view)); + engine.aspectEngine()->setData(data); + engine.aspectEngine()->initialize(); + engine.setSource(QUrl("qrc:/main.qml")); + view.show(); + + return app.exec(); +} diff --git a/examples/qt3d/lights/main.qml b/examples/qt3d/lights/main.qml new file mode 100644 index 000000000..eb28fc1a5 --- /dev/null +++ b/examples/qt3d/lights/main.qml @@ -0,0 +1,91 @@ +/**************************************************************************** +** +** Copyright (C) 2015 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 as Quick +import Qt3D.Core 2.0 +import Qt3D.Render 2.0 + +Entity +{ + components: FrameGraph { + activeFrameGraph: ForwardRenderer { + clearColor: Qt.rgba(0, 0, 0, 1) + camera: camera + } + } + + Camera { + id: camera + projectionType: CameraLens.PerspectiveProjection + fieldOfView: 45 + aspectRatio: 16/9 + nearPlane : 0.1 + farPlane : 1000.0 + position: Qt.vector3d( 0.0, 0.0, 50.0 ) + upVector: Qt.vector3d( 0.0, 1.0, 0.0 ) + viewCenter: Qt.vector3d( 0.0, 0.0, -1.0 ) + } + + Configuration { + controlledCamera: camera + } + + Entity { + components: [ + Transform { translation: Qt.vector3d(2.0, 1.0, 1.0); }, + PointLight { + color: Qt.rgba(1, 0, 0, 1) + } + ] + } + + Entity { + components: [ + Transform { translation: Qt.vector3d(2.0, 3.0, 4.0); }, + PointLight { + color: Qt.rgba(1, 0, 0, 1) + } + ] + } + + Entity { + components: [ + Mesh { + source: "assets/obj/toyplane.obj" + } + ] + } +} diff --git a/examples/qt3d/qt3d.pro b/examples/qt3d/qt3d.pro index 4de448259..afa4cce79 100644 --- a/examples/qt3d/qt3d.pro +++ b/examples/qt3d/qt3d.pro @@ -44,7 +44,8 @@ SUBDIRS += \ instanced-arrays-qml \ picking-qml \ transforms-qml \ - qgltf + qgltf \ + lights # TODO Port the old examples to new APIs #SUBDIRS += qt3d |