blob: 0e926f674dbe98dc49e069d4fb7e2324ea0af1ed (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
|
// Copyright (C) 2019 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#ifndef QSSGCAMERA_H
#define QSSGCAMERA_H
//
// W A R N I N G
// -------------
//
// This file is not part of the Qt API. It exists purely as an
// implementation detail. This header file may change from version to
// version without notice, or even be removed.
//
// We mean it.
//
#include <QtQuick3D/private/qquick3dnode_p.h>
QT_BEGIN_NAMESPACE
class QSSGRenderCamera;
class Q_QUICK3D_EXPORT QQuick3DCamera : public QQuick3DNode
{
Q_OBJECT
Q_PROPERTY(bool frustumCullingEnabled READ frustumCullingEnabled WRITE setFrustumCullingEnabled NOTIFY frustumCullingEnabledChanged)
Q_PROPERTY(QQuick3DNode *lookAtNode READ lookAtNode WRITE setLookAtNode NOTIFY lookAtNodeChanged REVISION(6, 4))
Q_PROPERTY(float levelOfDetailBias READ levelOfDetailBias WRITE setLevelOfDetailBias NOTIFY levelOfDetailBiasChanged REVISION(6, 5))
QML_NAMED_ELEMENT(Camera)
QML_UNCREATABLE("Camera is Abstract")
public:
Q_INVOKABLE QVector3D mapToViewport(const QVector3D &scenePos) const;
Q_INVOKABLE QVector3D mapFromViewport(const QVector3D &viewportPos) const;
QVector3D mapToViewport(const QVector3D &scenePos,
qreal width,
qreal height);
QVector3D mapFromViewport(const QVector3D &viewportPos,
qreal width,
qreal height);
Q_INVOKABLE void lookAt(const QVector3D &scenePos);
Q_INVOKABLE void lookAt(QQuick3DNode *node);
// It will be used only after the scene was drawn.
// It means that the spatialNode of this camera already was created.
void updateGlobalVariables(const QRectF &inViewport);
bool frustumCullingEnabled() const;
QQuick3DNode *lookAtNode() const;
Q_REVISION(6, 5) float levelOfDetailBias() const;
public Q_SLOTS:
void setFrustumCullingEnabled(bool frustumCullingEnabled);
void setLookAtNode(QQuick3DNode *node);
Q_REVISION(6, 5) void setLevelOfDetailBias(float newLevelOFDetailBias);
Q_SIGNALS:
void frustumCullingEnabledChanged();
Q_REVISION(6, 4) void lookAtNodeChanged();
Q_REVISION(6, 5) void levelOfDetailBiasChanged();
protected:
explicit QQuick3DCamera(QQuick3DNodePrivate &dd, QQuick3DNode *parent = nullptr);
QSSGRenderGraphObject *updateSpatialNode(QSSGRenderGraphObject *node) override;
private Q_SLOTS:
void updateLookAt();
private:
bool m_frustumCullingEnabled = false;
QQuick3DNode *m_lookAtNode = nullptr;
float m_levelOfDetailBias = 1.0f;
};
QT_END_NAMESPACE
#endif // QSSGCAMERA_H
|