blob: 78358fb7842a29eeb438a615b639e98b39df9bad (
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) 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 documentation of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:FDL$
** No Commercial Usage
** This file contains pre-release code and may not be distributed.
** You may use this file in accordance with the terms and conditions
** contained in the Technology Preview License Agreement accompanying
** this package.
**
** GNU 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.
**
** If you have questions regarding the use of this file, please contact
** Nokia at qt-info@nokia.com.
** $QT_END_LICENSE$
**
****************************************************************************/
/*!
\example basket
\title Basket Example
\section2 Basket in QtQuick3D
The QtQuick3D 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 declarative/basket.qml 1
We then add an \l Item3D object to load the basket model and
apply the desired texture to it:
\snippet declarative/basket.qml 2
And then we apply an animation to the rotation component of
the item's transform property:
\snippet declarative/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{teapot}{Hello Teapot} example. In this case, we create
the basket object and add a texture to it as follows:
\snippet 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 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 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 basket/basketview.cpp 3
\image basket-screenshot.png
\l{qt3d-examples.html}{Return to Examples}.
*/
|