vOOlkan
An object oriented approach to Vulkan
Camera.h
Go to the documentation of this file.
1#ifndef VULKAN_CAMERA
2#define VULKAN_CAMERA
3
4#include <glm/glm.hpp>
5#include <glm/gtx/quaternion.hpp>
6
7#include "Moveable.h"
8#include "Foundations.h"
9
10
11namespace Vulkan::Objects {
12
13
14 class Camera : public Physics::Moveable {
15 public:
16
17 Camera(glm::vec3 position, glm::vec3 rotationEuler) : Moveable{ position } {
18 setRotation(rotationEuler);
19 }
20
21
22 glm::mat4 getViewMatrix() const {
23 return glm::rotate(glm::mat4(1.0f), -getRotation().z, glm::vec3(0.0f, 0.0f, 1.0f)) *
24 glm::rotate(glm::mat4(1.0f), -getRotation().y, glm::vec3(1.0f, 0.0f, 0.0f)) *
25 glm::rotate(glm::mat4(1.0f), -getRotation().x, glm::vec3(0.0f, 1.0f, 0.0f)) *
26 glm::translate(glm::mat4(1.0f), glm::vec3(-getPosition()));
27 }
28
29 };
30
31}
32
33
34#endif
Definition: Camera.h:14
glm::mat4 getViewMatrix() const
Definition: Camera.h:22
Camera(glm::vec3 position, glm::vec3 rotationEuler)
Definition: Camera.h:17
A Movable object is an object which can be moved and rotated.
Definition: Moveable.h:16
virtual const glm::quat & getRotation() const
Definition: Moveable.h:43
virtual void setRotation(glm::quat rotation)
Definition: Moveable.h:58
virtual const Position & getPosition() const
Definition: Moveable.h:28
Moveable(Position position={ 0.0f, 0.0f, 0.0f }, glm::vec3 rotationEuler={ 0.0f, 0.0f, 0.0f })
Definition: Moveable.h:18
Definition: Camera.h:11