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.

74 lines
1.7 KiB

  1. //========= Copyright � 1996-2005, Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. //=============================================================================//
  6. #include "utlvector.h"
  7. #define VIEWANIM_RELATIVE (1<<0) // angles in keyframe are relative, add anim to current angles
  8. #define VIEWANIM_IGNORE_X (1<<1) // ignore the x component of this animation
  9. #define VIEWANIM_IGNORE_Y (1<<2) // ditto for y
  10. #define VIEWANIM_IGNORE_Z (1<<3) // ditto for z
  11. #define QAngleToVector(a,v) { v[0] = a[0]; v[1] = a[1]; v[2] = a[2]; }
  12. class CViewAngleKeyFrame
  13. {
  14. public:
  15. CViewAngleKeyFrame( QAngle vecAngles, float flTime, int iFlags )
  16. {
  17. m_vecAngles = vecAngles;
  18. m_flTime = flTime;
  19. m_iFlags = iFlags;
  20. }
  21. // the target angles for this keyframe in the view angle animation
  22. QAngle m_vecAngles;
  23. // time position of this keyframe
  24. float m_flTime;
  25. int m_iFlags;
  26. };
  27. typedef void (*ViewAnimCompleteCallback)( void );
  28. class CViewAngleAnimation : public C_BaseEntity
  29. {
  30. public:
  31. CViewAngleAnimation();
  32. ~CViewAngleAnimation();
  33. virtual void Spawn();
  34. void DeleteKeyFrames();
  35. void LoadViewAnimFile( const char *pKeyFrameFileName );
  36. void SaveAsAnimFile( const char *pKeyFrameFileName );
  37. void AddKeyFrame( CViewAngleKeyFrame *pKeyFrame );
  38. bool IsFinished( void );
  39. void RunAnimation( QAngle angles );
  40. void ClientThink();
  41. void SetAnimCompleteCallback( ViewAnimCompleteCallback pFunc )
  42. {
  43. m_pAnimCompleteCallback = pFunc;
  44. }
  45. private:
  46. void SetAngles( QAngle vecCalculatedAngles );
  47. float m_flAnimStartTime; // time this animation started
  48. bool m_bFinished;
  49. CUtlVector<CViewAngleKeyFrame *> m_KeyFrames;
  50. QAngle m_vecBaseAngles;
  51. int m_iFlags;
  52. ViewAnimCompleteCallback m_pAnimCompleteCallback;
  53. };