Radium Engine  1.5.20
Loading...
Searching...
No Matches
CameraManipulator.hpp
1#pragma once
2#include <Gui/RaGui.hpp>
3
4#include <memory>
5
6#include <QKeyEvent>
7#include <QMouseEvent>
8#include <QObject>
9
10#include <Core/CoreMacros.hpp>
11#include <Core/Types.hpp>
12#include <Core/Utils/Log.hpp>
13
14#include <Core/Asset/Camera.hpp>
15#include <Engine/Scene/CameraComponent.hpp>
16#include <Gui/Utils/KeyMappingManager.hpp>
17
18namespace Ra {
19namespace Engine {
20namespace Scene {
21class Light;
22}
23
24} // namespace Engine
25
26namespace Gui {
27
29class RA_GUI_API CameraManipulator : public QObject
30{
31 Q_OBJECT
32
33 public:
36
40 explicit CameraManipulator( const CameraManipulator& other );
41
45 virtual ~CameraManipulator();
46
48 virtual KeyMappingManager::Context mappingContext();
49
51 virtual bool handleMousePressEvent( QMouseEvent* event,
52 const Qt::MouseButtons& buttons,
53 const Qt::KeyboardModifiers& modifiers,
54 int key );
56 virtual bool handleMouseReleaseEvent( QMouseEvent* event );
58 virtual bool handleMouseMoveEvent( QMouseEvent* event,
59 const Qt::MouseButtons& buttons,
60 const Qt::KeyboardModifiers& modifiers,
61 int key );
63 virtual bool handleWheelEvent( QWheelEvent* event,
64 const Qt::MouseButtons& buttons,
65 const Qt::KeyboardModifiers& modifiers,
66 int key );
67
69 virtual bool handleKeyPressEvent( QKeyEvent* event,
72 virtual bool handleKeyReleaseEvent( QKeyEvent* event,
74
76 const Core::Asset::Camera* getCamera() const { return m_camera; }
77
79 Core::Asset::Camera* getCamera() { return m_camera; }
80
83 virtual void updateCamera();
84
87 void attachLight( Engine::Scene::Light* light );
88
90 bool hasLightAttached() const { return m_light != nullptr; }
91
93 Engine::Scene::Light* getLight() { return m_light; }
94
95 public slots:
98 void setCameraSensitivity( Scalar sensitivity );
99 void setCameraFov( Scalar fov );
100 void setCameraFovInDegrees( Scalar fov );
101 void setCameraZNear( Scalar zNear );
102 void setCameraZFar( Scalar zFar );
104
106 void mapCameraBehaviourToAabb( const Core::Aabb& aabb );
107
109 void unmapCameraBehaviourToAabb();
110
112 virtual void fitScene( const Core::Aabb& aabb ) = 0;
113
115 virtual void setCameraPosition( const Core::Vector3& position ) = 0;
116
118 virtual void setCameraTarget( const Core::Vector3& target ) = 0;
119
121 virtual void resetCamera() = 0;
122
123 signals:
124
125 protected:
126 std::pair<Scalar, Scalar> computeDeltaMouseMove( const QMouseEvent* mouseEvent ) {
127 return { ( mouseEvent->pos().x() - m_lastMouseX ) / m_camera->getWidth(),
128 ( mouseEvent->pos().y() - m_lastMouseY ) / m_camera->getHeight() };
129 }
130
132 Scalar m_lastMouseX { 0_ra };
133
135 Scalar m_lastMouseY { 0_ra };
136
138 Scalar m_cameraSensitivity { 1_ra };
140 Scalar m_quickCameraModifier { 1_ra };
142 Scalar m_wheelSpeedModifier { 0.02_ra };
143
144 Core::Aabb m_targetedAabb;
145 Scalar m_targetedAabbVolume { 0_ra };
146 bool m_mapCameraBahaviourToAabb { false };
147
151 Core::Vector3 m_target { 0_ra, 0_ra, 0_ra };
152
153 Core::Asset::Camera* m_camera { nullptr };
154 Engine::Scene::Light* m_light { nullptr };
155};
156
157} // namespace Gui
158} // namespace Ra
Camera class storing the Camera frame and the projection properties The view direction is -z in camer...
Definition Camera.hpp:16
The CameraManipulator class is the generic class for camera manipulators.
const Core::Asset::Camera * getCamera() const
Pointer access to the camera.
Engine::Scene::Light * getLight()
pointer acces to the attached light if it exists, returns nullptr otherwise.
Core::Aabb m_targetedAabb
Camera behavior restriction AABB.
virtual void resetCamera()=0
Reset the Camera settings to default values.
virtual void setCameraTarget(const Core::Vector3 &target)=0
Set the Camera target to target.
Core::Asset::Camera * getCamera()
Pointer access to the camera.
virtual void fitScene(const Core::Aabb &aabb)=0
Setup the Camera according to the AABB of the scene to render.
virtual void setCameraPosition(const Core::Vector3 &position)=0
Set the Camera position to position.
Ra::Core::Utils::Index KeyMappingAction
handle to an action
Ra::Core::Utils::Index Context
handle to a Context
hepler function to manage enum as underlying types in VariableSet
Definition Cage.cpp:3