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.

113 lines
3.0 KiB

  1. //===== Copyright � 1996-2005, Valve Corporation, All rights reserved. ======//
  2. //
  3. // Purpose: Data and functionality common to 2D and 3D views.
  4. //
  5. //===========================================================================//
  6. #ifndef MAPVIEW_H
  7. #define MAPVIEW_H
  8. #ifdef _WIN32
  9. #pragma once
  10. #endif
  11. class CWnd;
  12. class CView;
  13. class CMapAtom;
  14. class CMapClass;
  15. class CMapDoc;
  16. class CCamera;
  17. class CToolManager;
  18. #include "mathlib/vector.h"
  19. //
  20. // Maximum number of hits that can be returned by ObjectsAt.
  21. //
  22. #define MAX_PICK_HITS 512
  23. typedef struct HitInfo_s HitInfo_t;
  24. enum DrawType_t
  25. {
  26. VIEW_INVALID = -1,
  27. VIEW2D_XY = 0,
  28. VIEW2D_YZ,
  29. VIEW2D_XZ,
  30. VIEW3D_WIREFRAME,
  31. VIEW3D_POLYGON,
  32. VIEW3D_TEXTURED,
  33. VIEW3D_LIGHTMAP_GRID,
  34. VIEW3D_SMOOTHING_GROUP,
  35. VIEW3D_ENGINE,
  36. VIEW3D_TEXTURED_SHADED,
  37. VIEW_LOGICAL,
  38. VIEW3D_LIGHTING_PREVIEW2,
  39. VIEW3D_LIGHTING_PREVIEW_RAYTRACED,
  40. // Must be last!
  41. VIEW_TYPE_LAST
  42. };
  43. #define FLAG_OBJECTS_AT_RESOLVE_INSTANCES 0x0000001
  44. #define FLAG_OBJECTS_AT_ONLY_SOLIDS 0x0000002
  45. class CMapView
  46. {
  47. public:
  48. CMapView(void);
  49. virtual void ActivateView(bool bActivate);
  50. inline bool IsActive(void) { return(m_bActive); }
  51. bool IsOrthographic();
  52. virtual void SetDrawType(DrawType_t eDrawType) { m_eDrawType = eDrawType; }
  53. virtual DrawType_t GetDrawType(void) { return m_eDrawType; }
  54. // virtual CMapClass *ObjectAt(POINT ptClient, ULONG &ulFace) = 0;
  55. virtual void ProcessInput() = 0; // do input update
  56. virtual void RenderView() = 0; // render view NOW, called usually by framework
  57. virtual void UpdateView( int nFlags ); // something changed, render this view with the next frame
  58. virtual bool ShouldRender(); // let view decide if it wants to render or not
  59. virtual CWnd *GetViewWnd() = 0;
  60. virtual CMapDoc *GetMapDoc() = 0;
  61. // get axis we look along
  62. virtual const Vector &GetViewAxis();
  63. void SetCamera(const Vector &vecPos, const Vector &vecLookAt);
  64. CCamera *GetCamera() { return m_pCamera; }
  65. // convert client view space to map world coordinates
  66. // general rule: float = world, int = client view
  67. virtual void WorldToClient(Vector2D &ptClient, const Vector &vWorld) = 0;
  68. virtual void ClientToWorld(Vector &vWorld, const Vector2D &vClient ) = 0;
  69. virtual void BuildRay( const Vector2D &ptClient, Vector& vStart, Vector& vEnd );
  70. virtual int ObjectsAt( const Vector2D &ptClient, HitInfo_t *pObjects, int nMaxObjects, unsigned int nFlags = 0 ) = 0;
  71. virtual bool HitTest( const Vector2D &ptClient, const Vector& mins, const Vector& maxs ) = 0;
  72. virtual void GetBestTransformPlane( Vector &horzAxis, Vector &vertAxis, Vector &thirdAxis) = 0;
  73. bool SelectAt(const Vector2D &ptClient, bool bMakeFirst, bool bFace);
  74. // protected:
  75. bool m_bActive;
  76. bool m_bUpdateView;
  77. DrawType_t m_eDrawType;
  78. unsigned int m_dwTimeLastRender;
  79. CCamera *m_pCamera; // Defines the camera position and settings for this view.
  80. CToolManager *m_pToolManager; // tool manager for this view
  81. int m_nRenderedFrames;
  82. int m_nLastRaytracedBitmapRenderTimeStamp;
  83. };
  84. #endif // MAPVIEW_H