1 | // Copyright (C) 2015 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 "qclipplane.h" |
5 | #include "qclipplane_p.h" |
6 | |
7 | QT_BEGIN_NAMESPACE |
8 | |
9 | namespace Qt3DRender { |
10 | |
11 | /*! |
12 | \class Qt3DRender::QClipPlane |
13 | \inmodule Qt3DRender |
14 | \since 5.5 |
15 | \brief Enables an additional OpenGL clipping plane that can be in shaders |
16 | using gl_ClipDistance. |
17 | |
18 | By default, OpenGL supports up to 8 additional clipping planes. |
19 | Qt3DCore::QClipPlane allows to enable one of these additional planes. These |
20 | planes can then be manipulated in the shaders using gl_ClipDistance[i] |
21 | where i varies between 0 and 7. The underlying implementation may support more |
22 | than 8 clip planes, but it is not guaranteed. |
23 | */ |
24 | |
25 | /*! |
26 | \qmltype ClipPlane |
27 | \instantiates Qt3DRender::QClipPlane |
28 | \inherits RenderState |
29 | \inqmlmodule Qt3D.Render |
30 | \since 5.5 |
31 | \brief Enables an additional OpenGL clipping plane that can be in shaders |
32 | using gl_ClipDistance. |
33 | |
34 | By default, OpenGL supports up to 8 additional clipping planes. ClipPlane |
35 | allows to enable one of these additional planes. These planes can then be |
36 | manipulated in the shaders using gl_ClipDistance[i] where i varies between |
37 | 0 and 7. The underlying implementation may support more than 8 clip planes, |
38 | but it is not guaranteed. |
39 | */ |
40 | |
41 | /*! |
42 | \qmlproperty int ClipPlane::planeIndex |
43 | Holds the index of the plane. |
44 | \note Usually between 0-7. |
45 | */ |
46 | |
47 | /*! |
48 | \qmlproperty vector3d ClipPlane::normal |
49 | Holds the normal of the plane. |
50 | */ |
51 | |
52 | /*! |
53 | \qmlproperty real ClipPlane::distance |
54 | Holds the distance of the plane from the world origin. |
55 | */ |
56 | |
57 | |
58 | /*! |
59 | \property QClipPlane::planeIndex |
60 | Holds the index of the plane. |
61 | \note Usually between 0-7. |
62 | */ |
63 | |
64 | /*! |
65 | \property QClipPlane::normal |
66 | Holds the normal of the plane. |
67 | */ |
68 | |
69 | /*! |
70 | \property QClipPlane::distance |
71 | Holds the distance of the plane from the world origin. |
72 | */ |
73 | |
74 | |
75 | QClipPlane::QClipPlane(QNode *parent) |
76 | : QRenderState(*new QClipPlanePrivate(), parent) |
77 | { |
78 | } |
79 | |
80 | /*! \internal */ |
81 | QClipPlane::~QClipPlane() |
82 | { |
83 | } |
84 | |
85 | int QClipPlane::planeIndex() const |
86 | { |
87 | Q_D(const QClipPlane); |
88 | return d->m_planeIndex; |
89 | } |
90 | |
91 | QVector3D QClipPlane::normal() const |
92 | { |
93 | Q_D(const QClipPlane); |
94 | return d->m_normal; |
95 | } |
96 | |
97 | float QClipPlane::distance() const |
98 | { |
99 | Q_D(const QClipPlane); |
100 | return d->m_distance; |
101 | } |
102 | |
103 | void QClipPlane::setPlaneIndex(int planeIndex) |
104 | { |
105 | Q_D(QClipPlane); |
106 | if (planeIndex != d->m_planeIndex) { |
107 | d->m_planeIndex = planeIndex; |
108 | Q_EMIT planeIndexChanged(planeIndex); |
109 | } |
110 | } |
111 | |
112 | void QClipPlane::setNormal(QVector3D normal) |
113 | { |
114 | Q_D(QClipPlane); |
115 | if (normal != d->m_normal) { |
116 | d->m_normal = normal; |
117 | Q_EMIT normalChanged(normal); |
118 | } |
119 | } |
120 | |
121 | void QClipPlane::setDistance(float distance) |
122 | { |
123 | Q_D(QClipPlane); |
124 | if (distance != d->m_distance) { |
125 | d->m_distance = distance; |
126 | Q_EMIT distanceChanged(distance); |
127 | } |
128 | } |
129 | |
130 | } // namespace Qt3DRender |
131 | |
132 | QT_END_NAMESPACE |
133 | |
134 | #include "moc_qclipplane.cpp" |
135 | |