CamWnd.h 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206
  1. /*
  2. ===========================================================================
  3. Doom 3 GPL Source Code
  4. Copyright (C) 1999-2011 id Software LLC, a ZeniMax Media company.
  5. This file is part of the Doom 3 GPL Source Code (?Doom 3 Source Code?).
  6. Doom 3 Source Code is free software: you can redistribute it and/or modify
  7. it under the terms of the GNU General Public License as published by
  8. the Free Software Foundation, either version 3 of the License, or
  9. (at your option) any later version.
  10. Doom 3 Source Code is distributed in the hope that it will be useful,
  11. but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. GNU General Public License for more details.
  14. You should have received a copy of the GNU General Public License
  15. along with Doom 3 Source Code. If not, see <http://www.gnu.org/licenses/>.
  16. In addition, the Doom 3 Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 Source Code. If not, please request a copy in writing from id Software at the address below.
  17. If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
  18. ===========================================================================
  19. */
  20. #if !defined(AFX_CAMWND_H__44B4BA03_781B_11D1_B53C_00AA00A410FC__INCLUDED_)
  21. #define AFX_CAMWND_H__44B4BA03_781B_11D1_B53C_00AA00A410FC__INCLUDED_
  22. #if _MSC_VER >= 1000
  23. #pragma once
  24. #endif // _MSC_VER >= 1000
  25. typedef enum
  26. {
  27. cd_wire,
  28. cd_solid,
  29. cd_texture,
  30. cd_light,
  31. cd_blend
  32. } camera_draw_mode;
  33. typedef struct
  34. {
  35. int width, height;
  36. idVec3 origin;
  37. idAngles angles;
  38. camera_draw_mode draw_mode;
  39. idVec3 color; // background
  40. idVec3 forward, right, up; // move matrix
  41. idVec3 vup, vpn, vright; // view matrix
  42. } camera_t;
  43. /////////////////////////////////////////////////////////////////////////////
  44. // CCamWnd window
  45. class CXYWnd;
  46. class CCamWnd : public CWnd
  47. {
  48. DECLARE_DYNCREATE(CCamWnd);
  49. // Construction
  50. public:
  51. CCamWnd();
  52. // Attributes
  53. public:
  54. // Operations
  55. public:
  56. // Overrides
  57. // ClassWizard generated virtual function overrides
  58. //{{AFX_VIRTUAL(CCamWnd)
  59. protected:
  60. virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
  61. //}}AFX_VIRTUAL
  62. // Implementation
  63. public:
  64. void ShiftTexture_BrushPrimit(face_t *f, int x, int y);
  65. CXYWnd* m_pXYFriend;
  66. void SetXYFriend(CXYWnd* pWnd);
  67. virtual ~CCamWnd();
  68. camera_t& Camera(){return m_Camera;};
  69. void Cam_MouseControl(float dtime);
  70. void Cam_ChangeFloor(bool up);
  71. void BuildRendererState();
  72. void ToggleRenderMode();
  73. void ToggleRebuildMode();
  74. void ToggleEntityMode();
  75. void ToggleSelectMode();
  76. void ToggleAnimationMode();
  77. void ToggleSoundMode();
  78. void SetProjectionMatrix();
  79. void UpdateCameraView();
  80. void BuildEntityRenderState( entity_t *ent, bool update );
  81. bool GetRenderMode() {
  82. return renderMode;
  83. }
  84. bool GetRebuildMode() {
  85. return rebuildMode;
  86. }
  87. bool GetEntityMode() {
  88. return entityMode;
  89. }
  90. bool GetAnimationMode() {
  91. return animationMode;
  92. }
  93. bool GetSelectMode() {
  94. return selectMode;
  95. }
  96. bool GetSoundMode() {
  97. return soundMode;
  98. }
  99. bool UpdateRenderEntities();
  100. void MarkWorldDirty();
  101. void SetView( const idVec3 &origin, const idAngles &angles ) {
  102. m_Camera.origin = origin;
  103. m_Camera.angles = angles;
  104. }
  105. protected:
  106. void Cam_Init();
  107. void Cam_BuildMatrix();
  108. void Cam_PositionDrag();
  109. void Cam_MouseLook();
  110. void Cam_MouseDown(int x, int y, int buttons);
  111. void Cam_MouseUp (int x, int y, int buttons);
  112. void Cam_MouseMoved (int x, int y, int buttons);
  113. void InitCull();
  114. bool CullBrush (brush_t *b, bool cubicOnly);
  115. void Cam_Draw();
  116. void Cam_Render();
  117. // game renderer interaction
  118. qhandle_t worldModelDef;
  119. idRenderModel *worldModel; // createRawModel of the brush and patch geometry
  120. bool worldDirty;
  121. bool renderMode;
  122. bool rebuildMode;
  123. bool entityMode;
  124. bool selectMode;
  125. bool animationMode;
  126. bool soundMode;
  127. void FreeRendererState();
  128. void UpdateCaption();
  129. bool BuildBrushRenderData(brush_t *brush);
  130. void DrawEntityData();
  131. camera_t m_Camera;
  132. int m_nCambuttonstate;
  133. CPoint m_ptButton;
  134. CPoint m_ptCursor;
  135. CPoint m_ptLastCursor;
  136. face_t* m_pSide_select;
  137. idVec3 m_vCull1;
  138. idVec3 m_vCull2;
  139. int m_nCullv1[3];
  140. int m_nCullv2[3];
  141. bool m_bClipMode;
  142. idVec3 saveOrg;
  143. idAngles saveAng;
  144. bool saveValid;
  145. // Generated message map functions
  146. protected:
  147. void OriginalMouseDown(UINT nFlags, CPoint point);
  148. void OriginalMouseUp(UINT nFlags, CPoint point);
  149. //{{AFX_MSG(CCamWnd)
  150. afx_msg void OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags);
  151. afx_msg void OnPaint();
  152. afx_msg void OnDestroy();
  153. afx_msg void OnClose();
  154. afx_msg void OnMouseMove(UINT nFlags, CPoint point);
  155. afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
  156. afx_msg void OnLButtonUp(UINT nFlags, CPoint point);
  157. afx_msg void OnMButtonDown(UINT nFlags, CPoint point);
  158. afx_msg void OnMButtonUp(UINT nFlags, CPoint point);
  159. afx_msg void OnRButtonDown(UINT nFlags, CPoint point);
  160. afx_msg void OnRButtonUp(UINT nFlags, CPoint point);
  161. afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
  162. afx_msg void OnSize(UINT nType, int cx, int cy);
  163. afx_msg void OnKeyUp(UINT nChar, UINT nRepCnt, UINT nFlags);
  164. afx_msg void OnTimer(UINT nIDEvent);
  165. //}}AFX_MSG
  166. DECLARE_MESSAGE_MAP()
  167. };
  168. /////////////////////////////////////////////////////////////////////////////
  169. //{{AFX_INSERT_LOCATION}}
  170. // Microsoft Developer Studio will insert additional declarations immediately before the previous line.
  171. #endif // !defined(AFX_CAMWND_H__44B4BA03_781B_11D1_B53C_00AA00A410FC__INCLUDED_)