1 | // Copyright (C) 2014 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 | #ifndef QT3DRENDER_CAMERALENS_H |
5 | #define QT3DRENDER_CAMERALENS_H |
6 | |
7 | #include <Qt3DCore/qcomponent.h> |
8 | #include <Qt3DRender/qt3drender_global.h> |
9 | |
10 | #include <QtGui/QMatrix4x4> |
11 | #include <QtGui/QQuaternion> |
12 | #include <QtGui/QVector3D> |
13 | |
14 | QT_BEGIN_NAMESPACE |
15 | |
16 | namespace Qt3DRender { |
17 | |
18 | class QCameraLensPrivate; |
19 | |
20 | class Q_3DRENDERSHARED_EXPORT QCameraLens : public Qt3DCore::QComponent |
21 | { |
22 | Q_OBJECT |
23 | Q_PROPERTY(ProjectionType projectionType READ projectionType WRITE setProjectionType NOTIFY projectionTypeChanged) |
24 | Q_PROPERTY(float nearPlane READ nearPlane WRITE setNearPlane NOTIFY nearPlaneChanged) |
25 | Q_PROPERTY(float farPlane READ farPlane WRITE setFarPlane NOTIFY farPlaneChanged) |
26 | Q_PROPERTY(float fieldOfView READ fieldOfView WRITE setFieldOfView NOTIFY fieldOfViewChanged) |
27 | Q_PROPERTY(float aspectRatio READ aspectRatio WRITE setAspectRatio NOTIFY aspectRatioChanged) |
28 | Q_PROPERTY(float left READ left WRITE setLeft NOTIFY leftChanged) |
29 | Q_PROPERTY(float right READ right WRITE setRight NOTIFY rightChanged) |
30 | Q_PROPERTY(float bottom READ bottom WRITE setBottom NOTIFY bottomChanged) |
31 | Q_PROPERTY(float top READ top WRITE setTop NOTIFY topChanged) |
32 | Q_PROPERTY(QMatrix4x4 projectionMatrix READ projectionMatrix WRITE setProjectionMatrix NOTIFY projectionMatrixChanged) |
33 | Q_PROPERTY(float exposure READ exposure WRITE setExposure NOTIFY exposureChanged REVISION 9) |
34 | |
35 | public: |
36 | explicit QCameraLens(QNode *parent = nullptr); |
37 | ~QCameraLens(); |
38 | |
39 | enum ProjectionType { |
40 | OrthographicProjection, |
41 | PerspectiveProjection, |
42 | FrustumProjection, |
43 | CustomProjection |
44 | }; |
45 | Q_ENUM(ProjectionType) // LCOV_EXCL_LINE |
46 | |
47 | ProjectionType projectionType() const; |
48 | float nearPlane() const; |
49 | float farPlane() const; |
50 | float fieldOfView() const; |
51 | float aspectRatio() const; |
52 | float left() const; |
53 | float right() const; |
54 | float bottom() const; |
55 | float top() const; |
56 | |
57 | QMatrix4x4 projectionMatrix() const; |
58 | |
59 | void setOrthographicProjection(float left, float right, |
60 | float bottom, float top, |
61 | float nearPlane, float farPlane); |
62 | |
63 | void setFrustumProjection(float left, float right, |
64 | float bottom, float top, |
65 | float nearPlane, float farPlane); |
66 | |
67 | void setPerspectiveProjection(float fieldOfView, float aspect, |
68 | float nearPlane, float farPlane); |
69 | |
70 | float exposure() const; |
71 | |
72 | void viewAll(Qt3DCore::QNodeId cameraId); |
73 | void viewEntity(Qt3DCore::QNodeId entityId, Qt3DCore::QNodeId cameraId); |
74 | |
75 | public Q_SLOTS: |
76 | void setProjectionType(ProjectionType projectionType); |
77 | void setNearPlane(float nearPlane); |
78 | void setFarPlane(float farPlane); |
79 | void setFieldOfView(float fieldOfView); |
80 | void setAspectRatio(float aspectRatio); |
81 | void setLeft(float left); |
82 | void setRight(float right); |
83 | void setBottom(float bottom); |
84 | void setTop(float top); |
85 | void setProjectionMatrix(const QMatrix4x4 &projectionMatrix); |
86 | void setExposure(float exposure); |
87 | |
88 | Q_SIGNALS: |
89 | void projectionTypeChanged(QCameraLens::ProjectionType projectionType); |
90 | void nearPlaneChanged(float nearPlane); |
91 | void farPlaneChanged(float farPlane); |
92 | void fieldOfViewChanged(float fieldOfView); |
93 | void aspectRatioChanged(float aspectRatio); |
94 | void leftChanged(float left); |
95 | void rightChanged(float right); |
96 | void bottomChanged(float bottom); |
97 | void topChanged(float top); |
98 | void projectionMatrixChanged(const QMatrix4x4 &projectionMatrix); |
99 | void exposureChanged(float exposure); |
100 | void viewSphere(const QVector3D ¢er, float radius); |
101 | |
102 | protected: |
103 | explicit QCameraLens(QCameraLensPrivate &dd, QNode *parent = nullptr); |
104 | |
105 | private: |
106 | Q_DECLARE_PRIVATE(QCameraLens) |
107 | }; |
108 | |
109 | } // Qt3DRender |
110 | |
111 | QT_END_NAMESPACE |
112 | |
113 | #endif // QT3DRENDER_CAMERALENS_H |
114 | |