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
3#include "Engine.h"
4#include "GLFW/glfw3.h"
5#include "Types.h"
6#include "scene/GameObject.h"
7
8namespace mnd
9{
10
11void CameraComponent::Update(f32 deltaTime) {}
12
14{
15 mat4 mat = mat4(1.0F);
16 mat = mat4_cast(m_owner->GetRotation());
17 mat[3] = vec4(m_owner->GetPosition(), 1.0F);
18
19 if (m_owner->GetParent() != nullptr) {
20 mat = m_owner->GetParent()->GetWorldTransform() * mat;
21 }
22
23 return inverse(mat);
24}
25
27{
28 return perspective(radians(m_fov), aspect, m_nearPlane, m_farPlane);
29}
30
31} // namespace mnd
Engine-wide primitive type aliases and GLM math imports.
void Update(f32 deltaTime) override
No per-frame logic needed; view/projection are computed on demand.
mat4 GetProjectionMatrix(f32 aspect) const
Compute the perspective projection matrix.
mat4 GetViewMatrix() const
Compute the view matrix from the owner's world transform.
GameObject * m_owner
Definition Component.h:57
const vec3 & GetPosition() const
const quat & GetRotation() const
GameObject * GetParent()
Returns the parent node, or nullptr for root objects.
mat4 GetWorldTransform() const
Compute the world transform by walking up the parent chain.
glm::mat4 mat4
4×4 column-major float matrix (model/view/projection).
Definition Types.h:63
glm::vec4 vec4
4-component float vector (e.g. RGBA colour, homogeneous coords).
Definition Types.h:52
float f32
32-bit IEEE float — the standard GL scalar type.
Definition Types.h:40