Monad Engine da02fba2
> Undercity Codex_
Loading...
Searching...
No Matches
mnd::CameraComponent Class Referenceabstract

Perspective camera — provides view and projection matrices each frame. More...

#include <CameraComponent.h>

+ Inheritance diagram for mnd::CameraComponent:
+ Collaboration diagram for mnd::CameraComponent:

Public Member Functions

void Update (f32 deltaTime) override
 No per-frame logic needed; view/projection are computed on demand.
 
mat4 GetViewMatrix () const
 Compute the view matrix from the owner's world transform.
 
mat4 GetProjectionMatrix (f32 aspect) const
 Compute the perspective projection matrix.
 
f32 GetFov () const
 
f32 GetNearPlane () const
 
f32 GetFarPlane () const
 
void SetFov (f32 fov)
 
void SetNearPlane (f32 n)
 
void SetFarPlane (f32 f)
 
virtual void LoadProperties (const nlohmann::json &json)
 
virtual void Init ()
 
virtual size_t GetTypeId () const =0
 
GameObjectGetOwner ()
 

Static Public Member Functions

template<typename T >
static size_t StaticTypeId ()
 

Protected Attributes

GameObjectm_owner = nullptr
 

Detailed Description

Perspective camera — provides view and projection matrices each frame.

Works in conjunction with the owning GameObject's transform:

  • Position and rotation of the owner define where the camera is and where it looks.
  • m_fov, m_nearPlane, m_farPlane define the viewing frustum.

Definition at line 33 of file CameraComponent.h.

Member Function Documentation

◆ GetFarPlane()

f32 mnd::CameraComponent::GetFarPlane ( ) const
inline

Definition at line 64 of file CameraComponent.h.

Referenced by mnd::InspectCamera().

◆ GetFov()

f32 mnd::CameraComponent::GetFov ( ) const
inline

Definition at line 60 of file CameraComponent.h.

Referenced by mnd::InspectCamera().

◆ GetNearPlane()

f32 mnd::CameraComponent::GetNearPlane ( ) const
inline

Definition at line 62 of file CameraComponent.h.

Referenced by mnd::InspectCamera().

◆ GetOwner()

GameObject * mnd::Component::GetOwner ( )
inherited

◆ GetProjectionMatrix()

mat4 mnd::CameraComponent::GetProjectionMatrix ( f32  aspect) const

Compute the perspective projection matrix.

Maps camera-space coordinates to clip space using glm::perspective.

Parameters
aspectWindow width / height (updated each frame by the engine).
Returns
Column-major 4×4 projection matrix.

Definition at line 26 of file CameraComponent.cpp.

◆ GetTypeId()

virtual size_t mnd::Component::GetTypeId ( ) const
pure virtualinherited

◆ GetViewMatrix()

mat4 mnd::CameraComponent::GetViewMatrix ( ) const

Compute the view matrix from the owner's world transform.

Equivalent to glm::inverse(owner->GetWorldTransform()). Converts world-space coordinates into camera-space (eye space).

Returns
Column-major 4×4 view matrix.

Definition at line 13 of file CameraComponent.cpp.

References mnd::GameObject::GetParent(), mnd::GameObject::GetPosition(), mnd::GameObject::GetRotation(), mnd::GameObject::GetWorldTransform(), and mnd::Component::m_owner.

◆ Init()

void mnd::Component::Init ( )
virtualinherited

Reimplemented in mnd::PhysicsComponent, and mnd::PlayerControllerComponent.

Definition at line 10 of file Component.cpp.

Referenced by mnd::GameObject::AddComponent().

◆ LoadProperties()

void mnd::Component::LoadProperties ( const nlohmann::json &  json)
virtualinherited

◆ SetFarPlane()

void mnd::CameraComponent::SetFarPlane ( f32  f)
inline

Definition at line 70 of file CameraComponent.h.

Referenced by mnd::InspectCamera().

◆ SetFov()

void mnd::CameraComponent::SetFov ( f32  fov)
inline

Definition at line 66 of file CameraComponent.h.

Referenced by mnd::InspectCamera().

◆ SetNearPlane()

void mnd::CameraComponent::SetNearPlane ( f32  n)
inline

Definition at line 68 of file CameraComponent.h.

Referenced by mnd::InspectCamera().

◆ StaticTypeId()

template<typename T >
static size_t mnd::Component::StaticTypeId ( )
inlinestaticinherited

Definition at line 50 of file Component.h.

◆ Update()

void mnd::CameraComponent::Update ( f32  deltaTime)
overridevirtual

No per-frame logic needed; view/projection are computed on demand.

Implements mnd::Component.

Definition at line 11 of file CameraComponent.cpp.

Member Data Documentation

◆ m_owner


The documentation for this class was generated from the following files: