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 | #ifndef _USE_MATH_DEFINES |
42 | # define _USE_MATH_DEFINES // For MSVC |
43 | #endif |
44 | |
45 | #include "qcylindermesh.h" |
46 | |
47 | #include <Qt3DExtras/qcylindergeometry.h> |
48 | #include <Qt3DRender/qbuffer.h> |
49 | #include <Qt3DRender/qbufferdatagenerator.h> |
50 | #include <Qt3DRender/qattribute.h> |
51 | #include <QtGui/QVector3D> |
52 | |
53 | #include <qmath.h> |
54 | |
55 | QT_BEGIN_NAMESPACE |
56 | |
57 | using namespace Qt3DRender; |
58 | |
59 | namespace Qt3DExtras { |
60 | |
61 | /*! |
62 | * \qmltype CylinderMesh |
63 | * \instantiates Qt3DExtras::QCylinderMesh |
64 | * \inqmlmodule Qt3D.Extras |
65 | * \brief A cylindrical mesh. |
66 | */ |
67 | |
68 | /*! |
69 | * \qmlproperty int CylinderMesh::rings |
70 | * |
71 | * Holds the number of rings in the mesh. |
72 | */ |
73 | |
74 | /*! |
75 | * \qmlproperty int CylinderMesh::slices |
76 | * |
77 | * Holds the number of slices in the mesh. |
78 | */ |
79 | |
80 | /*! |
81 | * \qmlproperty real CylinderMesh::radius |
82 | * |
83 | * Holds the radius of the cylinder. |
84 | */ |
85 | |
86 | /*! |
87 | * \qmlproperty real CylinderMesh::length |
88 | * |
89 | * Holds the length of the cylinder. |
90 | */ |
91 | |
92 | /*! |
93 | * \class Qt3DExtras::QCylinderMesh |
94 | \ingroup qt3d-extras-geometries |
95 | * \inheaderfile Qt3DExtras/QCylinderMesh |
96 | * \inmodule Qt3DExtras |
97 | * |
98 | * \inherits Qt3DRender::QGeometryRenderer |
99 | * |
100 | * \brief A cylindrical mesh. |
101 | */ |
102 | |
103 | /*! |
104 | * Constructs a new QCylinderMesh with \a parent. |
105 | */ |
106 | QCylinderMesh::(QNode *parent) |
107 | : QGeometryRenderer(parent) |
108 | { |
109 | QCylinderGeometry *geometry = new QCylinderGeometry(this); |
110 | QObject::connect(sender: geometry, signal: &QCylinderGeometry::radiusChanged, receiver: this, slot: &QCylinderMesh::radiusChanged); |
111 | QObject::connect(sender: geometry, signal: &QCylinderGeometry::ringsChanged, receiver: this, slot: &QCylinderMesh::ringsChanged); |
112 | QObject::connect(sender: geometry, signal: &QCylinderGeometry::slicesChanged, receiver: this, slot: &QCylinderMesh::slicesChanged); |
113 | QObject::connect(sender: geometry, signal: &QCylinderGeometry::lengthChanged, receiver: this, slot: &QCylinderMesh::lengthChanged); |
114 | |
115 | QGeometryRenderer::setGeometry(geometry); |
116 | } |
117 | |
118 | /*! \internal */ |
119 | QCylinderMesh::() |
120 | { |
121 | } |
122 | |
123 | void QCylinderMesh::(int rings) |
124 | { |
125 | static_cast<QCylinderGeometry *>(geometry())->setRings(rings); |
126 | } |
127 | |
128 | void QCylinderMesh::(int slices) |
129 | { |
130 | static_cast<QCylinderGeometry *>(geometry())->setSlices(slices); |
131 | } |
132 | |
133 | void QCylinderMesh::(float radius) |
134 | { |
135 | static_cast<QCylinderGeometry *>(geometry())->setRadius(radius); |
136 | } |
137 | |
138 | void QCylinderMesh::(float length) |
139 | { |
140 | static_cast<QCylinderGeometry *>(geometry())->setLength(length); |
141 | } |
142 | |
143 | /*! |
144 | * \property QCylinderMesh::rings |
145 | * |
146 | * Holds the number of rings in the mesh. |
147 | */ |
148 | int QCylinderMesh::() const |
149 | { |
150 | return static_cast<QCylinderGeometry *>(geometry())->rings(); |
151 | } |
152 | |
153 | /*! |
154 | * \property QCylinderMesh::slices |
155 | * |
156 | * Holds the number of slices in the mesh. |
157 | */ |
158 | int QCylinderMesh::() const |
159 | { |
160 | return static_cast<QCylinderGeometry *>(geometry())->slices(); |
161 | } |
162 | |
163 | /*! |
164 | * \property QCylinderMesh::radius |
165 | * |
166 | * Holds the radius of the cylinder. |
167 | */ |
168 | float QCylinderMesh::() const |
169 | { |
170 | return static_cast<QCylinderGeometry *>(geometry())->radius(); |
171 | } |
172 | |
173 | /*! |
174 | * \property QCylinderMesh::length |
175 | * |
176 | * Holds the length of the cylinder. |
177 | */ |
178 | float QCylinderMesh::() const |
179 | { |
180 | return static_cast<QCylinderGeometry *>(geometry())->length(); |
181 | } |
182 | |
183 | } // namespace Qt3DExtras |
184 | |
185 | QT_END_NAMESPACE |
186 | |