|
Vulkan Schnee 0.0.1 (22840dc8)
High-performance rendering engine
|
A camera component that provides view and projection matrices based on its SceneNode transform. Use setActive() to mark this camera as the active camera for rendering. More...
#include <CameraComponent.h>
Public Member Functions | |
| Camera (Entities::Scene *owningScene, std::shared_ptr< Entities::SceneNode > sceneNode, float fov=60.0f, float nearPlane=0.01f, float farPlane=1000.0f) | |
| Constructs a camera component with default parameters. | |
| ~Camera () override=default | |
| Destroys the camera component. | |
| void | beginPlay () override |
| Called when the component is added to the scene or the game starts. | |
| void | tick (double deltaTime) override |
| Called every frame if ticking is enabled. | |
| void | endPlay () override |
| Called when the component is removed or the game ends. | |
| bool | drawImGui () override |
| Draws component-specific ImGui inspector controls. | |
| void | setActive (bool active) |
| Sets this camera as the active camera for rendering. | |
| bool | isActive () const |
| Checks if this camera is currently the active camera. | |
| virtual glm::mat4 | getViewMatrix () const |
| Gets the view matrix computed from the camera's world transform. | |
| virtual glm::mat4 | getProjectionMatrix () const |
| Gets the projection matrix based on FOV, aspect ratio, and clipping planes. | |
| virtual glm::mat4 | getEyeViewMatrix (size_t eyeIndex) const |
| Gets the view matrix for a specific eye. Base returns getViewMatrix() for both (mono). | |
| virtual glm::mat4 | getEyeProjectionMatrix (size_t eyeIndex) const |
| Gets the projection matrix for a specific eye. Base returns getProjectionMatrix() for both (mono). | |
| glm::mat4 | getViewProjectionMatrix () const |
| Gets the combined view-projection matrix. | |
| void | setFov (float fov) |
| Sets the vertical field of view. | |
| float | getFov () const |
| Gets the vertical field of view. | |
| void | setAspectRatio (float aspectRatio) |
| Sets the aspect ratio (width / height) | |
| float | getAspectRatio () const |
| Gets the aspect ratio. | |
| void | setNearPlane (float nearPlane) |
| Sets the near clipping plane distance. | |
| float | getNearPlane () const |
| Gets the near clipping plane distance. | |
| void | setFarPlane (float farPlane) |
| Sets the far clipping plane distance. | |
| float | getFarPlane () const |
| Gets the far clipping plane distance. | |
| glm::vec3 | getWorldPosition () const |
| Gets the camera's world position from its scene node. | |
| glm::vec3 | getForwardVector () const |
| Gets the forward direction vector of the camera. | |
| glm::vec3 | getRightVector () const |
| Gets the right direction vector of the camera. | |
| glm::vec3 | getUpVector () const |
| Gets the up direction vector of the camera. | |
| std::shared_ptr< Entities::SceneNode > | getSceneNode () const |
| Gets the scene node associated with this camera. | |
| Public Member Functions inherited from Engine::Components::Logic | |
| Logic (Entities::Scene *owningScene) | |
| Constructs a logic component owned by a scene. | |
| Logic (const Entities::SpawnContext &context) | |
| Constructs a logic component from spawn context data. | |
| virtual | ~Logic ()=default |
| Destroys the logic component. | |
| virtual std::string | getComponentName () const |
| Gets the component type name for debugging/UI. | |
| virtual bool | drawImGuiName () |
| Used to alter the name of the entity in the outliner. | |
| bool | hasBegunPlay () const |
| Checks whether beginPlay() has been called without a matching endPlay(). | |
| bool | canTick () const |
| Checks if the component is currently set to tick. | |
| void | setCanTick (bool enable) |
| Enables or disables ticking for this component. | |
| Entities::Entity * | getOwningEntity () const |
| Gets the entity this component belongs to. | |
Static Public Attributes | |
| static constexpr bool | IsUnique = true |
| Only one camera component is allowed per entity. | |
| static constexpr const char * | ComponentName = "Camera" |
| Component registry name. | |
| Static Public Attributes inherited from Engine::Components::Logic | |
| static constexpr bool | IsUnique = false |
| Defines whether multiple instances of this component can exist on the same entity. Defaults to false (multiple allowed). Override in derived classes with static constexpr bool IsUnique =
true; if needed. | |
| static constexpr const char * | ComponentName = "Logic" |
| Fallback component type name. Derived classes may override getComponentName() for custom labels. | |
Private Member Functions | |
| void | updateProjectionMatrix () |
Private Attributes | |
| std::shared_ptr< Entities::SceneNode > | sceneNode_ |
| entt::entity | cameraEntity_ = entt::null |
| float | fov_ |
| float | nearPlane_ |
| float | farPlane_ |
| float | aspectRatio_ = 16.0f / 9.0f |
| glm::mat4 | cachedProjectionMatrix_ {1.0f} |
| bool | projectionDirty_ = true |
Additional Inherited Members | |
| Protected Member Functions inherited from Engine::Components::Logic | |
| Entities::Scene * | getScene () const |
| Gets the scene this component belongs to. | |
| Core::SceneManager * | getSceneManager () const |
| Helper to get the SceneManager from the owning scene. | |
A camera component that provides view and projection matrices based on its SceneNode transform. Use setActive() to mark this camera as the active camera for rendering.
Definition at line 13 of file CameraComponent.h.
| Engine::Components::Camera::Camera | ( | Entities::Scene * | owningScene, |
| std::shared_ptr< Entities::SceneNode > | sceneNode, | ||
| float | fov = 60.0f, | ||
| float | nearPlane = 0.01f, | ||
| float | farPlane = 1000.0f ) |
Constructs a camera component with default parameters.
| owningScene | The scene this component belongs to |
| sceneNode | The scene node providing the camera's transform |
| fov | Vertical field of view in degrees (default: 60) |
| nearPlane | Near clipping plane distance (default: 0.01) |
| farPlane | Far clipping plane distance (default: 1000) |
|
overridedefault |
Destroys the camera component.
|
overridevirtual |
Called when the component is added to the scene or the game starts.
Reimplemented from Engine::Components::Logic.
|
overridevirtual |
Draws component-specific ImGui inspector controls.
Reimplemented from Engine::Components::Logic.
|
overridevirtual |
Called when the component is removed or the game ends.
Reimplemented from Engine::Components::Logic.
|
inlinenodiscard |
Gets the aspect ratio.
Definition at line 107 of file CameraComponent.h.
References aspectRatio_.
|
nodiscardvirtual |
Gets the projection matrix for a specific eye. Base returns getProjectionMatrix() for both (mono).
| eyeIndex | 0 = left eye, 1 = right eye |
Reimplemented in Engine::Components::VrCamera.
|
nodiscardvirtual |
Gets the view matrix for a specific eye. Base returns getViewMatrix() for both (mono).
| eyeIndex | 0 = left eye, 1 = right eye |
Reimplemented in Engine::Components::VrCamera.
|
inlinenodiscard |
Gets the far clipping plane distance.
Definition at line 131 of file CameraComponent.h.
References farPlane_.
|
nodiscard |
Gets the forward direction vector of the camera.
|
inlinenodiscard |
Gets the vertical field of view.
Definition at line 95 of file CameraComponent.h.
References fov_.
|
inlinenodiscard |
Gets the near clipping plane distance.
Definition at line 119 of file CameraComponent.h.
References nearPlane_.
|
nodiscardvirtual |
Gets the projection matrix based on FOV, aspect ratio, and clipping planes.
|
nodiscard |
Gets the right direction vector of the camera.
|
inlinenodiscard |
Gets the scene node associated with this camera.
Definition at line 161 of file CameraComponent.h.
References sceneNode_.
|
nodiscard |
Gets the up direction vector of the camera.
|
nodiscardvirtual |
Gets the view matrix computed from the camera's world transform.
|
nodiscard |
Gets the combined view-projection matrix.
|
nodiscard |
Gets the camera's world position from its scene node.
|
nodiscard |
Checks if this camera is currently the active camera.
| void Engine::Components::Camera::setActive | ( | bool | active | ) |
Sets this camera as the active camera for rendering.
| active | If true, this camera becomes the active camera (removing active tag from others) |
| void Engine::Components::Camera::setAspectRatio | ( | float | aspectRatio | ) |
Sets the aspect ratio (width / height)
| aspectRatio | New aspect ratio |
| void Engine::Components::Camera::setFarPlane | ( | float | farPlane | ) |
Sets the far clipping plane distance.
| farPlane | Far plane distance |
| void Engine::Components::Camera::setFov | ( | float | fov | ) |
Sets the vertical field of view.
| fov | Field of view in degrees |
| void Engine::Components::Camera::setNearPlane | ( | float | nearPlane | ) |
Sets the near clipping plane distance.
| nearPlane | Near plane distance |
|
overridevirtual |
Called every frame if ticking is enabled.
| deltaTime | Time elapsed since last frame. |
Reimplemented from Engine::Components::Logic.
Reimplemented in Engine::Components::VrCamera.
|
private |
|
private |
Definition at line 172 of file CameraComponent.h.
Referenced by getAspectRatio().
|
mutableprivate |
Definition at line 174 of file CameraComponent.h.
|
private |
Definition at line 167 of file CameraComponent.h.
|
staticconstexpr |
Component registry name.
Definition at line 16 of file CameraComponent.h.
|
private |
Definition at line 171 of file CameraComponent.h.
Referenced by getFarPlane().
|
private |
Definition at line 169 of file CameraComponent.h.
Referenced by getFov().
|
staticconstexpr |
Only one camera component is allowed per entity.
Definition at line 15 of file CameraComponent.h.
|
private |
Definition at line 170 of file CameraComponent.h.
Referenced by getNearPlane().
|
private |
Definition at line 175 of file CameraComponent.h.
|
private |
Definition at line 166 of file CameraComponent.h.
Referenced by getSceneNode().