summaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
authorLaszlo Agocs <laszlo.agocs@theqtcompany.com>2015-12-07 14:20:01 +0100
committerLaszlo Agocs <laszlo.agocs@theqtcompany.com>2015-12-09 13:53:23 +0000
commit94f3df1aacab5853d09e79596eb3bdae3aecae0a (patch)
tree4db06240d22462becc9ad5b499926aa11316b88d /examples
parent3655c334b0f4a28a1487c918384da50498ef9418 (diff)
Add support for spotlights
Change-Id: I61a4e072c1a2e00cdbcee917aa557e56fb8cb7c0 Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
Diffstat (limited to 'examples')
-rw-r--r--examples/qt3d/lights/PlaneEntity.qml59
-rw-r--r--examples/qt3d/lights/lights.pro6
-rw-r--r--examples/qt3d/lights/lights.qrc1
-rw-r--r--examples/qt3d/lights/main.qml45
4 files changed, 106 insertions, 5 deletions
diff --git a/examples/qt3d/lights/PlaneEntity.qml b/examples/qt3d/lights/PlaneEntity.qml
new file mode 100644
index 000000000..ce07db08b
--- /dev/null
+++ b/examples/qt3d/lights/PlaneEntity.qml
@@ -0,0 +1,59 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Klaralvdalens Datakonsult AB (KDAB).
+** Contact: http://www.qt-project.org/legal
+**
+** 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.0
+
+Entity {
+ id: root
+ property alias position: transform.translation
+ property alias scale: transform.scale
+ property alias width: mesh.width
+ property alias height: mesh.height
+ property alias resolution: mesh.meshResolution
+ property Material material
+
+ components: [ transform, mesh, root.material ]
+
+ Transform { id: transform }
+
+ PlaneMesh {
+ id: mesh
+ width: 1.0
+ height: 1.0
+ meshResolution: Qt.size(2, 2)
+ }
+}
diff --git a/examples/qt3d/lights/lights.pro b/examples/qt3d/lights/lights.pro
index d1a2c4fea..85fe72c15 100644
--- a/examples/qt3d/lights/lights.pro
+++ b/examples/qt3d/lights/lights.pro
@@ -6,11 +6,13 @@ SOURCE += main.cpp
QT += qml quick 3dcore 3drender 3dinput 3dquick
-OTHER_FILES += main.qml
+OTHER_FILES += main.qml \
+ PlaneEntity.qml
SOURCES += \
main.cpp
RESOURCES += \
lights.qrc \
- ../exampleresources/obj.qrc
+ ../exampleresources/obj.qrc \
+ ../exampleresources/textures.qrc
diff --git a/examples/qt3d/lights/lights.qrc b/examples/qt3d/lights/lights.qrc
index 5f6483ac3..caa3f2d28 100644
--- a/examples/qt3d/lights/lights.qrc
+++ b/examples/qt3d/lights/lights.qrc
@@ -1,5 +1,6 @@
<RCC>
<qresource prefix="/">
<file>main.qml</file>
+ <file>PlaneEntity.qml</file>
</qresource>
</RCC>
diff --git a/examples/qt3d/lights/main.qml b/examples/qt3d/lights/main.qml
index 0d9e953a4..85af9b6cd 100644
--- a/examples/qt3d/lights/main.qml
+++ b/examples/qt3d/lights/main.qml
@@ -54,9 +54,9 @@ Entity
aspectRatio: 16/9
nearPlane : 0.1
farPlane : 1000.0
- position: Qt.vector3d( 0.0, 0.0, 50.0 )
+ position: Qt.vector3d( 0.0, 40.0, 300.0 )
upVector: Qt.vector3d( 0.0, 1.0, 0.0 )
- viewCenter: Qt.vector3d( 0.0, 0.0, -1.0 )
+ viewCenter: Qt.vector3d( 0.0, -10.0, -1.0 )
}
Configuration {
@@ -69,7 +69,6 @@ Entity
DirectionalLight {
color: Qt.rgba(0.9, 0.9, 0.0, 1.0)
direction: Qt.vector3d(-1, -1, 0)
- intensity: 0.5
}
]
}
@@ -115,6 +114,46 @@ Entity
}
Entity {
+ id: spotLight
+ components: [
+ SphereMesh {
+ radius: 1
+ },
+ Transform {
+ translation: Qt.vector3d(-5.0, 40.0, -5.0)
+ },
+ SpotLight {
+ direction: Qt.vector3d(1.0, -4.0, 0.0)
+ Quick.SequentialAnimation on direction.x {
+ Quick.NumberAnimation { from: -4.0; to: 4.0; duration: 5000 }
+ Quick.NumberAnimation { from: 4.0; to: -4.0; duration: 5000 }
+ loops: Quick.Animation.Infinite
+ }
+ cutOffAngle: 30
+ attenuation: Qt.vector3d(1, 0, 0)
+ intensity: 4
+ }
+ ]
+ }
+
+ PlaneEntity {
+ id: floor
+
+ width: 600
+ height: 600
+ resolution: Qt.size(20, 20)
+ position: Qt.vector3d(0, -30, 0)
+
+ material: NormalDiffuseMapMaterial {
+ ambient: Qt.rgba( 0.2, 0.2, 0.2, 1.0 )
+ diffuse: "assets/textures/pattern_09/diffuse.webp"
+ normal: "assets/textures/pattern_09/normal.webp"
+ textureScale: 10
+ shininess: 10
+ }
+ }
+
+ Entity {
components: [
Mesh {
source: "assets/obj/toyplane.obj"