summaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
authorSarah Smith <sarah.j.smith@nokia.com>2011-03-09 17:08:07 +1000
committerSarah Smith <sarah.j.smith@nokia.com>2011-03-09 17:43:07 +1000
commitb87a08f5292069facf9b427cb43a675d43578293 (patch)
treeaf3efc8960a3e556e15b7b66f81821b01297c366 /examples
Add files ported from research/qt3d
Fill repo with some of the files from the research/qt3d project. At present the new project builds under MacOSX. To-dos include getting it building under linux, windows, harmattan and maemo/meego; updating the documentation to reflect the new QtQuick focus; and fixing the issues with private headers.
Diffstat (limited to 'examples')
-rw-r--r--examples/basket/README15
-rw-r--r--examples/basket/basket.jpgbin0 -> 454145 bytes
-rw-r--r--examples/basket/basket.pro7
-rw-r--r--examples/basket/basket.qrc5
-rw-r--r--examples/basket/basket_data.h404
-rw-r--r--examples/basket/basket_data.txt332
-rw-r--r--examples/basket/basketview.cpp93
-rw-r--r--examples/basket/basketview.h69
-rw-r--r--examples/basket/main.cpp57
-rw-r--r--examples/builder/builder.cpp192
-rw-r--r--examples/builder/builder.h66
-rw-r--r--examples/builder/builder.pro8
-rw-r--r--examples/builder/builder.qrc5
-rw-r--r--examples/builder/main.cpp58
-rw-r--r--examples/builder/qt-soup.pngbin0 -> 91448 bytes
-rw-r--r--examples/cube/cube.pro7
-rw-r--r--examples/cube/cube.qrc5
-rw-r--r--examples/cube/cubeview.cpp74
-rw-r--r--examples/cube/cubeview.h62
-rw-r--r--examples/cube/main.cpp57
-rw-r--r--examples/cube/qtlogo.pngbin0 -> 13923 bytes
-rw-r--r--examples/cylinder/cubeview.cpp77
-rw-r--r--examples/cylinder/cubeview.h62
-rw-r--r--examples/cylinder/cupTexture.pngbin0 -> 82843 bytes
-rw-r--r--examples/cylinder/cylinder.pro7
-rw-r--r--examples/cylinder/cylinder.qrc6
-rw-r--r--examples/cylinder/cylinderview.cpp101
-rw-r--r--examples/cylinder/cylinderview.h62
-rw-r--r--examples/cylinder/latte.pngbin0 -> 294671 bytes
-rw-r--r--examples/cylinder/main.cpp57
-rw-r--r--examples/examples.pro2
-rw-r--r--examples/geometry/EarthFlat_512x512.jpgbin0 -> 183612 bytes
-rw-r--r--examples/geometry/bullseye.pngbin0 -> 2737 bytes
-rw-r--r--examples/geometry/geometry.cpp201
-rw-r--r--examples/geometry/geometry.h56
-rw-r--r--examples/geometry/geometry.pro12
-rw-r--r--examples/geometry/geometry.qrc6
-rw-r--r--examples/geometry/geometryview.cpp122
-rw-r--r--examples/geometry/geometryview.h85
-rw-r--r--examples/geometry/main.cpp55
-rw-r--r--examples/geometry/quadplane.cpp92
-rw-r--r--examples/geometry/quadplane.h57
-rw-r--r--examples/graphicsview/cubeicon.pngbin0 -> 703 bytes
-rw-r--r--examples/graphicsview/cubeitem.cpp193
-rw-r--r--examples/graphicsview/cubeitem.h61
-rw-r--r--examples/graphicsview/edge.cpp151
-rw-r--r--examples/graphicsview/edge.h77
-rw-r--r--examples/graphicsview/graph.cpp130
-rw-r--r--examples/graphicsview/graph.h67
-rw-r--r--examples/graphicsview/graphicsview.pro26
-rw-r--r--examples/graphicsview/graphicsview.qrc6
-rw-r--r--examples/graphicsview/main.cpp58
-rw-r--r--examples/graphicsview/modelitem.cpp220
-rw-r--r--examples/graphicsview/modelitem.h89
-rw-r--r--examples/graphicsview/node.cpp185
-rw-r--r--examples/graphicsview/node.h83
-rw-r--r--examples/graphicsview/scene.cpp54
-rw-r--r--examples/graphicsview/scene.h56
-rw-r--r--examples/graphicsview/teapoticon.pngbin0 -> 4969 bytes
-rw-r--r--examples/graphicsview/teapotitem.cpp129
-rw-r--r--examples/graphicsview/teapotitem.h63
-rw-r--r--examples/graphicsview/view.cpp121
-rw-r--r--examples/graphicsview/view.h87
-rw-r--r--examples/nesting/cubeview.cpp209
-rw-r--r--examples/nesting/cubeview.h90
-rw-r--r--examples/nesting/main.cpp57
-rw-r--r--examples/nesting/nesting.pro7
-rw-r--r--examples/nesting/nesting.qrc5
-rw-r--r--examples/nesting/qtlogo.pngbin0 -> 13923 bytes
-rw-r--r--examples/tank/main.cpp56
-rw-r--r--examples/tank/quadplane.cpp107
-rw-r--r--examples/tank/quadplane.h55
-rw-r--r--examples/tank/tank.cpp136
-rw-r--r--examples/tank/tank.h59
-rw-r--r--examples/tank/tank.pro14
-rw-r--r--examples/tank/tankview.cpp116
-rw-r--r--examples/tank/tankview.h67
-rw-r--r--examples/teapot/main.cpp61
-rw-r--r--examples/teapot/teapot.pro6
-rw-r--r--examples/teapot/teapotview.cpp68
-rw-r--r--examples/teapot/teapotview.h66
-rw-r--r--examples/tutorials/converting-rawgl/converting-rawgl.pro6
-rw-r--r--examples/tutorials/converting/converting-rawgl.cpp211
-rw-r--r--examples/tutorials/converting/converting.cpp109
-rw-r--r--examples/tutorials/converting/converting.pro8
-rw-r--r--examples/tutorials/cube1/cube1.pro5
-rw-r--r--examples/tutorials/cube1/cubeview.cpp67
-rw-r--r--examples/tutorials/cube1/cubeview.h64
-rw-r--r--examples/tutorials/cube1/main.cpp50
-rw-r--r--examples/tutorials/cube2/cube2.pro5
-rw-r--r--examples/tutorials/cube2/cubeview.cpp66
-rw-r--r--examples/tutorials/cube2/cubeview.h64
-rw-r--r--examples/tutorials/cube2/main.cpp50
-rw-r--r--examples/tutorials/cube3/cube3.pro5
-rw-r--r--examples/tutorials/cube3/cubeview.cpp69
-rw-r--r--examples/tutorials/cube3/cubeview.h64
-rw-r--r--examples/tutorials/cube3/main.cpp50
-rw-r--r--examples/tutorials/cube4/cube.qml61
-rw-r--r--examples/tutorials/cube4/cube.qrc5
-rw-r--r--examples/tutorials/cube4/cube4.pro6
-rw-r--r--examples/tutorials/cube4/cubeview.cpp76
-rw-r--r--examples/tutorials/cube4/cubeview.h68
-rw-r--r--examples/tutorials/cube4/main.cpp50
-rw-r--r--examples/tutorials/cube4/qtlogo.pngbin0 -> 13923 bytes
-rw-r--r--examples/tutorials/penguin/main.cpp51
-rw-r--r--examples/tutorials/penguin/model.qrc5
-rw-r--r--examples/tutorials/penguin/modelview.cpp64
-rw-r--r--examples/tutorials/penguin/modelview.h66
-rw-r--r--examples/tutorials/penguin/penguin.3dsbin0 -> 36301 bytes
-rw-r--r--examples/tutorials/penguin/penguin.pro7
-rw-r--r--examples/tutorials/penguin_advanced/main.cpp51
-rw-r--r--examples/tutorials/penguin_advanced/model_advanced.qrc5
-rw-r--r--examples/tutorials/penguin_advanced/modelview.cpp76
-rw-r--r--examples/tutorials/penguin_advanced/modelview.h66
-rw-r--r--examples/tutorials/penguin_advanced/penguin.3dsbin0 -> 36301 bytes
-rw-r--r--examples/tutorials/penguin_advanced/penguin_advanced.pro8
-rw-r--r--examples/tutorials/shaders/TutorialTeapot.qml65
l---------examples/tutorials/shaders/meshes1
-rw-r--r--examples/tutorials/shaders/shader-tutorial-1-textures.qml105
-rw-r--r--examples/tutorials/shaders/shader-tutorial-2-vertex-shader.qml117
-rw-r--r--examples/tutorials/shaders/shader-tutorial-3-transformed-coordinates.qml126
-rw-r--r--examples/tutorials/shaders/shader-tutorial-lighting.qml85
-rw-r--r--examples/tutorials/shaders/shader-tutorial-varying.qml77
-rw-r--r--examples/tutorials/shaders/shader-tutorial.qml82
-rw-r--r--examples/tutorials/shaders/shaders.pro7
-rw-r--r--examples/tutorials/shaders/shaders.qmlproject16
l---------examples/tutorials/shaders/textures/basket.jpg1
l---------examples/tutorials/shaders/textures/qtlogo.png1
-rw-r--r--examples/tutorials/teapot-qml/teapot-bounce.qml76
-rw-r--r--examples/tutorials/teapot-qml/teapot-qml.qmlproject16
-rw-r--r--examples/tutorials/teapot-qml/teapot.bez340
-rw-r--r--examples/tutorials/teapot-qml/teapot.qml59
-rw-r--r--examples/tutorials/tutorials.pro3
133 files changed, 8346 insertions, 0 deletions
diff --git a/examples/basket/README b/examples/basket/README
new file mode 100644
index 000000000..560fd74c5
--- /dev/null
+++ b/examples/basket/README
@@ -0,0 +1,15 @@
+
+This example draws a rotating basket, textured with a basket weave,
+to demonstrte how to use textures and how to create simple animated
+effects. The basket model is based on the standard teapot model,
+with the handle and spout removed.
+
+The texture came from www.cgtextures.com:
+
+http://www.cgtextures.com/texview.php?id=25208&s=S&PHPSESSID=2fd7273841dfba0001d8fb6e8c832cba
+
+The license details on the textures from the site is basically
+royalty-free for the example use we are making of it. Consult the
+license agreement for the full details:
+
+http://www.cgtextures.com/content.php?action=license
diff --git a/examples/basket/basket.jpg b/examples/basket/basket.jpg
new file mode 100644
index 000000000..438e7a0c2
--- /dev/null
+++ b/examples/basket/basket.jpg
Binary files differ
diff --git a/examples/basket/basket.pro b/examples/basket/basket.pro
new file mode 100644
index 000000000..8c24581b0
--- /dev/null
+++ b/examples/basket/basket.pro
@@ -0,0 +1,7 @@
+TEMPLATE = app
+TARGET = basket
+CONFIG += qt warn_on qt3d
+SOURCES = basketview.cpp main.cpp
+HEADERS = basketview.h basket_data.h
+RESOURCES = basket.qrc
+DESTDIR = ../../bin
diff --git a/examples/basket/basket.qrc b/examples/basket/basket.qrc
new file mode 100644
index 000000000..590b65c7a
--- /dev/null
+++ b/examples/basket/basket.qrc
@@ -0,0 +1,5 @@
+<!DOCTYPE RCC><RCC version="1.0">
+<qresource>
+ <file>basket.jpg</file>
+</qresource>
+</RCC>
diff --git a/examples/basket/basket_data.h b/examples/basket/basket_data.h
new file mode 100644
index 000000000..d456a6924
--- /dev/null
+++ b/examples/basket/basket_data.h
@@ -0,0 +1,404 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtQuick3D examples of the Qt Toolkit.
+**
+** $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 Nokia Corporation and its Subsidiary(-ies) 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$
+**
+****************************************************************************/
+
+#ifndef BASKET_DATA_H
+#define BASKET_DATA_H
+
+#include "qglbezierpatches.h"
+
+// Generated from basket_data.txt by meshcvt, depth = 4
+
+#define BasketBezierVertexCount 306
+#define BasketPatchCount 24
+#define BasketDepth 4
+static float const BasketBezierVertexData[] = {
+ 0.700000f, 0.450000f, -0.000000f,
+ 0.700000f, 0.450000f, 0.392000f,
+ 0.392000f, 0.450000f, 0.700000f,
+ 0.000000f, 0.450000f, 0.700000f,
+ 0.668750f, 0.515625f, -0.000000f,
+ 0.668750f, 0.515625f, 0.374500f,
+ 0.374500f, 0.515625f, 0.668750f,
+ 0.000000f, 0.515625f, 0.668750f,
+ 0.718750f, 0.515625f, -0.000000f,
+ 0.718750f, 0.515625f, 0.402500f,
+ 0.402500f, 0.515625f, 0.718750f,
+ 0.000000f, 0.515625f, 0.718750f,
+ 0.750000f, 0.450000f, -0.000000f,
+ 0.750000f, 0.450000f, 0.420000f,
+ 0.420000f, 0.450000f, 0.750000f,
+ 0.000000f, 0.450000f, 0.750000f,
+ -0.392000f, 0.450000f, 0.700000f,
+ -0.700000f, 0.450000f, 0.392000f,
+ -0.700000f, 0.450000f, -0.000000f,
+ -0.374500f, 0.515625f, 0.668750f,
+ -0.668750f, 0.515625f, 0.374500f,
+ -0.668750f, 0.515625f, -0.000000f,
+ -0.402500f, 0.515625f, 0.718750f,
+ -0.718750f, 0.515625f, 0.402500f,
+ -0.718750f, 0.515625f, -0.000000f,
+ -0.420000f, 0.450000f, 0.750000f,
+ -0.750000f, 0.450000f, 0.420000f,
+ -0.750000f, 0.450000f, -0.000000f,
+ -0.700000f, 0.450000f, -0.392000f,
+ -0.392000f, 0.450000f, -0.700000f,
+ 0.000000f, 0.450000f, -0.700000f,
+ -0.668750f, 0.515625f, -0.374500f,
+ -0.374500f, 0.515625f, -0.668750f,
+ 0.000000f, 0.515625f, -0.668750f,
+ -0.718750f, 0.515625f, -0.402500f,
+ -0.402500f, 0.515625f, -0.718750f,
+ 0.000000f, 0.515625f, -0.718750f,
+ -0.750000f, 0.450000f, -0.420000f,
+ -0.420000f, 0.450000f, -0.750000f,
+ 0.000000f, 0.450000f, -0.750000f,
+ 0.392000f, 0.450000f, -0.700000f,
+ 0.700000f, 0.450000f, -0.392000f,
+ 0.374500f, 0.515625f, -0.668750f,
+ 0.668750f, 0.515625f, -0.374500f,
+ 0.402500f, 0.515625f, -0.718750f,
+ 0.718750f, 0.515625f, -0.402500f,
+ 0.420000f, 0.450000f, -0.750000f,
+ 0.750000f, 0.450000f, -0.420000f,
+ 0.875000f, 0.187500f, -0.000000f,
+ 0.875000f, 0.187500f, 0.490000f,
+ 0.490000f, 0.187500f, 0.875000f,
+ 0.000000f, 0.187500f, 0.875000f,
+ 1.000000f, -0.075000f, -0.000000f,
+ 1.000000f, -0.075000f, 0.560000f,
+ 0.560000f, -0.075000f, 1.000000f,
+ 0.000000f, -0.075000f, 1.000000f,
+ 1.000000f, -0.300000f, -0.000000f,
+ 1.000000f, -0.300000f, 0.560000f,
+ 0.560000f, -0.300000f, 1.000000f,
+ 0.000000f, -0.300000f, 1.000000f,
+ -0.490000f, 0.187500f, 0.875000f,
+ -0.875000f, 0.187500f, 0.490000f,
+ -0.875000f, 0.187500f, -0.000000f,
+ -0.560000f, -0.075000f, 1.000000f,
+ -1.000000f, -0.075000f, 0.560000f,
+ -1.000000f, -0.075000f, -0.000000f,
+ -0.560000f, -0.300000f, 1.000000f,
+ -1.000000f, -0.300000f, 0.560000f,
+ -1.000000f, -0.300000f, -0.000000f,
+ -0.875000f, 0.187500f, -0.490000f,
+ -0.490000f, 0.187500f, -0.875000f,
+ 0.000000f, 0.187500f, -0.875000f,
+ -1.000000f, -0.075000f, -0.560000f,
+ -0.560000f, -0.075000f, -1.000000f,
+ 0.000000f, -0.075000f, -1.000000f,
+ -1.000000f, -0.300000f, -0.560000f,
+ -0.560000f, -0.300000f, -1.000000f,
+ 0.000000f, -0.300000f, -1.000000f,
+ 0.490000f, 0.187500f, -0.875000f,
+ 0.875000f, 0.187500f, -0.490000f,
+ 0.560000f, -0.075000f, -1.000000f,
+ 1.000000f, -0.075000f, -0.560000f,
+ 0.560000f, -0.300000f, -1.000000f,
+ 1.000000f, -0.300000f, -0.560000f,
+ 1.000000f, -0.525000f, -0.000000f,
+ 1.000000f, -0.525000f, 0.560000f,
+ 0.560000f, -0.525000f, 1.000000f,
+ 0.000000f, -0.525000f, 1.000000f,
+ 0.750000f, -0.637500f, -0.000000f,
+ 0.750000f, -0.637500f, 0.420000f,
+ 0.420000f, -0.637500f, 0.750000f,
+ 0.000000f, -0.637500f, 0.750000f,
+ 0.750000f, -0.675000f, -0.000000f,
+ 0.750000f, -0.675000f, 0.420000f,
+ 0.420000f, -0.675000f, 0.750000f,
+ 0.000000f, -0.675000f, 0.750000f,
+ -0.560000f, -0.525000f, 1.000000f,
+ -1.000000f, -0.525000f, 0.560000f,
+ -1.000000f, -0.525000f, -0.000000f,
+ -0.420000f, -0.637500f, 0.750000f,
+ -0.750000f, -0.637500f, 0.420000f,
+ -0.750000f, -0.637500f, -0.000000f,
+ -0.420000f, -0.675000f, 0.750000f,
+ -0.750000f, -0.675000f, 0.420000f,
+ -0.750000f, -0.675000f, -0.000000f,
+ -1.000000f, -0.525000f, -0.560000f,
+ -0.560000f, -0.525000f, -1.000000f,
+ 0.000000f, -0.525000f, -1.000000f,
+ -0.750000f, -0.637500f, -0.420000f,
+ -0.420000f, -0.637500f, -0.750000f,
+ 0.000000f, -0.637500f, -0.750000f,
+ -0.750000f, -0.675000f, -0.420000f,
+ -0.420000f, -0.675000f, -0.750000f,
+ 0.000000f, -0.675000f, -0.750000f,
+ 0.560000f, -0.525000f, -1.000000f,
+ 1.000000f, -0.525000f, -0.560000f,
+ 0.420000f, -0.637500f, -0.750000f,
+ 0.750000f, -0.637500f, -0.420000f,
+ 0.420000f, -0.675000f, -0.750000f,
+ 0.750000f, -0.675000f, -0.420000f,
+ -0.800000f, 0.262500f, -0.000000f,
+ -0.800000f, 0.262500f, 0.150000f,
+ -0.750000f, 0.375000f, 0.150000f,
+ -0.750000f, 0.375000f, -0.000000f,
+ -1.150000f, 0.262500f, -0.000000f,
+ -1.150000f, 0.262500f, 0.150000f,
+ -1.250000f, 0.375000f, 0.150000f,
+ -1.250000f, 0.375000f, -0.000000f,
+ -1.350000f, 0.262500f, -0.000000f,
+ -1.350000f, 0.262500f, 0.150000f,
+ -1.500000f, 0.375000f, 0.150000f,
+ -1.500000f, 0.375000f, -0.000000f,
+ -1.350000f, 0.150000f, -0.000000f,
+ -1.350000f, 0.150000f, 0.150000f,
+ -1.500000f, 0.150000f, 0.150000f,
+ -1.500000f, 0.150000f, -0.000000f,
+ -0.750000f, 0.375000f, -0.150000f,
+ -0.800000f, 0.262500f, -0.150000f,
+ -1.250000f, 0.375000f, -0.150000f,
+ -1.150000f, 0.262500f, -0.150000f,
+ -1.500000f, 0.375000f, -0.150000f,
+ -1.350000f, 0.262500f, -0.150000f,
+ -1.500000f, 0.150000f, -0.150000f,
+ -1.350000f, 0.150000f, -0.150000f,
+ -1.350000f, 0.037500f, -0.000000f,
+ -1.350000f, 0.037500f, 0.150000f,
+ -1.500000f, -0.075000f, 0.150000f,
+ -1.500000f, -0.075000f, -0.000000f,
+ -1.250000f, -0.187500f, -0.000000f,
+ -1.250000f, -0.187500f, 0.150000f,
+ -1.325000f, -0.281250f, 0.150000f,
+ -1.325000f, -0.281250f, -0.000000f,
+ -1.000000f, -0.300000f, 0.150000f,
+ -0.950000f, -0.450000f, 0.150000f,
+ -0.950000f, -0.450000f, -0.000000f,
+ -1.500000f, -0.075000f, -0.150000f,
+ -1.350000f, 0.037500f, -0.150000f,
+ -1.325000f, -0.281250f, -0.150000f,
+ -1.250000f, -0.187500f, -0.150000f,
+ -0.950000f, -0.450000f, -0.150000f,
+ -1.000000f, -0.300000f, -0.150000f,
+ 0.850000f, -0.037500f, -0.000000f,
+ 0.850000f, -0.037500f, 0.330000f,
+ 0.850000f, -0.450000f, 0.330000f,
+ 0.850000f, -0.450000f, -0.000000f,
+ 1.300000f, -0.037500f, -0.000000f,
+ 1.300000f, -0.037500f, 0.330000f,
+ 1.550000f, -0.337500f, 0.330000f,
+ 1.550000f, -0.337500f, -0.000000f,
+ 1.150000f, 0.300000f, -0.000000f,
+ 1.150000f, 0.300000f, 0.125000f,
+ 1.200000f, 0.262500f, 0.125000f,
+ 1.200000f, 0.262500f, -0.000000f,
+ 1.350000f, 0.450000f, -0.000000f,
+ 1.350000f, 0.450000f, 0.125000f,
+ 1.650000f, 0.450000f, 0.125000f,
+ 1.650000f, 0.450000f, -0.000000f,
+ 0.850000f, -0.450000f, -0.330000f,
+ 0.850000f, -0.037500f, -0.330000f,
+ 1.550000f, -0.337500f, -0.330000f,
+ 1.300000f, -0.037500f, -0.330000f,
+ 1.200000f, 0.262500f, -0.125000f,
+ 1.150000f, 0.300000f, -0.125000f,
+ 1.650000f, 0.450000f, -0.125000f,
+ 1.350000f, 0.450000f, -0.125000f,
+ 1.400000f, 0.487500f, -0.000000f,
+ 1.400000f, 0.487500f, 0.125000f,
+ 1.762500f, 0.496875f, 0.125000f,
+ 1.762500f, 0.496875f, -0.000000f,
+ 1.450000f, 0.487500f, -0.000000f,
+ 1.450000f, 0.487500f, 0.075000f,
+ 1.725000f, 0.506250f, 0.075000f,
+ 1.725000f, 0.506250f, -0.000000f,
+ 1.400000f, 0.450000f, -0.000000f,
+ 1.400000f, 0.450000f, 0.075000f,
+ 1.600000f, 0.450000f, 0.075000f,
+ 1.600000f, 0.450000f, -0.000000f,
+ 1.762500f, 0.496875f, -0.125000f,
+ 1.400000f, 0.487500f, -0.125000f,
+ 1.725000f, 0.506250f, -0.075000f,
+ 1.450000f, 0.487500f, -0.075000f,
+ 1.600000f, 0.450000f, -0.075000f,
+ 1.400000f, 0.450000f, -0.075000f,
+ 0.000000f, 0.825000f, -0.000000f,
+ 0.000000f, 0.825000f, 0.001000f,
+ 0.001000f, 0.825000f, -0.000000f,
+ 0.400000f, 0.825000f, -0.000000f,
+ 0.400000f, 0.825000f, 0.225000f,
+ 0.225000f, 0.825000f, 0.400000f,
+ 0.000000f, 0.825000f, 0.400000f,
+ 0.000000f, 0.675000f, -0.000000f,
+ 0.100000f, 0.600000f, -0.000000f,
+ 0.100000f, 0.600000f, 0.056000f,
+ 0.056000f, 0.600000f, 0.100000f,
+ 0.000000f, 0.600000f, 0.100000f,
+ -0.001000f, 0.825000f, -0.000000f,
+ -0.225000f, 0.825000f, 0.400000f,
+ -0.400000f, 0.825000f, 0.225000f,
+ -0.400000f, 0.825000f, -0.000000f,
+ -0.056000f, 0.600000f, 0.100000f,
+ -0.100000f, 0.600000f, 0.056000f,
+ -0.100000f, 0.600000f, -0.000000f,
+ 0.000000f, 0.825000f, -0.001000f,
+ -0.400000f, 0.825000f, -0.225000f,
+ -0.225000f, 0.825000f, -0.400000f,
+ 0.000000f, 0.825000f, -0.400000f,
+ -0.100000f, 0.600000f, -0.056000f,
+ -0.056000f, 0.600000f, -0.100000f,
+ 0.000000f, 0.600000f, -0.100000f,
+ 0.225000f, 0.825000f, -0.400000f,
+ 0.400000f, 0.825000f, -0.225000f,
+ 0.056000f, 0.600000f, -0.100000f,
+ 0.100000f, 0.600000f, -0.056000f,
+ 0.200000f, 0.525000f, -0.000000f,
+ 0.200000f, 0.525000f, 0.112000f,
+ 0.112000f, 0.525000f, 0.200000f,
+ 0.000000f, 0.525000f, 0.200000f,
+ 0.650000f, 0.525000f, -0.000000f,
+ 0.650000f, 0.525000f, 0.364000f,
+ 0.364000f, 0.525000f, 0.650000f,
+ 0.000000f, 0.525000f, 0.650000f,
+ 0.650000f, 0.450000f, -0.000000f,
+ 0.650000f, 0.450000f, 0.364000f,
+ 0.364000f, 0.450000f, 0.650000f,
+ 0.000000f, 0.450000f, 0.650000f,
+ -0.112000f, 0.525000f, 0.200000f,
+ -0.200000f, 0.525000f, 0.112000f,
+ -0.200000f, 0.525000f, -0.000000f,
+ -0.364000f, 0.525000f, 0.650000f,
+ -0.650000f, 0.525000f, 0.364000f,
+ -0.650000f, 0.525000f, -0.000000f,
+ -0.364000f, 0.450000f, 0.650000f,
+ -0.650000f, 0.450000f, 0.364000f,
+ -0.650000f, 0.450000f, -0.000000f,
+ -0.200000f, 0.525000f, -0.112000f,
+ -0.112000f, 0.525000f, -0.200000f,
+ 0.000000f, 0.525000f, -0.200000f,
+ -0.650000f, 0.525000f, -0.364000f,
+ -0.364000f, 0.525000f, -0.650000f,
+ 0.000000f, 0.525000f, -0.650000f,
+ -0.650000f, 0.450000f, -0.364000f,
+ -0.364000f, 0.450000f, -0.650000f,
+ 0.000000f, 0.450000f, -0.650000f,
+ 0.112000f, 0.525000f, -0.200000f,
+ 0.200000f, 0.525000f, -0.112000f,
+ 0.364000f, 0.525000f, -0.650000f,
+ 0.650000f, 0.525000f, -0.364000f,
+ 0.364000f, 0.450000f, -0.650000f,
+ 0.650000f, 0.450000f, -0.364000f,
+ 0.000000f, -0.750000f, -0.000000f,
+ 0.750000f, -0.675000f, -0.000000f,
+ 0.750000f, -0.675000f, -0.420000f,
+ 0.420000f, -0.675000f, -0.750000f,
+ 0.000000f, -0.675000f, -0.750000f,
+ 0.750000f, -0.712500f, -0.000000f,
+ 0.750000f, -0.712500f, -0.420000f,
+ 0.420000f, -0.712500f, -0.750000f,
+ 0.000000f, -0.712500f, -0.750000f,
+ 0.712500f, -0.750000f, -0.000000f,
+ 0.712500f, -0.750000f, -0.399000f,
+ 0.399000f, -0.750000f, -0.712500f,
+ 0.000000f, -0.750000f, -0.712500f,
+ -0.420000f, -0.675000f, -0.750000f,
+ -0.750000f, -0.675000f, -0.420000f,
+ -0.750000f, -0.675000f, -0.000000f,
+ -0.420000f, -0.712500f, -0.750000f,
+ -0.750000f, -0.712500f, -0.420000f,
+ -0.750000f, -0.712500f, -0.000000f,
+ -0.399000f, -0.750000f, -0.712500f,
+ -0.712500f, -0.750000f, -0.399000f,
+ -0.712500f, -0.750000f, -0.000000f,
+ -0.750000f, -0.675000f, 0.420000f,
+ -0.420000f, -0.675000f, 0.750000f,
+ 0.000000f, -0.675000f, 0.750000f,
+ -0.750000f, -0.712500f, 0.420000f,
+ -0.420000f, -0.712500f, 0.750000f,
+ 0.000000f, -0.712500f, 0.750000f,
+ -0.712500f, -0.750000f, 0.399000f,
+ -0.399000f, -0.750000f, 0.712500f,
+ 0.000000f, -0.750000f, 0.712500f,
+ 0.420000f, -0.675000f, 0.750000f,
+ 0.750000f, -0.675000f, 0.420000f,
+ 0.420000f, -0.712500f, 0.750000f,
+ 0.750000f, -0.712500f, 0.420000f,
+ 0.399000f, -0.750000f, 0.712500f,
+ 0.712500f, -0.750000f, 0.399000f
+};
+
+static ushort const BasketPatchData[] = {
+ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
+ 3, 16, 17, 18, 7, 19, 20, 21, 11, 22, 23, 24, 15, 25, 26, 27,
+ 18, 28, 29, 30, 21, 31, 32, 33, 24, 34, 35, 36, 27, 37, 38, 39,
+ 30, 40, 41, 0, 33, 42, 43, 4, 36, 44, 45, 8, 39, 46, 47, 12,
+ 12, 13, 14, 15, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59,
+ 15, 25, 26, 27, 51, 60, 61, 62, 55, 63, 64, 65, 59, 66, 67, 68,
+ 27, 37, 38, 39, 62, 69, 70, 71, 65, 72, 73, 74, 68, 75, 76, 77,
+ 39, 46, 47, 12, 71, 78, 79, 48, 74, 80, 81, 52, 77, 82, 83, 56,
+ 56, 57, 58, 59, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95,
+ 59, 66, 67, 68, 87, 96, 97, 98, 91, 99, 100, 101, 95, 102, 103, 104,
+ 68, 75, 76, 77, 98, 105, 106, 107, 101, 108, 109, 110, 104, 111, 112, 113,
+ 77, 82, 83, 56, 107, 114, 115, 84, 110, 116, 117, 88, 113, 118, 119, 92,
+ 203, 203, 203, 203, 206, 207, 208, 209, 210, 210, 210, 210, 211, 212, 213, 214,
+ 203, 203, 203, 203, 209, 216, 217, 218, 210, 210, 210, 210, 214, 219, 220, 221,
+ 203, 203, 203, 203, 218, 223, 224, 225, 210, 210, 210, 210, 221, 226, 227, 228,
+ 203, 203, 203, 203, 225, 229, 230, 206, 210, 210, 210, 210, 228, 231, 232, 211,
+ 211, 212, 213, 214, 233, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244,
+ 214, 219, 220, 221, 236, 245, 246, 247, 240, 248, 249, 250, 244, 251, 252, 253,
+ 221, 226, 227, 228, 247, 254, 255, 256, 250, 257, 258, 259, 253, 260, 261, 262,
+ 228, 231, 232, 211, 256, 263, 264, 233, 259, 265, 266, 237, 262, 267, 268, 241,
+ 269, 269, 269, 269, 278, 279, 280, 281, 274, 275, 276, 277, 270, 271, 272, 273,
+ 269, 269, 269, 269, 281, 288, 289, 290, 277, 285, 286, 287, 273, 282, 283, 284,
+ 269, 269, 269, 269, 290, 297, 298, 299, 287, 294, 295, 296, 284, 291, 292, 293,
+ 269, 269, 269, 269, 299, 304, 305, 278, 296, 302, 303, 274, 293, 300, 301, 270
+};
+
+class BasketPatches : public QGLBezierPatches
+{
+public:
+ BasketPatches()
+ {
+ QVector3DArray positions;
+ for (int pindex = 0; pindex < BasketPatchCount * 16; ++pindex) {
+ int vindex = BasketPatchData[pindex];
+ positions.append(BasketBezierVertexData[vindex * 3],
+ BasketBezierVertexData[vindex * 3 + 1],
+ BasketBezierVertexData[vindex * 3 + 2]);
+ }
+ setPositions(positions);
+ setSubdivisionDepth(BasketDepth);
+ }
+};
+
+#endif
diff --git a/examples/basket/basket_data.txt b/examples/basket/basket_data.txt
new file mode 100644
index 000000000..6b693b5a7
--- /dev/null
+++ b/examples/basket/basket_data.txt
@@ -0,0 +1,332 @@
+24
+1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16
+4,17,18,19,8,20,21,22,12,23,24,25,16,26,27,28
+19,29,30,31,22,32,33,34,25,35,36,37,28,38,39,40
+31,41,42,1,34,43,44,5,37,45,46,9,40,47,48,13
+13,14,15,16,49,50,51,52,53,54,55,56,57,58,59,60
+16,26,27,28,52,61,62,63,56,64,65,66,60,67,68,69
+28,38,39,40,63,70,71,72,66,73,74,75,69,76,77,78
+40,47,48,13,72,79,80,49,75,81,82,53,78,83,84,57
+57,58,59,60,85,86,87,88,89,90,91,92,93,94,95,96
+60,67,68,69,88,97,98,99,92,100,101,102,96,103,104,105
+69,76,77,78,99,106,107,108,102,109,110,111,105,112,113,114
+78,83,84,57,108,115,116,85,111,117,118,89,114,119,120,93
+204,204,204,204,207,208,209,210,211,211,211,211,212,213,214,215,4
+204,204,204,204,210,217,218,219,211,211,211,211,215,220,221,222,4
+204,204,204,204,219,224,225,226,211,211,211,211,222,227,228,229,4
+204,204,204,204,226,230,231,207,211,211,211,211,229,232,233,212,4
+212,213,214,215,234,235,236,237,238,239,240,241,242,243,244,245
+215,220,221,222,237,246,247,248,241,249,250,251,245,252,253,254
+222,227,228,229,248,255,256,257,251,258,259,260,254,261,262,263
+229,232,233,212,257,264,265,234,260,266,267,238,263,268,269,242
+270,270,270,270,279,280,281,282,275,276,277,278,271,272,273,274,4
+270,270,270,270,282,289,290,291,278,286,287,288,274,283,284,285,4
+270,270,270,270,291,298,299,300,288,295,296,297,285,292,293,294,4
+270,270,270,270,300,305,306,279,297,303,304,275,294,301,302,271,4
+306
+1.4,0.0,2.4
+1.4,-0.784,2.4
+0.784,-1.4,2.4
+0.0,-1.4,2.4
+1.3375,0.0,2.53125
+1.3375,-0.749,2.53125
+0.749,-1.3375,2.53125
+0.0,-1.3375,2.53125
+1.4375,0.0,2.53125
+1.4375,-0.805,2.53125
+0.805,-1.4375,2.53125
+0.0,-1.4375,2.53125
+1.5,0.0,2.4
+1.5,-0.84,2.4
+0.84,-1.5,2.4
+0.0,-1.5,2.4
+-0.784,-1.4,2.4
+-1.4,-0.784,2.4
+-1.4,0.0,2.4
+-0.749,-1.3375,2.53125
+-1.3375,-0.749,2.53125
+-1.3375,0.0,2.53125
+-0.805,-1.4375,2.53125
+-1.4375,-0.805,2.53125
+-1.4375,0.0,2.53125
+-0.84,-1.5,2.4
+-1.5,-0.84,2.4
+-1.5,0.0,2.4
+-1.4,0.784,2.4
+-0.784,1.4,2.4
+0.0,1.4,2.4
+-1.3375,0.749,2.53125
+-0.749,1.3375,2.53125
+0.0,1.3375,2.53125
+-1.4375,0.805,2.53125
+-0.805,1.4375,2.53125
+0.0,1.4375,2.53125
+-1.5,0.84,2.4
+-0.84,1.5,2.4
+0.0,1.5,2.4
+0.784,1.4,2.4
+1.4,0.784,2.4
+0.749,1.3375,2.53125
+1.3375,0.749,2.53125
+0.805,1.4375,2.53125
+1.4375,0.805,2.53125
+0.84,1.5,2.4
+1.5,0.84,2.4
+1.75,0.0,1.875
+1.75,-0.98,1.875
+0.98,-1.75,1.875
+0.0,-1.75,1.875
+2.0,0.0,1.35
+2.0,-1.12,1.35
+1.12,-2.0,1.35
+0.0,-2.0,1.35
+2.0,0.0,0.9
+2.0,-1.12,0.9
+1.12,-2.0,0.9
+0.0,-2.0,0.9
+-0.98,-1.75,1.875
+-1.75,-0.98,1.875
+-1.75,0.0,1.875
+-1.12,-2.0,1.35
+-2.0,-1.12,1.35
+-2.0,0.0,1.35
+-1.12,-2.0,0.9
+-2.0,-1.12,0.9
+-2.0,0.0,0.9
+-1.75,0.98,1.875
+-0.98,1.75,1.875
+0.0,1.75,1.875
+-2.0,1.12,1.35
+-1.12,2.0,1.35
+0.0,2.0,1.35
+-2.0,1.12,0.9
+-1.12,2.0,0.9
+0.0,2.0,0.9
+0.98,1.75,1.875
+1.75,0.98,1.875
+1.12,2.0,1.35
+2.0,1.12,1.35
+1.12,2.0,0.9
+2.0,1.12,0.9
+2.0,0.0,0.45
+2.0,-1.12,0.45
+1.12,-2.0,0.45
+0.0,-2.0,0.45
+1.5,0.0,0.225
+1.5,-0.84,0.225
+0.84,-1.5,0.225
+0.0,-1.5,0.225
+1.5,0.0,0.15
+1.5,-0.84,0.15
+0.84,-1.5,0.15
+0.0,-1.5,0.15
+-1.12,-2.0,0.45
+-2.0,-1.12,0.45
+-2.0,0.0,0.45
+-0.84,-1.5,0.225
+-1.5,-0.84,0.225
+-1.5,0.0,0.225
+-0.84,-1.5,0.15
+-1.5,-0.84,0.15
+-1.5,0.0,0.15
+-2.0,1.12,0.45
+-1.12,2.0,0.45
+0.0,2.0,0.45
+-1.5,0.84,0.225
+-0.84,1.5,0.225
+0.0,1.5,0.225
+-1.5,0.84,0.15
+-0.84,1.5,0.15
+0.0,1.5,0.15
+1.12,2.0,0.45
+2.0,1.12,0.45
+0.84,1.5,0.225
+1.5,0.84,0.225
+0.84,1.5,0.15
+1.5,0.84,0.15
+-1.6,0.0,2.025
+-1.6,-0.3,2.025
+-1.5,-0.3,2.25
+-1.5,0.0,2.25
+-2.3,0.0,2.025
+-2.3,-0.3,2.025
+-2.5,-0.3,2.25
+-2.5,0.0,2.25
+-2.7,0.0,2.025
+-2.7,-0.3,2.025
+-3.0,-0.3,2.25
+-3.0,0.0,2.25
+-2.7,0.0,1.8
+-2.7,-0.3,1.8
+-3.0,-0.3,1.8
+-3.0,0.0,1.8
+-1.5,0.3,2.25
+-1.6,0.3,2.025
+-2.5,0.3,2.25
+-2.3,0.3,2.025
+-3.0,0.3,2.25
+-2.7,0.3,2.025
+-3.0,0.3,1.8
+-2.7,0.3,1.8
+-2.7,0.0,1.575
+-2.7,-0.3,1.575
+-3.0,-0.3,1.35
+-3.0,0.0,1.35
+-2.5,0.0,1.125
+-2.5,-0.3,1.125
+-2.65,-0.3,0.9375
+-2.65,0.0,0.9375
+-2.0,-0.3,0.9
+-1.9,-0.3,0.6
+-1.9,0.0,0.6
+-3.0,0.3,1.35
+-2.7,0.3,1.575
+-2.65,0.3,0.9375
+-2.5,0.3,1.125
+-1.9,0.3,0.6
+-2.0,0.3,0.9
+1.7,0.0,1.425
+1.7,-0.66,1.425
+1.7,-0.66,0.6
+1.7,0.0,0.6
+2.6,0.0,1.425
+2.6,-0.66,1.425
+3.1,-0.66,0.825
+3.1,0.0,0.825
+2.3,0.0,2.1
+2.3,-0.25,2.1
+2.4,-0.25,2.025
+2.4,0.0,2.025
+2.7,0.0,2.4
+2.7,-0.25,2.4
+3.3,-0.25,2.4
+3.3,0.0,2.4
+1.7,0.66,0.6
+1.7,0.66,1.425
+3.1,0.66,0.825
+2.6,0.66,1.425
+2.4,0.25,2.025
+2.3,0.25,2.1
+3.3,0.25,2.4
+2.7,0.25,2.4
+2.8,0.0,2.475
+2.8,-0.25,2.475
+3.525,-0.25,2.49375
+3.525,0.0,2.49375
+2.9,0.0,2.475
+2.9,-0.15,2.475
+3.45,-0.15,2.5125
+3.45,0.0,2.5125
+2.8,0.0,2.4
+2.8,-0.15,2.4
+3.2,-0.15,2.4
+3.2,0.0,2.4
+3.525,0.25,2.49375
+2.8,0.25,2.475
+3.45,0.15,2.5125
+2.9,0.15,2.475
+3.2,0.15,2.4
+2.8,0.15,2.4
+0.0,0.0,3.15
+0.0,-0.002,3.15
+0.002,0.0,3.15
+0.8,0.0,3.15
+0.8,-0.45,3.15
+0.45,-0.8,3.15
+0.0,-0.8,3.15
+0.0,0.0,2.85,0.0,0.0,1.0
+0.2,0.0,2.7
+0.2,-0.112,2.7
+0.112,-0.2,2.7
+0.0,-0.2,2.7
+-0.002,0.0,3.15
+-0.45,-0.8,3.15
+-0.8,-0.45,3.15
+-0.8,0.0,3.15
+-0.112,-0.2,2.7
+-0.2,-0.112,2.7
+-0.2,0.0,2.7
+0.0,0.002,3.15
+-0.8,0.45,3.15
+-0.45,0.8,3.15
+0.0,0.8,3.15
+-0.2,0.112,2.7
+-0.112,0.2,2.7
+0.0,0.2,2.7
+0.45,0.8,3.15
+0.8,0.45,3.15
+0.112,0.2,2.7
+0.2,0.112,2.7
+0.4,0.0,2.55
+0.4,-0.224,2.55
+0.224,-0.4,2.55
+0.0,-0.4,2.55
+1.3,0.0,2.55
+1.3,-0.728,2.55
+0.728,-1.3,2.55
+0.0,-1.3,2.55
+1.3,0.0,2.4
+1.3,-0.728,2.4
+0.728,-1.3,2.4
+0.0,-1.3,2.4
+-0.224,-0.4,2.55
+-0.4,-0.224,2.55
+-0.4,0.0,2.55
+-0.728,-1.3,2.55
+-1.3,-0.728,2.55
+-1.3,0.0,2.55
+-0.728,-1.3,2.4
+-1.3,-0.728,2.4
+-1.3,0.0,2.4
+-0.4,0.224,2.55
+-0.224,0.4,2.55
+0.0,0.4,2.55
+-1.3,0.728,2.55
+-0.728,1.3,2.55
+0.0,1.3,2.55
+-1.3,0.728,2.4
+-0.728,1.3,2.4
+0.0,1.3,2.4
+0.224,0.4,2.55
+0.4,0.224,2.55
+0.728,1.3,2.55
+1.3,0.728,2.55
+0.728,1.3,2.4
+1.3,0.728,2.4
+0.0,0.0,0.0,0.0,0.0,-1.0
+1.5,0.0,0.15
+1.5,0.84,0.15
+0.84,1.5,0.15
+0.0,1.5,0.15
+1.5,0.0,0.075
+1.5,0.84,0.075
+0.84,1.5,0.075
+0.0,1.5,0.075
+1.425,0.0,0.0
+1.425,0.798,0.0
+0.798,1.425,0.0
+0.0,1.425,0.0
+-0.84,1.5,0.15
+-1.5,0.84,0.15
+-1.5,0.0,0.15
+-0.84,1.5,0.075
+-1.5,0.84,0.075
+-1.5,0.0,0.075
+-0.798,1.425,0.0
+-1.425,0.798,0.0
+-1.425,0.0,0.0
+-1.5,-0.84,0.15
+-0.84,-1.5,0.15
+0.0,-1.5,0.15
+-1.5,-0.84,0.075
+-0.84,-1.5,0.075
+0.0,-1.5,0.075
+-1.425,-0.798,0.0
+-0.798,-1.425,0.0
+0.0,-1.425,0.0
+0.84,-1.5,0.15
+1.5,-0.84,0.15
+0.84,-1.5,0.075
+1.5,-0.84,0.075
+0.798,-1.425,0.0
+1.425,-0.798,0.0
diff --git a/examples/basket/basketview.cpp b/examples/basket/basketview.cpp
new file mode 100644
index 000000000..41b20dfbb
--- /dev/null
+++ b/examples/basket/basketview.cpp
@@ -0,0 +1,93 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtQuick3D examples of the Qt Toolkit.
+**
+** $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 Nokia Corporation and its Subsidiary(-ies) 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 <QPropertyAnimation>
+
+#include "basketview.h"
+#include "basket_data.h"
+#include "qglbuilder.h"
+#include "qglscenenode.h"
+
+BasketView::BasketView(QWidget *parent)
+ : QGLView(parent)
+ , m_angle(0)
+{
+ setWindowTitle(tr("Basket"));
+
+//! [1]
+ QGLBuilder builder;
+ builder << BasketPatches();
+ basket = builder.finalizedSceneNode();
+
+ QGLMaterial *mat = new QGLMaterial;
+ QUrl url;
+ url.setPath(QLatin1String(":/basket.jpg"));
+ url.setScheme(QLatin1String("file"));
+ mat->setTextureUrl(url);
+ basket->setMaterial(mat);
+ basket->setEffect(QGL::LitModulateTexture2D);
+//! [1]
+
+//! [2]
+ QPropertyAnimation *animation;
+ animation = new QPropertyAnimation(this, "angle", this);
+ animation->setStartValue(0.0f);
+ animation->setEndValue(360.0f);
+ animation->setDuration(2000);
+ animation->setLoopCount(-1);
+ animation->start();
+//! [2]
+
+ camera()->setEye(QVector3D(0, 4, 10));
+}
+
+BasketView::~BasketView()
+{
+ delete basket;
+}
+
+//! [3]
+void BasketView::paintGL(QGLPainter *painter)
+{
+ painter->modelViewMatrix().rotate(angle(), 0, 1, 0);
+ painter->modelViewMatrix().scale(1.5f);
+ basket->draw(painter);
+}
+//! [3]
diff --git a/examples/basket/basketview.h b/examples/basket/basketview.h
new file mode 100644
index 000000000..03a8d61fd
--- /dev/null
+++ b/examples/basket/basketview.h
@@ -0,0 +1,69 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtQuick3D examples of the Qt Toolkit.
+**
+** $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 Nokia Corporation and its Subsidiary(-ies) 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$
+**
+****************************************************************************/
+
+#ifndef BASKETVIEW_H
+#define BASKETVIEW_H
+
+#include "qglview.h"
+
+class QGLSceneNode;
+
+//! [1]
+class BasketView : public QGLView
+{
+ Q_OBJECT
+ Q_PROPERTY(qreal angle READ angle WRITE setAngle)
+public:
+ qreal angle() const { return m_angle; }
+ void setAngle(qreal angle) { m_angle = angle; update(); }
+//! [1]
+
+ BasketView(QWidget *parent = 0);
+ ~BasketView();
+
+protected:
+ void paintGL(QGLPainter *painter);
+
+private:
+ QGLSceneNode *basket;
+ qreal m_angle;
+};
+
+#endif
diff --git a/examples/basket/main.cpp b/examples/basket/main.cpp
new file mode 100644
index 000000000..c8d28193d
--- /dev/null
+++ b/examples/basket/main.cpp
@@ -0,0 +1,57 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtQuick3D examples of the Qt Toolkit.
+**
+** $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 Nokia Corporation and its Subsidiary(-ies) 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 <QApplication>
+#include "basketview.h"
+
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+ BasketView view;
+ if (view.stereoType() != QGLView::RedCyanAnaglyph)
+ view.camera()->setEyeSeparation(0.3f);
+ if (QApplication::arguments().contains(QLatin1String("-maximize")))
+ view.showMaximized();
+ else if (QApplication::arguments().contains(QLatin1String("-fullscreen")))
+ view.showFullScreen();
+ else
+ view.show();
+ return app.exec();
+}
diff --git a/examples/builder/builder.cpp b/examples/builder/builder.cpp
new file mode 100644
index 000000000..3628b4d43
--- /dev/null
+++ b/examples/builder/builder.cpp
@@ -0,0 +1,192 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtQuick3D examples of the Qt Toolkit.
+**
+** $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 Nokia Corporation and its Subsidiary(-ies) 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 "builder.h"
+#include "qglbuilder.h"
+#include "qglmaterialcollection.h"
+#include "qgltexture2d.h"
+#include "qglmaterial.h"
+#include "qglscenenode.h"
+#include "qgllightmodel.h"
+
+#include <QtGui/qmatrix4x4.h>
+
+#include <QtCore/qmath.h>
+
+BuilderView::BuilderView(QWidget *parent)
+ : QGLView(parent)
+ , canScene(new QGLSceneNode(this))
+{
+ //! [0]
+ QGLSceneNode *can = buildGeometry();
+ canScene->addNode(can);
+ {
+ // rotate the can around so its label shows; and down
+ // so the base is facing down
+ QMatrix4x4 mat;
+ QQuaternion q1 = QQuaternion::fromAxisAndAngle(1.0f, 0.0f, 0.0f, 270.0f);
+ QQuaternion q2 = QQuaternion::fromAxisAndAngle(0.0f, 1.0f, 0.0f, 100.0f);
+ mat.rotate(q2 * q1);
+ can->setLocalTransform(mat);
+ }
+
+ // display a copy of the can to the left
+ QGLSceneNode *node = new QGLSceneNode(canScene);
+ node->addNode(can);
+ {
+ QMatrix4x4 mat;
+ mat.translate(-2.0f, 0.0f, -2.0f);
+ node->setLocalTransform(mat);
+ }
+
+ // display a copy of the can to the right
+ node = new QGLSceneNode(canScene);
+ node->addNode(can);
+ {
+ QMatrix4x4 mat;
+ mat.translate(2.0f, 0.0f, -2.0f);
+ node->setLocalTransform(mat);
+ }
+ //! [0]
+
+ // rotate the whole scene about x-axis so that
+ // can tops are visible when scene is first displayed
+ {
+ QMatrix4x4 mat;
+ mat.rotate(1.0f, 0.0f, 0.0f, -30.0f);
+ canScene->setLocalTransform(mat);
+ }
+}
+
+BuilderView::~BuilderView()
+{
+ delete canScene;
+}
+
+void BuilderView::initializeGL(QGLPainter *painter)
+{
+ QGLLightParameters *light0 = new QGLLightParameters(this);
+ light0->setAmbientColor(Qt::white);
+ light0->setDiffuseColor(Qt::white);
+ light0->setDirection(QVector3D(0.0f, 0.2f, 2.0f));
+ painter->setMainLight(light0);
+ QGLLightModel *model = new QGLLightModel(this);
+ model->setAmbientSceneColor(Qt::white);
+ painter->setLightModel(model);
+}
+
+//! [1]
+void BuilderView::paintGL(QGLPainter *painter)
+{
+ canScene->draw(painter);
+}
+//! [1]
+
+QGLSceneNode *BuilderView::buildGeometry()
+{
+ //! [2]
+ QGLBuilder builder;
+ QGLSceneNode *root = builder.sceneNode();
+
+ QGLMaterial *mat = new QGLMaterial;
+ mat->setAmbientColor(Qt::lightGray);
+ mat->setDiffuseColor(Qt::lightGray);
+ QUrl url;
+ url.setPath(QLatin1String(":/images/qt-soup.png"));
+ url.setScheme(QLatin1String("file"));
+ mat->setTextureUrl(url);
+ int canMat = root->palette()->addMaterial(mat);
+ root->setMaterialIndex(canMat);
+ root->setEffect(QGL::LitMaterial);
+ //! [2]
+
+ // size data for can
+ const qreal canRadius = 1.0f;
+ const qreal canHeight = 2.5f;
+ const int numSlices = 32;
+
+ QGeometryData canRim;
+ QVector3D canExtrudeVec(0.0f, 0.0f, -canHeight);
+
+ // do the math for the defining points
+ for (int i = 0; i < numSlices; ++i)
+ {
+ qreal angle = (qreal(i) * 2.0 * M_PI) / numSlices;
+ canRim.appendVertex(QVector3D(canRadius * qCos(angle),
+ canRadius * qSin(angle),
+ canHeight / 2.0f));
+ }
+
+ //! [3]
+ // create the flat top lid of the can
+ builder.newSection();
+ builder.currentNode()->setObjectName(QLatin1String("CanTop"));
+ QGeometryData top;
+ top.appendVertex(canRim.center());
+ top.appendVertexArray(canRim.vertices());
+ builder.addTriangulatedFace(top);
+
+ // create the sides of the can
+ builder.newSection();
+ builder.currentNode()->setObjectName(QLatin1String("CanSides"));
+ builder.currentNode()->setMaterialIndex(canMat);
+ builder.currentNode()->setEffect(QGL::LitModulateTexture2D);
+ QGeometryData canTop = canRim;
+ canTop.detach();
+ canTop.appendVertex(canTop.vertex(0)); // doubled vert for texture seam
+ canTop.generateTextureCoordinates(); // generate x texture coords
+ QGeometryData canBase = canTop.translated(canExtrudeVec); // base has tex.y == 0
+ for (int i = 0; i < canTop.count(); ++i)
+ canTop.texCoord(i).setY(1.0); // top has tex.y == 1
+ builder.addQuadsInterleaved(canTop, canBase);
+
+ // create the flat bottom lid of the can
+ builder.newSection();
+ builder.currentNode()->setObjectName(QLatin1String("CanBottom"));
+ builder.currentNode()->setEffect(QGL::LitMaterial);
+ QGeometryData rimReversed = canRim.translated(canExtrudeVec).reversed();
+ QGeometryData canBottom;
+ canBottom.appendVertex(rimReversed.center());
+ canBottom.appendVertexArray(rimReversed.vertices());
+ builder.addTriangulatedFace(canBottom);
+
+ return builder.finalizedSceneNode();
+ //! [3]
+}
diff --git a/examples/builder/builder.h b/examples/builder/builder.h
new file mode 100644
index 000000000..a54dea6bf
--- /dev/null
+++ b/examples/builder/builder.h
@@ -0,0 +1,66 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtQuick3D examples of the Qt Toolkit.
+**
+** $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 Nokia Corporation and its Subsidiary(-ies) 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$
+**
+****************************************************************************/
+
+#ifndef BUILDER_H
+#define BUILDER_H
+
+#include "qglview.h"
+
+class QGLSceneNode;
+class QGLBuilder;
+
+class BuilderView : public QGLView
+{
+ Q_OBJECT
+public:
+ BuilderView(QWidget *parent = 0);
+ ~BuilderView();
+
+protected:
+ void initializeGL(QGLPainter *painter);
+ void paintGL(QGLPainter *painter);
+
+private:
+ QGLSceneNode *buildGeometry();
+
+ QGLSceneNode *canScene;
+};
+
+#endif
diff --git a/examples/builder/builder.pro b/examples/builder/builder.pro
new file mode 100644
index 000000000..2fac6f330
--- /dev/null
+++ b/examples/builder/builder.pro
@@ -0,0 +1,8 @@
+TEMPLATE = app
+TARGET = builder
+CONFIG += qt warn_on qt3d
+SOURCES = builder.cpp \
+ main.cpp
+HEADERS = builder.h
+DESTDIR = ../../bin
+RESOURCES += builder.qrc
diff --git a/examples/builder/builder.qrc b/examples/builder/builder.qrc
new file mode 100644
index 000000000..8eefbaf1d
--- /dev/null
+++ b/examples/builder/builder.qrc
@@ -0,0 +1,5 @@
+<RCC>
+ <qresource prefix="/images" >
+ <file>qt-soup.png</file>
+ </qresource>
+</RCC>
diff --git a/examples/builder/main.cpp b/examples/builder/main.cpp
new file mode 100644
index 000000000..ade7d1008
--- /dev/null
+++ b/examples/builder/main.cpp
@@ -0,0 +1,58 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtQuick3D examples of the Qt Toolkit.
+**
+** $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 Nokia Corporation and its Subsidiary(-ies) 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 <QApplication>
+
+#include "builder.h"
+
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+ BuilderView view;
+ if (view.stereoType() != QGLView::RedCyanAnaglyph)
+ view.camera()->setEyeSeparation(0.3f);
+ if (QApplication::arguments().contains(QLatin1String("-maximize")))
+ view.showMaximized();
+ else if (QApplication::arguments().contains(QLatin1String("-fullscreen")))
+ view.showFullScreen();
+ else
+ view.show();
+ return app.exec();
+}
diff --git a/examples/builder/qt-soup.png b/examples/builder/qt-soup.png
new file mode 100644
index 000000000..5b264fffa
--- /dev/null
+++ b/examples/builder/qt-soup.png
Binary files differ
diff --git a/examples/cube/cube.pro b/examples/cube/cube.pro
new file mode 100644
index 000000000..ec2bc6967
--- /dev/null
+++ b/examples/cube/cube.pro
@@ -0,0 +1,7 @@
+TEMPLATE = app
+TARGET = cube
+CONFIG += qt warn_on qt3d
+SOURCES = cubeview.cpp main.cpp
+HEADERS = cubeview.h
+RESOURCES = cube.qrc
+DESTDIR = ../../bin
diff --git a/examples/cube/cube.qrc b/examples/cube/cube.qrc
new file mode 100644
index 000000000..70f5024d9
--- /dev/null
+++ b/examples/cube/cube.qrc
@@ -0,0 +1,5 @@
+<!DOCTYPE RCC><RCC version="1.0">
+<qresource>
+ <file>qtlogo.png</file>
+</qresource>
+</RCC>
diff --git a/examples/cube/cubeview.cpp b/examples/cube/cubeview.cpp
new file mode 100644
index 000000000..e8de75168
--- /dev/null
+++ b/examples/cube/cubeview.cpp
@@ -0,0 +1,74 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtQuick3D examples of the Qt Toolkit.
+**
+** $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 Nokia Corporation and its Subsidiary(-ies) 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 "cubeview.h"
+#include "qglbuilder.h"
+#include "qglcube.h"
+
+#include <QtCore/qurl.h>
+
+CubeView::CubeView(QWidget *parent)
+ : QGLView(parent)
+{
+ QGLBuilder builder;
+ builder << QGL::Faceted << QGLCube(1.5f);
+ cube = builder.finalizedSceneNode();
+
+ QGLMaterial *mat = new QGLMaterial;
+ mat->setColor(QColor(170, 202, 0));
+ QUrl url;
+ url.setPath(QLatin1String(":/qtlogo.png"));
+ url.setScheme(QLatin1String("file"));
+ mat->setTextureUrl(url);
+ cube->setMaterial(mat);
+
+ cube->setEffect(QGL::LitDecalTexture2D);
+}
+
+CubeView::~CubeView()
+{
+ delete cube;
+}
+
+void CubeView::paintGL(QGLPainter *painter)
+{
+ painter->modelViewMatrix().rotate(45.0f, 1.0f, 1.0f, 1.0f);
+ cube->draw(painter);
+}
diff --git a/examples/cube/cubeview.h b/examples/cube/cubeview.h
new file mode 100644
index 000000000..8996fd342
--- /dev/null
+++ b/examples/cube/cubeview.h
@@ -0,0 +1,62 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtQuick3D examples of the Qt Toolkit.
+**
+** $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 Nokia Corporation and its Subsidiary(-ies) 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$
+**
+****************************************************************************/
+
+#ifndef CUBEVIEW_H
+#define CUBEVIEW_H
+
+#include "qglview.h"
+
+class QGLSceneNode;
+
+class CubeView : public QGLView
+{
+ Q_OBJECT
+public:
+ CubeView(QWidget *parent = 0);
+ ~CubeView();
+
+protected:
+ void paintGL(QGLPainter *painter);
+
+private:
+ QGLSceneNode *cube;
+};
+
+#endif
diff --git a/examples/cube/main.cpp b/examples/cube/main.cpp
new file mode 100644
index 000000000..1def235d5
--- /dev/null
+++ b/examples/cube/main.cpp
@@ -0,0 +1,57 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtQuick3D examples of the Qt Toolkit.
+**
+** $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 Nokia Corporation and its Subsidiary(-ies) 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 <QApplication>
+#include "cubeview.h"
+
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+ CubeView view;
+ if (view.stereoType() != QGLView::RedCyanAnaglyph)
+ view.camera()->setEyeSeparation(0.3f);
+ if (QApplication::arguments().contains(QLatin1String("-maximize")))
+ view.showMaximized();
+ else if (QApplication::arguments().contains(QLatin1String("-fullscreen")))
+ view.showFullScreen();
+ else
+ view.show();
+ return app.exec();
+}
diff --git a/examples/cube/qtlogo.png b/examples/cube/qtlogo.png
new file mode 100644
index 000000000..7d3e97eb3
--- /dev/null
+++ b/examples/cube/qtlogo.png
Binary files differ
diff --git a/examples/cylinder/cubeview.cpp b/examples/cylinder/cubeview.cpp
new file mode 100644
index 000000000..4569caeb0
--- /dev/null
+++ b/examples/cylinder/cubeview.cpp
@@ -0,0 +1,77 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtQuick3D examples of the Qt Toolkit.
+**
+** $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 Nokia Corporation and its Subsidiary(-ies) 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 "cubeview.h"
+#include "qglbuilder.h"
+#include "qglcube.h"
+#include "qglcylinder.h"
+
+#include <QtCore/qurl.h>
+
+CubeView::CubeView(QWidget *parent)
+ : QGLView(parent)
+{
+ QGLBuilder builder;
+ builder << QGL::Smooth << QGLCylinder(2.0, 1.5, 2.0, 36, 3);
+ cube = builder.finalizedSceneNode();
+
+ QGLMaterial *mat = new QGLMaterial;
+ mat->setColor(QColor(170, 202, 0));
+ QUrl url;
+ url.setPath(QLatin1String(":/cupTexture.png"));
+ url.setScheme(QLatin1String("file"));
+ mat->setTextureUrl(url);
+ cube->setMaterial(mat);
+
+ cube->setEffect(QGL::LitDecalTexture2D);
+}
+
+CubeView::~CubeView()
+{
+ delete cube;
+}
+
+void CubeView::paintGL(QGLPainter *painter)
+{
+ painter->modelViewMatrix().translate(0.0f, -1.0f, 0.0f);
+ painter->modelViewMatrix().rotate(-75.0f, 1.0f, 0.0f, 0.0f);
+ cube->draw(painter);
+}
diff --git a/examples/cylinder/cubeview.h b/examples/cylinder/cubeview.h
new file mode 100644
index 000000000..8996fd342
--- /dev/null
+++ b/examples/cylinder/cubeview.h
@@ -0,0 +1,62 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtQuick3D examples of the Qt Toolkit.
+**
+** $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 Nokia Corporation and its Subsidiary(-ies) 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$
+**
+****************************************************************************/
+
+#ifndef CUBEVIEW_H
+#define CUBEVIEW_H
+
+#include "qglview.h"
+
+class QGLSceneNode;
+
+class CubeView : public QGLView
+{
+ Q_OBJECT
+public:
+ CubeView(QWidget *parent = 0);
+ ~CubeView();
+
+protected:
+ void paintGL(QGLPainter *painter);
+
+private:
+ QGLSceneNode *cube;
+};
+
+#endif
diff --git a/examples/cylinder/cupTexture.png b/examples/cylinder/cupTexture.png
new file mode 100644
index 000000000..e099dea22
--- /dev/null
+++ b/examples/cylinder/cupTexture.png
Binary files differ
diff --git a/examples/cylinder/cylinder.pro b/examples/cylinder/cylinder.pro
new file mode 100644
index 000000000..ee018cb9d
--- /dev/null
+++ b/examples/cylinder/cylinder.pro
@@ -0,0 +1,7 @@
+TEMPLATE = app
+TARGET = cylinder
+CONFIG += qt warn_on qt3d
+SOURCES = cylinderview.cpp main.cpp
+HEADERS = cylinderview.h
+RESOURCES = cylinder.qrc
+DESTDIR = ../../bin
diff --git a/examples/cylinder/cylinder.qrc b/examples/cylinder/cylinder.qrc
new file mode 100644
index 000000000..20fa400f7
--- /dev/null
+++ b/examples/cylinder/cylinder.qrc
@@ -0,0 +1,6 @@
+<RCC>
+ <qresource prefix="/">
+ <file>latte.png</file>
+ <file>cupTexture.png</file>
+ </qresource>
+</RCC>
diff --git a/examples/cylinder/cylinderview.cpp b/examples/cylinder/cylinderview.cpp
new file mode 100644
index 000000000..2b347ab68
--- /dev/null
+++ b/examples/cylinder/cylinderview.cpp
@@ -0,0 +1,101 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtQuick3D examples of the Qt Toolkit.
+**
+** $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 Nokia Corporation and its Subsidiary(-ies) 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 "cylinderview.h"
+#include "qglbuilder.h"
+#include "qglcylinder.h"
+#include <QtCore/qurl.h>
+
+CylinderView::CylinderView(QWidget *parent)
+ : QGLView(parent)
+{
+ QGLBuilder builder;
+ builder << QGL::Smooth << QGLCylinder(2.0, 1.5, 2.0, 36, 3, true, true);
+
+ QGLMaterial *matLid = new QGLMaterial;
+ matLid->setAmbientColor(Qt::gray);
+ matLid->setDiffuseColor(Qt::gray);
+ QUrl urlLid;
+ urlLid.setPath(QLatin1String(":/latte.png"));
+ urlLid.setScheme(QLatin1String("file"));
+ matLid->setTextureUrl(urlLid);
+
+ QGLMaterial *matSides = new QGLMaterial;
+ matSides->setColor(QColor(170, 202, 0));
+ QUrl urlSides;
+ urlSides.setPath(QLatin1String(":/cupTexture.png"));
+ urlSides.setScheme(QLatin1String("file"));
+ matSides->setTextureUrl(urlSides);
+
+ QGLSceneNode *root = builder.sceneNode();
+
+ QGLSceneNode *lid = root->findChild<QGLSceneNode *>("Cylinder Top");
+ int lidMat = root->palette()->addMaterial(matLid);
+ lid->setMaterialIndex(lidMat);
+ lid->setEffect(QGL::LitDecalTexture2D);
+
+ QGLSceneNode *sides = root->findChild<QGLSceneNode *>("Cylinder Sides");
+ int sideMat = root->palette()->addMaterial(matSides);
+ sides->setMaterialIndex(sideMat);
+ sides->setEffect(QGL::LitDecalTexture2D);
+
+
+ cylinder = builder.finalizedSceneNode();
+
+ QGLMaterial *mat = new QGLMaterial;
+ mat->setAmbientColor(Qt::gray);
+ mat->setDiffuseColor(Qt::gray);
+ cylinder->setMaterial(mat);
+ cylinder->setEffect(QGL::LitMaterial);
+}
+
+CylinderView::~CylinderView()
+{
+ delete cylinder;
+}
+
+void CylinderView::paintGL(QGLPainter *painter)
+{
+ painter->modelViewMatrix().translate(0.0f, -1.0f, 0.0f);
+ painter->modelViewMatrix().rotate(-75.0f, 1.0f, 0.0f, 0.0f);
+ cylinder->draw(painter);
+}
+
diff --git a/examples/cylinder/cylinderview.h b/examples/cylinder/cylinderview.h
new file mode 100644
index 000000000..c2f4824b9
--- /dev/null
+++ b/examples/cylinder/cylinderview.h
@@ -0,0 +1,62 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtQuick3D examples of the Qt Toolkit.
+**
+** $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 Nokia Corporation and its Subsidiary(-ies) 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$
+**
+****************************************************************************/
+
+#ifndef CYLINDERVIEW_H
+#define CYLINDERVIEW_H
+
+#include "qglview.h"
+
+class QGLSceneNode;
+
+class CylinderView : public QGLView
+{
+ Q_OBJECT
+public:
+ CylinderView(QWidget *parent = 0);
+ ~CylinderView();
+
+protected:
+ void paintGL(QGLPainter *painter);
+
+private:
+ QGLSceneNode *cylinder;
+};
+
+#endif
diff --git a/examples/cylinder/latte.png b/examples/cylinder/latte.png
new file mode 100644
index 000000000..6902b96c6
--- /dev/null
+++ b/examples/cylinder/latte.png
Binary files differ
diff --git a/examples/cylinder/main.cpp b/examples/cylinder/main.cpp
new file mode 100644
index 000000000..5ea06b74e
--- /dev/null
+++ b/examples/cylinder/main.cpp
@@ -0,0 +1,57 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtQuick3D examples of the Qt Toolkit.
+**
+** $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 Nokia Corporation and its Subsidiary(-ies) 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 <QApplication>
+#include "cylinderview.h"
+
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+ CylinderView view;
+ if (view.stereoType() != QGLView::RedCyanAnaglyph)
+ view.camera()->setEyeSeparation(0.3f);
+ if (QApplication::arguments().contains(QLatin1String("-maximize")))
+ view.showMaximized();
+ else if (QApplication::arguments().contains(QLatin1String("-fullscreen")))
+ view.showFullScreen();
+ else
+ view.show();
+ return app.exec();
+}
diff --git a/examples/examples.pro b/examples/examples.pro
new file mode 100644
index 000000000..a25bb6e91
--- /dev/null
+++ b/examples/examples.pro
@@ -0,0 +1,2 @@
+TEMPLATE = subdirs
+SUBDIRS += basket builder cube cylinder geometry graphicsview nesting tank teapot tutorials
diff --git a/examples/geometry/EarthFlat_512x512.jpg b/examples/geometry/EarthFlat_512x512.jpg
new file mode 100644
index 000000000..28864977b
--- /dev/null
+++ b/examples/geometry/EarthFlat_512x512.jpg
Binary files differ
diff --git a/examples/geometry/bullseye.png b/examples/geometry/bullseye.png
new file mode 100644
index 000000000..e67cf7038
--- /dev/null
+++ b/examples/geometry/bullseye.png
Binary files differ
diff --git a/examples/geometry/geometry.cpp b/examples/geometry/geometry.cpp
new file mode 100644
index 000000000..c8f262c14
--- /dev/null
+++ b/examples/geometry/geometry.cpp
@@ -0,0 +1,201 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtQuick3D examples of the Qt Toolkit.
+**
+** $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 Nokia Corporation and its Subsidiary(-ies) 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 "geometry.h"
+#include "qgltexture2d.h"
+#include "qglmaterialcollection.h"
+#include "qtriangle3d.h"
+
+#include <QImage>
+#include <QPainter>
+
+// icosahedron is defined by phi, derived from the golden section
+// http://en.wikipedia.org/wiki/Icosahedron#Cartesian_coordinates
+const qreal phi = 1.618033988749894848f;
+
+Geometry::Geometry(QObject *parent, QGLMaterialCollection *materials)
+ : QGLSceneNode(parent)
+{
+ setPalette(materials);
+
+ float ico[12][3] = {
+ { 0.0f, 1.0f, phi }, // A - 0
+ { 0.0f, 1.0f, -phi }, // B - 1
+ { 0.0f, -1.0f, phi }, // C - 2
+ { 0.0f, -1.0f, -phi }, // D - 3
+ { 1.0f, phi, 0.0f }, // E - 4
+ { 1.0f, -phi, 0.0f }, // F - 5
+ { -1.0f, phi, 0.0f }, // G - 6
+ { -1.0f, -phi, 0.0f }, // H - 7
+ { phi, 0.0f, 1.0f }, // I - 8
+ { phi, 0.0f, -1.0f }, // J - 9
+ { -phi, 0.0f, 1.0f }, // K - 10
+ { -phi, 0.0f, -1.0f } // L - 11
+ };
+
+ int face[20][3] = {
+ { 4, 0, 8 }, // E-A-I
+ { 6, 0, 4 }, // G-A-E
+ { 6, 10, 0 }, // G-K-A
+ { 11, 10, 6 }, // L-K-G
+ { 0, 2, 8 }, // A-C-I
+ { 10, 2, 0 }, // K-C-A
+ { 10, 7, 2 }, // K-H-C
+ { 11, 7, 10 }, // L-H-K
+ { 2, 5, 8 }, // C-F-I
+ { 7, 5, 2 }, // H-F-C
+ { 7, 3, 5 }, // H-D-F
+ { 11, 3, 7 }, // L-D-H
+ { 5, 9, 8 }, // F-J-I
+ { 3, 9, 5 }, // D-J-F
+ { 3, 1, 9 }, // D-B-J
+ { 11, 1, 3 }, // L-B-D
+ { 9, 4, 8 }, // J-E-I
+ { 1, 4, 9 }, // B-E-J
+ { 1, 6, 4 }, // B-G-E
+ { 11, 6, 1 } // L-G-B
+ };
+
+ const float u0 = 0.0f;
+ const float u1 = 0.173205081f;
+ const float u2 = 0.346410162f;
+ const float u3 = 0.519615242f;
+ const float u4 = 0.692820323f;
+ const float u5 = 0.866025402f;
+ const float v0 = 0.0f;
+ const float v1 = 0.111111111f;
+ const float v2 = 0.222222222f;
+ const float v3 = 0.333333333f;
+ const float v4 = 0.444444444f;
+ const float v5 = 0.555555555f;
+ const float v6 = 0.666666666f;
+ const float v7 = 0.777777777f;
+ const float v8 = 0.888888888f;
+ const float v9 = 1.0f;
+
+ float tex[20][3][2] = {
+ { { u0, v1 }, { u1, v2 }, { u1, v0 } }, // E-A-I
+ { { u0, v3 }, { u1, v2 }, { u0, v1 } }, // G-A-E
+ { { u0, v3 }, { u1, v4 }, { u1, v2 } }, // G-K-A
+ { { u0, v5 }, { u1, v4 }, { u0, v3 } }, // L-K-G
+ { { u1, v2 }, { u2, v3 }, { u2, v1 } }, // A-C-I
+ { { u1, v4 }, { u2, v3 }, { u1, v2 } }, // K-C-A
+ { { u1, v4 }, { u2, v5 }, { u2, v3 } }, // K-H-C
+ { { u1, v6 }, { u2, v5 }, { u1, v4 } }, // L-H-K
+ { { u2, v3 }, { u3, v4 }, { u3, v2 } }, // C-F-I
+ { { u2, v5 }, { u3, v4 }, { u2, v3 } }, // H-F-C
+ { { u2, v5 }, { u3, v6 }, { u3, v4 } }, // H-D-F
+ { { u2, v7 }, { u3, v6 }, { u2, v5 } }, // L-D-H
+ { { u3, v4 }, { u4, v5 }, { u4, v3 } }, // F-J-I
+ { { u3, v6 }, { u4, v5 }, { u3, v4 } }, // D-J-F
+ { { u3, v6 }, { u4, v7 }, { u4, v5 } }, // D-B-J
+ { { u3, v8 }, { u4, v7 }, { u3, v6 } }, // L-B-D
+ { { u4, v5 }, { u5, v6 }, { u5, v4 } }, // J-E-I
+ { { u4, v7 }, { u5, v6 }, { u4, v5 } }, // B-E-J
+ { { u4, v7 }, { u5, v8 }, { u5, v6 } }, // B-G-E
+ { { u4, v9 }, { u5, v8 }, { u4, v7 } } // L-G-B
+ };
+ QImage uv(1024, 1024, QImage::Format_ARGB32);
+ uv.fill(qRgba(196, 196, 196, 196));
+ QPainter painter;
+ painter.begin(&uv);
+ painter.setRenderHint(QPainter::Antialiasing);
+ QPen pen = painter.pen();
+ pen.setWidth(2.0);
+ painter.setPen(pen);
+ QFont font = painter.font();
+ font.setPointSize(36);
+ painter.setFont(font);
+ QFontMetrics metrics = painter.fontMetrics();
+
+ QGLBuilder b;
+ b.newSection();
+ b.currentNode()->setEffect(QGL::LitDecalTexture2D);
+ for (int ix = 0; ix < 20; ++ix)
+ {
+ QVector3D v0(ico[face[ix][0]][0], ico[face[ix][0]][1], ico[face[ix][0]][2]);
+ QVector3D v1(ico[face[ix][1]][0], ico[face[ix][1]][1], ico[face[ix][1]][2]);
+ QVector3D v2(ico[face[ix][2]][0], ico[face[ix][2]][1], ico[face[ix][2]][2]);
+
+ QVector2D t0(tex[ix][0][0], tex[ix][0][1]);
+ QVector2D t1(tex[ix][1][0], tex[ix][1][1]);
+ QVector2D t2(tex[ix][2][0], tex[ix][2][1]);
+
+ // scale up and flip to draw the texture
+ QVector2D tv0 = t0 * 1024.0;
+ QVector2D tv1 = t1 * 1024.0;
+ QVector2D tv2 = t2 * 1024.0;
+
+ painter.setPen(QColor("darkblue"));
+ painter.drawLine(tv0.toPointF(), tv1.toPointF());
+ painter.drawLine(tv1.toPointF(), tv2.toPointF());
+ painter.drawLine(tv2.toPointF(), tv0.toPointF());
+ QTriangle3D tri(tv0, tv1, tv2);
+ QVector3D cen = tri.center();
+ QString n = QString::number(ix+1);
+
+ painter.setPen(QColor("darkgreen"));
+ painter.drawText(QPointF(cen.x() - metrics.width(n) / 2.0, cen.y() + 3.0), n);
+
+ // Qt's coordinate system is upside down. I'm ok with that.
+ t0.setY(1.0f - t0.y());
+ t1.setY(1.0f - t1.y());
+ t2.setY(1.0f - t2.y());
+
+ QGeometryData op;
+ op.appendVertex(v0, v1, v2);
+ op.appendTexCoord(t0, t1, t2);
+ b.addTriangles(op);
+ }
+
+ painter.end();
+
+ QGLMaterial *mat = new QGLMaterial;
+ mat->setAmbientColor(QColor(32, 64, 196));
+ mat->setDiffuseColor(QColor(32, 32, 32));
+
+ QGLTexture2D *texture = new QGLTexture2D(mat);
+ texture->setImage(uv);
+ mat->setTexture(texture);
+
+ setMaterial(mat);
+ QGLSceneNode *n = b.finalizedSceneNode();
+ addNode(n);
+}
diff --git a/examples/geometry/geometry.h b/examples/geometry/geometry.h
new file mode 100644
index 000000000..f9a356fc8
--- /dev/null
+++ b/examples/geometry/geometry.h
@@ -0,0 +1,56 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtQuick3D examples of the Qt Toolkit.
+**
+** $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 Nokia Corporation and its Subsidiary(-ies) 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$
+**
+****************************************************************************/
+
+#ifndef GEOMETRY_H
+#define GEOMETRY_H
+
+#include "qglbuilder.h"
+
+#include <QImage>
+
+class QGLTexture2D;
+
+class Geometry : public QGLSceneNode
+{
+public:
+ Geometry(QObject *parent = 0, QGLMaterialCollection *materials = 0);
+};
+
+#endif // GEOMETRY_H
diff --git a/examples/geometry/geometry.pro b/examples/geometry/geometry.pro
new file mode 100644
index 000000000..66025be88
--- /dev/null
+++ b/examples/geometry/geometry.pro
@@ -0,0 +1,12 @@
+TEMPLATE = app
+TARGET = geometry
+CONFIG += qt warn_on qt3d
+SOURCES = geometryview.cpp \
+ main.cpp \
+ geometry.cpp \
+ quadplane.cpp
+HEADERS = geometryview.h \
+ geometry.h \
+ quadplane.h
+RESOURCES = geometry.qrc
+DESTDIR = ../../bin
diff --git a/examples/geometry/geometry.qrc b/examples/geometry/geometry.qrc
new file mode 100644
index 000000000..4599a46ad
--- /dev/null
+++ b/examples/geometry/geometry.qrc
@@ -0,0 +1,6 @@
+<RCC>
+ <qresource prefix="/" >
+ <file>bullseye.png</file>
+ <file>EarthFlat_512x512.jpg</file>
+ </qresource>
+</RCC>
diff --git a/examples/geometry/geometryview.cpp b/examples/geometry/geometryview.cpp
new file mode 100644
index 000000000..762e56fcd
--- /dev/null
+++ b/examples/geometry/geometryview.cpp
@@ -0,0 +1,122 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtQuick3D examples of the Qt Toolkit.
+**
+** $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 Nokia Corporation and its Subsidiary(-ies) 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 "geometryview.h"
+#include "qray3d.h"
+
+#include <QImage>
+#include <QPainter>
+#include <QDir>
+#include <QTimer>
+#include <QWheelEvent>
+
+#include <math.h>
+
+#include "geometry.h"
+#include "quadplane.h"
+#include "qplane3d.h"
+#include "qglmaterialcollection.h"
+#include "qgraphicsscale3d.h"
+
+GeometryView::GeometryView(QWidget *parent)
+ : QGLView(parent)
+ , timer(new QTimer(this))
+{
+ lp = new QGLLightParameters(this);
+ lp->setPosition(QVector3D(-3.0, 1.0, 15.0));
+ lp->setSpotAngle(15.0);
+ lp->setSpotExponent(24);
+ lp->setSpotDirection(QVector3D(0.0, -1.0, -2.0));
+
+ palette = new QGLMaterialCollection(this);
+
+ // first set up the geometry - an icosahedron
+ // this one handles all its own colors and textures
+ icosahedron = new Geometry(this, palette);
+
+ // now a generic flat floor plane which will be painted grey
+ // and textured the same as the icosahedron
+ floor = new QuadPlane(this);
+ floor->setPalette(palette);
+ QGLMaterial *parms = new QGLMaterial;
+ parms->setAmbientColor(Qt::darkGray);
+ parms->setDiffuseColor(Qt::gray);
+ int m = palette->addMaterial(parms);
+ QGLTexture2D *tex = icosahedron->material()->texture();
+ parms->setTexture(tex);
+ floor->setMaterialIndex(m);
+ floor->setPosition(QVector3D(0, 0, -5));
+ QGraphicsScale3D *scale = new QGraphicsScale3D(floor);
+ scale->setScale(QVector3D(0.2, 0.2, 0.1));
+ floor->addTransform(scale);
+
+ mdl = new QGLLightModel(this);
+ mdl->setAmbientSceneColor(QColor(196,196,196));
+}
+
+GeometryView::~GeometryView()
+{
+ delete icosahedron;
+ delete floor;
+ delete timer;
+}
+
+void GeometryView::initializeGL(QGLPainter *painter)
+{
+ painter->setLightModel(mdl);
+
+ painter->setMainLight(lp);
+
+ connect(timer, SIGNAL(timeout()), this, SLOT(rotate()));
+ timer->start(25);
+}
+
+void GeometryView::paintGL(QGLPainter *painter)
+{
+ floor->draw(painter);
+ painter->modelViewMatrix().rotate(angle, 0.10f, 1.0f, 0.0f);
+ icosahedron->draw(painter);
+}
+
+void GeometryView::rotate()
+{
+ angle = (angle + 2) % 360;
+ updateGL();
+}
diff --git a/examples/geometry/geometryview.h b/examples/geometry/geometryview.h
new file mode 100644
index 000000000..822a7a409
--- /dev/null
+++ b/examples/geometry/geometryview.h
@@ -0,0 +1,85 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtQuick3D examples of the Qt Toolkit.
+**
+** $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 Nokia Corporation and its Subsidiary(-ies) 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$
+**
+****************************************************************************/
+
+#ifndef GEOMETRYVIEW_H
+#define GEOMETRYVIEW_H
+
+#include "qglview.h"
+#include "qgltexture2d.h"
+
+class QTimer;
+class QuadPlane;
+class Geometry;
+class QGLLightParameters;
+class QGLMaterial;
+class QGLLightModel;
+class QGLMaterialCollection;
+class QWheelEvent;
+
+class GeometryView : public QGLView
+{
+ Q_OBJECT
+public:
+ GeometryView(QWidget *parent = 0);
+ ~GeometryView();
+
+protected:
+ void initializeGL(QGLPainter *painter);
+ void paintGL(QGLPainter *painter);
+
+private slots:
+ void rotate();
+
+private:
+ void makeTexture();
+
+ QGLTexture2D texture;
+ Geometry *icosahedron;
+ QuadPlane *floor;
+ QTimer *timer;
+ int angle;
+ QGLLightParameters *lp;
+ QGLMaterialCollection *palette;
+ QGLMaterial *mat1;
+ QGLMaterial *mat2;
+ QGLLightModel *mdl;
+};
+
+#endif // GEOMETRYVIEW_H
diff --git a/examples/geometry/main.cpp b/examples/geometry/main.cpp
new file mode 100644
index 000000000..9ec88be7b
--- /dev/null
+++ b/examples/geometry/main.cpp
@@ -0,0 +1,55 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtQuick3D examples of the Qt Toolkit.
+**
+** $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 Nokia Corporation and its Subsidiary(-ies) 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 <QApplication>
+#include "geometryview.h"
+
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+ GeometryView view;
+ if (QApplication::arguments().contains(QLatin1String("-maximize")))
+ view.showMaximized();
+ else if (QApplication::arguments().contains(QLatin1String("-fullscreen")))
+ view.showFullScreen();
+ else
+ view.show();
+ return app.exec();
+}
diff --git a/examples/geometry/quadplane.cpp b/examples/geometry/quadplane.cpp
new file mode 100644
index 000000000..3387002bc
--- /dev/null
+++ b/examples/geometry/quadplane.cpp
@@ -0,0 +1,92 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtQuick3D examples of the Qt Toolkit.
+**
+** $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 Nokia Corporation and its Subsidiary(-ies) 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 "quadplane.h"
+
+/*!
+ \class QuadPlane
+ \brief The QuadPlane class holds a 3D model of a large flat plane.
+ When drawing a large flat plane, such as a wall or a floor, it is desirable
+ to decompose it into smaller units to make the shading effects look correct.
+ This class composes a plane out of a configurable number of quads.
+*/
+
+/*!
+ Construct a new QuadPlane with \a size, subdivided \a level times. By default
+ the plane is 100.0f x 100.0f, and is subdivided 3 times - that is into an
+ 8 x 8 grid.
+
+ It is centered on the origin, and lies in the z = 0 plane.
+*/
+QuadPlane::QuadPlane(QObject *parent, QSizeF size, int level)
+ : QGLSceneNode(parent)
+{
+ setObjectName(QLatin1String("QuadPlane"));
+ if (level > 8)
+ level = 8;
+ if (level < 1)
+ level = 1;
+ int divisions = 1;
+ for ( ; level--; divisions *= 2) {} // integer 2**n
+ QSizeF div = size / float(divisions);
+ QSizeF half = size / 2.0f;
+ QGLBuilder builder;
+ QGeometryData zip;
+ QGeometryData zip2;
+ for (int yy = 0; yy <= divisions; ++yy)
+ {
+ qreal y = half.height() - float(yy) * div.height();
+ qreal texY = float(yy) / divisions;
+ for (int xx = 0; xx <= divisions; ++xx)
+ {
+ qreal x = half.width() - float(xx) * div.width();
+ qreal texX = float(xx) / divisions;
+ zip.appendVertex(QVector3D(x, y, 0));
+ zip.appendTexCoord(QVector2D(1.0f - texX, 1.0f - texY));
+ }
+ if (yy > 0)
+ builder.addQuadsInterleaved(zip, zip2);
+ zip2 = zip;
+ zip2.detach();
+ zip.clear();
+ }
+ QGLSceneNode *n = builder.finalizedSceneNode();
+ addNode(n);
+}
diff --git a/examples/geometry/quadplane.h b/examples/geometry/quadplane.h
new file mode 100644
index 000000000..e95d1907f
--- /dev/null
+++ b/examples/geometry/quadplane.h
@@ -0,0 +1,57 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtQuick3D examples of the Qt Toolkit.
+**
+** $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 Nokia Corporation and its Subsidiary(-ies) 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$
+**
+****************************************************************************/
+
+#ifndef QUADPLANE_H
+#define QUADPLANE_H
+
+#include "qglbuilder.h"
+
+#include <QSizeF>
+
+class QPlane3D;
+
+class QuadPlane : public QGLSceneNode
+{
+public:
+ QuadPlane(QObject *parent = 0,
+ QSizeF size = QSizeF(100.0f, 100.0f), int level = 3);
+};
+
+#endif // QUADPLANE_H
diff --git a/examples/graphicsview/cubeicon.png b/examples/graphicsview/cubeicon.png
new file mode 100644
index 000000000..9979fb582
--- /dev/null
+++ b/examples/graphicsview/cubeicon.png
Binary files differ
diff --git a/examples/graphicsview/cubeitem.cpp b/examples/graphicsview/cubeitem.cpp
new file mode 100644
index 000000000..10c7609f8
--- /dev/null
+++ b/examples/graphicsview/cubeitem.cpp
@@ -0,0 +1,193 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtQuick3D examples of the Qt Toolkit.
+**
+** $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 Nokia Corporation and its Subsidiary(-ies) 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 "cubeitem.h"
+#include "qglpainter.h"
+#include "qglcube.h"
+#include "qray3d.h"
+#include "qplane3d.h"
+#include "qtriangle3d.h"
+#include "qgraphicsembedscene.h"
+
+const qreal CubeSize = 2.0f;
+
+CubeItem::CubeItem(QGraphicsItem *parent)
+ : ModelItem(parent)
+{
+ QGLBuilder builder;
+ builder.newSection(QGL::Faceted);
+ builder << QGLCube(CubeSize);
+ cube = builder.finalizedSceneNode();
+}
+
+CubeItem::~CubeItem()
+{
+ delete cube;
+}
+
+void CubeItem::paintGL(QGLPainter *painter)
+{
+ GLuint textureId = this->textureId();
+ if (textureId) {
+ glDisable(GL_DEPTH_TEST);
+ glEnable(GL_BLEND);
+ painter->setFaceColor(QGL::AllFaces, QColor(0, 0, 0, 200));
+ painter->setStandardEffect(QGL::LitDecalTexture2D);
+ glBindTexture(GL_TEXTURE_2D, textureId);
+ glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
+ glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
+ if (painter->isFixedFunction())
+ glEnable(GL_TEXTURE_2D);
+ glCullFace(GL_FRONT);
+ glEnable(GL_CULL_FACE);
+ cube->draw(painter);
+ glCullFace(GL_BACK);
+ cube->draw(painter);
+ glDisable(GL_CULL_FACE);
+ glBindTexture(GL_TEXTURE_2D, 0);
+ if (painter->isFixedFunction())
+ glDisable(GL_TEXTURE_2D);
+ } else {
+ painter->setStandardEffect(QGL::LitMaterial);
+ cube->draw(painter);
+ }
+}
+
+static const int vertexDataLen = 6 * 4 * 3;
+
+static const float vertexData[vertexDataLen] = {
+ -0.5f * CubeSize, -0.5f * CubeSize, -0.5f * CubeSize,
+ -0.5f * CubeSize, -0.5f * CubeSize, 0.5f * CubeSize,
+ -0.5f * CubeSize, 0.5f * CubeSize, 0.5f * CubeSize,
+ -0.5f * CubeSize, 0.5f * CubeSize, -0.5f * CubeSize,
+
+ -0.5f * CubeSize, 0.5f * CubeSize, -0.5f * CubeSize,
+ -0.5f * CubeSize, 0.5f * CubeSize, 0.5f * CubeSize,
+ 0.5f * CubeSize, 0.5f * CubeSize, 0.5f * CubeSize,
+ 0.5f * CubeSize, 0.5f * CubeSize, -0.5f * CubeSize,
+
+ 0.5f * CubeSize, 0.5f * CubeSize, -0.5f * CubeSize,
+ 0.5f * CubeSize, 0.5f * CubeSize, 0.5f * CubeSize,
+ 0.5f * CubeSize, -0.5f * CubeSize, 0.5f * CubeSize,
+ 0.5f * CubeSize, -0.5f * CubeSize, -0.5f * CubeSize,
+
+ 0.5f * CubeSize, -0.5f * CubeSize, -0.5f * CubeSize,
+ 0.5f * CubeSize, -0.5f * CubeSize, 0.5f * CubeSize,
+ -0.5f * CubeSize, -0.5f * CubeSize, 0.5f * CubeSize,
+ -0.5f * CubeSize, -0.5f * CubeSize, -0.5f * CubeSize,
+
+ 0.5f * CubeSize, -0.5f * CubeSize, 0.5f * CubeSize,
+ 0.5f * CubeSize, 0.5f * CubeSize, 0.5f * CubeSize,
+ -0.5f * CubeSize, 0.5f * CubeSize, 0.5f * CubeSize,
+ -0.5f * CubeSize, -0.5f * CubeSize, 0.5f * CubeSize,
+
+ 0.5f * CubeSize, 0.5f * CubeSize, -0.5f * CubeSize,
+ 0.5f * CubeSize, -0.5f * CubeSize, -0.5f * CubeSize,
+ -0.5f * CubeSize, -0.5f * CubeSize, -0.5f * CubeSize,
+ -0.5f * CubeSize, 0.5f * CubeSize, -0.5f * CubeSize
+};
+
+QPointF CubeItem::intersection(const QRay3D &ray, int *actualFace) const
+{
+ // Determine which face of the cube contains the point.
+ QMatrix4x4 mv = camera()->modelViewMatrix();
+ QVector3D pt1, pt2, pt3, pt4;
+ QVector2D tc1, tc2, tc3;
+ bool singleFace = (pressedFace() != -1);
+ for (int face = 0; face < 6; ++face) {
+ if (singleFace && face != pressedFace())
+ continue;
+
+ // Test the two triangles on the face for an intersection.
+ pt1 = QVector3D(vertexData[face * 4 * 3],
+ vertexData[face * 4 * 3 + 1],
+ vertexData[face * 4 * 3 + 2]);
+ pt2 = QVector3D(vertexData[face * 4 * 3 + 3],
+ vertexData[face * 4 * 3 + 4],
+ vertexData[face * 4 * 3 + 5]);
+ pt3 = QVector3D(vertexData[face * 4 * 3 + 6],
+ vertexData[face * 4 * 3 + 7],
+ vertexData[face * 4 * 3 + 8]);
+ pt4 = QVector3D(vertexData[face * 4 * 3 + 9],
+ vertexData[face * 4 * 3 + 10],
+ vertexData[face * 4 * 3 + 11]);
+ pt1 = mv.map(pt1);
+ pt2 = mv.map(pt2);
+ pt3 = mv.map(pt3);
+ pt4 = mv.map(pt4);
+ QTriangle3D triangle(pt1, pt2, pt3);
+ qreal t = triangle.intersection(ray);
+ if (qIsNaN(t)) {
+ triangle.setQ(pt3);
+ triangle.setR(pt4);
+ t = triangle.intersection(ray);
+ if (qIsNaN(t)) {
+ if (!singleFace)
+ continue;
+ // The mouse probably moved outside the face while the
+ // mouse button was held down. Use the triangle's plane
+ // to compute a virtual texture co-ordinate.
+ t = triangle.plane().intersection(ray);
+ }
+ tc1 = QVector2D(1.0f, 0.0f);
+ tc2 = QVector2D(0.0f, 1.0f);
+ tc3 = QVector2D(0.0f, 0.0f);
+ } else {
+ tc1 = QVector2D(1.0f, 0.0f);
+ tc2 = QVector2D(1.0f, 1.0f);
+ tc3 = QVector2D(0.0f, 1.0f);
+ }
+
+ // We want the face that is pointing towards the user.
+ QVector3D v = QVector3D::crossProduct(pt2 - pt1, pt3 - pt1);
+ if (!singleFace && v.z() <= 0.0f)
+ continue;
+
+ // Get the texture co-ordinate corresponding to the intersection.
+ QVector2D uv = triangle.uv(ray.point(t));
+ QVector2D tc =
+ uv.x() * tc1 + uv.y() * tc2 + (1 - uv.x() - uv.y()) * tc3;
+ *actualFace = face;
+ return QPointF(tc.x(), tc.y());
+ }
+
+ *actualFace = -1;
+ return QPointF();
+}
diff --git a/examples/graphicsview/cubeitem.h b/examples/graphicsview/cubeitem.h
new file mode 100644
index 000000000..67b4aa257
--- /dev/null
+++ b/examples/graphicsview/cubeitem.h
@@ -0,0 +1,61 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtQuick3D examples of the Qt Toolkit.
+**
+** $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 Nokia Corporation and its Subsidiary(-ies) 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$
+**
+****************************************************************************/
+
+#ifndef CUBEITEM_H
+#define CUBEITEM_H
+
+#include "modelitem.h"
+
+class CubeItem : public ModelItem
+{
+ Q_OBJECT
+public:
+ CubeItem(QGraphicsItem *parent = 0);
+ ~CubeItem();
+
+protected:
+ void paintGL(QGLPainter *painter);
+ QPointF intersection(const QRay3D &ray, int *actualFace) const;
+
+private:
+ QGLSceneNode *cube;
+};
+
+#endif
diff --git a/examples/graphicsview/edge.cpp b/examples/graphicsview/edge.cpp
new file mode 100644
index 000000000..bf480ec4b
--- /dev/null
+++ b/examples/graphicsview/edge.cpp
@@ -0,0 +1,151 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtQuick3D examples of the Qt Toolkit.
+**
+** $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 Nokia Corporation and its Subsidiary(-ies) 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 <QPainter>
+
+#include "edge.h"
+#include "node.h"
+
+#include <math.h>
+
+static const double Pi = 3.14159265358979323846264338327950288419717;
+static double TwoPi = 2.0 * Pi;
+
+Edge::Edge(Node *sourceNode, Node *destNode)
+ : arrowSize(10)
+{
+ setAcceptedMouseButtons(0);
+ source = sourceNode;
+ dest = destNode;
+ source->addEdge(this);
+ dest->addEdge(this);
+ adjust();
+}
+
+Edge::~Edge()
+{
+}
+
+Node *Edge::sourceNode() const
+{
+ return source;
+}
+
+void Edge::setSourceNode(Node *node)
+{
+ source = node;
+ adjust();
+}
+
+Node *Edge::destNode() const
+{
+ return dest;
+}
+
+void Edge::setDestNode(Node *node)
+{
+ dest = node;
+ adjust();
+}
+
+void Edge::adjust()
+{
+ if (!source || !dest)
+ return;
+
+ QLineF line(mapFromItem(source, 0, 0), mapFromItem(dest, 0, 0));
+ qreal length = line.length();
+
+ prepareGeometryChange();
+
+ if (length > qreal(20.)) {
+ QPointF edgeOffset((line.dx() * 10) / length, (line.dy() * 10) / length);
+ sourcePoint = line.p1() + edgeOffset;
+ destPoint = line.p2() - edgeOffset;
+ } else {
+ sourcePoint = destPoint = line.p1();
+ }
+}
+
+QRectF Edge::boundingRect() const
+{
+ if (!source || !dest)
+ return QRectF();
+
+ qreal penWidth = 1;
+ qreal extra = (penWidth + arrowSize) / 2.0;
+
+ return QRectF(sourcePoint, QSizeF(destPoint.x() - sourcePoint.x(),
+ destPoint.y() - sourcePoint.y()))
+ .normalized()
+ .adjusted(-extra, -extra, extra, extra);
+}
+
+void Edge::paint(QPainter *painter, const QStyleOptionGraphicsItem *, QWidget *)
+{
+ if (!source || !dest)
+ return;
+
+ QLineF line(sourcePoint, destPoint);
+ if (qFuzzyCompare(line.length(), qreal(0.)))
+ return;
+
+ // Draw the line itself
+ painter->setPen(QPen(Qt::black, 2, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin));
+ painter->drawLine(line);
+
+ // Draw the arrows
+ double angle = ::acos(line.dx() / line.length());
+ if (line.dy() >= 0)
+ angle = TwoPi - angle;
+
+ QPointF sourceArrowP1 = sourcePoint + QPointF(sin(angle + Pi / 3) * arrowSize,
+ cos(angle + Pi / 3) * arrowSize);
+ QPointF sourceArrowP2 = sourcePoint + QPointF(sin(angle + Pi - Pi / 3) * arrowSize,
+ cos(angle + Pi - Pi / 3) * arrowSize);
+ QPointF destArrowP1 = destPoint + QPointF(sin(angle - Pi / 3) * arrowSize,
+ cos(angle - Pi / 3) * arrowSize);
+ QPointF destArrowP2 = destPoint + QPointF(sin(angle - Pi + Pi / 3) * arrowSize,
+ cos(angle - Pi + Pi / 3) * arrowSize);
+
+ painter->setBrush(Qt::black);
+ painter->drawPolygon(QPolygonF() << line.p1() << sourceArrowP1 << sourceArrowP2);
+ painter->drawPolygon(QPolygonF() << line.p2() << destArrowP1 << destArrowP2);
+}
diff --git a/examples/graphicsview/edge.h b/examples/graphicsview/edge.h
new file mode 100644
index 000000000..d50c403a9
--- /dev/null
+++ b/examples/graphicsview/edge.h
@@ -0,0 +1,77 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtQuick3D examples of the Qt Toolkit.
+**
+** $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 Nokia Corporation and its Subsidiary(-ies) 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$
+**
+****************************************************************************/
+
+#ifndef EDGE_H
+#define EDGE_H
+
+#include <QGraphicsItem>
+
+class Node;
+
+class Edge : public QGraphicsItem
+{
+public:
+ Edge(Node *sourceNode, Node *destNode);
+ ~Edge();
+
+ Node *sourceNode() const;
+ void setSourceNode(Node *node);
+
+ Node *destNode() const;
+ void setDestNode(Node *node);
+
+ void adjust();
+
+ enum { Type = UserType + 2 };
+ int type() const { return Type; }
+
+protected:
+ QRectF boundingRect() const;
+ void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
+
+private:
+ Node *source, *dest;
+
+ QPointF sourcePoint;
+ QPointF destPoint;
+ qreal arrowSize;
+};
+
+#endif
diff --git a/examples/graphicsview/graph.cpp b/examples/graphicsview/graph.cpp
new file mode 100644
index 000000000..2aa28b107
--- /dev/null
+++ b/examples/graphicsview/graph.cpp
@@ -0,0 +1,130 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtQuick3D examples of the Qt Toolkit.
+**
+** $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 Nokia Corporation and its Subsidiary(-ies) 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 "graph.h"
+#include "edge.h"
+#include "node.h"
+#include "scene.h"
+
+#include <QDebug>
+#include <QGraphicsScene>
+
+#include <math.h>
+
+Graph::Graph(QObject *parent)
+ : QObject(parent), timerId(0)
+{
+ QGraphicsEmbedScene *scene = new Scene(this);
+ sceneObject = scene;
+ scene->setItemIndexMethod(QGraphicsScene::NoIndex);
+ scene->setSceneRect(-128, -128, 256, 256);
+
+ Node *node1 = new Node(this);
+ Node *node2 = new Node(this);
+ Node *node3 = new Node(this);
+ Node *node4 = new Node(this);
+ centerNode = new Node(this);
+ Node *node6 = new Node(this);
+ Node *node7 = new Node(this);
+ Node *node8 = new Node(this);
+ Node *node9 = new Node(this);
+ scene->addItem(node1);
+ scene->addItem(node2);
+ scene->addItem(node3);
+ scene->addItem(node4);
+ scene->addItem(centerNode);
+ scene->addItem(node6);
+ scene->addItem(node7);
+ scene->addItem(node8);
+ scene->addItem(node9);
+ scene->addItem(new Edge(node1, node2));
+ scene->addItem(new Edge(node2, node3));
+ scene->addItem(new Edge(node2, centerNode));
+ scene->addItem(new Edge(node3, node6));
+ scene->addItem(new Edge(node4, node1));
+ scene->addItem(new Edge(node4, centerNode));
+ scene->addItem(new Edge(centerNode, node6));
+ scene->addItem(new Edge(centerNode, node8));
+ scene->addItem(new Edge(node6, node9));
+ scene->addItem(new Edge(node7, node4));
+ scene->addItem(new Edge(node8, node7));
+ scene->addItem(new Edge(node9, node8));
+
+ node1->setPos(-50, -50);
+ node2->setPos(0, -50);
+ node3->setPos(50, -50);
+ node4->setPos(-50, 0);
+ centerNode->setPos(0, 0);
+ node6->setPos(50, 0);
+ node7->setPos(-50, 50);
+ node8->setPos(0, 50);
+ node9->setPos(50, 50);
+}
+
+void Graph::itemMoved()
+{
+ if (!timerId)
+ timerId = startTimer(1000 / 25);
+}
+
+void Graph::timerEvent(QTimerEvent *event)
+{
+ Q_UNUSED(event);
+
+ QList<Node *> nodes;
+ foreach (QGraphicsItem *item, scene()->items()) {
+ if (Node *node = qgraphicsitem_cast<Node *>(item))
+ nodes << node;
+ }
+
+ foreach (Node *node, nodes)
+ node->calculateForces();
+
+ bool itemsMoved = false;
+ foreach (Node *node, nodes) {
+ if (node->advance())
+ itemsMoved = true;
+ }
+
+ if (!itemsMoved) {
+ killTimer(timerId);
+ timerId = 0;
+ }
+}
diff --git a/examples/graphicsview/graph.h b/examples/graphicsview/graph.h
new file mode 100644
index 000000000..0fa897ce8
--- /dev/null
+++ b/examples/graphicsview/graph.h
@@ -0,0 +1,67 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtQuick3D examples of the Qt Toolkit.
+**
+** $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 Nokia Corporation and its Subsidiary(-ies) 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$
+**
+****************************************************************************/
+
+#ifndef GRAPHWIDGET_H
+#define GRAPHWIDGET_H
+
+#include "qgraphicsembedscene.h"
+
+class Node;
+
+class Graph : public QObject
+{
+ Q_OBJECT
+public:
+ Graph(QObject *parent = 0);
+
+ QGraphicsEmbedScene *scene() const { return sceneObject; }
+
+ void itemMoved();
+
+protected:
+ void timerEvent(QTimerEvent *event);
+
+private:
+ QGraphicsEmbedScene *sceneObject;
+ int timerId;
+ Node *centerNode;
+};
+
+#endif
diff --git a/examples/graphicsview/graphicsview.pro b/examples/graphicsview/graphicsview.pro
new file mode 100644
index 000000000..98aba411d
--- /dev/null
+++ b/examples/graphicsview/graphicsview.pro
@@ -0,0 +1,26 @@
+TEMPLATE = app
+TARGET = graphicsview
+CONFIG += qt warn_on qt3d
+VPATH += $$PWD/../../src/threed/geometry
+SOURCES = \
+ cubeitem.cpp \
+ modelitem.cpp \
+ teapotitem.cpp \
+ main.cpp \
+ edge.cpp \
+ node.cpp \
+ graph.cpp \
+ scene.cpp \
+ view.cpp
+HEADERS = \
+ cubeitem.h \
+ modelitem.h \
+ teapotitem.h \
+ edge.h \
+ node.h \
+ graph.h \
+ scene.h \
+ view.h
+RESOURCES = \
+ graphicsview.qrc
+DESTDIR = ../../bin
diff --git a/examples/graphicsview/graphicsview.qrc b/examples/graphicsview/graphicsview.qrc
new file mode 100644
index 000000000..37a99a114
--- /dev/null
+++ b/examples/graphicsview/graphicsview.qrc
@@ -0,0 +1,6 @@
+<!DOCTYPE RCC><RCC version="1.0">
+<qresource>
+ <file>cubeicon.png</file>
+ <file>teapoticon.png</file>
+</qresource>
+</RCC>
diff --git a/examples/graphicsview/main.cpp b/examples/graphicsview/main.cpp
new file mode 100644
index 000000000..39a3d7a08
--- /dev/null
+++ b/examples/graphicsview/main.cpp
@@ -0,0 +1,58 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtQuick3D examples of the Qt Toolkit.
+**
+** $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 Nokia Corporation and its Subsidiary(-ies) 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 <QApplication>
+#include <QtOpenGL/qgl.h>
+#include <QtCore/qmath.h>
+#include <QtCore/qdatetime.h>
+#include "view.h"
+
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+
+ QGLFormat format(QGLFormat::defaultFormat());
+ format.setSampleBuffers(true);
+ View view;
+ view.setViewport(new QGLWidget(format));
+ view.show();
+
+ return app.exec();
+}
diff --git a/examples/graphicsview/modelitem.cpp b/examples/graphicsview/modelitem.cpp
new file mode 100644
index 000000000..41ba13833
--- /dev/null
+++ b/examples/graphicsview/modelitem.cpp
@@ -0,0 +1,220 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtQuick3D examples of the Qt Toolkit.
+**
+** $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 Nokia Corporation and its Subsidiary(-ies) 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 "modelitem.h"
+#include "qglpainter.h"
+#include "qgraphicsembedscene.h"
+#include <QtGui/qgraphicssceneevent.h>
+#include <QtGui/qapplication.h>
+
+const qreal CubeSize = 2.0f;
+
+ModelItem::ModelItem(QGraphicsItem *parent)
+ : QGLGraphicsViewportItem(parent)
+ , mScene(0)
+ , mTextureId(0)
+ , navigating(false)
+ , mPressedFace(-1)
+ , pressedButton(Qt::NoButton)
+{
+ startNavCamera = new QGLCamera();
+
+ setFlag(ItemIsFocusable, true);
+}
+
+ModelItem::~ModelItem()
+{
+ delete startNavCamera;
+}
+
+void ModelItem::setScene(QGraphicsEmbedScene *scene)
+{
+ mScene = scene;
+ connect(scene, SIGNAL(changed(QList<QRectF>)), this, SLOT(updateScene()));
+}
+
+void ModelItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
+{
+ // Render the inner scene into a framebuffer object.
+ // We do this while the ordinary Qt paint engine has
+ // control of the GL context rather than later when the
+ // QGLPainter has control of the GL context.
+ if (mScene)
+ mTextureId = mScene->renderToTexture();
+
+ // Now render the GL parts of the item using QGLPainter.
+ QGLGraphicsViewportItem::paint(painter, option, widget);
+}
+
+void ModelItem::updateScene()
+{
+ update();
+}
+
+void ModelItem::mousePressEvent(QGraphicsSceneMouseEvent *event)
+{
+ int face;
+ QPointF tc = intersection
+ (event->widget(), event->pos().toPoint(), &face);
+ if (!navigating && mPressedFace == -1 && face != -1) {
+ mPressedFace = face;
+ pressedButton = event->button();
+ mScene->deliverEvent(event, tc);
+ return;
+ } else if (!navigating && face == -1) {
+ navigating = true;
+ pressedButton = event->button();
+ pressedPos = event->pos().toPoint();
+ startNavCamera->setEye(camera()->eye());
+ startNavCamera->setCenter(camera()->center());
+ startNavCamera->setUpVector(camera()->upVector());
+#ifndef QT_NO_CURSOR
+ setCursor(Qt::ClosedHandCursor);
+#endif
+ return;
+ }
+ QGraphicsItem::mousePressEvent(event);
+}
+
+void ModelItem::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
+{
+ if (navigating) {
+ QPoint delta = event->pos().toPoint() - pressedPos;
+ int deltax = delta.x();
+ int deltay = delta.y();
+ QGLCamera *camera = this->camera();
+ int rotation = camera->screenRotation();
+ if (rotation == 90 || rotation == 270) {
+ qSwap(deltax, deltay);
+ }
+ if (rotation == 90 || rotation == 180) {
+ deltax = -deltax;
+ }
+ if (rotation == 180 || rotation == 270) {
+ deltay = -deltay;
+ }
+ qreal anglex = deltax * 90.0f / rect().width();
+ qreal angley = deltay * 90.0f / rect().height();
+ QQuaternion q = startNavCamera->pan(-anglex);
+ q *= startNavCamera->tilt(-angley);
+ camera->setEye(startNavCamera->eye());
+ camera->setCenter(startNavCamera->center());
+ camera->setUpVector(startNavCamera->upVector());
+ camera->rotateCenter(q);
+ } else if (mPressedFace != -1) {
+ int face;
+ QPointF tc = intersection
+ (event->widget(), event->pos().toPoint(), &face);
+ if (face != mPressedFace)
+ tc = QPointF(-1, -1);
+ mScene->deliverEvent(event, tc);
+ return;
+ }
+ QGraphicsItem::mouseMoveEvent(event);
+}
+
+void ModelItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
+{
+ if (navigating && pressedButton == event->button()) {
+ navigating = false;
+ pressedButton = Qt::NoButton;
+#ifndef QT_NO_CURSOR
+ unsetCursor();
+#endif
+ return;
+ } else if (mPressedFace != -1) {
+ int face;
+ QPointF tc = intersection
+ (event->widget(), event->pos().toPoint(), &face);
+ if (face != mPressedFace)
+ tc = QPoint(-1, -1);
+ if (pressedButton == event->button()) {
+ mPressedFace = -1;
+ pressedButton = Qt::NoButton;
+ }
+ mScene->deliverEvent(event, tc);
+ return;
+ }
+ QGraphicsItem::mouseReleaseEvent(event);
+}
+
+void ModelItem::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event)
+{
+ int face;
+ QPointF tc = intersection
+ (event->widget(), event->pos().toPoint(), &face);
+ if (mPressedFace == -1 && face != -1) {
+ mPressedFace = face;
+ pressedButton = event->button();
+ mScene->deliverEvent(event, tc);
+ return;
+ }
+ QGraphicsItem::mouseDoubleClickEvent(event);
+}
+
+QPointF ModelItem::intersection
+ (QWidget *widget, const QPoint &point, int *actualFace) const
+{
+ // Bail out if no scene.
+ if (!mScene) {
+ *actualFace = -1;
+ return QPointF();
+ }
+
+ // Get the combined matrix for the projection.
+ int dpiX = widget->logicalDpiX();
+ int dpiY = widget->logicalDpiY();
+ QRectF bounds = boundingRect();
+ qreal aspectRatio = (bounds.width() * dpiY) / (bounds.height() * dpiX);
+ QMatrix4x4 proj = camera()->projectionMatrix(aspectRatio);
+
+ // Find the relative position of the point within (-1, -1) to (1, 1).
+ QPointF relativePoint =
+ QPointF((point.x() - bounds.center().x()) * 2 / bounds.width(),
+ -(point.y() - bounds.center().y()) * 2 / bounds.height());
+
+ // Get the ray extending from the eye through the point the user selected.
+ QVector3D eyept = proj.inverted().map
+ (QVector3D(relativePoint.x(), relativePoint.y(), -1.0f));
+ QRay3D ray(QVector3D(0, 0, 0), eyept);
+
+ // Intersect with the ray using a model-specific intersection method.
+ return intersection(ray, actualFace);
+}
diff --git a/examples/graphicsview/modelitem.h b/examples/graphicsview/modelitem.h
new file mode 100644
index 000000000..063cbb2b2
--- /dev/null
+++ b/examples/graphicsview/modelitem.h
@@ -0,0 +1,89 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtQuick3D examples of the Qt Toolkit.
+**
+** $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 Nokia Corporation and its Subsidiary(-ies) 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$
+**
+****************************************************************************/
+
+#ifndef MODELITEM_H
+#define MODELITEM_H
+
+#include "qglgraphicsviewportitem.h"
+#include "qglbuilder.h"
+#include "qray3d.h"
+
+class QGraphicsEmbedScene;
+
+class ModelItem : public QObject, public QGLGraphicsViewportItem
+{
+ Q_OBJECT
+public:
+ ModelItem(QGraphicsItem *parent = 0);
+ ~ModelItem();
+
+ QGraphicsEmbedScene *scene() const { return mScene; }
+ void setScene(QGraphicsEmbedScene *scene);
+
+ void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
+
+protected:
+ void mousePressEvent(QGraphicsSceneMouseEvent *event);
+ void mouseMoveEvent(QGraphicsSceneMouseEvent *event);
+ void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
+ void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event);
+
+private Q_SLOTS:
+ void updateScene();
+
+protected:
+ virtual QPointF intersection(const QRay3D &ray, int *actualFace) const = 0;
+ GLuint textureId() const { return mTextureId; }
+ int pressedFace() const { return mPressedFace; }
+
+private:
+ QGraphicsEmbedScene *mScene;
+ GLuint mTextureId;
+ bool navigating;
+ int mPressedFace;
+ Qt::MouseButton pressedButton;
+ QPoint pressedPos;
+ QGLCamera *startNavCamera;
+
+ QPointF intersection
+ (QWidget *widget, const QPoint &point, int *actualFace) const;
+};
+
+#endif
diff --git a/examples/graphicsview/node.cpp b/examples/graphicsview/node.cpp
new file mode 100644
index 000000000..4723b0ab4
--- /dev/null
+++ b/examples/graphicsview/node.cpp
@@ -0,0 +1,185 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtQuick3D examples of the Qt Toolkit.
+**
+** $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 Nokia Corporation and its Subsidiary(-ies) 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 <QGraphicsScene>
+#include <QGraphicsSceneMouseEvent>
+#include <QPainter>
+#include <QStyleOption>
+
+#include "edge.h"
+#include "node.h"
+#include "graph.h"
+
+Node::Node(Graph *graphWidget)
+ : graph(graphWidget)
+{
+ setFlag(ItemIsMovable);
+ setFlag(ItemSendsGeometryChanges);
+ //setCacheMode(DeviceCoordinateCache);
+ setZValue(-1);
+}
+
+void Node::addEdge(Edge *edge)
+{
+ edgeList << edge;
+ edge->adjust();
+}
+
+QList<Edge *> Node::edges() const
+{
+ return edgeList;
+}
+
+void Node::calculateForces()
+{
+ if (!scene() || scene()->mouseGrabberItem() == this) {
+ newPos = pos();
+ return;
+ }
+
+ // Sum up all forces pushing this item away
+ qreal xvel = 0;
+ qreal yvel = 0;
+ foreach (QGraphicsItem *item, scene()->items()) {
+ Node *node = qgraphicsitem_cast<Node *>(item);
+ if (!node)
+ continue;
+
+ QLineF line(mapFromItem(node, 0, 0), QPointF(0, 0));
+ qreal dx = line.dx();
+ qreal dy = line.dy();
+ double l = 2.0 * (dx * dx + dy * dy);
+ if (l > 0) {
+ xvel += (dx * 150.0) / l;
+ yvel += (dy * 150.0) / l;
+ }
+ }
+
+ // Now subtract all forces pulling items together
+ double weight = (edgeList.size() + 1) * 10;
+ foreach (Edge *edge, edgeList) {
+ QPointF pos;
+ if (edge->sourceNode() == this)
+ pos = mapFromItem(edge->destNode(), 0, 0);
+ else
+ pos = mapFromItem(edge->sourceNode(), 0, 0);
+ xvel += pos.x() / weight;
+ yvel += pos.y() / weight;
+ }
+
+ if (qAbs(xvel) < 0.1 && qAbs(yvel) < 0.1)
+ xvel = yvel = 0;
+
+ QRectF sceneRect = scene()->sceneRect();
+ newPos = pos() + QPointF(xvel, yvel);
+ newPos.setX(qMin(qMax(newPos.x(), sceneRect.left() + 10), sceneRect.right() - 10));
+ newPos.setY(qMin(qMax(newPos.y(), sceneRect.top() + 10), sceneRect.bottom() - 10));
+}
+
+bool Node::advance()
+{
+ if (newPos == pos())
+ return false;
+
+ setPos(newPos);
+ return true;
+}
+
+QRectF Node::boundingRect() const
+{
+ qreal adjust = 42;
+ return QRectF(-10 - adjust, -10 - adjust,
+ 23 + adjust * 2, 23 + adjust * 2);
+}
+
+QPainterPath Node::shape() const
+{
+ QPainterPath path;
+ path.addEllipse(-20, -20, 40, 40);
+ return path;
+}
+
+void Node::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *)
+{
+ painter->setPen(Qt::NoPen);
+ painter->setBrush(Qt::darkGray);
+ painter->drawEllipse(-7, -7, 20, 20);
+
+ QRadialGradient gradient(-3, -3, 10);
+ if (option->state & QStyle::State_Sunken) {
+ gradient.setCenter(3, 3);
+ gradient.setFocalPoint(3, 3);
+ gradient.setColorAt(1, QColor(Qt::yellow).light(120));
+ gradient.setColorAt(0, QColor(Qt::darkYellow).light(120));
+ } else {
+ gradient.setColorAt(0, Qt::yellow);
+ gradient.setColorAt(1, Qt::darkYellow);
+ }
+ painter->setBrush(gradient);
+ painter->setPen(QPen(Qt::black, 0));
+ painter->drawEllipse(-10, -10, 20, 20);
+}
+
+QVariant Node::itemChange(GraphicsItemChange change, const QVariant &value)
+{
+ switch (change) {
+ case ItemPositionHasChanged:
+ foreach (Edge *edge, edgeList)
+ edge->adjust();
+ graph->itemMoved();
+ break;
+ default:
+ break;
+ };
+
+ return QGraphicsItem::itemChange(change, value);
+}
+
+void Node::mousePressEvent(QGraphicsSceneMouseEvent *event)
+{
+ update();
+ QGraphicsItem::mousePressEvent(event);
+}
+
+void Node::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
+{
+ update();
+ QGraphicsItem::mouseReleaseEvent(event);
+}
diff --git a/examples/graphicsview/node.h b/examples/graphicsview/node.h
new file mode 100644
index 000000000..45208610a
--- /dev/null
+++ b/examples/graphicsview/node.h
@@ -0,0 +1,83 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtQuick3D examples of the Qt Toolkit.
+**
+** $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 Nokia Corporation and its Subsidiary(-ies) 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$
+**
+****************************************************************************/
+
+#ifndef NODE_H
+#define NODE_H
+
+#include <QGraphicsItem>
+#include <QList>
+
+class Edge;
+class Graph;
+QT_BEGIN_NAMESPACE
+class QGraphicsSceneMouseEvent;
+QT_END_NAMESPACE
+
+class Node : public QGraphicsItem
+{
+public:
+ Node(Graph *graphWidget);
+
+ void addEdge(Edge *edge);
+ QList<Edge *> edges() const;
+
+ enum { Type = UserType + 1 };
+ int type() const { return Type; }
+
+ void calculateForces();
+ bool advance();
+
+ QRectF boundingRect() const;
+ QPainterPath shape() const;
+ void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
+
+protected:
+ QVariant itemChange(GraphicsItemChange change, const QVariant &value);
+
+ void mousePressEvent(QGraphicsSceneMouseEvent *event);
+ void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
+
+private:
+ QList<Edge *> edgeList;
+ QPointF newPos;
+ Graph *graph;
+};
+
+#endif
diff --git a/examples/graphicsview/scene.cpp b/examples/graphicsview/scene.cpp
new file mode 100644
index 000000000..5fe551058
--- /dev/null
+++ b/examples/graphicsview/scene.cpp
@@ -0,0 +1,54 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtQuick3D examples of the Qt Toolkit.
+**
+** $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 Nokia Corporation and its Subsidiary(-ies) 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 "scene.h"
+#include <QtGui/qpainter.h>
+
+void Scene::drawBackground(QPainter *painter, const QRectF &rect)
+{
+ painter->save();
+ QLinearGradient gradient(rect.topLeft(), rect.bottomRight());
+ gradient.setColorAt(0, QColor(0, 128, 192, 255));
+ gradient.setColorAt(1, QColor(0, 0, 128, 255));
+ painter->setPen(QPen(Qt::black, 3));
+ painter->setBrush(gradient);
+ painter->drawRect(rect);
+ painter->restore();
+}
diff --git a/examples/graphicsview/scene.h b/examples/graphicsview/scene.h
new file mode 100644
index 000000000..73be795a8
--- /dev/null
+++ b/examples/graphicsview/scene.h
@@ -0,0 +1,56 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtQuick3D examples of the Qt Toolkit.
+**
+** $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 Nokia Corporation and its Subsidiary(-ies) 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$
+**
+****************************************************************************/
+
+#ifndef SCENE_H
+#define SCENE_H
+
+#include "qgraphicsembedscene.h"
+
+class Scene : public QGraphicsEmbedScene
+{
+ Q_OBJECT
+public:
+ Scene(QObject *parent = 0) : QGraphicsEmbedScene(parent) {}
+
+protected:
+ void drawBackground(QPainter *painter, const QRectF &rect);
+};
+
+#endif
diff --git a/examples/graphicsview/teapoticon.png b/examples/graphicsview/teapoticon.png
new file mode 100644
index 000000000..17392361d
--- /dev/null
+++ b/examples/graphicsview/teapoticon.png
Binary files differ
diff --git a/examples/graphicsview/teapotitem.cpp b/examples/graphicsview/teapotitem.cpp
new file mode 100644
index 000000000..72161a5a2
--- /dev/null
+++ b/examples/graphicsview/teapotitem.cpp
@@ -0,0 +1,129 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtQuick3D examples of the Qt Toolkit.
+**
+** $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 Nokia Corporation and its Subsidiary(-ies) 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 "teapotitem.h"
+#include "qglpainter.h"
+#include "qplane3d.h"
+#include "qtriangle3d.h"
+#include <QtCore/qnumeric.h>
+
+TeapotItem::TeapotItem(QGraphicsItem *parent)
+ : ModelItem(parent)
+{
+ QGLBuilder builder;
+ builder.newSection(QGL::Faceted);
+ builder << teapot;
+ teapotNode = builder.finalizedSceneNode();
+}
+
+TeapotItem::~TeapotItem()
+{
+ delete teapotNode;
+}
+
+void TeapotItem::paintGL(QGLPainter *painter)
+{
+ GLuint textureId = this->textureId();
+ if (textureId) {
+ glDisable(GL_DEPTH_TEST);
+ glEnable(GL_BLEND);
+ painter->setFaceColor(QGL::AllFaces, QColor(0, 0, 0, 200));
+ painter->setStandardEffect(QGL::LitDecalTexture2D);
+ glBindTexture(GL_TEXTURE_2D, textureId);
+ glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
+ glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
+ if (painter->isFixedFunction())
+ glEnable(GL_TEXTURE_2D);
+ glCullFace(GL_FRONT);
+ glEnable(GL_CULL_FACE);
+ teapotNode->draw(painter);
+ glCullFace(GL_BACK);
+ teapotNode->draw(painter);
+ glDisable(GL_CULL_FACE);
+ glBindTexture(GL_TEXTURE_2D, 0);
+ if (painter->isFixedFunction())
+ glDisable(GL_TEXTURE_2D);
+ } else {
+ painter->setStandardEffect(QGL::LitMaterial);
+ teapotNode->draw(painter);
+ }
+}
+
+QPointF TeapotItem::intersection(const QRay3D &ray, int *actualFace) const
+{
+ QVector2D tc;
+ QGLBezierPatches patches = teapot.transformed(camera()->modelViewMatrix());
+ if (pressedFace() == -1) {
+ // Intersect with the whole teapot.
+ qreal t = patches.intersection(ray, &tc, actualFace);
+ if (!qIsNaN(t))
+ return QPointF(tc.x(), tc.y());
+ } else {
+ // Only intersect with the patch that was pressed previously.
+ QGLBezierPatches subpatches;
+ subpatches.setPositions
+ (patches.positions().mid(pressedFace() * 16, 16));
+ qreal t = subpatches.intersection(ray, &tc);
+ if (!qIsNaN(t)) {
+ *actualFace = pressedFace();
+ return QPointF(tc.x(), tc.y());
+ }
+
+ // The mouse has moved outside the boundary of the patch.
+ // Use the plane containing the patch to extend the hit
+ // area out to infinity.
+ QTriangle3D triangle(subpatches.positions()[0],
+ subpatches.positions()[3],
+ subpatches.positions()[12]);
+ t = triangle.plane().intersection(ray);
+ if (!qIsNaN(t)) {
+ *actualFace = pressedFace();
+ QVector2D uv = triangle.uv(ray.point(t));
+ QVector2D tc1(0, 0);
+ QVector2D tc2(1, 0);
+ QVector2D tc3(0, 1);
+ QVector2D tc =
+ uv.x() * tc1 + uv.y() * tc2 + (1 - uv.x() - uv.y()) * tc3;
+ return QPointF(tc.x(), tc.y());
+ }
+ }
+ *actualFace = -1;
+ return QPointF();
+}
diff --git a/examples/graphicsview/teapotitem.h b/examples/graphicsview/teapotitem.h
new file mode 100644
index 000000000..f2706eeb1
--- /dev/null
+++ b/examples/graphicsview/teapotitem.h
@@ -0,0 +1,63 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtQuick3D examples of the Qt Toolkit.
+**
+** $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 Nokia Corporation and its Subsidiary(-ies) 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$
+**
+****************************************************************************/
+
+#ifndef TEAPOTITEM_H
+#define TEAPOTITEM_H
+
+#include "modelitem.h"
+#include "qglteapot.h"
+
+class TeapotItem : public ModelItem
+{
+ Q_OBJECT
+public:
+ TeapotItem(QGraphicsItem *parent = 0);
+ ~TeapotItem();
+
+protected:
+ void paintGL(QGLPainter *painter);
+ QPointF intersection(const QRay3D &ray, int *actualFace) const;
+
+private:
+ QGLTeapot teapot;
+ QGLSceneNode *teapotNode;
+};
+
+#endif
diff --git a/examples/graphicsview/view.cpp b/examples/graphicsview/view.cpp
new file mode 100644
index 000000000..73f4bb6c9
--- /dev/null
+++ b/examples/graphicsview/view.cpp
@@ -0,0 +1,121 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtQuick3D examples of the Qt Toolkit.
+**
+** $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 Nokia Corporation and its Subsidiary(-ies) 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 "view.h"
+#include "cubeitem.h"
+#include "teapotitem.h"
+#include "graph.h"
+#include "qglcamera.h"
+#include <QtGui/qgraphicssceneevent.h>
+
+View::View(QWidget *parent)
+ : QGraphicsView(parent)
+{
+ setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
+ setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
+ setViewportUpdateMode(QGraphicsView::FullViewportUpdate);
+
+ scene.setBackgroundBrush(Qt::black);
+ setScene(&scene);
+
+ cube = new CubeItem();
+ cube->setRect(0, 0, 600, 480);
+ cube->camera()->setEye(QVector3D(-5.0f, 3.0f, 6.0f));
+ cube->setVisible(false);
+
+ teapot = new TeapotItem();
+ teapot->setRect(0, 0, 600, 480);
+ teapot->camera()->setEye(QVector3D(-5.0f, 3.0f, 6.0f));
+
+ Button *cubeButton = new Button
+ (QPixmap(QLatin1String(":/cubeicon.png")), teapot);
+ Button *teapotButton = new Button
+ (QPixmap(QLatin1String(":/teapoticon.png")), cube);
+
+ connect(cubeButton, SIGNAL(clicked()), this, SLOT(switchToCube()));
+ connect(teapotButton, SIGNAL(clicked()), this, SLOT(switchToTeapot()));
+
+ scene.addItem(cube);
+ scene.addItem(teapot);
+
+ Graph *graph = new Graph(this);
+ cube->setScene(graph->scene());
+ teapot->setScene(graph->scene());
+}
+
+void View::resizeEvent(QResizeEvent *e)
+{
+ QGraphicsView::resizeEvent(e);
+ cube->setRect(0, 0, width(), height());
+ teapot->setRect(0, 0, width(), height());
+}
+
+void View::switchToCube()
+{
+ teapot->setVisible(false);
+ cube->setVisible(true);
+}
+
+void View::switchToTeapot()
+{
+ cube->setVisible(false);
+ teapot->setVisible(true);
+}
+
+Button::Button(const QPixmap &pixmap, QGraphicsItem *parent)
+ : QGraphicsPixmapItem(pixmap, parent)
+ , pressed(false)
+{
+ setFlag(ItemIsSelectable, true);
+}
+
+void Button::mousePressEvent(QGraphicsSceneMouseEvent *event)
+{
+ pressed = true;
+ QGraphicsItem::mousePressEvent(event);
+}
+
+void Button::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
+{
+ if (pressed && boundingRect().contains(event->scenePos()))
+ emit clicked();
+ pressed = false;
+ QGraphicsItem::mouseReleaseEvent(event);
+}
diff --git a/examples/graphicsview/view.h b/examples/graphicsview/view.h
new file mode 100644
index 000000000..f47a7249b
--- /dev/null
+++ b/examples/graphicsview/view.h
@@ -0,0 +1,87 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtQuick3D examples of the Qt Toolkit.
+**
+** $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 Nokia Corporation and its Subsidiary(-ies) 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$
+**
+****************************************************************************/
+
+#ifndef VIEW_H
+#define VIEW_H
+
+#include <QtGui/qgraphicsview.h>
+#include <QtGui/qgraphicsscene.h>
+#include <QtGui/qgraphicsitem.h>
+
+class CubeItem;
+class TeapotItem;
+
+class View : public QGraphicsView
+{
+ Q_OBJECT
+public:
+ View(QWidget *parent = 0);
+
+protected:
+ void resizeEvent(QResizeEvent *e);
+
+private Q_SLOTS:
+ void switchToCube();
+ void switchToTeapot();
+
+private:
+ QGraphicsScene scene;
+ CubeItem *cube;
+ TeapotItem *teapot;
+};
+
+class Button : public QObject, public QGraphicsPixmapItem
+{
+ Q_OBJECT
+public:
+ Button(const QPixmap &pixmap, QGraphicsItem *parent);
+
+Q_SIGNALS:
+ void clicked();
+
+protected:
+ void mousePressEvent(QGraphicsSceneMouseEvent *event);
+ void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
+
+private:
+ bool pressed;
+};
+
+#endif
diff --git a/examples/nesting/cubeview.cpp b/examples/nesting/cubeview.cpp
new file mode 100644
index 000000000..d14b5048e
--- /dev/null
+++ b/examples/nesting/cubeview.cpp
@@ -0,0 +1,209 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtQuick3D examples of the Qt Toolkit.
+**
+** $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 Nokia Corporation and its Subsidiary(-ies) 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 "cubeview.h"
+#include "qglcube.h"
+#include "qglteapot.h"
+#include <QtOpenGL/qglframebufferobject.h>
+#include <QtCore/qpropertyanimation.h>
+
+//! [1]
+CubeView::CubeView(QWidget *parent)
+ : QGLView(parent)
+ , fbo(0)
+ , tangle(0.0f)
+ , cangle(0.0f)
+ , oangle(0.0f)
+{
+ QGLBuilder builder;
+ builder.newSection(QGL::Faceted);
+ builder << QGLCube(1.5f);
+ cube = builder.currentNode();
+ cube->setObjectName(QLatin1String("Cube"));
+
+ builder.newSection();
+ builder << QGLTeapot();
+ teapot = builder.currentNode();
+ teapot->setObjectName(QLatin1String("Teapot"));
+
+ scene = builder.finalizedSceneNode();
+ scene->setParent(this);
+//! [1]
+
+//! [2]
+ QPropertyAnimation *animation;
+
+ animation = new QPropertyAnimation(this, "teapotAngle", this);
+ animation->setStartValue(0.0f);
+ animation->setEndValue(360.0f);
+ animation->setDuration(1000);
+ animation->setLoopCount(-1);
+ animation->start();
+
+ animation = new QPropertyAnimation(this, "cubeAngle", this);
+ animation->setStartValue(0.0f);
+ animation->setEndValue(360.0f);
+ animation->setDuration(5000);
+ animation->setLoopCount(-1);
+ animation->start();
+
+ animation = new QPropertyAnimation(this, "orbitAngle", this);
+ animation->setStartValue(0.0f);
+ animation->setEndValue(360.0f);
+ animation->setDuration(5000);
+ animation->setLoopCount(-1);
+ animation->start();
+//! [2]
+
+//! [3]
+ innerCamera = new QGLCamera(this);
+}
+//! [3]
+
+CubeView::~CubeView()
+{
+ delete fbo;
+}
+
+//! [4]
+void CubeView::initializeGL(QGLPainter *)
+{
+ fbo = new QGLFramebufferObject(512, 512, QGLFramebufferObject::Depth);
+ fboSurface.setFramebufferObject(fbo);
+//! [4]
+
+//! [5]
+ QImage textureImage(QLatin1String(":/qtlogo.png"));
+ qtlogo.setImage(textureImage);
+
+ glEnable(GL_BLEND);
+}
+//! [5]
+
+//! [6]
+void CubeView::paintGL(QGLPainter *painter)
+{
+ painter->modelViewMatrix().push();
+ painter->projectionMatrix().push();
+ painter->pushSurface(&fboSurface);
+//! [6]
+
+//! [7]
+ painter->setCamera(innerCamera);
+ painter->modelViewMatrix().rotate(tangle, 0.0f, 1.0f, 0.0f);
+
+ painter->setFaceColor(QGL::AllFaces, QColor(170, 202, 0));
+ painter->setStandardEffect(QGL::LitMaterial);
+
+ glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
+ teapot->draw(painter);
+//! [7]
+
+//! [8]
+ painter->popSurface();
+ painter->projectionMatrix().pop();
+ painter->modelViewMatrix().pop();
+//! [8]
+
+//! [9]
+ painter->modelViewMatrix().rotate(oangle, 0.0f, 1.0f, 0.0f);
+ QMatrix4x4 m = painter->modelViewMatrix();
+ QVector3D cube1pos(-1.5f, 0.0f, 0.0f);
+ QVector3D cube2pos(1.5f, 0.0f, 0.0f);
+
+ if (m.map(cube1pos).z() < m.map(cube2pos).z()) {
+ drawCube1(painter, cube1pos);
+ drawCube2(painter, cube2pos);
+ } else {
+ drawCube2(painter, cube2pos);
+ drawCube1(painter, cube1pos);
+ }
+}
+//! [9]
+
+//! [10]
+void CubeView::drawCube1(QGLPainter *painter, const QVector3D &posn)
+{
+ painter->modelViewMatrix().push();
+
+ qtlogo.bind();
+ painter->setFaceColor(QGL::AllFaces, QColor(202, 100, 0, 150));
+ painter->setStandardEffect(QGL::LitDecalTexture2D);
+
+ painter->modelViewMatrix().translate(posn);
+ painter->modelViewMatrix().rotate(cangle, 1.0f, -1.0f, 1.0f);
+
+ glCullFace(GL_FRONT);
+ glEnable(GL_CULL_FACE);
+ cube->draw(painter);
+ glCullFace(GL_BACK);
+ cube->draw(painter);
+ glDisable(GL_CULL_FACE);
+
+ painter->modelViewMatrix().pop();
+}
+//! [10]
+
+//! [11]
+void CubeView::drawCube2(QGLPainter *painter, const QVector3D &posn)
+{
+ painter->modelViewMatrix().push();
+
+ painter->setFaceColor(QGL::AllFaces, QColor(0, 160, 202, 125));
+ painter->setStandardEffect(QGL::LitDecalTexture2D);
+ glBindTexture(GL_TEXTURE_2D, fbo->texture());
+ glEnable(GL_TEXTURE_2D);
+
+ painter->modelViewMatrix().translate(posn);
+ painter->modelViewMatrix().rotate(cangle, 1.0f, 1.0f, 1.0f);
+
+ glCullFace(GL_FRONT);
+ glEnable(GL_CULL_FACE);
+ cube->draw(painter);
+ glCullFace(GL_BACK);
+ cube->draw(painter);
+ glDisable(GL_CULL_FACE);
+
+ glBindTexture(GL_TEXTURE_2D, 0);
+ glDisable(GL_TEXTURE_2D);
+
+ painter->modelViewMatrix().pop();
+}
+//! [11]
diff --git a/examples/nesting/cubeview.h b/examples/nesting/cubeview.h
new file mode 100644
index 000000000..1fae5de4d
--- /dev/null
+++ b/examples/nesting/cubeview.h
@@ -0,0 +1,90 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtQuick3D examples of the Qt Toolkit.
+**
+** $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 Nokia Corporation and its Subsidiary(-ies) 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$
+**
+****************************************************************************/
+
+#ifndef CUBEVIEW_H
+#define CUBEVIEW_H
+
+#include "qglview.h"
+#include "qglbuilder.h"
+#include "qglframebufferobjectsurface.h"
+
+class QGLFramebufferObject;
+class QGLCamera;
+
+class CubeView : public QGLView
+{
+ Q_OBJECT
+ Q_PROPERTY(qreal teapotAngle READ teapotAngle WRITE setTeapotAngle)
+ Q_PROPERTY(qreal cubeAngle READ cubeAngle WRITE setCubeAngle)
+ Q_PROPERTY(qreal orbitAngle READ orbitAngle WRITE setOrbitAngle)
+public:
+ CubeView(QWidget *parent = 0);
+ ~CubeView();
+
+ qreal teapotAngle() const { return tangle; }
+ void setTeapotAngle(qreal angle) { tangle = angle; update(); }
+
+ qreal cubeAngle() const { return cangle; }
+ void setCubeAngle(qreal angle) { cangle = angle; update(); }
+
+ qreal orbitAngle() const { return oangle; }
+ void setOrbitAngle(qreal angle) { oangle = angle; update(); }
+
+protected:
+ void initializeGL(QGLPainter *painter);
+ void paintGL(QGLPainter *painter);
+
+private:
+ QGLSceneNode *scene;
+ QGLSceneNode *cube;
+ QGLSceneNode *teapot;
+ QGLTexture2D qtlogo;
+ QGLFramebufferObject *fbo;
+ QGLFramebufferObjectSurface fboSurface;
+ QGLCamera *innerCamera;
+ qreal tangle;
+ qreal cangle;
+ qreal oangle;
+
+ void drawCube1(QGLPainter *painter, const QVector3D &posn);
+ void drawCube2(QGLPainter *painter, const QVector3D &posn);
+};
+
+#endif
diff --git a/examples/nesting/main.cpp b/examples/nesting/main.cpp
new file mode 100644
index 000000000..f3d5764d0
--- /dev/null
+++ b/examples/nesting/main.cpp
@@ -0,0 +1,57 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtQuick3D examples of the Qt Toolkit.
+**
+** $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 Nokia Corporation and its Subsidiary(-ies) 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 <QApplication>
+#include "cubeview.h"
+
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+ CubeView view;
+ if (view.stereoType() != QGLView::RedCyanAnaglyph)
+ view.camera()->setEyeSeparation(0.5f);
+ if (QApplication::arguments().contains(QLatin1String("-maximize")))
+ view.showMaximized();
+ else if (QApplication::arguments().contains(QLatin1String("-fullscreen")))
+ view.showFullScreen();
+ else
+ view.show();
+ return app.exec();
+}
diff --git a/examples/nesting/nesting.pro b/examples/nesting/nesting.pro
new file mode 100644
index 000000000..0ea63d333
--- /dev/null
+++ b/examples/nesting/nesting.pro
@@ -0,0 +1,7 @@
+TEMPLATE = app
+TARGET = nesting
+CONFIG += qt warn_on qt3d
+SOURCES = cubeview.cpp main.cpp
+HEADERS = cubeview.h
+RESOURCES = nesting.qrc
+DESTDIR = ../../bin
diff --git a/examples/nesting/nesting.qrc b/examples/nesting/nesting.qrc
new file mode 100644
index 000000000..70f5024d9
--- /dev/null
+++ b/examples/nesting/nesting.qrc
@@ -0,0 +1,5 @@
+<!DOCTYPE RCC><RCC version="1.0">
+<qresource>
+ <file>qtlogo.png</file>
+</qresource>
+</RCC>
diff --git a/examples/nesting/qtlogo.png b/examples/nesting/qtlogo.png
new file mode 100644
index 000000000..7d3e97eb3
--- /dev/null
+++ b/examples/nesting/qtlogo.png
Binary files differ
diff --git a/examples/tank/main.cpp b/examples/tank/main.cpp
new file mode 100644
index 000000000..ee9c1429b
--- /dev/null
+++ b/examples/tank/main.cpp
@@ -0,0 +1,56 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtQuick3D examples of the Qt Toolkit.
+**
+** $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 Nokia Corporation and its Subsidiary(-ies) 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 <QtGui/QApplication>
+
+#include <time.h>
+
+#include "tankview.h"
+
+int main(int argc, char *argv[])
+{
+ qsrand(time(0));
+
+ QApplication a(argc, argv);
+ TankView w;
+ w.show();
+
+ return a.exec();
+}
diff --git a/examples/tank/quadplane.cpp b/examples/tank/quadplane.cpp
new file mode 100644
index 000000000..fb3cf16b7
--- /dev/null
+++ b/examples/tank/quadplane.cpp
@@ -0,0 +1,107 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtQuick3D examples of the Qt Toolkit.
+**
+** $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 Nokia Corporation and its Subsidiary(-ies) 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 "quadplane.h"
+#include "qgraphicsrotation3d.h"
+
+QGLMaterial *qCreateFloor()
+{
+ quint32 sz = 512;
+ QImage image(QSize(sz, sz), QImage::Format_ARGB32);
+ QRgb col = qRgba(196, 196, 200, 255);
+ image.fill(col);
+ QPainter painter(&image);
+ QPen pen = painter.pen();
+ pen.setColor(QColor(col).darker());
+ pen.setWidth(2);
+ painter.setPen(pen);
+ for (quint32 i = 0; i < sz; i += (sz / 8))
+ {
+ painter.drawLine(0, i, sz-1, i);
+ painter.drawLine(i, 0, i, sz-1);
+ }
+ painter.end();
+ QGLMaterial *mat = new QGLMaterial;
+ QGLTexture2D *tex = new QGLTexture2D(mat);
+ tex->setImage(image);
+ mat->setTexture(tex);
+ return mat;
+}
+
+QuadPlane::QuadPlane(QObject *parent, QSizeF size, int level)
+ : QGLSceneNode(parent)
+{
+ setObjectName("QuadPlane");
+ if (level > 8)
+ level = 8;
+ if (level < 1)
+ level = 1;
+ int divisions = 1;
+ for ( ; level--; divisions *= 2) {} // integer 2**n
+ QSizeF div = size / float(divisions);
+ QSizeF half = size / 2.0f;
+ QGLBuilder builder;
+ QGeometryData zip;
+ QGeometryData zip2;
+ for (int yy = 0; yy <= divisions; ++yy)
+ {
+ qreal y = half.height() - float(yy) * div.height();
+ qreal texY = float(yy) / divisions;
+ for (int xx = 0; xx <= divisions; ++xx)
+ {
+ qreal x = half.width() - float(xx) * div.width();
+ qreal texX = float(xx) / divisions;
+ zip.appendVertex(QVector3D(x, y, 0));
+ zip.appendTexCoord(QVector2D(1.0f - texX, 1.0f - texY));
+ }
+ if (yy > 0)
+ builder.addQuadsInterleaved(zip, zip2);
+ zip2 = zip;
+ zip2.detach();
+ zip.clear();
+ }
+ QGLSceneNode *n = builder.finalizedSceneNode();
+ addNode(n);
+ n->setMaterial(qCreateFloor());
+ QGraphicsRotation3D *rot = new QGraphicsRotation3D(n);
+ rot->setAxis(QVector3D(1, 0, 0));
+ rot->setAngle(90.0f);
+ n->addTransform(rot);
+}
diff --git a/examples/tank/quadplane.h b/examples/tank/quadplane.h
new file mode 100644
index 000000000..2ffc1963a
--- /dev/null
+++ b/examples/tank/quadplane.h
@@ -0,0 +1,55 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtQuick3D examples of the Qt Toolkit.
+**
+** $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 Nokia Corporation and its Subsidiary(-ies) 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$
+**
+****************************************************************************/
+
+#ifndef QUADPLANE_H
+#define QUADPLANE_H
+
+#include "qglbuilder.h"
+
+#include <QSizeF>
+
+class QuadPlane : public QGLSceneNode
+{
+public:
+ QuadPlane(QObject *parent = 0,
+ QSizeF size = QSizeF(100.0f, 100.0f), int level = 3);
+};
+
+#endif // QUADPLANE_H
diff --git a/examples/tank/tank.cpp b/examples/tank/tank.cpp
new file mode 100644
index 000000000..fe4fa8e8b
--- /dev/null
+++ b/examples/tank/tank.cpp
@@ -0,0 +1,136 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtQuick3D examples of the Qt Toolkit.
+**
+** $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 Nokia Corporation and its Subsidiary(-ies) 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 "tank.h"
+
+#include <QSequentialAnimationGroup>
+#include <QPropertyAnimation>
+#include <QImage>
+#include <QPainter>
+#include <QSize>
+
+#ifndef QT_NO_DEBUG
+#include <QThread>
+#include <QCoreApplication>
+#endif
+
+#include "qglbuilder.h"
+#include "qglcylinder.h"
+#include "qglmaterial.h"
+#include "qgltexture2d.h"
+#include "qgraphicsscale3d.h"
+#include "qgraphicsrotation3d.h"
+
+static inline int rval()
+{
+ // return an int 64 <--> 192 inclusive
+ return (qreal(qrand()) / qreal(RAND_MAX)) * 128 + 64;
+}
+
+static QGLMaterial *qCreateFluid()
+{
+ QImage image(QSize(128,128), QImage::Format_ARGB32);
+ QRgb col = qRgba(rval(), rval(), rval(), 196);
+ image.fill(col);
+ QPainter painter(&image);
+ QLinearGradient linearGrad(QPointF(56, 56), QPointF(72, 72));
+ linearGrad.setColorAt(0, col);
+ linearGrad.setColorAt(1, QColor(col).lighter());
+ linearGrad.setSpread(QGradient::ReflectSpread);
+ painter.fillRect(image.rect(), linearGrad);
+ painter.end();
+ QGLMaterial *mat = new QGLMaterial;
+ QColor white(Qt::white);
+ white.setAlpha(128);
+ mat->setAmbientColor(white);
+ mat->setDiffuseColor(white);
+ QGLTexture2D *tex = new QGLTexture2D(mat);
+ tex->setImage(image);
+ mat->setTexture(tex);
+ return mat;
+}
+
+Tank::Tank(QObject *parent) :
+ QGLSceneNode(parent)
+{
+ QSequentialAnimationGroup *seq = new QSequentialAnimationGroup(this);
+ QGraphicsScale3D *scale = new QGraphicsScale3D(this);
+ addTransform(scale);
+ QPropertyAnimation *anim = new QPropertyAnimation(scale, "scale");
+ anim->setDuration(10000);
+ anim->setStartValue(QVector3D(1.0f, 0.1f, 1.0f));
+ anim->setEndValue(QVector3D(1.0f, 1.2f, 1.0f));
+ anim->setEasingCurve(QEasingCurve(QEasingCurve::InOutQuad));
+ seq->addAnimation(anim);
+ seq->addPause(2000);
+ anim = new QPropertyAnimation(scale, "scale");
+ anim->setDuration(10000);
+ anim->setStartValue(QVector3D(1.0f, 1.2f, 1.0f));
+ anim->setEndValue(QVector3D(1.0f, 0.1f, 1.0f));
+ anim->setEasingCurve(QEasingCurve(QEasingCurve::InOutQuad));
+ seq->addAnimation(anim);
+ seq->setLoopCount(-1);
+ seq->start();
+
+ addNode(tankObject());
+ setMaterial(qCreateFluid());
+}
+
+QGLSceneNode *Tank::tankObject()
+{
+#ifndef QT_NO_DEBUG
+ // NOT THREADSAFE, NOT RE-ENTRANT
+ Q_ASSERT(QThread::currentThread() == qApp->thread());
+#endif
+ static QGLSceneNode *theTank = 0;
+ if (!theTank)
+ {
+ QGLBuilder build;
+ build << QGLCylinder(1.0f, 1.0f, 1.0f, 32);
+ theTank = build.finalizedSceneNode();
+ theTank->setObjectName("Tank Component");
+ QGraphicsRotation3D *rot = new QGraphicsRotation3D(theTank);
+ rot->setAxis(QVector3D(1, 0, 0));
+ rot->setAngle(-90.0f);
+ theTank->addTransform(rot);
+ theTank->setY(-theTank->boundingBox().minimum().y());
+ }
+ return theTank;
+}
diff --git a/examples/tank/tank.h b/examples/tank/tank.h
new file mode 100644
index 000000000..894496404
--- /dev/null
+++ b/examples/tank/tank.h
@@ -0,0 +1,59 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtQuick3D examples of the Qt Toolkit.
+**
+** $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 Nokia Corporation and its Subsidiary(-ies) 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$
+**
+****************************************************************************/
+
+#ifndef TANK_H
+#define TANK_H
+
+#include "qglscenenode.h"
+
+class Tank : public QGLSceneNode
+{
+ Q_OBJECT
+public:
+ explicit Tank(QObject *parent = 0);
+
+signals:
+
+public slots:
+private:
+ static QGLSceneNode *tankObject();
+};
+
+#endif // TANK_H
diff --git a/examples/tank/tank.pro b/examples/tank/tank.pro
new file mode 100644
index 000000000..50b916ff6
--- /dev/null
+++ b/examples/tank/tank.pro
@@ -0,0 +1,14 @@
+CONFIG += qt warn_on qt3d
+TARGET = tank
+TEMPLATE = app
+
+SOURCES += main.cpp\
+ tankview.cpp \
+ tank.cpp \
+ quadplane.cpp
+
+HEADERS += tankview.h \
+ tank.h \
+ quadplane.h
+
+DESTDIR = ../../bin
diff --git a/examples/tank/tankview.cpp b/examples/tank/tankview.cpp
new file mode 100644
index 000000000..9d4d7afbc
--- /dev/null
+++ b/examples/tank/tankview.cpp
@@ -0,0 +1,116 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtQuick3D examples of the Qt Toolkit.
+**
+** $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 Nokia Corporation and its Subsidiary(-ies) 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 "tankview.h"
+#include "tank.h"
+#include "quadplane.h"
+
+#include "qglscenenode.h"
+#include "qray3d.h"
+#include "qplane3d.h"
+
+#include <QMouseEvent>
+
+TankView::TankView(QWidget *parent)
+ : QGLView(parent)
+ , m_tankScene(new QGLSceneNode)
+ , m_count(0)
+{
+ m_tankScene->setParent(this);
+ m_tankScene->setPalette(new QGLMaterialCollection(this));
+ m_tankScene->setEffect(QGL::LitDecalTexture2D);
+ m_tankScene->addNode(new QuadPlane(0, QSizeF(25, 25)));
+ Tank *tank = addTank();
+ connect(tank, SIGNAL(updated()), this, SLOT(update()));
+
+ qDumpScene(m_tankScene);
+
+ setToolTip(tr("Double-click to add more tanks"));
+ setWindowTitle(tr("Double-click Me!"));
+}
+
+TankView::~TankView()
+{
+}
+
+Tank *TankView::addTank()
+{
+ Tank *tank = new Tank(m_tankScene);
+ tank->setObjectName(QString(QLatin1String("Tank %1")).arg(m_count));
+ ++m_count;
+ connect(tank, SIGNAL(updated()), this, SLOT(update()));
+ return tank;
+}
+
+void TankView::paintGL(QGLPainter *painter)
+{
+ glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
+ m_tankScene->draw(painter);
+}
+
+void TankView::initializeGL(QGLPainter *painter)
+{
+ painter->setClearColor(Qt::gray);
+ camera()->setEye(camera()->eye() + QVector3D(0.0f, 4.0f, 0.0f));
+ glEnable(GL_BLEND);
+}
+
+void TankView::mouseDoubleClickEvent(QMouseEvent *e)
+{
+ Tank *t = addTank();
+ QVector3D pick = mapPoint(e->pos());
+
+ // find the origin of the near plane
+ QRay3D eyeline(camera()->eye(), (camera()->center() - camera()->eye()).normalized());
+ QVector3D nearPlaneOrigin = eyeline.point(camera()->nearPlane());
+
+ // from the near plane origin move up and across by the pick's XY to find the point
+ // on the near plane
+ QRay3D up(nearPlaneOrigin, camera()->upVector());
+ QVector3D sideDir = QVector3D::crossProduct(camera()->upVector(), -eyeline.direction());
+ QRay3D side(up.point(pick.y()), sideDir.normalized());
+ QVector3D v = side.point(pick.x());
+
+ // intersect the ray thru the picked point on the near plane with the floor
+ QRay3D ray(camera()->eye(), v - camera()->eye());
+ QPlane3D floorPlane(QVector3D(), QVector3D(0, 1, 0));
+ QVector3D pointOnFloor = ray.point(floorPlane.intersection(ray));
+ t->setPosition(pointOnFloor);
+}
diff --git a/examples/tank/tankview.h b/examples/tank/tankview.h
new file mode 100644
index 000000000..38b966158
--- /dev/null
+++ b/examples/tank/tankview.h
@@ -0,0 +1,67 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtQuick3D examples of the Qt Toolkit.
+**
+** $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 Nokia Corporation and its Subsidiary(-ies) 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$
+**
+****************************************************************************/
+
+#ifndef TANKVIEW_H
+#define TANKVIEW_H
+
+#include "qglview.h"
+
+class QGLSceneNode;
+class Tank;
+
+class TankView : public QGLView
+{
+public:
+ TankView(QWidget *parent = 0);
+ ~TankView();
+protected:
+ void initializeGL(QGLPainter *painter);
+ void paintGL(QGLPainter *painter);
+ void mouseDoubleClickEvent(QMouseEvent *e);
+private:
+ Tank *addTank();
+
+ QGLSceneNode *m_tankScene;
+ int m_count;
+};
+
+
+
+#endif // TANKVIEW_H
diff --git a/examples/teapot/main.cpp b/examples/teapot/main.cpp
new file mode 100644
index 000000000..e14a10306
--- /dev/null
+++ b/examples/teapot/main.cpp
@@ -0,0 +1,61 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtQuick3D examples of the Qt Toolkit.
+**
+** $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 Nokia Corporation and its Subsidiary(-ies) 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 <QApplication>
+#include "teapotview.h"
+
+//! [main]
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+ TeapotView view;
+//! [main-args]
+ if (view.stereoType() != QGLView::RedCyanAnaglyph)
+ view.camera()->setEyeSeparation(0.3f);
+ if (QApplication::arguments().contains(QLatin1String("-maximize")))
+ view.showMaximized();
+ else if (QApplication::arguments().contains(QLatin1String("-fullscreen")))
+ view.showFullScreen();
+ else
+ view.show();
+//! [main-args-end]
+ return app.exec();
+}
+//! [main]
diff --git a/examples/teapot/teapot.pro b/examples/teapot/teapot.pro
new file mode 100644
index 000000000..1024f6a72
--- /dev/null
+++ b/examples/teapot/teapot.pro
@@ -0,0 +1,6 @@
+TEMPLATE = app
+TARGET = teapot
+CONFIG += qt warn_on qt3d
+SOURCES = teapotview.cpp main.cpp
+HEADERS = teapotview.h
+DESTDIR = ../../bin
diff --git a/examples/teapot/teapotview.cpp b/examples/teapot/teapotview.cpp
new file mode 100644
index 000000000..2ffe53a34
--- /dev/null
+++ b/examples/teapot/teapotview.cpp
@@ -0,0 +1,68 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtQuick3D examples of the Qt Toolkit.
+**
+** $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 Nokia Corporation and its Subsidiary(-ies) 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 "teapotview.h"
+#include "qglbuilder.h"
+#include "qglscenenode.h"
+
+//! [initialize]
+void TeapotView::initializeGL(QGLPainter *painter)
+{
+ painter->setStandardEffect(QGL::LitMaterial);
+//! [create-display-list]
+ QGLBuilder builder;
+ builder << QGLTeapot();
+ teapot = builder.finalizedSceneNode();
+}
+//! [initialize]
+
+//! [destructor]
+TeapotView::~TeapotView()
+{
+ delete teapot;
+}
+//! [destructor]
+
+//! [paint]
+void TeapotView::paintGL(QGLPainter *painter)
+{
+ teapot->draw(painter);
+}
+//! [paint]
diff --git a/examples/teapot/teapotview.h b/examples/teapot/teapotview.h
new file mode 100644
index 000000000..d251f990a
--- /dev/null
+++ b/examples/teapot/teapotview.h
@@ -0,0 +1,66 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtQuick3D examples of the Qt Toolkit.
+**
+** $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 Nokia Corporation and its Subsidiary(-ies) 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$
+**
+****************************************************************************/
+
+#ifndef TEAPOTVIEW_H
+#define TEAPOTVIEW_H
+
+//! [class-defn]
+#include "qglview.h"
+#include "qglteapot.h"
+
+class QGLSceneNode;
+
+class TeapotView : public QGLView
+{
+ Q_OBJECT
+public:
+ TeapotView(QWidget *parent = 0) : QGLView(parent), teapot(0) {}
+ ~TeapotView();
+
+protected:
+ void initializeGL(QGLPainter *painter);
+ void paintGL(QGLPainter *painter);
+
+private:
+ QGLSceneNode *teapot;
+};
+//! [class-defn]
+
+#endif
diff --git a/examples/tutorials/converting-rawgl/converting-rawgl.pro b/examples/tutorials/converting-rawgl/converting-rawgl.pro
new file mode 100644
index 000000000..8263b9a7d
--- /dev/null
+++ b/examples/tutorials/converting-rawgl/converting-rawgl.pro
@@ -0,0 +1,6 @@
+TEMPLATE = app
+TARGET = converting-rawgl
+CONFIG += qt warn_on
+QT += opengl
+VPATH += ../converting
+SOURCES = converting-rawgl.cpp
diff --git a/examples/tutorials/converting/converting-rawgl.cpp b/examples/tutorials/converting/converting-rawgl.cpp
new file mode 100644
index 000000000..e65abd3a9
--- /dev/null
+++ b/examples/tutorials/converting/converting-rawgl.cpp
@@ -0,0 +1,211 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtQuick3D examples of the Qt Toolkit.
+**
+** $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 Nokia Corporation and its Subsidiary(-ies) 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$
+**
+****************************************************************************/
+
+//! [class-defn]
+#include <QApplication>
+#include <QtOpenGL/qgl.h>
+
+class TutorialWidget : public QGLWidget
+{
+ Q_OBJECT
+public:
+ TutorialWidget(QWidget *parent=0) : QGLWidget(parent) {}
+
+protected:
+ void resizeGL(int width, int height);
+ void paintGL();
+#if defined(QT_OPENGL_ES_2)
+ void initializeGL();
+
+private:
+ GLuint program;
+ GLuint vertexAttr;
+ GLuint matrixUniform;
+ GLuint colorUniform;
+#endif
+};
+//! [class-defn]
+
+//! [set-viewport]
+void TutorialWidget::resizeGL(int width, int height)
+{
+ glViewport(0, 0, width, height);
+}
+//! [set-viewport]
+
+#if !defined(QT_OPENGL_ES_2)
+
+//! [clear-window]
+void TutorialWidget::paintGL()
+{
+ QColor clearColor(palette().color(backgroundRole()));
+ glClearColor(clearColor.redF(), clearColor.greenF(),
+ clearColor.blueF(), clearColor.alphaF());
+ glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
+//! [clear-window]
+
+//! [set-matrices]
+ glMatrixMode(GL_PROJECTION);
+ glLoadIdentity();
+ glOrtho(0, width(), height(), 0, -1.0f, 1.0f);
+
+ glMatrixMode(GL_MODELVIEW);
+ glLoadIdentity();
+//! [set-matrices]
+
+//! [draw]
+ QColor color(170, 202, 0, 255);
+ glColor4f(color.redF(), color.greenF(), color.blueF(), color.alphaF());
+
+ static GLfloat vertices[] = {
+ 60.0f, 10.0f, 0.0f,
+ 110.0f, 110.0f, 0.0f,
+ 10.0f, 110.0f, 0.0f
+ };
+
+ glVertexPointer(3, GL_FLOAT, 0, vertices);
+ glEnableClientState(GL_VERTEX_ARRAY);
+ glDrawArrays(GL_TRIANGLES, 0, 3);
+ glDisableClientState(GL_VERTEX_ARRAY);
+//! [draw]
+}
+
+#else // QT_OPENGL_ES_2
+
+void TutorialWidget::initializeGL()
+{
+ GLuint vshader = glCreateShader(GL_VERTEX_SHADER);
+ const char *vsrc[1] = {
+ "attribute highp vec4 vertex;\n"
+ "uniform mediump mat4 matrix;\n"
+ "void main(void)\n"
+ "{\n"
+ " gl_Position = matrix * vertex;\n"
+ "}\n"
+ };
+ glShaderSource(vshader, 1, vsrc, 0);
+ glCompileShader(vshader);
+
+ GLuint fshader = glCreateShader(GL_FRAGMENT_SHADER);
+ const char *fsrc[1] = {
+ "uniform mediump vec4 color;\n"
+ "void main(void)\n"
+ "{\n"
+ " gl_FragColor = color;\n"
+ "}\n"
+ };
+ glShaderSource(fshader, 1, fsrc, 0);
+ glCompileShader(fshader);
+
+ program = glCreateProgram();
+ glAttachShader(program, vshader);
+ glAttachShader(program, fshader);
+ glLinkProgram(program);
+
+ vertexAttr = glGetAttribLocation(program, "vertex");
+ matrixUniform = glGetUniformLocation(program, "matrix");
+ colorUniform = glGetUniformLocation(program, "color");
+
+ glUseProgram(program);
+}
+
+void TutorialWidget::paintGL()
+{
+ QColor clearColor(palette().color(backgroundRole()));
+ glClearColor(clearColor.redF(), clearColor.greenF(),
+ clearColor.blueF(), clearColor.alphaF());
+ glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
+
+ GLfloat width = this->width();
+ GLfloat height = this->height();
+ GLfloat left = 0.0f;
+ GLfloat right = width;
+ GLfloat top = 0.0f;
+ GLfloat bottom = height;
+ GLfloat nearPlane = -1.0f;
+ GLfloat farPlane = 1.0f;
+ GLfloat clip = farPlane - nearPlane;
+ GLfloat mat[4][4];
+ mat[0][0] = 2.0f / width;
+ mat[1][0] = 0.0f;
+ mat[2][0] = 0.0f;
+ mat[3][0] = -(left + right) / width;
+ mat[0][1] = 0.0f;
+ mat[1][1] = 2.0f / -height;
+ mat[2][1] = 0.0f;
+ mat[3][1] = -(top + bottom) / -height;
+ mat[0][2] = 0.0f;
+ mat[1][2] = 0.0f;
+ mat[2][2] = -2.0f / clip;
+ mat[3][2] = -(nearPlane + farPlane) / clip;
+ mat[0][3] = 0.0f;
+ mat[1][3] = 0.0f;
+ mat[2][3] = 0.0f;
+ mat[3][3] = 1.0f;
+ glUniformMatrix4fv(matrixUniform, 1, GL_FALSE, mat[0]);
+
+ QColor color(170, 202, 0, 255);
+ glUniform4f(colorUniform, color.redF(), color.greenF(), color.blueF(), color.alphaF());
+
+ static GLfloat vertices[] = {
+ 60.0f, 10.0f, 0.0f,
+ 110.0f, 110.0f, 0.0f,
+ 10.0f, 110.0f, 0.0f
+ };
+
+ glVertexAttribPointer(vertexAttr, 3, GL_FLOAT, GL_FALSE, 0, vertices);
+ glEnableVertexAttribArray(vertexAttr);
+ glDrawArrays(GL_TRIANGLES, 0, 3);
+ glDisableVertexAttribArray(vertexAttr);
+}
+
+#endif // QT_OPENGL_ES_2
+
+//! [main]
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+ TutorialWidget widget;
+ widget.show();
+ return app.exec();
+}
+//! [main]
+
+#include "converting-rawgl.moc"
diff --git a/examples/tutorials/converting/converting.cpp b/examples/tutorials/converting/converting.cpp
new file mode 100644
index 000000000..51c47ffa8
--- /dev/null
+++ b/examples/tutorials/converting/converting.cpp
@@ -0,0 +1,109 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtQuick3D examples of the Qt Toolkit.
+**
+** $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 Nokia Corporation and its Subsidiary(-ies) 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$
+**
+****************************************************************************/
+
+//! [includes]
+#include <QApplication>
+#include <QtOpenGL/qgl.h>
+#include "qglpainter.h"
+//! [includes]
+
+//! [class-defn]
+class TutorialWidget : public QGLWidget
+{
+ Q_OBJECT
+public:
+ TutorialWidget(QWidget *parent=0) : QGLWidget(parent) {}
+
+protected:
+ void paintGL();
+};
+//! [class-defn]
+
+//! [paintGL]
+//! [clear-window]
+void TutorialWidget::paintGL()
+{
+ QGLPainter painter(this);
+
+ painter.setClearColor(palette().color(backgroundRole()));
+ glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
+//! [clear-window]
+
+//! [set-matrices]
+ QMatrix4x4 projm;
+ projm.ortho(rect());
+ painter.projectionMatrix() = projm;
+
+ painter.modelViewMatrix().setToIdentity();
+//! [set-matrices]
+
+//! [draw-all]
+//! [set-effect]
+ painter.setStandardEffect(QGL::FlatColor);
+ painter.setColor(QColor(170, 202, 0, 255));
+//! [set-effect]
+
+//! [create-vertex-array]
+ QVector3DArray vertices;
+ vertices.append(60.0f, 10.0f, 0.0f);
+ vertices.append(110.0f, 110.0f, 0.0f);
+ vertices.append(10.0f, 110.0f, 0.0f);
+//! [create-vertex-array]
+
+//! [draw]
+ painter.clearAttributes();
+ painter.setVertexAttribute(QGL::Position, vertices);
+ painter.draw(QGL::Triangles, 3);
+//! [draw]
+//! [draw-all]
+}
+//! [paintGL]
+
+//! [main]
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+ TutorialWidget widget;
+ widget.show();
+ return app.exec();
+}
+//! [main]
+
+#include "converting.moc"
diff --git a/examples/tutorials/converting/converting.pro b/examples/tutorials/converting/converting.pro
new file mode 100644
index 000000000..b4febdaa5
--- /dev/null
+++ b/examples/tutorials/converting/converting.pro
@@ -0,0 +1,8 @@
+TEMPLATE = app
+TARGET = converting
+CONFIG += qt warn_on
+QT += opengl
+SOURCES = converting.cpp
+LIBS += -L../../../lib -L../../../bin
+
+include(../../../src/threed/threed_dep.pri)
diff --git a/examples/tutorials/cube1/cube1.pro b/examples/tutorials/cube1/cube1.pro
new file mode 100644
index 000000000..51df0efe0
--- /dev/null
+++ b/examples/tutorials/cube1/cube1.pro
@@ -0,0 +1,5 @@
+TEMPLATE = app
+TARGET = cube1
+CONFIG += qt warn_on qt3d
+SOURCES = cubeview.cpp main.cpp
+HEADERS = cubeview.h
diff --git a/examples/tutorials/cube1/cubeview.cpp b/examples/tutorials/cube1/cubeview.cpp
new file mode 100644
index 000000000..51e074f62
--- /dev/null
+++ b/examples/tutorials/cube1/cubeview.cpp
@@ -0,0 +1,67 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtQuick3D examples of the Qt Toolkit.
+**
+** $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 Nokia Corporation and its Subsidiary(-ies) 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 "cubeview.h"
+#include "qglbuilder.h"
+#include "qglcube.h"
+
+//! [1]
+CubeView::CubeView(QWidget *parent)
+ : QGLView(parent)
+{
+ QGLBuilder builder;
+ builder << QGL::Faceted;
+ builder << QGLCube();
+
+ cube = builder.finalizedSceneNode();
+}
+//! [1]
+
+CubeView::~CubeView()
+{
+ delete cube;
+}
+
+//! [2]
+void CubeView::paintGL(QGLPainter *painter)
+{
+ cube->draw(painter);
+}
+//! [2]
diff --git a/examples/tutorials/cube1/cubeview.h b/examples/tutorials/cube1/cubeview.h
new file mode 100644
index 000000000..04238f58d
--- /dev/null
+++ b/examples/tutorials/cube1/cubeview.h
@@ -0,0 +1,64 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtQuick3D examples of the Qt Toolkit.
+**
+** $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 Nokia Corporation and its Subsidiary(-ies) 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$
+**
+****************************************************************************/
+
+#ifndef CUBEVIEW_H
+#define CUBEVIEW_H
+
+#include "qglview.h"
+
+class QGLSceneNode;
+
+//! [1]
+class CubeView : public QGLView
+{
+ Q_OBJECT
+public:
+ CubeView(QWidget *parent = 0);
+ ~CubeView();
+
+protected:
+ void paintGL(QGLPainter *painter);
+
+private:
+ QGLSceneNode *cube;
+};
+//! [1]
+
+#endif
diff --git a/examples/tutorials/cube1/main.cpp b/examples/tutorials/cube1/main.cpp
new file mode 100644
index 000000000..28fc9bb15
--- /dev/null
+++ b/examples/tutorials/cube1/main.cpp
@@ -0,0 +1,50 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtQuick3D examples of the Qt Toolkit.
+**
+** $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 Nokia Corporation and its Subsidiary(-ies) 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 <QApplication>
+#include "cubeview.h"
+
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+ CubeView view;
+ view.show();
+ return app.exec();
+}
diff --git a/examples/tutorials/cube2/cube2.pro b/examples/tutorials/cube2/cube2.pro
new file mode 100644
index 000000000..3bf258831
--- /dev/null
+++ b/examples/tutorials/cube2/cube2.pro
@@ -0,0 +1,5 @@
+TEMPLATE = app
+TARGET = cube2
+CONFIG += qt warn_on qt3d
+SOURCES = cubeview.cpp main.cpp
+HEADERS = cubeview.h
diff --git a/examples/tutorials/cube2/cubeview.cpp b/examples/tutorials/cube2/cubeview.cpp
new file mode 100644
index 000000000..1dca459a8
--- /dev/null
+++ b/examples/tutorials/cube2/cubeview.cpp
@@ -0,0 +1,66 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtQuick3D examples of the Qt Toolkit.
+**
+** $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 Nokia Corporation and its Subsidiary(-ies) 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 "cubeview.h"
+#include "qglbuilder.h"
+#include "qglcube.h"
+
+CubeView::CubeView(QWidget *parent)
+ : QGLView(parent)
+{
+ QGLBuilder builder;
+ builder << QGL::Faceted;
+ builder << QGLCube();
+
+ cube = builder.finalizedSceneNode();
+}
+
+CubeView::~CubeView()
+{
+ delete cube;
+}
+
+//! [2]
+void CubeView::paintGL(QGLPainter *painter)
+{
+ painter->modelViewMatrix().rotate(45.0f, 1.0f, 1.0f, 1.0f);
+ cube->draw(painter);
+}
+//! [2]
diff --git a/examples/tutorials/cube2/cubeview.h b/examples/tutorials/cube2/cubeview.h
new file mode 100644
index 000000000..04238f58d
--- /dev/null
+++ b/examples/tutorials/cube2/cubeview.h
@@ -0,0 +1,64 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtQuick3D examples of the Qt Toolkit.
+**
+** $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 Nokia Corporation and its Subsidiary(-ies) 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$
+**
+****************************************************************************/
+
+#ifndef CUBEVIEW_H
+#define CUBEVIEW_H
+
+#include "qglview.h"
+
+class QGLSceneNode;
+
+//! [1]
+class CubeView : public QGLView
+{
+ Q_OBJECT
+public:
+ CubeView(QWidget *parent = 0);
+ ~CubeView();
+
+protected:
+ void paintGL(QGLPainter *painter);
+
+private:
+ QGLSceneNode *cube;
+};
+//! [1]
+
+#endif
diff --git a/examples/tutorials/cube2/main.cpp b/examples/tutorials/cube2/main.cpp
new file mode 100644
index 000000000..28fc9bb15
--- /dev/null
+++ b/examples/tutorials/cube2/main.cpp
@@ -0,0 +1,50 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtQuick3D examples of the Qt Toolkit.
+**
+** $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 Nokia Corporation and its Subsidiary(-ies) 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 <QApplication>
+#include "cubeview.h"
+
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+ CubeView view;
+ view.show();
+ return app.exec();
+}
diff --git a/examples/tutorials/cube3/cube3.pro b/examples/tutorials/cube3/cube3.pro
new file mode 100644
index 000000000..70b049fe2
--- /dev/null
+++ b/examples/tutorials/cube3/cube3.pro
@@ -0,0 +1,5 @@
+TEMPLATE = app
+TARGET = cube3
+CONFIG += qt warn_on qt3d
+SOURCES = cubeview.cpp main.cpp
+HEADERS = cubeview.h
diff --git a/examples/tutorials/cube3/cubeview.cpp b/examples/tutorials/cube3/cubeview.cpp
new file mode 100644
index 000000000..80c3e0f1a
--- /dev/null
+++ b/examples/tutorials/cube3/cubeview.cpp
@@ -0,0 +1,69 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtQuick3D examples of the Qt Toolkit.
+**
+** $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 Nokia Corporation and its Subsidiary(-ies) 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 "cubeview.h"
+#include "qglbuilder.h"
+#include "qglcube.h"
+
+CubeView::CubeView(QWidget *parent)
+ : QGLView(parent)
+{
+ QGLBuilder builder;
+ builder << QGL::Faceted;
+ builder << QGLCube();
+
+ cube = builder.finalizedSceneNode();
+}
+
+CubeView::~CubeView()
+{
+ delete cube;
+}
+
+//! [2]
+void CubeView::paintGL(QGLPainter *painter)
+{
+ painter->setStandardEffect(QGL::LitMaterial);
+ painter->setFaceColor(QGL::AllFaces, QColor(170, 202, 0));
+
+ painter->modelViewMatrix().rotate(45.0f, 1.0f, 1.0f, 1.0f);
+ cube->draw(painter);
+}
+//! [2]
diff --git a/examples/tutorials/cube3/cubeview.h b/examples/tutorials/cube3/cubeview.h
new file mode 100644
index 000000000..04238f58d
--- /dev/null
+++ b/examples/tutorials/cube3/cubeview.h
@@ -0,0 +1,64 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtQuick3D examples of the Qt Toolkit.
+**
+** $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 Nokia Corporation and its Subsidiary(-ies) 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$
+**
+****************************************************************************/
+
+#ifndef CUBEVIEW_H
+#define CUBEVIEW_H
+
+#include "qglview.h"
+
+class QGLSceneNode;
+
+//! [1]
+class CubeView : public QGLView
+{
+ Q_OBJECT
+public:
+ CubeView(QWidget *parent = 0);
+ ~CubeView();
+
+protected:
+ void paintGL(QGLPainter *painter);
+
+private:
+ QGLSceneNode *cube;
+};
+//! [1]
+
+#endif
diff --git a/examples/tutorials/cube3/main.cpp b/examples/tutorials/cube3/main.cpp
new file mode 100644
index 000000000..28fc9bb15
--- /dev/null
+++ b/examples/tutorials/cube3/main.cpp
@@ -0,0 +1,50 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtQuick3D examples of the Qt Toolkit.
+**
+** $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 Nokia Corporation and its Subsidiary(-ies) 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 <QApplication>
+#include "cubeview.h"
+
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+ CubeView view;
+ view.show();
+ return app.exec();
+}
diff --git a/examples/tutorials/cube4/cube.qml b/examples/tutorials/cube4/cube.qml
new file mode 100644
index 000000000..d4ba6d995
--- /dev/null
+++ b/examples/tutorials/cube4/cube.qml
@@ -0,0 +1,61 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtQuick3D examples of the Qt Toolkit.
+**
+** $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 Nokia Corporation and its Subsidiary(-ies) 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$
+**
+****************************************************************************/
+
+//! [1]
+import Qt 4.7
+import Qt3D 1.0
+import Qt3D.Shapes 1.0
+
+Viewport {
+ width: 640; height: 480
+
+ Cube {
+ transform: Rotation3D {
+ angle: 45; axis: Qt.vector3d(1, 1, 1)
+ }
+
+ effect: Effect {
+ color: "#aaca00";
+ texture: "qtlogo.png"
+ decal: true
+ }
+ }
+}
+//! [1]
diff --git a/examples/tutorials/cube4/cube.qrc b/examples/tutorials/cube4/cube.qrc
new file mode 100644
index 000000000..70f5024d9
--- /dev/null
+++ b/examples/tutorials/cube4/cube.qrc
@@ -0,0 +1,5 @@
+<!DOCTYPE RCC><RCC version="1.0">
+<qresource>
+ <file>qtlogo.png</file>
+</qresource>
+</RCC>
diff --git a/examples/tutorials/cube4/cube4.pro b/examples/tutorials/cube4/cube4.pro
new file mode 100644
index 000000000..a2f4ba79c
--- /dev/null
+++ b/examples/tutorials/cube4/cube4.pro
@@ -0,0 +1,6 @@
+TEMPLATE = app
+TARGET = cube4
+CONFIG += qt warn_on qt3d
+SOURCES = cubeview.cpp main.cpp
+HEADERS = cubeview.h
+RESOURCES = cube.qrc
diff --git a/examples/tutorials/cube4/cubeview.cpp b/examples/tutorials/cube4/cubeview.cpp
new file mode 100644
index 000000000..e3045292b
--- /dev/null
+++ b/examples/tutorials/cube4/cubeview.cpp
@@ -0,0 +1,76 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtQuick3D examples of the Qt Toolkit.
+**
+** $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 Nokia Corporation and its Subsidiary(-ies) 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 "cubeview.h"
+#include "qglbuilder.h"
+#include "qglcube.h"
+
+//! [1]
+CubeView::CubeView(QWidget *parent)
+ : QGLView(parent)
+{
+//! [1]
+ QGLBuilder builder;
+ builder << QGL::Faceted;
+ builder << QGLCube();
+
+ cube = builder.finalizedSceneNode();
+
+//! [2]
+ logo.setImage(QImage(QLatin1String(":/qtlogo.png")));
+}
+//! [2]
+
+CubeView::~CubeView()
+{
+ delete cube;
+}
+
+//! [3]
+void CubeView::paintGL(QGLPainter *painter)
+{
+ painter->setStandardEffect(QGL::LitDecalTexture2D);
+ painter->setFaceColor(QGL::AllFaces, QColor(170, 202, 0));
+ logo.bind();
+
+ painter->modelViewMatrix().rotate(45.0f, 1.0f, 1.0f, 1.0f);
+ cube->draw(painter);
+}
+//! [3]
diff --git a/examples/tutorials/cube4/cubeview.h b/examples/tutorials/cube4/cubeview.h
new file mode 100644
index 000000000..4f00216ca
--- /dev/null
+++ b/examples/tutorials/cube4/cubeview.h
@@ -0,0 +1,68 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtQuick3D examples of the Qt Toolkit.
+**
+** $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 Nokia Corporation and its Subsidiary(-ies) 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$
+**
+****************************************************************************/
+
+#ifndef CUBEVIEW_H
+#define CUBEVIEW_H
+
+#include "qglview.h"
+#include "qgltexture2d.h"
+
+class QGLSceneNode;
+
+//! [1]
+class CubeView : public QGLView
+{
+//! [1]
+ Q_OBJECT
+public:
+ CubeView(QWidget *parent = 0);
+ ~CubeView();
+
+protected:
+ void paintGL(QGLPainter *painter);
+
+//! [2]
+private:
+ QGLSceneNode *cube;
+ QGLTexture2D logo;
+};
+//! [2]
+
+#endif
diff --git a/examples/tutorials/cube4/main.cpp b/examples/tutorials/cube4/main.cpp
new file mode 100644
index 000000000..28fc9bb15
--- /dev/null
+++ b/examples/tutorials/cube4/main.cpp
@@ -0,0 +1,50 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtQuick3D examples of the Qt Toolkit.
+**
+** $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 Nokia Corporation and its Subsidiary(-ies) 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 <QApplication>
+#include "cubeview.h"
+
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+ CubeView view;
+ view.show();
+ return app.exec();
+}
diff --git a/examples/tutorials/cube4/qtlogo.png b/examples/tutorials/cube4/qtlogo.png
new file mode 100644
index 000000000..7d3e97eb3
--- /dev/null
+++ b/examples/tutorials/cube4/qtlogo.png
Binary files differ
diff --git a/examples/tutorials/penguin/main.cpp b/examples/tutorials/penguin/main.cpp
new file mode 100644
index 000000000..e5c995db3
--- /dev/null
+++ b/examples/tutorials/penguin/main.cpp
@@ -0,0 +1,51 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtQuick3D examples of the Qt Toolkit.
+**
+** $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 Nokia Corporation and its Subsidiary(-ies) 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 <QApplication>
+
+#include "modelview.h"
+
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+ ModelView view;
+ view.show();
+ return app.exec();
+}
diff --git a/examples/tutorials/penguin/model.qrc b/examples/tutorials/penguin/model.qrc
new file mode 100644
index 000000000..2c330de09
--- /dev/null
+++ b/examples/tutorials/penguin/model.qrc
@@ -0,0 +1,5 @@
+<RCC>
+ <qresource prefix="/">
+ <file>penguin.3ds</file>
+ </qresource>
+</RCC>
diff --git a/examples/tutorials/penguin/modelview.cpp b/examples/tutorials/penguin/modelview.cpp
new file mode 100644
index 000000000..3ba6b7355
--- /dev/null
+++ b/examples/tutorials/penguin/modelview.cpp
@@ -0,0 +1,64 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtQuick3D examples of the Qt Toolkit.
+**
+** $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 Nokia Corporation and its Subsidiary(-ies) 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 "modelview.h"
+#include "qglabstractscene.h"
+
+ModelView::~ModelView()
+{
+ delete m_scene;
+}
+
+//! [initialize]
+void ModelView::initializeGL(QGLPainter *painter)
+{
+ Q_UNUSED(painter);
+
+ m_scene = QGLAbstractScene::loadScene(QLatin1String(":/penguin.3ds"));
+}
+//! [initialize]
+
+//! [paint]
+void ModelView::paintGL(QGLPainter *painter)
+{
+ QGLSceneNode *o = m_scene->mainNode();
+ o->draw(painter);
+}
+//! [paint]
diff --git a/examples/tutorials/penguin/modelview.h b/examples/tutorials/penguin/modelview.h
new file mode 100644
index 000000000..978b185f8
--- /dev/null
+++ b/examples/tutorials/penguin/modelview.h
@@ -0,0 +1,66 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtQuick3D examples of the Qt Toolkit.
+**
+** $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 Nokia Corporation and its Subsidiary(-ies) 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$
+**
+****************************************************************************/
+
+#ifndef MODELVIEW_H
+#define MODELVIEW_H
+
+//! [class-defn]
+#include "qglview.h"
+
+class QGLAbstractScene;
+class QGLSceneNode;
+
+class ModelView : public QGLView
+{
+ Q_OBJECT
+public:
+ ModelView(QWidget *parent = 0) : QGLView(parent) {}
+ ~ModelView();
+
+protected:
+ void initializeGL(QGLPainter *painter);
+ void paintGL(QGLPainter *painter);
+
+private:
+ QGLAbstractScene *m_scene;
+};
+//! [class-defn]
+
+#endif
diff --git a/examples/tutorials/penguin/penguin.3ds b/examples/tutorials/penguin/penguin.3ds
new file mode 100644
index 000000000..26c09ac07
--- /dev/null
+++ b/examples/tutorials/penguin/penguin.3ds
Binary files differ
diff --git a/examples/tutorials/penguin/penguin.pro b/examples/tutorials/penguin/penguin.pro
new file mode 100644
index 000000000..f35c1cd4e
--- /dev/null
+++ b/examples/tutorials/penguin/penguin.pro
@@ -0,0 +1,7 @@
+TEMPLATE = app
+TARGET = penguin
+CONFIG += qt warn_on qt3d
+SOURCES = modelview.cpp \
+ main.cpp
+HEADERS = modelview.h
+RESOURCES = model.qrc
diff --git a/examples/tutorials/penguin_advanced/main.cpp b/examples/tutorials/penguin_advanced/main.cpp
new file mode 100644
index 000000000..e5c995db3
--- /dev/null
+++ b/examples/tutorials/penguin_advanced/main.cpp
@@ -0,0 +1,51 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtQuick3D examples of the Qt Toolkit.
+**
+** $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 Nokia Corporation and its Subsidiary(-ies) 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 <QApplication>
+
+#include "modelview.h"
+
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+ ModelView view;
+ view.show();
+ return app.exec();
+}
diff --git a/examples/tutorials/penguin_advanced/model_advanced.qrc b/examples/tutorials/penguin_advanced/model_advanced.qrc
new file mode 100644
index 000000000..2c330de09
--- /dev/null
+++ b/examples/tutorials/penguin_advanced/model_advanced.qrc
@@ -0,0 +1,5 @@
+<RCC>
+ <qresource prefix="/">
+ <file>penguin.3ds</file>
+ </qresource>
+</RCC>
diff --git a/examples/tutorials/penguin_advanced/modelview.cpp b/examples/tutorials/penguin_advanced/modelview.cpp
new file mode 100644
index 000000000..a72495331
--- /dev/null
+++ b/examples/tutorials/penguin_advanced/modelview.cpp
@@ -0,0 +1,76 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtQuick3D examples of the Qt Toolkit.
+**
+** $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 Nokia Corporation and its Subsidiary(-ies) 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 "modelview.h"
+#include "qglabstractscene.h"
+#include "qglscenenode.h"
+
+ModelView::ModelView(QWidget *parent)
+ : QGLView(parent)
+ , m_scene(0)
+ , m_main(0)
+{
+}
+
+//! [initialize]
+void ModelView::initializeGL(QGLPainter *painter)
+{
+ Q_UNUSED(painter);
+ camera()->setEye(QVector3D(0.0f, 2.0f, 25.0f));
+
+ m_scene = QGLAbstractScene::loadScene(QLatin1String(":/penguin.3ds"));
+ if (m_scene)
+ m_main = m_scene->mainNode();
+
+ QQuaternion xt = QQuaternion::fromAxisAndAngle(1.0f, 0.0f, 0.0f, -90.0f);
+ QQuaternion yt = QQuaternion::fromAxisAndAngle(0.0f, 1.0f, 0.0f, 30.0f);
+ m_pose = yt * xt;
+}
+//! [initialize]
+
+//! [paint]
+void ModelView::paintGL(QGLPainter *painter)
+{
+ painter->modelViewMatrix().rotate(m_pose);
+
+ if (m_main)
+ m_main->draw(painter);
+}
+//! [paint]
diff --git a/examples/tutorials/penguin_advanced/modelview.h b/examples/tutorials/penguin_advanced/modelview.h
new file mode 100644
index 000000000..38b4340cc
--- /dev/null
+++ b/examples/tutorials/penguin_advanced/modelview.h
@@ -0,0 +1,66 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtQuick3D examples of the Qt Toolkit.
+**
+** $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 Nokia Corporation and its Subsidiary(-ies) 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$
+**
+****************************************************************************/
+
+#ifndef MODELVIEW_H
+#define MODELVIEW_H
+
+#include "qglview.h"
+
+class QGLAbstractScene;
+class QGLSceneNode;
+
+class ModelView : public QGLView
+{
+ Q_OBJECT
+public:
+ ModelView(QWidget *parent = 0);
+ ~ModelView() {}
+
+protected:
+ void initializeGL(QGLPainter *painter);
+ void paintGL(QGLPainter *painter);
+
+private:
+ QGLAbstractScene *m_scene;
+ QGLSceneNode *m_main;
+ QQuaternion m_pose;
+};
+
+#endif
diff --git a/examples/tutorials/penguin_advanced/penguin.3ds b/examples/tutorials/penguin_advanced/penguin.3ds
new file mode 100644
index 000000000..26c09ac07
--- /dev/null
+++ b/examples/tutorials/penguin_advanced/penguin.3ds
Binary files differ
diff --git a/examples/tutorials/penguin_advanced/penguin_advanced.pro b/examples/tutorials/penguin_advanced/penguin_advanced.pro
new file mode 100644
index 000000000..079c5f5b0
--- /dev/null
+++ b/examples/tutorials/penguin_advanced/penguin_advanced.pro
@@ -0,0 +1,8 @@
+TEMPLATE = app
+TARGET = penguin
+DESTDIR = ../../../bin
+CONFIG += qt warn_on qt3d
+SOURCES = modelview.cpp \
+ main.cpp
+HEADERS = modelview.h
+RESOURCES = model_advanced.qrc
diff --git a/examples/tutorials/shaders/TutorialTeapot.qml b/examples/tutorials/shaders/TutorialTeapot.qml
new file mode 100644
index 000000000..5f2c29e08
--- /dev/null
+++ b/examples/tutorials/shaders/TutorialTeapot.qml
@@ -0,0 +1,65 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtQuick3D examples of the Qt Toolkit.
+**
+** $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 Nokia Corporation and its Subsidiary(-ies) 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 Qt 4.7
+import Qt3D 1.0
+
+Item3D {
+ mesh: Mesh { source: "meshes/teapot.bez" }
+ effect: Effect {}
+ property int xRotation : 0.0
+ property int yRotation : 0.0
+ property int zRotation : 0.0
+
+ transform: [
+ Rotation3D {
+ angle: xRotation
+ axis: Qt.vector3d(1, 0, 0)
+ },
+ Rotation3D {
+ angle: yRotation
+ axis: Qt.vector3d(0, 1, 0)
+ },
+ Rotation3D {
+ angle: zRotation
+ axis: Qt.vector3d(0, 0, 1)
+ }
+ ]
+}
diff --git a/examples/tutorials/shaders/meshes b/examples/tutorials/shaders/meshes
new file mode 120000
index 000000000..3bc225c36
--- /dev/null
+++ b/examples/tutorials/shaders/meshes
@@ -0,0 +1 @@
+../../../demos/declarative/meshes \ No newline at end of file
diff --git a/examples/tutorials/shaders/shader-tutorial-1-textures.qml b/examples/tutorials/shaders/shader-tutorial-1-textures.qml
new file mode 100644
index 000000000..081a94c0f
--- /dev/null
+++ b/examples/tutorials/shaders/shader-tutorial-1-textures.qml
@@ -0,0 +1,105 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtQuick3D examples of the Qt Toolkit.
+**
+** $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 Nokia Corporation and its Subsidiary(-ies) 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 Qt 4.7
+import Qt3D 1.0
+
+Viewport {
+ width: 640; height: 480
+
+ TutorialTeapot {
+ effect: program
+ }
+
+ ShaderProgram {
+ id: program
+ texture: "textures/qtlogo.png"
+ property real textureOffsetX : 1.0
+ NumberAnimation on textureOffsetX
+ {
+ running: true; loops: Animation.Infinite
+ from: 0.0; to: 1.0;
+ duration: 1000
+ }
+
+ property string texture2: "textures/basket.jpg"
+ property real interpolationFactor : 1.0
+ SequentialAnimation on interpolationFactor
+ {
+ running: true; loops: Animation.Infinite
+ NumberAnimation { from: 0.0; to: 1.0; duration: 2000 }
+ PauseAnimation { duration: 500 }
+ NumberAnimation { from: 1.0; to: 0.0; duration: 2000 }
+ PauseAnimation { duration: 500 }
+ }
+
+ vertexShader: "
+ attribute highp vec4 qt_Vertex;
+ uniform mediump mat4 qt_ModelViewProjectionMatrix;
+
+ attribute highp vec4 qt_MultiTexCoord0;
+ uniform mediump float textureOffsetX;
+ varying mediump vec4 texCoord;
+
+ void main(void)
+ {
+ gl_Position = qt_ModelViewProjectionMatrix * qt_Vertex;
+ texCoord.st = vec2(-qt_MultiTexCoord0.s - textureOffsetX,
+ -qt_MultiTexCoord0.t);
+ texCoord.pq = vec2(-qt_MultiTexCoord0.s + textureOffsetX,
+ -qt_MultiTexCoord0.t);
+ }
+ "
+ fragmentShader: "
+ varying highp vec4 texCoord;
+ uniform sampler2D qt_Texture0;
+ uniform sampler2D texture2;
+ uniform mediump float interpolationFactor;
+
+ void main(void)
+ {
+ mediump vec4 texture1Color = texture2D(qt_Texture0, texCoord.st);
+ mediump vec4 texture2Color = texture2D(texture2, texCoord.pq);
+ mediump vec4 textureColor = mix(texture1Color, texture2Color, interpolationFactor);
+ gl_FragColor = textureColor;
+ }
+ "
+ }
+}
diff --git a/examples/tutorials/shaders/shader-tutorial-2-vertex-shader.qml b/examples/tutorials/shaders/shader-tutorial-2-vertex-shader.qml
new file mode 100644
index 000000000..37f9ddfde
--- /dev/null
+++ b/examples/tutorials/shaders/shader-tutorial-2-vertex-shader.qml
@@ -0,0 +1,117 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtQuick3D examples of the Qt Toolkit.
+**
+** $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 Nokia Corporation and its Subsidiary(-ies) 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 Qt 4.7
+import Qt3D 1.0
+
+Viewport {
+ width: 640; height: 480
+
+ TutorialTeapot {
+ id: teapot
+ effect: program
+ xRotation: 30
+ }
+
+ ShaderProgram {
+ id: program
+ texture: "textures/qtlogo.png"
+
+ property real textureOffsetX : 0.0
+ property real squashFactor : 0.0
+ NumberAnimation on textureOffsetX
+ {
+ running: true; loops: Animation.Infinite
+ from: 0.0; to: 1.0;
+ duration: 1000
+ }
+
+ SequentialAnimation on squashFactor
+ {
+ running: true; loops: Animation.Infinite
+ NumberAnimation {
+ from: 0.0; to: 1.0; duration: 1000
+ easing.type: "InQuad"
+ }
+ PauseAnimation {
+ duration: 250
+ }
+ NumberAnimation {
+ from: 1.0; to: 0.0; duration: 1000
+ easing.type: "OutQuad"
+ }
+ }
+
+ vertexShader: "
+ attribute highp vec4 qt_Vertex;
+ uniform mediump mat4 qt_ModelViewProjectionMatrix;
+
+ attribute highp vec4 qt_MultiTexCoord0;
+ varying highp vec4 texCoord;
+ uniform mediump float textureOffsetX;
+ uniform mediump float squashFactor;
+
+ void main(void)
+ {
+ const float modelSize = 2.0;
+ const float modelBottom = -1.0;
+ float newY = max(qt_Vertex.y - squashFactor * modelSize,
+ qt_Vertex.y * 0.01 + modelBottom);
+ gl_Position = qt_ModelViewProjectionMatrix *
+ vec4(qt_Vertex.x, newY, qt_Vertex.zw);
+
+ texCoord = vec4(-qt_MultiTexCoord0.s
+ - textureOffsetX,
+ -qt_MultiTexCoord0.t,
+ qt_MultiTexCoord0.pq);
+ }
+ "
+ fragmentShader: "
+ varying highp vec4 texCoord;
+ uniform sampler2D qt_Texture0;
+
+ void main(void)
+ {
+ mediump vec4 textureColor = texture2D(qt_Texture0, texCoord.st);
+ gl_FragColor = textureColor;
+ }
+ "
+ }
+}
diff --git a/examples/tutorials/shaders/shader-tutorial-3-transformed-coordinates.qml b/examples/tutorials/shaders/shader-tutorial-3-transformed-coordinates.qml
new file mode 100644
index 000000000..6b3595c5d
--- /dev/null
+++ b/examples/tutorials/shaders/shader-tutorial-3-transformed-coordinates.qml
@@ -0,0 +1,126 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtQuick3D examples of the Qt Toolkit.
+**
+** $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 Nokia Corporation and its Subsidiary(-ies) 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 Qt 4.7
+import Qt3D 1.0
+
+Viewport {
+ width: 640; height: 480
+
+
+ Item3D {
+ z: -8.0
+ transform: [
+ Rotation3D {
+ NumberAnimation on angle {
+ running: true; loops: Animation.Infinite
+ from: 0; to: 360; duration: 5000
+ }
+ axis: Qt.vector3d(0, 0, 1.0)
+ }
+ ]
+
+ TutorialTeapot {id: teapot1; effect: program; y:2.0; x:0.0}
+ TutorialTeapot {id: teapot2; effect: program; y:-1.0; x:-1.732}
+ TutorialTeapot {id: teapot3; effect: program; y:-1.0; x:1.732}
+ }
+
+ ShaderProgram {
+ id: program
+ texture: "textures/qtlogo.png"
+
+ property real textureOffsetX : 0.0
+ property real squashFactor : 0.0
+ NumberAnimation on textureOffsetX
+ {
+ running: true; loops: Animation.Infinite
+ from: 0.0; to: 1.0;
+ duration: 1000
+ }
+
+ SequentialAnimation on squashFactor
+ {
+ running: true; loops: Animation.Infinite
+ NumberAnimation {
+ from: 0.0; to: 1.0; duration: 1000
+ easing.type: "InQuad"
+ }
+ PauseAnimation {
+ duration: 250
+ }
+ NumberAnimation {
+ from: 1.0; to: 0.0; duration: 1000
+ easing.type: "OutQuad"
+ }
+ }
+
+
+ vertexShader: "
+ attribute highp vec4 qt_Vertex;
+ uniform mediump mat4 qt_ModelViewProjectionMatrix;
+
+ attribute mediump vec4 qt_MultiTexCoord0;
+ varying mediump vec4 texCoord;
+
+ void main(void)
+ {
+ const float modelBottom = -4.0;
+
+ vec4 workingPosition = qt_ModelViewProjectionMatrix * qt_Vertex;
+ float newY = max(workingPosition.y,
+ workingPosition.y * 0.15 + modelBottom);
+ workingPosition.y = newY;
+ gl_Position = workingPosition;
+
+ texCoord = -qt_MultiTexCoord0;
+ }
+ "
+ fragmentShader: "
+ varying mediump vec4 texCoord;
+ uniform sampler2D qt_Texture0;
+
+ void main(void)
+ {
+ mediump vec4 textureColor = texture2D(qt_Texture0, texCoord.st);
+ gl_FragColor = textureColor;
+ }
+ "
+ }
+}
diff --git a/examples/tutorials/shaders/shader-tutorial-lighting.qml b/examples/tutorials/shaders/shader-tutorial-lighting.qml
new file mode 100644
index 000000000..94bcee74d
--- /dev/null
+++ b/examples/tutorials/shaders/shader-tutorial-lighting.qml
@@ -0,0 +1,85 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtQuick3D examples of the Qt Toolkit.
+**
+** $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 Nokia Corporation and its Subsidiary(-ies) 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 Qt 4.7
+import Qt3D 1.0
+import Qt3D.Shapes 1.0
+
+Viewport {
+ width: 640; height: 480
+
+
+ Cube {
+ id: teapot
+ effect: program
+// xRotation: 30
+ }
+
+ ShaderProgram {
+ id: program
+ texture: "textures/qtlogo.png"
+
+ vertexShader: "
+ attribute highp vec4 qt_Vertex;
+ uniform highp mat4 qt_ModelViewProjectionMatrix;
+
+ attribute highp vec4 qt_MultiTexCoord0;
+ varying highp vec4 texCoord;
+
+ void main(void)
+ {
+ gl_Position = qt_ModelViewProjectionMatrix * qt_Vertex;
+// texCoord = -qt_MultiTexCoord0;
+ texCoord = qt_Vertex;
+ }
+ "
+ fragmentShader: "
+ varying highp vec4 texCoord;
+ uniform sampler2D qt_Texture0;
+
+ void main(void)
+ {
+ mediump vec4 textureColor = texture2D(qt_Texture0, texCoord.st);
+// gl_FragColor = textureColor;
+ gl_FragColor = vec4(texCoord.xyz , 1.0);
+ }
+ "
+ }
+}
diff --git a/examples/tutorials/shaders/shader-tutorial-varying.qml b/examples/tutorials/shaders/shader-tutorial-varying.qml
new file mode 100644
index 000000000..3341bb7b5
--- /dev/null
+++ b/examples/tutorials/shaders/shader-tutorial-varying.qml
@@ -0,0 +1,77 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtQuick3D examples of the Qt Toolkit.
+**
+** $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 Nokia Corporation and its Subsidiary(-ies) 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 Qt 4.7
+import Qt3D 1.0
+
+Viewport {
+ width: 640; height: 480
+
+ Pane {
+ effect: ShaderProgram {
+ id: program
+
+ vertexShader: "
+ attribute highp vec4 qt_Vertex;
+ uniform mediump mat4 qt_ModelViewProjectionMatrix;
+
+ attribute highp vec4 qt_MultiTexCoord0;
+ varying highp vec4 texCoord;
+
+ void main(void)
+ {
+ gl_Position = qt_ModelViewProjectionMatrix * qt_Vertex;
+ texCoord = vec4(qt_MultiTexCoord0.st, 0, 0);
+ }
+ "
+ fragmentShader: "
+ varying highp vec4 texCoord;
+
+ void main(void)
+ {
+ gl_FragColor = vec4(mod(texCoord.x, 1.0),
+ mod(texCoord.y, 1.0),
+ 0.0,
+ 1.0);
+ }
+ "
+ }
+ }
+}
diff --git a/examples/tutorials/shaders/shader-tutorial.qml b/examples/tutorials/shaders/shader-tutorial.qml
new file mode 100644
index 000000000..37d379bb8
--- /dev/null
+++ b/examples/tutorials/shaders/shader-tutorial.qml
@@ -0,0 +1,82 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtQuick3D examples of the Qt Toolkit.
+**
+** $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 Nokia Corporation and its Subsidiary(-ies) 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 Qt 4.7
+import Qt3D 1.0
+
+Viewport {
+ width: 640; height: 480
+
+
+ TutorialTeapot {
+ id: teapot
+ effect: program
+ xRotation: 30
+ }
+
+ ShaderProgram {
+ id: program
+ texture: "textures/qtlogo.png"
+
+ vertexShader: "
+ attribute highp vec4 qt_Vertex;
+ uniform highp mat4 qt_ModelViewProjectionMatrix;
+
+ attribute highp vec4 qt_MultiTexCoord0;
+ varying highp vec4 texCoord;
+
+ void main(void)
+ {
+ texCoord = qt_MultiTexCoord0;
+ gl_Position = qt_ModelViewProjectionMatrix * qt_Vertex;
+ }
+ "
+ fragmentShader: "
+ varying highp vec4 texCoord;
+ uniform sampler2D qt_Texture0;
+
+ void main(void)
+ {
+ mediump vec4 textureColor = texture2D(qt_Texture0, texCoord.st);
+ gl_FragColor = textureColor;
+ }
+ "
+ }
+}
diff --git a/examples/tutorials/shaders/shaders.pro b/examples/tutorials/shaders/shaders.pro
new file mode 100644
index 000000000..05755ad8a
--- /dev/null
+++ b/examples/tutorials/shaders/shaders.pro
@@ -0,0 +1,7 @@
+TEMPLATE = subdirs
+
+# These examples contain no C++ and can simply be copied
+sources.files = . \
+
+sources.path = $$[QT_INSTALL_EXAMPLES]/tutorials
+INSTALLS += sources
diff --git a/examples/tutorials/shaders/shaders.qmlproject b/examples/tutorials/shaders/shaders.qmlproject
new file mode 100644
index 000000000..d4909f868
--- /dev/null
+++ b/examples/tutorials/shaders/shaders.qmlproject
@@ -0,0 +1,16 @@
+import QmlProject 1.0
+
+Project {
+ /* Include .qml, .js, and image files from current directory and subdirectories */
+ QmlFiles {
+ directory: "."
+ }
+ JavaScriptFiles {
+ directory: "."
+ }
+ ImageFiles {
+ directory: "."
+ }
+ /* List of plugin directories passed to QML runtime */
+ // importPaths: [ " ../exampleplugin " ]
+}
diff --git a/examples/tutorials/shaders/textures/basket.jpg b/examples/tutorials/shaders/textures/basket.jpg
new file mode 120000
index 000000000..b23d4eec4
--- /dev/null
+++ b/examples/tutorials/shaders/textures/basket.jpg
@@ -0,0 +1 @@
+../../../../demos/declarative/textures/basket.jpg \ No newline at end of file
diff --git a/examples/tutorials/shaders/textures/qtlogo.png b/examples/tutorials/shaders/textures/qtlogo.png
new file mode 120000
index 000000000..b8b931c8b
--- /dev/null
+++ b/examples/tutorials/shaders/textures/qtlogo.png
@@ -0,0 +1 @@
+../../../../demos/declarative/textures/qtlogo.png \ No newline at end of file
diff --git a/examples/tutorials/teapot-qml/teapot-bounce.qml b/examples/tutorials/teapot-qml/teapot-bounce.qml
new file mode 100644
index 000000000..7a9e61e69
--- /dev/null
+++ b/examples/tutorials/teapot-qml/teapot-bounce.qml
@@ -0,0 +1,76 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtQuick3D examples of the Qt Toolkit.
+**
+** $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 Nokia Corporation and its Subsidiary(-ies) 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 Qt 4.7
+import Qt3D 1.0
+
+Viewport {
+ width: 640; height: 480
+
+//! [1]
+ Item3D {
+ id: teapot
+ mesh: Mesh { source: "teapot.bez" }
+
+ effect: Effect {
+ material: china
+ }
+
+ Material {
+ id: china
+ ambientColor: "#c09680"
+ specularColor: "#3c3c3c"
+ shininess: 128
+ }
+//! [1]
+
+//! [3]
+ SequentialAnimation on y {
+ running: true
+ loops: Animation.Infinite
+ PauseAnimation { duration: 500 }
+ NumberAnimation { to : 1.0; duration: 300; easing.type: "OutQuad" }
+ NumberAnimation { to : 0.0; duration: 300; easing.type: "OutBounce" }
+ }
+//! [3]
+//! [2]
+ }
+//! [2]
+}
diff --git a/examples/tutorials/teapot-qml/teapot-qml.qmlproject b/examples/tutorials/teapot-qml/teapot-qml.qmlproject
new file mode 100644
index 000000000..d4909f868
--- /dev/null
+++ b/examples/tutorials/teapot-qml/teapot-qml.qmlproject
@@ -0,0 +1,16 @@
+import QmlProject 1.0
+
+Project {
+ /* Include .qml, .js, and image files from current directory and subdirectories */
+ QmlFiles {
+ directory: "."
+ }
+ JavaScriptFiles {
+ directory: "."
+ }
+ ImageFiles {
+ directory: "."
+ }
+ /* List of plugin directories passed to QML runtime */
+ // importPaths: [ " ../exampleplugin " ]
+}
diff --git a/examples/tutorials/teapot-qml/teapot.bez b/examples/tutorials/teapot-qml/teapot.bez
new file mode 100644
index 000000000..02b2ac447
--- /dev/null
+++ b/examples/tutorials/teapot-qml/teapot.bez
@@ -0,0 +1,340 @@
+32
+1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16
+4,17,18,19,8,20,21,22,12,23,24,25,16,26,27,28
+19,29,30,31,22,32,33,34,25,35,36,37,28,38,39,40
+31,41,42,1,34,43,44,5,37,45,46,9,40,47,48,13
+13,14,15,16,49,50,51,52,53,54,55,56,57,58,59,60
+16,26,27,28,52,61,62,63,56,64,65,66,60,67,68,69
+28,38,39,40,63,70,71,72,66,73,74,75,69,76,77,78
+40,47,48,13,72,79,80,49,75,81,82,53,78,83,84,57
+57,58,59,60,85,86,87,88,89,90,91,92,93,94,95,96
+60,67,68,69,88,97,98,99,92,100,101,102,96,103,104,105
+69,76,77,78,99,106,107,108,102,109,110,111,105,112,113,114
+78,83,84,57,108,115,116,85,111,117,118,89,114,119,120,93
+121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136
+124,137,138,121,128,139,140,125,132,141,142,129,136,143,144,133
+133,134,135,136,145,146,147,148,149,150,151,152,69,153,154,155
+136,143,144,133,148,156,157,145,152,158,159,149,155,160,161,69
+162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177
+165,178,179,162,169,180,181,166,173,182,183,170,177,184,185,174
+174,175,176,177,186,187,188,189,190,191,192,193,194,195,196,197
+177,184,185,174,189,198,199,186,193,200,201,190,197,202,203,194
+204,204,204,204,207,208,209,210,211,211,211,211,212,213,214,215,4
+204,204,204,204,210,217,218,219,211,211,211,211,215,220,221,222,4
+204,204,204,204,219,224,225,226,211,211,211,211,222,227,228,229,4
+204,204,204,204,226,230,231,207,211,211,211,211,229,232,233,212,4
+212,213,214,215,234,235,236,237,238,239,240,241,242,243,244,245
+215,220,221,222,237,246,247,248,241,249,250,251,245,252,253,254
+222,227,228,229,248,255,256,257,251,258,259,260,254,261,262,263
+229,232,233,212,257,264,265,234,260,266,267,238,263,268,269,242
+270,270,270,270,279,280,281,282,275,276,277,278,271,272,273,274,4
+270,270,270,270,282,289,290,291,278,286,287,288,274,283,284,285,4
+270,270,270,270,291,298,299,300,288,295,296,297,285,292,293,294,4
+270,270,270,270,300,305,306,279,297,303,304,275,294,301,302,271,4
+306
+0.700000,0.450000,-0.000000
+0.700000,0.450000,0.392000
+0.392000,0.450000,0.700000
+0.000000,0.450000,0.700000
+0.668750,0.515625,-0.000000
+0.668750,0.515625,0.374500
+0.374500,0.515625,0.668750
+0.000000,0.515625,0.668750
+0.718750,0.515625,-0.000000
+0.718750,0.515625,0.402500
+0.402500,0.515625,0.718750
+0.000000,0.515625,0.718750
+0.750000,0.450000,-0.000000
+0.750000,0.450000,0.420000
+0.420000,0.450000,0.750000
+0.000000,0.450000,0.750000
+-0.392000,0.450000,0.700000
+-0.700000,0.450000,0.392000
+-0.700000,0.450000,-0.000000
+-0.374500,0.515625,0.668750
+-0.668750,0.515625,0.374500
+-0.668750,0.515625,-0.000000
+-0.402500,0.515625,0.718750
+-0.718750,0.515625,0.402500
+-0.718750,0.515625,-0.000000
+-0.420000,0.450000,0.750000
+-0.750000,0.450000,0.420000
+-0.750000,0.450000,-0.000000
+-0.700000,0.450000,-0.392000
+-0.392000,0.450000,-0.700000
+0.000000,0.450000,-0.700000
+-0.668750,0.515625,-0.374500
+-0.374500,0.515625,-0.668750
+0.000000,0.515625,-0.668750
+-0.718750,0.515625,-0.402500
+-0.402500,0.515625,-0.718750
+0.000000,0.515625,-0.718750
+-0.750000,0.450000,-0.420000
+-0.420000,0.450000,-0.750000
+0.000000,0.450000,-0.750000
+0.392000,0.450000,-0.700000
+0.700000,0.450000,-0.392000
+0.374500,0.515625,-0.668750
+0.668750,0.515625,-0.374500
+0.402500,0.515625,-0.718750
+0.718750,0.515625,-0.402500
+0.420000,0.450000,-0.750000
+0.750000,0.450000,-0.420000
+0.875000,0.187500,-0.000000
+0.875000,0.187500,0.490000
+0.490000,0.187500,0.875000
+0.000000,0.187500,0.875000
+1.000000,-0.075000,-0.000000
+1.000000,-0.075000,0.560000
+0.560000,-0.075000,1.000000
+0.000000,-0.075000,1.000000
+1.000000,-0.300000,-0.000000
+1.000000,-0.300000,0.560000
+0.560000,-0.300000,1.000000
+0.000000,-0.300000,1.000000
+-0.490000,0.187500,0.875000
+-0.875000,0.187500,0.490000
+-0.875000,0.187500,-0.000000
+-0.560000,-0.075000,1.000000
+-1.000000,-0.075000,0.560000
+-1.000000,-0.075000,-0.000000
+-0.560000,-0.300000,1.000000
+-1.000000,-0.300000,0.560000
+-1.000000,-0.300000,-0.000000
+-0.875000,0.187500,-0.490000
+-0.490000,0.187500,-0.875000
+0.000000,0.187500,-0.875000
+-1.000000,-0.075000,-0.560000
+-0.560000,-0.075000,-1.000000
+0.000000,-0.075000,-1.000000
+-1.000000,-0.300000,-0.560000
+-0.560000,-0.300000,-1.000000
+0.000000,-0.300000,-1.000000
+0.490000,0.187500,-0.875000
+0.875000,0.187500,-0.490000
+0.560000,-0.075000,-1.000000
+1.000000,-0.075000,-0.560000
+0.560000,-0.300000,-1.000000
+1.000000,-0.300000,-0.560000
+1.000000,-0.525000,-0.000000
+1.000000,-0.525000,0.560000
+0.560000,-0.525000,1.000000
+0.000000,-0.525000,1.000000
+0.750000,-0.637500,-0.000000
+0.750000,-0.637500,0.420000
+0.420000,-0.637500,0.750000
+0.000000,-0.637500,0.750000
+0.750000,-0.675000,-0.000000
+0.750000,-0.675000,0.420000
+0.420000,-0.675000,0.750000
+0.000000,-0.675000,0.750000
+-0.560000,-0.525000,1.000000
+-1.000000,-0.525000,0.560000
+-1.000000,-0.525000,-0.000000
+-0.420000,-0.637500,0.750000
+-0.750000,-0.637500,0.420000
+-0.750000,-0.637500,-0.000000
+-0.420000,-0.675000,0.750000
+-0.750000,-0.675000,0.420000
+-0.750000,-0.675000,-0.000000
+-1.000000,-0.525000,-0.560000
+-0.560000,-0.525000,-1.000000
+0.000000,-0.525000,-1.000000
+-0.750000,-0.637500,-0.420000
+-0.420000,-0.637500,-0.750000
+0.000000,-0.637500,-0.750000
+-0.750000,-0.675000,-0.420000
+-0.420000,-0.675000,-0.750000
+0.000000,-0.675000,-0.750000
+0.560000,-0.525000,-1.000000
+1.000000,-0.525000,-0.560000
+0.420000,-0.637500,-0.750000
+0.750000,-0.637500,-0.420000
+0.420000,-0.675000,-0.750000
+0.750000,-0.675000,-0.420000
+-0.800000,0.262500,-0.000000
+-0.800000,0.262500,0.150000
+-0.750000,0.375000,0.150000
+-0.750000,0.375000,-0.000000
+-1.150000,0.262500,-0.000000
+-1.150000,0.262500,0.150000
+-1.250000,0.375000,0.150000
+-1.250000,0.375000,-0.000000
+-1.350000,0.262500,-0.000000
+-1.350000,0.262500,0.150000
+-1.500000,0.375000,0.150000
+-1.500000,0.375000,-0.000000
+-1.350000,0.150000,-0.000000
+-1.350000,0.150000,0.150000
+-1.500000,0.150000,0.150000
+-1.500000,0.150000,-0.000000
+-0.750000,0.375000,-0.150000
+-0.800000,0.262500,-0.150000
+-1.250000,0.375000,-0.150000
+-1.150000,0.262500,-0.150000
+-1.500000,0.375000,-0.150000
+-1.350000,0.262500,-0.150000
+-1.500000,0.150000,-0.150000
+-1.350000,0.150000,-0.150000
+-1.350000,0.037500,-0.000000
+-1.350000,0.037500,0.150000
+-1.500000,-0.075000,0.150000
+-1.500000,-0.075000,-0.000000
+-1.250000,-0.187500,-0.000000
+-1.250000,-0.187500,0.150000
+-1.325000,-0.281250,0.150000
+-1.325000,-0.281250,-0.000000
+-1.000000,-0.300000,0.150000
+-0.950000,-0.450000,0.150000
+-0.950000,-0.450000,-0.000000
+-1.500000,-0.075000,-0.150000
+-1.350000,0.037500,-0.150000
+-1.325000,-0.281250,-0.150000
+-1.250000,-0.187500,-0.150000
+-0.950000,-0.450000,-0.150000
+-1.000000,-0.300000,-0.150000
+0.850000,-0.037500,-0.000000
+0.850000,-0.037500,0.330000
+0.850000,-0.450000,0.330000
+0.850000,-0.450000,-0.000000
+1.300000,-0.037500,-0.000000
+1.300000,-0.037500,0.330000
+1.550000,-0.337500,0.330000
+1.550000,-0.337500,-0.000000
+1.150000,0.300000,-0.000000
+1.150000,0.300000,0.125000
+1.200000,0.262500,0.125000
+1.200000,0.262500,-0.000000
+1.350000,0.450000,-0.000000
+1.350000,0.450000,0.125000
+1.650000,0.450000,0.125000
+1.650000,0.450000,-0.000000
+0.850000,-0.450000,-0.330000
+0.850000,-0.037500,-0.330000
+1.550000,-0.337500,-0.330000
+1.300000,-0.037500,-0.330000
+1.200000,0.262500,-0.125000
+1.150000,0.300000,-0.125000
+1.650000,0.450000,-0.125000
+1.350000,0.450000,-0.125000
+1.400000,0.487500,-0.000000
+1.400000,0.487500,0.125000
+1.762500,0.496875,0.125000
+1.762500,0.496875,-0.000000
+1.450000,0.487500,-0.000000
+1.450000,0.487500,0.075000
+1.725000,0.506250,0.075000
+1.725000,0.506250,-0.000000
+1.400000,0.450000,-0.000000
+1.400000,0.450000,0.075000
+1.600000,0.450000,0.075000
+1.600000,0.450000,-0.000000
+1.762500,0.496875,-0.125000
+1.400000,0.487500,-0.125000
+1.725000,0.506250,-0.075000
+1.450000,0.487500,-0.075000
+1.600000,0.450000,-0.075000
+1.400000,0.450000,-0.075000
+0.000000,0.825000,-0.000000
+0.000000,0.825000,0.001000
+0.001000,0.825000,-0.000000
+0.400000,0.825000,-0.000000
+0.400000,0.825000,0.225000
+0.225000,0.825000,0.400000
+0.000000,0.825000,0.400000
+0.000000,0.675000,-0.000000
+0.100000,0.600000,-0.000000
+0.100000,0.600000,0.056000
+0.056000,0.600000,0.100000
+0.000000,0.600000,0.100000
+-0.001000,0.825000,-0.000000
+-0.225000,0.825000,0.400000
+-0.400000,0.825000,0.225000
+-0.400000,0.825000,-0.000000
+-0.056000,0.600000,0.100000
+-0.100000,0.600000,0.056000
+-0.100000,0.600000,-0.000000
+0.000000,0.825000,-0.001000
+-0.400000,0.825000,-0.225000
+-0.225000,0.825000,-0.400000
+0.000000,0.825000,-0.400000
+-0.100000,0.600000,-0.056000
+-0.056000,0.600000,-0.100000
+0.000000,0.600000,-0.100000
+0.225000,0.825000,-0.400000
+0.400000,0.825000,-0.225000
+0.056000,0.600000,-0.100000
+0.100000,0.600000,-0.056000
+0.200000,0.525000,-0.000000
+0.200000,0.525000,0.112000
+0.112000,0.525000,0.200000
+0.000000,0.525000,0.200000
+0.650000,0.525000,-0.000000
+0.650000,0.525000,0.364000
+0.364000,0.525000,0.650000
+0.000000,0.525000,0.650000
+0.650000,0.450000,-0.000000
+0.650000,0.450000,0.364000
+0.364000,0.450000,0.650000
+0.000000,0.450000,0.650000
+-0.112000,0.525000,0.200000
+-0.200000,0.525000,0.112000
+-0.200000,0.525000,-0.000000
+-0.364000,0.525000,0.650000
+-0.650000,0.525000,0.364000
+-0.650000,0.525000,-0.000000
+-0.364000,0.450000,0.650000
+-0.650000,0.450000,0.364000
+-0.650000,0.450000,-0.000000
+-0.200000,0.525000,-0.112000
+-0.112000,0.525000,-0.200000
+0.000000,0.525000,-0.200000
+-0.650000,0.525000,-0.364000
+-0.364000,0.525000,-0.650000
+0.000000,0.525000,-0.650000
+-0.650000,0.450000,-0.364000
+-0.364000,0.450000,-0.650000
+0.000000,0.450000,-0.650000
+0.112000,0.525000,-0.200000
+0.200000,0.525000,-0.112000
+0.364000,0.525000,-0.650000
+0.650000,0.525000,-0.364000
+0.364000,0.450000,-0.650000
+0.650000,0.450000,-0.364000
+0.000000,-0.750000,-0.000000
+0.750000,-0.675000,-0.000000
+0.750000,-0.675000,-0.420000
+0.420000,-0.675000,-0.750000
+0.000000,-0.675000,-0.750000
+0.750000,-0.712500,-0.000000
+0.750000,-0.712500,-0.420000
+0.420000,-0.712500,-0.750000
+0.000000,-0.712500,-0.750000
+0.712500,-0.750000,-0.000000
+0.712500,-0.750000,-0.399000
+0.399000,-0.750000,-0.712500
+0.000000,-0.750000,-0.712500
+-0.420000,-0.675000,-0.750000
+-0.750000,-0.675000,-0.420000
+-0.750000,-0.675000,-0.000000
+-0.420000,-0.712500,-0.750000
+-0.750000,-0.712500,-0.420000
+-0.750000,-0.712500,-0.000000
+-0.399000,-0.750000,-0.712500
+-0.712500,-0.750000,-0.399000
+-0.712500,-0.750000,-0.000000
+-0.750000,-0.675000,0.420000
+-0.420000,-0.675000,0.750000
+0.000000,-0.675000,0.750000
+-0.750000,-0.712500,0.420000
+-0.420000,-0.712500,0.750000
+0.000000,-0.712500,0.750000
+-0.712500,-0.750000,0.399000
+-0.399000,-0.750000,0.712500
+0.000000,-0.750000,0.712500
+0.420000,-0.675000,0.750000
+0.750000,-0.675000,0.420000
+0.420000,-0.712500,0.750000
+0.750000,-0.712500,0.420000
+0.399000,-0.750000,0.712500
+0.712500,-0.750000,0.399000
diff --git a/examples/tutorials/teapot-qml/teapot.qml b/examples/tutorials/teapot-qml/teapot.qml
new file mode 100644
index 000000000..97e0bdf56
--- /dev/null
+++ b/examples/tutorials/teapot-qml/teapot.qml
@@ -0,0 +1,59 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtQuick3D examples of the Qt Toolkit.
+**
+** $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 Nokia Corporation and its Subsidiary(-ies) 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$
+**
+****************************************************************************/
+
+//![1]
+//![2]
+import Qt 4.7
+import Qt3D 1.0
+//![2]
+
+//![3]
+Viewport {
+ width: 640; height: 480
+//![3]
+//![4]
+ Item3D {
+ id: teapot
+ mesh: Mesh { source: "teapot.bez" }
+ effect: Effect {}
+ }
+//![4]
+}
+//![1]
diff --git a/examples/tutorials/tutorials.pro b/examples/tutorials/tutorials.pro
new file mode 100644
index 000000000..8c3fdf364
--- /dev/null
+++ b/examples/tutorials/tutorials.pro
@@ -0,0 +1,3 @@
+TEMPLATE = subdirs
+SUBDIRS += penguin penguin_advanced
+SUBDIRS += cube1 cube2 cube3 cube4