Vulkan Schnee 0.0.1 (22840dc8)
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)
 Constructs a VR camera backed by a headset and scene node.
 ~VrCamera () override=default
 Destroys the VR camera component.
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::Headset * getHeadset () const
 Gets the headset used by this VR camera.
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
 Destroys the camera component.
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.
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.
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
 This component type is unique per actor.
static constexpr const char * ComponentName = "VrCamera"
 Component registry name.
Static Public Attributes inherited from Engine::Components::Camera
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 Attributes

Rendering::Headset * headset_ = nullptr

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.

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 )

Constructs a VR camera backed by a headset and scene node.

Parameters
owningSceneScene that owns this component.
sceneNodeScene node that receives headset orientation.
headsetHeadset used to query VR eye matrices.

◆ ~VrCamera()

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

Destroys the VR camera component.

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

Gets the headset used by this VR camera.

Returns
Headset pointer, or nullptr if none is assigned.

Definition at line 50 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

Component registry name.

Definition at line 24 of file VrCameraComponent.h.

◆ headset_

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

Definition at line 53 of file VrCameraComponent.h.

Referenced by getHeadset().

◆ IsUnique

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

This component type is unique per actor.

Definition at line 23 of file VrCameraComponent.h.


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