generated from karl/cpp-template
27 lines
655 B
C++
27 lines
655 B
C++
#pragma once
|
|
|
|
#include <glm/glm.hpp>
|
|
#include <glm/gtc/matrix_transform.hpp>
|
|
#include <glm/gtx/dual_quaternion.hpp>
|
|
|
|
#include "Spatial.h"
|
|
|
|
class Camera : public Spatial {
|
|
public:
|
|
/// Create a camera with a field of view (in degrees), width and height (in any unit) and near
|
|
/// and far distances
|
|
Camera(float fov, float width, float height, float near, float far)
|
|
: projection(glm::perspective(glm::radians(fov), width / height, near, far)) {
|
|
}
|
|
|
|
glm::mat4 get_projection() {
|
|
return projection;
|
|
}
|
|
|
|
glm::mat4 get_view() {
|
|
return glm::inverse(get_matrix());
|
|
}
|
|
|
|
private:
|
|
glm::mat4 projection;
|
|
}; |