BilliardsPlayView.h
上传用户:sycq158
上传日期:2008-10-22
资源大小:15361k
文件大小:4k
源码类别:

游戏

开发平台:

Visual C++

  1. #if !defined(AFX_BILLIARDSPLAYVIEW_H__F1742F84_AF33_446D_A3A0_AF8DCD1A1C81__INCLUDED_)
  2. #define AFX_BILLIARDSPLAYVIEW_H__F1742F84_AF33_446D_A3A0_AF8DCD1A1C81__INCLUDED_
  3. #if _MSC_VER > 1000
  4. #pragma once
  5. #endif // _MSC_VER > 1000
  6. // BilliardsPlayView.h : header file
  7. #include "Transform.h"
  8. //
  9. #define INFINITY  100000 
  10. #define MOUSE_SELECT 0
  11. #define MOUSE_SPIN 1
  12. #define MOUSE_TRANSLATE 2
  13. #define MOUSE_ZOOM 3
  14. #define ANIMATE_TIMER 1
  15. #define M_PI 3.141592653f    
  16. #define NUM_BALL 16
  17. #define BALL_RADIUS 3.0f
  18. #define TABLE_WIDTH 50.0f
  19. #define TABLE_LENGTH 100.0f
  20. #define TABLE_HEIGHT 3.0f
  21. #define HOLE_RADIUS 1.5f
  22. #define BAR_WIDTH 3.0f
  23. #define BAR_HEIGHT 5.0f
  24. #define POLE_HEIGHT 28.0f
  25. #define POLE_RADIUS 4.0f
  26. #define ACCELERATION -0.04f //加速度
  27. #define DECR 0.7f
  28. #define DOTPROD3(a, b)  ((a)[0]*(b)[0] + (a)[1]*(b)[1] + (a)[2]*(b)[2])
  29. #define VEC3_V_OP_S(a,b,op,c)  {  (a)[0] = (b)[0] op (c);  
  30.   (a)[1] = (b)[1] op (c);  
  31.   (a)[2] = (b)[2] op (c);  }
  32. #define VEC3_V_OP_V(a,b,op,c)  { (a)[0] = (b)[0] op (c)[0]; 
  33.  (a)[1] = (b)[1] op (c)[1]; 
  34.  (a)[2] = (b)[2] op (c)[2]; 
  35. }
  36. /////////////////////////////////////////////////////////////////////////////
  37. // CBilliardsPlayView view
  38. class CBilliardsPlayView : public CView
  39. {
  40. protected:
  41. CBilliardsPlayView();           // protected constructor used by dynamic creation
  42. DECLARE_DYNCREATE(CBilliardsPlayView)
  43. // Attributes
  44. public:
  45.     HDC m_hDc;
  46. HGLRC m_hRc;
  47. float m_fViewWidth, m_fViewHeight;
  48. float m_fViewNear, m_fViewFar;
  49. float m_vProjectCenter[3];
  50. EYE m_sEye;
  51. float m_spinAxes[3];
  52. float m_spinAngle;
  53.     unsigned int m_SelectBuffer[100];
  54. int m_nSelectObject;
  55. BOOL m_bAnimate;
  56. BOOL m_bCanHit;
  57. int m_nEnter;
  58. float m_fPosition[NUM_BALL][3];
  59. float m_fVelocity[NUM_BALL][3];
  60. BOOL m_bVisible[NUM_BALL];
  61. float m_fDirection[3];
  62. float m_fStrength;
  63.     int m_nMouseAct;
  64.     BOOL m_bLButtonDown;
  65.     float   hitx;
  66.     float   hitz;
  67. // Operations
  68. public:
  69.     void    texinit();
  70.     void    Init();
  71.     void    DrawPlayground();
  72.     void    DrawBall();
  73.     BOOL    SetThePixelFormat(CDC *pDC);
  74. void    Project();
  75.     void    DrawScene();
  76.     int Calculate();
  77.     void    DrawArrow();
  78.     void    HitBall();
  79.     void Translate(float d[3]);
  80. void MouseTranslate(UINT nFlags, int x, int y);
  81. void MouseZoom(UINT nFlags, int x, int y);
  82. void Zoom(float scale);
  83. void MouseSpinGlobal(UINT nFlags, int x, int y, int init);
  84. void SpinGlobal(float axes[3], float angle);
  85.     int MouseSelect(int x, int y);
  86. int GetSelectObjFront(int selecthits, unsigned int *name);
  87. // Overrides
  88. // ClassWizard generated virtual function overrides
  89. //{{AFX_VIRTUAL(CBilliardsPlayView)
  90. protected:
  91. virtual void OnDraw(CDC* pDC);      // overridden to draw this view
  92. virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
  93. //}}AFX_VIRTUAL
  94. // Implementation
  95. protected:
  96. virtual ~CBilliardsPlayView();
  97. #ifdef _DEBUG
  98. virtual void AssertValid() const;
  99. virtual void Dump(CDumpContext& dc) const;
  100. #endif
  101. // Generated message map functions
  102. protected:
  103. //{{AFX_MSG(CBilliardsPlayView)
  104. afx_msg void OnSize(UINT nType, int cx, int cy);
  105. afx_msg BOOL OnEraseBkgnd(CDC* pDC);
  106. afx_msg void OnMouseMove(UINT nFlags, CPoint point);
  107. afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
  108. afx_msg void OnLButtonUp(UINT nFlags, CPoint point);
  109.     afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
  110. afx_msg void OnTimer(UINT nIDEvent);
  111. //}}AFX_MSG
  112. DECLARE_MESSAGE_MAP()
  113. };
  114. /////////////////////////////////////////////////////////////////////////////
  115. //{{AFX_INSERT_LOCATION}}
  116. // Microsoft Visual C++ will insert additional declarations immediately before the previous line.
  117. #endif // !defined(AFX_BILLIARDSPLAYVIEW_H__F1742F84_AF33_446D_A3A0_AF8DCD1A1C81__INCLUDED_)