Plasma Engine  2.0
Loading...
Searching...
No Matches
OrbitCameraContext.h
1#pragma once
2
3#include <EditorFramework/EditorFrameworkDLL.h>
4#include <EditorFramework/InputContexts/EditorInputContext.h>
5
6class plCamera;
7
9class PL_EDITORFRAMEWORK_DLL plOrbitCameraContext : public plEditorInputContext
10{
11public:
13
14 void SetCamera(plCamera* pCamera);
15 plCamera* GetCamera() const;
16
17 void SetDefaultCameraRelative(const plVec3& vDirection, float fDistanceScale);
18 void SetDefaultCameraFixed(const plVec3& vPosition);
19
20 void MoveCameraToDefaultPosition();
21
23 void SetOrbitVolume(const plVec3& vCenterPos, const plVec3& vHalfBoxSize);
24
26 plVec3 GetVolumeCenter() const { return m_Volume.GetCenter(); }
27
29 plVec3 GetVolumeHalfSize() const { return m_Volume.GetHalfExtents(); }
30
31protected:
32 virtual void DoFocusLost(bool bCancel) override;
33
34 virtual plEditorInput DoMousePressEvent(QMouseEvent* e) override;
35 virtual plEditorInput DoMouseReleaseEvent(QMouseEvent* e) override;
36 virtual plEditorInput DoMouseMoveEvent(QMouseEvent* e) override;
37 virtual plEditorInput DoWheelEvent(QWheelEvent* e) override;
38 virtual plEditorInput DoKeyPressEvent(QKeyEvent* e) override;
39 virtual plEditorInput DoKeyReleaseEvent(QKeyEvent* e) override;
40
41 virtual void OnSetOwner(plQtEngineDocumentWindow* pOwnerWindow, plQtEngineViewWidget* pOwnerView) override {}
42
43private:
44 virtual void UpdateContext() override;
45
46 float GetCameraSpeed() const;
47
48 void ResetCursor();
49 void SetCurrentMouseMode();
50
51 plVec2I32 m_vLastMousePos;
52
53 enum class Mode
54 {
55 Off,
56 Orbit,
57 Free,
58 Pan,
59 };
60
61 Mode m_Mode = Mode::Off;
62 plCamera* m_pCamera;
63
64 plBoundingBox m_Volume;
65
66 bool m_bFixedDefaultCamera = true;
67 plVec3 m_vDefaultCamera = plVec3(1, 0, 0);
68
69 bool m_bRun = false;
70 bool m_bMoveForwards = false;
71 bool m_bMoveBackwards = false;
72 bool m_bMoveRight = false;
73 bool m_bMoveLeft = false;
74 bool m_bMoveUp = false;
75 bool m_bMoveDown = false;
76
77 plTime m_LastUpdate;
78};
A camera class that stores the orientation and some basic camera settings.
Definition Camera.h:41
Definition EditorInputContext.h:22
A simple orbit camera. Use LMB to rotate, wheel to zoom, Alt to slow down.
Definition OrbitCameraContext.h:10
plVec3 GetVolumeCenter() const
The center point around which the camera can be moved and rotated.
Definition OrbitCameraContext.h:26
plVec3 GetVolumeHalfSize() const
The half-size of the volume in which the camera may move around.
Definition OrbitCameraContext.h:29
Base class for all document windows that need a connection to the engine process, and might want to r...
Definition EngineDocumentWindow.moc.h:37
Base class for views that show engine output.
Definition EngineViewWidget.moc.h:34
The time class encapsulates a double value storing the time in seconds.
Definition Time.h:12