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_RENDER_CAMERALENS_H
5#define QT3DRENDER_RENDER_CAMERALENS_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 for the convenience
12// of other Qt classes. 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 <Qt3DRender/private/backendnode_p.h>
19#include <Qt3DCore/private/matrix4x4_p.h>
20#include <Qt3DRender/private/qcameralens_p.h>
21#include <QRectF>
22
23QT_BEGIN_NAMESPACE
24
25namespace Qt3DRender {
26
27namespace Render {
28
29class EntityManager;
30class CameraManager;
31class Sphere;
32
33class CameraLensFunctor : public Qt3DCore::QBackendNodeMapper
34{
35public:
36 explicit CameraLensFunctor(AbstractRenderer *renderer, QRenderAspect *renderAspect);
37 Qt3DCore::QBackendNode *create(Qt3DCore::QNodeId id) const override;
38 Qt3DCore::QBackendNode *get(Qt3DCore::QNodeId id) const override;
39 void destroy(Qt3DCore::QNodeId id) const override;
40
41private:
42 CameraManager *m_manager;
43 AbstractRenderer *m_renderer;
44 QRenderAspect *m_renderAspect;
45};
46
47class Q_3DRENDERSHARED_PRIVATE_EXPORT CameraLens : public BackendNode
48{
49public:
50 CameraLens();
51 ~CameraLens();
52 void cleanup();
53
54 void setRenderAspect(QRenderAspect* renderAspect);
55
56 Matrix4x4 viewMatrix(const Matrix4x4 &worldTransform);
57
58 void setProjection(const Matrix4x4 &projection);
59 inline Matrix4x4 projection() const { return m_projection; }
60
61 void setExposure(float exposure);
62 inline float exposure() const { return m_exposure; }
63 void syncFromFrontEnd(const Qt3DCore::QNode *frontEnd, bool firstTime) override;
64
65 void processViewAllResult(Qt3DCore::QAspectManager *aspectManager, const Sphere &sphere, Qt3DCore::QNodeId commandId);
66
67 static bool viewMatrixForCamera(EntityManager *manager, Qt3DCore::QNodeId cameraId,
68 Matrix4x4 &viewMatrix, Matrix4x4 &projectionMatrix);
69
70private:
71 void computeSceneBoundingVolume(Qt3DCore::QNodeId entityId,
72 Qt3DCore::QNodeId cameraId,
73 Qt3DCore::QNodeId requestId);
74
75 QRenderAspect *m_renderAspect;
76 CameraLensRequest m_pendingViewAllRequest;
77 Matrix4x4 m_projection;
78 float m_exposure;
79};
80
81} // namespace Render
82} // namespace Qt3DRender
83
84QT_END_NAMESPACE
85
86#endif // QT3DRENDER_RENDER_CAMERALENS_H
87

source code of qt3d/src/render/backend/cameralens_p.h