|
1 /**************************************************************************** |
|
2 ** |
|
3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). |
|
4 ** All rights reserved. |
|
5 ** Contact: Nokia Corporation (qt-info@nokia.com) |
|
6 ** |
|
7 ** This file is part of the Qt3D module of the Qt Toolkit. |
|
8 ** |
|
9 ** $QT_BEGIN_LICENSE:LGPL$ |
|
10 ** No Commercial Usage |
|
11 ** This file contains pre-release code and may not be distributed. |
|
12 ** You may use this file in accordance with the terms and conditions |
|
13 ** contained in the Technology Preview License Agreement accompanying |
|
14 ** this package. |
|
15 ** |
|
16 ** GNU Lesser General Public License Usage |
|
17 ** Alternatively, this file may be used under the terms of the GNU Lesser |
|
18 ** General Public License version 2.1 as published by the Free Software |
|
19 ** Foundation and appearing in the file LICENSE.LGPL included in the |
|
20 ** packaging of this file. Please review the following information to |
|
21 ** ensure the GNU Lesser General Public License version 2.1 requirements |
|
22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. |
|
23 ** |
|
24 ** In addition, as a special exception, Nokia gives you certain additional |
|
25 ** rights. These rights are described in the Nokia Qt LGPL Exception |
|
26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. |
|
27 ** |
|
28 ** If you have questions regarding the use of this file, please contact |
|
29 ** Nokia at qt-info@nokia.com. |
|
30 ** |
|
31 ** |
|
32 ** |
|
33 ** |
|
34 ** |
|
35 ** |
|
36 ** |
|
37 ** |
|
38 ** $QT_END_LICENSE$ |
|
39 ** |
|
40 ****************************************************************************/ |
|
41 |
|
42 #ifndef CAMERA_H |
|
43 #define CAMERA_H |
|
44 |
|
45 #include <QtCore/qobject.h> |
|
46 #include <QtCore/qsize.h> |
|
47 #include <QtGui/qvector3d.h> |
|
48 #include <QtGui/qmatrix4x4.h> |
|
49 #include <QtGui/qquaternion.h> |
|
50 |
|
51 class CameraPrivate; |
|
52 class QGLPainter; |
|
53 |
|
54 class Camera : public QObject |
|
55 { |
|
56 Q_OBJECT |
|
57 Q_ENUMS(ProjectionType) |
|
58 Q_PROPERTY(ProjectionType projectionType READ projectionType WRITE setProjectionType NOTIFY projectionChanged) |
|
59 Q_PROPERTY(qreal fieldOfView READ fieldOfView WRITE setFieldOfView NOTIFY projectionChanged) |
|
60 Q_PROPERTY(qreal nearPlane READ nearPlane WRITE setNearPlane NOTIFY projectionChanged) |
|
61 Q_PROPERTY(qreal farPlane READ farPlane WRITE setFarPlane NOTIFY projectionChanged) |
|
62 Q_PROPERTY(QSizeF viewSize READ viewSize WRITE setViewSize NOTIFY projectionChanged) |
|
63 Q_PROPERTY(QSizeF minViewSize READ minViewSize WRITE setMinViewSize NOTIFY projectionChanged) |
|
64 Q_PROPERTY(int screenRotation READ screenRotation WRITE setScreenRotation NOTIFY projectionChanged) |
|
65 Q_PROPERTY(qreal xEye READ xEye WRITE setXEye NOTIFY viewChanged) |
|
66 Q_PROPERTY(qreal yEye READ yEye WRITE setYEye NOTIFY viewChanged) |
|
67 Q_PROPERTY(qreal zEye READ zEye WRITE setZEye NOTIFY viewChanged) |
|
68 Q_PROPERTY(QVector3D eye READ eye WRITE setEye NOTIFY viewChanged) |
|
69 Q_PROPERTY(QVector3D upVector READ upVector WRITE setUpVector NOTIFY viewChanged) |
|
70 Q_PROPERTY(qreal xCentre READ xCentre WRITE setXCentre NOTIFY viewChanged) |
|
71 Q_PROPERTY(qreal yCentre READ yCentre WRITE setYCentre NOTIFY viewChanged) |
|
72 Q_PROPERTY(qreal zCentre READ zCentre WRITE setZCentre NOTIFY viewChanged) |
|
73 Q_PROPERTY(QVector3D center READ center WRITE setCenter NOTIFY viewChanged) |
|
74 Q_PROPERTY(qreal eyeSeparation READ eyeSeparation WRITE setEyeSeparation NOTIFY viewChanged) |
|
75 Q_PROPERTY(QVector3D motionAdjustment READ motionAdjustment WRITE setMotionAdjustment DESIGNABLE false NOTIFY viewChanged) |
|
76 Q_PROPERTY(bool adjustForAspectRatio READ adjustForAspectRatio WRITE setAdjustForAspectRatio NOTIFY viewChanged) |
|
77 public: |
|
78 explicit Camera(QObject *parent = 0); |
|
79 ~Camera(); |
|
80 |
|
81 enum ProjectionType |
|
82 { |
|
83 Perspective, |
|
84 Orthographic |
|
85 }; |
|
86 |
|
87 Camera::ProjectionType projectionType() const; |
|
88 void setProjectionType(Camera::ProjectionType value); |
|
89 |
|
90 qreal fieldOfView() const; |
|
91 void setFieldOfView(qreal angle); |
|
92 |
|
93 qreal nearPlane() const; |
|
94 void setNearPlane(qreal value); |
|
95 |
|
96 qreal farPlane() const; |
|
97 void setFarPlane(qreal value); |
|
98 |
|
99 QSizeF viewSize() const; |
|
100 void setViewSize(const QSizeF& size); |
|
101 |
|
102 QSizeF minViewSize() const; |
|
103 void setMinViewSize(const QSizeF& size); |
|
104 |
|
105 int screenRotation() const; |
|
106 void setScreenRotation(int angle); |
|
107 |
|
108 qreal xEye() const; |
|
109 void setXEye(qreal value); |
|
110 qreal yEye() const; |
|
111 void setYEye(qreal value); |
|
112 qreal zEye() const; |
|
113 void setZEye(qreal value); |
|
114 |
|
115 QVector3D eye() const; |
|
116 void setEye(const QVector3D& vertex); |
|
117 |
|
118 QVector3D upVector() const; |
|
119 void setUpVector(const QVector3D& vector); |
|
120 |
|
121 qreal xCentre() const; |
|
122 void setXCentre(qreal value); |
|
123 qreal yCentre() const; |
|
124 void setYCentre(qreal value); |
|
125 qreal zCentre() const; |
|
126 void setZCentre(qreal value); |
|
127 |
|
128 QVector3D center() const; |
|
129 void setCenter(const QVector3D& vertex); |
|
130 |
|
131 qreal eyeSeparation() const; |
|
132 void setEyeSeparation(qreal value); |
|
133 |
|
134 QVector3D motionAdjustment() const; |
|
135 void setMotionAdjustment(const QVector3D& vector); |
|
136 |
|
137 bool adjustForAspectRatio() const; |
|
138 void setAdjustForAspectRatio(bool value); |
|
139 |
|
140 QQuaternion tilt(qreal angle) const; |
|
141 QQuaternion pan(qreal angle) const; |
|
142 QQuaternion roll(qreal angle) const; |
|
143 |
|
144 void rotateEye(const QQuaternion& q); |
|
145 void rotateCenter(const QQuaternion& q); |
|
146 |
|
147 QVector3D translation(qreal x, qreal y, qreal z) const; |
|
148 |
|
149 void translateEye(const QVector3D& vector); |
|
150 void translateCenter(const QVector3D& vector); |
|
151 |
|
152 QMatrix4x4 projectionMatrix(qreal aspectRatio) const; |
|
153 QMatrix4x4 modelViewMatrix() const; |
|
154 |
|
155 Q_SIGNALS: |
|
156 void projectionChanged(); |
|
157 void viewChanged(); |
|
158 |
|
159 private: |
|
160 CameraPrivate *d_ptr; |
|
161 |
|
162 CameraPrivate *d_func() const { return d_ptr; } |
|
163 |
|
164 Q_DISABLE_COPY(Camera) |
|
165 }; |
|
166 |
|
167 #endif |