Vulkan Schnee 0.0.1
High-performance rendering engine
Loading...
Searching...
No Matches
Engine::Components::VrCamera Class Reference

Camera component driven by VR headset tracking. More...

#include <VrCameraComponent.h>

Inheritance diagram for Engine::Components::VrCamera:
Collaboration diagram for Engine::Components::VrCamera:

Public Member Functions

 VrCamera (Entities::Scene *owningScene, std::shared_ptr< Entities::SceneNode > sceneNode, Rendering::Headset *headset)
 ~VrCamera () override=default
void tick (double deltaTime) override
 Called every frame if ticking is enabled.
glm::mat4 getEyeViewMatrix (size_t eyeIndex) const override
 Gets the view matrix for a specific eye. Base returns getViewMatrix() for both (mono).
glm::mat4 getEyeProjectionMatrix (size_t eyeIndex) const override
 Gets the projection matrix for a specific eye. Base returns getProjectionMatrix() for both (mono).
Rendering::HeadsetgetHeadset () const
Public Member Functions inherited from 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.
 ~Camera () override=default
void beginPlay () override
 Called when the component is added to the scene or the game starts.
void endPlay () override
 Called when the component is removed or the game ends.
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.
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::SceneNodegetSceneNode () const
 Gets the scene node associated with this camera.
Public Member Functions inherited from Engine::Components::Logic
 Logic (Entities::Scene *owningScene)
virtual ~Logic ()=default
virtual std::string getComponentName () const
 Gets the component type name for debugging/UI.
bool hasBegunPlay () const
bool canTick () const
 Checks if the component is currently set to tick.
void setCanTick (bool enable)
 Enables or disables ticking for this component.
Entities::EntitygetOwningEntity () const
 Gets the entity this component belongs to.

Static Public Attributes

static constexpr bool IsUnique = true
static constexpr const char * ComponentName = "VrCamera"
Static Public Attributes inherited from Engine::Components::Camera
static constexpr bool IsUnique = true
static constexpr const char * ComponentName = "Camera"
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 Attributes

Rendering::Headsetheadset_ = nullptr

Additional Inherited Members

Protected Member Functions inherited from Engine::Components::Logic
Entities::ScenegetScene () const
 Gets the scene this component belongs to.
Core::SceneManagergetSceneManager () const
 Helper to get the SceneManager from the owning scene.

Detailed Description

Camera component driven by VR headset tracking.

Each frame, reads headset orientation from OpenXR and writes it to the SceneNode. Provides per-eye view and projection matrices that incorporate IPD offsets from the headset.

Locomotion (player world position) is handled externally — typically by VrMovementComponent writing to the same actor's SceneNode.

Definition at line 21 of file VrCameraComponent.h.

Constructor & Destructor Documentation

◆ VrCamera()

Engine::Components::VrCamera::VrCamera ( Entities::Scene * owningScene,
std::shared_ptr< Entities::SceneNode > sceneNode,
Rendering::Headset * headset )

◆ ~VrCamera()

Engine::Components::VrCamera::~VrCamera ( )
overridedefault

Member Function Documentation

◆ getEyeProjectionMatrix()

glm::mat4 Engine::Components::VrCamera::getEyeProjectionMatrix ( size_t eyeIndex) const
nodiscardoverridevirtual

Gets the projection matrix for a specific eye. Base returns getProjectionMatrix() for both (mono).

Parameters
eyeIndex0 = left eye, 1 = right eye

Reimplemented from Engine::Components::Camera.

◆ getEyeViewMatrix()

glm::mat4 Engine::Components::VrCamera::getEyeViewMatrix ( size_t eyeIndex) const
nodiscardoverridevirtual

Gets the view matrix for a specific eye. Base returns getViewMatrix() for both (mono).

Parameters
eyeIndex0 = left eye, 1 = right eye

Reimplemented from Engine::Components::Camera.

◆ getHeadset()

Rendering::Headset * Engine::Components::VrCamera::getHeadset ( ) const
inlinenodiscard

Definition at line 37 of file VrCameraComponent.h.

References headset_.

◆ tick()

void Engine::Components::VrCamera::tick ( double deltaTime)
overridevirtual

Called every frame if ticking is enabled.

Parameters
deltaTimeTime elapsed since last frame.

Reimplemented from Engine::Components::Camera.

Member Data Documentation

◆ ComponentName

const char* Engine::Components::VrCamera::ComponentName = "VrCamera"
staticconstexpr

Definition at line 24 of file VrCameraComponent.h.

◆ headset_

Rendering::Headset* Engine::Components::VrCamera::headset_ = nullptr
private

Definition at line 40 of file VrCameraComponent.h.

Referenced by getHeadset().

◆ IsUnique

bool Engine::Components::VrCamera::IsUnique = true
staticconstexpr

Definition at line 23 of file VrCameraComponent.h.


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