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.

215 lines
6.2 KiB

  1. //========= Copyright � 1996-2005, Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. // $NoKeywords: $
  6. //=============================================================================//
  7. #ifndef MAPVIEW3D_H
  8. #define MAPVIEW3D_H
  9. #ifdef _WIN32
  10. #pragma once
  11. #endif
  12. #include "Keyboard.h"
  13. #include "MapView.h"
  14. #include "Render3D.h"
  15. #include "camera.h"
  16. #include "mapface.h"
  17. namespace vgui
  18. {
  19. typedef unsigned long HCursor;
  20. }
  21. class CMapAtom;
  22. class CRender3D;
  23. class CCamera;
  24. class CTitleWnd;
  25. class CMapDecal;
  26. struct PLANE;
  27. class CMapView3D : public CView, public CMapView
  28. {
  29. protected:
  30. CMapView3D();
  31. DECLARE_DYNCREATE(CMapView3D)
  32. public:
  33. virtual LRESULT WindowProc( UINT message, WPARAM wParam, LPARAM lParam );
  34. enum
  35. {
  36. updNothing = 0x00,
  37. updMorphOnly = 0x01,
  38. updAll = 0x02,
  39. updRedrawNow = 0x04
  40. };
  41. void SetCamera(const Vector &vecPos, const Vector &vecLookAt);
  42. //
  43. // CMapView interface:
  44. //
  45. void RenderView();
  46. bool ShouldRender();
  47. void ActivateView(bool bActivate);
  48. void UpdateView(int nFlags);
  49. CView *GetViewWnd() { return (CView*)this; }
  50. CMapDoc *GetMapDoc() { return (CMapDoc*)m_pDocument;}
  51. void WorldToClient(Vector2D &ptClient, const Vector &vecWorld);
  52. void ClientToWorld(Vector &vecWorld, const Vector2D &ptClient);
  53. bool HitTest( const Vector2D &vPoint, const Vector& mins, const Vector& maxs );
  54. void GetBestTransformPlane( Vector &horzAxis, Vector &vertAxis, Vector &thirdAxis);
  55. void GetHitPos(const Vector2D &point, PLANE &plane, Vector &pos);
  56. void ProcessInput(void);
  57. void UpdateStatusBar();
  58. // Called by the camera tool to control the camera.
  59. void EnableMouseLook(bool bEnable);
  60. void EnableRotating(bool bEnable);
  61. void EnableStrafing(bool bEnable);
  62. void UpdateCameraVariables(void);
  63. void MoveForward(float flDistance);
  64. void MoveUp(float flDistance);
  65. void MoveRight(float flDistance);
  66. void Pitch(float flDegrees);
  67. void Yaw(float flDegrees);
  68. void BeginPick(void);
  69. void EndPick(void);
  70. DrawType_t GetDrawType() { return m_eDrawType; }
  71. void SetDrawType(DrawType_t eDrawType);
  72. int ObjectsAt( const Vector2D &point, HitInfo_t *pObjects, int nMaxObjects, unsigned int nFlags = 0 );
  73. CMapClass *NearestObjectAt( const Vector2D &point, ULONG &ulFace, unsigned int nFlags = 0, VMatrix *pLocalMatrix = NULL );
  74. void RenderPreloadObject(CMapAtom *pObject);
  75. void SetCursor( vgui::HCursor hCursor );
  76. // Release all video memory
  77. void ReleaseVideoMemory();
  78. void Foundry_OnLButtonDown( int x, int y );
  79. // ClassWizard generated virtual function overrides
  80. //{{AFX_VIRTUAL(CMapView3D)
  81. public:
  82. virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
  83. virtual BOOL DestroyWindow();
  84. virtual void OnInitialUpdate();
  85. protected:
  86. virtual BOOL OnPreparePrinting(CPrintInfo* pInfo);
  87. //}}AFX_VIRTUAL
  88. public:
  89. virtual ~CMapView3D();
  90. #ifdef _DEBUG
  91. virtual void AssertValid() const;
  92. virtual void Dump(CDumpContext& dc) const;
  93. #endif
  94. void RenderView2( bool bRenderingOverEngine );
  95. private:
  96. void Render( bool bRenderingOverEngine );
  97. void EnableCrosshair(bool bEnable);
  98. bool ControlCamera(const CPoint &point);
  99. //
  100. // Keyboard processing.
  101. //
  102. void InitializeKeyMap(void);
  103. void ProcessMouse(void);
  104. void ProcessKeys(float fElapsedTime);
  105. void ProcessMovementKeys(float fElapsedTime);
  106. float GetKeyScale(unsigned int uKeyState);
  107. // Radius culling
  108. void ProcessCulling( void );
  109. enum
  110. {
  111. MVTIMER_PICKNEXT = 0
  112. };
  113. bool m_bMouseLook; // Set to true when we override the mouse processing to use mouselook.
  114. bool m_bStrafing;
  115. bool m_bRotating;
  116. CPoint m_ptLastMouseMovement; // Last position used for tracking the mouse for camera control.
  117. DWORD m_dwTimeLastSample; // Used for calculating rendering framerate.
  118. DWORD m_dwTimeLastInputSample; // Used for framerate-independent input processing.
  119. float m_fForwardSpeed; // Current forward speed, in world units per second.
  120. float m_fStrafeSpeed; // Current side-to-side speed, in world units per second.
  121. float m_fVerticalSpeed; // Current up-down speed, in world units per second.
  122. float m_fForwardSpeedMax; // Maximum forward speed, in world units per second.
  123. float m_fStrafeSpeedMax; // Maximum side-to-side speed, in world units per second.
  124. float m_fVerticalSpeedMax; // Maximum up-down speed, in world units per second.
  125. float m_fForwardAcceleration; // Forward acceleration, in world units per second squared.
  126. float m_fStrafeAcceleration; // Side-to-side acceleration, in world units per second squared.
  127. float m_fVerticalAcceleration; // Up-down acceleration, in world units per second squared.
  128. DrawType_t m_eDrawType; // How we render - wireframe, flat, textured, lightmap grid, or lighting preview.
  129. bool m_bLightingPreview;
  130. CTitleWnd *m_pwndTitle; // Title window.
  131. CRender3D *m_pRender; // Performs the 3D rendering in our window.
  132. CKeyboard m_Keyboard; // Handles binding of keys and mouse buttons to logical functions.
  133. bool m_bCameraPosChanged;
  134. bool m_bClippingChanged;
  135. //{{AFX_MSG(CMapView3D)
  136. protected:
  137. afx_msg void OnTimer(UINT nIDEvent);
  138. afx_msg void OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags);
  139. afx_msg void OnKeyUp(UINT nChar, UINT nRepCnt, UINT nFlags);
  140. afx_msg void OnSize(UINT nType, int cx, int cy);
  141. afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
  142. afx_msg void OnLButtonUp(UINT nFlags, CPoint point);
  143. afx_msg void OnLButtonDblClk(UINT nFlags, CPoint point);
  144. afx_msg void OnRButtonDown( UINT nFlags, CPoint point );
  145. afx_msg BOOL OnMouseWheel(UINT nFlags, short zDelta, CPoint point);
  146. afx_msg void OnRButtonUp(UINT nFlags, CPoint point);
  147. afx_msg void OnContextMenu(CWnd *pWnd, CPoint point);
  148. afx_msg void OnChar(UINT nChar, UINT nRepCnt, UINT nFlags);
  149. afx_msg void OnSetFocus(CWnd* pOldWnd);
  150. afx_msg void OnDraw(CDC *pDC);
  151. afx_msg BOOL OnFaceAlign(UINT uCmd);
  152. afx_msg BOOL OnFaceJustify(UINT uCmd);
  153. afx_msg void OnView3dWireframe(void);
  154. afx_msg void OnView3dPolygon(void);
  155. afx_msg void OnView3dTextured(void);
  156. afx_msg void OnView3dLightmapGrid(void);
  157. afx_msg void OnView3dLightingPreview(void);
  158. afx_msg void OnView3dLightingPreviewRayTraced(void);
  159. //afx_msg void OnView3dEngine(void);
  160. afx_msg void OnMouseMove(UINT nFlags, CPoint point);
  161. afx_msg void OnKillFocus(CWnd *pNewWnd);
  162. afx_msg void OnNcPaint( );
  163. //}}AFX_MSG
  164. DECLARE_MESSAGE_MAP()
  165. };
  166. #endif // MAPVIEW3D_H