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
3.4 KiB

  1. //====== Copyright � 1996-2004, Valve Corporation, All rights reserved. =======
  2. //
  3. // Purpose:
  4. //
  5. //=============================================================================
  6. #ifndef MANIPULATOR_H
  7. #define MANIPULATOR_H
  8. #ifdef _WIN32
  9. #pragma once
  10. #endif
  11. #include "vgui_controls/Panel.h"
  12. #include "mathlib/vector.h"
  13. //-----------------------------------------------------------------------------
  14. // Manipulator interface
  15. //-----------------------------------------------------------------------------
  16. class IManipulator
  17. {
  18. public:
  19. virtual void OnBeginManipulation( void ) = 0;
  20. virtual void OnAcceptManipulation( void ) = 0;
  21. virtual void OnCancelManipulation( void ) = 0;
  22. virtual void OnTick( void ) = 0;
  23. virtual void OnCursorMoved( int x, int y ) = 0;
  24. virtual void OnMousePressed( vgui::MouseCode code, int x, int y ) = 0;
  25. virtual void OnMouseReleased( vgui::MouseCode code, int x, int y ) = 0;
  26. virtual void OnMouseWheeled( int delta ) = 0;
  27. virtual void SetViewportSize( int w, int h ) = 0;
  28. };
  29. //-----------------------------------------------------------------------------
  30. // Base class helper for implementing manipulators
  31. //-----------------------------------------------------------------------------
  32. class CBaseManipulator : public IManipulator
  33. {
  34. public:
  35. CBaseManipulator()
  36. {
  37. m_nViewport[ 0 ] = m_nViewport[ 1 ] = 0;
  38. }
  39. virtual void OnTick( void ) {};
  40. virtual void OnBeginManipulation( void ) {}
  41. virtual void OnAcceptManipulation( void ) {};
  42. virtual void OnCancelManipulation( void ) {};
  43. virtual void OnCursorMoved( int x, int y ) {};
  44. virtual void OnMousePressed( vgui::MouseCode code, int x, int y ) {};
  45. virtual void OnMouseReleased( vgui::MouseCode code, int x, int y ) {};
  46. virtual void OnMouseWheeled( int delta ) {};
  47. virtual void SetViewportSize( int w, int h )
  48. {
  49. m_nViewport[ 0 ] = w;
  50. m_nViewport[ 1 ] = h;
  51. }
  52. protected:
  53. int m_nViewport[ 2 ];
  54. };
  55. //-----------------------------------------------------------------------------
  56. // Base class for manipulators which operate on transforms
  57. //-----------------------------------------------------------------------------
  58. class CTransformManipulator : public CBaseManipulator
  59. {
  60. public:
  61. CTransformManipulator( matrix3x4_t *pTransform );
  62. void SetTransform( matrix3x4_t *transform );
  63. matrix3x4_t *GetTransform();
  64. protected:
  65. matrix3x4_t *m_pTransform;
  66. };
  67. //-----------------------------------------------------------------------------
  68. // Standard maya-like transform manipulator
  69. //-----------------------------------------------------------------------------
  70. class CPotteryWheelManip : public CTransformManipulator
  71. {
  72. public:
  73. CPotteryWheelManip( matrix3x4_t *pTransform );
  74. virtual void OnBeginManipulation( void );
  75. virtual void OnAcceptManipulation( void );
  76. virtual void OnCancelManipulation( void );
  77. virtual void OnTick( void );
  78. virtual void OnCursorMoved( int x, int y );
  79. virtual void OnMousePressed( vgui::MouseCode code, int x, int y );
  80. virtual void OnMouseReleased( vgui::MouseCode code, int x, int y );
  81. virtual void OnMouseWheeled( int delta );
  82. // Sets the zoom level
  83. void SetZoom( float flZoom );
  84. protected:
  85. int m_lastx, m_lasty;
  86. float m_zoom;
  87. float m_altitude, m_azimuth;
  88. //vec3 m_lookat
  89. float m_prevZoom;
  90. float m_prevAltitude, m_prevAzimuth;
  91. float m_flLastMouseTime;
  92. float m_flLastTickTime;
  93. float m_flSpin;
  94. bool m_bSpin;
  95. void UpdateTransform( void );
  96. void UpdateZoom( float delta );
  97. };
  98. #endif // MANIPULATOR_H