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.

57 lines
1.8 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose: A set of utilities to deal with camera transforms
  4. //
  5. //===========================================================================//
  6. #ifndef CAMERAUTILS_H
  7. #define CAMERAUTILS_H
  8. #ifdef _WIN32
  9. #pragma once
  10. #endif
  11. #include "tier2/tier2.h"
  12. #include "Color.h"
  13. //-----------------------------------------------------------------------------
  14. // Forward declarations
  15. //-----------------------------------------------------------------------------
  16. class Vector;
  17. class QAngle;
  18. class IMaterial;
  19. struct matrix3x4_t;
  20. class VMatrix;
  21. //-----------------------------------------------------------------------------
  22. // Camera state
  23. // TODO: Maybe this should be a base class of CViewSetup?
  24. //-----------------------------------------------------------------------------
  25. struct Camera_t
  26. {
  27. Vector m_origin;
  28. QAngle m_angles;
  29. float m_flFOV;
  30. float m_flZNear;
  31. float m_flZFar;
  32. };
  33. //-----------------------------------------------------------------------------
  34. // accessors for generated matrices
  35. //-----------------------------------------------------------------------------
  36. void ComputeViewMatrix( VMatrix *pWorldToCamera, const Camera_t& camera );
  37. void ComputeViewMatrix( matrix3x4_t *pWorldToCamera, const Camera_t& camera );
  38. void ComputeProjectionMatrix( VMatrix *pCameraToProjection, const Camera_t& camera, int width, int height );
  39. //-----------------------------------------------------------------------------
  40. // Computes the screen space position given a screen size
  41. //-----------------------------------------------------------------------------
  42. void ComputeScreenSpacePosition( Vector2D *pScreenPosition, const Vector &vecWorldPosition,
  43. const Camera_t &camera, int width, int height );
  44. #endif // CAMERAUTILS_H