Sparkle 0.0.1
Loading...
Searching...
No Matches
spk_camera.hpp
1#pragma once
2
3#include "structure/design_pattern/spk_contract_provider.hpp"
4#include "structure/math/spk_matrix.hpp"
5#include "structure/math/spk_vector2.hpp"
6#include "structure/math/spk_vector3.hpp"
7#include "structure/math/spk_vector4.hpp"
8
9namespace spk
10{
15 class Camera
16 {
17 private:
18 spk::Matrix4x4 _projectionMatrix = spk::Matrix4x4::identity();
19 spk::Matrix4x4 _inverseProjectionMatrix = spk::Matrix4x4::identity();
20
21 spk::ContractProvider _onProjectionEditionContractProvider;
22
23 public:
27 Camera();
28
36 void setPerspective(float p_fovDegrees, float p_aspectRatio, float p_nearPlane = 0.1f, float p_farPlane = 1000.0f);
46 void setOrthographic(float p_left, float p_right, float p_bottom, float p_top, float p_nearPlane = 0.1f, float p_farPlane = 1000.0f);
47
52 const spk::Matrix4x4 &projectionMatrix() const;
57 const spk::Matrix4x4 &inverseProjectionMatrix() const;
58
64 spk::Vector3 convertScreenToCamera(const spk::Vector3 &p_screenPosition) const;
70 spk::Vector3 convertScreenToCamera(const spk::Vector2 &p_screenPosition) const;
71
77 spk::ContractProvider::Contract subscribeToProjectionEdition(const spk::ContractProvider::Job &p_job);
78 };
79}
void setPerspective(float p_fovDegrees, float p_aspectRatio, float p_nearPlane=0.1f, float p_farPlane=1000.0f)
Sets a perspective projection.
Definition spk_camera.cpp:10
const spk::Matrix4x4 & projectionMatrix() const
Returns the projection matrix.
Definition spk_camera.cpp:26
Camera()
Builds a camera with an identity projection.
Definition spk_camera.cpp:5
const spk::Matrix4x4 & inverseProjectionMatrix() const
Returns the inverse projection matrix.
Definition spk_camera.cpp:31
spk::Vector3 convertScreenToCamera(const spk::Vector3 &p_screenPosition) const
Converts a screen position to camera space.
Definition spk_camera.cpp:36
spk::ContractProvider::Contract subscribeToProjectionEdition(const spk::ContractProvider::Job &p_job)
Subscribes to projection changes.
Definition spk_camera.cpp:47
void setOrthographic(float p_left, float p_right, float p_bottom, float p_top, float p_nearPlane=0.1f, float p_farPlane=1000.0f)
Sets an orthographic projection.
Definition spk_camera.cpp:18
static spk::IMatrix< SizeX, SizeY > identity()
Definition spk_matrix.hpp:139
typename Contract::Job Job
Definition spk_contract_provider.hpp:267