1 | /**************************************************************************** |
2 | ** |
3 | ** Copyright (C) 2014 Klaralvdalens Datakonsult AB (KDAB). |
4 | ** Copyright (C) 2016 The Qt Company Ltd and/or its subsidiary(-ies). |
5 | ** Contact: https://www.qt.io/licensing/ |
6 | ** |
7 | ** This file is part of the Qt3D module of the Qt Toolkit. |
8 | ** |
9 | ** $QT_BEGIN_LICENSE:LGPL$ |
10 | ** Commercial License Usage |
11 | ** Licensees holding valid commercial Qt licenses may use this file in |
12 | ** accordance with the commercial license agreement provided with the |
13 | ** Software or, alternatively, in accordance with the terms contained in |
14 | ** a written agreement between you and The Qt Company. For licensing terms |
15 | ** and conditions see https://www.qt.io/terms-conditions. For further |
16 | ** information use the contact form at https://www.qt.io/contact-us. |
17 | ** |
18 | ** GNU Lesser General Public License Usage |
19 | ** Alternatively, this file may be used under the terms of the GNU Lesser |
20 | ** General Public License version 3 as published by the Free Software |
21 | ** Foundation and appearing in the file LICENSE.LGPL3 included in the |
22 | ** packaging of this file. Please review the following information to |
23 | ** ensure the GNU Lesser General Public License version 3 requirements |
24 | ** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. |
25 | ** |
26 | ** GNU General Public License Usage |
27 | ** Alternatively, this file may be used under the terms of the GNU |
28 | ** General Public License version 2.0 or (at your option) the GNU General |
29 | ** Public license version 3 or any later version approved by the KDE Free |
30 | ** Qt Foundation. The licenses are as published by the Free Software |
31 | ** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 |
32 | ** included in the packaging of this file. Please review the following |
33 | ** information to ensure the GNU General Public License requirements will |
34 | ** be met: https://www.gnu.org/licenses/gpl-2.0.html and |
35 | ** https://www.gnu.org/licenses/gpl-3.0.html. |
36 | ** |
37 | ** $QT_END_LICENSE$ |
38 | ** |
39 | ****************************************************************************/ |
40 | |
41 | #include "qspheremesh.h" |
42 | |
43 | #include <Qt3DExtras/qspheregeometry.h> |
44 | |
45 | QT_BEGIN_NAMESPACE |
46 | |
47 | namespace Qt3DExtras { |
48 | |
49 | /*! |
50 | * \qmltype SphereMesh |
51 | * \instantiates Qt3DExtras::QSphereMesh |
52 | * \inqmlmodule Qt3D.Extras |
53 | * \brief A spherical mesh. |
54 | */ |
55 | |
56 | /*! |
57 | * \qmlproperty int SphereMesh::rings |
58 | * |
59 | * Holds the number of rings in the mesh. |
60 | */ |
61 | |
62 | /*! |
63 | * \qmlproperty int SphereMesh::slices |
64 | * |
65 | * Holds the number of slices in the mesh. |
66 | */ |
67 | |
68 | /*! |
69 | * \qmlproperty real SphereMesh::radius |
70 | * |
71 | * Holds the radius of the sphere. |
72 | */ |
73 | |
74 | /*! |
75 | * \qmlproperty bool SphereMesh::generateTangents |
76 | * |
77 | * Holds the value of the automatic tangent vectors generation flag. |
78 | * Tangent vectors are orthogonal to normal vectors. |
79 | */ |
80 | |
81 | /*! |
82 | * \class Qt3DExtras::QSphereMesh |
83 | \ingroup qt3d-extras-geometries |
84 | * \inheaderfile Qt3DExtras/QSphereMesh |
85 | * \inmodule Qt3DExtras |
86 | * |
87 | * \inherits Qt3DRender::QGeometryRenderer |
88 | * |
89 | * \brief A spherical mesh. |
90 | */ |
91 | |
92 | /*! |
93 | * Constructs a new QSphereMesh with \a parent. |
94 | */ |
95 | QSphereMesh::(QNode *parent) |
96 | : QGeometryRenderer(parent) |
97 | { |
98 | QSphereGeometry *geometry = new QSphereGeometry(this); |
99 | QObject::connect(sender: geometry, signal: &QSphereGeometry::radiusChanged, receiver: this, slot: &QSphereMesh::radiusChanged); |
100 | QObject::connect(sender: geometry, signal: &QSphereGeometry::ringsChanged, receiver: this, slot: &QSphereMesh::ringsChanged); |
101 | QObject::connect(sender: geometry, signal: &QSphereGeometry::slicesChanged, receiver: this, slot: &QSphereMesh::slicesChanged); |
102 | QObject::connect(sender: geometry, signal: &QSphereGeometry::generateTangentsChanged, receiver: this, slot: &QSphereMesh::generateTangentsChanged); |
103 | QGeometryRenderer::setGeometry(geometry); |
104 | } |
105 | |
106 | /*! \internal */ |
107 | QSphereMesh::() |
108 | { |
109 | } |
110 | |
111 | void QSphereMesh::(int rings) |
112 | { |
113 | static_cast<QSphereGeometry *>(geometry())->setRings(rings); |
114 | } |
115 | |
116 | void QSphereMesh::(int slices) |
117 | { |
118 | static_cast<QSphereGeometry *>(geometry())->setSlices(slices); |
119 | } |
120 | |
121 | void QSphereMesh::(float radius) |
122 | { |
123 | static_cast<QSphereGeometry *>(geometry())->setRadius(radius); |
124 | } |
125 | |
126 | void QSphereMesh::(bool gen) |
127 | { |
128 | static_cast<QSphereGeometry *>(geometry())->setGenerateTangents(gen); |
129 | } |
130 | |
131 | /*! |
132 | * \property QSphereMesh::generateTangents |
133 | * |
134 | * Holds the value of the automatic tangent vectors generation flag. |
135 | * Tangent vectors are orthogonal to normal vectors. |
136 | */ |
137 | bool QSphereMesh::() const |
138 | { |
139 | return static_cast<QSphereGeometry *>(geometry())->generateTangents(); |
140 | } |
141 | |
142 | /*! |
143 | * \property QSphereMesh::rings |
144 | * |
145 | * Holds the number of rings in the mesh. |
146 | */ |
147 | int QSphereMesh::() const |
148 | { |
149 | return static_cast<QSphereGeometry *>(geometry())->rings(); |
150 | } |
151 | |
152 | /*! |
153 | * \property QSphereMesh::slices |
154 | * |
155 | * Holds the number of slices in the mesh. |
156 | */ |
157 | int QSphereMesh::() const |
158 | { |
159 | return static_cast<QSphereGeometry *>(geometry())->slices(); |
160 | } |
161 | |
162 | /*! |
163 | * \property QSphereMesh::radius |
164 | * |
165 | * Holds the radius of the sphere. |
166 | */ |
167 | float QSphereMesh::() const |
168 | { |
169 | return static_cast<QSphereGeometry *>(geometry())->radius(); |
170 | } |
171 | |
172 | } // Qt3DExtras |
173 | |
174 | QT_END_NAMESPACE |
175 | |