Rendu
A lightweight rendering engine for experimentations
Loading...
Searching...
No Matches
ControllableCamera.hpp
1#pragma once
2
3#include "input/Camera.hpp"
4#include "Common.hpp"
5
10class ControllableCamera final : public Camera {
11
12public:
14 enum class Mode : uint {
15 FPS = 0,
16 TurnTable,
17 //Trackball, ///< Currently not supported.
18 Joystick
19 };
20
23
29 void pose(const glm::vec3 & position, const glm::vec3 & center, const glm::vec3 & up) override;
30
32 void reset();
33
35 void update();
36
40 void physics(double frameTime);
41
45 float & speed() { return _speed; }
46
48 void interface();
49
50private:
54 void updateUsingJoystick(double frameTime);
55
59 void updateUsingKeyboard(double frameTime);
60
64 void updateUsingTurnTable(double frameTime);
65
66 float _speed = 1.2f;
67 float _angularSpeed = 4.0f;
68
69 // Camera additional state.
70 glm::vec2 _angles = glm::vec2(glm::half_pi<float>(), 0.0f);
71 float _radius = 1.0f;
72
73 Mode _mode = Mode::TurnTable;
74
75 float _guiFOV;
76};
This class represents a camera as used in real-time rendering APIs. It provides a view and projection...
Definition: Camera.hpp:11
const glm::vec3 & up() const
Definition: Camera.hpp:90
const glm::vec3 & center() const
Definition: Camera.hpp:96
const glm::vec3 & position() const
Definition: Camera.hpp:84
This camera can be controlled through the inputs received from the user.
Definition: ControllableCamera.hpp:10
void physics(double frameTime)
Definition: ControllableCamera.cpp:53
void reset()
Reset the position of the camera.
Definition: ControllableCamera.cpp:8
void updateUsingJoystick(double frameTime)
Definition: ControllableCamera.cpp:66
float _guiFOV
Field of view in degrees for the GUI.
Definition: ControllableCamera.hpp:75
void pose(const glm::vec3 &position, const glm::vec3 &center, const glm::vec3 &up) override
Definition: ControllableCamera.cpp:19
ControllableCamera()
Constructor.
Definition: ControllableCamera.cpp:4
glm::vec2 _angles
Orientation angles.
Definition: ControllableCamera.hpp:70
void updateUsingKeyboard(double frameTime)
Definition: ControllableCamera.cpp:146
void interface()
Definition: ControllableCamera.cpp:263
float & speed()
Definition: ControllableCamera.hpp:45
Mode
The interaction mode of the controllable camera.
Definition: ControllableCamera.hpp:14
void update()
Update once-per-frame parameters.
Definition: ControllableCamera.cpp:29
float _speed
Camera speed.
Definition: ControllableCamera.hpp:66
void updateUsingTurnTable(double frameTime)
Definition: ControllableCamera.cpp:201
Mode _mode
The current interaction mode.
Definition: ControllableCamera.hpp:73
float _angularSpeed
Camera angular speed.
Definition: ControllableCamera.hpp:67
float _radius
Turntable radius.
Definition: ControllableCamera.hpp:71