| 1 | /**************************************************************************** | 
| 2 | ** | 
| 3 | ** Copyright (C) 2016 Klaralvdalens Datakonsult AB (KDAB). | 
| 4 | ** Contact: https://www.qt.io/licensing/ | 
| 5 | ** | 
| 6 | ** This file is part of the Qt3D module of the Qt Toolkit. | 
| 7 | ** | 
| 8 | ** $QT_BEGIN_LICENSE:LGPL$ | 
| 9 | ** Commercial License Usage | 
| 10 | ** Licensees holding valid commercial Qt licenses may use this file in | 
| 11 | ** accordance with the commercial license agreement provided with the | 
| 12 | ** Software or, alternatively, in accordance with the terms contained in | 
| 13 | ** a written agreement between you and The Qt Company. For licensing terms | 
| 14 | ** and conditions see https://www.qt.io/terms-conditions. For further | 
| 15 | ** information use the contact form at https://www.qt.io/contact-us. | 
| 16 | ** | 
| 17 | ** GNU Lesser General Public License Usage | 
| 18 | ** Alternatively, this file may be used under the terms of the GNU Lesser | 
| 19 | ** General Public License version 3 as published by the Free Software | 
| 20 | ** Foundation and appearing in the file LICENSE.LGPL3 included in the | 
| 21 | ** packaging of this file. Please review the following information to | 
| 22 | ** ensure the GNU Lesser General Public License version 3 requirements | 
| 23 | ** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. | 
| 24 | ** | 
| 25 | ** GNU General Public License Usage | 
| 26 | ** Alternatively, this file may be used under the terms of the GNU | 
| 27 | ** General Public License version 2.0 or (at your option) the GNU General | 
| 28 | ** Public license version 3 or any later version approved by the KDE Free | 
| 29 | ** Qt Foundation. The licenses are as published by the Free Software | 
| 30 | ** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 | 
| 31 | ** included in the packaging of this file. Please review the following | 
| 32 | ** information to ensure the GNU General Public License requirements will | 
| 33 | ** be met: https://www.gnu.org/licenses/gpl-2.0.html and | 
| 34 | ** https://www.gnu.org/licenses/gpl-3.0.html. | 
| 35 | ** | 
| 36 | ** $QT_END_LICENSE$ | 
| 37 | ** | 
| 38 | ****************************************************************************/ | 
| 39 |  | 
| 40 | #ifndef _USE_MATH_DEFINES | 
| 41 | # define _USE_MATH_DEFINES // For MSVC | 
| 42 | #endif | 
| 43 |  | 
| 44 | #include "qconegeometry.h" | 
| 45 |  | 
| 46 | #include <Qt3DExtras/qconemesh.h> | 
| 47 | #include <Qt3DRender/qbuffer.h> | 
| 48 | #include <Qt3DRender/qbufferdatagenerator.h> | 
| 49 | #include <Qt3DRender/qattribute.h> | 
| 50 | #include <QtGui/QVector3D> | 
| 51 |  | 
| 52 | #include <qmath.h> | 
| 53 |  | 
| 54 | QT_BEGIN_NAMESPACE | 
| 55 |  | 
| 56 | namespace Qt3DExtras { | 
| 57 |  | 
| 58 | /*! | 
| 59 |  * \qmltype ConeMesh | 
| 60 |  * \instantiates Qt3DExtras::QConeMesh | 
| 61 |  * \inqmlmodule Qt3D.Extras | 
| 62 |  * \brief A conical mesh. | 
| 63 |  */ | 
| 64 |  | 
| 65 | /*! | 
| 66 |  * \qmlproperty int ConeMesh::rings | 
| 67 |  * | 
| 68 |  * Holds the number of rings in the mesh. | 
| 69 |  */ | 
| 70 |  | 
| 71 | /*! | 
| 72 |  * \qmlproperty int ConeMesh::slices | 
| 73 |  * | 
| 74 |  * Holds the number of slices in the mesh. | 
| 75 |  */ | 
| 76 |  | 
| 77 | /*! | 
| 78 |  * \qmlproperty bool ConeMesh::hasTopEndcap | 
| 79 |  * | 
| 80 |  * Determines if the cone top is capped or open. | 
| 81 |  */ | 
| 82 |  | 
| 83 | /*! | 
| 84 |  * \qmlproperty bool ConeMesh::hasBottomEndcap | 
| 85 |  * | 
| 86 |  * Determines if the cone bottom is capped or open. | 
| 87 |  */ | 
| 88 |  | 
| 89 | /*! | 
| 90 |  * \qmlproperty real ConeMesh::topRadius | 
| 91 |  * | 
| 92 |  * Holds the top radius of the cone. | 
| 93 |  */ | 
| 94 |  | 
| 95 | /*! | 
| 96 |  * \qmlproperty real ConeMesh::bottomRadius | 
| 97 |  * | 
| 98 |  * Holds the bottom radius of the cone. | 
| 99 |  */ | 
| 100 |  | 
| 101 | /*! | 
| 102 |  * \qmlproperty real ConeMesh::length | 
| 103 |  * | 
| 104 |  * Holds the length of the cone. | 
| 105 |  */ | 
| 106 |  | 
| 107 | /*! | 
| 108 |  * \class Qt3DExtras::QConeMesh | 
| 109 |    \ingroup qt3d-extras-geometries | 
| 110 |  * \inheaderfile Qt3DExtras/QConeMesh | 
| 111 |  * \inmodule Qt3DExtras | 
| 112 |  * | 
| 113 |  * \inherits Qt3DRender::QGeometryRenderer | 
| 114 |  * | 
| 115 |  * \brief A conical mesh. | 
| 116 |  */ | 
| 117 |  | 
| 118 | QConeMesh::(QNode *parent) | 
| 119 |     : QGeometryRenderer(parent) | 
| 120 | { | 
| 121 |     QConeGeometry *geometry = new QConeGeometry(this); | 
| 122 |     QObject::connect(sender: geometry, signal: &QConeGeometry::hasTopEndcapChanged, receiver: this, slot: &QConeMesh::hasTopEndcapChanged); | 
| 123 |     QObject::connect(sender: geometry, signal: &QConeGeometry::hasBottomEndcapChanged, receiver: this, slot: &QConeMesh::hasBottomEndcapChanged); | 
| 124 |     QObject::connect(sender: geometry, signal: &QConeGeometry::topRadiusChanged, receiver: this, slot: &QConeMesh::topRadiusChanged); | 
| 125 |     QObject::connect(sender: geometry, signal: &QConeGeometry::bottomRadiusChanged, receiver: this, slot: &QConeMesh::bottomRadiusChanged); | 
| 126 |     QObject::connect(sender: geometry, signal: &QConeGeometry::ringsChanged, receiver: this, slot: &QConeMesh::ringsChanged); | 
| 127 |     QObject::connect(sender: geometry, signal: &QConeGeometry::slicesChanged, receiver: this, slot: &QConeMesh::slicesChanged); | 
| 128 |     QObject::connect(sender: geometry, signal: &QConeGeometry::lengthChanged, receiver: this, slot: &QConeMesh::lengthChanged); | 
| 129 |  | 
| 130 |     QGeometryRenderer::setGeometry(geometry); | 
| 131 | } | 
| 132 |  | 
| 133 | /*! \internal */ | 
| 134 | QConeMesh::() | 
| 135 | { | 
| 136 | } | 
| 137 |  | 
| 138 | void QConeMesh::(bool hasTopEndcap) | 
| 139 | { | 
| 140 |     static_cast<QConeGeometry *>(geometry())->setHasTopEndcap(hasTopEndcap); | 
| 141 | } | 
| 142 |  | 
| 143 | void QConeMesh::(bool hasBottomEndcap) | 
| 144 | { | 
| 145 |     static_cast<QConeGeometry *>(geometry())->setHasBottomEndcap(hasBottomEndcap); | 
| 146 | } | 
| 147 |  | 
| 148 | void QConeMesh::(float topRadius) | 
| 149 | { | 
| 150 |     static_cast<QConeGeometry *>(geometry())->setTopRadius(topRadius); | 
| 151 | } | 
| 152 |  | 
| 153 | void QConeMesh::(float bottomRadius) | 
| 154 | { | 
| 155 |     static_cast<QConeGeometry *>(geometry())->setBottomRadius(bottomRadius); | 
| 156 | } | 
| 157 |  | 
| 158 | void QConeMesh::(int rings) | 
| 159 | { | 
| 160 |     static_cast<QConeGeometry *>(geometry())->setRings(rings); | 
| 161 | } | 
| 162 |  | 
| 163 | void QConeMesh::(int slices) | 
| 164 | { | 
| 165 |     static_cast<QConeGeometry *>(geometry())->setSlices(slices); | 
| 166 | } | 
| 167 |  | 
| 168 | void QConeMesh::(float length) | 
| 169 | { | 
| 170 |     static_cast<QConeGeometry *>(geometry())->setLength(length); | 
| 171 | } | 
| 172 |  | 
| 173 | /*! | 
| 174 |  * \property QConeMesh::hasTopEndcap | 
| 175 |  * | 
| 176 |  * Determines if the cone top is capped or open. | 
| 177 |  */ | 
| 178 | bool QConeMesh::() const | 
| 179 | { | 
| 180 |     return static_cast<QConeGeometry *>(geometry())->hasTopEndcap(); | 
| 181 | } | 
| 182 |  | 
| 183 | /*! | 
| 184 |  * \property QConeMesh::hasBottomEndcap | 
| 185 |  * | 
| 186 |  * Determines if the cone bottom is capped or open. | 
| 187 |  */ | 
| 188 | bool QConeMesh::() const | 
| 189 | { | 
| 190 |     return static_cast<QConeGeometry *>(geometry())->hasBottomEndcap(); | 
| 191 | } | 
| 192 |  | 
| 193 | /*! | 
| 194 |  * \property QConeMesh::topRadius | 
| 195 |  * | 
| 196 |  * Holds the top radius of the cone. | 
| 197 |  */ | 
| 198 | float QConeMesh::() const | 
| 199 | { | 
| 200 |     return static_cast<QConeGeometry *>(geometry())->topRadius(); | 
| 201 | } | 
| 202 |  | 
| 203 | /*! | 
| 204 |  * \property QConeMesh::bottomRadius | 
| 205 |  * | 
| 206 |  * Holds the bottom radius of the cone. | 
| 207 |  */ | 
| 208 | float QConeMesh::() const | 
| 209 | { | 
| 210 |     return static_cast<QConeGeometry *>(geometry())->bottomRadius(); | 
| 211 | } | 
| 212 |  | 
| 213 | /*! | 
| 214 |  * \property QConeMesh::rings | 
| 215 |  * | 
| 216 |  * Holds the number of rings in the mesh. | 
| 217 |  */ | 
| 218 | int QConeMesh::() const | 
| 219 | { | 
| 220 |     return static_cast<QConeGeometry *>(geometry())->rings(); | 
| 221 | } | 
| 222 |  | 
| 223 | /*! | 
| 224 |  * \property QConeMesh::slices | 
| 225 |  * | 
| 226 |  * Holds the number of slices in the mesh. | 
| 227 |  */ | 
| 228 | int QConeMesh::() const | 
| 229 | { | 
| 230 |     return static_cast<QConeGeometry *>(geometry())->slices(); | 
| 231 | } | 
| 232 |  | 
| 233 | /*! | 
| 234 |  * \property QConeMesh::length | 
| 235 |  * | 
| 236 |  * Holds the length of the cone. | 
| 237 |  */ | 
| 238 | float QConeMesh::() const | 
| 239 | { | 
| 240 |     return static_cast<QConeGeometry *>(geometry())->length(); | 
| 241 | } | 
| 242 |  | 
| 243 | } // namespace Qt3DExtras | 
| 244 |  | 
| 245 | QT_END_NAMESPACE | 
| 246 |  |