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

其他书籍

开发平台:

HTML/CSS

  1. // Cone.h: interface for the CCone class.
  2. //
  3. //////////////////////////////////////////////////////////////////////
  4. #if !defined(AFX_CONE_H__8D338063_9E7F_4455_8A3B_394075E29035__INCLUDED_)
  5. #define AFX_CONE_H__8D338063_9E7F_4455_8A3B_394075E29035__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 cone
  12. #define CONE_D3DFVF_CUSTOMVERTEX (D3DFVF_XYZ|D3DFVF_NORMAL|D3DFVF_TEX1)
  13. class CCone : public CBase  
  14. {
  15. private:
  16. //Define a custom vertex for our cone
  17. struct CONE_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. CCone(LPDIRECT3DDEVICE8 pD3DDevice, float rHeight = 1.0, float rRadius = 1.0, int nSegments = 20);
  29. virtual ~CCone();
  30. private:
  31. bool UpdateVertices();
  32. bool CreateIndexBuffer();
  33. bool CreateVertexBuffer();
  34. LPDIRECT3DDEVICE8 m_pD3DDevice;
  35. LPDIRECT3DVERTEXBUFFER8 m_pVertexBuffer;
  36. LPDIRECT3DINDEXBUFFER8 m_pIndexBuffer;
  37. LPDIRECT3DTEXTURE8 m_pSideTexture;
  38. LPDIRECT3DTEXTURE8 m_pEndTexture;
  39. D3DMATERIAL8 m_matMaterial;
  40. float m_rHeight;
  41. float m_rRadius;
  42. int m_nSegments;
  43. DWORD m_dwNumOfIndices;
  44. DWORD m_dwNumOfVertices;
  45. DWORD m_dwNumOfSidePolygons;
  46. DWORD m_dwNumOfEndPolygons;
  47. };
  48. #endif // !defined(AFX_CONE_H__8D338063_9E7F_4455_8A3B_394075E29035__INCLUDED_)