| 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 | #include "qfrontface.h" |
| 42 | #include "qfrontface_p.h" |
| 43 | #include <Qt3DRender/private/qrenderstatecreatedchange_p.h> |
| 44 | |
| 45 | QT_BEGIN_NAMESPACE |
| 46 | |
| 47 | namespace Qt3DRender { |
| 48 | |
| 49 | /*! |
| 50 | \class Qt3DRender::QFrontFace |
| 51 | \brief The QFrontFace class defines front and back facing polygons. |
| 52 | \since 5.7 |
| 53 | \ingroup renderstates |
| 54 | \inmodule Qt3DRender |
| 55 | |
| 56 | A Qt3DRender::QFrontFace sets the winding direction of the front facing polygons. |
| 57 | |
| 58 | \sa QCullFace |
| 59 | */ |
| 60 | |
| 61 | /*! |
| 62 | \qmltype FrontFace |
| 63 | \brief The FrontFace type defines front and back facing polygons. |
| 64 | \since 5.7 |
| 65 | \ingroup renderstates |
| 66 | \inqmlmodule Qt3D.Render |
| 67 | \inherits RenderState |
| 68 | \instantiates Qt3DRender::QFrontFace |
| 69 | |
| 70 | A FrontFace sets the winding direction of the front facing polygons. |
| 71 | |
| 72 | \sa CullFace |
| 73 | */ |
| 74 | |
| 75 | /*! |
| 76 | \enum QFrontFace::WindingDirection |
| 77 | |
| 78 | This enumeration specifies the winding direction values. |
| 79 | \value ClockWise Clockwise polygons are front facing. |
| 80 | \value CounterClockWise Counter clockwise polygons are front facing. |
| 81 | */ |
| 82 | |
| 83 | /*! |
| 84 | \qmlproperty enumeration FrontFace::direction |
| 85 | Holds the winding direction of the front facing polygons. Default is FrontFace.Clockwise. |
| 86 | */ |
| 87 | |
| 88 | /*! |
| 89 | \property QFrontFace::direction |
| 90 | Holds the winding direction of the front facing polygons. Default is Clockwise. |
| 91 | */ |
| 92 | |
| 93 | /*! |
| 94 | The constructor creates a new QFrontFace::QFrontFace instance with the |
| 95 | specified \a parent |
| 96 | */ |
| 97 | QFrontFace::QFrontFace(QNode *parent) |
| 98 | : QRenderState(*new QFrontFacePrivate, parent) |
| 99 | { |
| 100 | } |
| 101 | |
| 102 | /*! \internal */ |
| 103 | QFrontFace::~QFrontFace() |
| 104 | { |
| 105 | } |
| 106 | |
| 107 | QFrontFace::WindingDirection QFrontFace::direction() const |
| 108 | { |
| 109 | Q_D(const QFrontFace); |
| 110 | return d->m_direction; |
| 111 | } |
| 112 | |
| 113 | void QFrontFace::setDirection(QFrontFace::WindingDirection direction) |
| 114 | { |
| 115 | Q_D(QFrontFace); |
| 116 | if (d->m_direction != direction) { |
| 117 | d->m_direction = direction; |
| 118 | emit directionChanged(direction); |
| 119 | } |
| 120 | } |
| 121 | |
| 122 | Qt3DCore::QNodeCreatedChangeBasePtr QFrontFace::createNodeCreationChange() const |
| 123 | { |
| 124 | auto creationChange = QRenderStateCreatedChangePtr<QFrontFaceData>::create(arguments: this); |
| 125 | auto &data = creationChange->data; |
| 126 | Q_D(const QFrontFace); |
| 127 | data.direction = d->m_direction; |
| 128 | return creationChange; |
| 129 | } |
| 130 | |
| 131 | } // namespace Qt3DRender |
| 132 | |
| 133 | QT_END_NAMESPACE |
| 134 | |