Team Fortress 2 Source Code as on 22/4/2020
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.

209 lines
6.0 KiB

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