Pyrogenesis HEAD
Pyrogenesis, a RTS Engine
CameraController.h
Go to the documentation of this file.
1/* Copyright (C) 2022 Wildfire Games.
2* This file is part of 0 A.D.
3*
4* 0 A.D. is free software: you can redistribute it and/or modify
5* it under the terms of the GNU General Public License as published by
6* the Free Software Foundation, either version 2 of the License, or
7* (at your option) any later version.
8*
9* 0 A.D. is distributed in the hope that it will be useful,
10* but WITHOUT ANY WARRANTY; without even the implied warranty of
11* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12* GNU General Public License for more details.
13*
14* You should have received a copy of the GNU General Public License
15* along with 0 A.D. If not, see <http://www.gnu.org/licenses/>.
16*/
17
18#ifndef INCLUDED_CAMERACONTROLLER
19#define INCLUDED_CAMERACONTROLLER
20
23
25{
27public:
30
31 void LoadConfig() override;
32
33 InReaction HandleEvent(const SDL_Event_* ev) override;
34
35 CVector3D GetCameraPivot() const override;
36 CVector3D GetCameraPosition() const override;
37 CVector3D GetCameraRotation() const override;
38 float GetCameraZoom() const override;
39
40 void SetCamera(const CVector3D& pos, float rotX, float rotY, float zoom) override;
41 void MoveCameraTarget(const CVector3D& target) override;
42 void ResetCameraTarget(const CVector3D& target) override;
43 void FollowEntity(entity_id_t entity, bool firstPerson) override;
45
46 void Update(const float deltaRealTime) override;
47 void SetViewport(const SViewPort& vp) override;
48
49 bool GetConstrainCamera() const override
50 {
51 return m_ConstrainCamera;
52 }
53
54 void SetConstrainCamera(bool constrain) override
55 {
56 m_ConstrainCamera = constrain;
57 }
58
59private:
60 CVector3D GetSmoothPivot(CCamera &camera) const;
62 void SetupCameraMatrixSmooth(CMatrix3D* orientation);
63 void SetupCameraMatrixSmoothRot(CMatrix3D* orientation);
64 void SetupCameraMatrixNonSmooth(CMatrix3D* orientation);
65 void FocusHeight(bool smooth);
66
67 /**
68 * Set projection of current camera using near, far, and FOV values
69 */
71
72 /**
73 * Whether the camera movement should be constrained by min/max limits
74 * and terrain avoidance.
75 */
77
78 /**
79 * Entity for the camera to follow, or INVALID_ENTITY if none.
80 */
82
83 /**
84 * Whether to follow FollowEntity in first-person mode.
85 */
87
88 // Settings
91 // How close the mouse pointer should be to a view edge to move the camera.
113
114 // Camera Controls State
119 CSmoothedValue m_RotateX; // inclination around x axis (relative to camera)
120 CSmoothedValue m_RotateY; // rotation around y (vertical) axis
121};
122
123#endif // INCLUDED_CAMERACONTROLLER
Definition: CameraController.h:25
CSmoothedValue m_RotateX
Definition: CameraController.h:119
float m_ViewZoomMax
Definition: CameraController.h:105
float m_ViewRotateYDefault
Definition: CameraController.h:99
float m_ViewRotateYSpeedWheel
Definition: CameraController.h:98
void SetupCameraMatrixSmooth(CMatrix3D *orientation)
Definition: CameraController.cpp:532
float m_ViewZoomDefault
Definition: CameraController.h:106
~CCameraController() override
entity_id_t m_FollowEntity
Entity for the camera to follow, or INVALID_ENTITY if none.
Definition: CameraController.h:81
float m_HeightSmoothness
Definition: CameraController.h:111
CVector3D GetSmoothPivot(CCamera &camera) const
Definition: CameraController.cpp:408
float m_ViewRotateYSpeed
Definition: CameraController.h:97
float m_ViewZoomMin
Definition: CameraController.h:104
void SetupCameraMatrixSmoothRot(CMatrix3D *orientation)
Definition: CameraController.cpp:540
CSmoothedValue m_PosY
Definition: CameraController.h:116
bool m_FollowFirstPerson
Whether to follow FollowEntity in first-person mode.
Definition: CameraController.h:86
float m_ViewRotateSpeedModifier
Definition: CameraController.h:100
CSmoothedValue m_RotateY
Definition: CameraController.h:120
void SetupCameraMatrixNonSmooth(CMatrix3D *orientation)
Definition: CameraController.cpp:548
CSmoothedValue m_Zoom
Definition: CameraController.h:118
CVector3D GetCameraPivot() const override
Definition: CameraController.cpp:413
void Update(const float deltaRealTime) override
Definition: CameraController.cpp:159
bool GetConstrainCamera() const override
Definition: CameraController.h:49
void ResetCameraAngleZoom()
Definition: CameraController.cpp:514
float m_ViewFar
Definition: CameraController.h:110
float m_ViewFOV
Definition: CameraController.h:108
bool m_ConstrainCamera
Whether the camera movement should be constrained by min/max limits and terrain avoidance.
Definition: CameraController.h:76
InReaction HandleEvent(const SDL_Event_ *ev) override
Definition: CameraController.cpp:616
CVector3D GetCameraRotation() const override
Definition: CameraController.cpp:423
float m_ViewScrollSpeed
Definition: CameraController.h:89
float m_ViewRotateXMin
Definition: CameraController.h:94
void MoveCameraTarget(const CVector3D &target) override
Definition: CameraController.cpp:452
void ResetCameraTarget(const CVector3D &target) override
Definition: CameraController.cpp:474
float m_ViewRotateXSpeed
Definition: CameraController.h:93
float m_ViewScrollSpeedModifier
Definition: CameraController.h:90
entity_id_t GetFollowedEntity() override
Definition: CameraController.cpp:504
CSmoothedValue m_PosZ
Definition: CameraController.h:117
CCameraController(CCamera &camera)
Definition: CameraController.cpp:52
int m_ViewScrollMouseDetectDistance
Definition: CameraController.h:92
NONCOPYABLE(CCameraController)
float m_ViewNear
Definition: CameraController.h:109
void SetConstrainCamera(bool constrain) override
Definition: CameraController.h:54
float m_ViewZoomSpeedWheel
Definition: CameraController.h:103
void SetCamera(const CVector3D &pos, float rotX, float rotY, float zoom) override
Definition: CameraController.cpp:434
CVector3D GetCameraPosition() const override
Definition: CameraController.cpp:418
void FocusHeight(bool smooth)
Definition: CameraController.cpp:556
void SetViewport(const SViewPort &vp) override
Definition: CameraController.cpp:153
float m_ViewRotateXDefault
Definition: CameraController.h:96
float m_ViewRotateXMax
Definition: CameraController.h:95
void FollowEntity(entity_id_t entity, bool firstPerson) override
Definition: CameraController.cpp:498
void LoadConfig() override
Definition: CameraController.cpp:104
float m_ViewZoomSpeedModifier
Definition: CameraController.h:107
void SetCameraProjection()
Set projection of current camera using near, far, and FOV values.
Definition: CameraController.cpp:509
float m_ViewZoomSpeed
Definition: CameraController.h:102
float GetCameraZoom() const override
Definition: CameraController.cpp:429
float m_ViewDragSpeed
Definition: CameraController.h:101
CSmoothedValue m_PosX
Definition: CameraController.h:115
float m_HeightMin
Definition: CameraController.h:112
Definition: Camera.h:42
Definition: Matrix3D.h:34
A value with exponential decay towards the target value.
Definition: SmoothedValue.h:27
Definition: Vector3D.h:31
camera controller interface.
Definition: ICameraController.h:34
InReaction
Definition: input.h:35
u32 entity_id_t
Entity ID type.
Definition: Entity.h:29
Definition: libsdl.h:53
Definition: Camera.h:34