diff options
author | Tomi Korpipää <tomi.korpipaa@theqtcompany.com> | 2016-04-19 09:55:20 +0300 |
---|---|---|
committer | Tomi Korpipää <tomi.korpipaa@theqtcompany.com> | 2016-04-19 09:17:14 +0000 |
commit | af27dc16d9a1b491692a38efa302346d6a29ab07 (patch) | |
tree | 09b21d1d582c37168e91d421527e34d46970c74e | |
parent | 8ae22725a8d54f99bdc47c9c2df9c750ac4074b3 (diff) |
Initial commit of current Cinematic3D demo
Change-Id: Ie3d5581dd134c734b99d3b2fe725af2899ecd9e0
Reviewed-by: Miikka Heikkinen <miikka.heikkinen@theqtcompany.com>
86 files changed, 3574 insertions, 0 deletions
diff --git a/android/AndroidManifest.xml b/android/AndroidManifest.xml new file mode 100644 index 0000000..3b171c6 --- /dev/null +++ b/android/AndroidManifest.xml @@ -0,0 +1,60 @@ +<?xml version="1.0"?> +<manifest package="org.qtproject.example" xmlns:android="http://schemas.android.com/apk/res/android" android:versionName="1.0" android:versionCode="1" android:installLocation="auto"> + <application android:hardwareAccelerated="true" android:name="org.qtproject.qt5.android.bindings.QtApplication" android:label="-- %%INSERT_APP_NAME%% --"> + <activity android:configChanges="orientation|uiMode|screenLayout|screenSize|smallestScreenSize|locale|fontScale|keyboard|keyboardHidden|navigation" android:name="org.qtproject.qt5.android.bindings.QtActivity" android:label="-- %%INSERT_APP_NAME%% --" android:screenOrientation="landscape" android:launchMode="singleTop"> + <intent-filter> + <action android:name="android.intent.action.MAIN"/> + <category android:name="android.intent.category.LAUNCHER"/> + </intent-filter> + <meta-data android:name="android.app.lib_name" android:value="-- %%INSERT_APP_LIB_NAME%% --"/> + <meta-data android:name="android.app.qt_sources_resource_id" android:resource="@array/qt_sources"/> + <meta-data android:name="android.app.repository" android:value="default"/> + <meta-data android:name="android.app.qt_libs_resource_id" android:resource="@array/qt_libs"/> + <meta-data android:name="android.app.bundled_libs_resource_id" android:resource="@array/bundled_libs"/> + <!-- Deploy Qt libs as part of package --> + <meta-data android:name="android.app.bundle_local_qt_libs" android:value="-- %%BUNDLE_LOCAL_QT_LIBS%% --"/> + <meta-data android:name="android.app.bundled_in_lib_resource_id" android:resource="@array/bundled_in_lib"/> + <meta-data android:name="android.app.bundled_in_assets_resource_id" android:resource="@array/bundled_in_assets"/> + <!-- Run with local libs --> + <meta-data android:name="android.app.use_local_qt_libs" android:value="-- %%USE_LOCAL_QT_LIBS%% --"/> + <meta-data android:name="android.app.libs_prefix" android:value="/data/local/tmp/qt/"/> + <meta-data android:name="android.app.load_local_libs" android:value="-- %%INSERT_LOCAL_LIBS%% --"/> + <meta-data android:name="android.app.load_local_jars" android:value="-- %%INSERT_LOCAL_JARS%% --"/> + <meta-data android:name="android.app.static_init_classes" android:value="-- %%INSERT_INIT_CLASSES%% --"/> + <!-- Messages maps --> + <meta-data android:value="@string/ministro_not_found_msg" android:name="android.app.ministro_not_found_msg"/> + <meta-data android:value="@string/ministro_needed_msg" android:name="android.app.ministro_needed_msg"/> + <meta-data android:value="@string/fatal_error_msg" android:name="android.app.fatal_error_msg"/> + <!-- Messages maps --> + + <!-- Splash screen --> + <!-- + <meta-data android:name="android.app.splash_screen_drawable" android:resource="@drawable/logo"/> + --> + <!-- Splash screen --> + + <!-- Background running --> + <!-- Warning: changing this value to true may cause unexpected crashes if the + application still try to draw after + "applicationStateChanged(Qt::ApplicationSuspended)" + signal is sent! --> + <meta-data android:name="android.app.background_running" android:value="false"/> + <!-- Background running --> + + <!-- Show translucent UI on top of Qt's surface when system theme mandates it --> + <meta-data android:name="android.app.allow_overlapping_system_ui" android:value="false"/> + <!-- Show translucent UI on top of Qt's surface when system theme mandates it --> + </activity> + </application> + <uses-sdk android:minSdkVersion="9" android:targetSdkVersion="14"/> + <supports-screens android:largeScreens="true" android:normalScreens="true" android:anyDensity="true" android:smallScreens="true"/> + + <!-- The following comment will be replaced upon deployment with default permissions based on the dependencies of the application. + Remove the comment if you do not require these default permissions. --> + <!-- %%INSERT_PERMISSIONS --> + + <!-- The following comment will be replaced upon deployment with default features based on the dependencies of the application. + Remove the comment if you do not require these default features. --> + <!-- %%INSERT_FEATURES --> + +</manifest> diff --git a/android/build.gradle b/android/build.gradle new file mode 100644 index 0000000..ef416b0 --- /dev/null +++ b/android/build.gradle @@ -0,0 +1,57 @@ +buildscript { + repositories { + jcenter() + } + + dependencies { + classpath 'com.android.tools.build:gradle:1.1.0' + } +} + +allprojects { + repositories { + jcenter() + } +} + +apply plugin: 'com.android.application' + +dependencies { + compile fileTree(dir: 'libs', include: ['*.jar']) +} + +android { + /******************************************************* + * The following variables: + * - androidBuildToolsVersion, + * - androidCompileSdkVersion + * - qt5AndroidDir - holds the path to qt android files + * needed to build any Qt application + * on Android. + * + * are defined in gradle.properties file. This file is + * updated by QtCreator and androiddeployqt tools. + * Changing them manually might break the compilation! + *******************************************************/ + + compileSdkVersion androidCompileSdkVersion.toInteger() + + buildToolsVersion androidBuildToolsVersion + + sourceSets { + main { + manifest.srcFile 'AndroidManifest.xml' + java.srcDirs = [qt5AndroidDir + '/src', 'src', 'java'] + aidl.srcDirs = [qt5AndroidDir + '/src', 'src', 'aidl'] + res.srcDirs = [qt5AndroidDir + '/res', 'res'] + resources.srcDirs = ['src'] + renderscript.srcDirs = ['src'] + assets.srcDirs = ['assets'] + jniLibs.srcDirs = ['libs'] + } + } + + lintOptions { + abortOnError false + } +} diff --git a/android/res/values/libs.xml b/android/res/values/libs.xml new file mode 100644 index 0000000..4d68673 --- /dev/null +++ b/android/res/values/libs.xml @@ -0,0 +1,25 @@ +<?xml version='1.0' encoding='utf-8'?> +<resources> + <array name="qt_sources"> + <item>https://download.qt-project.org/ministro/android/qt5/qt-5.4</item> + </array> + + <!-- The following is handled automatically by the deployment tool. It should + not be edited manually. --> + + <array name="bundled_libs"> + <!-- %%INSERT_EXTRA_LIBS%% --> + </array> + + <array name="qt_libs"> + <!-- %%INSERT_QT_LIBS%% --> + </array> + + <array name="bundled_in_lib"> + <!-- %%INSERT_BUNDLED_IN_LIB%% --> + </array> + <array name="bundled_in_assets"> + <!-- %%INSERT_BUNDLED_IN_ASSETS%% --> + </array> + +</resources> diff --git a/cinematic3d.pro b/cinematic3d.pro new file mode 100644 index 0000000..3bb658b --- /dev/null +++ b/cinematic3d.pro @@ -0,0 +1,42 @@ +TEMPLATE = app + +QT += qml quick +QT += multimedia + +SOURCES += main.cpp + +RESOURCES += \ + qml.qrc \ + images.qrc + +VIDEO_FILES.files = \ + # Note: Enable these if videos are bundled locally + #videos/Build_Your_World_With_Qt.mp4 \ + #videos/Bluescape_collaborative_workspace.mp4 \ + #videos/IoT_and_Qt.mp4 \ + #videos/Meet_Qt_Creator.mp4 \ + #videos/3D_Planets_Example.mp4 + +# On OSX videos are bundled, on android installed into assets +osx { + VIDEO_FILES.path = Contents/MacOS + QMAKE_BUNDLE_DATA += VIDEO_FILES +} +android { + VIDEO_FILES.path = /assets/videos + INSTALLS += VIDEO_FILES +} + + +# Additional import path used to resolve QML modules in Qt Creator's code model +QML_IMPORT_PATH = + +# Default rules for deployment. +include(deployment.pri) + +DISTFILES += \ + android/AndroidManifest.xml \ + android/res/values/libs.xml \ + android/build.gradle + +ANDROID_PACKAGE_SOURCE_DIR = $$PWD/android diff --git a/deployment.pri b/deployment.pri new file mode 100644 index 0000000..5441b63 --- /dev/null +++ b/deployment.pri @@ -0,0 +1,27 @@ +android-no-sdk { + target.path = /data/user/qt + export(target.path) + INSTALLS += target +} else:android { + x86 { + target.path = /libs/x86 + } else: armeabi-v7a { + target.path = /libs/armeabi-v7a + } else { + target.path = /libs/armeabi + } + export(target.path) + INSTALLS += target +} else:unix { + isEmpty(target.path) { + qnx { + target.path = /tmp/$${TARGET}/bin + } else { + target.path = /opt/$${TARGET}/bin + } + export(target.path) + } + INSTALLS += target +} + +export(INSTALLS) diff --git a/images.qrc b/images.qrc new file mode 100644 index 0000000..a84d77d --- /dev/null +++ b/images.qrc @@ -0,0 +1,60 @@ +<RCC> + <qresource prefix="/"> + <file>qml/images/qt_logo.png</file> + <file>qml/images/quit_logo.png</file> + <file>qml/images/qt_logo_small.png</file> + <file>qml/images/quit_logo_small.png</file> + <file>qml/images/cubemaps/space/space_negx.png</file> + <file>qml/images/cubemaps/space/space_negy.png</file> + <file>qml/images/cubemaps/space/space_negz.png</file> + <file>qml/images/cubemaps/space/space_posx.png</file> + <file>qml/images/cubemaps/space/space_posy.png</file> + <file>qml/images/cubemaps/space/space_posz.png</file> + <file>qml/images/cubemaps/miramar/miramar_negx.webp</file> + <file>qml/images/cubemaps/miramar/miramar_negy.webp</file> + <file>qml/images/cubemaps/miramar/miramar_negz.webp</file> + <file>qml/images/cubemaps/miramar/miramar_posx.webp</file> + <file>qml/images/cubemaps/miramar/miramar_posy.webp</file> + <file>qml/images/cubemaps/miramar/miramar_posz.webp</file> + <file>qml/images/panel_bg.png</file> + <file>qml/images/panel2_bg.png</file> + <file>qml/images/info_sc1.png</file> + <file>qml/images/info_sc2.png</file> + <file>qml/images/info_sc3.png</file> + <file>qml/images/info_sc4.png</file> + <file>qml/images/planet.png</file> + <file>qml/images/icons/info.png</file> + <file>qml/images/icons/pause.png</file> + <file>qml/images/icons/play.png</file> + <file>qml/images/icons/rewind.png</file> + <file>qml/images/icons/settings.png</file> + <file>qml/images/icons/back.png</file> + <file>qml/images/icons/fastforward.png</file> + <file>qml/images/icons/rotation.png</file> + <file>qml/images/covers/3D_Planets.jpg</file> + <file>qml/images/covers/Bluescape.jpg</file> + <file>qml/images/covers/Build_Your_World.jpg</file> + <file>qml/images/covers/IoT.jpg</file> + <file>qml/images/covers/Meet_Qt_Creator.jpg</file> + <file>qml/images/shots/3D_Planets_1.jpg</file> + <file>qml/images/shots/3D_Planets_2.jpg</file> + <file>qml/images/shots/3D_Planets_3.jpg</file> + <file>qml/images/shots/3D_Planets_4.jpg</file> + <file>qml/images/shots/Bluescape_1.jpg</file> + <file>qml/images/shots/Bluescape_2.jpg</file> + <file>qml/images/shots/Bluescape_3.jpg</file> + <file>qml/images/shots/Bluescape_4.jpg</file> + <file>qml/images/shots/Build_Your_World_1.jpg</file> + <file>qml/images/shots/Build_Your_World_2.jpg</file> + <file>qml/images/shots/Build_Your_World_3.jpg</file> + <file>qml/images/shots/Build_Your_World_4.jpg</file> + <file>qml/images/shots/IoT_1.jpg</file> + <file>qml/images/shots/IoT_2.jpg</file> + <file>qml/images/shots/IoT_3.jpg</file> + <file>qml/images/shots/IoT_4.jpg</file> + <file>qml/images/shots/Meet_Qt_Creator_1.jpg</file> + <file>qml/images/shots/Meet_Qt_Creator_2.jpg</file> + <file>qml/images/shots/Meet_Qt_Creator_3.jpg</file> + <file>qml/images/shots/Meet_Qt_Creator_4.jpg</file> + </qresource> +</RCC> diff --git a/main.cpp b/main.cpp new file mode 100644 index 0000000..919e9ac --- /dev/null +++ b/main.cpp @@ -0,0 +1,84 @@ +/**************************************************************************** +** +** Copyright (C) 2015 QUIt Coding Ltd. +** Contact: info@quitcoding.com +** +** This file is part of Cinematic 3D, a Qt3D demo application. +** +** $QT_BEGIN_LICENSE:BSD$ +** 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 <QQmlApplicationEngine> +#include <QUrl> +#include <QStringList> +#include <QStandardPaths> +#include <QQmlContext> +#include <QNetworkConfigurationManager> +#include <QDebug> + +static bool FORCE_LOCAL_VIDEOS = false; + +int main(int argc, char *argv[]) +{ + QGuiApplication app(argc, argv); + QQmlApplicationEngine engine; + + QNetworkConfigurationManager mgr; + + // Export movies path + // On Android use assets, on OS X (bundle) application path, otherwise application path + "/videos" + + + // If we have network connections, use empty videoPath + if (!FORCE_LOCAL_VIDEOS && mgr.isOnline()) { + qDebug() << "Loading videos from Internet"; + engine.rootContext()->setContextProperty("videoPath", "https://s3-eu-west-1.amazonaws.com/qt-files/examples/Videos/"); + } else { + qDebug() << "Loading videos locally"; +#if defined(Q_OS_ANDROID) + engine.rootContext()->setContextProperty("videoPath", "assets:/videos/"); +#else + const QUrl appPath(QUrl::fromLocalFile(app.applicationDirPath())); +#if defined(Q_OS_OSX) + engine.rootContext()->setContextProperty("videoPath", appPath.toString() + "/"); +#else + engine.rootContext()->setContextProperty("videoPath", appPath.toString() + "/videos/"); +#endif +#endif + } + engine.load(QUrl(QStringLiteral("qrc:/qml/main.qml"))); + + return app.exec(); +} + @@ -0,0 +1,25 @@ +<RCC> + <qresource prefix="/"> + <file>qml/main.qml</file> + <file>qml/CarouselView.qml</file> + <file>qml/CarouselPathView.qml</file> + <file>qml/Cinematic3DScene.qml</file> + <file>qml/BackgroundCubeMap.qml</file> + <file>qml/EnvMappedWavyGLES2ShaderProgram.qml</file> + <file>qml/EnvMappedBoxGLES2ShaderProgram.qml</file> + <file>qml/Cover3D.qml</file> + <file>qml/PlayerView.qml</file> + <file>qml/IconButton.qml</file> + <file>qml/DetailsView.qml</file> + <file>qml/TextureBox3D.qml</file> + <file>qml/MipMappedTexture2D.qml</file> + <file>qml/InfoView.qml</file> + <file>qml/SettingsView.qml</file> + <file>qml/Switch.qml</file> + <file>qml/FpsItem.qml</file> + <file>qml/Sphere3D.qml</file> + <file>qml/TexturedBoxGLES2ShaderProgram.qml</file> + <file>qml/TexturedWavyShaderProgram.qml</file> + <file>qml/Cinematic3D_videos.xml</file> + </qresource> +</RCC> diff --git a/qml/BackgroundCubeMap.qml b/qml/BackgroundCubeMap.qml new file mode 100644 index 0000000..1c9aa8c --- /dev/null +++ b/qml/BackgroundCubeMap.qml @@ -0,0 +1,154 @@ +/**************************************************************************** +** +** Copyright (C) 2015 QUIt Coding Ltd. +** Contact: info@quitcoding.com +** +** This file is part of Cinematic 3D, a Qt3D demo application. +** +** $QT_BEGIN_LICENSE:BSD$ +** 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 + +Entity { + property alias cameraPosition: transform.translation + property int cubemapIndex: 0 + property TextureCubeMap cubemapTexture: skyboxTexture + + TextureCubeMap { + id: skyboxTexture + property var cubemaps: ["space", "miramar"] + property string cubemap: cubemaps[cubemapIndex] + property string path: "qrc:/qml/images/cubemaps/" + cubemap + "/" + cubemap + property string extension: cubemap == "space" ? ".png" : ".webp" + + generateMipMaps: false + magnificationFilter: Texture.Linear + minificationFilter: Texture.Linear + wrapMode { + x: WrapMode.ClampToEdge + y: WrapMode.ClampToEdge + } + TextureImage { face: Texture.CubeMapPositiveX; source: skyboxTexture.path + "_posx" + skyboxTexture.extension } + TextureImage { face: Texture.CubeMapPositiveY; source: skyboxTexture.path + "_posy" + skyboxTexture.extension } + TextureImage { face: Texture.CubeMapPositiveZ; source: skyboxTexture.path + "_posz" + skyboxTexture.extension } + TextureImage { face: Texture.CubeMapNegativeX; source: skyboxTexture.path + "_negx" + skyboxTexture.extension } + TextureImage { face: Texture.CubeMapNegativeY; source: skyboxTexture.path + "_negy" + skyboxTexture.extension } + TextureImage { face: Texture.CubeMapNegativeZ; source: skyboxTexture.path + "_negz" + skyboxTexture.extension } + } + + ShaderProgram { + id: gles2SkyboxShader + + vertexShaderCode: " + attribute vec3 vertexPosition; + varying vec3 texCoord0; + + uniform mat4 mvp; + + void main() + { + texCoord0 = vertexPosition.xyz; + gl_Position = vec4(mvp * vec4(vertexPosition, 1.0)).xyww; // Fail depth test always against any rendered pixel + } + " + + fragmentShaderCode: " + varying highp vec3 texCoord0; + uniform samplerCube skyboxTexture; + + void main() + { + gl_FragColor = textureCube(skyboxTexture, texCoord0); + } + " + } + + CuboidMesh { + id: cuboidMesh + yzMeshResolution: Qt.size(2, 2) + xzMeshResolution: Qt.size(2, 2) + xyMeshResolution: Qt.size(2, 2) + } + + Transform { + id: transform + } + + Material { + id: skyboxMaterial + + parameters: [ + Parameter {name: "skyboxTexture"; value: cubemapTexture } + ] + + effect: Effect { + techniques: [ + Technique { + graphicsApiFilter { + api: GraphicsApiFilter.OpenGLES + profile: GraphicsApiFilter.NoProfile + majorVersion: 2 + minorVersion: 0 + } + renderPasses: RenderPass { + shaderProgram: gles2SkyboxShader + renderStates: [ + CullFace { mode: CullFace.Front }, + DepthTest { depthFunction: DepthTest.LessOrEqual } + ] + } + }, + Technique { + graphicsApiFilter { + api: GraphicsApiFilter.OpenGL + profile: GraphicsApiFilter.NoProfile + majorVersion: 2 + minorVersion: 0 + } + renderPasses: RenderPass { + shaderProgram: gles2SkyboxShader + renderStates: [ + CullFace { mode: CullFace.Front }, + DepthTest { depthFunction: DepthTest.LessOrEqual } + ] + } + } + ] + } + } + + components: [cuboidMesh, skyboxMaterial, transform] +} + diff --git a/qml/CarouselPathView.qml b/qml/CarouselPathView.qml new file mode 100644 index 0000000..e272122 --- /dev/null +++ b/qml/CarouselPathView.qml @@ -0,0 +1,168 @@ +/**************************************************************************** +** +** Copyright (C) 2015 QUIt Coding Ltd. +** Contact: info@quitcoding.com +** +** This file is part of Cinematic 3D, a Qt3D demo application. +** +** $QT_BEGIN_LICENSE:BSD$ +** 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.4 +import QtQuick.XmlListModel 2.0 + +PathView { + id: pathView + + property string name: currentItem ? currentItem.name : "" + property string description: currentItem ? currentItem.description : "" + + anchors.fill: parent + anchors.leftMargin: -itemWidth * 0.5 + anchors.rightMargin: -itemWidth * 0.5 + highlightRangeMode: ListView.StrictlyEnforceRange + preferredHighlightBegin: 0.5 + preferredHighlightEnd: 0.5 + snapMode: PathView.SnapToItem + maximumFlickVelocity: 3000 * dp + pathItemCount: 5 + model: moviesModel + path: Path { + startX: 0 + startY: pathView.height / 2 + PathLine { + relativeX: pathView.width + relativeY: 0 + } + } + delegate: Item { + property string name: model.name + property string description: model.description + property bool selected: pathView.currentIndex == index + property real fadeAnimationState: selected ? 0 : (1 - carouselView.opacity) + + onSelectedChanged: { + if (selected) + root.selectedCoverImage = coverImage.source; + } + transform: Translate { + y: fadeAnimationState * carouselView.height + } + + width: itemWidth + height: itemHeight + Rectangle { + anchors.fill: parent + anchors.margins: 2 + color: selected ? "#ffffff" : "#000000" + opacity: selected ? 0.8 : 0.4 + radius: width * 0.05 + Behavior on opacity { + NumberAnimation { + duration: 400 + easing.type: Easing.InOutQuad + } + } + Behavior on color { + ColorAnimation { + duration: 400 + } + } + } + Rectangle { + anchors.fill: coverImage + anchors.margins: -1 * dp + opacity: 0.6 + color: "#606060" + } + + Image { + id: coverImage + width: parent.width * 0.9 + height: width * 3/2 + anchors.horizontalCenter: parent.horizontalCenter + anchors.bottom: parent.bottom + anchors.bottomMargin: parent.width * 0.05 + source: "images/covers/" + model.image + ".jpg" + } + Text { + anchors.horizontalCenter: parent.horizontalCenter + anchors.top: parent.top + anchors.topMargin: parent.height * 0.08 - paintedHeight * 0.4 + width: parent.width * 0.9 + horizontalAlignment: Text.AlignHCenter + fontSizeMode: Text.HorizontalFit + minimumPixelSize: 18*dp + font.pixelSize: 24*dp + elide: Text.ElideRight + color: selected ? "#606060" : "#808080" + text: model.name + } + MouseArea { + anchors.fill: parent + enabled: carouselInteractive + onClicked: { + if (pathView.currentIndex === index) { + // Setup and open details view + videoFile = model.video; + detailsView.title = model.name; + detailsView.description = model.description; + detailsView.imageName = model.image; + hideDetailsView.stop(); + showDetailsView.start(); + } else { + // Select the clicked item + pathView.currentIndex = index; + } + } + } + } + + XmlListModel { + id: moviesModel + source: "Cinematic3D_videos.xml" + query: "/videolist/item" + XmlRole { name: "image"; query: "thumbnail/string()" } + XmlRole { name: "name"; query: "title/string()" } + XmlRole { name: "description"; query: "description/string()" } + XmlRole { name: "video"; query: "link/string()" } + + onStatusChanged: { + if (status == XmlListModel.Ready) { + // TODO: Show carousel only once loaded? + } else if (status == XmlListModel.Error) { + console.debug("Error loading XML model"); + } + } + } +} diff --git a/qml/CarouselView.qml b/qml/CarouselView.qml new file mode 100644 index 0000000..f97548e --- /dev/null +++ b/qml/CarouselView.qml @@ -0,0 +1,150 @@ +/**************************************************************************** +** +** Copyright (C) 2015 QUIt Coding Ltd. +** Contact: info@quitcoding.com +** +** This file is part of Cinematic 3D, a Qt3D demo application. +** +** $QT_BEGIN_LICENSE:BSD$ +** 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.4 + +Item { + id: root + + property real itemHeight: itemWidth * 1.65 + property real itemWidth: width * 0.25 + + property string selectedCoverImage + property alias carouselMoving: pathView.moving + property alias carouselInteractive: pathView.interactive + + width: parent.width + height: parent.height + + CarouselPathView { + id: pathView + + property real prevOffset: 0 + onOffsetChanged: { + var delta = offset - prevOffset; + if (delta > 1) + delta -= pathView.count; + else if (delta < -1) + delta += pathView.count; + window.carouselOffset += delta; + prevOffset = offset; + } + } + + ShaderEffectSource { + id: pathViewSource + sourceItem: pathView + hideSource: true + visible: false + } + ShaderEffect { + property variant src: pathViewSource + property real highlightAnimation: highlightAnimation2 * highlightAnimation3 + property real highlightAnimation2: 1.0 + property real highlightAnimation3: 1.0 + property real showCarouselOpacity : settings.showCarouselOpacity + Behavior on showCarouselOpacity { + NumberAnimation { + duration: 400 + easing.type: Easing.InOutQuad + } + } + SequentialAnimation on highlightAnimation2 { + loops: Animation.Infinite + NumberAnimation { + to: 1.1 + duration: 1800 + easing.type: Easing.InOutQuad + } + NumberAnimation { + to: 1.0 + duration: 1100 + easing.type: Easing.InOutQuad + } + } + SequentialAnimation on highlightAnimation3 { + loops: Animation.Infinite + NumberAnimation { + to: 1.04 + duration: 1100 + easing.type: Easing.InElastic + } + NumberAnimation { + to: 1.0 + duration: 2400 + easing.type: Easing.OutElastic + } + } + + anchors.fill: pathView + mesh: GridMesh { + resolution: Qt.size(32, 16) + } + vertexShader: " + uniform highp mat4 qt_Matrix; + attribute highp vec4 qt_Vertex; + attribute highp vec2 qt_MultiTexCoord0; + varying highp vec2 coord; + uniform highp float highlightAnimation; + void main() { + lowp float PI = 3.14159265; + highp float posy = 0.8 * qt_MultiTexCoord0.y + (0.2*qt_MultiTexCoord0.y) * sin(qt_MultiTexCoord0.x*PI); + coord = vec2(qt_MultiTexCoord0.x, posy); + gl_Position = qt_Matrix * qt_Vertex; + }" + fragmentShader: " + varying highp vec2 coord; + uniform sampler2D src; + uniform lowp float qt_Opacity; + uniform lowp float highlightAnimation; + uniform lowp float showCarouselOpacity; + void main() { + lowp vec4 tex = texture2D(src, coord); + lowp float dist = abs(coord.x-0.5)*2.0; + // Opacity + lowp vec4 gray = vec4((tex.r + tex.g + tex.b) / 3.0); + tex = mix(tex, gray, dist*1.5*showCarouselOpacity); + // Shadow + tex.rgb *= (1.2*highlightAnimation - dist*1.2); + gl_FragColor = tex * qt_Opacity; + }" + } +} + diff --git a/qml/Cinematic3DScene.qml b/qml/Cinematic3DScene.qml new file mode 100644 index 0000000..d4dfa38 --- /dev/null +++ b/qml/Cinematic3DScene.qml @@ -0,0 +1,170 @@ +/**************************************************************************** +** +** Copyright (C) 2015 QUIt Coding Ltd. +** Contact: info@quitcoding.com +** +** This file is part of Cinematic 3D, a Qt3D demo application. +** +** $QT_BEGIN_LICENSE:BSD$ +** 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 QtQuick 2.4 as QQ2 + +Entity { + id: root + + property alias coverImage: cover.coverImage + property real showDetailsTransitionState: 0.0 + property real showVideoTransitionState: 0.0 + property bool showCover: false + property vector3d cameraPosition: fullCameraTransform.matrix.inverted().times(Qt.vector3d(0,0,0)) + + RenderSettings { + activeFrameGraph: ForwardRenderer { + camera: mainCamera + clearColor: "black" + } + } + + Camera { + id: mainCamera + projectionType: CameraLens.PerspectiveProjection + // Scale the 3D view exactly as the carousel view + fieldOfView: 2 * Math.atan(0.5 * 1.5 * window.height / window.width) * 180 / Math.PI + aspectRatio: window.width / window.height + nearPlane: 0.01 + farPlane: 1000.0 + + // Animate camera roll and yaw + property real roll: 0 + QQ2.SequentialAnimation on roll { + loops: QQ2.Animation.Infinite + QQ2.NumberAnimation { + from: -1 + to: 1 + duration: 4000 + easing.type: Easing.InOutSine + } + QQ2.NumberAnimation { + from: 1 + to: -1 + duration: 4000 + easing.type: Easing.InOutSine + } + } + + property real yaw: 0 + QQ2.NumberAnimation on yaw { + from: 0 + to: -2 * Math.PI + duration: 60000 + loops: QQ2.Animation.Infinite + } + + Transform { + id: cameraRotationTransform + matrix: { + var m = Qt.matrix4x4(); + m.rotate(-19 * window.carouselOffset, Qt.vector3d(0.0, 1.0, 0.0)); + m.rotate(5 * mainCamera.roll, Qt.vector3d(0.0, 0.0, 1.0)); + m.lookAt(Qt.vector3d( 0.0, 0.0, 0.0 ), + Qt.vector3d(-40 * Math.sin(mainCamera.yaw), mainCamera.roll * 3, -40 * Math.cos(mainCamera.yaw) ), + Qt.vector3d( 0.0, 1.0, 0.0 )); + return m; + } + } + + components: [ + Transform { + id: fullCameraTransform + matrix: { + // Rotates the camera together with the objects + var m = Qt.matrix4x4(); + m.rotate(90 * showVideoTransitionState * (viewingVideo ? -1 : 1), Qt.vector3d(0.0, 1.0, 0.0)); + // Moving the camera relative to the objects + // Used in the video view transitions + m.translate(Qt.vector3d(0, 0, 50 * showVideoTransitionState * (viewingVideo ? -1 : 1))); + m = m.times(cameraRotationTransform.matrix); + return m; + } + + } + ] + } + + BackgroundCubeMap { + id: sky + // Keep the camera always in the center of the skybox + cameraPosition: root.cameraPosition + cubemapIndex: settings.starsBackground ? 0 : 1 + } + + Cover3D { + id: cover + showDetailsTransitionState: root.showDetailsTransitionState + cameraMatrix: cameraRotationTransform.matrix + cameraPosition: root.cameraPosition + visible: showCover + envMapping: settings.show3DReflections + cubemapTexture: sky.cubemapTexture + } + + TextureBox3D { + id: screenshotBox + + property string imagePath: "/qml/images/shots/" + + coverImage1: imagePath + detailsView.imageName + "_1.jpg" + coverImage2: imagePath + detailsView.imageName + "_2.jpg" + coverImage3: imagePath + detailsView.imageName + "_3.jpg" + coverImage4: imagePath + detailsView.imageName + "_4.jpg" + cameraMatrix: cameraRotationTransform.matrix + showDetailsTransitionState: root.showDetailsTransitionState + visible: showCover + cubemapTexture: sky.cubemapTexture + size: 9 + envMapping: settings.show3DReflections + } + + Sphere3D { + id: videoSphere + cameraMatrix: cameraRotationTransform.matrix + cameraPosition: root.cameraPosition + surface: "images/planet.png" + envMapping: settings.show3DReflections + size: 14 + } +} + diff --git a/qml/Cinematic3D_videos.xml b/qml/Cinematic3D_videos.xml new file mode 100644 index 0000000..45d7635 --- /dev/null +++ b/qml/Cinematic3D_videos.xml @@ -0,0 +1,52 @@ +<videolist> + +<item> +<title>Build Your World with Qt</title> +<thumbnail>Build_Your_World</thumbnail> +<link>Build_Your_World_With_Qt.mp4</link> +<description>Qt is the leading independent technology for cross-platform development. Create connected devices, UIs and applications that run anywhere on any device, on any operating system at any time. + +Companies in over 70 industries use Qt to power millions of devices and applications. Build your world with Qt. +</description> +</item> + +<item> +<title>Bluescape</title> +<thumbnail>Bluescape</thumbnail> +<link>Bluescape_collaborative_workspace.mp4</link> +<description>Bluescape cloud-based visual collaborative workspace + +With the support of Digia, Qt Services, Bluescape developed a special mapping software for teams to execute simultaneous collaboration on any device. Digia, Qt's knowledgeable team and performing technology resulted in Bluescape to look no further. +</description> +</item> + +<item> +<title>Internet of Things</title> +<thumbnail>IoT</thumbnail> +<link>IoT_and_Qt.mp4</link> +<description>Internet of Things and Qt + +The Qt Weather Station is a simple demo of how easy it is to create Internet of Things systems with Qt, the cross-platform application and UI framework. +</description> +</item> + +<item> +<title>Meet Qt Creator</title> +<thumbnail>Meet_Qt_Creator</thumbnail> +<link>Meet_Qt_Creator.mp4</link> +<description>Cross-platform Integrated Development Environment + +Whether you are creating a mobile app, desktop application or a connected embedded device, Qt Creator is the cross-platform IDE that makes application and UI development a breeze. Since time-to-market is key, the IDE includes productivity tools that speed up your development time. +</description> +</item> + + +<item> +<title>3D Planets Example</title> +<thumbnail>3D_Planets</thumbnail> +<link>3D_Planets_Example.mp4</link> +<description>Qt 5.5 features the new Qt Canvas 3D module that lets you integrate 3D contents written with a WebGL-like API. the 3D Planets example is written with the Three.js 3D library. The same example is also implemented using the technology preview of the new Qt 3D module, using a Qt API. +</description> +</item> + +</videolist> diff --git a/qml/Cover3D.qml b/qml/Cover3D.qml new file mode 100644 index 0000000..f9d5057 --- /dev/null +++ b/qml/Cover3D.qml @@ -0,0 +1,153 @@ +/**************************************************************************** +** +** Copyright (C) 2015 QUIt Coding Ltd. +** Contact: info@quitcoding.com +** +** This file is part of Cinematic 3D, a Qt3D demo application. +** +** $QT_BEGIN_LICENSE:BSD$ +** 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 QtQuick 2.4 as QQ2 + +Entity { + id: entity + + property real showDetailsTransitionState: 0.0 + property real waviness: showDetailsTransitionState * 0.5 + property url coverImage + property bool visible: true + property matrix4x4 cameraMatrix + property TextureCubeMap cubemapTexture + property vector3d cameraPosition + property bool envMapping: true + + EnvMappedWavyGLES2ShaderProgram { + id: envMappedWavyShaderProgram + } + + TexturedWavyShaderProgram { + id: texturedWavyShaderProgram + } + + Material { + id: material + + effect: Effect { + id: fx + + property real wave: 0 + QQ2.NumberAnimation on wave { + from: 0 + to: 2 * Math.PI + loops: QQ2.Animation.Infinite + duration: 3500 + } + + Parameter { id: cubemapParam; name: "skyboxTexture"; value: cubemapTexture } + Parameter { id: waveParam; name: "wave"; value: fx.wave } + Parameter { id: wavinessParam; name: "waviness"; value: entity.waviness } + Parameter { id: coverTextureParam; name: "coverTexture"; value: MipMappedTexture2D { source: coverImage } } + Parameter { id: cameraPositionParam; name: "cameraPosition"; value: cameraPosition } + + parameters: [cubemapParam, waveParam, wavinessParam, coverTextureParam, cameraPositionParam]; + + techniques: [ + Technique { + graphicsApiFilter { + api: GraphicsApiFilter.OpenGL + profile: GraphicsApiFilter.NoProfile + majorVersion: 2 + minorVersion: 0 + } + + renderPasses: RenderPass { + renderStates: [ + CullFace { mode: CullFace.Back }, + DepthTest { depthFunction: DepthTest.LessOrEqual } + ] + + shaderProgram: envMapping ? envMappedWavyShaderProgram : texturedWavyShaderProgram + } + }, + Technique { + graphicsApiFilter { + api: GraphicsApiFilter.OpenGLES + profile: GraphicsApiFilter.NoProfile + majorVersion: 2 + minorVersion: 0 + } + + renderPasses: RenderPass { + renderStates: [ + CullFace { mode: CullFace.Back }, + DepthTest { depthFunction: DepthTest.LessOrEqual } + ] + + shaderProgram: envMapping ? envMappedWavyShaderProgram : texturedWavyShaderProgram + } + } + ] + } + } + + Transform { + id: modelTransform + matrix: { + var m = cameraMatrix.inverted(); + m.translate(Qt.vector3d(0.0, + -1.5 + (1.5 * showDetailsTransitionState), + -40)); + m.rotate(40 * Math.min(1.0, showDetailsTransitionState * 1.5), Qt.vector3d(0, 1, 0)); + m.translate(Qt.vector3d(-25 * Math.max(0, showDetailsTransitionState - 0.4), + 0.0, + 0.0)); + return m; + } + } + + CuboidMesh { + id: mesh + property real multiplier: 0.0256 + xExtent: 512 * multiplier + yExtent: 768 * multiplier + zExtent: 2.0 + yzMeshResolution: Qt.size(20, 20) + xzMeshResolution: Qt.size(20, 20) + xyMeshResolution: Qt.size(20, 20) + } + + components: visible ? [modelTransform, mesh, material] : [] +} diff --git a/qml/DetailsView.qml b/qml/DetailsView.qml new file mode 100644 index 0000000..38e67a2 --- /dev/null +++ b/qml/DetailsView.qml @@ -0,0 +1,145 @@ +/**************************************************************************** +** +** Copyright (C) 2015 QUIt Coding Ltd. +** Contact: info@quitcoding.com +** +** This file is part of Cinematic 3D, a Qt3D demo application. +** +** $QT_BEGIN_LICENSE:BSD$ +** 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.4 + +Item { + id: root + + property string title + property string description + property string imageName + + signal backButtonClicked + + IconButton { + id: backButton + anchors.left: parent.left + anchors.leftMargin: 20 * dp + anchors.top: parent.top + anchors.topMargin: 20 * dp + icon: "images/icons/back.png" + onClicked: { + root.backButtonClicked() + } + } + + Text { + id: labelTextItem + anchors.horizontalCenter: parent.horizontalCenter + anchors.top: parent.top + anchors.topMargin: 20 * dp + font.pixelSize: 40 * dp + color: "#ffffff" + text: root.title + } + + Item { + anchors.fill: parent + anchors.margins: 20 * dp + anchors.leftMargin: parent.width/2 + 20 * dp + anchors.topMargin: 80 * dp + opacity: 2 * (parent.opacity - 0.5) + + Flickable { + id: flickableArea + anchors.fill: parent + anchors.bottomMargin: 80 * dp + contentHeight: textItem.paintedHeight + contentWidth: width + clip: true + topMargin: 80 * dp + bottomMargin: 80 * dp + Text { + id: textItem + width: parent.width - 20 * dp + anchors.horizontalCenter: parent.horizontalCenter + wrapMode: Text.WordWrap + font.pixelSize: 24 * dp + style: Text.Outline + color: "#e0e0e0" + styleColor: "#202020" + text: root.description + } + } + + ShaderEffectSource { + id: flickableAreaSource + sourceItem: flickableArea + hideSource: true + visible: false + } + ShaderEffect { + property variant src: flickableAreaSource + + anchors.fill: flickableArea + + fragmentShader: " + varying highp vec2 qt_TexCoord0; + uniform lowp float qt_Opacity; + uniform sampler2D src; + void main() { + lowp vec4 tex = texture2D(src, qt_TexCoord0); + lowp float dist = abs(qt_TexCoord0.y-0.5)*4.0; + tex*= min(1.0, (2.0 - dist)); + gl_FragColor = tex * qt_Opacity; + }" + } + + Text { + anchors.horizontalCenter: playButton.horizontalCenter + anchors.top: playButton.bottom + font.pixelSize: 16 * dp + color: "#ffffff" + text: qsTr("PLAY") + } + IconButton { + id: playButton + anchors.horizontalCenter: parent.horizontalCenter + anchors.bottom: parent.bottom + anchors.bottomMargin: 20 * dp + icon: "images/icons/play.png" + onClicked: { + showVideo.start(); + } + } + } +} + diff --git a/qml/EnvMappedBoxGLES2ShaderProgram.qml b/qml/EnvMappedBoxGLES2ShaderProgram.qml new file mode 100644 index 0000000..e4183d8 --- /dev/null +++ b/qml/EnvMappedBoxGLES2ShaderProgram.qml @@ -0,0 +1,112 @@ +/**************************************************************************** +** +** Copyright (C) 2015 QUIt Coding Ltd. +** Contact: info@quitcoding.com +** +** This file is part of Cinematic 3D, a Qt3D demo application. +** +** $QT_BEGIN_LICENSE:BSD$ +** 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.Render 2.0 + +ShaderProgram { + vertexShaderCode: " + attribute highp vec4 vertexPosition; + attribute highp vec3 vertexNormal; + attribute highp vec2 vertexTexCoord; + + varying highp vec2 texCoord; + varying highp vec3 normal; + varying highp vec3 viewDirection; + varying highp float w1; + varying highp float w2; + varying highp float w3; + varying highp float w4; + + uniform highp mat4 mvp; + uniform highp mat4 modelMatrix; + uniform highp vec3 cameraPosition; + + void main() + { + normal = (modelMatrix * vec4(vertexNormal, 0)).xyz; + viewDirection = vec3(modelMatrix * vertexPosition) - cameraPosition; + texCoord = vec2(vertexTexCoord.s, 1. - vertexTexCoord.t); + + w1 = w2 = w3 = w4 = 0.; + if (vertexNormal.x > 0.) { + w1 = 1.; + texCoord = vec2(texCoord.t, 1. - texCoord.s); + } else if (vertexNormal.z > 0.) { + w2 = 1.; + } else if (vertexNormal.x < 0.) { + w3 = 1.; + texCoord = vec2(1. - texCoord.t, 1. - texCoord.s); + } else if (vertexNormal.z < 0.) { + w4 = 1.; + texCoord = vec2(1. - texCoord.s, texCoord.t); + } + + gl_Position = mvp * vertexPosition; + } + " + + fragmentShaderCode: " + varying highp vec3 normal; + varying highp vec3 viewDirection; + varying highp vec2 texCoord; + varying highp float w1; + varying highp float w2; + varying highp float w3; + varying highp float w4; + + uniform samplerCube skyboxTexture; + uniform sampler2D tex1; + uniform sampler2D tex2; + uniform sampler2D tex3; + uniform sampler2D tex4; + + void main() + { + highp vec3 reflectedDirection = reflect(viewDirection, normalize(normal)); + highp vec4 color = w1 * texture2D(tex1, texCoord); + color += w2 * texture2D(tex2, texCoord); + color += w3 * texture2D(tex3, texCoord); + color += w4 * texture2D(tex4, texCoord); + highp float shininess = 0.6 - color.a * 0.5; + color += (1.0 - color.a) * vec4(0.2, 0.2, 0.2, 1.0); + gl_FragColor = vec4(mix(color.rgb, textureCube(skyboxTexture, reflectedDirection).rgb, shininess), 1.0); + } + " +} diff --git a/qml/EnvMappedWavyGLES2ShaderProgram.qml b/qml/EnvMappedWavyGLES2ShaderProgram.qml new file mode 100644 index 0000000..29028a3 --- /dev/null +++ b/qml/EnvMappedWavyGLES2ShaderProgram.qml @@ -0,0 +1,109 @@ +/**************************************************************************** +** +** Copyright (C) 2015 QUIt Coding Ltd. +** Contact: info@quitcoding.com +** +** This file is part of Cinematic 3D, a Qt3D demo application. +** +** $QT_BEGIN_LICENSE:BSD$ +** 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.Render 2.0 + +ShaderProgram { + vertexShaderCode: " + attribute highp vec4 vertexPosition; + attribute highp vec3 vertexNormal; + attribute highp vec2 vertexTexCoord; + + varying highp vec2 texCoord; + varying highp vec3 normal; + varying highp vec3 viewDirection; + varying highp float highlight; + varying highp float front; + + uniform highp mat4 mvp; + uniform highp mat4 inverseModelMatrix; + uniform highp mat4 modelMatrix; + uniform highp float wave; + uniform highp float waviness; + uniform highp vec3 cameraPosition; + + void main() + { + highp vec4 pos = vertexPosition; + highp vec3 v1 = pos.xyz; + v1.x += 0.0001; + v1.z += sin(v1.x*0.3 + wave) * waviness; + v1.z -= cos(v1.y*0.3 + wave) * waviness; + highp vec3 v2 = pos.xyz; + v2.y += 0.0001; + v2.z += sin(v2.x*0.3 + wave) * waviness; + v2.z -= cos(v2.y*0.3 + wave) * waviness; + pos.z += sin(pos.x*0.3 + wave) * waviness; + pos.z -= cos(pos.y*0.3 + wave) * waviness; + highlight = pos.z - 0.5; + highp vec3 n = cross(v1 - pos.xyz, v2 - pos.xyz); + normal = normalize(vec3(vec4(n, 0.0) * inverseModelMatrix)); + + front = max(0.0, vertexNormal.z); + if (vertexNormal.z <= 0.) + normal = (modelMatrix * vec4(vertexNormal, 0)).xyz; + + viewDirection = vec3(modelMatrix * pos) - cameraPosition; + + texCoord = vec2(vertexTexCoord.s, 1. - vertexTexCoord.t); + gl_Position = mvp * pos; + } + " + + fragmentShaderCode: " + varying highp vec3 normal; + varying highp vec3 viewDirection; + varying highp float highlight; + varying highp vec2 texCoord; + varying highp float front; + + uniform samplerCube skyboxTexture; + uniform sampler2D coverTexture; + + void main() + { + highp vec3 reflectedDirection = reflect(viewDirection, normalize(normal)); + highp vec4 color = front * texture2D(coverTexture, texCoord); + highp float shininess = 0.5 - front * 0.35; + gl_FragColor = vec4(mix(color.rgb, textureCube(skyboxTexture, reflectedDirection).rgb, shininess) + + highlight * vec3(0.2), 1.0); + } + " +} diff --git a/qml/FpsItem.qml b/qml/FpsItem.qml new file mode 100644 index 0000000..93543cc --- /dev/null +++ b/qml/FpsItem.qml @@ -0,0 +1,89 @@ +/**************************************************************************** +** +** Copyright (C) 2015 QUIt Coding Ltd. +** Contact: info@quitcoding.com +** +** This file is part of Cinematic 3D, a Qt3D demo application. +** +** $QT_BEGIN_LICENSE:BSD$ +** 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.4 + +Item { + id: root + property int frameCounter: 0 + property int fps: 0 + + width: 90 * dp + height: 30 * dp + opacity: 0.5 + + Image { + id: spinnerImage + anchors.verticalCenter: parent.verticalCenter + width: height + height: parent.height + source: "images/icons/rotation.png" + smooth: true + NumberAnimation on rotation { + from:0 + to: 360 + duration: 800 + loops: Animation.Infinite + } + onRotationChanged: root.frameCounter++; + } + + Text { + anchors.right: parent.right + anchors.verticalCenter: spinnerImage.verticalCenter + color: "#ffffff" + style: Text.Outline + styleColor: "#606060" + font.pixelSize: 18 * dp + text: root.fps + " fps" + } + + Timer { + interval: 2000 + repeat: true + running: true + onTriggered: { + // Very simple fps counter, checking how many times animation has been + // updated within interval seconds. + root.fps = root.frameCounter / (interval/1000); + root.frameCounter = 0; + } + } +} diff --git a/qml/IconButton.qml b/qml/IconButton.qml new file mode 100644 index 0000000..ada480e --- /dev/null +++ b/qml/IconButton.qml @@ -0,0 +1,76 @@ +/**************************************************************************** +** +** Copyright (C) 2015 QUIt Coding Ltd. +** Contact: info@quitcoding.com +** +** This file is part of Cinematic 3D, a Qt3D demo application. +** +** $QT_BEGIN_LICENSE:BSD$ +** 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.4 + +Item { + id: root + + property alias icon: iconImageItem.source + property bool isToggled: false + signal clicked + + implicitWidth: 80 * dp + implicitHeight: 80 * dp + + Image { + id: iconImageItem + anchors.fill: parent + fillMode: Image.PreserveAspectFit + smooth: true + opacity: mouseArea.pressed || isToggled ? 0.5 : 1.0 + Behavior on opacity { + NumberAnimation { duration: 64; easing.type: Easing.InOutQuad } + } + } + + Behavior on opacity { + NumberAnimation { duration: 400; easing.type: Easing.InOutQuad } + } + + MouseArea { + id: mouseArea + anchors.fill: parent + anchors.margins: -root.width*0.2 + onClicked: { + root.clicked(); + } + } +} diff --git a/qml/InfoView.qml b/qml/InfoView.qml new file mode 100644 index 0000000..aedca30 --- /dev/null +++ b/qml/InfoView.qml @@ -0,0 +1,317 @@ +/**************************************************************************** +** +** Copyright (C) 2015 QUIt Coding Ltd. +** Contact: info@quitcoding.com +** +** This file is part of Cinematic 3D, a Qt3D demo application. +** +** $QT_BEGIN_LICENSE:BSD$ +** 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.4 + +Item { + id: root + + property bool isOpen: false + + anchors.fill: parent + + function show() { + isOpen = true; + hideAnimation.stop(); + showAnimation.restart(); + } + function hide() { + isOpen = false; + showAnimation.stop(); + hideAnimation.restart(); + } + + ParallelAnimation { + id: showAnimation + NumberAnimation { target: backgroundItem; property: "opacity"; to: 1; duration: 250; easing.type: Easing.InOutQuad } + NumberAnimation { target: backgroundItem; property: "scale"; to: 1; duration: 500; easing.type: Easing.OutBack } + } + ParallelAnimation { + id: hideAnimation + NumberAnimation { target: backgroundItem; property: "opacity"; to: 0; duration: 500; easing.type: Easing.InOutQuad } + NumberAnimation { target: backgroundItem; property: "scale"; to: 0.6; duration: 500; easing.type: Easing.InOutQuad } + } + + MouseArea { + anchors.fill: parent + enabled: root.isOpen + onClicked: { + root.hide(); + } + } + + Item { + id: toolbar + anchors.right: parent.right + width: 200 * dp + height: 60 * dp + + Image { + id: infoButton + anchors.right: parent.right + anchors.rightMargin: -10 * dp + anchors.verticalCenter: parent.verticalCenter + width: 86 * dp + height: 86 * dp + fillMode: Image.PreserveAspectFit + smooth: true + source: "images/icons/info.png" + opacity: mouseArea.pressed || root.isOpen ? 1.0 : 0.5 + Behavior on opacity { + NumberAnimation { + duration: 200 + easing.type: Easing.InOutQuad + } + } + } + Image { + id: qtLogo + anchors.right: infoButton.left + anchors.rightMargin: -10 * dp + anchors.verticalCenter: parent.verticalCenter + width: 40 * dp + height: 40 * dp + fillMode: Image.PreserveAspectFit + smooth: true + source: "images/qt_logo_small.png" + opacity: 0.5 + } + Image { + id: quitLogo + anchors.right: qtLogo.left + anchors.verticalCenter: parent.verticalCenter + width: 100 * dp + height: 40 * dp + fillMode: Image.PreserveAspectFit + smooth: true + source: "images/quit_logo_small.png" + opacity: 0.5 + } + + MouseArea { + id: mouseArea + anchors.fill: parent + onClicked: { + if (root.isOpen) { + root.hide(); + } else { + root.show(); + } + } + } + } + + BorderImage { + id: backgroundItem + anchors.right: parent.right + anchors.rightMargin: 25 * dp + anchors.top: toolbar.verticalCenter + anchors.topMargin: 10 * dp + width: 440 * dp + height: root.height - 80 * dp + source: "images/panel2_bg.png" + border.right : 22 + border.left : 10 + border.bottom : 5 + border.top : 26 + transformOrigin: Item.TopRight + visible: opacity + opacity: 0 + scale: 0.6 + + Flickable { + id: flickableArea + anchors.fill: parent + anchors.topMargin: backgroundItem.border.top + anchors.bottomMargin:backgroundItem.border.bottom + contentHeight: infoContentItem.height + contentWidth: width + clip: true + Column { + id: infoContentItem + // Comes from BorderImage + margin + width: parent.width - 20 - 20 * dp + anchors.horizontalCenter: parent.horizontalCenter + anchors.horizontalCenterOffset: 2 + spacing: 30 * dp + Item { + width: 1 + height: 40 * dp + } + Text { + anchors.horizontalCenter: parent.horizontalCenter + font.pixelSize: 30 * dp + style: Text.Outline + font.bold: true + color: "#e0e0e0" + styleColor: "#202020" + text: qsTr("Cinematic 3D") + } + Text { + width: parent.width + wrapMode: Text.WordWrap + font.pixelSize: 24 * dp + style: Text.Outline + color: "#e0e0e0" + styleColor: "#202020" + textFormat: Text.StyledText + text: qsTr("This application is built using Qt - the cross-platform application and UI framework. It shows the 3D UI capabilities introduced with Qt 5.5.<br><br>The implementation highlights the new Qt 3D module, together with the Qt Quick and the Qt Multimedia modules.") + } + Image { + width: parent.width + height: width * 0.5 + fillMode: Image.PreserveAspectCrop + source: "images/info_sc1.png" + smooth: true + Rectangle { + anchors.fill: parent + anchors.margins: -1 + z: -1 + color: "#808080" + } + } + Text { + width: parent.width + wrapMode: Text.WordWrap + font.pixelSize: 24 * dp + style: Text.Outline + color: "#e0e0e0" + styleColor: "#202020" + textFormat: Text.StyledText + text: qsTr("<b>Qt 3D</b> is a new addition included as a technology preview in Qt 5.5 which allows binging true 3D elements into UIs built with Qt Quick. Qt 3D offers both QML and C++ APIs. In this demo Qt 3D is used for the skybox background and for some elements of video details view. Qt 3D also supports property animations which are used for implementing the transition effects.") + } + Image { + width: parent.width + height: width * 0.5 + fillMode: Image.PreserveAspectCrop + source: "images/info_sc2.png" + smooth: true + Rectangle { + anchors.fill: parent + anchors.margins: -1 + z: -1 + color: "#808080" + } + } + Text { + width: parent.width + wrapMode: Text.WordWrap + font.pixelSize: 24 * dp + style: Text.Outline + color: "#e0e0e0" + styleColor: "#202020" + textFormat: Text.StyledText + text: qsTr("<b>Qt Quick</b> is used to create the actual UI and all the interactions. The carousel is implemented with Qt Quick by blending it using a ShaderEffect with 3D elements. Qt Quick is powered by the Qt Quick Engine that has been optimized and improved with Qt 5.5. This demo has no custom C++ code, but everything has been implemented using QML and JavaScript.") + } + Image { + width: parent.width + height: width * 0.5 + fillMode: Image.PreserveAspectCrop + source: "images/info_sc3.png" + smooth: true + Rectangle { + anchors.fill: parent + anchors.margins: -1 + z: -1 + color: "#808080" + } + } + Text { + width: parent.width + wrapMode: Text.WordWrap + font.pixelSize: 24 * dp + style: Text.Outline + color: "#e0e0e0" + styleColor: "#202020" + textFormat: Text.StyledText + text: qsTr("<b>Qt Multimedia</b> handles the playback of the videos.") + } + Image { + anchors.horizontalCenter: parent.horizontalCenter + width: parent.width * 0.6 + height: width * 0.3 + fillMode: Image.PreserveAspectFit + source: "images/info_sc4.png" + smooth: true + } + Text { + width: parent.width + wrapMode: Text.WordWrap + font.pixelSize: 14 * dp + style: Text.Outline + color: "#e0e0e0" + styleColor: "#202020" + textFormat: Text.StyledText + horizontalAlignment: Text.AlignHCenter + text: qsTr("This demo is built in co-operation between<br><b>QUIt Coding</b> and <b>The Qt Company</b>.<br><br>Enjoy the power of Qt 5.5!<br><br>Try it out, or learn more, visit <i>http://www.qt.io</i>") + } + Item { + width: 1 + height: 40 * dp + } + } + } + + // Smoothly clip top & bottom of flickable content + ShaderEffectSource { + id: flickableAreaSource + sourceItem: flickableArea + hideSource: true + visible: false + } + ShaderEffect { + property variant src: flickableAreaSource + + anchors.fill: flickableArea + + fragmentShader: " + varying highp vec2 qt_TexCoord0; + uniform lowp float qt_Opacity; + uniform sampler2D src; + void main() { + lowp vec4 tex = texture2D(src, qt_TexCoord0); + lowp float dist = abs(qt_TexCoord0.y-0.5)*4.0; + tex*= min(1.0, (2.0 - dist)); + gl_FragColor = tex * qt_Opacity; + }" + } + } +} + diff --git a/qml/MipMappedTexture2D.qml b/qml/MipMappedTexture2D.qml new file mode 100644 index 0000000..d4eabc3 --- /dev/null +++ b/qml/MipMappedTexture2D.qml @@ -0,0 +1,58 @@ +/**************************************************************************** +** +** Copyright (C) 2015 QUIt Coding Ltd. +** Contact: info@quitcoding.com +** +** This file is part of Cinematic 3D, a Qt3D demo application. +** +** $QT_BEGIN_LICENSE:BSD$ +** 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 + +Texture2D { + property alias source: image.source + + minificationFilter: Texture.LinearMipMapLinear + magnificationFilter: Texture.Linear + generateMipMaps: true + wrapMode { + x: WrapMode.ClampToEdge + y: WrapMode.ClampToEdge + } + + TextureImage { + id: image + } +} diff --git a/qml/PlayerView.qml b/qml/PlayerView.qml new file mode 100644 index 0000000..ed67a2d --- /dev/null +++ b/qml/PlayerView.qml @@ -0,0 +1,266 @@ +/**************************************************************************** +** +** Copyright (C) 2015 QUIt Coding Ltd. +** Contact: info@quitcoding.com +** +** This file is part of Cinematic 3D, a Qt3D demo application. +** +** $QT_BEGIN_LICENSE:BSD$ +** 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.4 +import QtMultimedia 5.5 + +Rectangle { + id: root + + // The directory of videos + // Note: videoPath is defined in main.cpp + property string videosDir: videoPath + // The video which is currently loaded + property string playingVideo: videosDir + videoFile + // TODO: Will provided videos require zoomed mode or not to fit the screen? + property bool videoZoomed: false + // How long (in ms) the controls are visible + property int controlsHideTime: 4000 + // How much (in ms) the forward & rewind buttons seek + property int seekAmount: 2500 + + function restartHideTimer() { + root.state = "controlsVisible"; + hideControlsTimer.restart(); + } + + function mediaStatusToString(status) { + switch (status) { + case MediaPlayer.NoMedia: + return "NoMedia"; + case MediaPlayer.Loading: + return "Loading"; + case MediaPlayer.Loaded: + return "Loaded"; + case MediaPlayer.Buffering: + return "Buffering"; + case MediaPlayer.Stalled: + return "Stalled"; + case MediaPlayer.Buffered: + return "Buffered"; + case MediaPlayer.EndOfMedia: + return "EndOfMedia"; + case MediaPlayer.InvalidMedia: + return "InvalidMedia"; + case MediaPlayer.UnknownStatus: + return "UnknownStatus"; + default: + return "???" + } + } + + function msToTimeString(ms) { + var totalSec = Math.floor(ms / 1000); + var min = Math.floor(totalSec / 60); + var sec = totalSec - min*60; + if (min <= 9) min = "0" + min; + if (sec <= 9) sec = "0" + sec; + return min + ":" + sec; + } + + onVisibleChanged: { + if (visible) { + state = "controlsVisible"; + hideControlsTimer.restart(); + video.play(); + } else { + if (videoFile != "") { + video.stop(); + } + } + } + + anchors.fill: parent + color: "#000000" + + states: [ + State { + name: "controlsVisible" + PropertyChanges { target: topBar; opacity: 0.8 } + PropertyChanges { target: bottomBar; anchors.bottomMargin: 0; opacity: 0.8 } + } + ] + + transitions: [ + Transition { + PropertyAnimation { + targets: [topBar, bottomBar] + properties: "anchors.topMargin, anchors.bottomMargin, opacity" + easing.type: Easing.InOutQuad + duration: 500 + } + } + ] + + Timer { + id: hideControlsTimer + interval: root.controlsHideTime + running: true + onTriggered: { + root.state = ""; + } + } + + Video { + id: video + property string statusString + property string playbackStateString + + anchors.fill: parent + fillMode: videoZoomed ? VideoOutput.PreserveAspectCrop : VideoOutput.PreserveAspectFit + source: playingVideo != videosDir ? playingVideo : "" + autoPlay: true + onStatusChanged: { + console.debug("playingVideo: " + playingVideo); + playbackStateString = mediaStatusToString(status); + console.debug("video status: " + playbackStateString); + if (status == MediaPlayer.EndOfMedia) { + hideVideo.start(); + } + } + } + + MouseArea { + anchors.fill: parent + onClicked: { + restartHideTimer(); + } + } + + Item { + id: topBar + width: parent.width + height: parent.height * 0.15 + anchors.top: parent.top + opacity: 0 + visible: opacity + // top-left back button + IconButton { + id: backButton + anchors.left: parent.left + anchors.leftMargin: 20 * dp + anchors.top: parent.top + anchors.topMargin: 20 * dp + icon: "images/icons/back.png" + onClicked: { + video.pause(); + hideVideo.start(); + } + } + } + + Rectangle { + id: bottomBar + width: parent.width * 0.6 + height: parent.height * 0.24 + anchors.horizontalCenter: parent.horizontalCenter + anchors.bottom: parent.bottom + anchors.bottomMargin: -height + color: "#202020" + opacity: 0 + visible: opacity + // Control buttons row + Row { + anchors.horizontalCenter: parent.horizontalCenter + anchors.verticalCenter: parent.verticalCenter + anchors.verticalCenterOffset: 10 * dp + height: 80 * dp + spacing: 30 + IconButton { + anchors.verticalCenter: parent.verticalCenter + icon: "images/icons/rewind.png" + onClicked: { + restartHideTimer(); + video.seek(video.position - seekAmount); + } + } + IconButton { + anchors.verticalCenter: parent.verticalCenter + icon: video.playbackState === MediaPlayer.PlayingState ? "images/icons/pause.png" : "images/icons/play.png" + onClicked: { + restartHideTimer(); + if (video.playbackState === MediaPlayer.PlayingState) { + video.pause(); + } else { + video.play(); + } + } + } + IconButton { + anchors.verticalCenter: parent.verticalCenter + icon: "images/icons/fastforward.png" + onClicked: { + restartHideTimer(); + video.seek(Math.min(video.duration, video.position + seekAmount)); + } + } + } + + // Video duration bar + Rectangle { + anchors.top: parent.top + width: parent.width + height: 2 + color: "#606060" + Rectangle { + anchors.verticalCenter: parent.verticalCenter + width: (parent.width) * (video.position / video.duration) + height: 8 * dp + color: "#909090" + Rectangle { + anchors.left: parent.right + anchors.verticalCenter: parent.verticalCenter + width: 2 * dp + height: parent.height + color: "#ffffff" + } + } + } + + Text { + anchors.horizontalCenter: parent.horizontalCenter + anchors.top: parent.top + anchors.topMargin: 10 * dp + font.pixelSize: 20 * dp + color: "#d0d0d0" + text: msToTimeString(video.position) + " / " + msToTimeString(video.duration) + } + } +} diff --git a/qml/SettingsView.qml b/qml/SettingsView.qml new file mode 100644 index 0000000..b5d97d4 --- /dev/null +++ b/qml/SettingsView.qml @@ -0,0 +1,173 @@ +/**************************************************************************** +** +** Copyright (C) 2015 QUIt Coding Ltd. +** Contact: info@quitcoding.com +** +** This file is part of Cinematic 3D, a Qt3D demo application. +** +** $QT_BEGIN_LICENSE:BSD$ +** 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.4 + +Item { + id: root + + property bool isOpen: false + + function show() { + isOpen = true; + hideAnimation.stop(); + showAnimation.restart(); + } + function hide() { + isOpen = false; + showAnimation.stop(); + hideAnimation.restart(); + } + + anchors.fill: parent + + ParallelAnimation { + id: showAnimation + NumberAnimation { target: backgroundItem; property: "opacity"; to: 1; duration: 250; easing.type: Easing.InOutQuad } + NumberAnimation { target: backgroundItem; property: "scale"; to: 1; duration: 500; easing.type: Easing.OutBack } + } + ParallelAnimation { + id: hideAnimation + NumberAnimation { target: backgroundItem; property: "opacity"; to: 0; duration: 500; easing.type: Easing.InOutQuad } + NumberAnimation { target: backgroundItem; property: "scale"; to: 0.6; duration: 500; easing.type: Easing.InOutQuad } + } + + MouseArea { + anchors.fill: parent + enabled: root.isOpen + onClicked: { + root.hide(); + } + } + + IconButton { + id: settingsIcon + anchors.left: parent.left + anchors.bottom: parent.bottom + icon: "images/icons/settings.png" + opacity: 0.5 + onClicked: { + if (root.isOpen) { + root.hide(); + } else { + root.show(); + } + } + } + + BorderImage { + id: backgroundItem + anchors.left: settingsIcon.horizontalCenter + anchors.bottom: settingsIcon.verticalCenter + width: 340 * dp + height: settingsContentColumn.height + 36 + source: "images/panel_bg.png" + border.left : 22 + border.right : 10 + border.top : 5 + border.bottom : 26 + + transformOrigin: Item.BottomLeft + visible: opacity + opacity: 0 + scale: 0.6 + + Column { + id: settingsContentColumn + width: parent.width + y: 8 + Switch { + text: qsTr("Carousel Transparency") + checked: settings.showCarouselOpacity + onCheckedChanged: { + settings.showCarouselOpacity = checked; + } + } + Rectangle { + anchors.horizontalCenter: parent.horizontalCenter + width: parent.width - 48 * dp + height: 1 + color: "#808080" + } + Switch { + text: qsTr("3D Reflections") + checked: settings.show3DReflections + onCheckedChanged: { + settings.show3DReflections = checked; + } + } + Rectangle { + anchors.horizontalCenter: parent.horizontalCenter + width: parent.width - 48 * dp + height: 1 + color: "#808080" + } + Switch { + text: qsTr("3D Background") + textOff: qsTr("SKY") + textOn: qsTr("STARS") + checked: settings.starsBackground + onCheckedChanged: { + settings.starsBackground = checked; + } + } + Rectangle { + anchors.horizontalCenter: parent.horizontalCenter + width: parent.width - 48 * dp + height: 1 + color: "#808080" + } + Switch { + text: qsTr("Slow Transitions") + checked: settings.slowAnimations + onCheckedChanged: { + settings.slowAnimations = checked; + } + } + Switch { + text: qsTr("Show fps") + checked: settings.showFps + onCheckedChanged: { + settings.showFps = checked; + } + } + } + } +} diff --git a/qml/Sphere3D.qml b/qml/Sphere3D.qml new file mode 100644 index 0000000..f5a89a3 --- /dev/null +++ b/qml/Sphere3D.qml @@ -0,0 +1,199 @@ +/**************************************************************************** +** +** Copyright (C) 2015 QUIt Coding Ltd. +** Contact: info@quitcoding.com +** +** This file is part of Cinematic 3D, a Qt3D demo application. +** +** $QT_BEGIN_LICENSE:BSD$ +** 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 + +Entity { + id: entity + + property bool visible: true + property matrix4x4 cameraMatrix + property real size: 10 + property TextureCubeMap cubemapTexture + property url surface + property vector3d cameraPosition + property bool envMapping: true + + ShaderProgram { + id: simpleShader + + vertexShaderCode: " + attribute highp vec4 vertexPosition; + attribute highp vec2 vertexTexCoord; + + varying highp vec2 texCoord; + + uniform highp mat4 mvp; + + void main() + { + texCoord = vertexTexCoord; + gl_Position = mvp * vertexPosition; + } + " + + fragmentShaderCode: " + varying highp vec2 texCoord; + + uniform sampler2D surfaceTexture; + + void main() + { + highp vec4 surface = texture2D(surfaceTexture, texCoord); + gl_FragColor = vec4(surface.rgb * 0.8, 1.0); + } + " + } + + ShaderProgram { + id: envMappedShader + + vertexShaderCode: " + attribute highp vec4 vertexPosition; + attribute highp vec3 vertexNormal; + attribute highp vec2 vertexTexCoord; + + varying highp vec2 texCoord; + varying highp vec3 normal; + varying highp vec3 viewDirection; + + uniform highp mat4 mvp; + uniform highp mat4 modelMatrix; + uniform highp vec3 cameraPosition; + + void main() + { + normal = (modelMatrix * vec4(vertexNormal, 0)).xyz; + viewDirection = vec3(modelMatrix * vertexPosition) - cameraPosition; + texCoord = vertexTexCoord; + gl_Position = mvp * vertexPosition; + } + " + + fragmentShaderCode: " + varying highp vec3 normal; + varying highp vec3 viewDirection; + varying highp vec2 texCoord; + + uniform samplerCube skyboxTexture; + uniform sampler2D surfaceTexture; + + void main() + { + highp vec4 surface = texture2D(surfaceTexture, texCoord); + highp vec3 reflectedDirection = reflect(viewDirection, normalize(normal)); + gl_FragColor = vec4(0.6 * textureCube(skyboxTexture, reflectedDirection).rgb + surface.rgb * 0.7, 1.0); + } + " + } + + Material { + id: material + + effect: Effect { + id: fx + + Parameter { id: cubemapParam; name: "skyboxTexture"; value: cubemapTexture } + Parameter { id: surfacetexParam; name: "surfaceTexture"; value: MipMappedTexture2D { source: surface } } + Parameter { id: cameraPositionParam; name: "cameraPosition"; value: cameraPosition } + + parameters: [cubemapParam, surfacetexParam, cameraPositionParam] + + techniques: [ + Technique { + graphicsApiFilter { + api: GraphicsApiFilter.OpenGL + profile: GraphicsApiFilter.NoProfile + majorVersion: 2 + minorVersion: 0 + } + + renderPasses: RenderPass { + renderStates: [ + CullFace { mode: CullFace.Back }, + DepthTest { depthFunction: DepthTest.LessOrEqual } + ] + + shaderProgram: envMapping ? envMappedShader : simpleShader + } + }, + Technique { + graphicsApiFilter { + api: GraphicsApiFilter.OpenGLES + profile: GraphicsApiFilter.NoProfile + majorVersion: 2 + minorVersion: 0 + } + + renderPasses: RenderPass { + renderStates: [ + CullFace { mode: CullFace.Back }, + DepthTest { depthFunction: DepthTest.LessOrEqual } + ] + + shaderProgram: envMapping ? envMappedShader : simpleShader + } + } + ] + } + } + + Transform { + id: modelTransform + property real xShift: (105.5 + size) - 105 * showVideoTransitionState + matrix: { + var m = cameraMatrix.inverted(); + m.translate(Qt.vector3d(viewingVideo ? -xShift : xShift, + 0.0, + viewingVideo ? 50 : -50)); + return m; + } + } + + SphereMesh { + id: mesh + radius: size + slices: 32 + rings: 32 + } + + components: visible ? [modelTransform, mesh, material] : [] +} diff --git a/qml/Switch.qml b/qml/Switch.qml new file mode 100644 index 0000000..bd47358 --- /dev/null +++ b/qml/Switch.qml @@ -0,0 +1,186 @@ +/**************************************************************************** +** +** Copyright (C) 2015 QUIt Coding Ltd. +** Contact: info@quitcoding.com +** +** This file is part of Cinematic 3D, a Qt3D demo application. +** +** $QT_BEGIN_LICENSE:BSD$ +** 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.4 + +Item { + id: root + + property alias text: textItem.text + property bool checked: false + property string textOn: qsTr("ON") + property string textOff: qsTr("OFF") + + QtObject { + id: priv + property real switchWidth: 86 * dp + property real barHeight: 25 * dp + property real knobMovement: switchWidth - knobSize + 2 + property real knobSize: 32 * dp + property real knobState: knob.x / knobMovement + + function releaseSwitch() { + // Don't switch if we are already in that side + if ((knob.x == -2 && !checked) || (knob.x == priv.knobMovement && checked)) { + return; + } + checked = !checked; + } + } + + width: parent ? parent.width : 200 * dp + height: 64 * dp + + MouseArea { + width: parent.width + height: parent.height + onClicked: { + root.checked = !root.checked; + } + } + + Text { + id: textItem + anchors.verticalCenter: parent.verticalCenter + anchors.left: parent.left + anchors.leftMargin: 22 * dp + anchors.right: switchBackgroundImage.left + anchors.rightMargin: 8 * dp + wrapMode: Text.WordWrap + font.pixelSize: 20 * dp + color: "#ffffff" + } + + Rectangle { + id: switchBackgroundImage + anchors.verticalCenter: parent.verticalCenter + anchors.right: parent.right + anchors.rightMargin: 32 * dp + height: priv.barHeight + width: priv.switchWidth + radius: height/2 + color: "#404040" + } + Rectangle { + id: switchFrameImage + anchors.verticalCenter: parent.verticalCenter + anchors.right: parent.right + anchors.rightMargin: 32 * dp + height: priv.barHeight + width: priv.switchWidth + radius: height/2 + color: "transparent" + border.width: 1 * dp + border.color: "#808080" + z: 2 + } + + Item { + id: switchItem + anchors.fill: switchBackgroundImage + + Text { + anchors.verticalCenter: parent.verticalCenter + anchors.right: knob.left + anchors.rightMargin: (priv.switchWidth - priv.knobSize - paintedWidth) / 2 + color: "#ffffff" + font.pixelSize: 12 * dp + text: textOn + } + Text { + anchors.verticalCenter: parent.verticalCenter + anchors.left: knob.right + anchors.leftMargin: (priv.switchWidth - priv.knobSize - paintedWidth - 6*dp) / 2 + color: "#808080" + font.pixelSize: 12 * dp + text: textOff + } + + Item { + id: knob + anchors.verticalCenter: parent.verticalCenter + height: priv.knobSize + width: height + x: checked ? priv.knobMovement : -2 + MouseArea { + anchors.fill: parent + drag.target: knob; drag.axis: Drag.XAxis; drag.minimumX: -2; drag.maximumX: priv.knobMovement + onClicked: checked = !checked; + onReleased: priv.releaseSwitch(); + } + Behavior on x { + NumberAnimation { duration: 250; easing.type: Easing.InOutQuad } + } + } + } + + Rectangle { + id: knobVisual + property real colorValue: 0.6 + priv.knobState*0.4 + anchors.verticalCenter: parent.verticalCenter + height: priv.knobSize + width: height + x: switchBackgroundImage.x + knob.x + z: 10 + radius: height/2 + color: Qt.rgba(colorValue, colorValue, colorValue, 1.0) + border.width: 1 * dp + border.color: "#404040" + } + + // Mask out switch parts which should be hidden + ShaderEffect { + id: shaderItem + property variant source: ShaderEffectSource { sourceItem: switchItem; hideSource: true } + property variant maskSource: ShaderEffectSource { sourceItem: switchBackgroundImage; hideSource: false } + + anchors.fill: switchBackgroundImage + + fragmentShader: " + varying highp vec2 qt_TexCoord0; + uniform highp float qt_Opacity; + uniform sampler2D source; + uniform sampler2D maskSource; + void main(void) { + gl_FragColor = texture2D(source, qt_TexCoord0.st) * (texture2D(maskSource, qt_TexCoord0.st).a) * qt_Opacity; + } + " + } +} diff --git a/qml/TextureBox3D.qml b/qml/TextureBox3D.qml new file mode 100644 index 0000000..9440813 --- /dev/null +++ b/qml/TextureBox3D.qml @@ -0,0 +1,155 @@ +/**************************************************************************** +** +** Copyright (C) 2015 QUIt Coding Ltd. +** Contact: info@quitcoding.com +** +** This file is part of Cinematic 3D, a Qt3D demo application. +** +** $QT_BEGIN_LICENSE:BSD$ +** 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 QtQuick 2.4 as QQ2 + +Entity { + id: entity + + property real showDetailsTransitionState: 0.0 + property url coverImage1 + property url coverImage2 + property url coverImage3 + property url coverImage4 + property bool visible: true + property matrix4x4 cameraMatrix + property TextureCubeMap cubemapTexture + property real size: 1 + property vector3d cameraPosition + property bool envMapping: true + + EnvMappedBoxGLES2ShaderProgram { + id: envMappedBoxShaderProgram + } + + TexturedBoxGLES2ShaderProgram { + id: texturedBoxShaderProgram + } + + Material { + id: material + + effect: Effect { + id: fx + + Parameter { id: p1; name: "skyboxTexture"; value: cubemapTexture } + Parameter { id: ptex1; name: "tex1"; value: MipMappedTexture2D { source: coverImage1 } } + Parameter { id: ptex2; name: "tex2"; value: MipMappedTexture2D { source: coverImage2 } } + Parameter { id: ptex3; name: "tex3"; value: MipMappedTexture2D { source: coverImage3 } } + Parameter { id: ptex4; name: "tex4"; value: MipMappedTexture2D { source: coverImage4 } } + Parameter { id: cameraPositionParam; name: "cameraPosition"; value: cameraPosition } + + parameters: [p1, ptex1, ptex2, ptex3, ptex4, cameraPositionParam] + + techniques: [ + Technique { + graphicsApiFilter { + api: GraphicsApiFilter.OpenGL + profile: GraphicsApiFilter.NoProfile + majorVersion: 2 + minorVersion: 0 + } + + renderPasses: RenderPass { + renderStates: [ + CullFace { mode: CullFace.Back }, + DepthTest { depthFunction: DepthTest.LessOrEqual } + ] + + shaderProgram: envMapping ? envMappedBoxShaderProgram : texturedBoxShaderProgram + } + }, + Technique { + graphicsApiFilter { + api: GraphicsApiFilter.OpenGLES + profile: GraphicsApiFilter.NoProfile + majorVersion: 2 + minorVersion: 0 + } + + renderPasses: RenderPass { + renderStates: [ + CullFace { mode: CullFace.Back }, + DepthTest { depthFunction: DepthTest.LessOrEqual } + ] + + shaderProgram: envMapping ? envMappedBoxShaderProgram : texturedBoxShaderProgram + } + } + ] + } + } + + Transform { + id: modelTransform + + property real angle: 0 + QQ2.NumberAnimation on angle { + from: 0 + to: 360 + loops: QQ2.Animation.Infinite + duration: 8000 + running: true + } + matrix: { + var m = cameraMatrix.inverted(); + m.translate(Qt.vector3d(6, + -4 - (1.0 - showDetailsTransitionState) * 10, + -20 * showDetailsTransitionState)); + m.rotate(modelTransform.angle, Qt.vector3d(0, 1, 0)); + m.rotate(15, Qt.vector3d(0, 0, 1)); + return m; + } + } + + CuboidMesh { + id: mesh + xExtent: size + yExtent: 0.5625 * size + zExtent: size + yzMeshResolution: Qt.size(2, 2) + xzMeshResolution: Qt.size(2, 2) + xyMeshResolution: Qt.size(2, 2) + } + + components: visible ? [modelTransform, mesh, material] : [] +} diff --git a/qml/TexturedBoxGLES2ShaderProgram.qml b/qml/TexturedBoxGLES2ShaderProgram.qml new file mode 100644 index 0000000..e7035c5 --- /dev/null +++ b/qml/TexturedBoxGLES2ShaderProgram.qml @@ -0,0 +1,101 @@ +/**************************************************************************** +** +** Copyright (C) 2015 QUIt Coding Ltd. +** Contact: info@quitcoding.com +** +** This file is part of Cinematic 3D, a Qt3D demo application. +** +** $QT_BEGIN_LICENSE:BSD$ +** 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.Render 2.0 + +ShaderProgram { + vertexShaderCode: " + attribute highp vec4 vertexPosition; + attribute highp vec3 vertexNormal; + attribute highp vec2 vertexTexCoord; + + varying highp vec2 texCoord; + varying highp float w1; + varying highp float w2; + varying highp float w3; + varying highp float w4; + + uniform highp mat4 mvp; + + void main() + { + texCoord = vec2(vertexTexCoord.s, 1. - vertexTexCoord.t); + + w1 = w2 = w3 = w4 = 0.; + if (vertexNormal.x > 0.) { + w1 = 1.; + texCoord = vec2(texCoord.t, 1. - texCoord.s); + } else if (vertexNormal.z > 0.) { + w2 = 1.; + } else if (vertexNormal.x < 0.) { + w3 = 1.; + texCoord = vec2(1. - texCoord.t, 1. - texCoord.s); + } else if (vertexNormal.z < 0.) { + w4 = 1.; + texCoord = vec2(1. - texCoord.s, texCoord.t); + } + + gl_Position = mvp * vertexPosition; + } + " + + fragmentShaderCode: " + varying highp vec2 texCoord; + varying highp float w1; + varying highp float w2; + varying highp float w3; + varying highp float w4; + + uniform sampler2D tex1; + uniform sampler2D tex2; + uniform sampler2D tex3; + uniform sampler2D tex4; + + void main() + { + highp vec4 color = w1 * texture2D(tex1, texCoord); + color += w2 * texture2D(tex2, texCoord); + color += w3 * texture2D(tex3, texCoord); + color += w4 * texture2D(tex4, texCoord); + color += (1.0 - color.a) * vec4(0.3, 0.3, 0.3, 1.0); + gl_FragColor = color; + } + " +} diff --git a/qml/TexturedWavyShaderProgram.qml b/qml/TexturedWavyShaderProgram.qml new file mode 100644 index 0000000..a741c44 --- /dev/null +++ b/qml/TexturedWavyShaderProgram.qml @@ -0,0 +1,79 @@ +/**************************************************************************** +** +** Copyright (C) 2015 QUIt Coding Ltd. +** Contact: info@quitcoding.com +** +** This file is part of Cinematic 3D, a Qt3D demo application. +** +** $QT_BEGIN_LICENSE:BSD$ +** 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.Render 2.0 + +ShaderProgram { + vertexShaderCode: " + attribute highp vec4 vertexPosition; + attribute highp vec3 vertexNormal; + attribute highp vec2 vertexTexCoord; + + varying highp vec2 texCoord; + varying highp float front; + + uniform highp mat4 mvp; + uniform highp float wave; + uniform highp float waviness; + + void main() + { + highp vec4 pos = vertexPosition; + pos.z += sin(pos.x*0.3 + wave) * waviness; + pos.z -= cos(pos.y*0.3 + wave) * waviness; + front = step(0.0, vertexNormal.z); + texCoord = vec2(vertexTexCoord.s, 1. - vertexTexCoord.t); + gl_Position = mvp * pos; + } + " + + fragmentShaderCode: " + varying highp vec2 texCoord; + varying highp float front; + + uniform sampler2D coverTexture; + + void main() + { + highp vec4 color = front * texture2D(coverTexture, texCoord); + gl_FragColor = vec4(color.rgb, 1.0); + } + " +} diff --git a/qml/images/covers/3D_Planets.jpg b/qml/images/covers/3D_Planets.jpg Binary files differnew file mode 100644 index 0000000..7eed7ab --- /dev/null +++ b/qml/images/covers/3D_Planets.jpg diff --git a/qml/images/covers/Bluescape.jpg b/qml/images/covers/Bluescape.jpg Binary files differnew file mode 100644 index 0000000..0b12812 --- /dev/null +++ b/qml/images/covers/Bluescape.jpg diff --git a/qml/images/covers/Build_Your_World.jpg b/qml/images/covers/Build_Your_World.jpg Binary files differnew file mode 100644 index 0000000..67273ef --- /dev/null +++ b/qml/images/covers/Build_Your_World.jpg diff --git a/qml/images/covers/IoT.jpg b/qml/images/covers/IoT.jpg Binary files differnew file mode 100644 index 0000000..3ba393c --- /dev/null +++ b/qml/images/covers/IoT.jpg diff --git a/qml/images/covers/Meet_Qt_Creator.jpg b/qml/images/covers/Meet_Qt_Creator.jpg Binary files differnew file mode 100644 index 0000000..6b7e865 --- /dev/null +++ b/qml/images/covers/Meet_Qt_Creator.jpg diff --git a/qml/images/cubemaps/miramar/miramar_negx.webp b/qml/images/cubemaps/miramar/miramar_negx.webp Binary files differnew file mode 100644 index 0000000..1ea719f --- /dev/null +++ b/qml/images/cubemaps/miramar/miramar_negx.webp diff --git a/qml/images/cubemaps/miramar/miramar_negy.webp b/qml/images/cubemaps/miramar/miramar_negy.webp Binary files differnew file mode 100644 index 0000000..5329f6a --- /dev/null +++ b/qml/images/cubemaps/miramar/miramar_negy.webp diff --git a/qml/images/cubemaps/miramar/miramar_negz.webp b/qml/images/cubemaps/miramar/miramar_negz.webp Binary files differnew file mode 100644 index 0000000..2bae546 --- /dev/null +++ b/qml/images/cubemaps/miramar/miramar_negz.webp diff --git a/qml/images/cubemaps/miramar/miramar_posx.webp b/qml/images/cubemaps/miramar/miramar_posx.webp Binary files differnew file mode 100644 index 0000000..ec33d1e --- /dev/null +++ b/qml/images/cubemaps/miramar/miramar_posx.webp diff --git a/qml/images/cubemaps/miramar/miramar_posy.webp b/qml/images/cubemaps/miramar/miramar_posy.webp Binary files differnew file mode 100644 index 0000000..6d36fcb --- /dev/null +++ b/qml/images/cubemaps/miramar/miramar_posy.webp diff --git a/qml/images/cubemaps/miramar/miramar_posz.webp b/qml/images/cubemaps/miramar/miramar_posz.webp Binary files differnew file mode 100644 index 0000000..327041c --- /dev/null +++ b/qml/images/cubemaps/miramar/miramar_posz.webp diff --git a/qml/images/cubemaps/space/space_negx.png b/qml/images/cubemaps/space/space_negx.png Binary files differnew file mode 100644 index 0000000..772d4de --- /dev/null +++ b/qml/images/cubemaps/space/space_negx.png diff --git a/qml/images/cubemaps/space/space_negy.png b/qml/images/cubemaps/space/space_negy.png Binary files differnew file mode 100644 index 0000000..0abd703 --- /dev/null +++ b/qml/images/cubemaps/space/space_negy.png diff --git a/qml/images/cubemaps/space/space_negz.png b/qml/images/cubemaps/space/space_negz.png Binary files differnew file mode 100644 index 0000000..e49670a --- /dev/null +++ b/qml/images/cubemaps/space/space_negz.png diff --git a/qml/images/cubemaps/space/space_posx.png b/qml/images/cubemaps/space/space_posx.png Binary files differnew file mode 100644 index 0000000..b7e14c1 --- /dev/null +++ b/qml/images/cubemaps/space/space_posx.png diff --git a/qml/images/cubemaps/space/space_posy.png b/qml/images/cubemaps/space/space_posy.png Binary files differnew file mode 100644 index 0000000..d69df9a --- /dev/null +++ b/qml/images/cubemaps/space/space_posy.png diff --git a/qml/images/cubemaps/space/space_posz.png b/qml/images/cubemaps/space/space_posz.png Binary files differnew file mode 100644 index 0000000..a2dc3ae --- /dev/null +++ b/qml/images/cubemaps/space/space_posz.png diff --git a/qml/images/icons/back.png b/qml/images/icons/back.png Binary files differnew file mode 100644 index 0000000..e0bcc7d --- /dev/null +++ b/qml/images/icons/back.png diff --git a/qml/images/icons/fastforward.png b/qml/images/icons/fastforward.png Binary files differnew file mode 100644 index 0000000..533588a --- /dev/null +++ b/qml/images/icons/fastforward.png diff --git a/qml/images/icons/info.png b/qml/images/icons/info.png Binary files differnew file mode 100644 index 0000000..e43ac27 --- /dev/null +++ b/qml/images/icons/info.png diff --git a/qml/images/icons/pause.png b/qml/images/icons/pause.png Binary files differnew file mode 100644 index 0000000..5db2ab3 --- /dev/null +++ b/qml/images/icons/pause.png diff --git a/qml/images/icons/play.png b/qml/images/icons/play.png Binary files differnew file mode 100644 index 0000000..bb5731d --- /dev/null +++ b/qml/images/icons/play.png diff --git a/qml/images/icons/rewind.png b/qml/images/icons/rewind.png Binary files differnew file mode 100644 index 0000000..d58104f --- /dev/null +++ b/qml/images/icons/rewind.png diff --git a/qml/images/icons/rotation.png b/qml/images/icons/rotation.png Binary files differnew file mode 100755 index 0000000..f3eb085 --- /dev/null +++ b/qml/images/icons/rotation.png diff --git a/qml/images/icons/settings.png b/qml/images/icons/settings.png Binary files differnew file mode 100644 index 0000000..756d344 --- /dev/null +++ b/qml/images/icons/settings.png diff --git a/qml/images/info_sc1.png b/qml/images/info_sc1.png Binary files differnew file mode 100644 index 0000000..3eac790 --- /dev/null +++ b/qml/images/info_sc1.png diff --git a/qml/images/info_sc2.png b/qml/images/info_sc2.png Binary files differnew file mode 100644 index 0000000..bdfb395 --- /dev/null +++ b/qml/images/info_sc2.png diff --git a/qml/images/info_sc3.png b/qml/images/info_sc3.png Binary files differnew file mode 100644 index 0000000..d39eb09 --- /dev/null +++ b/qml/images/info_sc3.png diff --git a/qml/images/info_sc4.png b/qml/images/info_sc4.png Binary files differnew file mode 100644 index 0000000..c99c021 --- /dev/null +++ b/qml/images/info_sc4.png diff --git a/qml/images/panel2_bg.png b/qml/images/panel2_bg.png Binary files differnew file mode 100644 index 0000000..92e40cb --- /dev/null +++ b/qml/images/panel2_bg.png diff --git a/qml/images/panel_bg.png b/qml/images/panel_bg.png Binary files differnew file mode 100644 index 0000000..b50a2e2 --- /dev/null +++ b/qml/images/panel_bg.png diff --git a/qml/images/planet.png b/qml/images/planet.png Binary files differnew file mode 100644 index 0000000..7bd581d --- /dev/null +++ b/qml/images/planet.png diff --git a/qml/images/qt_logo.png b/qml/images/qt_logo.png Binary files differnew file mode 100644 index 0000000..b576fba --- /dev/null +++ b/qml/images/qt_logo.png diff --git a/qml/images/qt_logo_small.png b/qml/images/qt_logo_small.png Binary files differnew file mode 100644 index 0000000..15d3beb --- /dev/null +++ b/qml/images/qt_logo_small.png diff --git a/qml/images/quit_logo.png b/qml/images/quit_logo.png Binary files differnew file mode 100644 index 0000000..a3f1943 --- /dev/null +++ b/qml/images/quit_logo.png diff --git a/qml/images/quit_logo_small.png b/qml/images/quit_logo_small.png Binary files differnew file mode 100644 index 0000000..991a8f1 --- /dev/null +++ b/qml/images/quit_logo_small.png diff --git a/qml/images/shots/3D_Planets_1.jpg b/qml/images/shots/3D_Planets_1.jpg Binary files differnew file mode 100644 index 0000000..aa53541 --- /dev/null +++ b/qml/images/shots/3D_Planets_1.jpg diff --git a/qml/images/shots/3D_Planets_2.jpg b/qml/images/shots/3D_Planets_2.jpg Binary files differnew file mode 100644 index 0000000..3fd4abd --- /dev/null +++ b/qml/images/shots/3D_Planets_2.jpg diff --git a/qml/images/shots/3D_Planets_3.jpg b/qml/images/shots/3D_Planets_3.jpg Binary files differnew file mode 100644 index 0000000..a773bcd --- /dev/null +++ b/qml/images/shots/3D_Planets_3.jpg diff --git a/qml/images/shots/3D_Planets_4.jpg b/qml/images/shots/3D_Planets_4.jpg Binary files differnew file mode 100644 index 0000000..01b2284 --- /dev/null +++ b/qml/images/shots/3D_Planets_4.jpg diff --git a/qml/images/shots/Bluescape_1.jpg b/qml/images/shots/Bluescape_1.jpg Binary files differnew file mode 100644 index 0000000..01bff77 --- /dev/null +++ b/qml/images/shots/Bluescape_1.jpg diff --git a/qml/images/shots/Bluescape_2.jpg b/qml/images/shots/Bluescape_2.jpg Binary files differnew file mode 100644 index 0000000..acc85c7 --- /dev/null +++ b/qml/images/shots/Bluescape_2.jpg diff --git a/qml/images/shots/Bluescape_3.jpg b/qml/images/shots/Bluescape_3.jpg Binary files differnew file mode 100644 index 0000000..d9817ee --- /dev/null +++ b/qml/images/shots/Bluescape_3.jpg diff --git a/qml/images/shots/Bluescape_4.jpg b/qml/images/shots/Bluescape_4.jpg Binary files differnew file mode 100644 index 0000000..c411627 --- /dev/null +++ b/qml/images/shots/Bluescape_4.jpg diff --git a/qml/images/shots/Build_Your_World_1.jpg b/qml/images/shots/Build_Your_World_1.jpg Binary files differnew file mode 100644 index 0000000..1c4ce14 --- /dev/null +++ b/qml/images/shots/Build_Your_World_1.jpg diff --git a/qml/images/shots/Build_Your_World_2.jpg b/qml/images/shots/Build_Your_World_2.jpg Binary files differnew file mode 100644 index 0000000..d68900f --- /dev/null +++ b/qml/images/shots/Build_Your_World_2.jpg diff --git a/qml/images/shots/Build_Your_World_3.jpg b/qml/images/shots/Build_Your_World_3.jpg Binary files differnew file mode 100644 index 0000000..4041fc0 --- /dev/null +++ b/qml/images/shots/Build_Your_World_3.jpg diff --git a/qml/images/shots/Build_Your_World_4.jpg b/qml/images/shots/Build_Your_World_4.jpg Binary files differnew file mode 100644 index 0000000..2a6b926 --- /dev/null +++ b/qml/images/shots/Build_Your_World_4.jpg diff --git a/qml/images/shots/IoT_1.jpg b/qml/images/shots/IoT_1.jpg Binary files differnew file mode 100644 index 0000000..d3d4120 --- /dev/null +++ b/qml/images/shots/IoT_1.jpg diff --git a/qml/images/shots/IoT_2.jpg b/qml/images/shots/IoT_2.jpg Binary files differnew file mode 100644 index 0000000..5bfffc3 --- /dev/null +++ b/qml/images/shots/IoT_2.jpg diff --git a/qml/images/shots/IoT_3.jpg b/qml/images/shots/IoT_3.jpg Binary files differnew file mode 100644 index 0000000..e6eb04e --- /dev/null +++ b/qml/images/shots/IoT_3.jpg diff --git a/qml/images/shots/IoT_4.jpg b/qml/images/shots/IoT_4.jpg Binary files differnew file mode 100644 index 0000000..3ee6eb5 --- /dev/null +++ b/qml/images/shots/IoT_4.jpg diff --git a/qml/images/shots/Meet_Qt_Creator_1.jpg b/qml/images/shots/Meet_Qt_Creator_1.jpg Binary files differnew file mode 100644 index 0000000..3a7de25 --- /dev/null +++ b/qml/images/shots/Meet_Qt_Creator_1.jpg diff --git a/qml/images/shots/Meet_Qt_Creator_2.jpg b/qml/images/shots/Meet_Qt_Creator_2.jpg Binary files differnew file mode 100644 index 0000000..c14dc3c --- /dev/null +++ b/qml/images/shots/Meet_Qt_Creator_2.jpg diff --git a/qml/images/shots/Meet_Qt_Creator_3.jpg b/qml/images/shots/Meet_Qt_Creator_3.jpg Binary files differnew file mode 100644 index 0000000..4dbae46 --- /dev/null +++ b/qml/images/shots/Meet_Qt_Creator_3.jpg diff --git a/qml/images/shots/Meet_Qt_Creator_4.jpg b/qml/images/shots/Meet_Qt_Creator_4.jpg Binary files differnew file mode 100644 index 0000000..eda52e8 --- /dev/null +++ b/qml/images/shots/Meet_Qt_Creator_4.jpg diff --git a/qml/main.qml b/qml/main.qml new file mode 100644 index 0000000..03c88d0 --- /dev/null +++ b/qml/main.qml @@ -0,0 +1,279 @@ +/**************************************************************************** +** +** Copyright (C) 2015 QUIt Coding Ltd. +** Contact: info@quitcoding.com +** +** This file is part of Cinematic 3D, a Qt3D demo application. +** +** $QT_BEGIN_LICENSE:BSD$ +** 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.4 +import QtQuick.Window 2.2 +import QtQuick.Scene3D 2.0 + +Window { + id: window + + // Scaling factor + property real dp: width / 960 + // True when video player should be loaded + property bool videoOn: false + // True when playing video + property bool viewingVideo: false + // Filename of currently selected video + property string videoFile: "" + // Current carousel item offset + property real carouselOffset: 0.0 + + width: 960 + height: 600 + visible: true + color: "#000000" + + // These are controlled from SettingsView + QtObject { + id: settings + property bool showCarouselOpacity: true + property bool show3DReflections: true + property bool starsBackground: true + property bool showFps: false + property bool slowAnimations: false + } + + // Qt3D view + Scene3D { + id: scene3D + anchors.fill: parent + opacity: 0 + Component.onCompleted: startupShowAnimation.start() + Cinematic3DScene { + id: cinematic3DScene + coverImage: carouselView.selectedCoverImage.length > 0 ? carouselView.selectedCoverImage : "images/covers/Build_Your_World.jpg" + } + } + + // Video details view + DetailsView { + id: detailsView + anchors.fill: parent + opacity: cinematic3DScene.showDetailsTransitionState * (1 - cinematic3DScene.showVideoTransitionState * 2.0) + // Set initial cover image + imageName: "Build_Your_World" + onBackButtonClicked: { + if (cinematic3DScene.showCover) { + showDetailsView.stop(); + hideDetailsView.start(); + } + } + } + + // Video carousel view + CarouselView { + id: carouselView + anchors.verticalCenter: parent.verticalCenter + carouselInteractive: !cinematic3DScene.showCover + opacity: 0 + visible: opacity + } + + // Top-left corner fps item + FpsItem { + anchors.left: parent.left + anchors.top: parent.top + visible: settings.showFps + } + + // Top-right corner info view + InfoView { + id: infoView + anchors.right: parent.right + anchors.top: parent.top + } + + // Bottom-left corner settings view + SettingsView { + id: settingsView + } + + // Video playback loader view + Loader { + id: playerViewLoader + anchors.fill: parent + source: "PlayerView.qml" + opacity: 0 + visible: opacity + // Load video component only as needed + active: videoOn + } + + // Start -> CarouseView animation + SequentialAnimation { + id: startupShowAnimation + PauseAnimation { + duration: 1000 + } + NumberAnimation { + target: carouselView + property: "opacity" + to: 1 + duration: 500 + easing.type: Easing.InOutQuad + } + NumberAnimation { + target: scene3D + property: "opacity" + to: 1 + duration: 500 + easing.type: Easing.InOutQuad + } + } + + // CarouseView <-> DetailsView animations + SequentialAnimation { + id: showDetailsView + + PropertyAction { + target: cinematic3DScene + property: "showCover" + value: true + } + + NumberAnimation { + target: carouselView + property: "opacity" + to: 0 + duration: 300 + settings.slowAnimations*1000 + easing.type: Easing.InOutQuad + } + + NumberAnimation { + target: cinematic3DScene + property: "showDetailsTransitionState" + to: 1.0 + duration: 500 + settings.slowAnimations*1000 + easing.type: Easing.InOutQuad + } + } + + SequentialAnimation { + id: hideDetailsView + + NumberAnimation { + target: cinematic3DScene + property: "showDetailsTransitionState" + to: 0.0 + duration: 300 + settings.slowAnimations*1000 + easing.type: Easing.InOutQuad + } + + NumberAnimation { + target: carouselView + property: "opacity" + to: 1.0 + duration: 500 + settings.slowAnimations*1000 + easing.type: Easing.InOutQuad + } + + PropertyAction { + target: cinematic3DScene + property: "showCover" + value: false + } + } + + // DetailsView <-> Video animations + SequentialAnimation { + id: showVideo + + NumberAnimation { + target: cinematic3DScene + property: "showVideoTransitionState" + to: 1.0 + duration: 1000 + settings.slowAnimations*3000 + easing.type: Easing.InOutQuad + } + + PropertyAction { + target: window + property: "videoOn" + value: true + } + + NumberAnimation { + target: playerViewLoader + property: "opacity" + to: 1.0 + duration: 1000 + settings.slowAnimations*1500 + easing.type: Easing.InOutQuad + } + + PropertyAction { + target: window + property: "viewingVideo" + value: true + } + } + + SequentialAnimation { + id: hideVideo + + NumberAnimation { + target: playerViewLoader + property: "opacity" + to: 0.0 + duration: 1000 + settings.slowAnimations*1000 + easing.type: Easing.InOutQuad + } + + PropertyAction { + target: window + property: "videoOn" + value: false + } + + NumberAnimation { + target: cinematic3DScene + property: "showVideoTransitionState" + to: 0.0 + duration: 1200 + settings.slowAnimations*3000 + easing.type: Easing.InOutQuad + } + + PropertyAction { + target: window + property: "viewingVideo" + value: false + } + } +} diff --git a/videos/NOTE.TXT b/videos/NOTE.TXT new file mode 100644 index 0000000..e4a6670 --- /dev/null +++ b/videos/NOTE.TXT @@ -0,0 +1,3 @@ +To support local videos: +- Add here mp4 video files with names matching to XML model. +- To bundle videos on OS X, enable video files in pro file VIDEO_FILES. |