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.

108 lines
2.7 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. //=============================================================================//
  6. #ifndef CAM_THIRDPERSON_H
  7. #define CAM_THIRDPERSON_H
  8. #if defined( _WIN32 )
  9. #pragma once
  10. #endif
  11. #ifdef CLIENT_DLL
  12. #include "c_baseplayer.h"
  13. #else
  14. #include "baseplayer.h"
  15. #endif
  16. #define DIST_FORWARD 0
  17. #define DIST_RIGHT 1
  18. #define DIST_UP 2
  19. //-------------------------------------------------- Constants
  20. #define CAM_MIN_DIST 30.0
  21. #define CAM_ANGLE_MOVE .5
  22. #define MAX_ANGLE_DIFF 10.0
  23. #define PITCH_MAX 90.0
  24. #define PITCH_MIN 0
  25. #define YAW_MAX 135.0
  26. #define YAW_MIN -135.0
  27. #define DIST 2
  28. #define CAM_HULL_OFFSET 14.0 // the size of the bounding hull used for collision checking
  29. #define CAMERA_UP_OFFSET 25.0f
  30. #define CAMERA_OFFSET_LERP_TIME 0.5f
  31. #define CAMERA_UP_OFFSET_LERP_TIME 0.25f
  32. class CThirdPersonManager
  33. {
  34. public:
  35. CThirdPersonManager();
  36. void SetCameraOffsetAngles( const Vector& vecOffset ) { m_vecCameraOffset = vecOffset; }
  37. const Vector& GetCameraOffsetAngles( void ) const { return m_vecCameraOffset; }
  38. void SetDesiredCameraOffset( const Vector& vecOffset ) { m_vecDesiredCameraOffset = vecOffset; }
  39. const Vector& GetDesiredCameraOffset( void ) const { return m_vecDesiredCameraOffset; }
  40. Vector GetFinalCameraOffset( void );
  41. void SetCameraOrigin( const Vector& vecOffset ) { m_vecCameraOrigin = vecOffset; }
  42. const Vector& GetCameraOrigin( void ) const { return m_vecCameraOrigin; }
  43. void Update( void );
  44. void PositionCamera( CBasePlayer *pPlayer, const QAngle& angles );
  45. void UseCameraOffsets( bool bUse ) { m_bUseCameraOffsets = bUse; }
  46. bool UsingCameraOffsets( void ) { return m_bUseCameraOffsets; }
  47. const QAngle& GetCameraViewAngles( void ) const { return m_ViewAngles; }
  48. Vector GetDistanceFraction( void );
  49. bool WantToUseGameThirdPerson( void );
  50. void SetOverridingThirdPerson( bool bOverride ) { m_bOverrideThirdPerson = bOverride; }
  51. bool IsOverridingThirdPerson( void ) { return m_bOverrideThirdPerson; }
  52. void Init( void );
  53. void SetForcedThirdPerson( bool bForced ) { m_bForced = bForced; }
  54. bool GetForcedThirdPerson() const { return m_bForced; }
  55. private:
  56. // What is the current camera offset from the view origin?
  57. Vector m_vecCameraOffset;
  58. // Distances from the center
  59. Vector m_vecDesiredCameraOffset;
  60. Vector m_vecCameraOrigin;
  61. bool m_bUseCameraOffsets;
  62. QAngle m_ViewAngles;
  63. float m_flFraction;
  64. float m_flUpFraction;
  65. float m_flTargetFraction;
  66. float m_flTargetUpFraction;
  67. bool m_bOverrideThirdPerson;
  68. bool m_bForced;
  69. float m_flUpOffset;
  70. float m_flLerpTime;
  71. float m_flUpLerpTime;
  72. };
  73. extern CThirdPersonManager g_ThirdPersonManager;
  74. #endif // CAM_THIRDPERSON_H