71 lines
1.5 KiB
C++

#pragma once
#ifndef _NB_CAMERA
#define _NB_CAMERA
#include <GLLoad.h>
#include <glm/glm.hpp>
#include <glm/gtc/matrix_inverse.hpp>
#include <glm/gtc/matrix_transform.hpp>
#include <glm/gtc/type_ptr.hpp>
namespace NB {
class Camera {
public:
typedef glm::vec3 Vec3;
typedef glm::mat4 Mat4;
enum CameraType : unsigned char {
None,
Orthographic,
Perspective
};
static Vec3 normCross(const Vec3&, const Vec3&);
Camera(
const Vec3& pos=Vec3(1.0f, 0.0f, 0.0f),
const Vec3& tar=Vec3(0.0f, 0.0f, 0.0f),
const Vec3& up =Vec3(0.0f, 1.0f, 0.0f)
);
Vec3 getPos() const;
Vec3 getTarget() const;
Vec3 getDirection() const;
Vec3 getWorldUp() const;
Vec3 getUp() const;
Vec3 getRight() const;
Mat4 getLookMatrix() const;
Mat4 getProjectionMatrix() const;
Mat4 getFlattenedMatrices() const;
void setProjection(const Mat4&);
void setPos(const Vec3&);
void setTarget(const Vec3&);
void setDirection(const Vec3&);
void setWorldUp(const Vec3&);
void addPos(const Vec3&);
void panPos(const Vec3&);
void panPosRelative(const Vec3&);
void addTarget(const Vec3&);
void roll(float);
void pitch(float);
void yaw(float);
protected:
Vec3 _pos;
Vec3 _tar;
Vec3 _dir;
Vec3 _world_up;
Vec3 _up;
Vec3 _right;
Mat4 _look;
Mat4 _proj;
const CameraType _camera_type;
void _calcLook();
};
}
#endif // _NB_CAMERA