blob: bc25a815080aee835d489c14cf7631e060152e4d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
|
/****************************************************************************
**
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: http://www.qt-project.org/
**
** This file is part of the Qt3D documentation of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:FDL$
** GNU Free Documentation License
** Alternatively, this file may be used under the terms of the GNU Free
** Documentation License version 1.3 as published by the Free Software
** Foundation and appearing in the file included in the packaging of
** this file.
**
** Other Usage
** Alternatively, this file may be used in accordance with the terms
** and conditions contained in a signed written agreement between you
** and Nokia.
**
**
**
**
** $QT_END_LICENSE$
**
****************************************************************************/
/*!
\example quick3d/basket
\title Basket Example
\section2 Basket in QML
The QML version of the basket example is very similar in
structure to the C++ version above, but much simpler.
We start by defining a viewport with a specific camera position:
\snippet quick3d/basket/qml/basket.qml 1
We then add an \l Item3D object to load the basket model and
apply the desired texture to it:
\snippet quick3d/basket/qml/basket.qml 2
And then we apply an animation to the rotation component of
the item's transform property:
\snippet quick3d/basket/qml/basket.qml 3
\section2 Basket in Qt3D
The Basket example shows how Qt3D can be used to draw an animated
object covered in a texture. The basic application shell is similar
to the \l{qt3d/teapot}{Hello Teapot} example. In this case, we create
the basket object and add a texture to it as follows:
\snippet qt3d/basket/basketview.cpp 1
For this animation, we want to spin the basket around its Y axis,
once every 2 seconds. We first declare an \c angle property in the
class declaration (calling \c{update()} will force the view to
redraw whenever the angle changes):
\snippet qt3d/basket/basketview.h 1
Then we create a QPropertyAnimation object that will update
\c angle every time through the event loop with a new value
between 0 and 360 degrees:
\snippet qt3d/basket/basketview.cpp 2
Now all we have to do is draw the basket using the \c angle
property every time \c{paintGL()} is called:
\snippet qt3d/basket/basketview.cpp 3
\image basket-screenshot.png
\l{qt3d-examples.html}{Return to Examples}.
*/
|