summaryrefslogtreecommitdiffstats
path: root/tests/manual/phong-cubes
diff options
context:
space:
mode:
Diffstat (limited to 'tests/manual/phong-cubes')
-rw-r--r--tests/manual/phong-cubes/CMakeLists.txt58
-rw-r--r--tests/manual/phong-cubes/CubeEntity.qml34
-rw-r--r--tests/manual/phong-cubes/main.cpp16
-rw-r--r--tests/manual/phong-cubes/main.qml110
-rw-r--r--tests/manual/phong-cubes/phong-cubes.pro18
-rw-r--r--tests/manual/phong-cubes/phong-cubes.qrc6
6 files changed, 242 insertions, 0 deletions
diff --git a/tests/manual/phong-cubes/CMakeLists.txt b/tests/manual/phong-cubes/CMakeLists.txt
new file mode 100644
index 000000000..df7ab1b72
--- /dev/null
+++ b/tests/manual/phong-cubes/CMakeLists.txt
@@ -0,0 +1,58 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
+
+cmake_minimum_required(VERSION 3.16)
+project(phong-cubes LANGUAGES CXX)
+
+set(CMAKE_AUTOMOC ON)
+
+if(NOT DEFINED INSTALL_EXAMPLESDIR)
+ set(INSTALL_EXAMPLESDIR "examples")
+endif()
+
+set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}")
+
+find_package(Qt6 REQUIRED COMPONENTS 3DCore 3DInput 3DQuick 3DQuickExtras 3DRender Core Gui Qml Quick)
+
+qt_add_executable(phong-cubes
+ main.cpp
+)
+
+set_target_properties(phong-cubes PROPERTIES
+ WIN32_EXECUTABLE TRUE
+ MACOSX_BUNDLE TRUE
+)
+
+target_link_libraries(phong-cubes PUBLIC
+ Qt::3DCore
+ Qt::3DInput
+ Qt::3DQuick
+ Qt::3DQuickExtras
+ Qt::3DRender
+ Qt::Core
+ Qt::Gui
+ Qt::Qml
+ Qt::Quick
+)
+
+# Resources:
+set(phong-cubes_resource_files
+ "CubeEntity.qml"
+ "main.qml"
+)
+
+qt6_add_resources(phong-cubes "phong-cubes"
+ PREFIX
+ "/"
+ FILES
+ ${phong-cubes_resource_files}
+)
+
+qt6_add_resources(big_resources ../exampleresources/textures.qrc)
+target_sources(phong-cubes PRIVATE ${big_resources})
+
+install(TARGETS phong-cubes
+ RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
+ BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
+ LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
+)
diff --git a/tests/manual/phong-cubes/CubeEntity.qml b/tests/manual/phong-cubes/CubeEntity.qml
new file mode 100644
index 000000000..24f360eb9
--- /dev/null
+++ b/tests/manual/phong-cubes/CubeEntity.qml
@@ -0,0 +1,34 @@
+// Copyright (C) 2017 Klaralvdalens Datakonsult AB (KDAB).
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+import QtQuick 2.0 as Quick
+import Qt3D.Core 2.0
+import Qt3D.Render 2.0
+import Qt3D.Extras 2.0
+
+Entity {
+ id: root
+ property vector3d position: Qt.vector3d()
+ property Material material
+
+ components: [mesh, material, transform]
+
+ CuboidMesh {
+ id: mesh
+ xExtent: 0.5
+ yExtent: xExtent
+ zExtent: xExtent
+ }
+
+ Transform {
+ id: transform
+ translation: root.position
+ rotationZ: 45
+
+ Quick.NumberAnimation on rotationY {
+ from: 0; to: 360
+ loops: Quick.Animation.Infinite
+ duration: 5000
+ }
+ }
+}
diff --git a/tests/manual/phong-cubes/main.cpp b/tests/manual/phong-cubes/main.cpp
new file mode 100644
index 000000000..9c7ca6548
--- /dev/null
+++ b/tests/manual/phong-cubes/main.cpp
@@ -0,0 +1,16 @@
+// Copyright (C) 2017 Klaralvdalens Datakonsult AB (KDAB).
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+#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/phong-cubes/main.qml b/tests/manual/phong-cubes/main.qml
new file mode 100644
index 000000000..ed56387d4
--- /dev/null
+++ b/tests/manual/phong-cubes/main.qml
@@ -0,0 +1,110 @@
+// Copyright (C) 2017 Klaralvdalens Datakonsult AB (KDAB).
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+import Qt3D.Core 2.0
+import Qt3D.Render 2.0
+import Qt3D.Input 2.0
+import Qt3D.Extras 2.10
+import QtQuick 2.0
+
+Entity {
+ components: [
+ RenderSettings {
+ activeFrameGraph: ForwardRenderer {
+ clearColor: "white"
+ camera: mainCamera
+ }
+ },
+ InputSettings { }
+ ]
+
+ Camera {
+ id: mainCamera
+ position: Qt.vector3d(0.0, 0.0, 7.0)
+ upVector: Qt.vector3d(0.0, 1.0, 0.0)
+ viewCenter: Qt.vector3d(0.0, 0.0, 0.0)
+ }
+
+ FirstPersonCameraController {
+ camera: mainCamera
+ }
+
+ Entity {
+ components: [
+ PointLight {},
+ Transform { translation: mainCamera.position }
+ ]
+ }
+
+ CubeEntity {
+ position: Qt.vector3d(-1, 1, 0)
+ material: DiffuseSpecularMaterial {}
+ }
+
+ CubeEntity {
+ position: Qt.vector3d(0, 1, 0)
+ material: DiffuseSpecularMaterial {
+ diffuse: TextureLoader { source: "qrc:/assets/textures/aluminium_random_brushed/aluminium_random_brushed_basecolor.png" }
+ }
+ }
+
+ CubeEntity {
+ position: Qt.vector3d(1, 1, 0)
+ material: DiffuseSpecularMaterial {
+ diffuse: TextureLoader { source: "qrc:/assets/textures/aluminium_random_brushed/aluminium_random_brushed_basecolor.png" }
+ specular: TextureLoader { source: "qrc:/assets/textures/aluminium_random_brushed/aluminium_random_brushed_metallic.png" }
+ }
+ }
+
+ CubeEntity {
+ position: Qt.vector3d(-1, 0, 0)
+ material: DiffuseSpecularMaterial {
+ alphaBlending: true
+ diffuse: Qt.rgba(0.7, 0.7, 0.7, 0.5)
+ }
+ }
+
+ CubeEntity {
+ position: Qt.vector3d(0, 0, 0)
+ material: DiffuseSpecularMaterial {
+ normal: TextureLoader { source: "qrc:/assets/textures/aluminium_random_brushed/aluminium_random_brushed_basecolor.png" }
+ diffuse: TextureLoader { source: "qrc:/assets/textures/aluminium_random_brushed/aluminium_random_brushed_metallic.png" }
+ }
+ }
+
+ CubeEntity {
+ position: Qt.vector3d(1, 0, 0)
+ material: DiffuseSpecularMaterial {
+ alphaBlending: true
+ normal: TextureLoader { source: "qrc:/assets/textures/aluminium_random_brushed/aluminium_random_brushed_basecolor.png" }
+ diffuse: TextureLoader { source: "qrc:/assets/textures/aluminium_random_brushed/aluminium_random_brushed_metallic.png" }
+ }
+ }
+
+ CubeEntity {
+ position: Qt.vector3d(-1, -1, 0)
+ material: DiffuseSpecularMaterial {
+ normal: TextureLoader { source: "qrc:/assets/textures/copper_brushed/copper_brushed_normal.png" }
+ diffuse: TextureLoader { source: "qrc:/assets/textures/copper_brushed/copper_brushed_basecolor.png" }
+ specular: TextureLoader { source: "qrc:/assets/textures/copper_brushed/copper_brushed_metallic.png" }
+ }
+ }
+
+ CubeEntity {
+ position: Qt.vector3d(0, -1, 0)
+ material: DiffuseSpecularMaterial {
+ normal: TextureLoader { source: "qrc:/assets/textures/copper_brushed/copper_brushed_normal.png" }
+ diffuse: TextureLoader { source: "qrc:/assets/textures/copper_brushed/copper_brushed_basecolor.png" }
+ specular: TextureLoader { source: "qrc:/assets/textures/copper_brushed/copper_brushed_metallic.png" }
+ }
+ }
+
+ CubeEntity {
+ position: Qt.vector3d(1, -1, 0)
+ material: DiffuseSpecularMaterial {
+ normal: TextureLoader { source: "qrc:/assets/textures/copper_brushed/copper_brushed_normal.png" }
+ diffuse: TextureLoader { source: "qrc:/assets/textures/copper_brushed/copper_brushed_basecolor.png" }
+ specular: TextureLoader { source: "qrc:/assets/textures/copper_brushed/copper_brushed_metallic.png" }
+ }
+ }
+}
diff --git a/tests/manual/phong-cubes/phong-cubes.pro b/tests/manual/phong-cubes/phong-cubes.pro
new file mode 100644
index 000000000..e099b336d
--- /dev/null
+++ b/tests/manual/phong-cubes/phong-cubes.pro
@@ -0,0 +1,18 @@
+!include( ../examples.pri ) {
+ error( "Couldn't find the examples.pri file!" )
+}
+
+SOURCE += main.cpp
+
+QT += qml quick 3dcore 3drender 3dinput 3dquick 3dquickextras
+
+OTHER_FILES += \
+ main.qml \
+ CubeEntity.qml
+
+SOURCES += \
+ main.cpp
+
+RESOURCES += \
+ phong-cubes.qrc \
+ ../exampleresources/textures.qrc
diff --git a/tests/manual/phong-cubes/phong-cubes.qrc b/tests/manual/phong-cubes/phong-cubes.qrc
new file mode 100644
index 000000000..84cec1121
--- /dev/null
+++ b/tests/manual/phong-cubes/phong-cubes.qrc
@@ -0,0 +1,6 @@
+<RCC>
+ <qresource prefix="/">
+ <file>main.qml</file>
+ <file>CubeEntity.qml</file>
+ </qresource>
+</RCC>