Radium Engine  1.5.20
Loading...
Searching...
No Matches
CameraManipulator.cpp
1#include <Gui/Viewer/CameraManipulator.hpp>
2
3#include <Core/Math/Math.hpp>
4#include <Engine/Scene/CameraManager.hpp>
5#include <Engine/Scene/Light.hpp>
6
7#include <Core/Asset/Camera.hpp>
8#include <Gui/Viewer/Viewer.hpp>
9
10namespace Ra {
11namespace Gui {
12using namespace Core::Utils; // log
13
15 QObject(),
16 m_cameraSensitivity( other.m_cameraSensitivity ),
17 m_quickCameraModifier( other.m_quickCameraModifier ),
18 m_wheelSpeedModifier( other.m_wheelSpeedModifier ),
19 m_targetedAabbVolume( other.m_targetedAabbVolume ),
20 m_mapCameraBahaviourToAabb( other.m_mapCameraBahaviourToAabb ),
21 m_target( other.m_target ),
22 m_camera( other.m_camera ),
23 m_light( other.m_light ) {}
24
26
27 auto cameraManager = static_cast<Ra::Engine::Scene::CameraManager*>(
28 Engine::RadiumEngine::getInstance()->getSystem( "DefaultCameraManager" ) );
29 m_camera = cameraManager->getActiveCamera();
30}
31
33
34void CameraManipulator::setCameraSensitivity( Scalar sensitivity ) {
35 m_cameraSensitivity = sensitivity;
36}
37
38void CameraManipulator::setCameraFov( Scalar fov ) {
39 m_camera->setFOV( fov );
40}
41
42void CameraManipulator::setCameraFovInDegrees( Scalar fov ) {
43 m_camera->setFOV( fov * Core::Math::toRad );
44}
45
46void CameraManipulator::setCameraZNear( Scalar zNear ) {
47 m_camera->setZNear( zNear );
48}
49
50void CameraManipulator::setCameraZFar( Scalar zFar ) {
51 m_camera->setZFar( zFar );
52}
53
55
56void CameraManipulator::mapCameraBehaviourToAabb( const Core::Aabb& aabb ) {
57 m_targetedAabb = aabb;
58 m_targetedAabbVolume = aabb.volume();
60}
61
65
70
74
76 const Qt::MouseButtons&,
77 const Qt::KeyboardModifiers&,
78 int ) {
79 return false;
80}
81
83 return false;
84}
85
87 const Qt::MouseButtons&,
88 const Qt::KeyboardModifiers&,
89 int ) {
90 return false;
91}
92
94 const Qt::MouseButtons&,
95 const Qt::KeyboardModifiers&,
96 int ) {
97 return false;
98}
99
102 return false;
103}
104
107 return false;
108}
109
110} // namespace Gui
111} // namespace Ra
void setZNear(Scalar zNear)
Set the Z Near plane distance to zNear.
Definition Camera.hpp:288
void setZFar(Scalar zFar)
Set the Z Far plane distance to zFar.
Definition Camera.hpp:297
void setFOV(Scalar fov)
Definition Camera.hpp:276
Core::Vector3 getDirection() const
Return the direction the camera is looking at.
Definition Camera.hpp:254
virtual void setDirection(const Eigen::Matrix< Scalar, 3, 1 > &)
Definition Light.hpp:67
The CameraManipulator class is the generic class for camera manipulators.
Core::Aabb m_targetedAabb
Camera behavior restriction AABB.
virtual bool handleMousePressEvent(QMouseEvent *event, const Qt::MouseButtons &buttons, const Qt::KeyboardModifiers &modifiers, int key)
virtual bool handleKeyReleaseEvent(QKeyEvent *event, const KeyMappingManager::KeyMappingAction &action)
bool m_mapCameraBahaviourToAabb
whether the camera is restrained or not
Core::Asset::Camera * m_camera
The Camera.
Scalar m_targetedAabbVolume
Volume of the m_targetedAabb.
virtual KeyMappingManager::Context mappingContext()
virtual bool handleWheelEvent(QWheelEvent *event, const Qt::MouseButtons &buttons, const Qt::KeyboardModifiers &modifiers, int key)
virtual bool handleMouseReleaseEvent(QMouseEvent *event)
void mapCameraBehaviourToAabb(const Core::Aabb &aabb)
Set the AABB to restrain the camera behavior against.
virtual bool handleMouseMoveEvent(QMouseEvent *event, const Qt::MouseButtons &buttons, const Qt::KeyboardModifiers &modifiers, int key)
virtual bool handleKeyPressEvent(QKeyEvent *event, const KeyMappingManager::KeyMappingAction &action)
void unmapCameraBehaviourToAabb()
Free the camera from AABB restriction.
Engine::Scene::Light * m_light
The light attached to the Camera.
CameraManipulator()
Initializes a manipulator for a given viewport size.
Scalar m_cameraSensitivity
the Camera sensitivity to manipulation.
void attachLight(Engine::Scene::Light *light)
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