Class EditorCamera#

Inheritance Relationships#

Base Type#

Class Documentation#

class EditorCamera : public TRAP::Graphics::Camera#

Remark

Headless mode: This class is not available in headless mode.

Public Types

enum class CameraMode#

Camera modes.

Values:

enumerator FlyCam#
enumerator ArcBall#

Public Functions

constexpr EditorCamera(f32 fov, f32 aspectRatio, f32 nearClip)#

Constructor. Create a new camera from the given parameters.

Parameters:
  • fov – Field of view in degrees.

  • aspectRatio – Viewport aspect ratio.

  • nearClip – Near clip plane.

constexpr ~EditorCamera() override = default#

Destructor.

constexpr EditorCamera(const EditorCamera&) noexcept = default#

Copy constructor.

constexpr EditorCamera(EditorCamera&&) noexcept = default#

Move constructor.

constexpr EditorCamera &operator=(const EditorCamera&) noexcept = default#

Copy assignment operator.

Returns:

EditorCamera.

constexpr EditorCamera &operator=(EditorCamera&&) noexcept = default#

Move assignment operator.

Returns:

EditorCamera.

constexpr void Init()#

Initialize the camera.

constexpr void Focus(const TRAP::Math::Vec3 &focusPoint)#

Focus the camera onto the given point.

Parameters:

focusPoint – Point to focus on.

void OnUpdate(const Utils::TimeStep &deltaTime)#

Update the camera.

Parameters:

deltaTime – Current frames delta time.

void OnEvent(Events::Event &event)#

Handle camera events.

Parameters:

event – Triggered event.

constexpr bool IsActive() const noexcept#

Retrieve whether the camera is active or not.

Returns:

True if camera is active, false otherwise.

constexpr void SetActive(bool active) noexcept#

Set camera active or inactive.

Parameters:

active – Active or inactive.

constexpr CameraMode GetCurrentMode() const noexcept#

Retrieve the current mode of the camera.

Returns:

Current mode of the camera.

constexpr f32 GetDistance() const noexcept#

Retrieve the distance between the camera and the focal point.

Returns:

Distance.

constexpr void SetDistance(f32 distance) noexcept#

Set the distance between the camera and the focal point.

Parameters:

distance – Distance to set.

constexpr const TRAP::Math::Vec3 &GetFocalPoint() const noexcept#

Retrieve the current focal point of the camera.

Returns:

Current focal point.

constexpr void SetViewportSize(f32 width, f32 height)#

Set the viewport of the camera. This updates the projection matrix.

Parameters:
  • width – Viewport width.

  • height – Viewport height.

constexpr const TRAP::Math::Mat4 &GetViewMatrix() const noexcept#

Retrieve the view matrix.

Returns:

View matrix.

constexpr TRAP::Math::Vec3 GetUpDirection() const#

Retrieve the current up direction.

Returns:

Up direction.

constexpr TRAP::Math::Vec3 GetRightDirection() const#

Retrieve the current right direction.

Returns:

Right direction.

constexpr TRAP::Math::Vec3 GetForwardDirection() const#

Retrieve the current forward direction.

Returns:

Forward direction.

constexpr const TRAP::Math::Vec3 &GetPosition() const noexcept#

Retrieve the current camera position.

Returns:

Camera position.

constexpr TRAP::Math::Quat GetOrientation() const#

Retrieve the current camera orientation.

Returns:

Camera orientation.

constexpr f32 GetFOV() const noexcept#

Retrieve the current field of view in degrees.

Returns:

Field of view in degrees.

constexpr f32 GetAspectRatio() const noexcept#

Retrieve the current aspect ration.

Returns:

Aspect ratio.

constexpr f32 GetNearClip() const noexcept#

Retrieve the nera clip plane.

Returns:

Near clip plane.

constexpr f32 GetPitch() const noexcept#

Retrieve the camera pitch.

Returns:

Pitch.

constexpr f32 GetYaw() const noexcept#

Retrieve the camera yaw.

Returns:

Yaw.

f32 GetCameraSpeed() const#

Retrieve the current camera speed.

Returns:

Camera speed.

Friends

friend class ::TRAPEditorLayer