Patch - Adds camera input handling - V14.5.32
Adds a system for managing camera input using a dedicated CameraInput struct and updates the camera class to process these inputs. This allows for more flexible and controlled camera movement.
This commit is contained in:
@@ -9,6 +9,8 @@
|
||||
// INCLUDES //
|
||||
//////////////
|
||||
#include <directxmath.h>
|
||||
|
||||
#include "input_class.h"
|
||||
#include "macro.h"
|
||||
using namespace DirectX;
|
||||
|
||||
@@ -121,7 +123,15 @@ public:
|
||||
return upF;
|
||||
}
|
||||
|
||||
/**
|
||||
* Move the camera
|
||||
* @param std::vector<bool> inputs : forward, backward, left, right, up, down, scrollUp, scrollDown, rightClick
|
||||
* @param float deltaTime : time since last frame
|
||||
* @return void
|
||||
*/
|
||||
void move(float deltatime);
|
||||
|
||||
void update_camera_inputs_states(input_class* imputs);
|
||||
|
||||
private:
|
||||
float position_x_, position_y_, position_z_;
|
||||
@@ -129,6 +139,8 @@ private:
|
||||
XMMATRIX view_matrix_;
|
||||
XMMATRIX reflection_view_matrix_;
|
||||
|
||||
float camera_speed_;
|
||||
std::shared_ptr<CameraInput> inputs_;
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -161,6 +161,18 @@ inline bool TestPlaneCorner(
|
||||
} \
|
||||
} while (0);
|
||||
|
||||
// --------------------------------------- //
|
||||
// --- Macros for the input processing --- //
|
||||
// --------------------------------------- //
|
||||
// ---------------------------------------------- //
|
||||
// --- Macros for the camera input processing --- //
|
||||
// ---------------------------------------------- //
|
||||
|
||||
struct CameraInput {
|
||||
bool move_forward = false;
|
||||
bool move_backward = false;
|
||||
bool move_left = false;
|
||||
bool move_right = false;
|
||||
bool move_up = false;
|
||||
bool move_down = false;
|
||||
bool scroll_up = false;
|
||||
bool scroll_down = false;
|
||||
bool right_click = false;
|
||||
};
|
||||
|
||||
@@ -844,6 +844,7 @@ bool application_class::frame(input_class* Input)
|
||||
buttonS = Input->is_key_pressed(DIK_S);
|
||||
buttonA = Input->is_key_pressed(DIK_Q);
|
||||
buttonE = Input->is_key_pressed(DIK_E);
|
||||
|
||||
position_->MoveCamera(buttonZ, buttonS, buttonQ, buttonD, buttonE, buttonA, scrollUp, scrollDown, rightMouseDown);
|
||||
position_->GetPosition(positionX, positionY, positionZ);
|
||||
|
||||
|
||||
@@ -13,6 +13,9 @@ camera_class::camera_class()
|
||||
rotation_x_ = 0.0f;
|
||||
rotation_y_ = 0.0f;
|
||||
rotation_z_ = 0.0f;
|
||||
|
||||
camera_speed_ = 1.0f;
|
||||
|
||||
LOG_INIT("Camera class initialized");
|
||||
}
|
||||
|
||||
@@ -171,4 +174,18 @@ void camera_class::get_reflection_view_matrix(XMMATRIX& reflectionViewMatrix) co
|
||||
{
|
||||
reflectionViewMatrix = reflection_view_matrix_;
|
||||
return;
|
||||
}
|
||||
|
||||
void camera_class::move(float deltatime)
|
||||
{
|
||||
}
|
||||
|
||||
void camera_class::update_camera_inputs_states(input_class* inputs)
|
||||
{
|
||||
inputs_->move_forward = inputs->is_key_pressed(DIK_W);
|
||||
inputs_->move_backward = inputs->is_key_pressed(DIK_S);
|
||||
inputs_->move_left = inputs->is_key_pressed(DIK_A);
|
||||
inputs_->move_right = inputs->is_key_pressed(DIK_D);
|
||||
inputs_->move_up = inputs->is_key_pressed(DIK_E);
|
||||
inputs_->move_down = inputs->is_key_pressed(DIK_Q);
|
||||
}
|
||||
Reference in New Issue
Block a user