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.

129 lines
3.6 KiB

  1. //========= Copyright � 1996-2005, Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. //=============================================================================//
  6. #ifndef MAPAXISHANDLE_H
  7. #define MAPAXISHANDLE_H
  8. #ifdef _WIN32
  9. #pragma once
  10. #endif
  11. #include "MapClass.h"
  12. #include "MapPointHandle.h"
  13. #include "ToolInterface.h"
  14. #include "MapPointHandle.h"
  15. #include "mapview.h"
  16. class CHelperInfo;
  17. class CRender2D;
  18. class CRender3D;
  19. class CToolAxisHandle;
  20. #define MAX_KEYNAME_SIZE 32
  21. class CMapAxisHandle : public CMapHelper
  22. {
  23. friend CToolAxisHandle;
  24. public:
  25. DECLARE_MAPCLASS(CMapAxisHandle, CMapHelper)
  26. //
  27. // Factory for building from a list of string parameters.
  28. //
  29. static CMapClass *Create(CHelperInfo *pInfo, CMapEntity *pParent);
  30. //
  31. // Construction/destruction:
  32. //
  33. CMapAxisHandle();
  34. CMapAxisHandle(const char *pszKey);
  35. ~CMapAxisHandle();
  36. inline void GetEndPoint(Vector &vecPos, int nPointIndex);
  37. void UpdateEndPoint(Vector &vecPos, int nPointIndex);
  38. inline int GetEndPointRadius();
  39. //
  40. // CMapClass implementation.
  41. //
  42. void CalcBounds(BOOL bFullUpdate = FALSE);
  43. virtual CMapClass *Copy(bool bUpdateDependencies);
  44. virtual CMapClass *CopyFrom(CMapClass *pFrom, bool bUpdateDependencies);
  45. virtual void Render2D(CRender2D *pRender);
  46. virtual int SerializeRMF(std::fstream &File, BOOL bRMF);
  47. virtual int SerializeMAP(std::fstream &File, BOOL bRMF);
  48. // Overridden to chain down to our endpoints, which are not children.
  49. void SetOrigin(Vector &vecOrigin);
  50. // Overridden to chain down to our endpoints, which are not children.
  51. virtual SelectionState_t SetSelectionState(SelectionState_t eSelectionState);
  52. // Overridden because axis helpers don't take the color of their parent entity.
  53. virtual void SetRenderColor(unsigned char red, unsigned char green, unsigned char blue);
  54. virtual void SetRenderColor(color32 rgbColor);
  55. virtual bool HitTest2D(CMapView2D *pView, const Vector2D &point, HitInfo_t &HitData);
  56. virtual CBaseTool *GetToolObject(int nHitData, bool bAttachObject);
  57. virtual bool IsVisualElement(void) { return(false); } // Only visible if our parent is selected.
  58. virtual bool IsClutter(void) const { return true; }
  59. virtual bool CanBeCulledByCordon() const { return false; } // We don't hide unless our parent hides.
  60. virtual const char* GetDescription() { return("Axis helper"); }
  61. virtual void OnAddToWorld(CMapWorld *pWorld);
  62. virtual void OnParentKeyChanged(const char *key, const char *value);
  63. virtual void PostloadWorld(CMapWorld *pWorld);
  64. virtual void Render3D(CRender3D *pRender);
  65. protected:
  66. SelectionState_t SetSelectionState(SelectionState_t eSelectionState, int nHandle);
  67. void UpdateParentKey(void);
  68. // Overriden to transform our endpoints, which are not children.
  69. virtual void DoTransform(const VMatrix &matrix);
  70. void Initialize(void);
  71. CMapPointHandle m_Point[2]; // The two endpoints of the axis.
  72. char m_szKeyName[MAX_KEYNAME_SIZE];
  73. };
  74. //-----------------------------------------------------------------------------
  75. // Purpose: Returns the position of the given endpoint.
  76. // Input : vecPos - Receives the position.
  77. // nPointIndex - Endpoint index [0,1].
  78. //-----------------------------------------------------------------------------
  79. inline void CMapAxisHandle::GetEndPoint(Vector &vecPos, int nPointIndex)
  80. {
  81. m_Point[nPointIndex].GetOrigin(vecPos);
  82. }
  83. //-----------------------------------------------------------------------------
  84. // Purpose: Returns the radius to use in rendering the endpoints.
  85. //-----------------------------------------------------------------------------
  86. inline int CMapAxisHandle::GetEndPointRadius()
  87. {
  88. return m_Point[0].GetRadius();
  89. }
  90. #endif // MAPAXISHANDLE_H