3DWindow.h
上传用户:fengshi120
上传日期:2014-07-17
资源大小:6155k
文件大小:4k
源码类别:

3D图形编程

开发平台:

C/C++

  1. #if !defined(AFX_3DWINDOWSMALL_H__147F5773_11F0_11D4_90C3_00AA00597E76__INCLUDED_)
  2. #define AFX_3DWINDOWSMALL_H__147F5773_11F0_11D4_90C3_00AA00597E76__INCLUDED_
  3. #if _MSC_VER > 1000
  4. #pragma once
  5. #endif // _MSC_VER > 1000
  6. // 3DWindow.h : header file
  7. #include <d3d9.h>
  8. #include <Dxerr9.h>
  9. #include "d3dutil.h"
  10. #include "FrameTimer.h"
  11. #include "D3DFont.h"
  12. #include "D3DFile.h"
  13. #define GUI_UPDATE_TIMER   70
  14. #define NUM_OF(ary_) (sizeof(ary_)/sizeof(ary_[0]))
  15. /////////////////////////////////////////////////////////////////////////////
  16. // C3DWindow window
  17. class C3DWindow : public CWnd
  18. {
  19. // Construction
  20. public:
  21. C3DWindow();
  22. // Attributes
  23. public:
  24. bool m_bOrthographic;
  25. LPDIRECT3D9 m_pD3D; // Used to create the D3DDevice
  26. LPDIRECT3DDEVICE9 m_pD3DDevice; // Our rendering device
  27. D3DXMATRIX m_matProj;
  28. D3DXMATRIX m_matProjT;
  29. D3DLIGHT9 m_light;// Description of the D3D light
  30. ID3DXMesh* m_pConeMesh[3];
  31. IDirect3DTexture9*      m_pTextureAxisLabelX;
  32. IDirect3DTexture9*      m_pTextureAxisLabelY;
  33. IDirect3DTexture9*      m_pTextureAxisLabelZ;
  34. LPDIRECT3DVERTEXBUFFER9 m_pPixelVB;
  35. float* m_pX;
  36. float* m_pY;
  37. float* m_pZ;
  38. Color* m_pC;
  39. int m_nPoints;
  40. float m_fScale;
  41. void RemovePixelVB(void);
  42. HRESULT ExportPixelVB(CString strFilename);
  43. bool m_bUsePoints;
  44. void ResetArcBall(void);
  45. void SetUpdateTimer(bool bState);
  46. int Start(bool bOrthographic);
  47. CRect m_rcClientRect;
  48. bool m_bRenderZAxis;
  49. CString m_strRegistry;
  50. D3DPRESENT_PARAMETERS m_d3dpp; 
  51. LPDIRECT3DVERTEXBUFFER9 m_pArcLineVB;
  52. void SetRegistryKey(CString strRegistry);
  53.     CD3DFont*               m_pFont;                // Font for drawing text
  54.     CD3DFont*               m_pFontLarge;                // Font for drawing big text
  55. HRESULT Render3DEnvironment(void);
  56. HRESULT RestoreDeviceObjects(void);
  57.     D3DSURFACE_DESC m_D3DsdBackBuffer;   // Surface desc of the backbuffer
  58.     CD3DArcBall m_ArcBall;          // mouse rotation utility
  59.     D3DXVECTOR3     m_vObjectCenter;    // Center of bounding sphere of object
  60.     FLOAT m_fObjectRadius;    // Radius of bounding sphere of object
  61.     D3DXMATRIX m_matWorld;
  62. HRESULT                 ReleaseD3DX();
  63.     HRESULT                 InitD3DX();
  64. HRESULT                 Render(void);
  65. INT_PTR m_GUITimerID;
  66. private:
  67. public:
  68. HRESULT CreateVB(int nPoints,float* pX,float* pY,float* pZ,Color* pC,float* pS);
  69. LPDIRECT3DVERTEXBUFFER9 m_pAxesVB[3];
  70. // Operations
  71. public:
  72. void InterpretError(HRESULT hr) const;
  73. // Overrides
  74. // ClassWizard generated virtual function overrides
  75. //{{AFX_VIRTUAL(C3DWindow)
  76. public:
  77. //}}AFX_VIRTUAL
  78. // Implementation
  79. public:
  80. HRESULT InitDeviceObjects(void);
  81. HRESULT DeleteDeviceObjects(void);
  82. HRESULT RenderText(void);
  83. CString m_strTopRightTextLine1;
  84. CString m_strTopLeftTextLine1;
  85. CString m_strBottomLeftTextLine1;
  86. static BOOL m_Registered;
  87. static BOOL m_bInhibitUpdate;
  88. static LRESULT CALLBACK Window3DWndProc(HWND, UINT, WPARAM, LPARAM);
  89. static BOOL Register();
  90. virtual ~C3DWindow();
  91. void ShowMenu(UINT idrMenu);
  92. void SetLightOutput(float fDiffuse,float fAmbient);
  93. HRESULT MakeConeMeshes(float fConeShiftX,float fConeShiftY, float fConeShiftZ);
  94. // Generated message map functions
  95. protected:
  96. //{{AFX_MSG(C3DWindow)
  97. afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
  98. afx_msg void OnDestroy();
  99. afx_msg void OnNcDestroy();
  100. afx_msg void OnRButtonUp(UINT nFlags, CPoint point);
  101. afx_msg void OnInitMenuPopup(CMenu* pPopupMenu, UINT nIndex, BOOL bSysMenu);
  102. //}}AFX_MSG
  103. DECLARE_MESSAGE_MAP()
  104. virtual BOOL OnCommand(WPARAM wParam, LPARAM lParam);
  105. public:
  106. afx_msg void OnPaint();
  107. virtual BOOL PreTranslateMessage(MSG* pMsg);
  108. afx_msg void OnTimer(UINT nIDEvent);
  109. afx_msg void OnMouseMove(UINT nFlags, CPoint point);
  110. afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
  111. afx_msg void OnLButtonUp(UINT nFlags, CPoint point);
  112. afx_msg void OnLButtonDblClk(UINT nFlags, CPoint point);
  113. };
  114. /////////////////////////////////////////////////////////////////////////////
  115. //{{AFX_INSERT_LOCATION}}
  116. // Microsoft Visual C++ will insert additional declarations immediately before the previous line.
  117. #endif // !defined(AFX_3DWINDOWSMALL_H__147F5773_11F0_11D4_90C3_00AA00597E76__INCLUDED_)