1// Copyright (C) 2014 Klaralvdalens Datakonsult AB (KDAB).
2// Copyright (C) 2016 The Qt Company Ltd and/or its subsidiary(-ies).
3// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
4
5#include "qspheremesh.h"
6
7#include <Qt3DExtras/qspheregeometryview.h>
8
9QT_BEGIN_NAMESPACE
10
11namespace Qt3DExtras {
12
13/*!
14 * \qmltype SphereMesh
15 * \instantiates Qt3DExtras::QSphereMesh
16 * \inqmlmodule Qt3D.Extras
17 * \brief A spherical mesh.
18 */
19
20/*!
21 * \qmlproperty int SphereMesh::rings
22 *
23 * Holds the number of rings in the mesh.
24 */
25
26/*!
27 * \qmlproperty int SphereMesh::slices
28 *
29 * Holds the number of slices in the mesh.
30 */
31
32/*!
33 * \qmlproperty real SphereMesh::radius
34 *
35 * Holds the radius of the sphere.
36 */
37
38/*!
39 * \qmlproperty bool SphereMesh::generateTangents
40 *
41 * Holds the value of the automatic tangent vectors generation flag.
42 * Tangent vectors are orthogonal to normal vectors.
43 */
44
45/*!
46 * \class Qt3DExtras::QSphereMesh
47 * \ingroup qt3d-extras-geometries
48 * \inheaderfile Qt3DExtras/QSphereMesh
49 * \inmodule Qt3DExtras
50 *
51 * \inherits Qt3DRender::QGeometryRenderer
52 *
53 * \brief A spherical mesh.
54 */
55
56/*!
57 * Constructs a new QSphereMesh with \a parent.
58 */
59QSphereMesh::QSphereMesh(QNode *parent)
60 : Qt3DRender::QGeometryRenderer(parent)
61{
62 QSphereGeometryView *geometry = new QSphereGeometryView(this);
63 QObject::connect(sender: geometry, signal: &QSphereGeometryView::radiusChanged, context: this, slot: &QSphereMesh::radiusChanged);
64 QObject::connect(sender: geometry, signal: &QSphereGeometryView::ringsChanged, context: this, slot: &QSphereMesh::ringsChanged);
65 QObject::connect(sender: geometry, signal: &QSphereGeometryView::slicesChanged, context: this, slot: &QSphereMesh::slicesChanged);
66 QObject::connect(sender: geometry, signal: &QSphereGeometryView::generateTangentsChanged, context: this, slot: &QSphereMesh::generateTangentsChanged);
67 setView(geometry);
68}
69
70/*! \internal */
71QSphereMesh::~QSphereMesh()
72{
73}
74
75void QSphereMesh::setRings(int rings)
76{
77 static_cast<QSphereGeometryView *>(view())->setRings(rings);
78}
79
80void QSphereMesh::setSlices(int slices)
81{
82 static_cast<QSphereGeometryView *>(view())->setSlices(slices);
83}
84
85void QSphereMesh::setRadius(float radius)
86{
87 static_cast<QSphereGeometryView *>(view())->setRadius(radius);
88}
89
90void QSphereMesh::setGenerateTangents(bool gen)
91{
92 static_cast<QSphereGeometryView *>(view())->setGenerateTangents(gen);
93}
94
95/*!
96 * \property QSphereMesh::generateTangents
97 *
98 * Holds the value of the automatic tangent vectors generation flag.
99 * Tangent vectors are orthogonal to normal vectors.
100 */
101bool QSphereMesh::generateTangents() const
102{
103 return static_cast<QSphereGeometryView *>(view())->generateTangents();
104}
105
106/*!
107 * \property QSphereMesh::rings
108 *
109 * Holds the number of rings in the mesh.
110 */
111int QSphereMesh::rings() const
112{
113 return static_cast<QSphereGeometryView *>(view())->rings();
114}
115
116/*!
117 * \property QSphereMesh::slices
118 *
119 * Holds the number of slices in the mesh.
120 */
121int QSphereMesh::slices() const
122{
123 return static_cast<QSphereGeometryView *>(view())->slices();
124}
125
126/*!
127 * \property QSphereMesh::radius
128 *
129 * Holds the radius of the sphere.
130 */
131float QSphereMesh::radius() const
132{
133 return static_cast<QSphereGeometryView *>(view())->radius();
134}
135
136} // Qt3DExtras
137
138QT_END_NAMESPACE
139
140#include "moc_qspheremesh.cpp"
141

source code of qt3d/src/extras/geometries/qspheremesh.cpp