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

其他书籍

开发平台:

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 <d3dx8.h>
  10. #include "Helper.h"
  11. //Define a FVF for our cubiods
  12. #define CUBIOD_D3DFVF_CUSTOMVERTEX (D3DFVF_XYZ|D3DFVF_DIFFUSE|D3DFVF_TEX1)
  13. class CCuboid  
  14. {
  15. public:
  16. bool SetTexture(const char* szTextureFilePath);
  17. bool SetPosition(float x, float y, float z);
  18. bool SetSize(float rWidth, float rHeight, float rDepth);
  19. bool Render();
  20. CCuboid(LPDIRECT3DDEVICE8 pD3DDevice);
  21. virtual ~CCuboid();
  22. private:
  23. bool UpdateVertices();
  24. HRESULT CreateVertexBuffer();
  25. LPDIRECT3DDEVICE8 m_pD3DDevice;
  26. LPDIRECT3DVERTEXBUFFER8 m_pVertexBuffer;
  27. LPDIRECT3DTEXTURE8 m_pTexture;
  28. float m_rWidth;
  29. float m_rHeight;
  30. float m_rDepth;
  31. float m_rX;
  32. float m_rY;
  33. float m_rZ;
  34. //Define a custom vertex for our cubiods
  35. struct CUBIOD_CUSTOMVERTEX
  36. {
  37. FLOAT x, y, z; //Position of vertex in 3D space
  38. DWORD colour; //Colour of vertex
  39. FLOAT tu, tv; //Texture coordinates
  40. };
  41. };
  42. #endif // !defined(AFX_CUBOID_H__AE25AF5F_AE56_48F5_99DC_47CAAA14F245__INCLUDED_)