⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 billiardsplayview.h

📁 桌面台球3D 开发环境VC 库DIRECTX8.1以上
💻 H
字号:
#if !defined(AFX_BILLIARDSPLAYVIEW_H__F1742F84_AF33_446D_A3A0_AF8DCD1A1C81__INCLUDED_)
#define AFX_BILLIARDSPLAYVIEW_H__F1742F84_AF33_446D_A3A0_AF8DCD1A1C81__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
// BilliardsPlayView.h : header file
#include "Transform.h"

//
#define INFINITY  100000 

#define	MOUSE_SELECT	0
#define	MOUSE_SPIN		1
#define	MOUSE_TRANSLATE	2
#define	MOUSE_ZOOM		3

#define	ANIMATE_TIMER	1

#define	M_PI			3.141592653f    
#define	NUM_BALL		16
#define	BALL_RADIUS		3.0f
#define	TABLE_WIDTH		50.0f
#define	TABLE_LENGTH	100.0f
#define	TABLE_HEIGHT	3.0f
#define	HOLE_RADIUS		1.5f
#define	BAR_WIDTH		3.0f
#define	BAR_HEIGHT		5.0f
#define	POLE_HEIGHT		28.0f
#define	POLE_RADIUS		4.0f
#define	ACCELERATION	-0.04f		//加速度
#define	DECR			0.7f

#define DOTPROD3(a, b)		 ((a)[0]*(b)[0] + (a)[1]*(b)[1] + (a)[2]*(b)[2])
#define VEC3_V_OP_S(a,b,op,c)  {  (a)[0] = (b)[0] op (c);  \
				  (a)[1] = (b)[1] op (c);  \
				  (a)[2] = (b)[2] op (c);  }
#define VEC3_V_OP_V(a,b,op,c)  { (a)[0] = (b)[0] op (c)[0]; \
				 (a)[1] = (b)[1] op (c)[1]; \
				 (a)[2] = (b)[2] op (c)[2]; \
				}



/////////////////////////////////////////////////////////////////////////////
// CBilliardsPlayView view

class CBilliardsPlayView : public CView
{
protected:
	CBilliardsPlayView();           // protected constructor used by dynamic creation
	DECLARE_DYNCREATE(CBilliardsPlayView)

// Attributes
public:
    HDC		m_hDc;
	HGLRC	m_hRc;
	float	m_fViewWidth, m_fViewHeight;
	float	m_fViewNear, m_fViewFar;

	
	float	m_vProjectCenter[3];
	EYE		m_sEye;
	float	m_spinAxes[3];
	float	m_spinAngle;

    unsigned int	m_SelectBuffer[100];
	int				m_nSelectObject;

	BOOL	m_bAnimate;
	BOOL	m_bCanHit;
	int		m_nEnter;

	float	m_fPosition[NUM_BALL][3];
	float	m_fVelocity[NUM_BALL][3];
	BOOL	m_bVisible[NUM_BALL];
	float	m_fDirection[3];
	float	m_fStrength;

    int		m_nMouseAct;

    BOOL	m_bLButtonDown;

    float   hitx;
    float   hitz;
// Operations
public:
    void    texinit();
    void    Init();
    void    DrawPlayground();
    void    DrawBall();
    BOOL    SetThePixelFormat(CDC *pDC);
	void    Project();
    void    DrawScene();
    int		Calculate();
    void    DrawArrow();
    void    HitBall();

    void	Translate(float d[3]);
	void	MouseTranslate(UINT nFlags, int x, int y);
	void	MouseZoom(UINT nFlags, int x, int y);
	void	Zoom(float scale);
	void	MouseSpinGlobal(UINT nFlags, int x, int y, int init);
	void	SpinGlobal(float axes[3], float angle);

    int		MouseSelect(int x, int y);
	int		GetSelectObjFront(int selecthits, unsigned int *name);


// Overrides
	// ClassWizard generated virtual function overrides
	//{{AFX_VIRTUAL(CBilliardsPlayView)
	protected:
	virtual void OnDraw(CDC* pDC);      // overridden to draw this view
	virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
	//}}AFX_VIRTUAL

// Implementation
protected:
	virtual ~CBilliardsPlayView();
#ifdef _DEBUG
	virtual void AssertValid() const;
	virtual void Dump(CDumpContext& dc) const;
#endif

	// Generated message map functions
protected:
	//{{AFX_MSG(CBilliardsPlayView)
	afx_msg void OnSize(UINT nType, int cx, int cy);
	afx_msg BOOL OnEraseBkgnd(CDC* pDC);
	afx_msg void OnMouseMove(UINT nFlags, CPoint point);
	afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
	afx_msg void OnLButtonUp(UINT nFlags, CPoint point);
    afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
	afx_msg void OnTimer(UINT nIDEvent);
	//}}AFX_MSG
	DECLARE_MESSAGE_MAP()
};

/////////////////////////////////////////////////////////////////////////////

//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.

#endif // !defined(AFX_BILLIARDSPLAYVIEW_H__F1742F84_AF33_446D_A3A0_AF8DCD1A1C81__INCLUDED_)

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -