Advertisement
Guest User

SimpleCamera.h

a guest
Apr 8th, 2020
260
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.40 KB | None | 0 0
  1. #pragma once
  2. #include "Math/Vector.h"
  3. #include "Math/Matrix.h"
  4. #include "World/Transform.h"
  5.  
  6. struct SimpleCamera
  7. {
  8. private:
  9.     Transform m_Transform;
  10.  
  11.     float m_ZNear               = 0.01f;
  12.     float m_ZFar                = 100;
  13.     float m_Aspect              = 0.0f;
  14.     float m_FovY                = 60.0f;
  15.     float m_NearFrustrumHeight  = 0.0f;
  16.     float m_FarFrustrumHeight   = 0.0f;
  17.     float m_Yaw                 = 0;
  18.     float m_Pitch               = 0;
  19.     bool m_ViewDirty            = true;
  20.  
  21.     Matrix4 m_View = Matrix4::Identity();
  22.     Matrix4 m_Proj = Matrix4::Identity();
  23.  
  24. public:
  25.     SimpleCamera();
  26.     ~SimpleCamera();
  27.  
  28. public:
  29.     Vector3 GetPosition()const;
  30.     void    SetPosition(const Vector3& v);
  31.  
  32.     Vector3 GetRight()const;
  33.     Vector3 GetUp()const;
  34.     Vector3 GetForward()const;
  35.  
  36.     float GetNearZ()const;
  37.     float GetFarZ()const;
  38.     float GetAspect()const;
  39.     float GetFovX()const;
  40.     float GetFoxY()const;
  41.  
  42.     float GetNearWindowWidth()const;
  43.     float GetNearWindowHeight()const;
  44.     float GetFarWindowWidth()const;
  45.     float GetFarWindowHeight()const;
  46.     float GetFocalLength()const;
  47.  
  48.     // Pass FOV as degree.
  49.     void SetFrustrum(float fovDeg, float aspect, float zNear, float zFar);
  50.     // Pass FOV as degree.
  51.     void SetFOV(float fovDeg);
  52.  
  53.     Matrix4 GetView()const;
  54.     Matrix4 GetProj()const;
  55.     Matrix4 GetViewProject()const;
  56.  
  57.     void Move(const Vector3& translate);
  58.     void Rotation(const Vector3& euler);
  59.     void Rotate(float yaw, float pitch);
  60.  
  61.     void LookAt(Vector3 target);
  62.  
  63.     void Update();
  64.     void OnGui();
  65. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement