Monad Engine da02fba2
> Undercity Codex_
Loading...
Searching...
No Matches
CameraComponent.cpp
Go to the documentation of this file.
1#include "scene/components/CameraComponent.h"
2#include "scene/GameObject.h"
3#include <glm/gtc/matrix_transform.hpp>
4
5namespace eng
6{
7 void CameraComponent::Update(float deltaTime)
8 {
9 }
10
12 {
13 glm::mat4 mat = glm::mat4(1.0f);
14 mat = glm::mat4_cast(m_owner->GetRotation());
15
16 mat[3] = glm::vec4(m_owner->GetPosition(), 1.0f);
17
18 if (m_owner->GetParent())
19 {
20 mat = m_owner->GetParent()->GetWorldTransform() * mat;
21 }
22
23 return glm::inverse(mat);
24 }
25
26 glm::mat4 CameraComponent::GetProjectionMatrix(float aspect) const
27 {
28 return glm::perspective(glm::radians(m_fov), aspect, m_nearPlane, m_farPlane);
29 }
30}
glm::mat4 GetProjectionMatrix(float aspect) const
glm::mat4 GetViewMatrix() const
void Update(float deltaTime) override
GameObject * m_owner
Definition Component.h:33
const glm::quat & GetRotation() const
const glm::vec3 & GetPosition() const
GameObject * GetParent()
glm::mat4 GetWorldTransform() const