76 Qt3DRender::QCamera *
camera()
const {
return mCamera; }
95 void setCameraMovementSpeed(
double movementSpeed );
110 void frameTriggered(
float dt );
113 void resetView(
float distance );
116 void setViewFromTop(
float worldX,
float worldY,
float distance,
float yaw = 0 );
127 void setLookingAtPoint(
const QgsVector3D &point,
float distance,
float pitch,
float yaw );
146 float distance()
const {
return mCameraPose.distanceFromCenterPoint(); }
153 float pitch()
const {
return mCameraPose.pitchAngle(); }
160 float yaw()
const {
return mCameraPose.headingAngle(); }
163 QDomElement writeXml( QDomDocument &doc )
const;
165 void readXml(
const QDomElement &elem );
168 void zoom(
float factor );
170 void tiltUpAroundViewCenter(
float deltaPitch );
172 void rotateAroundViewCenter(
float deltaYaw );
174 void setCameraHeadingAngle(
float angle );
176 void moveView(
float tx,
float ty );
182 void walkView(
double tx,
double ty,
double tz );
190 void rotateCamera(
float diffPitch,
float diffYaw );
197 bool willHandleKeyEvent( QKeyEvent *event );
219 void depthBufferCaptured(
const QImage &depthImage );
227 void updateCameraFromPose();
228 void moveCameraPositionBy(
const QVector3D &posDiff );
230 QWindow *window()
const;
233 enum class MouseOperation
246 const QList<MouseOperation> mTranslateOrRotate = {
247 MouseOperation::Translation,
248 MouseOperation::RotationCamera,
249 MouseOperation::RotationCenter
253 bool isATranslationRotationSequence( MouseOperation newOperation )
const;
255 void setMouseParameters(
const MouseOperation &newOperation,
const QPoint &clickPoint = QPoint() );
288 void onPositionChanged( Qt3DInput::QMouseEvent *mouse );
289 void onWheel( Qt3DInput::QWheelEvent *wheel );
290 void onMousePressed( Qt3DInput::QMouseEvent *mouse );
291 void onMouseReleased( Qt3DInput::QMouseEvent *mouse );
292 void onKeyPressed( Qt3DInput::QKeyEvent *event );
293 void onKeyReleased( Qt3DInput::QKeyEvent *event );
294 void applyFlyModeKeyMovements();
297 void onKeyPressedFlyNavigation( Qt3DInput::QKeyEvent *event );
298 void onKeyPressedTerrainNavigation( Qt3DInput::QKeyEvent *event );
299 void onPositionChangedFlyNavigation( Qt3DInput::QMouseEvent *mouse );
300 void onPositionChangedTerrainNavigation( Qt3DInput::QMouseEvent *mouse );
302 void handleTerrainNavigationWheelZoom();
308 double sampleDepthBuffer(
const QImage &buffer,
int px,
int py );
312 bool screenPointToWorldPos( QPoint position, Qt3DRender::QCamera *cameraBefore,
double &depth, QVector3D &worldPosition );
319 Qt3DRender::QCamera *mCamera =
nullptr;
330 bool mDepthBufferIsReady =
false;
331 QImage mDepthBufferImage;
333 std::unique_ptr<Qt3DRender::QCamera> mCameraBefore;
335 bool mRotationCenterCalculated =
false;
336 QVector3D mRotationCenter;
337 double mRotationDistanceFromCenter = 0;
338 double mRotationPitch = 0;
339 double mRotationYaw = 0;
341 bool mDragPointCalculated =
false;
342 QVector3D mDragPoint;
345 bool mZoomPointCalculated =
false;
346 QVector3D mZoomPoint;
348 Qt3DInput::QMouseHandler *mMouseHandler =
nullptr;
349 Qt3DInput::QKeyboardHandler *mKeyboardHandler =
nullptr;
352 double mCameraMovementSpeed = 5.0;
354 QSet<int> mDepressedKeys;
355 bool mCaptureFpsMouseMovements =
false;
356 bool mIgnoreNextMouseMove =
false;
357 QTimer *mFpsNavTimer =
nullptr;
359 double mCumulatedWheelY = 0;
361 MouseOperation mCurrentOperation = MouseOperation::None;
367 friend class TestQgs3DRendering;
368 friend class TestQgs3DCameraController;