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

Component that handles VR player movement using controller inputs. Writes locomotion to the actor's SceneNode, which the camera reads from. More...

#include <VrMovementComponent.h>

Inheritance diagram for Engine::Components::VrMovement:
Collaboration diagram for Engine::Components::VrMovement:

Public Member Functions

 VrMovement (Entities::Scene *owningScene, std::shared_ptr< Entities::SceneNode > sceneNode, Rendering::Headset *headset, Input::XrInputHandler *inputHandler)
 Constructs the VR movement component.
 ~VrMovement () override=default
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.
void setMoveSpeed (float speed)
 Sets the horizontal movement speed in units per second.
float getMoveSpeed () const
void setVerticalSpeed (float speed)
 Sets the vertical movement speed in units per second.
float getVerticalSpeed () const
void setDeadZone (float deadZone)
 Sets the dead zone for thumbstick input (0.0 to 1.0)
float getDeadZone () const
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 = "VrMovement"
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

glm::vec3 getHeadsetForwardXZ () const

Private Attributes

std::shared_ptr< Entities::SceneNodesceneNode_
Rendering::Headsetheadset_ = nullptr
Input::XrInputHandlerinputHandler_ = nullptr
float moveSpeed_ = 3.0f
float verticalSpeed_ = 2.0f
float deadZone_ = 0.15f

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

Component that handles VR player movement using controller inputs. Writes locomotion to the actor's SceneNode, which the camera reads from.

  • Right thumbstick: XZ plane movement (forward/back/strafe) aligned to headset facing
  • Right/Left trigger: Move up (Y+)
  • Right/Left grip: Move down (Y-)

Definition at line 27 of file VrMovementComponent.h.

Constructor & Destructor Documentation

◆ VrMovement()

Engine::Components::VrMovement::VrMovement ( Entities::Scene * owningScene,
std::shared_ptr< Entities::SceneNode > sceneNode,
Rendering::Headset * headset,
Input::XrInputHandler * inputHandler )

Constructs the VR movement component.

Parameters
owningSceneThe scene this component belongs to
sceneNodeScene node to write position to (typically actor's node)
headsetPointer to the headset for orientation queries
inputHandlerPointer to the XR input handler

◆ ~VrMovement()

Engine::Components::VrMovement::~VrMovement ( )
overridedefault

Member Function Documentation

◆ beginPlay()

void Engine::Components::VrMovement::beginPlay ( )
overridevirtual

Called when the component is added to the scene or the game starts.

Reimplemented from Engine::Components::Logic.

◆ endPlay()

void Engine::Components::VrMovement::endPlay ( )
overridevirtual

Called when the component is removed or the game ends.

Reimplemented from Engine::Components::Logic.

◆ getDeadZone()

float Engine::Components::VrMovement::getDeadZone ( ) const
inlinenodiscard

Definition at line 68 of file VrMovementComponent.h.

References deadZone_.

◆ getHeadsetForwardXZ()

glm::vec3 Engine::Components::VrMovement::getHeadsetForwardXZ ( ) const
nodiscardprivate

◆ getMoveSpeed()

float Engine::Components::VrMovement::getMoveSpeed ( ) const
inlinenodiscard

Definition at line 56 of file VrMovementComponent.h.

References moveSpeed_.

◆ getVerticalSpeed()

float Engine::Components::VrMovement::getVerticalSpeed ( ) const
inlinenodiscard

Definition at line 62 of file VrMovementComponent.h.

References verticalSpeed_.

◆ setDeadZone()

void Engine::Components::VrMovement::setDeadZone ( float deadZone)
inline

Sets the dead zone for thumbstick input (0.0 to 1.0)

Definition at line 67 of file VrMovementComponent.h.

References deadZone_.

◆ setMoveSpeed()

void Engine::Components::VrMovement::setMoveSpeed ( float speed)
inline

Sets the horizontal movement speed in units per second.

Definition at line 55 of file VrMovementComponent.h.

References moveSpeed_.

◆ setVerticalSpeed()

void Engine::Components::VrMovement::setVerticalSpeed ( float speed)
inline

Sets the vertical movement speed in units per second.

Definition at line 61 of file VrMovementComponent.h.

References verticalSpeed_.

◆ tick()

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

Called every frame if ticking is enabled.

Parameters
deltaTimeTime elapsed since last frame.

Reimplemented from Engine::Components::Logic.

Member Data Documentation

◆ ComponentName

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

Definition at line 30 of file VrMovementComponent.h.

◆ deadZone_

float Engine::Components::VrMovement::deadZone_ = 0.15f
private

Definition at line 79 of file VrMovementComponent.h.

Referenced by getDeadZone(), and setDeadZone().

◆ headset_

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

Definition at line 74 of file VrMovementComponent.h.

◆ inputHandler_

Input::XrInputHandler* Engine::Components::VrMovement::inputHandler_ = nullptr
private

Definition at line 75 of file VrMovementComponent.h.

◆ IsUnique

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

Definition at line 29 of file VrMovementComponent.h.

◆ moveSpeed_

float Engine::Components::VrMovement::moveSpeed_ = 3.0f
private

Definition at line 77 of file VrMovementComponent.h.

Referenced by getMoveSpeed(), and setMoveSpeed().

◆ sceneNode_

std::shared_ptr<Entities::SceneNode> Engine::Components::VrMovement::sceneNode_
private

Definition at line 73 of file VrMovementComponent.h.

◆ verticalSpeed_

float Engine::Components::VrMovement::verticalSpeed_ = 2.0f
private

Definition at line 78 of file VrMovementComponent.h.

Referenced by getVerticalSpeed(), and setVerticalSpeed().


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