plane.h
资源名称:Direct3D.rar [点击查看]
上传用户:junlon
上传日期:2022-01-05
资源大小:39075k
文件大小:2k
源码类别:
DirextX编程
开发平台:
Visual C++
- //--------------------------------------------------------------------------------------
- // 文件: plane.h
- //
- // 封装了平面类,该平面由 m_iWidthSampleNum,m_iHeightSampleNum 个顶点组成,两个对角顶点分别为
- //
- // m_leftBottomPt和m_rightUpPt, 该平面与水平面平行,所以输入的两个顶点必须高度一致,否则报错
- //
- // 版权归子墨工作室所有
- //--------------------------------------------------------------------------------------
- #ifndef __PLANE__H__INCLUDED__
- #define __PLANE__H__INCLUDED__
- //#define PLANEWIDTH 4.0f
- //#define PLANEHEIGHT 4.0f
- class CPlane
- {
- public:
- CPlane( WORD widthSampleNum, //widthSampleNum - 1 等于平面在X轴上的分段数
- WORD heightSampleNum, //heightSampleNum - 1等于平面在Y轴上的分段数
- D3DXVECTOR3 leftBottomPt, //平面的左下角顶点
- D3DXVECTOR3 rightUpPt ); //平面的右上角顶点
- ~CPlane();
- protected:
- LPDIRECT3DVERTEXBUFFER9 m_pVB;
- LPDIRECT3DINDEXBUFFER9 m_pIB;
- LPDIRECT3DTEXTURE9 m_pTexture;
- // 现假设平面与XOZ平面平行,所以 m_leftBottomPt.y == m_rightUpPt.y
- D3DXVECTOR3 m_leftBottomPt, m_rightUpPt;
- WORD m_iWidthSampleNum;
- WORD m_iHeightSampleNum;
- public:
- HRESULT OnCreateDevice( IDirect3DDevice9* pd3dDevice );
- void OnDestroyDevice();
- void OnRender( IDirect3DDevice9* pd3dDevice );
- };
- typedef struct tagPLANEVERTEX{
- D3DXVECTOR3 position; // The position of the vertex.
- D3DXVECTOR3 normal; // The nomal Vector.
- D3DCOLOR color; // The color
- FLOAT tu, tv; // The texture coordinates
- // static const DWORD FVF;
- }PLANEVERTEX;
- #define D3D_PLANEVT_FVF D3DFVF_XYZ|D3DFVF_NORMAL|D3DFVF_DIFFUSE|D3DFVF_TEX1
- #endif //__PLANE__H__INCLUDED__