diff options
author | Julian de Bhal <julian.debhal@nokia.com> | 2011-04-14 17:04:48 +1000 |
---|---|---|
committer | Julian de Bhal <julian.debhal@nokia.com> | 2011-04-14 17:06:16 +1000 |
commit | a1b29bc3798992bfac412bfcb2effd63a80af10d (patch) | |
tree | 9544607b035d46e68919e9fd435fce8d28a6e7ef /tests | |
parent | b0fac991340de58ab6d06beaa9b32c5a8c571be6 (diff) |
Add QDeclarativeItem3D::meshNode manual tests
Change-Id: I6680b4611bb3f5ed969818abe7f9fb85b2e0c036
Diffstat (limited to 'tests')
-rw-r--r-- | tests/manual/manual.pro | 2 | ||||
-rw-r--r-- | tests/manual/submesh/README | 9 | ||||
-rw-r--r-- | tests/manual/submesh/icon-l-qtquick3d.png | bin | 0 -> 6565 bytes | |||
-rw-r--r-- | tests/manual/submesh/main.cpp | 66 | ||||
-rw-r--r-- | tests/manual/submesh/qml/meshes/lunar-lander.3ds | bin | 0 -> 23456 bytes | |||
-rw-r--r-- | tests/manual/submesh/qml/tst_submesh.qml | 128 | ||||
-rw-r--r-- | tests/manual/submesh/submesh.pro | 48 | ||||
-rw-r--r-- | tests/manual/submesh/tst_submesh_qml.desktop | 8 | ||||
-rw-r--r-- | tests/shared/qmlres.h | 118 | ||||
-rw-r--r-- | tests/tests.pro | 2 |
10 files changed, 380 insertions, 1 deletions
diff --git a/tests/manual/manual.pro b/tests/manual/manual.pro new file mode 100644 index 000000000..29aa20369 --- /dev/null +++ b/tests/manual/manual.pro @@ -0,0 +1,2 @@ +TEMPLATE = subdirs +SUBDIRS += submesh diff --git a/tests/manual/submesh/README b/tests/manual/submesh/README new file mode 100644 index 000000000..4dc84f04c --- /dev/null +++ b/tests/manual/submesh/README @@ -0,0 +1,9 @@ + +This test renders a lander model and submeshes to validate functionality. +A radar dish submesh is stripped off, and duplicated three times. +One instance rotates near the original position on the lander. +If the submesh is not successfully removed from the model, there will be a second +stationary dish underneath/near this rotating dish. +A second model moves left and right, and should appear close to the right of lander. +The third dish is testing scaling. Because of the way the scaling works, it may also appear to +be moving left and right, and this is acceptable. diff --git a/tests/manual/submesh/icon-l-qtquick3d.png b/tests/manual/submesh/icon-l-qtquick3d.png Binary files differnew file mode 100644 index 000000000..69deef3f6 --- /dev/null +++ b/tests/manual/submesh/icon-l-qtquick3d.png diff --git a/tests/manual/submesh/main.cpp b/tests/manual/submesh/main.cpp new file mode 100644 index 000000000..bea68e85d --- /dev/null +++ b/tests/manual/submesh/main.cpp @@ -0,0 +1,66 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtQuick3D module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include <QtGui/QApplication> +#include <QtDeclarative/qdeclarativeview.h> +#include <QtCore/qdir.h> + +#include "../../shared/qmlres.h" + +int main(int argc, char *argv[]) +{ + QApplication app(argc, argv); + + qDebug() << "tst_submesh.qml"; + + QDeclarativeView view; + QString qml = q_get_qmldir(QLatin1String("qml/tst_submesh.qml")); + view.setSource(QUrl::fromLocalFile(qml)); + + if (QApplication::arguments().contains(QLatin1String("-maximize"))) + view.showMaximized(); + else if (QApplication::arguments().contains(QLatin1String("-fullscreen"))) + view.showFullScreen(); + else + view.show(); + + return app.exec(); +} diff --git a/tests/manual/submesh/qml/meshes/lunar-lander.3ds b/tests/manual/submesh/qml/meshes/lunar-lander.3ds Binary files differnew file mode 100644 index 000000000..7403fdefe --- /dev/null +++ b/tests/manual/submesh/qml/meshes/lunar-lander.3ds diff --git a/tests/manual/submesh/qml/tst_submesh.qml b/tests/manual/submesh/qml/tst_submesh.qml new file mode 100644 index 000000000..636bf8b49 --- /dev/null +++ b/tests/manual/submesh/qml/tst_submesh.qml @@ -0,0 +1,128 @@ +import Qt 4.7 +import Qt3D 1.0 + +// QTBUG-17418 +Item { + id: screen + width: 720 + height: 480 + Rectangle { + id: description + border.width: 3 + radius: 5 + property variant radarPostion: recieverItem.localToWorld(); + x: radarPostion.x * view.width + width: parent.width + height: text.height + 10 + Text { + id: text + width: parent.width + wrapMode: "WordWrap" + text: "There should be a stationary lander model with a rotating radar dish attached. \n" + + "The lander and attached radar dish should show no scaling or translation.\n" + + "There should be a second radar dish, scaling but not rotating.. \n" + + "It is acceptable if the scaling dish appears to be moving due to the scaling.\n" + + "There should be a third radar dish colored red, oscillating horizontally without scaling." + anchors.centerIn: parent + } + } + Rectangle { + width: parent.width + anchors.top: description.bottom + anchors.bottom: screen.bottom + anchors.left: screen.left + anchors.right: screen.right + color: "#aaccee" + + Viewport { + id: view + anchors.fill: parent + picking: true + // showPicking: true + camera: Camera { eye: Qt.vector3d(0,15,50)} + + Mesh { + id:landerMesh + source: "meshes/lunar-lander.3ds" + } + + Item3D { + mesh: landerMesh + + Item3D { + // Correct context loss from "pulling off" of graph + transform: [ + Rotation3D { axis: Qt.vector3d(1.0, 0.0, 0.0) ; angle: -90}, + Rotation3D { + id: radarSpin2 ; axis: Qt.vector3d(0.0, 1.0, 0.0); + angle: 0 + origin: Qt.vector3d(0.55,0.0,0.0) + NumberAnimation on angle { + running: true; loops: Animation.Infinite + from: 360; to: 0; duration: 3000; + } + } + ] + + Item3D { mesh: landerMesh; meshNode: "Rod.001" } + Item3D { mesh: landerMesh; meshNode: "Receiver.001" } + Item3D { mesh: landerMesh; meshNode: "Dish.001" } + } + } + + Item3D { + // Check that you can duplicate items + id: scalingRadarDish + SequentialAnimation on scale { + loops: Animation.Infinite; running: true + NumberAnimation { from:1.0 ; to: 3.0; duration: 500 } + NumberAnimation { from:3.0 ; to: 1.0; duration: 500 } + + } + // rotate object to remove ambiguity - scaling causes + // movement, and if this is in the z axis, the scaling + // could be confused with perspective. + + position: Qt.vector3d(3.0,0.0,0.0) + + transform: Rotation3D { + axis: Qt.vector3d(0.0,1.0,0.0) + angle: -90 + } + + effect: + Effect { id: redEffect; material: red } + Material { + // Distinctive red Color + id: red + ambientColor: "#884444" + diffuseColor: "#EE4422" + specularColor: "#FF8888" + shininess: 200 + } + + Item3D { mesh: landerMesh; meshNode: "Rod.001"; effect: redEffect } + Item3D { id: recieverItem; mesh: landerMesh; meshNode: "Receiver.001" ; effect: redEffect } + Item3D { mesh: landerMesh; meshNode: "Dish.001" ; effect: redEffect } + + } + Item3D { + // Check that you can duplicate items + id: translatingRadarDish + + SequentialAnimation on x { + loops: Animation.Infinite + NumberAnimation { from: 0.0; to: 5.0 ; duration: 600 } + NumberAnimation { from: 5.0; to: 0.0 ; duration: 600 } + } + + Item3D { mesh: landerMesh; meshNode: "Rod.001"; effect: redEffect } + Item3D { mesh: landerMesh; meshNode: "Receiver.001" ; effect: redEffect } + Item3D { mesh: landerMesh; meshNode: "Dish.001" ; effect: redEffect } + + } + } + + } + +} diff --git a/tests/manual/submesh/submesh.pro b/tests/manual/submesh/submesh.pro new file mode 100644 index 000000000..f277a374c --- /dev/null +++ b/tests/manual/submesh/submesh.pro @@ -0,0 +1,48 @@ +TEMPLATE = app +TARGET = tst_submesh +CONFIG += qt warn_on + +SOURCES += main.cpp +HEADERS += ../../shared/qmlres.h + +QT += declarative + +!package:DESTDIR = ../../../bin + +qmlResources.files = qml +symbian { + DEPLOYMENT = qmlResources +} else { + macx { + qmlResources.path = Contents/Resources + QMAKE_BUNDLE_DATA += qmlResources + } else { + !package { + qmlResources.input = qmlResources.files + qmlResources.output = $$OUT_PWD/../../../bin/resources/tests/$$TARGET/qml + qmlResources.commands = $$QMAKE_COPY_DIR ${QMAKE_FILE_IN} ${QMAKE_FILE_OUT} + qmlResources.CONFIG += no_link_no_clean + qmlResources.variable_out = POST_TARGETDEPS + QMAKE_EXTRA_COMPILERS += qmlResources + } + } +} + +# for make install use in packages +distInstalls.files = qml +distInstalls.path = $$[QT_INSTALL_DATA]/quick3d/tests/$$TARGET +INSTALLS += distInstalls + +package { + maemo { + applnk.files = tst_submesh_qml.desktop + applnk.path = /usr/share/applications + + icons.files = icon-l-qtquick3d.png + icons.path = /usr/share/themes/base/meegotouch/icons + INSTALLS += icons applnk + } + + target.path = $$[QT_INSTALL_BINS] + INSTALLS += target +} diff --git a/tests/manual/submesh/tst_submesh_qml.desktop b/tests/manual/submesh/tst_submesh_qml.desktop new file mode 100644 index 000000000..361fd36ec --- /dev/null +++ b/tests/manual/submesh/tst_submesh_qml.desktop @@ -0,0 +1,8 @@ +[Desktop Entry] +Type=Application +Name=tst_submesh +Icon=icon-l-qtquick3d +Exec=/usr/bin/tst_submesh -fullscreen +OnlyShowIn=X-MeeGo; +X-MeeGo-Logical-Id=qtn_comm_appname_tst_submesh_qml +X-MeeGo-Translation-Catalog=essentials diff --git a/tests/shared/qmlres.h b/tests/shared/qmlres.h new file mode 100644 index 000000000..00656c5a0 --- /dev/null +++ b/tests/shared/qmlres.h @@ -0,0 +1,118 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the Qt3D module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + + +#ifndef QMLRES_H +#define QMLRES_H + +#include <QtCore/qdir.h> +#include <QtCore/qcoreapplication.h> + +#include <QtCore/qdebug.h> + +/*! + \internal + Returns a string with the path to qml resources, including qml sources, + 3D assets and textures. The path depends on the platform, and (for + some platforms) whether it was installed from a package or is being run + in a development setting. +*/ +static QString q_get_qmldir(const QString &name) +{ + QString qml = name; + // try for a Linux package install first + QDir pkgdir(QLatin1String("/usr/share/qt4/quick3d/tests")); + QString app = QCoreApplication::applicationFilePath(); + app = app.section(QDir::separator(), -1); + if (pkgdir.cd(app) && pkgdir.exists()) + { + qml = pkgdir.filePath(qml); + } + else + { + // failing that try Mac (pkg & dev) next + QDir dir(QCoreApplication::applicationDirPath()); + if (dir.path().endsWith(QLatin1String("MacOS"))) + { + if (dir.cdUp() && dir.cd(QLatin1String("Resources")) + && dir.exists()) + { + qml = dir.filePath(qml); + } + else + { + qWarning("Expected app bundle with QML resources!"); + } + } + else + { + // for Windows (pkg & dev), and for Linux dev expect to find it + // in a "resources" directory next to the binary + if (dir.cd(QLatin1String("resources")) && dir.exists()) + { + app = QDir::toNativeSeparators(app); + //For windows platforms the "app" filepath should have the .exe extension removed. + const QString winExtension = ".exe"; + if (app.right(winExtension.length()) == winExtension) { + app = app.left(app.length() - winExtension.length()); + } + + //Grab just the app name itself. + app = app.section(QDir::separator(), -1); + + if (dir.cd(QLatin1String("tests")) && dir.cd(app) && dir.exists()) + { + qml = dir.filePath(qml); + } + else + { + QString msg = QLatin1String("tests"); + msg += QDir::separator(); + msg += app; + qWarning("Expected %s directry with qml resources!", qPrintable(msg)); + } + } + } + } + return qml; +} + +#endif // QMLRES_H diff --git a/tests/tests.pro b/tests/tests.pro index 6b6bdacbc..6c25dbe4e 100644 --- a/tests/tests.pro +++ b/tests/tests.pro @@ -1,2 +1,2 @@ TEMPLATE = subdirs -SUBDIRS = auto benchmarks +SUBDIRS = auto benchmarks manual |