1// Copyright (C) 2020 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
3
4#ifndef QQUICK3DSPOTLIGHT_H
5#define QQUICK3DSPOTLIGHT_H
6
7//
8// W A R N I N G
9// -------------
10//
11// This file is not part of the Qt API. It exists purely as an
12// implementation detail. This header file may change from version to
13// version without notice, or even be removed.
14//
15// We mean it.
16//
17
18#include <QtQuick3D/private/qquick3dabstractlight_p.h>
19
20QT_BEGIN_NAMESPACE
21
22class Q_QUICK3D_EXPORT QQuick3DSpotLight : public QQuick3DAbstractLight
23{
24 Q_OBJECT
25 Q_PROPERTY(float constantFade READ constantFade WRITE setConstantFade NOTIFY constantFadeChanged)
26 Q_PROPERTY(float linearFade READ linearFade WRITE setLinearFade NOTIFY linearFadeChanged)
27 Q_PROPERTY(float quadraticFade READ quadraticFade WRITE setQuadraticFade NOTIFY quadraticFadeChanged)
28 Q_PROPERTY(float coneAngle READ coneAngle WRITE setConeAngle NOTIFY coneAngleChanged)
29 Q_PROPERTY(float innerConeAngle READ innerConeAngle WRITE setInnerConeAngle NOTIFY innerConeAngleChanged)
30
31 QML_NAMED_ELEMENT(SpotLight)
32
33public:
34 explicit QQuick3DSpotLight(QQuick3DNode *parent = nullptr);
35 ~QQuick3DSpotLight() override {}
36
37 float constantFade() const;
38 float linearFade() const;
39 float quadraticFade() const;
40 float coneAngle() const;
41 float innerConeAngle() const;
42
43public Q_SLOTS:
44 void setConstantFade(float constantFade);
45 void setLinearFade(float linearFade);
46 void setQuadraticFade(float quadraticFade);
47 void setConeAngle(float coneAngle);
48 void setInnerConeAngle(float innerConeAngle);
49
50Q_SIGNALS:
51 void constantFadeChanged();
52 void linearFadeChanged();
53 void quadraticFadeChanged();
54 void coneAngleChanged();
55 void innerConeAngleChanged();
56
57protected:
58 QSSGRenderGraphObject *updateSpatialNode(QSSGRenderGraphObject *node) override;
59
60private:
61 float m_constantFade = 1.0f;
62 float m_linearFade = 0.0f;
63 float m_quadraticFade = 1.0f;
64 float m_coneAngle = 40.0f;
65 float m_innerConeAngle = 30.0f;
66};
67
68QT_END_NAMESPACE
69
70#endif // QQUICK3DSPOTLIGHT_H
71

source code of qtquick3d/src/quick3d/qquick3dspotlight_p.h