home *** CD-ROM | disk | FTP | other *** search
/ Programming an RTS Game with Direct3D / Programming an RTS Game with Direct3D.iso / Examples / Chapter 4 / Example 4.4 / terrain.h < prev   
Encoding:
C/C++ Source or Header  |  2006-06-28  |  999 b   |  55 lines

  1. #ifndef _TERRAIN_
  2. #define _TERRAIN_
  3.  
  4. #include <d3dx9.h>
  5. #include <vector>
  6. #include "heightmap.h"
  7. #include "debug.h"
  8.  
  9. struct TERRAINVertex
  10. {
  11.     TERRAINVertex(){}
  12.     TERRAINVertex(D3DXVECTOR3 pos, D3DCOLOR col)
  13.     {
  14.         position = pos;
  15.         color = col;
  16.         normal = D3DXVECTOR3(0.0f, 1.0f, 0.0f);
  17.     }
  18.  
  19.     D3DXVECTOR3 position, normal;
  20.     D3DCOLOR color;
  21.  
  22.     static const DWORD FVF;
  23. };
  24.  
  25. struct PATCH{
  26.     PATCH();
  27.     ~PATCH();
  28.     void Release();
  29.     HRESULT CreateMesh(HEIGHTMAP &hm, RECT source, IDirect3DDevice9* Dev, int index);
  30.     void Render();
  31.  
  32.     IDirect3DDevice9* m_pDevice;
  33.     ID3DXMesh *m_pMesh;
  34. };
  35.  
  36. class TERRAIN{
  37.     friend class APPLICATION;
  38.     public:
  39.         TERRAIN();        
  40.         void Init(IDirect3DDevice9* Dev, INTPOINT _size);
  41.         void Release();
  42.         void GenerateRandomTerrain(int numPatches);
  43.         void CreatePatches(int numPatches);
  44.         void Render();        
  45.  
  46.     private:
  47.  
  48.         INTPOINT m_size;
  49.         IDirect3DDevice9* m_pDevice; 
  50.  
  51.         HEIGHTMAP *m_pHeightMap;
  52.         std::vector<PATCH*> m_patches;
  53. };
  54.  
  55. #endif