Vulkan Schnee 0.0.1 (22840dc8)
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
 Destroys the VR movement 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.
void setMoveSpeed (float speed)
 Sets the horizontal movement speed in units per second.
float getMoveSpeed () const
 Gets the horizontal movement speed in units per second.
void setVerticalSpeed (float speed)
 Sets the vertical movement speed in units per second.
float getVerticalSpeed () const
 Gets the vertical movement speed in units per second.
void setDeadZone (float deadZone)
 Sets the dead zone for thumbstick input (0.0 to 1.0)
float getDeadZone () const
 Gets the thumbstick dead zone.
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 drawImGui ()
 Draws component-specific ImGui inspector controls.
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 = "VrMovement"
 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

glm::vec3 getHeadsetForwardXZ () const

Private Attributes

std::shared_ptr< Entities::SceneNode > sceneNode_
Rendering::Headset * headset_ = nullptr
Input::XrInputHandler * inputHandler_ = 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::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

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

Destroys the VR movement component.

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

Gets the thumbstick dead zone.

Returns
Dead zone threshold in the range 0.0 to 1.0.

Definition at line 83 of file VrMovementComponent.h.

References deadZone_.

◆ getHeadsetForwardXZ()

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

◆ getMoveSpeed()

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

Gets the horizontal movement speed in units per second.

Returns
Horizontal movement speed.

Definition at line 63 of file VrMovementComponent.h.

References moveSpeed_.

◆ getVerticalSpeed()

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

Gets the vertical movement speed in units per second.

Returns
Vertical movement speed.

Definition at line 73 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 78 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 58 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 68 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

Component registry name.

Definition at line 30 of file VrMovementComponent.h.

◆ deadZone_

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

Definition at line 94 of file VrMovementComponent.h.

Referenced by getDeadZone(), and setDeadZone().

◆ headset_

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

Definition at line 89 of file VrMovementComponent.h.

◆ inputHandler_

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

Definition at line 90 of file VrMovementComponent.h.

◆ IsUnique

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

This component type is unique per actor.

Definition at line 29 of file VrMovementComponent.h.

◆ moveSpeed_

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

Definition at line 92 of file VrMovementComponent.h.

Referenced by getMoveSpeed(), and setMoveSpeed().

◆ sceneNode_

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

Definition at line 88 of file VrMovementComponent.h.

◆ verticalSpeed_

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

Definition at line 93 of file VrMovementComponent.h.

Referenced by getVerticalSpeed(), and setVerticalSpeed().


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