Cuboid.h
上传用户:whgydz
上传日期:2007-01-12
资源大小:2259k
文件大小:2k
源码类别:

其他书籍

开发平台:

HTML/CSS

  1. // Cuboid.h: interface for the CCuboid class.
  2. //
  3. //////////////////////////////////////////////////////////////////////
  4. #if !defined(AFX_CUBOID_H__AE25AF5F_AE56_48F5_99DC_47CAAA14F245__INCLUDED_)
  5. #define AFX_CUBOID_H__AE25AF5F_AE56_48F5_99DC_47CAAA14F245__INCLUDED_
  6. #if _MSC_VER > 1000
  7. #pragma once
  8. #endif // _MSC_VER > 1000
  9. #include "Base.h"
  10. //Define a FVF for our cubiods
  11. #define CUBOID_D3DFVF_CUSTOMVERTEX (D3DFVF_XYZ|D3DFVF_NORMAL|D3DFVF_TEX1)
  12. class CCuboid : public CBase
  13. {
  14. private:
  15. //Define a custom vertex for our cubiods
  16. struct CUBOID_CUSTOMVERTEX
  17. {
  18. FLOAT x, y, z; //Position of vertex in 3D space
  19. FLOAT nx, ny, nz; //Lighting Normal
  20. FLOAT tu, tv; //Texture coordinates
  21. };
  22. public:
  23. bool SetMaterial(D3DCOLORVALUE rgbaDiffuse, D3DCOLORVALUE rgbaAmbient, D3DCOLORVALUE rgbaSpecular, D3DCOLORVALUE rgbaEmissive, float rPower);
  24. bool SetTexture(const char* szTextureFilePath);
  25. DWORD Render();
  26. CCuboid(LPDIRECT3DDEVICE8 pD3DDevice, float rWidth = 1.0, float rHeight = 1.0, float rDepth = 1.0);
  27. virtual ~CCuboid();
  28. private:
  29. bool CreateIndexBuffer();
  30. bool UpdateVertices();
  31. bool CreateVertexBuffer();
  32. LPDIRECT3DDEVICE8 m_pD3DDevice;
  33. LPDIRECT3DVERTEXBUFFER8 m_pVertexBuffer;
  34. LPDIRECT3DTEXTURE8 m_pTexture;
  35. D3DMATERIAL8 m_matMaterial;
  36. LPDIRECT3DINDEXBUFFER8 m_pIndexBuffer;
  37. float m_rWidth;
  38. float m_rHeight;
  39. float m_rDepth;
  40. DWORD m_dwNumOfVertices;
  41. DWORD m_dwNumOfIndices;
  42. DWORD m_dwNumOfPolygons;
  43. };
  44. #endif // !defined(AFX_CUBOID_H__AE25AF5F_AE56_48F5_99DC_47CAAA14F245__INCLUDED_)