67 lines
2.1 KiB
C++
67 lines
2.1 KiB
C++
#pragma once
|
|
|
|
//#include "../Utils/3DMaths.hpp" // Using PCH instead
|
|
|
|
|
|
class Camera final {
|
|
public:
|
|
Camera();
|
|
~Camera() {}
|
|
|
|
Camera(Camera&&) = default;
|
|
Camera& operator= (Camera&&) = default;
|
|
Camera(Camera const&) = delete;
|
|
Camera& operator= (Camera const&) = delete;
|
|
|
|
float GetFoV() const { return fov; }
|
|
float GetFarZ() const { return zf; }
|
|
const bool IsFrustrumUpdated() const { return frustrumUpdated; }
|
|
const bool IsCameraMoved() const { return camMoved; }
|
|
M3D_VECTOR GetPos() const { return M3D_V4LoadF3(&mPos); }
|
|
M3D_F3 GetPos3f() const { return mPos; }
|
|
M3D_VECTOR GetLook() const { return M3D_V4LoadF3(&mLook); }
|
|
M3D_F3 GetLook3f() const { return mLook; }
|
|
M3D_MATRIX GetView() const { return M3D_V4LoadF4x4(&mViewMat); }
|
|
const M3D_F4X4& GetView4x4f() const { return mViewMat; }
|
|
M3D_MATRIX GetProj() const { return M3D_V4LoadF4x4(&mProjMat); }
|
|
const M3D_F4X4& GetProj4x4f() const { return mProjMat; }
|
|
|
|
void SetPosition(const float x, const float y, const float z) { mPos = M3D_F3(x, y, z); }
|
|
void SetPosition(const M3D_F3 v) { mPos = v; }
|
|
|
|
void SetFrustrum(float fov, float r, float zn, float zf);
|
|
void UpdateCamView();
|
|
void LookAt(M3D_VECTOR pos, M3D_VECTOR target, M3D_VECTOR worldUp);
|
|
void LookAt(const M3D_F3& pos, const M3D_F3& target, const M3D_F3& up);
|
|
|
|
void Strafe(float d);
|
|
void Walk(float d);
|
|
void Fly(float d);
|
|
|
|
void Pitch(float angle);
|
|
void Yaw(float angle);
|
|
|
|
void ResetUpdateFlags() { frustrumUpdated = false; camMoved = false;} //TODO: need a proper way to manage this flags
|
|
|
|
private:
|
|
float fov; // It's the Y-FoV!
|
|
float zf;
|
|
|
|
bool frustrumUpdated = true;
|
|
bool camMoved = true;
|
|
|
|
M3D_F4X4 mProjMat = M3D_MIdentity4x4();
|
|
M3D_F4X4 mViewMat = M3D_MIdentity4x4();
|
|
|
|
/*
|
|
right-x up-x look-x pos-x
|
|
right-y up-y look-y pos-y
|
|
right-z up-z look-z pos-z
|
|
0 0 0 1
|
|
*/
|
|
M3D_F3 mPos = {0.0f, 0.0f, 0.0f};
|
|
M3D_F3 mRight = {1.0f, 0.0f, 0.0f};
|
|
M3D_F3 mUp = {0.0f, 1.0f, 0.0f};
|
|
M3D_F3 mLook = {0.0f, 0.0f, 1.0f};
|
|
|
|
}; |