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.

94 lines
3.5 KiB

  1. //========= Copyright � 1996-2005, Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. // $NoKeywords: $
  6. //=============================================================================//
  7. #ifndef TOOL3D_H
  8. #define TOOL3D_H
  9. #ifdef _WIN32
  10. #pragma once
  11. #endif
  12. #include "MapAtom.h"
  13. #include "ToolInterface.h"
  14. class CMapDoc;
  15. class CMapView;
  16. class CRender;
  17. #define inrange(a,minv,maxv) ((a) >= (minv) && (a) <= (maxv))
  18. #pragma warning(disable: 4244)
  19. #define DRAG_THRESHHOLD 2
  20. #define HANDLE_OFFSET 6
  21. class Tool3D : public CBaseTool
  22. {
  23. public:
  24. Tool3D(void);
  25. virtual int HitTest(CMapView *pView, const Vector2D &ptClient, bool bTestHandles = false) = 0;
  26. int HitTest(CMapView *pView, const Vector &ptWorld, bool bTestHandles = false);
  27. bool HitRect(CMapView *pView, const Vector2D &ptHit, const Vector &vecCenter, int extent );
  28. int GetTransformationAxis(); // 0,1,2 or -1 if translation is not axis aligned
  29. virtual unsigned int GetConstraints(unsigned int nKeyFlags);
  30. // helper functions when transforming from a map view input
  31. void StartTranslation( CMapView *pView, const Vector2D &vClickPoint, bool bUseDefaultPlane = true );
  32. void ProjectTranslation( CMapView *pView, const Vector2D &vPoint, Vector &vTransform, int nFlags = 0);
  33. void ProjectOnTranslationPlane( const Vector &vWorld, Vector &vTransform, int nFlags = 0 );
  34. void SetTransformationPlane(const Vector &vOrigin, const Vector &vHorz, const Vector &vVert, const Vector &vNormal);
  35. bool UpdateTranslation(CMapView *pView, const Vector2D &vPoint, UINT nFlags);
  36. bool IsTranslating(void) { return m_bIsTranslating; }
  37. virtual bool UpdateTranslation(const Vector &vUpdate, UINT flags);
  38. virtual void TranslatePoint(Vector& vPos);
  39. virtual void FinishTranslation(bool bSave);
  40. virtual bool OnLMouseDown2D( CMapView2D *pView, UINT nFlags, const Vector2D &vPoint );
  41. virtual bool OnLMouseUp2D( CMapView2D *pView, UINT nFlags, const Vector2D &vPoint );
  42. virtual bool OnRMouseDown2D( CMapView2D *pView, UINT nFlags, const Vector2D &vPoint );
  43. virtual bool OnRMouseUp2D( CMapView2D *pView, UINT nFlags, const Vector2D &vPoint );
  44. virtual bool OnMouseMove2D( CMapView2D *pView, UINT nFlags, const Vector2D &vPoint );
  45. virtual bool OnLMouseDown3D( CMapView3D *pView, UINT nFlags, const Vector2D &vPoint );
  46. virtual bool OnLMouseUp3D( CMapView3D *pView, UINT nFlags, const Vector2D &vPoint );
  47. virtual bool OnRMouseDown3D( CMapView3D *pView, UINT nFlags, const Vector2D &vPoint );
  48. virtual bool OnRMouseUp3D( CMapView3D *pView, UINT nFlags, const Vector2D &vPoint );
  49. virtual bool OnMouseMove3D( CMapView3D *pView, UINT nFlags, const Vector2D &vPoint );
  50. void RenderTranslationPlane(CRender *pRender);
  51. protected:
  52. enum
  53. {
  54. MOUSE_LEFT = 0,
  55. MOUSE_RIGHT = 1,
  56. };
  57. // each translation can use a translation plane
  58. Vector m_vPlaneOrigin; // transformation plane origin
  59. Vector m_vPlaneNormal; // transformation plane normal
  60. Vector m_vPlaneHorz; // transformation plane horizontal axis
  61. Vector m_vPlaneVert; // transformation plane vertical axis
  62. Vector m_vTranslation; // relative translation vector on the translation plane
  63. Vector m_vTranslationStart; // translation start point on translation plane
  64. bool m_bIsTranslating; // true while translation
  65. // 0 = left, 1 = right button
  66. bool m_bMouseDown[2]; // True if mouse button is down, false if not.
  67. bool m_bMouseDragged[2]; // Have they dragged the mouse with button down?
  68. Vector2D m_vMouseStart[2]; // Client pos at which last mouse was pressed.
  69. Vector2D m_vMousePos; // last know mouse pos
  70. };
  71. #endif // TOOL3D_H