engine/test/src/camera_controller.hpp

45 lines
1.1 KiB
C++
Raw Normal View History

2023-05-02 11:02:43 +00:00
#ifndef ENGINE_TEST_SRC_CAMERA_CONTROLLER_H_
#define ENGINE_TEST_SRC_CAMERA_CONTROLLER_H_
2022-11-07 20:15:26 +00:00
2023-05-02 11:02:43 +00:00
#include <glm/vec3.hpp>
2023-05-01 13:13:35 +00:00
#include "components/transform.h"
2023-05-02 11:02:43 +00:00
#include "ecs_system.h"
#include "event_system.h"
2023-05-01 13:13:35 +00:00
#include "systems/collisions.h"
2022-11-07 20:15:26 +00:00
2023-01-05 13:21:33 +00:00
struct CameraControllerComponent {
2023-05-02 11:02:43 +00:00
static constexpr float kWalkSpeed = 4.0f;
static constexpr float kThrust = 25.0f;
static constexpr float kCameraSensitivity = 0.007f;
2022-11-07 20:15:26 +00:00
2023-05-02 11:02:43 +00:00
float yaw = 0.0f;
float pitch = 0.0f;
float dy = 0.0f;
2022-11-07 20:15:26 +00:00
2023-05-02 11:02:43 +00:00
glm::vec3 last_collision_normal{};
glm::vec3 last_collision_point{};
bool just_collided = false;
bool is_grounded = false;
2023-01-22 18:20:10 +00:00
2023-01-05 13:21:33 +00:00
};
2023-05-02 11:02:43 +00:00
class CameraControllerSystem
: public engine::System,
public engine::EventHandler<engine::PhysicsSystem::CollisionEvent> {
public:
CameraControllerSystem(engine::Scene* scene);
2022-11-07 20:15:26 +00:00
2023-05-02 11:02:43 +00:00
// engine::System overrides
void OnUpdate(float ts) override;
2023-05-02 11:02:43 +00:00
// engine::EventHandler overrides
void OnEvent(engine::PhysicsSystem::CollisionEvent info) override;
2023-02-09 20:44:37 +00:00
2023-05-02 11:02:43 +00:00
engine::TransformComponent* t = nullptr;
engine::ColliderComponent* col = nullptr;
CameraControllerComponent* c = nullptr;
2022-11-07 20:15:26 +00:00
};
2023-05-02 11:02:43 +00:00
#endif