OpenGL-JIN/src/Camera.h
Teo-CD 9568b54b87 Added getters for camera properties
Added world translation for camera
Renamed previous translation to local_translate
2019-11-03 15:32:14 +01:00

51 lines
1.7 KiB
C++

//
// Created by trotfunky on 19/10/2019.
//
#ifndef TESTS_OPENGL_CAMERA_H
#define TESTS_OPENGL_CAMERA_H
#include <cmath>
#include <GL/glut.h>
#include "Math/Quaternion.h"
#include "Math/Vectors.h"
class Camera {
public:
Camera(const Vec3d& eye_pos,const Vec3d& look_direction,const Vec3d& up_vector);
/// Translates the camera according to the world axises.
/// \param translation Translation in the world coordinates system.
void translate(const Vec3d& translation);
/// Translates the camera relative to its current position and look direction.
/// \param translation Translation where x is pointing in the direction of vision.
void local_translate(const Vec3d& translation);
/// Rotates the gaze around its local x and z but around global y, relatively to the current orientation.
/// This is to provide a coherent movement in regards to mouse movement.
/// \param rotation Angles are radians to rotate about each axis.
void rotate(const Vec3d& rotation);
/// Calls the gluLookAt function for the camera.
void look();
void set_position(const Vec3d& eye_pos);
const Vec3d& get_eyepos() const;
const Vec3d& get_gaze() const;
const Vec3d& get_gazeup() const;
private:
Vec3d eye;
Vec3d gaze;
Vec3d gaze_up;
/// Quaternion from the world coordinates to the local coordinates
Quaternion rotation_quaternion;
/// Compute rotation quaternion from the global coordinates to the local coordinates.
/// As per https://math.stackexchange.com/questions/2122668/calculate-orientation-quaternion-given-two-axes-of-a-coordinate-system
void compute_base_change();
};
#endif //TESTS_OPENGL_CAMERA_H