Files
2025-12-15 23:22:33 +08:00

102 lines
3.0 KiB
C++

/***********************************************************************************************************************
*
* Copyright (c) 2010 - 2025 by Tech Soft 3D, Inc.
* The information contained herein is confidential and proprietary to Tech Soft 3D, Inc., and considered a trade secret
* as defined under civil and criminal statutes. Tech Soft 3D shall pursue its civil and criminal remedies in the event
* of unauthorized use or misappropriation of its trade secrets. Use of this information by anyone other than authorized
* employees of Tech Soft 3D, Inc. is granted only under a written non-disclosure agreement, expressly prescribing the
* scope and manner of such use.
*
***********************************************************************************************************************/
#ifndef CAMERA_H
#define CAMERA_H
#include <glm/vec3.hpp>
#include "../utils/bounding_box.h"
class Camera
{
public:
enum class EMovement
{
ZOOM_IN = 0,
ZOOM_OUT,
FRONT_DIRECT,
FRONT_INV,
RIGHT_DIRECT,
RIGHT_INV,
UP_DIRECT,
UP_INV,
MV_RIGHT,
MV_LEFT,
MV_UP,
MV_DOWN
};//enum to manage the different kind of camera moving
enum class EView
{
ISO = 0,
TOP,
BOTTOM,
LEFT,
RIGHT,
FRONT,
BACK
};//enum names the computed views
glm::vec3 position;
glm::vec3 front;
glm::vec3 up;
glm::vec3 right;
glm::vec3 orbital_center;
glm::vec3 start_position;
glm::vec3 start_front;
glm::vec3 start_right;
glm::vec3 start_up;
// camera Attributes
float max_bbx_length;
EView current_view;
~Camera()= default;
// processes input received from any keyboard-like input system. Accepts input parameter in the form of camera defined ENUM (to abstract it from windowing systems)
void process_keyboard(Camera::EMovement direction);
// processes input received from a mouse input system. Expects the offset value in both the x and y direction.
void process_mouse_rotation(float xOffset, float yOffset, int screenWidth, int screenHeight);
// processes input received from a mouse scroll-wheel event. Only requires input on the vertical wheel-axis.
void process_mouse_scroll(bool is_zoom_in);
// processes input received from a mouse move event.
void process_mouse_translation(float xOffset, float yOffset);
// process input received from a right mouse click.
void process_switch_view();
// set the original position of the camera, calculated with the size of the bounding box
void initialize_position( const utils::geometry::BoundingBox& bbox);
// processes input received when the O key on the keyboard is pressed.
void set_to_origin();
// allows to have the most optimised far after a zoom in or out
float calculate_far();
// allows to have the most optimised near after a zoom in or out
float calculate_near();
// returns the view matrix calculated
glm::mat4 get_view_matrix();
private:
// allow to move the camera in cercle from orbital center and the current camera position
void rotate_camera(glm::vec3 axe_rotate, float alpha);
};
#endif // CAMERA_H