| 1 | // Copyright (C) 2016 Klaralvdalens Datakonsult AB (KDAB). |
| 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only |
| 3 | |
| 4 | #include "qconemesh.h" |
| 5 | |
| 6 | #include <Qt3DExtras/qconegeometryview.h> |
| 7 | #include <Qt3DCore/qbuffer.h> |
| 8 | #include <Qt3DCore/qattribute.h> |
| 9 | #include <QtGui/QVector3D> |
| 10 | |
| 11 | #include <qmath.h> |
| 12 | |
| 13 | QT_BEGIN_NAMESPACE |
| 14 | |
| 15 | namespace Qt3DExtras { |
| 16 | |
| 17 | /*! |
| 18 | * \qmltype ConeMesh |
| 19 | * \nativetype Qt3DExtras::QConeMesh |
| 20 | * \inqmlmodule Qt3D.Extras |
| 21 | * \brief A conical mesh. |
| 22 | */ |
| 23 | |
| 24 | /*! |
| 25 | * \qmlproperty int ConeMesh::rings |
| 26 | * |
| 27 | * Holds the number of rings in the mesh. |
| 28 | */ |
| 29 | |
| 30 | /*! |
| 31 | * \qmlproperty int ConeMesh::slices |
| 32 | * |
| 33 | * Holds the number of slices in the mesh. |
| 34 | */ |
| 35 | |
| 36 | /*! |
| 37 | * \qmlproperty bool ConeMesh::hasTopEndcap |
| 38 | * |
| 39 | * Determines if the cone top is capped or open. |
| 40 | */ |
| 41 | |
| 42 | /*! |
| 43 | * \qmlproperty bool ConeMesh::hasBottomEndcap |
| 44 | * |
| 45 | * Determines if the cone bottom is capped or open. |
| 46 | */ |
| 47 | |
| 48 | /*! |
| 49 | * \qmlproperty real ConeMesh::topRadius |
| 50 | * |
| 51 | * Holds the top radius of the cone. |
| 52 | */ |
| 53 | |
| 54 | /*! |
| 55 | * \qmlproperty real ConeMesh::bottomRadius |
| 56 | * |
| 57 | * Holds the bottom radius of the cone. |
| 58 | */ |
| 59 | |
| 60 | /*! |
| 61 | * \qmlproperty real ConeMesh::length |
| 62 | * |
| 63 | * Holds the length of the cone. |
| 64 | */ |
| 65 | |
| 66 | /*! |
| 67 | * \class Qt3DExtras::QConeMesh |
| 68 | * \ingroup qt3d-extras-geometries |
| 69 | * \inheaderfile Qt3DExtras/QConeMesh |
| 70 | * \inmodule Qt3DExtras |
| 71 | * |
| 72 | * \inherits Qt3DRender::QGeometryRenderer |
| 73 | * |
| 74 | * \brief A conical mesh. |
| 75 | */ |
| 76 | |
| 77 | QConeMesh::(QNode *parent) |
| 78 | : Qt3DRender::QGeometryRenderer(parent) |
| 79 | { |
| 80 | QConeGeometryView *geometry = new QConeGeometryView(this); |
| 81 | QObject::connect(sender: geometry, signal: &QConeGeometryView::hasTopEndcapChanged, context: this, slot: &QConeMesh::hasTopEndcapChanged); |
| 82 | QObject::connect(sender: geometry, signal: &QConeGeometryView::hasBottomEndcapChanged, context: this, slot: &QConeMesh::hasBottomEndcapChanged); |
| 83 | QObject::connect(sender: geometry, signal: &QConeGeometryView::topRadiusChanged, context: this, slot: &QConeMesh::topRadiusChanged); |
| 84 | QObject::connect(sender: geometry, signal: &QConeGeometryView::bottomRadiusChanged, context: this, slot: &QConeMesh::bottomRadiusChanged); |
| 85 | QObject::connect(sender: geometry, signal: &QConeGeometryView::ringsChanged, context: this, slot: &QConeMesh::ringsChanged); |
| 86 | QObject::connect(sender: geometry, signal: &QConeGeometryView::slicesChanged, context: this, slot: &QConeMesh::slicesChanged); |
| 87 | QObject::connect(sender: geometry, signal: &QConeGeometryView::lengthChanged, context: this, slot: &QConeMesh::lengthChanged); |
| 88 | |
| 89 | setView(geometry); |
| 90 | } |
| 91 | |
| 92 | /*! \internal */ |
| 93 | QConeMesh::() |
| 94 | { |
| 95 | } |
| 96 | |
| 97 | void QConeMesh::(bool hasTopEndcap) |
| 98 | { |
| 99 | static_cast<QConeGeometryView *>(view())->setHasTopEndcap(hasTopEndcap); |
| 100 | } |
| 101 | |
| 102 | void QConeMesh::(bool hasBottomEndcap) |
| 103 | { |
| 104 | static_cast<QConeGeometryView *>(view())->setHasBottomEndcap(hasBottomEndcap); |
| 105 | } |
| 106 | |
| 107 | void QConeMesh::(float topRadius) |
| 108 | { |
| 109 | static_cast<QConeGeometryView *>(view())->setTopRadius(topRadius); |
| 110 | } |
| 111 | |
| 112 | void QConeMesh::(float bottomRadius) |
| 113 | { |
| 114 | static_cast<QConeGeometryView *>(view())->setBottomRadius(bottomRadius); |
| 115 | } |
| 116 | |
| 117 | void QConeMesh::(int rings) |
| 118 | { |
| 119 | static_cast<QConeGeometryView *>(view())->setRings(rings); |
| 120 | } |
| 121 | |
| 122 | void QConeMesh::(int slices) |
| 123 | { |
| 124 | static_cast<QConeGeometryView *>(view())->setSlices(slices); |
| 125 | } |
| 126 | |
| 127 | void QConeMesh::(float length) |
| 128 | { |
| 129 | static_cast<QConeGeometryView *>(view())->setLength(length); |
| 130 | } |
| 131 | |
| 132 | /*! |
| 133 | * \property Qt3DExtras::QConeMesh::hasTopEndcap |
| 134 | * |
| 135 | * Determines if the cone top is capped or open. |
| 136 | */ |
| 137 | bool QConeMesh::() const |
| 138 | { |
| 139 | return static_cast<QConeGeometryView *>(view())->hasTopEndcap(); |
| 140 | } |
| 141 | |
| 142 | /*! |
| 143 | * \property Qt3DExtras::QConeMesh::hasBottomEndcap |
| 144 | * |
| 145 | * Determines if the cone bottom is capped or open. |
| 146 | */ |
| 147 | bool QConeMesh::() const |
| 148 | { |
| 149 | return static_cast<QConeGeometryView *>(view())->hasBottomEndcap(); |
| 150 | } |
| 151 | |
| 152 | /*! |
| 153 | * \property Qt3DExtras::QConeMesh::topRadius |
| 154 | * |
| 155 | * Holds the top radius of the cone. |
| 156 | */ |
| 157 | float QConeMesh::() const |
| 158 | { |
| 159 | return static_cast<QConeGeometryView *>(view())->topRadius(); |
| 160 | } |
| 161 | |
| 162 | /*! |
| 163 | * \property Qt3DExtras::QConeMesh::bottomRadius |
| 164 | * |
| 165 | * Holds the bottom radius of the cone. |
| 166 | */ |
| 167 | float QConeMesh::() const |
| 168 | { |
| 169 | return static_cast<QConeGeometryView *>(view())->bottomRadius(); |
| 170 | } |
| 171 | |
| 172 | /*! |
| 173 | * \property Qt3DExtras::QConeMesh::rings |
| 174 | * |
| 175 | * Holds the number of rings in the mesh. |
| 176 | */ |
| 177 | int QConeMesh::() const |
| 178 | { |
| 179 | return static_cast<QConeGeometryView *>(view())->rings(); |
| 180 | } |
| 181 | |
| 182 | /*! |
| 183 | * \property Qt3DExtras::QConeMesh::slices |
| 184 | * |
| 185 | * Holds the number of slices in the mesh. |
| 186 | */ |
| 187 | int QConeMesh::() const |
| 188 | { |
| 189 | return static_cast<QConeGeometryView *>(view())->slices(); |
| 190 | } |
| 191 | |
| 192 | /*! |
| 193 | * \property Qt3DExtras::QConeMesh::length |
| 194 | * |
| 195 | * Holds the length of the cone. |
| 196 | */ |
| 197 | float QConeMesh::() const |
| 198 | { |
| 199 | return static_cast<QConeGeometryView *>(view())->length(); |
| 200 | } |
| 201 | |
| 202 | } // namespace Qt3DExtras |
| 203 | |
| 204 | QT_END_NAMESPACE |
| 205 | |
| 206 | #include "moc_qconemesh.cpp" |
| 207 | |