Vulkan Schnee 0.0.1 (22840dc8)
High-performance rendering engine
Loading...
Searching...
No Matches
VrMovementComponent.h
1#pragma once
2#include "Engine/Component/LogicComponent.h"
3#include "Engine/World/SceneGraph.h"
4
5#include <glm/glm.hpp>
6#include <memory>
7
8namespace Engine::Rendering
9{
10 class Headset;
11} // namespace Engine::Rendering
12
13namespace Input
14{
15 class XrInputHandler;
16} // namespace Input
17
18namespace Engine::Components {
19
27 class VrMovement : public Logic {
28 public:
29 static constexpr bool IsUnique = true;
30 static constexpr const char* ComponentName = "VrMovement";
31
40 Entities::Scene * owningScene,
41 std::shared_ptr<Entities::SceneNode> sceneNode,
42 Rendering::Headset * headset,
43 Input::XrInputHandler * inputHandler
44 );
45
49 ~VrMovement() override = default;
50
51 void beginPlay() override;
52 void tick(double deltaTime) override;
53 void endPlay() override;
54
58 void setMoveSpeed(float speed) { moveSpeed_ = speed; }
63 [[nodiscard]] float getMoveSpeed() const { return moveSpeed_; }
64
68 void setVerticalSpeed(float speed) { verticalSpeed_ = speed; }
73 [[nodiscard]] float getVerticalSpeed() const { return verticalSpeed_; }
74
78 void setDeadZone(float deadZone) { deadZone_ = deadZone; }
83 [[nodiscard]] float getDeadZone() const { return deadZone_; }
84
85 private:
86 [[nodiscard]] glm::vec3 getHeadsetForwardXZ() const;
87
88 std::shared_ptr<Entities::SceneNode> sceneNode_;
91
92 float moveSpeed_ = 3.0f;
93 float verticalSpeed_ = 2.0f;
94 float deadZone_ = 0.15f;
95 };
96
97}
Logic(Entities::Scene *owningScene)
Constructs a logic component owned by a scene.
void setMoveSpeed(float speed)
Sets the horizontal movement speed in units per second.
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.
glm::vec3 getHeadsetForwardXZ() const
~VrMovement() override=default
Destroys the VR movement component.
static constexpr const char * ComponentName
Component registry name.
static constexpr bool IsUnique
This component type is unique per actor.
VrMovement(Entities::Scene *owningScene, std::shared_ptr< Entities::SceneNode > sceneNode, Rendering::Headset *headset, Input::XrInputHandler *inputHandler)
Constructs the VR movement component.
void setDeadZone(float deadZone)
Sets the dead zone for thumbstick input (0.0 to 1.0)
float getDeadZone() const
Gets the thumbstick dead zone.
Input::XrInputHandler * inputHandler_
void setVerticalSpeed(float speed)
Sets the vertical movement speed in units per second.
std::shared_ptr< Entities::SceneNode > sceneNode_
void tick(double deltaTime) override
Called every frame if ticking is enabled.
float getMoveSpeed() const
Gets the horizontal movement speed in units per second.
float getVerticalSpeed() const
Gets the vertical movement speed in units per second.
Owns scene entities, actor lifetime, and the scene graph root.
Definition Scene.h:84
Owns the OpenXR session, XR swapchain, eye transforms, and per-frame XR submission state.
Definition Headset.h:55
Creates OpenXR controller actions from the profile registry and samples the input state.