Counter Strike : Global Offensive Source Code
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.

128 lines
4.4 KiB

  1. //========= Copyright � 1996-2005, Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. //=============================================================================//
  6. #ifndef HLTVCAMERA_H
  7. #define HLTVCAMERA_H
  8. #ifdef _WIN32
  9. #pragma once
  10. #endif
  11. #include "GameEventListener.h"
  12. class C_HLTVCamera : CGameEventListener
  13. {
  14. public:
  15. C_HLTVCamera();
  16. virtual ~C_HLTVCamera();
  17. enum AutodirectorState_t
  18. {
  19. AUTODIRECTOR_ON = 0,
  20. AUTODIRECTOR_OFF,
  21. AUTODIRECTOR_PAUSED
  22. };
  23. void Init();
  24. void Reset();
  25. void Update();
  26. void CalcView(CViewSetup *pSetup);
  27. void FireGameEvent( IGameEvent *event );
  28. void SetMode(int iMode);
  29. void SetChaseCamParams( float flOffset, float flDistance, float flTheta, float flPhi );
  30. void SpecNextPlayer( bool bInverse );
  31. void SpecNamedPlayer( const char *szPlayerName );
  32. void SpecPlayerByIndex( int iIndex );
  33. void SpecPlayerByAccountID( const char *pszSteamID );
  34. void ToggleChaseAsFirstPerson();
  35. bool IsPVSLocked();
  36. bool HasCameraMan() { return ( m_iCameraMan != 0 ); }
  37. void SetAutoDirector( AutodirectorState_t eState );
  38. AutodirectorState_t AutoDirectorState() const;
  39. bool IsAutoDirectorOn() const;
  40. int GetMode(); // returns current camera mode
  41. C_BaseEntity *GetPrimaryTarget(); // return primary target
  42. void SetPrimaryTarget( int nEntity); // set the primary obs target
  43. C_BasePlayer *GetCameraMan(); // return camera entity if any
  44. Vector GetCameraPosition() { return m_vCamOrigin; }
  45. int GetCurrentOrLastTarget() { return (m_iTarget1 != 0) ? m_iTarget1 : m_iLastTarget1; }
  46. int GetCurrentTargetEntindex() { return m_iTarget1; }
  47. void SetWatchingGrenade( C_BaseEntity *pGrenade, bool bWatching );
  48. bool IsWatchingGrenade( void ) { return m_bIsFollowingGrenade; }
  49. void CreateMove(CUserCmd *cmd);
  50. void FixupMovmentParents();
  51. void PostEntityPacketReceived();
  52. const char* GetTitleText() { return m_szTitleText; }
  53. int GetNumSpectators() { return m_nNumSpectators; }
  54. float GetIdealOverviewScale( void ) { return m_flIdealOverviewScale; }
  55. void SpecCameraGotoPos( Vector vecPos, QAngle angAngle, int nPlayerIndex = 0 );
  56. void SpecCameraLerptoPos( const Vector &origin, const QAngle &angles, int nPlayerIndex = 0, float flTime = 0.0f );
  57. protected:
  58. void CalcChaseCamView( Vector& eyeOrigin, QAngle& eyeAngles, float& fov );
  59. void CalcFixedView( Vector& eyeOrigin, QAngle& eyeAngles, float& fov );
  60. void CalcInEyeCamView( Vector& eyeOrigin, QAngle& eyeAngles, float& fov );
  61. void CalcRoamingView(Vector& eyeOrigin, QAngle& eyeAngles, float& fov);
  62. void CalcChaseOverview( CViewSetup &pSetup );
  63. Vector CalcIdealOverviewPosition( Vector vecStartPos, Vector vOldOverviewPos );
  64. //void CalcOverview( CViewSetup *pSetup );
  65. void SmoothCameraAngle( QAngle& targetAngle );
  66. void SetCameraAngle( QAngle& targetAngle );
  67. void Accelerate( Vector& wishdir, float wishspeed, float accel );
  68. int m_nCameraMode; // current camera mode
  69. int m_iCameraMan; // camera man entindex or 0
  70. Vector m_vCamOrigin; //current camera origin
  71. Vector m_vLastGrenadeVelocity; //current camera origin
  72. float m_flLastGrenadeVelocityUpdate;
  73. QAngle m_aCamAngle; //current camera angle
  74. int m_iTarget1; // first tracked target or 0
  75. int m_iLastTarget1; // the last target before we switched
  76. int m_iTarget2; // second tracked target or 0
  77. float m_flFOV; // current FOV
  78. float m_flOffset; // z-offset from target origin
  79. float m_flDistance; // distance to traget origin+offset
  80. float m_flLastDistance; // too smooth distance
  81. float m_flTheta; // view angle horizontal
  82. float m_flPhi; // view angle vertical
  83. float m_flInertia; // camera inertia 0..100
  84. float m_flLastAngleUpdateTime;
  85. bool m_bEntityPacketReceived; // true after a new packet was received
  86. int m_nNumSpectators;
  87. char m_szTitleText[64];
  88. CUserCmd m_LastCmd;
  89. Vector m_vecVelocity;
  90. float m_flAutodirectorPausedTime; // negative if autodirector is not paused
  91. float m_flIdealOverviewScale;
  92. Vector m_vOldOverviewPos;
  93. Vector m_vIdealOverviewPos;
  94. float m_flLastCamZPos;
  95. float m_flNextIdealOverviewPosUpdate;
  96. bool m_bIsFollowingGrenade;
  97. bool m_bIsSpecLerping;
  98. float m_flSpecLerpTime;
  99. float m_flSpecLerpEndTime;
  100. Vector m_vecSpecLerpIdealPos;
  101. QAngle m_angSpecLerpIdealAng;
  102. Vector m_vecSpecLerpOldPos;
  103. QAngle m_angSpecLerpOldAng;
  104. float m_flObserverChaseApproach;
  105. Vector m_vecObserverEyeDirPrevious;
  106. };
  107. extern C_HLTVCamera *HLTVCamera(); // get Singleton
  108. #endif // HLTVCAMERA_H