VkCV Framework
0.0.1
CV Vulkan framework
|
Used for managing an arbitrary amount of camera controllers. More...
#include <CameraManager.hpp>
Public Member Functions | |
CameraManager (Window &window) | |
The constructor of the CameraManager. More... | |
~CameraManager () | |
The destructor of the CameraManager. Destroying the CameraManager leads to deletion of all stored camera objects and camera controller objects. | |
uint32_t | addCamera (ControllerType controllerType=ControllerType::NONE) |
Adds a new camera object to the CameraManager and binds it to a camera controller object of specified controllerType . More... | |
uint32_t | addCamera (ControllerType controllerType, const Camera &camera) |
Adds a new camera object to the CameraManager and binds it to a camera controller object of specified controllerType . More... | |
Camera & | getCamera (uint32_t cameraIndex) |
Gets the stored camera object located at cameraIndex . More... | |
Camera & | getActiveCamera () |
Gets the stored camera object set as the active camera. More... | |
void | setActiveCamera (uint32_t cameraIndex) |
Sets the stored camera object located at cameraIndex as the active camera. More... | |
uint32_t | getActiveCameraIndex () const |
Gets the index of the stored active camera object. More... | |
void | setControllerType (uint32_t cameraIndex, ControllerType controllerType) |
Binds a stored camera object located at cameraIndex to a camera controller of specified controllerType . More... | |
ControllerType | getControllerType (uint32_t cameraIndex) |
Gets the currently bound camera controller type of the stored camera object located at cameraIndex . More... | |
void | update (double deltaTime) |
Updates all stored camera controllers in respect to deltaTime . More... | |
Private Member Functions | |
void | bindCameraToEvents () |
Binds the camera object to the window event handles. | |
void | keyCallback (int key, int scancode, int action, int mods) |
A callback function for key events. Currently, cycling between all existing camera controllers via Tab, window closure via Esc and polling key events from the active camera controller are supported. More... | |
void | scrollCallback (double offsetX, double offsetY) |
A callback function for mouse scrolling events. More... | |
void | mouseMoveCallback (double x, double y) |
A callback function for mouse movement events. More... | |
void | mouseButtonCallback (int button, int action, int mods) |
A callback function for mouse button events. More... | |
void | resizeCallback (int width, int height) |
A callback function for handling the window resizing event. Each existing camera is resized in respect of the window size. More... | |
void | gamepadCallback (int gamepadIndex) |
A callback function for gamepad input events. Currently, inputs are handled only for the first connected gamepad! More... | |
CameraController & | getControllerByType (ControllerType controllerType) |
Gets a camera controller object of specified controllerType . More... | |
CameraController & | getActiveController () |
Private Attributes | |
event_handle< int, int, int, int > | m_keyHandle |
event_handle< double, double > | m_mouseMoveHandle |
event_handle< double, double > | m_mouseScrollHandle |
event_handle< int, int, int > | m_mouseButtonHandle |
event_handle< int, int > | m_resizeHandle |
event_handle< int > | m_gamepadHandle |
Window & | m_window |
std::vector< Camera > | m_cameras |
std::vector< ControllerType > | m_cameraControllerTypes |
uint32_t | m_activeCameraIndex |
PilotCameraController | m_pilotController |
TrackballCameraController | m_trackController |
double | m_lastX |
double | m_lastY |
double | m_inputDelayTimer |
double | m_frameTime |
Used for managing an arbitrary amount of camera controllers.
|
explicit |
The constructor of the CameraManager.
[in] | window | The window. |
References bindCameraToEvents(), vkcv::Window::getHeight(), and vkcv::Window::getWidth().
uint32_t vkcv::camera::CameraManager::addCamera | ( | ControllerType | controllerType, |
const Camera & | camera | ||
) |
Adds a new camera object to the CameraManager and binds it to a camera controller object of specified controllerType
.
[in] | controllerType | The type of the camera controller. |
[in] | camera | The new camera object. |
uint32_t vkcv::camera::CameraManager::addCamera | ( | ControllerType | controllerType = ControllerType::NONE | ) |
Adds a new camera object to the CameraManager and binds it to a camera controller object of specified controllerType
.
[in] | controllerType | The type of the camera controller. |
References vkcv::Window::getHeight(), vkcv::Window::getWidth(), and vkcv::camera::Camera::setPerspective().
|
private |
A callback function for gamepad input events. Currently, inputs are handled only for the first connected gamepad!
gamepadIndex | The gamepad index. |
References vkcv::camera::CameraController::gamepadCallback(), getActiveCamera(), and getActiveController().
Referenced by bindCameraToEvents().
Camera & vkcv::camera::CameraManager::getActiveCamera | ( | ) |
Gets the stored camera object set as the active camera.
References getActiveCameraIndex().
Referenced by gamepadCallback(), keyCallback(), mouseButtonCallback(), mouseMoveCallback(), scrollCallback(), and update().
uint32_t vkcv::camera::CameraManager::getActiveCameraIndex | ( | ) | const |
Gets the index of the stored active camera object.
Referenced by getActiveCamera(), and getActiveController().
|
private |
@briof A method to get the currently active controller for the active camera.
References getActiveCameraIndex(), getControllerByType(), and getControllerType().
Referenced by gamepadCallback(), keyCallback(), mouseButtonCallback(), mouseMoveCallback(), scrollCallback(), and update().
Camera & vkcv::camera::CameraManager::getCamera | ( | uint32_t | cameraIndex | ) |
Gets the stored camera object located at cameraIndex
.
[in] | cameraIndex | The camera index. |
cameraIndex
. std::runtime_error | If cameraIndex is not a valid camera index. |
Referenced by resizeCallback().
|
private |
Gets a camera controller object of specified controllerType
.
[in] | controllerType | The type of the camera controller. |
Referenced by getActiveController().
ControllerType vkcv::camera::CameraManager::getControllerType | ( | uint32_t | cameraIndex | ) |
Gets the currently bound camera controller type of the stored camera object located at cameraIndex
.
[in] | cameraIndex | The camera index. |
std::runtime_error | If cameraIndex is not a valid camera index. |
Referenced by getActiveController().
|
private |
A callback function for key events. Currently, cycling between all existing camera controllers via Tab, window closure via Esc and polling key events from the active camera controller are supported.
[in] | key | The keyboard key. |
[in] | scancode | The platform-specific scancode. |
[in] | action | The key action. |
[in] | mods | The modifier bits. |
References getActiveCamera(), getActiveController(), vkcv::Window::getWindow(), and vkcv::camera::CameraController::keyCallback().
Referenced by bindCameraToEvents().
|
private |
A callback function for mouse button events.
[in] | button | The mouse button. |
[in] | action | The button action. |
[in] | mods | The modifier bits. |
References getActiveCamera(), getActiveController(), vkcv::Window::getWindow(), and vkcv::camera::CameraController::mouseButtonCallback().
Referenced by bindCameraToEvents().
|
private |
A callback function for mouse movement events.
[in] | x | The horizontal mouse position. |
[in] | y | The vertical mouse position. |
References getActiveCamera(), getActiveController(), vkcv::Window::getHeight(), vkcv::Window::getWidth(), and vkcv::camera::CameraController::mouseMoveCallback().
Referenced by bindCameraToEvents().
|
private |
A callback function for handling the window resizing event. Each existing camera is resized in respect of the window size.
[in] | width | The new width of the window. |
[in] | height | The new height of the window. |
References getCamera(), vkcv::Window::getWindow(), and vkcv::camera::Camera::setRatio().
Referenced by bindCameraToEvents().
|
private |
A callback function for mouse scrolling events.
[in] | offsetX | The offset in horizontal direction. |
[in] | offsetY | The offset in vertical direction. |
References getActiveCamera(), getActiveController(), and vkcv::camera::CameraController::scrollCallback().
Referenced by bindCameraToEvents().
void vkcv::camera::CameraManager::setActiveCamera | ( | uint32_t | cameraIndex | ) |
Sets the stored camera object located at cameraIndex
as the active camera.
[in] | cameraIndex | The camera index. |
std::runtime_error | If cameraIndex is not a valid camera index. |
void vkcv::camera::CameraManager::setControllerType | ( | uint32_t | cameraIndex, |
ControllerType | controllerType | ||
) |
Binds a stored camera object located at cameraIndex
to a camera controller of specified controllerType
.
[in] | cameraIndex | The camera index. |
[in] | controllerType | The type of the camera controller. |
std::runtime_error | If cameraIndex is not a valid camera index. |
void vkcv::camera::CameraManager::update | ( | double | deltaTime | ) |
Updates all stored camera controllers in respect to deltaTime
.
[in] | deltaTime | The time that has passed since last update. |
References getActiveCamera(), getActiveController(), vkcv::Window::getWindow(), and vkcv::camera::CameraController::updateCamera().