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

其他书籍

开发平台:

HTML/CSS

  1. // Cylinder.h: interface for the CCylinder class.
  2. //
  3. //////////////////////////////////////////////////////////////////////
  4. #if !defined(AFX_CYLINDER_H__F7B8B61C_6337_483D_A227_A28ECF766D93__INCLUDED_)
  5. #define AFX_CYLINDER_H__F7B8B61C_6337_483D_A227_A28ECF766D93__INCLUDED_
  6. #if _MSC_VER > 1000
  7. #pragma once
  8. #endif // _MSC_VER > 1000
  9. #include <d3dx8.h>
  10. #include "Base.h"
  11. //Define a FVF for our cylinder
  12. #define CYLINDER_D3DFVF_CUSTOMVERTEX (D3DFVF_XYZ|D3DFVF_NORMAL|D3DFVF_TEX1)
  13. class CCylinder : public CBase  
  14. {
  15. private:
  16. //Define a custom vertex for our cylinder
  17. struct CYLINDER_CUSTOMVERTEX
  18. {
  19. FLOAT x, y, z; //Position of vertex in 3D space
  20. FLOAT nx, ny, nz; //Lighting Normal
  21. FLOAT tu, tv; //Texture coordinates
  22. };
  23. public:
  24. bool SetMaterial(D3DCOLORVALUE rgbaDiffuse, D3DCOLORVALUE rgbaAmbient, D3DCOLORVALUE rgbaSpecular, D3DCOLORVALUE rgbaEmissive, float rPower);
  25. bool SetSideTexture(const char* szTextureFilePath);
  26. bool SetEndTexture(const char* szTextureFilePath);
  27. DWORD Render();
  28. CCylinder(LPDIRECT3DDEVICE8 pD3DDevice, float rHeight = 1.0, float rRadius = 1.0, int nSegments = 20);
  29. virtual ~CCylinder();
  30. private:
  31. bool UpdateVertices();
  32. bool CreateVertexBuffer();
  33. LPDIRECT3DDEVICE8 m_pD3DDevice;
  34. LPDIRECT3DVERTEXBUFFER8 m_pVertexBuffer;
  35. LPDIRECT3DTEXTURE8 m_pSideTexture;
  36. LPDIRECT3DTEXTURE8 m_pEndTexture;
  37. D3DMATERIAL8 m_matMaterial;
  38. float m_rHeight;
  39. float m_rRadius;
  40. int m_nSegments; 
  41. DWORD m_dwNumOfVertices;
  42. DWORD m_dwNumOfSidePolygons;
  43. DWORD m_dwNumOfEndPolygons;
  44. };
  45. #endif // !defined(AFX_CYLINDER_H__F7B8B61C_6337_483D_A227_A28ECF766D93__INCLUDED_)