2022-01-02 19:28:16 -05:00
|
|
|
#pragma once
|
|
|
|
|
2022-01-08 18:59:40 -05:00
|
|
|
#include <glm/glm.hpp>
|
2022-01-02 19:28:16 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Default camera values
|
|
|
|
*/
|
|
|
|
#define DEFAULT_CAMERA_YAW (-90.0f)
|
|
|
|
#define DEFAULT_CAMERA_PITCH (0.0f)
|
|
|
|
#define DEFAULT_CAMERA_ROLL (0.0f)
|
|
|
|
#define DEFAULT_CAMERA_SPEED (1.0f)
|
|
|
|
#define DEFAULT_CAMERA_SENSITIVITY (1.0f)
|
|
|
|
#define DEFAULT_CAMERA_JOYSENSITIVITY (1.0f)
|
|
|
|
#define DEFAULT_CAMERA_ZOOM (45.0f)
|
2022-01-08 18:59:40 -05:00
|
|
|
#define DEFAULT_CAMERA_ZNEAR (0.1f)
|
|
|
|
#define DEFAULT_CAMERA_ZFAR (1000.0f)
|
2022-01-02 19:28:16 -05:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Decelerate at gravity speed (9.8 m/s) / ???
|
|
|
|
*/
|
|
|
|
#define DEFAULT_CAMERA_DECELERATIONSPEED (0.98f)
|
|
|
|
#define DEFAULT_CAMERA_MOUSEDECELERATIONSPEED (0.098f)
|
|
|
|
|
|
|
|
class Camera
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* An abstract camera class that processes input and calculates the corresponding
|
2022-01-08 18:59:40 -05:00
|
|
|
* ...
|
2022-01-02 19:28:16 -05:00
|
|
|
*/
|
|
|
|
glm::vec3 Position;
|
|
|
|
glm::vec3 Front;
|
|
|
|
glm::vec3 WorldUp;
|
|
|
|
|
2022-01-08 18:59:40 -05:00
|
|
|
/**
|
|
|
|
* ... Euler Angles, Vectors and Matrices for use in OpenGL. */
|
|
|
|
glm::vec3 Right;
|
|
|
|
glm::vec3 Up;
|
2022-01-02 19:28:16 -05:00
|
|
|
glm::vec3 Angles;
|
|
|
|
|
2022-01-08 18:59:40 -05:00
|
|
|
/* TODO combine with Object */
|
2022-01-02 19:28:16 -05:00
|
|
|
glm::vec3 Direction; /* Position movement */
|
2022-01-08 18:59:40 -05:00
|
|
|
glm::vec3 ViewDirection; /* Yaw, Pitch movement */
|
2022-01-02 19:28:16 -05:00
|
|
|
|
|
|
|
void updateCameraVectors (void);
|
|
|
|
|
|
|
|
public:
|
|
|
|
/**
|
|
|
|
* Defines several possible options for camera movement.
|
|
|
|
* Used as abstraction to stay away from window-system specific input methods
|
|
|
|
*/
|
|
|
|
enum Movement
|
|
|
|
{
|
|
|
|
FORWARD, BACKWARD, LEFT, RIGHT, UP, DOWN, CW, CCW, NONE
|
|
|
|
};
|
|
|
|
|
|
|
|
/** Camera options */
|
2022-01-08 18:59:40 -05:00
|
|
|
float MovementSpeed, MouseSensitivity, JoystickSensitivity, DecelerationSpeed, ViewDecelerationSpeed;
|
|
|
|
float Zoom, zNear, zFar;
|
2022-01-02 19:28:16 -05:00
|
|
|
|
|
|
|
Camera (
|
|
|
|
const glm::vec3 position = glm::vec3(0.0f, 0.0f, 1.0f)
|
2022-01-08 18:59:40 -05:00
|
|
|
, const glm::vec3 up = glm::vec3(0.0f, 1.0f, 0.0f)
|
|
|
|
, const float yaw = DEFAULT_CAMERA_YAW
|
|
|
|
, const float pitch = DEFAULT_CAMERA_PITCH
|
|
|
|
, const float roll = DEFAULT_CAMERA_ROLL);
|
2022-01-02 19:28:16 -05:00
|
|
|
|
|
|
|
glm::mat4 GetViewMatrix (const bool constrainPitch = true);
|
2022-01-08 18:59:40 -05:00
|
|
|
void ProcessJoystickMovement (const float, const float, const float);
|
|
|
|
void ProcessKeyboard (const Camera::Movement, const float);
|
|
|
|
void ProcessMouseMovement (const float, const float, const float);
|
|
|
|
void ProcessMouseScroll (const float, const float, const float);
|
2022-01-02 19:28:16 -05:00
|
|
|
};
|