1// Copyright (C) 2019 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
3
4#ifndef QSSGPERSPECTIVECAMERA_H
5#define QSSGPERSPECTIVECAMERA_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/qquick3dcamera_p.h>
19
20QT_BEGIN_NAMESPACE
21
22struct QSSGRenderCamera;
23class Q_QUICK3D_EXPORT QQuick3DPerspectiveCamera : public QQuick3DCamera
24{
25 Q_OBJECT
26 Q_PROPERTY(float clipNear READ clipNear WRITE setClipNear NOTIFY clipNearChanged)
27 Q_PROPERTY(float clipFar READ clipFar WRITE setClipFar NOTIFY clipFarChanged)
28 Q_PROPERTY(float fieldOfView READ fieldOfView WRITE setFieldOfView NOTIFY fieldOfViewChanged)
29 Q_PROPERTY(FieldOfViewOrientation fieldOfViewOrientation READ fieldOfViewOrientation WRITE setFieldOfViewOrientation NOTIFY fieldOfViewOrientationChanged)
30
31 QML_NAMED_ELEMENT(PerspectiveCamera)
32
33public:
34 enum FieldOfViewOrientation {
35 Vertical,
36 Horizontal
37 };
38 Q_ENUM(FieldOfViewOrientation)
39
40 explicit QQuick3DPerspectiveCamera(QQuick3DNode *parent = nullptr);
41
42 float clipNear() const;
43 float clipFar() const;
44 float fieldOfView() const;
45 FieldOfViewOrientation fieldOfViewOrientation() const;
46
47public Q_SLOTS:
48 void setClipNear(float clipNear);
49 void setClipFar(float clipFar);
50 void setFieldOfView(float fieldOfView);
51 void setFieldOfViewOrientation(QQuick3DPerspectiveCamera::FieldOfViewOrientation fieldOfViewOrientation);
52
53Q_SIGNALS:
54 void clipNearChanged();
55 void clipFarChanged();
56 void fieldOfViewChanged();
57 void fieldOfViewOrientationChanged();
58
59protected:
60 explicit QQuick3DPerspectiveCamera(QQuick3DNodePrivate &dd, QQuick3DNode *parent = nullptr);
61 QSSGRenderGraphObject *updateSpatialNode(QSSGRenderGraphObject *node) override;
62
63private:
64 float m_clipNear = 10.0f;
65 float m_clipFar = 10000.0f;
66 float m_fieldOfView = 60.0f;
67 FieldOfViewOrientation m_fieldOfViewOrientation = Vertical;
68};
69
70QT_END_NAMESPACE
71
72#endif // QSSGPERSPECTIVECAMERA_H
73

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