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.

159 lines
4.7 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. //=============================================================================//
  6. #if defined( REPLAY_ENABLED )
  7. #ifndef REPLAYCAMERA_H
  8. #define REPLAYCAMERA_H
  9. #ifdef _WIN32
  10. #pragma once
  11. #endif
  12. #include "replay/ireplaycamera.h"
  13. #include "GameEventListener.h"
  14. class C_ReplayCamera : public CGameEventListener,
  15. public IReplayCamera
  16. {
  17. public:
  18. C_ReplayCamera();
  19. virtual ~C_ReplayCamera();
  20. void Init();
  21. void Reset();
  22. //
  23. // IReplayCamera:
  24. //
  25. virtual void ClearOverrideView();
  26. void EnableInput( bool bEnable );
  27. void OverrideView( const Vector *pOrigin, const QAngle *pAngles, float flFov );
  28. void GetCachedView( Vector &origin, QAngle &angles, float &fov );
  29. void CalcView(Vector& origin, QAngle& angles, float& fov);
  30. void FireGameEvent( IGameEvent *event );
  31. void SetMode(int iMode);
  32. void SetChaseCamParams( float flOffset, float flDistance, float flTheta, float flPhi );
  33. void SpecNextPlayer( bool bInverse );
  34. // See UTIL_PlayerByCommandArg for what all might go in here.
  35. void SpecPlayerByPredicate( const char *szPlayerSearch );
  36. bool IsPVSLocked();
  37. void SetAutoDirector( bool bActive );
  38. int GetMode(); // returns current camera mode
  39. C_BaseEntity *GetPrimaryTarget(); // return primary target
  40. inline int GetPrimaryTargetIndex() { return m_iTarget1; }
  41. void SetPrimaryTarget( int nEntity); // set the primary obs target
  42. void CreateMove(CUserCmd *cmd);
  43. void FixupMovmentParents();
  44. void PostEntityPacketReceived();
  45. const char* GetTitleText() { return m_szTitleText; }
  46. int GetNumSpectators() { return m_nNumSpectators; }
  47. void SmoothFov( float flDelta );
  48. float m_flRoamingAccel;
  49. float m_flRoamingSpeed;
  50. float m_flRoamingFov[2]; // FOV for roaming only - current and target - smoothing done by replay editor
  51. float m_flRoamingRotFilterFactor;
  52. float m_flRoamingShakeAmount;
  53. float m_flRoamingShakeSpeed;
  54. float m_flRoamingShakeDir;
  55. protected:
  56. void InitRoamingKeys();
  57. bool ShouldUseDefaultRoamingSettings() const;
  58. void CalcChaseCamView( Vector& eyeOrigin, QAngle& eyeAngles, float& fov, float flDelta );
  59. void CalcFixedView( Vector& eyeOrigin, QAngle& eyeAngles, float& fov, float flDelta );
  60. void CalcInEyeCamView( Vector& eyeOrigin, QAngle& eyeAngles, float& fov, float flDelta );
  61. void CalcRoamingView(Vector& eyeOrigin, QAngle& eyeAngles, float& fov, float flDelta);
  62. void SmoothCameraAngle( QAngle& targetAngle );
  63. void SetCameraAngle( QAngle& targetAngle );
  64. void Accelerate( Vector& wishdir, float wishspeed, float accel, float flDelta );
  65. bool ShouldOverrideView( Vector& origin, QAngle& angles, float& fov ); // Fills with override data if m_bOverrideView is set
  66. struct View_t
  67. {
  68. Vector origin;
  69. QAngle angles;
  70. float fov;
  71. };
  72. bool m_bInputEnabled;
  73. bool m_bOverrideView;
  74. View_t m_OverrideViewData;
  75. View_t m_CachedView;
  76. float m_flOldTime; // Time of last CalcView() (uses gpGlobals->realtime)
  77. int m_nCameraMode; // current camera mode
  78. Vector m_vCamOrigin; //current camera origin
  79. QAngle m_aCamAngle; //current camera angle
  80. QAngle m_aSmoothedRoamingAngles;
  81. int m_iTarget1; // first tracked target or 0
  82. int m_iTarget2; // second tracked target or 0
  83. float m_flFOV; // current FOV
  84. float m_flOffset; // z-offset from target origin
  85. float m_flDistance; // distance to traget origin+offset
  86. float m_flLastDistance; // too smooth distance
  87. float m_flTheta; // view angle horizontal
  88. float m_flPhi; // view angle vertical
  89. float m_flInertia; // camera inertia 0..100
  90. float m_flLastAngleUpdateTime;
  91. bool m_bEntityPacketReceived; // true after a new packet was received
  92. int m_nNumSpectators;
  93. char m_szTitleText[64];
  94. CUserCmd m_LastCmd;
  95. Vector m_vecVelocity;
  96. enum Dir_t
  97. {
  98. DIR_FWD,
  99. DIR_BACK,
  100. DIR_LEFT,
  101. DIR_RIGHT,
  102. DIR_UP,
  103. DIR_DOWN,
  104. NUM_DIRS
  105. };
  106. ButtonCode_t m_aMovementButtons[NUM_DIRS];
  107. float m_flNoiseSample;
  108. };
  109. //-----------------------------------------------------------------------------
  110. C_ReplayCamera *ReplayCamera();
  111. //-----------------------------------------------------------------------------
  112. #define FREE_CAM_ACCEL_MIN 1.1f
  113. #define FREE_CAM_ACCEL_MAX 10.0f
  114. #define FREE_CAM_SPEED_MIN 0.1f
  115. #define FREE_CAM_SPEED_MAX 20.0f
  116. #define FREE_CAM_FOV_MIN 10.0f
  117. #define FREE_CAM_FOV_MAX 130.0f
  118. #define FREE_CAM_ROT_FILTER_MIN 30.0f
  119. #define FREE_CAM_ROT_FILTER_MAX 5.0f
  120. #define FREE_CAM_SHAKE_SPEED_MIN 0.1f
  121. #define FREE_CAM_SHAKE_SPEED_MAX 15.0f
  122. #define FREE_CAM_SHAKE_AMOUNT_MIN 0.0f
  123. #define FREE_CAM_SHAKE_AMOUNT_MAX 35.0f
  124. #define FREE_CAM_SHAKE_DIR_MIN -1.0f
  125. #define FREE_CAM_SHAKE_DIR_MAX 1.0f
  126. //-----------------------------------------------------------------------------
  127. #endif // REPLAYCAMERA_H
  128. #endif