Team Fortress 2 Source Code as on 22/4/2020
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

124 lines
3.3 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. // $NoKeywords: $
  6. //=============================================================================//
  7. #ifndef CAMERA_H
  8. #define CAMERA_H
  9. #ifdef _WIN32
  10. #pragma once
  11. #endif
  12. #include "mathlib/vmatrix.h"
  13. #include "mathlib/vector4d.h"
  14. #define OCTANT_X_POSITIVE 1
  15. #define OCTANT_Y_POSITIVE 2
  16. #define OCTANT_Z_POSITIVE 4
  17. //
  18. // Return values from BoxIsVisible.
  19. //
  20. enum Visibility_t
  21. {
  22. VIS_NONE = 0, // The box is completely outside the view frustum.
  23. VIS_PARTIAL, // The box is partially inside the view frustum.
  24. VIS_TOTAL // The box is completely inside the view frustum.
  25. };
  26. class CCamera
  27. {
  28. public:
  29. CCamera(void);
  30. virtual ~CCamera(void);
  31. void Move(Vector &vDelta);
  32. void Pitch(float fDegrees);
  33. void Roll(float fDegrees);
  34. void Yaw(float fDegrees);
  35. void MoveForward(float fUnits);
  36. void MoveRight(float fUnits);
  37. void MoveUp(float fUnits);
  38. void GetViewPoint(Vector& fViewPoint) const;
  39. void GetViewForward(Vector& ViewForward) const;
  40. void GetViewUp(Vector& ViewUp) const;
  41. void GetViewRight(Vector& ViewRight) const;
  42. void GetViewMatrix(VMatrix& Matrix);
  43. void GetProjMatrix(VMatrix& Matrix);
  44. void GetViewProjMatrix( VMatrix &Matrix );
  45. float GetYaw(void);
  46. float GetPitch(void);
  47. float GetRoll(void);
  48. QAngle GetAngles( );
  49. void SetYaw(float fDegrees);
  50. void SetPitch(float fDegrees);
  51. void SetRoll(float fDegrees);
  52. void SetViewPoint(const Vector &ViewPoint);
  53. void SetViewTarget(const Vector &ViewTarget);
  54. void SetViewPort( int width, int height );
  55. void GetViewPort( int &width, int &height );
  56. bool IsOrthographic();
  57. void SetFarClip(float fFarZ);
  58. void SetNearClip(float fNearZ);
  59. float GetNearClip(void);
  60. float GetFarClip(void);
  61. void SetPerspective(float fFOV, float fNearZ, float fFarZ);
  62. void GetFrustumPlanes( Vector4D Planes[6] );
  63. float GetFOV(void);
  64. void SetOrthographic(float fZoom, float fNearZ, float fFarZ);
  65. void SetZoom(float fScale);
  66. void Zoom(float fScale);
  67. float GetZoom(void);
  68. void WorldToView( const Vector& vWorld, Vector2D &vView);
  69. void ViewToWorld( const Vector2D &vView, Vector& vWorld);
  70. void BuildRay( const Vector2D &vView, Vector& vStart, Vector& vEnd );
  71. protected:
  72. void BuildViewMatrix();
  73. void BuildProjMatrix();
  74. void CameraIdentityMatrix(VMatrix& Matrix);
  75. VMatrix m_ViewMatrix; // Camera view matrix, based on current yaw, pitch, and roll.
  76. Vector m_ViewPoint;
  77. float m_fYaw; // Counterclockwise rotation around the CAMERA_UP axis, in degrees [-359, 359].
  78. float m_fPitch; // Counterclockwise rotation around the CAMERA_RIGHT axis, in degrees [-90, 90].
  79. float m_fRoll; // Counterclockwise rotation around the CAMERA_FORWARD axis, in degrees [-359, 359].
  80. VMatrix m_ProjMatrix; // Camera projection matrix
  81. bool m_bIsOrthographic; // Camera projection mode
  82. float m_fHorizontalFOV; // Horizontal field of view in degrees.
  83. float m_fNearClip; // Distance to near clipping plane.
  84. float m_fFarClip; // Distance to far clipping plane.
  85. float m_fZoom; // Orthographic zoom scale
  86. float m_fScaleHorz;
  87. float m_fScaleVert;
  88. int m_nViewWidth;
  89. int m_nViewHeight;
  90. VMatrix m_ViewProjMatrix; // view and projection matrix
  91. VMatrix m_InvViewProjMatrix; // inverse view and projection matrix
  92. };
  93. #endif // CAMERA_H